@dynamic-labs-wallet/node-svm 1.1.55 → 1.1.57
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 +148 -1
- package/index.esm.js +148 -1
- package/package.json +2 -2
- package/src/client/client.d.ts +63 -3
- package/src/client/client.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -873,6 +873,72 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
873
873
|
// The sponsor endpoint always returns a v0 versioned transaction.
|
|
874
874
|
return web3_js.VersionedTransaction.deserialize(sponsoredBytes);
|
|
875
875
|
}
|
|
876
|
+
/**
|
|
877
|
+
* Generates a Token-2022 confidential-transfer seed inside the enclave and
|
|
878
|
+
* stores the sealed result in CKS. Returns the ElGamal public key and the
|
|
879
|
+
* derivation version — persist it for later confidential operations.
|
|
880
|
+
*/ async createConfidentialSeed({ walletId, solanaAddress, derivationVersion, traceContext }) {
|
|
881
|
+
return this.apiClient.createConfidentialSeed({
|
|
882
|
+
walletId,
|
|
883
|
+
request: {
|
|
884
|
+
derivationVersion,
|
|
885
|
+
solanaAddress
|
|
886
|
+
},
|
|
887
|
+
traceContext
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Signs Token-2022 confidential-transfer transactions in the enclave.
|
|
892
|
+
*
|
|
893
|
+
* The enclave is offline, so any missing `accountState` /
|
|
894
|
+
* `destinationAccountState` and the latest blockhash are fetched from
|
|
895
|
+
* `rpcUrl` on the caller's behalf. Pass `broadcast: true` to also submit
|
|
896
|
+
* the signed transactions to the cluster in order.
|
|
897
|
+
*
|
|
898
|
+
* @returns The signed transactions (base64, broadcast order), their
|
|
899
|
+
* signatures, and — when broadcast — the submitted transaction ids.
|
|
900
|
+
*/ async signConfidentialTransfer({ walletId, operation, solanaAddress, mint, tokenAccount, destinationTokenAccount, amount, decimals, accountState, destinationAccountState, auditorElgamalPubkey, feePayer, derivationVersion, chainId = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', lamportsPerByte = '6960', recentBlockhash, lastValidBlockHeight, rpcUrl, broadcast = false, broadcastOptions, traceContext }) {
|
|
901
|
+
const resolved = await this.resolveConfidentialInputs({
|
|
902
|
+
operation,
|
|
903
|
+
tokenAccount,
|
|
904
|
+
destinationTokenAccount,
|
|
905
|
+
accountState,
|
|
906
|
+
destinationAccountState,
|
|
907
|
+
recentBlockhash,
|
|
908
|
+
lastValidBlockHeight,
|
|
909
|
+
rpcUrl,
|
|
910
|
+
broadcast
|
|
911
|
+
});
|
|
912
|
+
const result = await this.apiClient.signConfidentialTransfer({
|
|
913
|
+
walletId,
|
|
914
|
+
request: {
|
|
915
|
+
accountState: resolved.accountState,
|
|
916
|
+
amount,
|
|
917
|
+
auditorElgamalPubkey,
|
|
918
|
+
chainId,
|
|
919
|
+
decimals,
|
|
920
|
+
derivationVersion,
|
|
921
|
+
destinationAccountState: resolved.destinationAccountState,
|
|
922
|
+
destinationTokenAccount,
|
|
923
|
+
feePayer,
|
|
924
|
+
lamportsPerByte,
|
|
925
|
+
lastValidBlockHeight: resolved.lastValidBlockHeight,
|
|
926
|
+
mint,
|
|
927
|
+
operation,
|
|
928
|
+
recentBlockhash: resolved.recentBlockhash,
|
|
929
|
+
solanaAddress,
|
|
930
|
+
tokenAccount
|
|
931
|
+
},
|
|
932
|
+
traceContext
|
|
933
|
+
});
|
|
934
|
+
const transactionIds = broadcast ? await this.broadcastConfidentialTransactions(resolved.connection, result.serializedTransactions, broadcastOptions, {
|
|
935
|
+
blockhash: resolved.recentBlockhash,
|
|
936
|
+
lastValidBlockHeight: Number(resolved.lastValidBlockHeight)
|
|
937
|
+
}) : undefined;
|
|
938
|
+
return _extends({}, result, {
|
|
939
|
+
transactionIds
|
|
940
|
+
});
|
|
941
|
+
}
|
|
876
942
|
/** @deprecated Use getWalletByAddress instead for better performance */ async getSvmWallets() {
|
|
877
943
|
// Calling the deprecated getWallets() is the point of this shim, and it is
|
|
878
944
|
// public and overridable, so routing around it would drop a consumer's override.
|
|
@@ -912,7 +978,88 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
912
978
|
enableMPCAccelerator,
|
|
913
979
|
logger,
|
|
914
980
|
debug
|
|
915
|
-
}), this.chainName = 'SVM'
|
|
981
|
+
}), this.chainName = 'SVM', // ---------------------------------------------------------------------------
|
|
982
|
+
// Token-2022 confidential transfers
|
|
983
|
+
// ---------------------------------------------------------------------------
|
|
984
|
+
this.svmAccountState = async (connection, account)=>{
|
|
985
|
+
const info = await connection.getAccountInfo(new web3_js.PublicKey(account));
|
|
986
|
+
if (!info) {
|
|
987
|
+
throw new Error(`Solana account not found: ${account}`);
|
|
988
|
+
}
|
|
989
|
+
return {
|
|
990
|
+
data: info.data.toString('base64'),
|
|
991
|
+
lamports: String(info.lamports),
|
|
992
|
+
owner: info.owner.toBase58()
|
|
993
|
+
};
|
|
994
|
+
}, this.confidentialBlockhash = async (connection)=>{
|
|
995
|
+
const latest = connection ? await connection.getLatestBlockhash() : undefined;
|
|
996
|
+
const recentBlockhash = latest == null ? void 0 : latest.blockhash;
|
|
997
|
+
const lastValidBlockHeight = latest ? String(latest.lastValidBlockHeight) : undefined;
|
|
998
|
+
if (!recentBlockhash || !lastValidBlockHeight) {
|
|
999
|
+
throw new node.ClientValidationError('signConfidentialTransfer requires rpcUrl to fetch the latest blockhash');
|
|
1000
|
+
}
|
|
1001
|
+
return {
|
|
1002
|
+
lastValidBlockHeight,
|
|
1003
|
+
recentBlockhash
|
|
1004
|
+
};
|
|
1005
|
+
}, this.broadcastConfidentialTransactions = async (connection, serializedTransactions, broadcastOptions, confirmationStrategy)=>serializedTransactions.reduce(async (accPromise, serializedTransaction)=>{
|
|
1006
|
+
const acc = await accPromise;
|
|
1007
|
+
const transactionId = await connection.sendRawTransaction(Buffer.from(serializedTransaction, 'base64'), broadcastOptions);
|
|
1008
|
+
// Confidential plans are order-dependent: confirm before submitting
|
|
1009
|
+
// the next transaction or Solana may process them out of order.
|
|
1010
|
+
// confirmTransaction resolves with value.err on a failed transaction
|
|
1011
|
+
// rather than rejecting — surface it instead of broadcasting the rest.
|
|
1012
|
+
const confirmation = await connection.confirmTransaction(_extends({}, confirmationStrategy, {
|
|
1013
|
+
signature: transactionId
|
|
1014
|
+
}), 'confirmed');
|
|
1015
|
+
if (confirmation.value.err) {
|
|
1016
|
+
throw new Error(`Confidential transaction ${transactionId} failed: ${JSON.stringify(confirmation.value.err)}`);
|
|
1017
|
+
}
|
|
1018
|
+
acc.push(transactionId);
|
|
1019
|
+
return acc;
|
|
1020
|
+
}, Promise.resolve([])), /**
|
|
1021
|
+
* Validates `rpcUrl`, fetches missing account states and the latest
|
|
1022
|
+
* blockhash, and returns the inputs the enclave request needs.
|
|
1023
|
+
*/ this.resolveConfidentialInputs = async ({ operation, tokenAccount, destinationTokenAccount, accountState, destinationAccountState, recentBlockhash, lastValidBlockHeight, rpcUrl, broadcast })=>{
|
|
1024
|
+
const needsAccountState = operation === 'transfer' || operation === 'withdraw' || operation === 'applyPendingBalance';
|
|
1025
|
+
const needsDestinationAccountState = operation === 'transfer';
|
|
1026
|
+
const mustFetch = broadcast || needsAccountState && !accountState || needsDestinationAccountState && !destinationAccountState || !recentBlockhash || !lastValidBlockHeight;
|
|
1027
|
+
if (mustFetch && !rpcUrl) {
|
|
1028
|
+
throw new node.ClientValidationError('signConfidentialTransfer requires rpcUrl to fetch account state, blockhash, or broadcast');
|
|
1029
|
+
}
|
|
1030
|
+
const connection = rpcUrl ? new web3_js.Connection(this.assertConfidentialRpcUrl(rpcUrl)) : undefined;
|
|
1031
|
+
if (connection) {
|
|
1032
|
+
if (needsAccountState && !accountState) {
|
|
1033
|
+
accountState = await this.svmAccountState(connection, tokenAccount);
|
|
1034
|
+
}
|
|
1035
|
+
if (needsDestinationAccountState && !destinationAccountState && destinationTokenAccount) {
|
|
1036
|
+
destinationAccountState = await this.svmAccountState(connection, destinationTokenAccount);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
if (!recentBlockhash || !lastValidBlockHeight) {
|
|
1040
|
+
const latest = await this.confidentialBlockhash(connection);
|
|
1041
|
+
recentBlockhash = latest.recentBlockhash;
|
|
1042
|
+
lastValidBlockHeight = latest.lastValidBlockHeight;
|
|
1043
|
+
}
|
|
1044
|
+
return {
|
|
1045
|
+
accountState,
|
|
1046
|
+
connection,
|
|
1047
|
+
destinationAccountState,
|
|
1048
|
+
lastValidBlockHeight,
|
|
1049
|
+
recentBlockhash
|
|
1050
|
+
};
|
|
1051
|
+
}, this.assertConfidentialRpcUrl = (rpcUrl)=>{
|
|
1052
|
+
const parsed = new URL(rpcUrl);
|
|
1053
|
+
const isLocalHttp = parsed.protocol === 'http:' && [
|
|
1054
|
+
'localhost',
|
|
1055
|
+
'127.0.0.1',
|
|
1056
|
+
'[::1]'
|
|
1057
|
+
].includes(parsed.hostname);
|
|
1058
|
+
if (parsed.protocol !== 'https:' && !isLocalHttp) {
|
|
1059
|
+
throw new node.ClientValidationError(`Unsupported rpcUrl protocol: ${parsed.protocol}`);
|
|
1060
|
+
}
|
|
1061
|
+
return rpcUrl;
|
|
1062
|
+
};
|
|
916
1063
|
}
|
|
917
1064
|
}
|
|
918
1065
|
|
package/index.esm.js
CHANGED
|
@@ -871,6 +871,72 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
871
871
|
// The sponsor endpoint always returns a v0 versioned transaction.
|
|
872
872
|
return VersionedTransaction.deserialize(sponsoredBytes);
|
|
873
873
|
}
|
|
874
|
+
/**
|
|
875
|
+
* Generates a Token-2022 confidential-transfer seed inside the enclave and
|
|
876
|
+
* stores the sealed result in CKS. Returns the ElGamal public key and the
|
|
877
|
+
* derivation version — persist it for later confidential operations.
|
|
878
|
+
*/ async createConfidentialSeed({ walletId, solanaAddress, derivationVersion, traceContext }) {
|
|
879
|
+
return this.apiClient.createConfidentialSeed({
|
|
880
|
+
walletId,
|
|
881
|
+
request: {
|
|
882
|
+
derivationVersion,
|
|
883
|
+
solanaAddress
|
|
884
|
+
},
|
|
885
|
+
traceContext
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Signs Token-2022 confidential-transfer transactions in the enclave.
|
|
890
|
+
*
|
|
891
|
+
* The enclave is offline, so any missing `accountState` /
|
|
892
|
+
* `destinationAccountState` and the latest blockhash are fetched from
|
|
893
|
+
* `rpcUrl` on the caller's behalf. Pass `broadcast: true` to also submit
|
|
894
|
+
* the signed transactions to the cluster in order.
|
|
895
|
+
*
|
|
896
|
+
* @returns The signed transactions (base64, broadcast order), their
|
|
897
|
+
* signatures, and — when broadcast — the submitted transaction ids.
|
|
898
|
+
*/ async signConfidentialTransfer({ walletId, operation, solanaAddress, mint, tokenAccount, destinationTokenAccount, amount, decimals, accountState, destinationAccountState, auditorElgamalPubkey, feePayer, derivationVersion, chainId = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', lamportsPerByte = '6960', recentBlockhash, lastValidBlockHeight, rpcUrl, broadcast = false, broadcastOptions, traceContext }) {
|
|
899
|
+
const resolved = await this.resolveConfidentialInputs({
|
|
900
|
+
operation,
|
|
901
|
+
tokenAccount,
|
|
902
|
+
destinationTokenAccount,
|
|
903
|
+
accountState,
|
|
904
|
+
destinationAccountState,
|
|
905
|
+
recentBlockhash,
|
|
906
|
+
lastValidBlockHeight,
|
|
907
|
+
rpcUrl,
|
|
908
|
+
broadcast
|
|
909
|
+
});
|
|
910
|
+
const result = await this.apiClient.signConfidentialTransfer({
|
|
911
|
+
walletId,
|
|
912
|
+
request: {
|
|
913
|
+
accountState: resolved.accountState,
|
|
914
|
+
amount,
|
|
915
|
+
auditorElgamalPubkey,
|
|
916
|
+
chainId,
|
|
917
|
+
decimals,
|
|
918
|
+
derivationVersion,
|
|
919
|
+
destinationAccountState: resolved.destinationAccountState,
|
|
920
|
+
destinationTokenAccount,
|
|
921
|
+
feePayer,
|
|
922
|
+
lamportsPerByte,
|
|
923
|
+
lastValidBlockHeight: resolved.lastValidBlockHeight,
|
|
924
|
+
mint,
|
|
925
|
+
operation,
|
|
926
|
+
recentBlockhash: resolved.recentBlockhash,
|
|
927
|
+
solanaAddress,
|
|
928
|
+
tokenAccount
|
|
929
|
+
},
|
|
930
|
+
traceContext
|
|
931
|
+
});
|
|
932
|
+
const transactionIds = broadcast ? await this.broadcastConfidentialTransactions(resolved.connection, result.serializedTransactions, broadcastOptions, {
|
|
933
|
+
blockhash: resolved.recentBlockhash,
|
|
934
|
+
lastValidBlockHeight: Number(resolved.lastValidBlockHeight)
|
|
935
|
+
}) : undefined;
|
|
936
|
+
return _extends({}, result, {
|
|
937
|
+
transactionIds
|
|
938
|
+
});
|
|
939
|
+
}
|
|
874
940
|
/** @deprecated Use getWalletByAddress instead for better performance */ async getSvmWallets() {
|
|
875
941
|
// Calling the deprecated getWallets() is the point of this shim, and it is
|
|
876
942
|
// public and overridable, so routing around it would drop a consumer's override.
|
|
@@ -910,7 +976,88 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
910
976
|
enableMPCAccelerator,
|
|
911
977
|
logger,
|
|
912
978
|
debug
|
|
913
|
-
}), this.chainName = 'SVM'
|
|
979
|
+
}), this.chainName = 'SVM', // ---------------------------------------------------------------------------
|
|
980
|
+
// Token-2022 confidential transfers
|
|
981
|
+
// ---------------------------------------------------------------------------
|
|
982
|
+
this.svmAccountState = async (connection, account)=>{
|
|
983
|
+
const info = await connection.getAccountInfo(new PublicKey(account));
|
|
984
|
+
if (!info) {
|
|
985
|
+
throw new Error(`Solana account not found: ${account}`);
|
|
986
|
+
}
|
|
987
|
+
return {
|
|
988
|
+
data: info.data.toString('base64'),
|
|
989
|
+
lamports: String(info.lamports),
|
|
990
|
+
owner: info.owner.toBase58()
|
|
991
|
+
};
|
|
992
|
+
}, this.confidentialBlockhash = async (connection)=>{
|
|
993
|
+
const latest = connection ? await connection.getLatestBlockhash() : undefined;
|
|
994
|
+
const recentBlockhash = latest == null ? void 0 : latest.blockhash;
|
|
995
|
+
const lastValidBlockHeight = latest ? String(latest.lastValidBlockHeight) : undefined;
|
|
996
|
+
if (!recentBlockhash || !lastValidBlockHeight) {
|
|
997
|
+
throw new ClientValidationError('signConfidentialTransfer requires rpcUrl to fetch the latest blockhash');
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
lastValidBlockHeight,
|
|
1001
|
+
recentBlockhash
|
|
1002
|
+
};
|
|
1003
|
+
}, this.broadcastConfidentialTransactions = async (connection, serializedTransactions, broadcastOptions, confirmationStrategy)=>serializedTransactions.reduce(async (accPromise, serializedTransaction)=>{
|
|
1004
|
+
const acc = await accPromise;
|
|
1005
|
+
const transactionId = await connection.sendRawTransaction(Buffer.from(serializedTransaction, 'base64'), broadcastOptions);
|
|
1006
|
+
// Confidential plans are order-dependent: confirm before submitting
|
|
1007
|
+
// the next transaction or Solana may process them out of order.
|
|
1008
|
+
// confirmTransaction resolves with value.err on a failed transaction
|
|
1009
|
+
// rather than rejecting — surface it instead of broadcasting the rest.
|
|
1010
|
+
const confirmation = await connection.confirmTransaction(_extends({}, confirmationStrategy, {
|
|
1011
|
+
signature: transactionId
|
|
1012
|
+
}), 'confirmed');
|
|
1013
|
+
if (confirmation.value.err) {
|
|
1014
|
+
throw new Error(`Confidential transaction ${transactionId} failed: ${JSON.stringify(confirmation.value.err)}`);
|
|
1015
|
+
}
|
|
1016
|
+
acc.push(transactionId);
|
|
1017
|
+
return acc;
|
|
1018
|
+
}, Promise.resolve([])), /**
|
|
1019
|
+
* Validates `rpcUrl`, fetches missing account states and the latest
|
|
1020
|
+
* blockhash, and returns the inputs the enclave request needs.
|
|
1021
|
+
*/ this.resolveConfidentialInputs = async ({ operation, tokenAccount, destinationTokenAccount, accountState, destinationAccountState, recentBlockhash, lastValidBlockHeight, rpcUrl, broadcast })=>{
|
|
1022
|
+
const needsAccountState = operation === 'transfer' || operation === 'withdraw' || operation === 'applyPendingBalance';
|
|
1023
|
+
const needsDestinationAccountState = operation === 'transfer';
|
|
1024
|
+
const mustFetch = broadcast || needsAccountState && !accountState || needsDestinationAccountState && !destinationAccountState || !recentBlockhash || !lastValidBlockHeight;
|
|
1025
|
+
if (mustFetch && !rpcUrl) {
|
|
1026
|
+
throw new ClientValidationError('signConfidentialTransfer requires rpcUrl to fetch account state, blockhash, or broadcast');
|
|
1027
|
+
}
|
|
1028
|
+
const connection = rpcUrl ? new Connection(this.assertConfidentialRpcUrl(rpcUrl)) : undefined;
|
|
1029
|
+
if (connection) {
|
|
1030
|
+
if (needsAccountState && !accountState) {
|
|
1031
|
+
accountState = await this.svmAccountState(connection, tokenAccount);
|
|
1032
|
+
}
|
|
1033
|
+
if (needsDestinationAccountState && !destinationAccountState && destinationTokenAccount) {
|
|
1034
|
+
destinationAccountState = await this.svmAccountState(connection, destinationTokenAccount);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
if (!recentBlockhash || !lastValidBlockHeight) {
|
|
1038
|
+
const latest = await this.confidentialBlockhash(connection);
|
|
1039
|
+
recentBlockhash = latest.recentBlockhash;
|
|
1040
|
+
lastValidBlockHeight = latest.lastValidBlockHeight;
|
|
1041
|
+
}
|
|
1042
|
+
return {
|
|
1043
|
+
accountState,
|
|
1044
|
+
connection,
|
|
1045
|
+
destinationAccountState,
|
|
1046
|
+
lastValidBlockHeight,
|
|
1047
|
+
recentBlockhash
|
|
1048
|
+
};
|
|
1049
|
+
}, this.assertConfidentialRpcUrl = (rpcUrl)=>{
|
|
1050
|
+
const parsed = new URL(rpcUrl);
|
|
1051
|
+
const isLocalHttp = parsed.protocol === 'http:' && [
|
|
1052
|
+
'localhost',
|
|
1053
|
+
'127.0.0.1',
|
|
1054
|
+
'[::1]'
|
|
1055
|
+
].includes(parsed.hostname);
|
|
1056
|
+
if (parsed.protocol !== 'https:' && !isLocalHttp) {
|
|
1057
|
+
throw new ClientValidationError(`Unsupported rpcUrl protocol: ${parsed.protocol}`);
|
|
1058
|
+
}
|
|
1059
|
+
return rpcUrl;
|
|
1060
|
+
};
|
|
914
1061
|
}
|
|
915
1062
|
}
|
|
916
1063
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-svm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.57",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "1.1.
|
|
7
|
+
"@dynamic-labs-wallet/node": "1.1.57",
|
|
8
8
|
"@solana/web3.js": "^1.98.2"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ServerKeyShare, DynamicWalletClient, type Ed25519KeygenResult, type ThresholdSignatureScheme, type TraceContext, type DynamicWalletClientProps, type WalletMetadata, type WalletApiKeyCreationResult, type RawSignPreImage, type SignMessageContext } from '@dynamic-labs-wallet/node';
|
|
2
|
-
import { type Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
1
|
+
import { type ServerKeyShare, DynamicWalletClient, type Ed25519KeygenResult, type ThresholdSignatureScheme, type TraceContext, type DynamicWalletClientProps, type WalletMetadata, type WalletApiKeyCreationResult, type RawSignPreImage, type SignMessageContext, type ConfidentialAccountState, type ConfidentialTransferOperation } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import { type SendOptions, type Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
import type { ClaimEarnRewardsParams, DepositToEarnVaultParams, EarnTransactionResult, ExecuteEarnTransactionParams, WithdrawFromEarnVaultParams } from './earn.types.js';
|
|
4
4
|
type SvmSignableTransaction = VersionedTransaction | Transaction | string;
|
|
5
5
|
type SignTransactionResult = string | {
|
|
@@ -10,7 +10,7 @@ export declare const ERROR_SIGN_TRANSACTION_CONTEXT_REQUIRED = "SVM transaction
|
|
|
10
10
|
export declare const ERROR_SIGN_TRANSACTION_RAW_HEX_CONTEXT_REQUIRED = "SVM transaction signing requires an explicit context.svmTransaction when transaction is a raw hex string.";
|
|
11
11
|
export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
12
12
|
readonly chainName = "SVM";
|
|
13
|
-
accountAddress?: string;
|
|
13
|
+
readonly accountAddress?: string;
|
|
14
14
|
constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, enableMPCAccelerator, logger, debug, }: DynamicWalletClientProps);
|
|
15
15
|
/**
|
|
16
16
|
* Creates a wallet account on the Solana chain
|
|
@@ -159,6 +159,66 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
159
159
|
transaction: VersionedTransaction | Transaction;
|
|
160
160
|
traceContext?: TraceContext;
|
|
161
161
|
}): Promise<VersionedTransaction>;
|
|
162
|
+
private readonly svmAccountState;
|
|
163
|
+
private readonly confidentialBlockhash;
|
|
164
|
+
private readonly broadcastConfidentialTransactions;
|
|
165
|
+
/**
|
|
166
|
+
* Generates a Token-2022 confidential-transfer seed inside the enclave and
|
|
167
|
+
* stores the sealed result in CKS. Returns the ElGamal public key and the
|
|
168
|
+
* derivation version — persist it for later confidential operations.
|
|
169
|
+
*/
|
|
170
|
+
createConfidentialSeed({ walletId, solanaAddress, derivationVersion, traceContext, }: {
|
|
171
|
+
walletId: string;
|
|
172
|
+
solanaAddress: string;
|
|
173
|
+
derivationVersion?: number;
|
|
174
|
+
traceContext?: TraceContext;
|
|
175
|
+
}): Promise<import("@dynamic-labs-wallet/core").CreateConfidentialSeedResponse>;
|
|
176
|
+
/**
|
|
177
|
+
* Signs Token-2022 confidential-transfer transactions in the enclave.
|
|
178
|
+
*
|
|
179
|
+
* The enclave is offline, so any missing `accountState` /
|
|
180
|
+
* `destinationAccountState` and the latest blockhash are fetched from
|
|
181
|
+
* `rpcUrl` on the caller's behalf. Pass `broadcast: true` to also submit
|
|
182
|
+
* the signed transactions to the cluster in order.
|
|
183
|
+
*
|
|
184
|
+
* @returns The signed transactions (base64, broadcast order), their
|
|
185
|
+
* signatures, and — when broadcast — the submitted transaction ids.
|
|
186
|
+
*/
|
|
187
|
+
signConfidentialTransfer({ walletId, operation, solanaAddress, mint, tokenAccount, destinationTokenAccount, amount, decimals, accountState, destinationAccountState, auditorElgamalPubkey, feePayer, derivationVersion, chainId, lamportsPerByte, recentBlockhash, lastValidBlockHeight, rpcUrl, broadcast, broadcastOptions, traceContext, }: {
|
|
188
|
+
walletId: string;
|
|
189
|
+
operation: ConfidentialTransferOperation;
|
|
190
|
+
solanaAddress: string;
|
|
191
|
+
mint: string;
|
|
192
|
+
tokenAccount: string;
|
|
193
|
+
destinationTokenAccount?: string;
|
|
194
|
+
amount?: string;
|
|
195
|
+
decimals?: number;
|
|
196
|
+
accountState?: ConfidentialAccountState;
|
|
197
|
+
destinationAccountState?: ConfidentialAccountState;
|
|
198
|
+
auditorElgamalPubkey?: string;
|
|
199
|
+
feePayer?: string;
|
|
200
|
+
derivationVersion?: number;
|
|
201
|
+
chainId?: string;
|
|
202
|
+
lamportsPerByte?: string;
|
|
203
|
+
/** Fetched from `rpcUrl` when omitted. */
|
|
204
|
+
recentBlockhash?: string;
|
|
205
|
+
lastValidBlockHeight?: string;
|
|
206
|
+
/** Solana JSON-RPC endpoint, required to fetch account state / blockhash or to broadcast. */
|
|
207
|
+
rpcUrl?: string;
|
|
208
|
+
broadcast?: boolean;
|
|
209
|
+
broadcastOptions?: SendOptions;
|
|
210
|
+
traceContext?: TraceContext;
|
|
211
|
+
}): Promise<{
|
|
212
|
+
transactionIds: string[] | undefined;
|
|
213
|
+
serializedTransactions: string[];
|
|
214
|
+
signatures: string[];
|
|
215
|
+
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Validates `rpcUrl`, fetches missing account states and the latest
|
|
218
|
+
* blockhash, and returns the inputs the enclave request needs.
|
|
219
|
+
*/
|
|
220
|
+
private readonly resolveConfidentialInputs;
|
|
221
|
+
private readonly assertConfidentialRpcUrl;
|
|
162
222
|
/** @deprecated Use getWalletByAddress instead for better performance */
|
|
163
223
|
getSvmWallets(): Promise<{
|
|
164
224
|
walletId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EAGjB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,0BAA0B,EAE/B,KAAK,eAAe,EAGpB,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EAGjB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,0BAA0B,EAE/B,KAAK,eAAe,EAGpB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EACnC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AAKzB,KAAK,sBAAsB,GAAG,oBAAoB,GAAG,WAAW,GAAG,MAAM,CAAC;AAC1E,KAAK,qBAAqB,GAAG,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAAA;CAAE,CAAC;AAM7G,eAAO,MAAM,uCAAuC,sFACiC,CAAC;AAEtF,eAAO,MAAM,+CAA+C,8GACiD,CAAC;AAgD9G,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