@dynamic-labs-wallet/node-svm 1.0.0 → 1.0.1
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 +22 -14
- package/index.esm.js +22 -14
- package/package.json +2 -2
- package/src/delegatedClient.d.ts +12 -4
- package/src/delegatedClient.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -520,27 +520,28 @@ const logError = node.createLogError('node-svm');
|
|
|
520
520
|
apiKey,
|
|
521
521
|
debug
|
|
522
522
|
});
|
|
523
|
-
|
|
523
|
+
return _extends({}, baseClient, {
|
|
524
524
|
chainName: 'SVM'
|
|
525
525
|
});
|
|
526
|
-
return svmClient;
|
|
527
526
|
};
|
|
528
527
|
/**
|
|
529
528
|
* Signs a message using delegated signing for SVM
|
|
530
|
-
*/ const delegatedSignMessage = async (client, { walletId, walletApiKey, keyShare, message, isFormatted = false })=>{
|
|
529
|
+
*/ const delegatedSignMessage = async (client, { walletId, shareSetId, walletApiKey, keyShare, message, derivationPath, isFormatted = false })=>{
|
|
531
530
|
try {
|
|
532
|
-
|
|
531
|
+
if (!keyShare || !walletId || !walletApiKey) {
|
|
532
|
+
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a message');
|
|
533
|
+
}
|
|
533
534
|
const signatureEd25519 = await node.delegatedSignMessage(client, {
|
|
534
535
|
walletId,
|
|
536
|
+
shareSetId,
|
|
535
537
|
walletApiKey,
|
|
536
538
|
keyShare,
|
|
537
539
|
message,
|
|
538
540
|
chainName: client.chainName,
|
|
541
|
+
derivationPath,
|
|
539
542
|
isFormatted
|
|
540
543
|
});
|
|
541
|
-
|
|
542
|
-
const base58Signature = encodeBase58(signatureEd25519);
|
|
543
|
-
return base58Signature;
|
|
544
|
+
return encodeBase58(signatureEd25519);
|
|
544
545
|
} catch (error) {
|
|
545
546
|
logError({
|
|
546
547
|
message: 'Error in delegatedSignMessage',
|
|
@@ -591,8 +592,11 @@ const logError = node.createLogError('node-svm');
|
|
|
591
592
|
* signerAddress: senderAddress, // Explicitly specify who signs
|
|
592
593
|
* });
|
|
593
594
|
*
|
|
594
|
-
*/ const delegatedSignTransaction = async (client, { walletId, walletApiKey, keyShare, transaction, signerAddress })=>{
|
|
595
|
+
*/ const delegatedSignTransaction = async (client, { walletId, shareSetId, walletApiKey, keyShare, transaction, signerAddress, derivationPath })=>{
|
|
595
596
|
try {
|
|
597
|
+
if (!keyShare || !walletId || !walletApiKey) {
|
|
598
|
+
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a transaction');
|
|
599
|
+
}
|
|
596
600
|
let messageToSign;
|
|
597
601
|
if (transaction instanceof web3_js.VersionedTransaction) {
|
|
598
602
|
// For versioned transactions, we need to sign the message directly
|
|
@@ -603,13 +607,14 @@ const logError = node.createLogError('node-svm');
|
|
|
603
607
|
const messageBytes = transaction.serializeMessage();
|
|
604
608
|
messageToSign = messageBytes.toString('hex');
|
|
605
609
|
}
|
|
606
|
-
// Use the delegated sign message function from node package
|
|
607
610
|
const signatureEd25519 = await node.delegatedSignMessage(client, {
|
|
608
611
|
walletId,
|
|
612
|
+
shareSetId,
|
|
609
613
|
walletApiKey,
|
|
610
614
|
keyShare,
|
|
611
615
|
message: messageToSign,
|
|
612
616
|
chainName: client.chainName,
|
|
617
|
+
derivationPath,
|
|
613
618
|
isFormatted: false
|
|
614
619
|
});
|
|
615
620
|
if (!signatureEd25519) {
|
|
@@ -635,12 +640,11 @@ const logError = node.createLogError('node-svm');
|
|
|
635
640
|
} catch (error) {
|
|
636
641
|
throw new Error(`Invalid signer address: ${resolvedSignerAddress}. ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
637
642
|
}
|
|
638
|
-
|
|
643
|
+
return addSignatureToTransaction({
|
|
639
644
|
transaction,
|
|
640
645
|
signature: signatureEd25519,
|
|
641
646
|
signerPublicKey
|
|
642
647
|
});
|
|
643
|
-
return signedTransaction;
|
|
644
648
|
} catch (error) {
|
|
645
649
|
logError({
|
|
646
650
|
message: 'Error in delegatedSignTransaction',
|
|
@@ -685,16 +689,18 @@ const logError = node.createLogError('node-svm');
|
|
|
685
689
|
* message: hash,
|
|
686
690
|
* });
|
|
687
691
|
*
|
|
688
|
-
*/ const delegatedSignRawMessage = async (client, { walletId, walletApiKey, keyShare, message })=>{
|
|
692
|
+
*/ const delegatedSignRawMessage = async (client, { walletId, shareSetId, walletApiKey, keyShare, message, derivationPath })=>{
|
|
689
693
|
if (!keyShare || !walletId || !walletApiKey) {
|
|
690
694
|
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a raw message');
|
|
691
695
|
}
|
|
692
696
|
try {
|
|
693
697
|
return await delegatedSignMessage(client, {
|
|
694
698
|
walletId,
|
|
699
|
+
shareSetId,
|
|
695
700
|
walletApiKey,
|
|
696
701
|
keyShare,
|
|
697
702
|
message: node.stripHexPrefix(message),
|
|
703
|
+
derivationPath,
|
|
698
704
|
isFormatted: true
|
|
699
705
|
});
|
|
700
706
|
} catch (error) {
|
|
@@ -710,8 +716,10 @@ const logError = node.createLogError('node-svm');
|
|
|
710
716
|
};
|
|
711
717
|
/**
|
|
712
718
|
* Revoke delegation - delegates to the node package
|
|
713
|
-
*/ const revokeDelegation = async (client,
|
|
714
|
-
return node.revokeDelegation(client,
|
|
719
|
+
*/ const revokeDelegation = async (client, { walletId })=>{
|
|
720
|
+
return node.revokeDelegation(client, {
|
|
721
|
+
walletId
|
|
722
|
+
});
|
|
715
723
|
};
|
|
716
724
|
|
|
717
725
|
exports.DynamicSvmWalletClient = DynamicSvmWalletClient;
|
package/index.esm.js
CHANGED
|
@@ -518,27 +518,28 @@ const logError = createLogError('node-svm');
|
|
|
518
518
|
apiKey,
|
|
519
519
|
debug
|
|
520
520
|
});
|
|
521
|
-
|
|
521
|
+
return _extends({}, baseClient, {
|
|
522
522
|
chainName: 'SVM'
|
|
523
523
|
});
|
|
524
|
-
return svmClient;
|
|
525
524
|
};
|
|
526
525
|
/**
|
|
527
526
|
* Signs a message using delegated signing for SVM
|
|
528
|
-
*/ const delegatedSignMessage = async (client, { walletId, walletApiKey, keyShare, message, isFormatted = false })=>{
|
|
527
|
+
*/ const delegatedSignMessage = async (client, { walletId, shareSetId, walletApiKey, keyShare, message, derivationPath, isFormatted = false })=>{
|
|
529
528
|
try {
|
|
530
|
-
|
|
529
|
+
if (!keyShare || !walletId || !walletApiKey) {
|
|
530
|
+
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a message');
|
|
531
|
+
}
|
|
531
532
|
const signatureEd25519 = await delegatedSignMessage$1(client, {
|
|
532
533
|
walletId,
|
|
534
|
+
shareSetId,
|
|
533
535
|
walletApiKey,
|
|
534
536
|
keyShare,
|
|
535
537
|
message,
|
|
536
538
|
chainName: client.chainName,
|
|
539
|
+
derivationPath,
|
|
537
540
|
isFormatted
|
|
538
541
|
});
|
|
539
|
-
|
|
540
|
-
const base58Signature = encodeBase58(signatureEd25519);
|
|
541
|
-
return base58Signature;
|
|
542
|
+
return encodeBase58(signatureEd25519);
|
|
542
543
|
} catch (error) {
|
|
543
544
|
logError({
|
|
544
545
|
message: 'Error in delegatedSignMessage',
|
|
@@ -589,8 +590,11 @@ const logError = createLogError('node-svm');
|
|
|
589
590
|
* signerAddress: senderAddress, // Explicitly specify who signs
|
|
590
591
|
* });
|
|
591
592
|
*
|
|
592
|
-
*/ const delegatedSignTransaction = async (client, { walletId, walletApiKey, keyShare, transaction, signerAddress })=>{
|
|
593
|
+
*/ const delegatedSignTransaction = async (client, { walletId, shareSetId, walletApiKey, keyShare, transaction, signerAddress, derivationPath })=>{
|
|
593
594
|
try {
|
|
595
|
+
if (!keyShare || !walletId || !walletApiKey) {
|
|
596
|
+
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a transaction');
|
|
597
|
+
}
|
|
594
598
|
let messageToSign;
|
|
595
599
|
if (transaction instanceof VersionedTransaction) {
|
|
596
600
|
// For versioned transactions, we need to sign the message directly
|
|
@@ -601,13 +605,14 @@ const logError = createLogError('node-svm');
|
|
|
601
605
|
const messageBytes = transaction.serializeMessage();
|
|
602
606
|
messageToSign = messageBytes.toString('hex');
|
|
603
607
|
}
|
|
604
|
-
// Use the delegated sign message function from node package
|
|
605
608
|
const signatureEd25519 = await delegatedSignMessage$1(client, {
|
|
606
609
|
walletId,
|
|
610
|
+
shareSetId,
|
|
607
611
|
walletApiKey,
|
|
608
612
|
keyShare,
|
|
609
613
|
message: messageToSign,
|
|
610
614
|
chainName: client.chainName,
|
|
615
|
+
derivationPath,
|
|
611
616
|
isFormatted: false
|
|
612
617
|
});
|
|
613
618
|
if (!signatureEd25519) {
|
|
@@ -633,12 +638,11 @@ const logError = createLogError('node-svm');
|
|
|
633
638
|
} catch (error) {
|
|
634
639
|
throw new Error(`Invalid signer address: ${resolvedSignerAddress}. ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
635
640
|
}
|
|
636
|
-
|
|
641
|
+
return addSignatureToTransaction({
|
|
637
642
|
transaction,
|
|
638
643
|
signature: signatureEd25519,
|
|
639
644
|
signerPublicKey
|
|
640
645
|
});
|
|
641
|
-
return signedTransaction;
|
|
642
646
|
} catch (error) {
|
|
643
647
|
logError({
|
|
644
648
|
message: 'Error in delegatedSignTransaction',
|
|
@@ -683,16 +687,18 @@ const logError = createLogError('node-svm');
|
|
|
683
687
|
* message: hash,
|
|
684
688
|
* });
|
|
685
689
|
*
|
|
686
|
-
*/ const delegatedSignRawMessage = async (client, { walletId, walletApiKey, keyShare, message })=>{
|
|
690
|
+
*/ const delegatedSignRawMessage = async (client, { walletId, shareSetId, walletApiKey, keyShare, message, derivationPath })=>{
|
|
687
691
|
if (!keyShare || !walletId || !walletApiKey) {
|
|
688
692
|
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a raw message');
|
|
689
693
|
}
|
|
690
694
|
try {
|
|
691
695
|
return await delegatedSignMessage(client, {
|
|
692
696
|
walletId,
|
|
697
|
+
shareSetId,
|
|
693
698
|
walletApiKey,
|
|
694
699
|
keyShare,
|
|
695
700
|
message: stripHexPrefix(message),
|
|
701
|
+
derivationPath,
|
|
696
702
|
isFormatted: true
|
|
697
703
|
});
|
|
698
704
|
} catch (error) {
|
|
@@ -708,8 +714,10 @@ const logError = createLogError('node-svm');
|
|
|
708
714
|
};
|
|
709
715
|
/**
|
|
710
716
|
* Revoke delegation - delegates to the node package
|
|
711
|
-
*/ const revokeDelegation = async (client,
|
|
712
|
-
return revokeDelegation$1(client,
|
|
717
|
+
*/ const revokeDelegation = async (client, { walletId })=>{
|
|
718
|
+
return revokeDelegation$1(client, {
|
|
719
|
+
walletId
|
|
720
|
+
});
|
|
713
721
|
};
|
|
714
722
|
|
|
715
723
|
export { DynamicSvmWalletClient, ERROR_CREATE_WALLET_ACCOUNT, ERROR_SIGN_RAW_MESSAGE, addSignatureToTransaction, attachSignature, createDelegatedSvmWalletClient, createSolanaTransaction, decodeBase58, delegatedSignMessage, delegatedSignRawMessage, delegatedSignTransaction, encodeBase58, getBalance, revokeDelegation, sendTransaction };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-svm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "1.0.
|
|
7
|
+
"@dynamic-labs-wallet/node": "1.0.1",
|
|
8
8
|
"@solana/web3.js": "^1.98.2"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
package/src/delegatedClient.d.ts
CHANGED
|
@@ -18,11 +18,13 @@ export declare const createDelegatedSvmWalletClient: ({ environmentId, baseApiUr
|
|
|
18
18
|
/**
|
|
19
19
|
* Signs a message using delegated signing for SVM
|
|
20
20
|
*/
|
|
21
|
-
export declare const delegatedSignMessage: (client: DelegatedSvmWalletClient, { walletId, walletApiKey, keyShare, message, isFormatted, }: {
|
|
21
|
+
export declare const delegatedSignMessage: (client: DelegatedSvmWalletClient, { walletId, shareSetId, walletApiKey, keyShare, message, derivationPath, isFormatted, }: {
|
|
22
22
|
walletId: string;
|
|
23
|
+
shareSetId: string;
|
|
23
24
|
walletApiKey: string;
|
|
24
25
|
keyShare: ServerKeyShare;
|
|
25
26
|
message: string;
|
|
27
|
+
derivationPath?: Uint32Array;
|
|
26
28
|
isFormatted?: boolean;
|
|
27
29
|
}) => Promise<string>;
|
|
28
30
|
/**
|
|
@@ -65,12 +67,14 @@ export declare const delegatedSignMessage: (client: DelegatedSvmWalletClient, {
|
|
|
65
67
|
* });
|
|
66
68
|
*
|
|
67
69
|
*/
|
|
68
|
-
export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient, { walletId, walletApiKey, keyShare, transaction, signerAddress, }: {
|
|
70
|
+
export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient, { walletId, shareSetId, walletApiKey, keyShare, transaction, signerAddress, derivationPath, }: {
|
|
69
71
|
walletId: string;
|
|
72
|
+
shareSetId: string;
|
|
70
73
|
walletApiKey: string;
|
|
71
74
|
keyShare: any;
|
|
72
75
|
transaction: VersionedTransaction | Transaction;
|
|
73
76
|
signerAddress?: string;
|
|
77
|
+
derivationPath?: Uint32Array;
|
|
74
78
|
}) => Promise<VersionedTransaction | Transaction>;
|
|
75
79
|
/**
|
|
76
80
|
* Signs a pre-formatted (raw) message using delegated signing for SVM.
|
|
@@ -106,14 +110,18 @@ export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient
|
|
|
106
110
|
* });
|
|
107
111
|
*
|
|
108
112
|
*/
|
|
109
|
-
export declare const delegatedSignRawMessage: (client: DelegatedSvmWalletClient, { walletId, walletApiKey, keyShare, message, }: {
|
|
113
|
+
export declare const delegatedSignRawMessage: (client: DelegatedSvmWalletClient, { walletId, shareSetId, walletApiKey, keyShare, message, derivationPath, }: {
|
|
110
114
|
walletId: string;
|
|
115
|
+
shareSetId: string;
|
|
111
116
|
walletApiKey: string;
|
|
112
117
|
keyShare: ServerKeyShare;
|
|
113
118
|
message: string;
|
|
119
|
+
derivationPath?: Uint32Array;
|
|
114
120
|
}) => Promise<string>;
|
|
115
121
|
/**
|
|
116
122
|
* Revoke delegation - delegates to the node package
|
|
117
123
|
*/
|
|
118
|
-
export declare const revokeDelegation: (client: DelegatedSvmWalletClient,
|
|
124
|
+
export declare const revokeDelegation: (client: DelegatedSvmWalletClient, { walletId }: {
|
|
125
|
+
walletId: string;
|
|
126
|
+
}) => Promise<void>;
|
|
119
127
|
//# 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,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQvF,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;CACjB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,GAAG;IAC7D,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,sEAMxC,wBAAwB,KAAG,
|
|
1
|
+
{"version":3,"file":"delegatedClient.d.ts","sourceRoot":"","sources":["../../packages/src/delegatedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,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