@dynamic-labs-wallet/node-svm 0.0.353 → 0.1.0-request-signing
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +1130 -235
- package/index.esm.js +1127 -238
- package/package.json +3 -3
- package/src/client/client.d.ts +172 -36
- package/src/client/client.d.ts.map +1 -1
- package/src/client/confidentialCheck.d.ts +27 -0
- package/src/client/confidentialCheck.d.ts.map +1 -0
- package/src/client/earn.client.d.ts +56 -0
- package/src/client/earn.client.d.ts.map +1 -0
- package/src/client/earn.constants.d.ts +9 -0
- package/src/client/earn.constants.d.ts.map +1 -0
- package/src/client/earn.types.d.ts +41 -0
- package/src/client/earn.types.d.ts.map +1 -0
- package/src/client/index.d.ts +3 -0
- package/src/client/index.d.ts.map +1 -1
- package/src/delegatedClient.d.ts +61 -56
- package/src/delegatedClient.d.ts.map +1 -1
package/src/delegatedClient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DelegatedWalletClient, ServerKeyShare } from '@dynamic-labs-wallet/node';
|
|
1
|
+
import type { DelegatedWalletClient, RawSignPreImage, ServerKeyShare, TraceContext, SignMessageContext } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import type { Transaction } from '@solana/web3.js';
|
|
3
3
|
import { VersionedTransaction } from '@solana/web3.js';
|
|
4
4
|
export type DelegatedSvmClientConfig = {
|
|
@@ -7,6 +7,8 @@ export type DelegatedSvmClientConfig = {
|
|
|
7
7
|
baseMPCRelayApiUrl?: string;
|
|
8
8
|
apiKey: string;
|
|
9
9
|
debug?: boolean;
|
|
10
|
+
/** @default true — see `CoreConfig.errorLogging` */
|
|
11
|
+
errorLogging?: boolean;
|
|
10
12
|
};
|
|
11
13
|
export type DelegatedSvmWalletClient = DelegatedWalletClient & {
|
|
12
14
|
readonly chainName: 'SVM';
|
|
@@ -14,63 +16,57 @@ export type DelegatedSvmWalletClient = DelegatedWalletClient & {
|
|
|
14
16
|
/**
|
|
15
17
|
* Creates a delegated SVM wallet client for functional operations
|
|
16
18
|
*/
|
|
17
|
-
export declare const createDelegatedSvmWalletClient: ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug, }: DelegatedSvmClientConfig) => DelegatedSvmWalletClient;
|
|
19
|
+
export declare const createDelegatedSvmWalletClient: ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug, errorLogging, }: DelegatedSvmClientConfig) => DelegatedSvmWalletClient;
|
|
18
20
|
/**
|
|
19
21
|
* Signs a message using delegated signing for SVM
|
|
20
22
|
*/
|
|
21
|
-
export declare const delegatedSignMessage: (client: DelegatedSvmWalletClient, { walletId, walletApiKey, keyShare, message, isFormatted, }: {
|
|
23
|
+
export declare const delegatedSignMessage: (client: DelegatedSvmWalletClient, { walletId, shareSetId, walletApiKey, keyShare, message, derivationPath, isFormatted, context, onError, }: {
|
|
22
24
|
walletId: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional. The `shareSetId` from the `wallet.delegation.created`
|
|
27
|
+
* webhook payload — a `WaasWallets.id`. NOT `keyShares[].id` from
|
|
28
|
+
* `byWalletAddress` (that's a `WalletKeyShares.id`, a different
|
|
29
|
+
* primary key). Omit and the server resolves the right share set
|
|
30
|
+
* by walletId + shareSetType.
|
|
31
|
+
*/
|
|
32
|
+
shareSetId?: string;
|
|
23
33
|
walletApiKey: string;
|
|
24
34
|
keyShare: ServerKeyShare;
|
|
25
35
|
message: string;
|
|
36
|
+
derivationPath?: Uint32Array;
|
|
26
37
|
isFormatted?: boolean;
|
|
38
|
+
context?: SignMessageContext;
|
|
39
|
+
onError?: (error: Error) => void;
|
|
27
40
|
}) => Promise<string>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* @param options.keyShare - The server key share
|
|
36
|
-
* @param options.transaction - The transaction to sign (VersionedTransaction or Transaction)
|
|
37
|
-
* @param options.signerAddress - Optional. The address that should sign the transaction.
|
|
38
|
-
* If not provided, defaults to the first signer (VersionedTransaction)
|
|
39
|
-
* or fee payer (Transaction). Use this for gasless transactions where
|
|
40
|
-
* a separate fee payer pays the fees.
|
|
41
|
-
*
|
|
42
|
-
* @returns The partially signed transaction with the signature attached for the specified signer
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* // Standard transaction where sender is also fee payer
|
|
46
|
-
* const signedTx = await delegatedSignTransaction(client, {
|
|
47
|
-
* walletId,
|
|
48
|
-
* walletApiKey,
|
|
49
|
-
* keyShare,
|
|
50
|
-
* transaction,
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* // Gasless transaction with separate fee payer
|
|
55
|
-
* const transaction = new Transaction();
|
|
56
|
-
* transaction.feePayer = feePayerPublicKey; // Set the actual fee payer
|
|
57
|
-
* transaction.add(instruction); // Instruction that requires sender signature
|
|
58
|
-
*
|
|
59
|
-
* const signedTx = await delegatedSignTransaction(client, {
|
|
60
|
-
* walletId,
|
|
61
|
-
* walletApiKey,
|
|
62
|
-
* keyShare,
|
|
63
|
-
* transaction,
|
|
64
|
-
* signerAddress: senderAddress, // Explicitly specify who signs
|
|
65
|
-
* });
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient, { walletId, walletApiKey, keyShare, transaction, signerAddress, }: {
|
|
41
|
+
export declare const delegatedSponsorTransaction: (client: DelegatedSvmWalletClient, { transaction, userId, traceContext, }: {
|
|
42
|
+
transaction: VersionedTransaction | Transaction;
|
|
43
|
+
userId: string;
|
|
44
|
+
traceContext?: TraceContext;
|
|
45
|
+
}) => Promise<VersionedTransaction>;
|
|
46
|
+
export declare const ERROR_DELEGATED_SIGN_TRANSACTION_CONTEXT_REQUIRED = "SVM transaction signing requires a chainId or an explicit context.svmTransaction.";
|
|
47
|
+
export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient, { walletId, shareSetId, walletApiKey, keyShare, transaction, signerAddress, derivationPath, chainId, context, sponsor, userId, traceContext, onError, }: {
|
|
69
48
|
walletId: string;
|
|
49
|
+
/**
|
|
50
|
+
* Optional. The `shareSetId` from the `wallet.delegation.created`
|
|
51
|
+
* webhook payload — a `WaasWallets.id`. NOT `keyShares[].id` from
|
|
52
|
+
* `byWalletAddress` (that's a `WalletKeyShares.id`, a different
|
|
53
|
+
* primary key). Omit and the server resolves the right share set
|
|
54
|
+
* by walletId + shareSetType.
|
|
55
|
+
*/
|
|
56
|
+
shareSetId?: string;
|
|
70
57
|
walletApiKey: string;
|
|
71
58
|
keyShare: any;
|
|
72
59
|
transaction: VersionedTransaction | Transaction;
|
|
73
60
|
signerAddress?: string;
|
|
61
|
+
derivationPath?: Uint32Array;
|
|
62
|
+
chainId?: string;
|
|
63
|
+
context?: SignMessageContext;
|
|
64
|
+
/** If true, sponsors the transaction (swapping its fee payer) before signing. */
|
|
65
|
+
sponsor?: boolean;
|
|
66
|
+
/** Required when `sponsor` is true. UUID of the wallet's owner. */
|
|
67
|
+
userId?: string;
|
|
68
|
+
traceContext?: TraceContext;
|
|
69
|
+
onError?: (error: Error) => void;
|
|
74
70
|
}) => Promise<VersionedTransaction | Transaction>;
|
|
75
71
|
/**
|
|
76
72
|
* Signs a pre-formatted (raw) message using delegated signing for SVM.
|
|
@@ -82,38 +78,47 @@ export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient
|
|
|
82
78
|
* @param options.walletApiKey - The wallet API key
|
|
83
79
|
* @param options.keyShare - The server key share
|
|
84
80
|
* @param options.message - Hex string of the already-hashed data to sign
|
|
81
|
+
* @param options.rawSign - Pre-image the digest is derived from, used to build the policy context
|
|
82
|
+
* @param options.context - Explicit policy context, when the caller builds one itself
|
|
85
83
|
*
|
|
86
84
|
* @returns The base58-encoded signature
|
|
87
85
|
*
|
|
88
86
|
* @example
|
|
89
|
-
* // Sign a pre-hashed message
|
|
90
|
-
* const signature = await delegatedSignRawMessage(client, {
|
|
91
|
-
* walletId,
|
|
92
|
-
* walletApiKey,
|
|
93
|
-
* keyShare,
|
|
94
|
-
* message: preHashedHex, // hex string of already-hashed data
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
87
|
* // Sign a SHA-256 hash derived from arbitrary application data
|
|
99
88
|
* import { createHash } from 'crypto';
|
|
100
|
-
* const
|
|
89
|
+
* const payload = Buffer.from('my application data', 'utf8').toString('hex');
|
|
90
|
+
* const hash = createHash('sha256').update(Buffer.from(payload, 'hex')).digest('hex');
|
|
101
91
|
* const signature = await delegatedSignRawMessage(client, {
|
|
102
92
|
* walletId,
|
|
103
93
|
* walletApiKey,
|
|
104
94
|
* keyShare,
|
|
105
95
|
* message: hash,
|
|
96
|
+
* rawSign: { hashFunction: SignMessageRawSignHashFunctionEnum.Sha256, payload },
|
|
106
97
|
* });
|
|
107
98
|
*
|
|
108
99
|
*/
|
|
109
|
-
export declare const delegatedSignRawMessage: (client: DelegatedSvmWalletClient, { walletId, walletApiKey, keyShare, message, }: {
|
|
100
|
+
export declare const delegatedSignRawMessage: (client: DelegatedSvmWalletClient, { walletId, shareSetId, walletApiKey, keyShare, message, derivationPath, context, rawSign, onError, }: {
|
|
110
101
|
walletId: string;
|
|
102
|
+
/**
|
|
103
|
+
* Optional. The `shareSetId` from the `wallet.delegation.created`
|
|
104
|
+
* webhook payload — a `WaasWallets.id`. NOT `keyShares[].id` from
|
|
105
|
+
* `byWalletAddress` (that's a `WalletKeyShares.id`, a different
|
|
106
|
+
* primary key). Omit and the server resolves the right share set
|
|
107
|
+
* by walletId + shareSetType.
|
|
108
|
+
*/
|
|
109
|
+
shareSetId?: string;
|
|
111
110
|
walletApiKey: string;
|
|
112
111
|
keyShare: ServerKeyShare;
|
|
113
112
|
message: string;
|
|
113
|
+
derivationPath?: Uint32Array;
|
|
114
|
+
context?: SignMessageContext;
|
|
115
|
+
rawSign?: RawSignPreImage;
|
|
116
|
+
onError?: (error: Error) => void;
|
|
114
117
|
}) => Promise<string>;
|
|
115
118
|
/**
|
|
116
119
|
* Revoke delegation - delegates to the node package
|
|
117
120
|
*/
|
|
118
|
-
export declare const revokeDelegation: (client: DelegatedSvmWalletClient,
|
|
121
|
+
export declare const revokeDelegation: (client: DelegatedSvmWalletClient, { walletId }: {
|
|
122
|
+
walletId: string;
|
|
123
|
+
}) => Promise<void>;
|
|
119
124
|
//# sourceMappingURL=delegatedClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegatedClient.d.ts","sourceRoot":"","sources":["../../packages/src/delegatedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"delegatedClient.d.ts","sourceRoot":"","sources":["../../packages/src/delegatedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AAYnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAa,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAMlE,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oDAAoD;IACpD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,GAAG;IAC7D,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,oFAOxC,wBAAwB,KAAG,wBAW7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,wBAAwB,6GAW7B;IACD,QA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