@dynamic-labs-wallet/svm 0.0.32 → 0.0.34
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.js +52 -91
- package/index.esm.js +54 -93
- package/package.json +3 -3
- package/src/svm/svm.d.ts +15 -13
- package/src/svm/svm.d.ts.map +1 -1
- package/src/svm/utils.d.ts +4 -4
- package/src/svm/utils.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -3,66 +3,25 @@
|
|
|
3
3
|
var browser = require('@dynamic-labs-wallet/browser');
|
|
4
4
|
var bs58 = require('bs58');
|
|
5
5
|
var web3_js = require('@solana/web3.js');
|
|
6
|
-
|
|
6
|
+
require('@dynamic-labs-wallet/core');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const addSignatureToTransaction = ({ transaction, signature })=>{
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
async function createSolanaTransaction({ senderSolanaAddress, amount, to, rpcUrl = 'https://api.devnet.solana.com' }) {
|
|
19
|
-
try {
|
|
20
|
-
const connection = new web3_js.Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
|
|
21
|
-
const balance = await getBalance({
|
|
22
|
-
address: senderSolanaAddress,
|
|
23
|
-
rpcUrl
|
|
24
|
-
});
|
|
25
|
-
if (balance < amount * 1e9) {
|
|
26
|
-
throw new Error('Insufficient balance');
|
|
10
|
+
if (transaction instanceof web3_js.Transaction) {
|
|
11
|
+
transaction.addSignature(transaction.feePayer, Buffer.from(signature));
|
|
12
|
+
} else {
|
|
13
|
+
// For versioned transactions, we should add the signature to the fee payer
|
|
14
|
+
// which is always the first account in the static account keys
|
|
15
|
+
// TODO: see if this works for sponsored transactions
|
|
16
|
+
const feePayer = transaction.message.staticAccountKeys[0];
|
|
17
|
+
transaction.addSignature(feePayer, Buffer.from(signature));
|
|
27
18
|
}
|
|
28
|
-
|
|
29
|
-
const transaction = new web3_js.Transaction().add(web3_js.SystemProgram.transfer({
|
|
30
|
-
fromPubkey: fromPubkey,
|
|
31
|
-
toPubkey: new web3_js.PublicKey(to),
|
|
32
|
-
lamports: amount * 1e9
|
|
33
|
-
}));
|
|
34
|
-
const { blockhash } = await connection.getLatestBlockhash();
|
|
35
|
-
transaction.recentBlockhash = blockhash;
|
|
36
|
-
transaction.feePayer = fromPubkey;
|
|
37
|
-
const serializedTransaction = transaction.serializeMessage();
|
|
38
|
-
return {
|
|
39
|
-
transaction,
|
|
40
|
-
serializedTransaction
|
|
41
|
-
};
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.error('Error in creating transaction:', error);
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function finalizeTransaction({ transaction, signature }) {
|
|
48
|
-
try {
|
|
49
|
-
transaction.addSignature(transaction.feePayer, Buffer.from(signature));
|
|
50
|
-
return new Uint8Array(transaction.serialize());
|
|
19
|
+
return transaction;
|
|
51
20
|
} catch (error) {
|
|
52
21
|
console.error('Error in finalizing transaction:', error);
|
|
53
22
|
throw error;
|
|
54
23
|
}
|
|
55
|
-
}
|
|
56
|
-
async function sendTransaction({ signedTransaction, rpcUrl = 'https://api.devnet.solana.com' }) {
|
|
57
|
-
try {
|
|
58
|
-
const connection = new web3_js.Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
|
|
59
|
-
const txid = await connection.sendRawTransaction(Buffer.from(signedTransaction));
|
|
60
|
-
return txid;
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.error('Error in sending transaction:', error);
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
24
|
+
};
|
|
66
25
|
|
|
67
26
|
class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
68
27
|
/**
|
|
@@ -70,7 +29,7 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
70
29
|
*
|
|
71
30
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
72
31
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
73
|
-
*/ async createWalletAccount({ thresholdSignatureScheme }) {
|
|
32
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password = undefined }) {
|
|
74
33
|
try {
|
|
75
34
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
76
35
|
chainName: this.chainName,
|
|
@@ -93,11 +52,12 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
93
52
|
walletId: newWalletId,
|
|
94
53
|
chainName: this.chainName,
|
|
95
54
|
clientKeyShares: clientKeyShares,
|
|
96
|
-
thresholdSignatureScheme
|
|
55
|
+
thresholdSignatureScheme,
|
|
56
|
+
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
97
57
|
};
|
|
98
58
|
await this.storeEncryptedBackupByWallet({
|
|
99
59
|
accountAddress,
|
|
100
|
-
password
|
|
60
|
+
password
|
|
101
61
|
});
|
|
102
62
|
return {
|
|
103
63
|
accountAddress,
|
|
@@ -120,8 +80,14 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
120
80
|
* This function takes a message and returns it after being signed with MPC
|
|
121
81
|
*
|
|
122
82
|
* @param message The message to sign (Uint8Array)
|
|
123
|
-
* @param
|
|
124
|
-
|
|
83
|
+
* @param accountAddress Solana address (base58 encoded)
|
|
84
|
+
* @param password The password for encrypted backup shares
|
|
85
|
+
*/ async signMessage({ message, accountAddress, password = undefined }) {
|
|
86
|
+
await this.verifyPassword({
|
|
87
|
+
accountAddress,
|
|
88
|
+
password,
|
|
89
|
+
walletOperation: browser.WalletOperation.SIGN_MESSAGE
|
|
90
|
+
});
|
|
125
91
|
if (!accountAddress) {
|
|
126
92
|
throw new Error('Account address is required');
|
|
127
93
|
}
|
|
@@ -129,7 +95,8 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
129
95
|
const signatureEd25519 = await this.sign({
|
|
130
96
|
message,
|
|
131
97
|
accountAddress: accountAddress,
|
|
132
|
-
chainName: this.chainName
|
|
98
|
+
chainName: this.chainName,
|
|
99
|
+
password
|
|
133
100
|
});
|
|
134
101
|
const base58Signature = bs58.encode(signatureEd25519);
|
|
135
102
|
return base58Signature;
|
|
@@ -158,48 +125,39 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
158
125
|
// console.log('verified', verified);
|
|
159
126
|
// return verified;
|
|
160
127
|
// }
|
|
161
|
-
async signTransaction({ senderAddress,
|
|
128
|
+
async signTransaction({ senderAddress, transaction, password = undefined }) {
|
|
129
|
+
await this.verifyPassword({
|
|
130
|
+
accountAddress: senderAddress,
|
|
131
|
+
password,
|
|
132
|
+
walletOperation: browser.WalletOperation.SIGN_TRANSACTION
|
|
133
|
+
});
|
|
162
134
|
try {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
135
|
+
let messageToSign;
|
|
136
|
+
if (transaction instanceof web3_js.VersionedTransaction) {
|
|
137
|
+
// For versioned transactions, we need to sign the message directly
|
|
138
|
+
const messageBytes = transaction.message.serialize();
|
|
139
|
+
messageToSign = Buffer.from(messageBytes).toString('hex');
|
|
140
|
+
} else {
|
|
141
|
+
// For legacy transactions, serialize the message
|
|
142
|
+
const messageBytes = transaction.serializeMessage();
|
|
143
|
+
messageToSign = Buffer.from(messageBytes).toString('hex');
|
|
171
144
|
}
|
|
172
|
-
const rawMessageToSign = new Uint8Array(serializedTransaction);
|
|
173
|
-
//convert raw bites to hex to send to server
|
|
174
|
-
const messageToSign = Buffer.from(rawMessageToSign).toString('hex');
|
|
175
145
|
const signatureEd25519 = await this.sign({
|
|
176
146
|
message: messageToSign,
|
|
177
147
|
accountAddress: senderAddress,
|
|
178
|
-
chainName: this.chainName
|
|
148
|
+
chainName: this.chainName,
|
|
149
|
+
password
|
|
179
150
|
});
|
|
180
151
|
if (!signatureEd25519) {
|
|
181
152
|
throw new Error('Signature is undefined');
|
|
182
153
|
}
|
|
183
|
-
const signedTransaction =
|
|
154
|
+
const signedTransaction = addSignatureToTransaction({
|
|
184
155
|
transaction,
|
|
185
156
|
signature: signatureEd25519
|
|
186
157
|
});
|
|
187
|
-
|
|
188
|
-
throw new Error('Signed transaction is undefined');
|
|
189
|
-
}
|
|
190
|
-
const txid = await sendTransaction({
|
|
191
|
-
signedTransaction,
|
|
192
|
-
rpcUrl
|
|
193
|
-
});
|
|
194
|
-
if (!txid) {
|
|
195
|
-
throw new Error('Transaction hash is undefined');
|
|
196
|
-
}
|
|
197
|
-
return {
|
|
198
|
-
txHash: txid,
|
|
199
|
-
signedTx: serializedTransaction
|
|
200
|
-
};
|
|
158
|
+
return signedTransaction;
|
|
201
159
|
} catch (error) {
|
|
202
|
-
this.logger.error('Error in
|
|
160
|
+
this.logger.error('Error in signTransaction:', error);
|
|
203
161
|
if (error instanceof Error) {
|
|
204
162
|
this.logger.error('Error details:', error);
|
|
205
163
|
}
|
|
@@ -210,11 +168,13 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
210
168
|
* Exports the private key for a given account address
|
|
211
169
|
*
|
|
212
170
|
* @param accountAddress The account address to export the private key for
|
|
171
|
+
* @param password The password for encrypted backup shares
|
|
213
172
|
* @returns The private key
|
|
214
|
-
*/ async exportPrivateKey({ accountAddress }) {
|
|
173
|
+
*/ async exportPrivateKey({ accountAddress, password = undefined }) {
|
|
215
174
|
const { derivedPrivateKey } = await this.exportKey({
|
|
216
175
|
accountAddress,
|
|
217
|
-
chainName: this.chainName
|
|
176
|
+
chainName: this.chainName,
|
|
177
|
+
password
|
|
218
178
|
});
|
|
219
179
|
if (!derivedPrivateKey) {
|
|
220
180
|
throw new Error('Derived private key is undefined');
|
|
@@ -289,7 +249,8 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
289
249
|
walletId: newWalletId,
|
|
290
250
|
chainName: this.chainName,
|
|
291
251
|
clientKeyShares,
|
|
292
|
-
thresholdSignatureScheme
|
|
252
|
+
thresholdSignatureScheme,
|
|
253
|
+
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
293
254
|
};
|
|
294
255
|
await this.storeEncryptedBackupByWallet({
|
|
295
256
|
accountAddress
|
package/index.esm.js
CHANGED
|
@@ -1,66 +1,25 @@
|
|
|
1
|
-
import { DynamicWalletClient } from '@dynamic-labs-wallet/browser';
|
|
1
|
+
import { DynamicWalletClient, getClientKeyShareBackupInfo, WalletOperation } from '@dynamic-labs-wallet/browser';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { Transaction, VersionedTransaction, Keypair } from '@solana/web3.js';
|
|
4
|
+
import '@dynamic-labs-wallet/core';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const addSignatureToTransaction = ({ transaction, signature })=>{
|
|
7
7
|
try {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
async function createSolanaTransaction({ senderSolanaAddress, amount, to, rpcUrl = 'https://api.devnet.solana.com' }) {
|
|
17
|
-
try {
|
|
18
|
-
const connection = new Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
|
|
19
|
-
const balance = await getBalance({
|
|
20
|
-
address: senderSolanaAddress,
|
|
21
|
-
rpcUrl
|
|
22
|
-
});
|
|
23
|
-
if (balance < amount * 1e9) {
|
|
24
|
-
throw new Error('Insufficient balance');
|
|
8
|
+
if (transaction instanceof Transaction) {
|
|
9
|
+
transaction.addSignature(transaction.feePayer, Buffer.from(signature));
|
|
10
|
+
} else {
|
|
11
|
+
// For versioned transactions, we should add the signature to the fee payer
|
|
12
|
+
// which is always the first account in the static account keys
|
|
13
|
+
// TODO: see if this works for sponsored transactions
|
|
14
|
+
const feePayer = transaction.message.staticAccountKeys[0];
|
|
15
|
+
transaction.addSignature(feePayer, Buffer.from(signature));
|
|
25
16
|
}
|
|
26
|
-
|
|
27
|
-
const transaction = new Transaction().add(SystemProgram.transfer({
|
|
28
|
-
fromPubkey: fromPubkey,
|
|
29
|
-
toPubkey: new PublicKey(to),
|
|
30
|
-
lamports: amount * 1e9
|
|
31
|
-
}));
|
|
32
|
-
const { blockhash } = await connection.getLatestBlockhash();
|
|
33
|
-
transaction.recentBlockhash = blockhash;
|
|
34
|
-
transaction.feePayer = fromPubkey;
|
|
35
|
-
const serializedTransaction = transaction.serializeMessage();
|
|
36
|
-
return {
|
|
37
|
-
transaction,
|
|
38
|
-
serializedTransaction
|
|
39
|
-
};
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error('Error in creating transaction:', error);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function finalizeTransaction({ transaction, signature }) {
|
|
46
|
-
try {
|
|
47
|
-
transaction.addSignature(transaction.feePayer, Buffer.from(signature));
|
|
48
|
-
return new Uint8Array(transaction.serialize());
|
|
17
|
+
return transaction;
|
|
49
18
|
} catch (error) {
|
|
50
19
|
console.error('Error in finalizing transaction:', error);
|
|
51
20
|
throw error;
|
|
52
21
|
}
|
|
53
|
-
}
|
|
54
|
-
async function sendTransaction({ signedTransaction, rpcUrl = 'https://api.devnet.solana.com' }) {
|
|
55
|
-
try {
|
|
56
|
-
const connection = new Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
|
|
57
|
-
const txid = await connection.sendRawTransaction(Buffer.from(signedTransaction));
|
|
58
|
-
return txid;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
console.error('Error in sending transaction:', error);
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
22
|
+
};
|
|
64
23
|
|
|
65
24
|
class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
66
25
|
/**
|
|
@@ -68,7 +27,7 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
68
27
|
*
|
|
69
28
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
70
29
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
71
|
-
*/ async createWalletAccount({ thresholdSignatureScheme }) {
|
|
30
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password = undefined }) {
|
|
72
31
|
try {
|
|
73
32
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
74
33
|
chainName: this.chainName,
|
|
@@ -91,11 +50,12 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
91
50
|
walletId: newWalletId,
|
|
92
51
|
chainName: this.chainName,
|
|
93
52
|
clientKeyShares: clientKeyShares,
|
|
94
|
-
thresholdSignatureScheme
|
|
53
|
+
thresholdSignatureScheme,
|
|
54
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
95
55
|
};
|
|
96
56
|
await this.storeEncryptedBackupByWallet({
|
|
97
57
|
accountAddress,
|
|
98
|
-
password
|
|
58
|
+
password
|
|
99
59
|
});
|
|
100
60
|
return {
|
|
101
61
|
accountAddress,
|
|
@@ -118,8 +78,14 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
118
78
|
* This function takes a message and returns it after being signed with MPC
|
|
119
79
|
*
|
|
120
80
|
* @param message The message to sign (Uint8Array)
|
|
121
|
-
* @param
|
|
122
|
-
|
|
81
|
+
* @param accountAddress Solana address (base58 encoded)
|
|
82
|
+
* @param password The password for encrypted backup shares
|
|
83
|
+
*/ async signMessage({ message, accountAddress, password = undefined }) {
|
|
84
|
+
await this.verifyPassword({
|
|
85
|
+
accountAddress,
|
|
86
|
+
password,
|
|
87
|
+
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
88
|
+
});
|
|
123
89
|
if (!accountAddress) {
|
|
124
90
|
throw new Error('Account address is required');
|
|
125
91
|
}
|
|
@@ -127,7 +93,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
127
93
|
const signatureEd25519 = await this.sign({
|
|
128
94
|
message,
|
|
129
95
|
accountAddress: accountAddress,
|
|
130
|
-
chainName: this.chainName
|
|
96
|
+
chainName: this.chainName,
|
|
97
|
+
password
|
|
131
98
|
});
|
|
132
99
|
const base58Signature = bs58.encode(signatureEd25519);
|
|
133
100
|
return base58Signature;
|
|
@@ -156,48 +123,39 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
156
123
|
// console.log('verified', verified);
|
|
157
124
|
// return verified;
|
|
158
125
|
// }
|
|
159
|
-
async signTransaction({ senderAddress,
|
|
126
|
+
async signTransaction({ senderAddress, transaction, password = undefined }) {
|
|
127
|
+
await this.verifyPassword({
|
|
128
|
+
accountAddress: senderAddress,
|
|
129
|
+
password,
|
|
130
|
+
walletOperation: WalletOperation.SIGN_TRANSACTION
|
|
131
|
+
});
|
|
160
132
|
try {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
133
|
+
let messageToSign;
|
|
134
|
+
if (transaction instanceof VersionedTransaction) {
|
|
135
|
+
// For versioned transactions, we need to sign the message directly
|
|
136
|
+
const messageBytes = transaction.message.serialize();
|
|
137
|
+
messageToSign = Buffer.from(messageBytes).toString('hex');
|
|
138
|
+
} else {
|
|
139
|
+
// For legacy transactions, serialize the message
|
|
140
|
+
const messageBytes = transaction.serializeMessage();
|
|
141
|
+
messageToSign = Buffer.from(messageBytes).toString('hex');
|
|
169
142
|
}
|
|
170
|
-
const rawMessageToSign = new Uint8Array(serializedTransaction);
|
|
171
|
-
//convert raw bites to hex to send to server
|
|
172
|
-
const messageToSign = Buffer.from(rawMessageToSign).toString('hex');
|
|
173
143
|
const signatureEd25519 = await this.sign({
|
|
174
144
|
message: messageToSign,
|
|
175
145
|
accountAddress: senderAddress,
|
|
176
|
-
chainName: this.chainName
|
|
146
|
+
chainName: this.chainName,
|
|
147
|
+
password
|
|
177
148
|
});
|
|
178
149
|
if (!signatureEd25519) {
|
|
179
150
|
throw new Error('Signature is undefined');
|
|
180
151
|
}
|
|
181
|
-
const signedTransaction =
|
|
152
|
+
const signedTransaction = addSignatureToTransaction({
|
|
182
153
|
transaction,
|
|
183
154
|
signature: signatureEd25519
|
|
184
155
|
});
|
|
185
|
-
|
|
186
|
-
throw new Error('Signed transaction is undefined');
|
|
187
|
-
}
|
|
188
|
-
const txid = await sendTransaction({
|
|
189
|
-
signedTransaction,
|
|
190
|
-
rpcUrl
|
|
191
|
-
});
|
|
192
|
-
if (!txid) {
|
|
193
|
-
throw new Error('Transaction hash is undefined');
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
txHash: txid,
|
|
197
|
-
signedTx: serializedTransaction
|
|
198
|
-
};
|
|
156
|
+
return signedTransaction;
|
|
199
157
|
} catch (error) {
|
|
200
|
-
this.logger.error('Error in
|
|
158
|
+
this.logger.error('Error in signTransaction:', error);
|
|
201
159
|
if (error instanceof Error) {
|
|
202
160
|
this.logger.error('Error details:', error);
|
|
203
161
|
}
|
|
@@ -208,11 +166,13 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
208
166
|
* Exports the private key for a given account address
|
|
209
167
|
*
|
|
210
168
|
* @param accountAddress The account address to export the private key for
|
|
169
|
+
* @param password The password for encrypted backup shares
|
|
211
170
|
* @returns The private key
|
|
212
|
-
*/ async exportPrivateKey({ accountAddress }) {
|
|
171
|
+
*/ async exportPrivateKey({ accountAddress, password = undefined }) {
|
|
213
172
|
const { derivedPrivateKey } = await this.exportKey({
|
|
214
173
|
accountAddress,
|
|
215
|
-
chainName: this.chainName
|
|
174
|
+
chainName: this.chainName,
|
|
175
|
+
password
|
|
216
176
|
});
|
|
217
177
|
if (!derivedPrivateKey) {
|
|
218
178
|
throw new Error('Derived private key is undefined');
|
|
@@ -287,7 +247,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
287
247
|
walletId: newWalletId,
|
|
288
248
|
chainName: this.chainName,
|
|
289
249
|
clientKeyShares,
|
|
290
|
-
thresholdSignatureScheme
|
|
250
|
+
thresholdSignatureScheme,
|
|
251
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
291
252
|
};
|
|
292
253
|
await this.storeEncryptedBackupByWallet({
|
|
293
254
|
accountAddress
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/svm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@dynamic-labs-wallet/browser": "0.0.
|
|
6
|
-
"@dynamic-labs-wallet/core": "0.0.
|
|
5
|
+
"@dynamic-labs-wallet/browser": "0.0.34",
|
|
6
|
+
"@dynamic-labs-wallet/core": "0.0.34",
|
|
7
7
|
"@solana/web3.js": "^1.98.0",
|
|
8
8
|
"bs58": "^6.0.0"
|
|
9
9
|
},
|
package/src/svm/svm.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ClientKeyShare, DynamicWalletClient, Ed25519KeygenResult, ThresholdSignatureScheme } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
2
3
|
export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
3
4
|
readonly chainName = "SOL";
|
|
4
5
|
accountAddress?: string;
|
|
@@ -14,8 +15,9 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
14
15
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
15
16
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
16
17
|
*/
|
|
17
|
-
createWalletAccount({ thresholdSignatureScheme, }: {
|
|
18
|
+
createWalletAccount({ thresholdSignatureScheme, password, }: {
|
|
18
19
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
20
|
+
password?: string;
|
|
19
21
|
}): Promise<{
|
|
20
22
|
accountAddress: string;
|
|
21
23
|
rawPublicKey: Uint8Array;
|
|
@@ -28,29 +30,29 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
28
30
|
* This function takes a message and returns it after being signed with MPC
|
|
29
31
|
*
|
|
30
32
|
* @param message The message to sign (Uint8Array)
|
|
31
|
-
* @param
|
|
33
|
+
* @param accountAddress Solana address (base58 encoded)
|
|
34
|
+
* @param password The password for encrypted backup shares
|
|
32
35
|
*/
|
|
33
|
-
signMessage({ message, accountAddress, }: {
|
|
36
|
+
signMessage({ message, accountAddress, password, }: {
|
|
34
37
|
message: string;
|
|
35
|
-
accountAddress
|
|
38
|
+
accountAddress: string;
|
|
39
|
+
password?: string;
|
|
36
40
|
}): Promise<string>;
|
|
37
|
-
signTransaction({ senderAddress,
|
|
41
|
+
signTransaction({ senderAddress, transaction, password, }: {
|
|
38
42
|
senderAddress: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}): Promise<{
|
|
43
|
-
txHash?: string;
|
|
44
|
-
signedTx: Uint8Array;
|
|
45
|
-
}>;
|
|
43
|
+
transaction: VersionedTransaction | Transaction;
|
|
44
|
+
password?: string;
|
|
45
|
+
}): Promise<VersionedTransaction | Transaction>;
|
|
46
46
|
/**
|
|
47
47
|
* Exports the private key for a given account address
|
|
48
48
|
*
|
|
49
49
|
* @param accountAddress The account address to export the private key for
|
|
50
|
+
* @param password The password for encrypted backup shares
|
|
50
51
|
* @returns The private key
|
|
51
52
|
*/
|
|
52
|
-
exportPrivateKey({ accountAddress }: {
|
|
53
|
+
exportPrivateKey({ accountAddress, password, }: {
|
|
53
54
|
accountAddress: string;
|
|
55
|
+
password?: string;
|
|
54
56
|
}): Promise<{
|
|
55
57
|
derivedPrivateKey: string;
|
|
56
58
|
}>;
|
package/src/svm/svm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svm.d.ts","sourceRoot":"","sources":["../../src/svm/svm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"svm.d.ts","sourceRoot":"","sources":["../../src/svm/svm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EAGzB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAW,WAAW,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG7E,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;gBAEZ,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,GACnB,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B;IASD;;;;;OAKG;IACG,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,GACrB,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,UAAU,CAAC;QACzB,eAAe,EAAE,cAAc,EAAE,CAAC;KACnC,CAAC;IAoDI,oBAAoB,CAAC,YAAY,EAAE,UAAU;;;IAOnD;;;;;;OAMG;IACG,WAAW,CAAC,EAChB,OAAO,EACP,cAAc,EACd,QAAoB,GACrB,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IA6CK,eAAe,CAAC,EACpB,aAAa,EACb,WAAW,EACX,QAAoB,GACrB,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,oBAAoB,GAAG,WAAW,CAAC;QAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,oBAAoB,GAAG,WAAW,CAAC;IA0C/C;;;;;;OAMG;IACG,gBAAgB,CAAC,EACrB,cAAc,EACd,QAAoB,GACrB,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;;;IAaD;;;;;OAKG;IACG,uBAAuB,CAAC,EAC5B,SAAS,EACT,cAAc,GACf,EAAE;QACD,SAAS,EAAE,mBAAmB,EAAE,CAAC;QACjC,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;;;IASD;;;;;OAKG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM;IAM5C,0BAA0B,CAAC,UAAU,EAAE,MAAM;IAQ7C,eAAe,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM;IAI9C;;;;;;;OAOG;IACG,gBAAgB,CAAC,EACrB,UAAU,EACV,SAAS,EACT,wBAAwB,GACzB,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,wBAAwB,EAAE,wBAAwB,CAAC;KACpD,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,UAAU,GAAG,SAAS,CAAC;QACrC,eAAe,EAAE,cAAc,EAAE,CAAC;KACnC,CAAC;IAmDI,aAAa;CAOpB"}
|
package/src/svm/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction } from '@solana/web3.js';
|
|
1
|
+
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
2
2
|
export declare function getBalance({ address, rpcUrl, }: {
|
|
3
3
|
address: string;
|
|
4
4
|
rpcUrl?: string;
|
|
@@ -12,10 +12,10 @@ export declare function createSolanaTransaction({ senderSolanaAddress, amount, t
|
|
|
12
12
|
transaction: Transaction;
|
|
13
13
|
serializedTransaction: Buffer;
|
|
14
14
|
}>;
|
|
15
|
-
export declare
|
|
16
|
-
transaction: Transaction;
|
|
15
|
+
export declare const addSignatureToTransaction: ({ transaction, signature, }: {
|
|
16
|
+
transaction: Transaction | VersionedTransaction;
|
|
17
17
|
signature: Uint8Array;
|
|
18
|
-
})
|
|
18
|
+
}) => VersionedTransaction | Transaction;
|
|
19
19
|
export declare function sendTransaction({ signedTransaction, rpcUrl, }: {
|
|
20
20
|
signedTransaction: Uint8Array;
|
|
21
21
|
rpcUrl?: string;
|
package/src/svm/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/svm/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/svm/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,EACX,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB,wBAAsB,UAAU,CAAC,EAC/B,OAAO,EACP,MAAuB,GACxB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,mBAWA;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,mBAAmB,EACnB,MAAM,EACN,EAAE,EACF,MAAwC,GACzC,EAAE;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;GA+BA;AAED,eAAO,MAAM,yBAAyB,gCAGnC;IACD,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAAC;IAChD,SAAS,EAAE,UAAU,CAAC;CACvB,KAAG,oBAAoB,GAAG,WAmB1B,CAAC;AAEF,wBAAsB,eAAe,CAAC,EACpC,iBAAiB,EACjB,MAAwC,GACzC,EAAE;IACD,iBAAiB,EAAE,UAAU,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,mBAaA"}
|