@dynamic-labs-wallet/evm 0.0.46 → 0.0.48
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 +37 -60
- package/index.esm.js +39 -62
- package/package.json +2 -2
- package/src/client/client.d.ts.map +1 -1
- package/src/client/constants.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -42,55 +42,40 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
45
|
-
let ceremonyCompleted = false;
|
|
46
45
|
try {
|
|
47
46
|
// Generate key shares for given threshold signature scheme (TSS)
|
|
48
47
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
49
48
|
chainName: this.chainName,
|
|
50
49
|
thresholdSignatureScheme,
|
|
51
50
|
onError,
|
|
52
|
-
onCeremonyComplete: ()=>{
|
|
53
|
-
|
|
51
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
52
|
+
// update wallet map
|
|
53
|
+
const checksumAddress = viem.getAddress(accountAddress);
|
|
54
|
+
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
55
|
+
accountAddress: checksumAddress,
|
|
56
|
+
walletId,
|
|
57
|
+
chainName: this.chainName,
|
|
58
|
+
thresholdSignatureScheme,
|
|
59
|
+
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
60
|
+
});
|
|
54
61
|
}
|
|
55
62
|
});
|
|
56
|
-
// Wait for the ceremony to complete, timeout after 5 seconds
|
|
57
|
-
await Promise.race([
|
|
58
|
-
(async ()=>{
|
|
59
|
-
while(!ceremonyCompleted){
|
|
60
|
-
await new Promise((resolve)=>setTimeout(resolve, 100));
|
|
61
|
-
}
|
|
62
|
-
})(),
|
|
63
|
-
browser.timeoutPromise({
|
|
64
|
-
timeInMs: 5000,
|
|
65
|
-
activity: 'Ceremony'
|
|
66
|
-
})
|
|
67
|
-
]);
|
|
68
63
|
if (!rawPublicKey || !clientKeyShares) {
|
|
69
64
|
throw new Error(ERROR_KEYGEN_FAILED);
|
|
70
65
|
}
|
|
71
|
-
// Get EVM address from public key
|
|
72
66
|
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
73
67
|
rawPublicKey: rawPublicKey
|
|
74
68
|
});
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.walletMap[accountAddress] = {
|
|
84
|
-
accountAddress,
|
|
85
|
-
walletId: newWallet.id,
|
|
86
|
-
chainName: this.chainName,
|
|
87
|
-
clientKeyShares: clientKeyShares,
|
|
88
|
-
thresholdSignatureScheme,
|
|
89
|
-
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
90
|
-
};
|
|
91
|
-
// Backup the new wallet
|
|
92
|
-
await this.storeEncryptedBackupByWallet({
|
|
69
|
+
// Update client key shares in wallet map
|
|
70
|
+
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
71
|
+
// TODO: remove this once iframe handling for secret shares is implemented
|
|
72
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
73
|
+
clientKeyShares
|
|
74
|
+
});
|
|
75
|
+
// Backup the new wallet without waiting for the promise to resolve
|
|
76
|
+
void this.storeEncryptedBackupByWalletWithRetry({
|
|
93
77
|
accountAddress,
|
|
78
|
+
clientKeyShares,
|
|
94
79
|
password
|
|
95
80
|
});
|
|
96
81
|
return {
|
|
@@ -227,48 +212,40 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
227
212
|
};
|
|
228
213
|
}
|
|
229
214
|
async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
230
|
-
let ceremonyCompleted = false;
|
|
231
215
|
// TODO: validate private key for EVM
|
|
232
216
|
const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
|
|
233
217
|
chainName,
|
|
234
218
|
privateKey,
|
|
235
219
|
thresholdSignatureScheme,
|
|
236
220
|
onError,
|
|
237
|
-
onCeremonyComplete: ()=>{
|
|
238
|
-
|
|
221
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
222
|
+
// update wallet map
|
|
223
|
+
const checksumAddress = viem.getAddress(accountAddress);
|
|
224
|
+
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
225
|
+
accountAddress: checksumAddress,
|
|
226
|
+
walletId,
|
|
227
|
+
chainName: this.chainName,
|
|
228
|
+
thresholdSignatureScheme,
|
|
229
|
+
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
230
|
+
});
|
|
239
231
|
}
|
|
240
232
|
});
|
|
241
|
-
// Wait for the ceremony to complete, timeout after 5 seconds
|
|
242
|
-
await Promise.race([
|
|
243
|
-
(async ()=>{
|
|
244
|
-
while(!ceremonyCompleted){
|
|
245
|
-
await new Promise((resolve)=>setTimeout(resolve, 100));
|
|
246
|
-
}
|
|
247
|
-
})(),
|
|
248
|
-
browser.timeoutPromise({
|
|
249
|
-
timeInMs: 5000,
|
|
250
|
-
activity: 'Ceremony'
|
|
251
|
-
})
|
|
252
|
-
]);
|
|
253
233
|
if (!rawPublicKey || !clientKeyShares) {
|
|
254
234
|
throw new Error('Error creating wallet account');
|
|
255
235
|
}
|
|
256
236
|
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
257
237
|
rawPublicKey: rawPublicKey
|
|
258
238
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this.walletMap[accountAddress] = {
|
|
239
|
+
// Update client key shares in wallet map
|
|
240
|
+
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
241
|
+
// TODO: remove this once iframe handling for secret shares is implemented
|
|
242
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
243
|
+
clientKeyShares
|
|
244
|
+
});
|
|
245
|
+
// Backup the new wallet without waiting for the promise to resolve
|
|
246
|
+
void this.storeEncryptedBackupByWalletWithRetry({
|
|
263
247
|
accountAddress,
|
|
264
|
-
walletId: newWalletId,
|
|
265
|
-
chainName: this.chainName,
|
|
266
248
|
clientKeyShares,
|
|
267
|
-
thresholdSignatureScheme,
|
|
268
|
-
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
269
|
-
};
|
|
270
|
-
await this.storeEncryptedBackupByWallet({
|
|
271
|
-
accountAddress,
|
|
272
249
|
password
|
|
273
250
|
});
|
|
274
251
|
return {
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamicWalletClient,
|
|
2
|
-
import { serializeSignature, createPublicClient, http,
|
|
1
|
+
import { DynamicWalletClient, getClientKeyShareBackupInfo, WalletOperation, MessageHash } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import { serializeSignature, createPublicClient, http, getAddress, serializeTransaction } from 'viem';
|
|
3
3
|
import { mainnet } from 'viem/chains';
|
|
4
4
|
|
|
5
5
|
function _extends() {
|
|
@@ -40,55 +40,40 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
43
|
-
let ceremonyCompleted = false;
|
|
44
43
|
try {
|
|
45
44
|
// Generate key shares for given threshold signature scheme (TSS)
|
|
46
45
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
47
46
|
chainName: this.chainName,
|
|
48
47
|
thresholdSignatureScheme,
|
|
49
48
|
onError,
|
|
50
|
-
onCeremonyComplete: ()=>{
|
|
51
|
-
|
|
49
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
50
|
+
// update wallet map
|
|
51
|
+
const checksumAddress = getAddress(accountAddress);
|
|
52
|
+
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
53
|
+
accountAddress: checksumAddress,
|
|
54
|
+
walletId,
|
|
55
|
+
chainName: this.chainName,
|
|
56
|
+
thresholdSignatureScheme,
|
|
57
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
58
|
+
});
|
|
52
59
|
}
|
|
53
60
|
});
|
|
54
|
-
// Wait for the ceremony to complete, timeout after 5 seconds
|
|
55
|
-
await Promise.race([
|
|
56
|
-
(async ()=>{
|
|
57
|
-
while(!ceremonyCompleted){
|
|
58
|
-
await new Promise((resolve)=>setTimeout(resolve, 100));
|
|
59
|
-
}
|
|
60
|
-
})(),
|
|
61
|
-
timeoutPromise({
|
|
62
|
-
timeInMs: 5000,
|
|
63
|
-
activity: 'Ceremony'
|
|
64
|
-
})
|
|
65
|
-
]);
|
|
66
61
|
if (!rawPublicKey || !clientKeyShares) {
|
|
67
62
|
throw new Error(ERROR_KEYGEN_FAILED);
|
|
68
63
|
}
|
|
69
|
-
// Get EVM address from public key
|
|
70
64
|
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
71
65
|
rawPublicKey: rawPublicKey
|
|
72
66
|
});
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.walletMap[accountAddress] = {
|
|
82
|
-
accountAddress,
|
|
83
|
-
walletId: newWallet.id,
|
|
84
|
-
chainName: this.chainName,
|
|
85
|
-
clientKeyShares: clientKeyShares,
|
|
86
|
-
thresholdSignatureScheme,
|
|
87
|
-
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
88
|
-
};
|
|
89
|
-
// Backup the new wallet
|
|
90
|
-
await this.storeEncryptedBackupByWallet({
|
|
67
|
+
// Update client key shares in wallet map
|
|
68
|
+
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
69
|
+
// TODO: remove this once iframe handling for secret shares is implemented
|
|
70
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
71
|
+
clientKeyShares
|
|
72
|
+
});
|
|
73
|
+
// Backup the new wallet without waiting for the promise to resolve
|
|
74
|
+
void this.storeEncryptedBackupByWalletWithRetry({
|
|
91
75
|
accountAddress,
|
|
76
|
+
clientKeyShares,
|
|
92
77
|
password
|
|
93
78
|
});
|
|
94
79
|
return {
|
|
@@ -225,48 +210,40 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
225
210
|
};
|
|
226
211
|
}
|
|
227
212
|
async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
228
|
-
let ceremonyCompleted = false;
|
|
229
213
|
// TODO: validate private key for EVM
|
|
230
214
|
const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
|
|
231
215
|
chainName,
|
|
232
216
|
privateKey,
|
|
233
217
|
thresholdSignatureScheme,
|
|
234
218
|
onError,
|
|
235
|
-
onCeremonyComplete: ()=>{
|
|
236
|
-
|
|
219
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
220
|
+
// update wallet map
|
|
221
|
+
const checksumAddress = getAddress(accountAddress);
|
|
222
|
+
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
223
|
+
accountAddress: checksumAddress,
|
|
224
|
+
walletId,
|
|
225
|
+
chainName: this.chainName,
|
|
226
|
+
thresholdSignatureScheme,
|
|
227
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
228
|
+
});
|
|
237
229
|
}
|
|
238
230
|
});
|
|
239
|
-
// Wait for the ceremony to complete, timeout after 5 seconds
|
|
240
|
-
await Promise.race([
|
|
241
|
-
(async ()=>{
|
|
242
|
-
while(!ceremonyCompleted){
|
|
243
|
-
await new Promise((resolve)=>setTimeout(resolve, 100));
|
|
244
|
-
}
|
|
245
|
-
})(),
|
|
246
|
-
timeoutPromise({
|
|
247
|
-
timeInMs: 5000,
|
|
248
|
-
activity: 'Ceremony'
|
|
249
|
-
})
|
|
250
|
-
]);
|
|
251
231
|
if (!rawPublicKey || !clientKeyShares) {
|
|
252
232
|
throw new Error('Error creating wallet account');
|
|
253
233
|
}
|
|
254
234
|
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
255
235
|
rawPublicKey: rawPublicKey
|
|
256
236
|
});
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
this.walletMap[accountAddress] = {
|
|
237
|
+
// Update client key shares in wallet map
|
|
238
|
+
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
239
|
+
// TODO: remove this once iframe handling for secret shares is implemented
|
|
240
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
241
|
+
clientKeyShares
|
|
242
|
+
});
|
|
243
|
+
// Backup the new wallet without waiting for the promise to resolve
|
|
244
|
+
void this.storeEncryptedBackupByWalletWithRetry({
|
|
261
245
|
accountAddress,
|
|
262
|
-
walletId: newWalletId,
|
|
263
|
-
chainName: this.chainName,
|
|
264
246
|
clientKeyShares,
|
|
265
|
-
thresholdSignatureScheme,
|
|
266
|
-
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
267
|
-
};
|
|
268
|
-
await this.storeEncryptedBackupByWallet({
|
|
269
|
-
accountAddress,
|
|
270
247
|
password
|
|
271
248
|
});
|
|
272
249
|
return {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/evm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/browser": "0.0.
|
|
6
|
+
"@dynamic-labs-wallet/browser": "0.0.48"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
9
|
"viem": "^2.22.1"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EAEd,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EAEd,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EAIzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,KAAK,EAEV,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE7B,MAAM,MAAM,CAAC;AAWd,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,KAAK,GACN,EAAE,wBAAwB;IAW3B,sBAAsB,CAAC,EACrB,KAAK,EACL,MAAM,GACP,EAAE;QACD,KAAK,EAAE,KAAK,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,YAAY;IAOV,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,OAAO,GACR,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KAClC,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;QACtD,eAAe,EAAE,cAAc,EAAE,CAAC;KACnC,CA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cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;QACtD,eAAe,EAAE,cAAc,EAAE,CAAC;KACnC,CAAC;IAmDI,aAAa;CAOpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,qCAAmC,CAAC;AAGxE,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,sCAAsC,CAAC;AAE/E,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAE5E,eAAO,MAAM,8BAA8B,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,qCAAmC,CAAC;AAGxE,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,sCAAsC,CAAC;AAE/E,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAE5E,eAAO,MAAM,8BAA8B,sCACN,CAAC"}
|