@dynamic-labs-wallet/evm 0.0.44 → 0.0.46
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 +39 -4
- package/index.esm.js +40 -5
- package/package.json +2 -2
- package/src/client/client.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -42,12 +42,29 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
45
|
+
let ceremonyCompleted = false;
|
|
45
46
|
try {
|
|
46
47
|
// Generate key shares for given threshold signature scheme (TSS)
|
|
47
48
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
48
49
|
chainName: this.chainName,
|
|
49
|
-
thresholdSignatureScheme
|
|
50
|
+
thresholdSignatureScheme,
|
|
51
|
+
onError,
|
|
52
|
+
onCeremonyComplete: ()=>{
|
|
53
|
+
ceremonyCompleted = true;
|
|
54
|
+
}
|
|
50
55
|
});
|
|
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
|
+
]);
|
|
51
68
|
if (!rawPublicKey || !clientKeyShares) {
|
|
52
69
|
throw new Error(ERROR_KEYGEN_FAILED);
|
|
53
70
|
}
|
|
@@ -59,11 +76,13 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
59
76
|
const refreshedUser = await this.apiClient.refreshUser();
|
|
60
77
|
// Find the new wallet in the user's verified credentials
|
|
61
78
|
const newWallet = refreshedUser.user.verifiedCredentials.find((wallet)=>wallet.address.toLowerCase() === accountAddress.toLowerCase());
|
|
62
|
-
|
|
79
|
+
if (!newWallet) {
|
|
80
|
+
throw new Error('Wallet not found after ceremony completion');
|
|
81
|
+
}
|
|
63
82
|
// Store the new wallet in the wallet map
|
|
64
83
|
this.walletMap[accountAddress] = {
|
|
65
84
|
accountAddress,
|
|
66
|
-
walletId:
|
|
85
|
+
walletId: newWallet.id,
|
|
67
86
|
chainName: this.chainName,
|
|
68
87
|
clientKeyShares: clientKeyShares,
|
|
69
88
|
thresholdSignatureScheme,
|
|
@@ -208,13 +227,29 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
208
227
|
};
|
|
209
228
|
}
|
|
210
229
|
async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
230
|
+
let ceremonyCompleted = false;
|
|
211
231
|
// TODO: validate private key for EVM
|
|
212
232
|
const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
|
|
213
233
|
chainName,
|
|
214
234
|
privateKey,
|
|
215
235
|
thresholdSignatureScheme,
|
|
216
|
-
onError
|
|
236
|
+
onError,
|
|
237
|
+
onCeremonyComplete: ()=>{
|
|
238
|
+
ceremonyCompleted = true;
|
|
239
|
+
}
|
|
217
240
|
});
|
|
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
|
+
]);
|
|
218
253
|
if (!rawPublicKey || !clientKeyShares) {
|
|
219
254
|
throw new Error('Error creating wallet account');
|
|
220
255
|
}
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DynamicWalletClient, getClientKeyShareBackupInfo, WalletOperation, MessageHash } from '@dynamic-labs-wallet/browser';
|
|
1
|
+
import { DynamicWalletClient, timeoutPromise, getClientKeyShareBackupInfo, WalletOperation, MessageHash } from '@dynamic-labs-wallet/browser';
|
|
2
2
|
import { serializeSignature, createPublicClient, http, serializeTransaction, getAddress } from 'viem';
|
|
3
3
|
import { mainnet } from 'viem/chains';
|
|
4
4
|
|
|
@@ -40,12 +40,29 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
43
|
+
let ceremonyCompleted = false;
|
|
43
44
|
try {
|
|
44
45
|
// Generate key shares for given threshold signature scheme (TSS)
|
|
45
46
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
46
47
|
chainName: this.chainName,
|
|
47
|
-
thresholdSignatureScheme
|
|
48
|
+
thresholdSignatureScheme,
|
|
49
|
+
onError,
|
|
50
|
+
onCeremonyComplete: ()=>{
|
|
51
|
+
ceremonyCompleted = true;
|
|
52
|
+
}
|
|
48
53
|
});
|
|
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
|
+
]);
|
|
49
66
|
if (!rawPublicKey || !clientKeyShares) {
|
|
50
67
|
throw new Error(ERROR_KEYGEN_FAILED);
|
|
51
68
|
}
|
|
@@ -57,11 +74,13 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
57
74
|
const refreshedUser = await this.apiClient.refreshUser();
|
|
58
75
|
// Find the new wallet in the user's verified credentials
|
|
59
76
|
const newWallet = refreshedUser.user.verifiedCredentials.find((wallet)=>wallet.address.toLowerCase() === accountAddress.toLowerCase());
|
|
60
|
-
|
|
77
|
+
if (!newWallet) {
|
|
78
|
+
throw new Error('Wallet not found after ceremony completion');
|
|
79
|
+
}
|
|
61
80
|
// Store the new wallet in the wallet map
|
|
62
81
|
this.walletMap[accountAddress] = {
|
|
63
82
|
accountAddress,
|
|
64
|
-
walletId:
|
|
83
|
+
walletId: newWallet.id,
|
|
65
84
|
chainName: this.chainName,
|
|
66
85
|
clientKeyShares: clientKeyShares,
|
|
67
86
|
thresholdSignatureScheme,
|
|
@@ -206,13 +225,29 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
206
225
|
};
|
|
207
226
|
}
|
|
208
227
|
async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
228
|
+
let ceremonyCompleted = false;
|
|
209
229
|
// TODO: validate private key for EVM
|
|
210
230
|
const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
|
|
211
231
|
chainName,
|
|
212
232
|
privateKey,
|
|
213
233
|
thresholdSignatureScheme,
|
|
214
|
-
onError
|
|
234
|
+
onError,
|
|
235
|
+
onCeremonyComplete: ()=>{
|
|
236
|
+
ceremonyCompleted = true;
|
|
237
|
+
}
|
|
215
238
|
});
|
|
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
|
+
]);
|
|
216
251
|
if (!rawPublicKey || !clientKeyShares) {
|
|
217
252
|
throw new Error('Error creating wallet account');
|
|
218
253
|
}
|
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.46",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/browser": "0.0.
|
|
6
|
+
"@dynamic-labs-wallet/browser": "0.0.46"
|
|
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,EAKzB,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,EAA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