Skip to content

Conversation

@cemozerr
Copy link
Member

Description

Related Issues

Checklist

@changeset-bot
Copy link

changeset-bot bot commented Jul 28, 2025

⚠️ No Changeset found

Latest commit: c860d83

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cemozerr cemozerr requested a review from ross-weir July 28, 2025 20:12
Copy link
Member

@ross-weir ross-weir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this should be a Signer impl we provide in our package, its much larger in scope then the other signers that complete almost immediately and just sign some data. This one can potentially block for a long time and there's no recovery mechanism if it's interrupted in some way

I feel like this would be better suited as a standalone script utility, thoughts?

import { keccak_256 } from "@noble/hashes/sha3";

// --- Turnkey Configuration ---
const ORG_ID = process.env.TURNKEY_ORG_ID;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please move all the env vars to a configuration object instead. This way we don't control how and where these need to be configured we just receive them as parameters

Same as what the actual turnkey client does: https://github.com/Sovereign-Labs/sovereign-sdk-web3-js/pull/189/files#diff-79afd446c73470ec4aea9d8ad8aa8ba905213d5323795579e1c7ad5f78530665R49


// Bind `this` to the methods to ensure the context is not lost
// when they are called by the Sovereign SDK.
this.sign = this.sign.bind(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldnt be needed?

}

public static async create(): Promise<TurnkeySecp256k1Signer> {
if (!/^[0-9a-fA-F]+$/.test(API_PRIVATE_KEY!)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove these formatting checks, we won't always know the shape of their API keys and their API will return a error if they're malformed

});

// Poll every 60s until COMPLETED
while (true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the program that's running this exits or crashes, etc? We currently have no way to resume a sign request or recover

// Helper function to wait for a certain amount of time.
const wait = (ms: number) => new Promise(r => setTimeout(r, ms));

export class TurnkeySecp256k1Signer implements Signer {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this in some way specific to secp256k1? It seems like we're call sign with a specific key id which could be any kind of key? If it's not specific lets just call it TurnkeySigner

package.json Outdated
"dependencies": {
"@changesets/cli": "^2.27.9"
"@changesets/cli": "^2.27.9",
"@turnkey/api-key-stamper": "^0.4.7",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move these new dependencies to packages/signers/package.json

import { TurnkeyClient } from "@turnkey/http";
import { ApiKeyStamper } from "@turnkey/api-key-stamper";
import { ethers } from "ethers"; // v6 helpers
import 'dotenv/config';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env vars wont always be defined in a .env file, we shouldn't control loading env vars in library code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants