@dynamic-labs-wallet/node-svm 1.0.105 → 1.0.106
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 +103 -42
- package/index.esm.js +104 -44
- package/package.json +2 -2
- package/src/delegatedClient.d.ts +12 -42
- package/src/delegatedClient.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -642,35 +642,110 @@ const logError = node.createLogError('node-svm');
|
|
|
642
642
|
* signerAddress: senderAddress, // Explicitly specify who signs
|
|
643
643
|
* });
|
|
644
644
|
*
|
|
645
|
-
*/
|
|
645
|
+
*/ /**
|
|
646
|
+
* Sponsors a Solana transaction for a delegated wallet's end user, swapping its
|
|
647
|
+
* fee payer for a Dynamic-funded sponsor. Grid's response is always a v0
|
|
648
|
+
* `VersionedTransaction` regardless of the input type, so pass the result to
|
|
649
|
+
* {@link delegatedSignTransaction} with an explicit `signerAddress` — the
|
|
650
|
+
* caller must sign as the *user*, not as the new fee payer.
|
|
651
|
+
*
|
|
652
|
+
* @param client - The delegated SVM wallet client
|
|
653
|
+
* @param options.transaction - Unsigned transaction (legacy or versioned). Its fee payer must be the delegated wallet's address.
|
|
654
|
+
* @param options.userId - UUID of the end user who owns the wallet — the `userId` field of the `wallet.delegation.created` webhook payload.
|
|
655
|
+
*
|
|
656
|
+
* @returns The sponsored transaction, always as a `VersionedTransaction`.
|
|
657
|
+
*/ const serializeSvmTransaction = (transaction)=>transaction instanceof web3_js.VersionedTransaction ? transaction.serialize() : transaction.serialize({
|
|
658
|
+
requireAllSignatures: false,
|
|
659
|
+
verifySignatures: false
|
|
660
|
+
});
|
|
661
|
+
const delegatedSponsorTransaction = async (client, { transaction, userId, traceContext })=>{
|
|
662
|
+
const serialized = serializeSvmTransaction(transaction);
|
|
663
|
+
const { transaction: sponsoredBase64 } = await node.withDelegatedServerAuth(client, (apiClient)=>apiClient.requestSvmSponsoredTransaction({
|
|
664
|
+
transaction: Buffer.from(serialized).toString('base64'),
|
|
665
|
+
userId,
|
|
666
|
+
traceContext
|
|
667
|
+
}));
|
|
668
|
+
// Grid always returns a v0 versioned transaction regardless of what went in;
|
|
669
|
+
// deserializing a legacy input here with Transaction.from() would be wrong.
|
|
670
|
+
return web3_js.VersionedTransaction.deserialize(Buffer.from(sponsoredBase64, 'base64'));
|
|
671
|
+
};
|
|
672
|
+
const sponsorTransactionIfRequested = async (client, { sponsor, userId, signerAddress, transaction, traceContext })=>{
|
|
673
|
+
if (!sponsor) {
|
|
674
|
+
return transaction;
|
|
675
|
+
}
|
|
676
|
+
if (!userId) {
|
|
677
|
+
throw new Error('userId is required when sponsor is true');
|
|
678
|
+
}
|
|
679
|
+
// Grid becomes the fee payer, so the signerAddress fallback below would
|
|
680
|
+
// attach the user's signature under the sponsor's key and produce a
|
|
681
|
+
// transaction that fails on broadcast.
|
|
682
|
+
if (!signerAddress) {
|
|
683
|
+
throw new Error('signerAddress is required when sponsor is true');
|
|
684
|
+
}
|
|
685
|
+
return delegatedSponsorTransaction(client, {
|
|
686
|
+
transaction,
|
|
687
|
+
userId,
|
|
688
|
+
traceContext
|
|
689
|
+
});
|
|
690
|
+
};
|
|
691
|
+
const computeMessageToSignHex = (transaction)=>{
|
|
692
|
+
if (transaction instanceof web3_js.VersionedTransaction) {
|
|
693
|
+
// For versioned transactions, we need to sign the message directly
|
|
694
|
+
return Buffer.from(Array.from(transaction.message.serialize())).toString('hex');
|
|
695
|
+
}
|
|
696
|
+
// For legacy transactions, serialize the message
|
|
697
|
+
return transaction.serializeMessage().toString('hex');
|
|
698
|
+
};
|
|
699
|
+
// Mirrors the browser SVM client: svmTransaction context requires a chainId,
|
|
700
|
+
// so it's only attached when the caller provides one.
|
|
701
|
+
const buildSignMessageContext = (context, chainId, transaction)=>{
|
|
702
|
+
if (chainId === undefined) {
|
|
703
|
+
return context;
|
|
704
|
+
}
|
|
705
|
+
return _extends({}, context, {
|
|
706
|
+
svmTransaction: {
|
|
707
|
+
chainId,
|
|
708
|
+
method: 'signAndSendTransaction',
|
|
709
|
+
serializedTransactions: [
|
|
710
|
+
encodeBase58(serializeSvmTransaction(transaction))
|
|
711
|
+
]
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
const resolveSignerAddress = (transaction, signerAddress)=>{
|
|
716
|
+
var _transaction_feePayer;
|
|
717
|
+
if (signerAddress !== undefined) {
|
|
718
|
+
return signerAddress;
|
|
719
|
+
}
|
|
720
|
+
if (transaction instanceof web3_js.VersionedTransaction) {
|
|
721
|
+
var _transaction_message_staticAccountKeys_;
|
|
722
|
+
var _transaction_message_staticAccountKeys__toBase58;
|
|
723
|
+
return (_transaction_message_staticAccountKeys__toBase58 = (_transaction_message_staticAccountKeys_ = transaction.message.staticAccountKeys[0]) == null ? void 0 : _transaction_message_staticAccountKeys_.toBase58()) != null ? _transaction_message_staticAccountKeys__toBase58 : '';
|
|
724
|
+
}
|
|
725
|
+
var _transaction_feePayer_toBase58;
|
|
726
|
+
return (_transaction_feePayer_toBase58 = (_transaction_feePayer = transaction.feePayer) == null ? void 0 : _transaction_feePayer.toBase58()) != null ? _transaction_feePayer_toBase58 : '';
|
|
727
|
+
};
|
|
728
|
+
const toSignerPublicKey = (resolvedSignerAddress)=>{
|
|
729
|
+
try {
|
|
730
|
+
return new web3_js.PublicKey(resolvedSignerAddress);
|
|
731
|
+
} catch (error) {
|
|
732
|
+
throw new Error(`Invalid signer address: ${resolvedSignerAddress}. ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
const delegatedSignTransaction = async (client, { walletId, shareSetId, walletApiKey, keyShare, transaction, signerAddress, derivationPath, chainId, context, sponsor = false, userId, traceContext })=>{
|
|
646
736
|
try {
|
|
647
737
|
if (!keyShare || !walletId || !walletApiKey) {
|
|
648
738
|
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a transaction');
|
|
649
739
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
// Mirrors the browser SVM client: svmTransaction context requires a chainId,
|
|
661
|
-
// so it's only attached when the caller provides one.
|
|
662
|
-
const resolvedContext = chainId !== undefined ? _extends({}, context, {
|
|
663
|
-
svmTransaction: {
|
|
664
|
-
chainId,
|
|
665
|
-
method: 'signAndSendTransaction',
|
|
666
|
-
serializedTransactions: [
|
|
667
|
-
encodeBase58(transaction instanceof web3_js.VersionedTransaction ? transaction.serialize() : transaction.serialize({
|
|
668
|
-
requireAllSignatures: false,
|
|
669
|
-
verifySignatures: false
|
|
670
|
-
}))
|
|
671
|
-
]
|
|
672
|
-
}
|
|
673
|
-
}) : context;
|
|
740
|
+
transaction = await sponsorTransactionIfRequested(client, {
|
|
741
|
+
sponsor,
|
|
742
|
+
userId,
|
|
743
|
+
signerAddress,
|
|
744
|
+
transaction,
|
|
745
|
+
traceContext
|
|
746
|
+
});
|
|
747
|
+
const messageToSign = computeMessageToSignHex(transaction);
|
|
748
|
+
const resolvedContext = buildSignMessageContext(context, chainId, transaction);
|
|
674
749
|
const signatureEd25519 = await node.delegatedSignMessage(client, {
|
|
675
750
|
walletId,
|
|
676
751
|
shareSetId,
|
|
@@ -685,26 +760,11 @@ const logError = node.createLogError('node-svm');
|
|
|
685
760
|
if (!signatureEd25519) {
|
|
686
761
|
throw new Error('Signature is undefined');
|
|
687
762
|
}
|
|
688
|
-
const resolvedSignerAddress =
|
|
689
|
-
var _transaction_feePayer;
|
|
690
|
-
if (transaction instanceof web3_js.VersionedTransaction) {
|
|
691
|
-
var _signers_;
|
|
692
|
-
const signers = transaction.message.staticAccountKeys;
|
|
693
|
-
var _signers__toBase58;
|
|
694
|
-
return (_signers__toBase58 = (_signers_ = signers[0]) == null ? void 0 : _signers_.toBase58()) != null ? _signers__toBase58 : '';
|
|
695
|
-
}
|
|
696
|
-
var _transaction_feePayer_toBase58;
|
|
697
|
-
return (_transaction_feePayer_toBase58 = (_transaction_feePayer = transaction.feePayer) == null ? void 0 : _transaction_feePayer.toBase58()) != null ? _transaction_feePayer_toBase58 : '';
|
|
698
|
-
})();
|
|
763
|
+
const resolvedSignerAddress = resolveSignerAddress(transaction, signerAddress);
|
|
699
764
|
if (!resolvedSignerAddress) {
|
|
700
765
|
throw new Error('Could not determine signer address. Provide signerAddress explicitly or ensure transaction has a fee payer.');
|
|
701
766
|
}
|
|
702
|
-
|
|
703
|
-
try {
|
|
704
|
-
signerPublicKey = new web3_js.PublicKey(resolvedSignerAddress);
|
|
705
|
-
} catch (error) {
|
|
706
|
-
throw new Error(`Invalid signer address: ${resolvedSignerAddress}. ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
707
|
-
}
|
|
767
|
+
const signerPublicKey = toSignerPublicKey(resolvedSignerAddress);
|
|
708
768
|
return addSignatureToTransaction({
|
|
709
769
|
transaction,
|
|
710
770
|
signature: signatureEd25519,
|
|
@@ -799,6 +859,7 @@ exports.decodeBase58 = decodeBase58;
|
|
|
799
859
|
exports.delegatedSignMessage = delegatedSignMessage;
|
|
800
860
|
exports.delegatedSignRawMessage = delegatedSignRawMessage;
|
|
801
861
|
exports.delegatedSignTransaction = delegatedSignTransaction;
|
|
862
|
+
exports.delegatedSponsorTransaction = delegatedSponsorTransaction;
|
|
802
863
|
exports.encodeBase58 = encodeBase58;
|
|
803
864
|
exports.getBalance = getBalance;
|
|
804
865
|
exports.revokeDelegation = revokeDelegation;
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SOLANA_RPC_URL, createLogError, DynamicWalletClient, getMPCChainConfig, stripHexPrefix, WalletOperation, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, revokeDelegation as revokeDelegation$1 } from '@dynamic-labs-wallet/node';
|
|
1
|
+
import { SOLANA_RPC_URL, createLogError, DynamicWalletClient, getMPCChainConfig, stripHexPrefix, WalletOperation, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, withDelegatedServerAuth, revokeDelegation as revokeDelegation$1 } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import { PublicKey, Connection, Transaction, SystemProgram, VersionedTransaction, Keypair } from '@solana/web3.js';
|
|
3
3
|
|
|
4
4
|
function _extends() {
|
|
@@ -640,35 +640,110 @@ const logError = createLogError('node-svm');
|
|
|
640
640
|
* signerAddress: senderAddress, // Explicitly specify who signs
|
|
641
641
|
* });
|
|
642
642
|
*
|
|
643
|
-
*/
|
|
643
|
+
*/ /**
|
|
644
|
+
* Sponsors a Solana transaction for a delegated wallet's end user, swapping its
|
|
645
|
+
* fee payer for a Dynamic-funded sponsor. Grid's response is always a v0
|
|
646
|
+
* `VersionedTransaction` regardless of the input type, so pass the result to
|
|
647
|
+
* {@link delegatedSignTransaction} with an explicit `signerAddress` — the
|
|
648
|
+
* caller must sign as the *user*, not as the new fee payer.
|
|
649
|
+
*
|
|
650
|
+
* @param client - The delegated SVM wallet client
|
|
651
|
+
* @param options.transaction - Unsigned transaction (legacy or versioned). Its fee payer must be the delegated wallet's address.
|
|
652
|
+
* @param options.userId - UUID of the end user who owns the wallet — the `userId` field of the `wallet.delegation.created` webhook payload.
|
|
653
|
+
*
|
|
654
|
+
* @returns The sponsored transaction, always as a `VersionedTransaction`.
|
|
655
|
+
*/ const serializeSvmTransaction = (transaction)=>transaction instanceof VersionedTransaction ? transaction.serialize() : transaction.serialize({
|
|
656
|
+
requireAllSignatures: false,
|
|
657
|
+
verifySignatures: false
|
|
658
|
+
});
|
|
659
|
+
const delegatedSponsorTransaction = async (client, { transaction, userId, traceContext })=>{
|
|
660
|
+
const serialized = serializeSvmTransaction(transaction);
|
|
661
|
+
const { transaction: sponsoredBase64 } = await withDelegatedServerAuth(client, (apiClient)=>apiClient.requestSvmSponsoredTransaction({
|
|
662
|
+
transaction: Buffer.from(serialized).toString('base64'),
|
|
663
|
+
userId,
|
|
664
|
+
traceContext
|
|
665
|
+
}));
|
|
666
|
+
// Grid always returns a v0 versioned transaction regardless of what went in;
|
|
667
|
+
// deserializing a legacy input here with Transaction.from() would be wrong.
|
|
668
|
+
return VersionedTransaction.deserialize(Buffer.from(sponsoredBase64, 'base64'));
|
|
669
|
+
};
|
|
670
|
+
const sponsorTransactionIfRequested = async (client, { sponsor, userId, signerAddress, transaction, traceContext })=>{
|
|
671
|
+
if (!sponsor) {
|
|
672
|
+
return transaction;
|
|
673
|
+
}
|
|
674
|
+
if (!userId) {
|
|
675
|
+
throw new Error('userId is required when sponsor is true');
|
|
676
|
+
}
|
|
677
|
+
// Grid becomes the fee payer, so the signerAddress fallback below would
|
|
678
|
+
// attach the user's signature under the sponsor's key and produce a
|
|
679
|
+
// transaction that fails on broadcast.
|
|
680
|
+
if (!signerAddress) {
|
|
681
|
+
throw new Error('signerAddress is required when sponsor is true');
|
|
682
|
+
}
|
|
683
|
+
return delegatedSponsorTransaction(client, {
|
|
684
|
+
transaction,
|
|
685
|
+
userId,
|
|
686
|
+
traceContext
|
|
687
|
+
});
|
|
688
|
+
};
|
|
689
|
+
const computeMessageToSignHex = (transaction)=>{
|
|
690
|
+
if (transaction instanceof VersionedTransaction) {
|
|
691
|
+
// For versioned transactions, we need to sign the message directly
|
|
692
|
+
return Buffer.from(Array.from(transaction.message.serialize())).toString('hex');
|
|
693
|
+
}
|
|
694
|
+
// For legacy transactions, serialize the message
|
|
695
|
+
return transaction.serializeMessage().toString('hex');
|
|
696
|
+
};
|
|
697
|
+
// Mirrors the browser SVM client: svmTransaction context requires a chainId,
|
|
698
|
+
// so it's only attached when the caller provides one.
|
|
699
|
+
const buildSignMessageContext = (context, chainId, transaction)=>{
|
|
700
|
+
if (chainId === undefined) {
|
|
701
|
+
return context;
|
|
702
|
+
}
|
|
703
|
+
return _extends({}, context, {
|
|
704
|
+
svmTransaction: {
|
|
705
|
+
chainId,
|
|
706
|
+
method: 'signAndSendTransaction',
|
|
707
|
+
serializedTransactions: [
|
|
708
|
+
encodeBase58(serializeSvmTransaction(transaction))
|
|
709
|
+
]
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
};
|
|
713
|
+
const resolveSignerAddress = (transaction, signerAddress)=>{
|
|
714
|
+
var _transaction_feePayer;
|
|
715
|
+
if (signerAddress !== undefined) {
|
|
716
|
+
return signerAddress;
|
|
717
|
+
}
|
|
718
|
+
if (transaction instanceof VersionedTransaction) {
|
|
719
|
+
var _transaction_message_staticAccountKeys_;
|
|
720
|
+
var _transaction_message_staticAccountKeys__toBase58;
|
|
721
|
+
return (_transaction_message_staticAccountKeys__toBase58 = (_transaction_message_staticAccountKeys_ = transaction.message.staticAccountKeys[0]) == null ? void 0 : _transaction_message_staticAccountKeys_.toBase58()) != null ? _transaction_message_staticAccountKeys__toBase58 : '';
|
|
722
|
+
}
|
|
723
|
+
var _transaction_feePayer_toBase58;
|
|
724
|
+
return (_transaction_feePayer_toBase58 = (_transaction_feePayer = transaction.feePayer) == null ? void 0 : _transaction_feePayer.toBase58()) != null ? _transaction_feePayer_toBase58 : '';
|
|
725
|
+
};
|
|
726
|
+
const toSignerPublicKey = (resolvedSignerAddress)=>{
|
|
727
|
+
try {
|
|
728
|
+
return new PublicKey(resolvedSignerAddress);
|
|
729
|
+
} catch (error) {
|
|
730
|
+
throw new Error(`Invalid signer address: ${resolvedSignerAddress}. ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
const delegatedSignTransaction = async (client, { walletId, shareSetId, walletApiKey, keyShare, transaction, signerAddress, derivationPath, chainId, context, sponsor = false, userId, traceContext })=>{
|
|
644
734
|
try {
|
|
645
735
|
if (!keyShare || !walletId || !walletApiKey) {
|
|
646
736
|
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a transaction');
|
|
647
737
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}
|
|
658
|
-
// Mirrors the browser SVM client: svmTransaction context requires a chainId,
|
|
659
|
-
// so it's only attached when the caller provides one.
|
|
660
|
-
const resolvedContext = chainId !== undefined ? _extends({}, context, {
|
|
661
|
-
svmTransaction: {
|
|
662
|
-
chainId,
|
|
663
|
-
method: 'signAndSendTransaction',
|
|
664
|
-
serializedTransactions: [
|
|
665
|
-
encodeBase58(transaction instanceof VersionedTransaction ? transaction.serialize() : transaction.serialize({
|
|
666
|
-
requireAllSignatures: false,
|
|
667
|
-
verifySignatures: false
|
|
668
|
-
}))
|
|
669
|
-
]
|
|
670
|
-
}
|
|
671
|
-
}) : context;
|
|
738
|
+
transaction = await sponsorTransactionIfRequested(client, {
|
|
739
|
+
sponsor,
|
|
740
|
+
userId,
|
|
741
|
+
signerAddress,
|
|
742
|
+
transaction,
|
|
743
|
+
traceContext
|
|
744
|
+
});
|
|
745
|
+
const messageToSign = computeMessageToSignHex(transaction);
|
|
746
|
+
const resolvedContext = buildSignMessageContext(context, chainId, transaction);
|
|
672
747
|
const signatureEd25519 = await delegatedSignMessage$1(client, {
|
|
673
748
|
walletId,
|
|
674
749
|
shareSetId,
|
|
@@ -683,26 +758,11 @@ const logError = createLogError('node-svm');
|
|
|
683
758
|
if (!signatureEd25519) {
|
|
684
759
|
throw new Error('Signature is undefined');
|
|
685
760
|
}
|
|
686
|
-
const resolvedSignerAddress =
|
|
687
|
-
var _transaction_feePayer;
|
|
688
|
-
if (transaction instanceof VersionedTransaction) {
|
|
689
|
-
var _signers_;
|
|
690
|
-
const signers = transaction.message.staticAccountKeys;
|
|
691
|
-
var _signers__toBase58;
|
|
692
|
-
return (_signers__toBase58 = (_signers_ = signers[0]) == null ? void 0 : _signers_.toBase58()) != null ? _signers__toBase58 : '';
|
|
693
|
-
}
|
|
694
|
-
var _transaction_feePayer_toBase58;
|
|
695
|
-
return (_transaction_feePayer_toBase58 = (_transaction_feePayer = transaction.feePayer) == null ? void 0 : _transaction_feePayer.toBase58()) != null ? _transaction_feePayer_toBase58 : '';
|
|
696
|
-
})();
|
|
761
|
+
const resolvedSignerAddress = resolveSignerAddress(transaction, signerAddress);
|
|
697
762
|
if (!resolvedSignerAddress) {
|
|
698
763
|
throw new Error('Could not determine signer address. Provide signerAddress explicitly or ensure transaction has a fee payer.');
|
|
699
764
|
}
|
|
700
|
-
|
|
701
|
-
try {
|
|
702
|
-
signerPublicKey = new PublicKey(resolvedSignerAddress);
|
|
703
|
-
} catch (error) {
|
|
704
|
-
throw new Error(`Invalid signer address: ${resolvedSignerAddress}. ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
705
|
-
}
|
|
765
|
+
const signerPublicKey = toSignerPublicKey(resolvedSignerAddress);
|
|
706
766
|
return addSignatureToTransaction({
|
|
707
767
|
transaction,
|
|
708
768
|
signature: signatureEd25519,
|
|
@@ -786,4 +846,4 @@ const logError = createLogError('node-svm');
|
|
|
786
846
|
});
|
|
787
847
|
};
|
|
788
848
|
|
|
789
|
-
export { DynamicSvmWalletClient, ERROR_CREATE_WALLET_ACCOUNT, ERROR_SIGN_RAW_MESSAGE, addSignatureToTransaction, attachSignature, createDelegatedSvmWalletClient, createSolanaTransaction, decodeBase58, delegatedSignMessage, delegatedSignRawMessage, delegatedSignTransaction, encodeBase58, getBalance, revokeDelegation, sendTransaction };
|
|
849
|
+
export { DynamicSvmWalletClient, ERROR_CREATE_WALLET_ACCOUNT, ERROR_SIGN_RAW_MESSAGE, addSignatureToTransaction, attachSignature, createDelegatedSvmWalletClient, createSolanaTransaction, decodeBase58, delegatedSignMessage, delegatedSignRawMessage, delegatedSignTransaction, delegatedSponsorTransaction, 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.106",
|
|
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.106",
|
|
8
8
|
"@solana/web3.js": "^1.98.2"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
package/src/delegatedClient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DelegatedWalletClient, ServerKeyShare } from '@dynamic-labs-wallet/node';
|
|
1
|
+
import type { DelegatedWalletClient, ServerKeyShare, TraceContext } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
3
3
|
import type { Transaction } from '@solana/web3.js';
|
|
4
4
|
import { VersionedTransaction } from '@solana/web3.js';
|
|
@@ -36,47 +36,12 @@ export declare const delegatedSignMessage: (client: DelegatedSvmWalletClient, {
|
|
|
36
36
|
isFormatted?: boolean;
|
|
37
37
|
context?: SignMessageContext;
|
|
38
38
|
}) => Promise<string>;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* @param options.walletApiKey - The wallet API key
|
|
46
|
-
* @param options.keyShare - The server key share
|
|
47
|
-
* @param options.transaction - The transaction to sign (VersionedTransaction or Transaction)
|
|
48
|
-
* @param options.signerAddress - Optional. The address that should sign the transaction.
|
|
49
|
-
* If not provided, defaults to the first signer (VersionedTransaction)
|
|
50
|
-
* or fee payer (Transaction). Use this for gasless transactions where
|
|
51
|
-
* a separate fee payer pays the fees.
|
|
52
|
-
*
|
|
53
|
-
* @returns The partially signed transaction with the signature attached for the specified signer
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* // Standard transaction where sender is also fee payer
|
|
57
|
-
* const signedTx = await delegatedSignTransaction(client, {
|
|
58
|
-
* walletId,
|
|
59
|
-
* walletApiKey,
|
|
60
|
-
* keyShare,
|
|
61
|
-
* transaction,
|
|
62
|
-
* });
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* // Gasless transaction with separate fee payer
|
|
66
|
-
* const transaction = new Transaction();
|
|
67
|
-
* transaction.feePayer = feePayerPublicKey; // Set the actual fee payer
|
|
68
|
-
* transaction.add(instruction); // Instruction that requires sender signature
|
|
69
|
-
*
|
|
70
|
-
* const signedTx = await delegatedSignTransaction(client, {
|
|
71
|
-
* walletId,
|
|
72
|
-
* walletApiKey,
|
|
73
|
-
* keyShare,
|
|
74
|
-
* transaction,
|
|
75
|
-
* signerAddress: senderAddress, // Explicitly specify who signs
|
|
76
|
-
* });
|
|
77
|
-
*
|
|
78
|
-
*/
|
|
79
|
-
export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient, { walletId, shareSetId, walletApiKey, keyShare, transaction, signerAddress, derivationPath, chainId, context, }: {
|
|
39
|
+
export declare const delegatedSponsorTransaction: (client: DelegatedSvmWalletClient, { transaction, userId, traceContext, }: {
|
|
40
|
+
transaction: VersionedTransaction | Transaction;
|
|
41
|
+
userId: string;
|
|
42
|
+
traceContext?: TraceContext;
|
|
43
|
+
}) => Promise<VersionedTransaction>;
|
|
44
|
+
export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient, { walletId, shareSetId, walletApiKey, keyShare, transaction, signerAddress, derivationPath, chainId, context, sponsor, userId, traceContext, }: {
|
|
80
45
|
walletId: string;
|
|
81
46
|
/**
|
|
82
47
|
* Optional. The `shareSetId` from the `wallet.delegation.created`
|
|
@@ -93,6 +58,11 @@ export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient
|
|
|
93
58
|
derivationPath?: Uint32Array;
|
|
94
59
|
chainId?: string;
|
|
95
60
|
context?: SignMessageContext;
|
|
61
|
+
/** If true, sponsors the transaction (swapping its fee payer) before signing. */
|
|
62
|
+
sponsor?: boolean;
|
|
63
|
+
/** Required when `sponsor` is true. UUID of the wallet's owner. */
|
|
64
|
+
userId?: string;
|
|
65
|
+
traceContext?: TraceContext;
|
|
96
66
|
}) => Promise<VersionedTransaction | Transaction>;
|
|
97
67
|
/**
|
|
98
68
|
* Signs a pre-formatted (raw) message using delegated signing for SVM.
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"delegatedClient.d.ts","sourceRoot":"","sources":["../../packages/src/delegatedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AASrG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,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,wBAU7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,wBAAwB,oGAU7B;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B,KACA,OAAO,CAAC,MAAM,CA4BhB,CAAC;AA6DF,eAAO,MAAM,2BAA2B,WAC9B,wBAAwB,0CAK7B;IACD,WAAW,EAAE,oBAAoB,GAAG,WAAW,CAAC;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,KACA,OAAO,CAAC,oBAAoB,CAc9B,CAAC;AAkFF,eAAO,MAAM,wBAAwB,WAC3B,wBAAwB,kJAc7B;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,GAAG,CAAC;IACd,WAAW,EAAE,oBAAoB,GAAG,WAAW,CAAC;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,KACA,OAAO,CAAC,oBAAoB,GAAG,WAAW,CAwD5C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,uBAAuB,WAC1B,wBAAwB,uFAS7B;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B,KACA,OAAO,CAAC,MAAM,CAwBhB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,WAAkB,wBAAwB,gBAAgB;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,kBAE1G,CAAC"}
|