@dynamic-labs-wallet/node-svm 0.0.0-beta.3 → 0.0.0-beta.308.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.js +53 -30
- package/index.esm.js +53 -30
- package/package.json +4 -4
- package/src/client/client.d.ts +15 -12
- package/src/client/client.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -61,8 +61,12 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
61
61
|
*
|
|
62
62
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
63
63
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
64
|
-
*/ async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
64
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError, backUpToClientShareService = false }) {
|
|
65
65
|
try {
|
|
66
|
+
let ceremonyCeremonyCompleteResolver;
|
|
67
|
+
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
68
|
+
ceremonyCeremonyCompleteResolver = resolve;
|
|
69
|
+
});
|
|
66
70
|
const { rawPublicKey, externalServerKeyShares } = await this.keyGen({
|
|
67
71
|
chainName: this.chainName,
|
|
68
72
|
thresholdSignatureScheme,
|
|
@@ -76,23 +80,34 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
76
80
|
thresholdSignatureScheme,
|
|
77
81
|
externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
|
|
78
82
|
});
|
|
83
|
+
this.logger.debug('walletMap updated for wallet', {
|
|
84
|
+
context: {
|
|
85
|
+
accountAddress,
|
|
86
|
+
walletId,
|
|
87
|
+
walletMap: this.walletMap
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
ceremonyCeremonyCompleteResolver(undefined);
|
|
79
91
|
}
|
|
80
92
|
});
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
// Wait for the ceremony to complete before proceeding
|
|
94
|
+
await ceremonyCompletePromise;
|
|
95
|
+
if (!rawPublicKey || !(rawPublicKey instanceof Uint8Array || typeof rawPublicKey === 'string')) {
|
|
96
|
+
throw new Error('Raw public key is not a Uint8Array or string' + typeof rawPublicKey);
|
|
83
97
|
}
|
|
84
98
|
if (!externalServerKeyShares) {
|
|
85
99
|
throw new Error('Error creating wallet account');
|
|
86
100
|
}
|
|
87
101
|
const { accountAddress } = await this.deriveAccountAddress(rawPublicKey);
|
|
88
|
-
|
|
102
|
+
await this.storeEncryptedBackupByWalletWithRetry({
|
|
89
103
|
accountAddress,
|
|
90
104
|
externalServerKeyShares,
|
|
91
|
-
password
|
|
105
|
+
password,
|
|
106
|
+
backUpToClientShareService
|
|
92
107
|
});
|
|
93
108
|
return {
|
|
94
109
|
accountAddress,
|
|
95
|
-
rawPublicKey
|
|
110
|
+
rawPublicKey,
|
|
96
111
|
externalServerKeyShares
|
|
97
112
|
};
|
|
98
113
|
} catch (error) {
|
|
@@ -102,9 +117,10 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
102
117
|
}
|
|
103
118
|
// Function to properly derive account address
|
|
104
119
|
async deriveAccountAddress(rawPublicKey) {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const
|
|
120
|
+
const pubKeyBytes = typeof rawPublicKey === 'string' ? Buffer.from(rawPublicKey, 'hex') : rawPublicKey;
|
|
121
|
+
// Create PublicKey from bytes and convert to base58
|
|
122
|
+
const pubKey = new web3_js.PublicKey(pubKeyBytes);
|
|
123
|
+
const accountAddress = pubKey.toBase58();
|
|
108
124
|
return {
|
|
109
125
|
accountAddress
|
|
110
126
|
};
|
|
@@ -115,7 +131,7 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
115
131
|
* @param message The message to sign (Uint8Array)
|
|
116
132
|
* @param accountAddress Solana address (base58 encoded)
|
|
117
133
|
* @param password The password for encrypted backup shares
|
|
118
|
-
*/ async signMessage({ message, accountAddress, password = undefined }) {
|
|
134
|
+
*/ async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares }) {
|
|
119
135
|
await this.verifyPassword({
|
|
120
136
|
accountAddress,
|
|
121
137
|
password,
|
|
@@ -129,8 +145,10 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
129
145
|
message,
|
|
130
146
|
accountAddress: accountAddress,
|
|
131
147
|
chainName: this.chainName,
|
|
132
|
-
password
|
|
148
|
+
password,
|
|
149
|
+
externalServerKeyShares
|
|
133
150
|
});
|
|
151
|
+
// Use PublicKey to encode signature
|
|
134
152
|
const base58Signature = new web3_js.PublicKey(signatureEd25519).toBase58();
|
|
135
153
|
return base58Signature;
|
|
136
154
|
} catch (error) {
|
|
@@ -138,7 +156,8 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
138
156
|
throw error;
|
|
139
157
|
}
|
|
140
158
|
}
|
|
141
|
-
|
|
159
|
+
//todo:should txn just be a string?
|
|
160
|
+
async signTransaction({ senderAddress, transaction, password = undefined, externalServerKeyShares }) {
|
|
142
161
|
await this.verifyPassword({
|
|
143
162
|
accountAddress: senderAddress,
|
|
144
163
|
password,
|
|
@@ -159,7 +178,8 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
159
178
|
message: messageToSign,
|
|
160
179
|
accountAddress: senderAddress,
|
|
161
180
|
chainName: this.chainName,
|
|
162
|
-
password
|
|
181
|
+
password,
|
|
182
|
+
externalServerKeyShares
|
|
163
183
|
});
|
|
164
184
|
if (!signatureEd25519) {
|
|
165
185
|
throw new Error('Signature is undefined');
|
|
@@ -185,19 +205,17 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
185
205
|
* @param accountAddress The account address to export the private key for
|
|
186
206
|
* @param password The password for encrypted backup shares
|
|
187
207
|
* @returns The private key
|
|
188
|
-
*/ async exportPrivateKey({ accountAddress, password = undefined }) {
|
|
208
|
+
*/ async exportPrivateKey({ accountAddress, password = undefined, externalServerKeyShares }) {
|
|
189
209
|
const { derivedPrivateKey } = await this.exportKey({
|
|
190
210
|
accountAddress,
|
|
191
211
|
chainName: this.chainName,
|
|
192
|
-
password
|
|
212
|
+
password,
|
|
213
|
+
externalServerKeyShares
|
|
193
214
|
});
|
|
194
215
|
if (!derivedPrivateKey) {
|
|
195
216
|
throw new Error('Derived private key is undefined');
|
|
196
217
|
}
|
|
197
|
-
|
|
198
|
-
return {
|
|
199
|
-
derivedPrivateKey: encodedPrivateKey
|
|
200
|
-
};
|
|
218
|
+
return derivedPrivateKey;
|
|
201
219
|
}
|
|
202
220
|
/**
|
|
203
221
|
* Exports the private key for a given account address
|
|
@@ -220,20 +238,18 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
220
238
|
* @param privateKey The private key to convert
|
|
221
239
|
* @returns The hex string
|
|
222
240
|
*/ decodePrivateKeyForSolana(privateKey) {
|
|
223
|
-
const decoded = new web3_js.PublicKey(privateKey).
|
|
241
|
+
const decoded = new web3_js.PublicKey(privateKey).toBuffer();
|
|
224
242
|
const slicedBytes = decoded.slice(0, 32);
|
|
225
243
|
return Buffer.from(slicedBytes).toString('hex');
|
|
226
244
|
}
|
|
227
245
|
getPublicKeyFromPrivateKey(privateKey) {
|
|
228
|
-
const privateKeyBytes = new web3_js.PublicKey(privateKey).
|
|
229
|
-
const keypair = web3_js.Keypair.fromSecretKey(
|
|
246
|
+
const privateKeyBytes = new web3_js.PublicKey(privateKey).toBuffer();
|
|
247
|
+
const keypair = web3_js.Keypair.fromSecretKey(privateKeyBytes);
|
|
230
248
|
const publicKeyBase58 = keypair.publicKey.toBase58();
|
|
231
249
|
return publicKeyBase58;
|
|
232
250
|
}
|
|
233
251
|
encodePublicKey(publicKey) {
|
|
234
|
-
|
|
235
|
-
const fromKey = pubKey.toBase58();
|
|
236
|
-
return fromKey;
|
|
252
|
+
return new web3_js.PublicKey(publicKey).toBase58();
|
|
237
253
|
}
|
|
238
254
|
/**
|
|
239
255
|
* Imports the private key for a given account address
|
|
@@ -243,7 +259,11 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
243
259
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
244
260
|
* @param password The password for encrypted backup shares
|
|
245
261
|
* @returns The account address, raw public key, and client key shares
|
|
246
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
262
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError, backUpToClientShareService = false }) {
|
|
263
|
+
let ceremonyCeremonyCompleteResolver;
|
|
264
|
+
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
265
|
+
ceremonyCeremonyCompleteResolver = resolve;
|
|
266
|
+
});
|
|
247
267
|
//get public key from private key
|
|
248
268
|
const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
|
|
249
269
|
const formattedPrivateKey = await this.decodePrivateKeyForSolana(privateKey);
|
|
@@ -261,8 +281,11 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
261
281
|
thresholdSignatureScheme,
|
|
262
282
|
externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
|
|
263
283
|
});
|
|
284
|
+
ceremonyCeremonyCompleteResolver(undefined);
|
|
264
285
|
}
|
|
265
286
|
});
|
|
287
|
+
// Wait for the ceremony to complete before proceeding
|
|
288
|
+
await ceremonyCompletePromise;
|
|
266
289
|
if (!rawPublicKey || !externalServerKeyShares) {
|
|
267
290
|
throw new Error('Error creating wallet account');
|
|
268
291
|
}
|
|
@@ -270,11 +293,11 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
270
293
|
if (accountAddress !== publicKey) {
|
|
271
294
|
throw new Error(`Public key mismatch: derived address ${accountAddress} !== public key ${publicKey}`);
|
|
272
295
|
}
|
|
273
|
-
|
|
274
|
-
void this.storeEncryptedBackupByWalletWithRetry({
|
|
296
|
+
await this.storeEncryptedBackupByWalletWithRetry({
|
|
275
297
|
accountAddress,
|
|
276
298
|
externalServerKeyShares,
|
|
277
|
-
password
|
|
299
|
+
password,
|
|
300
|
+
backUpToClientShareService
|
|
278
301
|
});
|
|
279
302
|
return {
|
|
280
303
|
accountAddress,
|
|
@@ -292,7 +315,7 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
292
315
|
environmentId,
|
|
293
316
|
baseApiUrl,
|
|
294
317
|
baseMPCRelayApiUrl
|
|
295
|
-
}), this.chainName = '
|
|
318
|
+
}), this.chainName = 'SVM';
|
|
296
319
|
}
|
|
297
320
|
}
|
|
298
321
|
|
package/index.esm.js
CHANGED
|
@@ -59,8 +59,12 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
59
59
|
*
|
|
60
60
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
61
61
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
62
|
-
*/ async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
62
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError, backUpToClientShareService = false }) {
|
|
63
63
|
try {
|
|
64
|
+
let ceremonyCeremonyCompleteResolver;
|
|
65
|
+
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
66
|
+
ceremonyCeremonyCompleteResolver = resolve;
|
|
67
|
+
});
|
|
64
68
|
const { rawPublicKey, externalServerKeyShares } = await this.keyGen({
|
|
65
69
|
chainName: this.chainName,
|
|
66
70
|
thresholdSignatureScheme,
|
|
@@ -74,23 +78,34 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
74
78
|
thresholdSignatureScheme,
|
|
75
79
|
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
76
80
|
});
|
|
81
|
+
this.logger.debug('walletMap updated for wallet', {
|
|
82
|
+
context: {
|
|
83
|
+
accountAddress,
|
|
84
|
+
walletId,
|
|
85
|
+
walletMap: this.walletMap
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
ceremonyCeremonyCompleteResolver(undefined);
|
|
77
89
|
}
|
|
78
90
|
});
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
// Wait for the ceremony to complete before proceeding
|
|
92
|
+
await ceremonyCompletePromise;
|
|
93
|
+
if (!rawPublicKey || !(rawPublicKey instanceof Uint8Array || typeof rawPublicKey === 'string')) {
|
|
94
|
+
throw new Error('Raw public key is not a Uint8Array or string' + typeof rawPublicKey);
|
|
81
95
|
}
|
|
82
96
|
if (!externalServerKeyShares) {
|
|
83
97
|
throw new Error('Error creating wallet account');
|
|
84
98
|
}
|
|
85
99
|
const { accountAddress } = await this.deriveAccountAddress(rawPublicKey);
|
|
86
|
-
|
|
100
|
+
await this.storeEncryptedBackupByWalletWithRetry({
|
|
87
101
|
accountAddress,
|
|
88
102
|
externalServerKeyShares,
|
|
89
|
-
password
|
|
103
|
+
password,
|
|
104
|
+
backUpToClientShareService
|
|
90
105
|
});
|
|
91
106
|
return {
|
|
92
107
|
accountAddress,
|
|
93
|
-
rawPublicKey
|
|
108
|
+
rawPublicKey,
|
|
94
109
|
externalServerKeyShares
|
|
95
110
|
};
|
|
96
111
|
} catch (error) {
|
|
@@ -100,9 +115,10 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
100
115
|
}
|
|
101
116
|
// Function to properly derive account address
|
|
102
117
|
async deriveAccountAddress(rawPublicKey) {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
const
|
|
118
|
+
const pubKeyBytes = typeof rawPublicKey === 'string' ? Buffer.from(rawPublicKey, 'hex') : rawPublicKey;
|
|
119
|
+
// Create PublicKey from bytes and convert to base58
|
|
120
|
+
const pubKey = new PublicKey(pubKeyBytes);
|
|
121
|
+
const accountAddress = pubKey.toBase58();
|
|
106
122
|
return {
|
|
107
123
|
accountAddress
|
|
108
124
|
};
|
|
@@ -113,7 +129,7 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
113
129
|
* @param message The message to sign (Uint8Array)
|
|
114
130
|
* @param accountAddress Solana address (base58 encoded)
|
|
115
131
|
* @param password The password for encrypted backup shares
|
|
116
|
-
*/ async signMessage({ message, accountAddress, password = undefined }) {
|
|
132
|
+
*/ async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares }) {
|
|
117
133
|
await this.verifyPassword({
|
|
118
134
|
accountAddress,
|
|
119
135
|
password,
|
|
@@ -127,8 +143,10 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
127
143
|
message,
|
|
128
144
|
accountAddress: accountAddress,
|
|
129
145
|
chainName: this.chainName,
|
|
130
|
-
password
|
|
146
|
+
password,
|
|
147
|
+
externalServerKeyShares
|
|
131
148
|
});
|
|
149
|
+
// Use PublicKey to encode signature
|
|
132
150
|
const base58Signature = new PublicKey(signatureEd25519).toBase58();
|
|
133
151
|
return base58Signature;
|
|
134
152
|
} catch (error) {
|
|
@@ -136,7 +154,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
136
154
|
throw error;
|
|
137
155
|
}
|
|
138
156
|
}
|
|
139
|
-
|
|
157
|
+
//todo:should txn just be a string?
|
|
158
|
+
async signTransaction({ senderAddress, transaction, password = undefined, externalServerKeyShares }) {
|
|
140
159
|
await this.verifyPassword({
|
|
141
160
|
accountAddress: senderAddress,
|
|
142
161
|
password,
|
|
@@ -157,7 +176,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
157
176
|
message: messageToSign,
|
|
158
177
|
accountAddress: senderAddress,
|
|
159
178
|
chainName: this.chainName,
|
|
160
|
-
password
|
|
179
|
+
password,
|
|
180
|
+
externalServerKeyShares
|
|
161
181
|
});
|
|
162
182
|
if (!signatureEd25519) {
|
|
163
183
|
throw new Error('Signature is undefined');
|
|
@@ -183,19 +203,17 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
183
203
|
* @param accountAddress The account address to export the private key for
|
|
184
204
|
* @param password The password for encrypted backup shares
|
|
185
205
|
* @returns The private key
|
|
186
|
-
*/ async exportPrivateKey({ accountAddress, password = undefined }) {
|
|
206
|
+
*/ async exportPrivateKey({ accountAddress, password = undefined, externalServerKeyShares }) {
|
|
187
207
|
const { derivedPrivateKey } = await this.exportKey({
|
|
188
208
|
accountAddress,
|
|
189
209
|
chainName: this.chainName,
|
|
190
|
-
password
|
|
210
|
+
password,
|
|
211
|
+
externalServerKeyShares
|
|
191
212
|
});
|
|
192
213
|
if (!derivedPrivateKey) {
|
|
193
214
|
throw new Error('Derived private key is undefined');
|
|
194
215
|
}
|
|
195
|
-
|
|
196
|
-
return {
|
|
197
|
-
derivedPrivateKey: encodedPrivateKey
|
|
198
|
-
};
|
|
216
|
+
return derivedPrivateKey;
|
|
199
217
|
}
|
|
200
218
|
/**
|
|
201
219
|
* Exports the private key for a given account address
|
|
@@ -218,20 +236,18 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
218
236
|
* @param privateKey The private key to convert
|
|
219
237
|
* @returns The hex string
|
|
220
238
|
*/ decodePrivateKeyForSolana(privateKey) {
|
|
221
|
-
const decoded = new PublicKey(privateKey).
|
|
239
|
+
const decoded = new PublicKey(privateKey).toBuffer();
|
|
222
240
|
const slicedBytes = decoded.slice(0, 32);
|
|
223
241
|
return Buffer.from(slicedBytes).toString('hex');
|
|
224
242
|
}
|
|
225
243
|
getPublicKeyFromPrivateKey(privateKey) {
|
|
226
|
-
const privateKeyBytes = new PublicKey(privateKey).
|
|
227
|
-
const keypair = Keypair.fromSecretKey(
|
|
244
|
+
const privateKeyBytes = new PublicKey(privateKey).toBuffer();
|
|
245
|
+
const keypair = Keypair.fromSecretKey(privateKeyBytes);
|
|
228
246
|
const publicKeyBase58 = keypair.publicKey.toBase58();
|
|
229
247
|
return publicKeyBase58;
|
|
230
248
|
}
|
|
231
249
|
encodePublicKey(publicKey) {
|
|
232
|
-
|
|
233
|
-
const fromKey = pubKey.toBase58();
|
|
234
|
-
return fromKey;
|
|
250
|
+
return new PublicKey(publicKey).toBase58();
|
|
235
251
|
}
|
|
236
252
|
/**
|
|
237
253
|
* Imports the private key for a given account address
|
|
@@ -241,7 +257,11 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
241
257
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
242
258
|
* @param password The password for encrypted backup shares
|
|
243
259
|
* @returns The account address, raw public key, and client key shares
|
|
244
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
260
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError, backUpToClientShareService = false }) {
|
|
261
|
+
let ceremonyCeremonyCompleteResolver;
|
|
262
|
+
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
263
|
+
ceremonyCeremonyCompleteResolver = resolve;
|
|
264
|
+
});
|
|
245
265
|
//get public key from private key
|
|
246
266
|
const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
|
|
247
267
|
const formattedPrivateKey = await this.decodePrivateKeyForSolana(privateKey);
|
|
@@ -259,8 +279,11 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
259
279
|
thresholdSignatureScheme,
|
|
260
280
|
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
261
281
|
});
|
|
282
|
+
ceremonyCeremonyCompleteResolver(undefined);
|
|
262
283
|
}
|
|
263
284
|
});
|
|
285
|
+
// Wait for the ceremony to complete before proceeding
|
|
286
|
+
await ceremonyCompletePromise;
|
|
264
287
|
if (!rawPublicKey || !externalServerKeyShares) {
|
|
265
288
|
throw new Error('Error creating wallet account');
|
|
266
289
|
}
|
|
@@ -268,11 +291,11 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
268
291
|
if (accountAddress !== publicKey) {
|
|
269
292
|
throw new Error(`Public key mismatch: derived address ${accountAddress} !== public key ${publicKey}`);
|
|
270
293
|
}
|
|
271
|
-
|
|
272
|
-
void this.storeEncryptedBackupByWalletWithRetry({
|
|
294
|
+
await this.storeEncryptedBackupByWalletWithRetry({
|
|
273
295
|
accountAddress,
|
|
274
296
|
externalServerKeyShares,
|
|
275
|
-
password
|
|
297
|
+
password,
|
|
298
|
+
backUpToClientShareService
|
|
276
299
|
});
|
|
277
300
|
return {
|
|
278
301
|
accountAddress,
|
|
@@ -290,7 +313,7 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
290
313
|
environmentId,
|
|
291
314
|
baseApiUrl,
|
|
292
315
|
baseMPCRelayApiUrl
|
|
293
|
-
}), this.chainName = '
|
|
316
|
+
}), this.chainName = 'SVM';
|
|
294
317
|
}
|
|
295
318
|
}
|
|
296
319
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-svm",
|
|
3
|
-
"version": "0.0.0-beta.
|
|
3
|
+
"version": "0.0.0-beta.308.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/node": "0.0.0-beta.
|
|
6
|
+
"@dynamic-labs-wallet/node": "0.0.0-beta.308.1",
|
|
7
7
|
"@solana/web3.js": "^1.98.2"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"main": "./index.cjs.js",
|
|
21
21
|
"module": "./index.esm.js",
|
|
22
22
|
"types": "./index.esm.d.ts",
|
|
23
|
+
"type": "module",
|
|
23
24
|
"exports": {
|
|
24
25
|
"./package.json": "./package.json",
|
|
25
26
|
".": {
|
|
26
27
|
"types": "./index.esm.d.ts",
|
|
27
28
|
"import": "./index.esm.js",
|
|
28
|
-
"require": "./index.cjs.js"
|
|
29
|
-
"default": "./index.cjs.js"
|
|
29
|
+
"require": "./index.cjs.js"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServerKeyShare, DynamicWalletClient, Ed25519KeygenResult, ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
4
|
-
readonly chainName = "
|
|
4
|
+
readonly chainName = "SVM";
|
|
5
5
|
accountAddress?: string;
|
|
6
6
|
constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, }: {
|
|
7
7
|
environmentId: string;
|
|
@@ -15,16 +15,17 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
15
15
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
16
16
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
17
17
|
*/
|
|
18
|
-
createWalletAccount({ thresholdSignatureScheme, password, onError, }: {
|
|
18
|
+
createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToClientShareService, }: {
|
|
19
19
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
20
20
|
password?: string;
|
|
21
21
|
onError?: (error: Error) => void;
|
|
22
|
+
backUpToClientShareService?: boolean;
|
|
22
23
|
}): Promise<{
|
|
23
24
|
accountAddress: string;
|
|
24
|
-
rawPublicKey: Uint8Array;
|
|
25
|
+
rawPublicKey: Uint8Array | string;
|
|
25
26
|
externalServerKeyShares: ServerKeyShare[];
|
|
26
27
|
}>;
|
|
27
|
-
deriveAccountAddress(rawPublicKey: Uint8Array): Promise<{
|
|
28
|
+
deriveAccountAddress(rawPublicKey: string | Uint8Array): Promise<{
|
|
28
29
|
accountAddress: string;
|
|
29
30
|
}>;
|
|
30
31
|
/**
|
|
@@ -34,15 +35,17 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
34
35
|
* @param accountAddress Solana address (base58 encoded)
|
|
35
36
|
* @param password The password for encrypted backup shares
|
|
36
37
|
*/
|
|
37
|
-
signMessage({ message, accountAddress, password, }: {
|
|
38
|
+
signMessage({ message, accountAddress, password, externalServerKeyShares, }: {
|
|
38
39
|
message: string;
|
|
39
40
|
accountAddress: string;
|
|
40
41
|
password?: string;
|
|
42
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
41
43
|
}): Promise<string>;
|
|
42
|
-
signTransaction({ senderAddress, transaction, password, }: {
|
|
44
|
+
signTransaction({ senderAddress, transaction, password, externalServerKeyShares, }: {
|
|
43
45
|
senderAddress: string;
|
|
44
46
|
transaction: VersionedTransaction | Transaction;
|
|
45
47
|
password?: string;
|
|
48
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
46
49
|
}): Promise<VersionedTransaction | Transaction>;
|
|
47
50
|
/**
|
|
48
51
|
* Exports the private key for a given account address
|
|
@@ -51,12 +54,11 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
51
54
|
* @param password The password for encrypted backup shares
|
|
52
55
|
* @returns The private key
|
|
53
56
|
*/
|
|
54
|
-
exportPrivateKey({ accountAddress, password, }: {
|
|
57
|
+
exportPrivateKey({ accountAddress, password, externalServerKeyShares, }: {
|
|
55
58
|
accountAddress: string;
|
|
56
59
|
password?: string;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}>;
|
|
60
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
61
|
+
}): Promise<string>;
|
|
60
62
|
/**
|
|
61
63
|
* Exports the private key for a given account address
|
|
62
64
|
*
|
|
@@ -87,15 +89,16 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
87
89
|
* @param password The password for encrypted backup shares
|
|
88
90
|
* @returns The account address, raw public key, and client key shares
|
|
89
91
|
*/
|
|
90
|
-
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, }: {
|
|
92
|
+
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, backUpToClientShareService, }: {
|
|
91
93
|
privateKey: string;
|
|
92
94
|
chainName: string;
|
|
93
95
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
94
96
|
password?: string;
|
|
95
97
|
onError?: (error: Error) => void;
|
|
98
|
+
backUpToClientShareService?: boolean;
|
|
96
99
|
}): Promise<{
|
|
97
100
|
accountAddress: string;
|
|
98
|
-
rawPublicKey: Uint8Array | undefined;
|
|
101
|
+
rawPublicKey: Uint8Array | string | undefined;
|
|
99
102
|
externalServerKeyShares: ServerKeyShare[];
|
|
100
103
|
}>;
|
|
101
104
|
getSvmWallets(): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EAGzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,WAAW,EACX,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AAIzB,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;gBAEZ,EACV,aAAa,EACb,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;IAQD;;;;;OAKG;IACG,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EAGzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,WAAW,EACX,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AAIzB,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;gBAEZ,EACV,aAAa,EACb,UAAU,EACV,kBA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