@dynamic-labs-wallet/evm 0.0.140 → 0.0.142
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 +14 -13
- package/index.esm.js +14 -13
- package/package.json +2 -2
- package/src/client/client.d.ts +8 -3
- package/src/client/client.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -144,7 +144,7 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
144
144
|
throw new Error(browser.ERROR_CREATE_WALLET_ACCOUNT);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
async signMessage({ message, accountAddress, password = undefined, signedSessionId, mfaToken }) {
|
|
147
|
+
async signMessage({ message, accountAddress, password = undefined, signedSessionId, mfaToken, context, onError }) {
|
|
148
148
|
await this.verifyPassword({
|
|
149
149
|
accountAddress,
|
|
150
150
|
password,
|
|
@@ -157,6 +157,9 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
157
157
|
}
|
|
158
158
|
// Format the message for EVM signing
|
|
159
159
|
const formattedMessage = formatEVMMessage(message, this.logger);
|
|
160
|
+
const resolvedContext = context != null ? context : {
|
|
161
|
+
evmMessage: message
|
|
162
|
+
};
|
|
160
163
|
// Sign the message using MPC
|
|
161
164
|
const signatureEcdsa = await this.sign({
|
|
162
165
|
message: formattedMessage,
|
|
@@ -165,9 +168,8 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
165
168
|
password,
|
|
166
169
|
signedSessionId,
|
|
167
170
|
mfaToken,
|
|
168
|
-
context:
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
+
context: resolvedContext,
|
|
172
|
+
onError
|
|
171
173
|
});
|
|
172
174
|
// Serialize the signature
|
|
173
175
|
const serializedSignature = serializeECDSASignature(signatureEcdsa, this.logger);
|
|
@@ -194,7 +196,7 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
194
196
|
throw new Error(browser.ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
|
-
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken }) {
|
|
199
|
+
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken, onError }) {
|
|
198
200
|
await this.verifyPassword({
|
|
199
201
|
accountAddress: senderAddress,
|
|
200
202
|
password,
|
|
@@ -216,7 +218,8 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
216
218
|
mfaToken,
|
|
217
219
|
context: {
|
|
218
220
|
evmTransaction: mapTransactionToEvmTransaction(transaction)
|
|
219
|
-
}
|
|
221
|
+
},
|
|
222
|
+
onError
|
|
220
223
|
});
|
|
221
224
|
if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
|
|
222
225
|
throw new Error('Invalid signature format returned from MPC signing');
|
|
@@ -237,7 +240,7 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
237
240
|
throw error;
|
|
238
241
|
}
|
|
239
242
|
}
|
|
240
|
-
async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId, mfaToken }) {
|
|
243
|
+
async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId, mfaToken, onError }) {
|
|
241
244
|
await this.verifyPassword({
|
|
242
245
|
accountAddress,
|
|
243
246
|
password,
|
|
@@ -259,7 +262,8 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
259
262
|
mfaToken,
|
|
260
263
|
context: {
|
|
261
264
|
evmTypedData: typedData
|
|
262
|
-
}
|
|
265
|
+
},
|
|
266
|
+
onError
|
|
263
267
|
});
|
|
264
268
|
const serializedSignature = serializeECDSASignature(signatureEcdsa, this.logger);
|
|
265
269
|
return serializedSignature;
|
|
@@ -319,10 +323,6 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
319
323
|
chainName,
|
|
320
324
|
privateKey: formattedPrivateKey,
|
|
321
325
|
thresholdSignatureScheme,
|
|
322
|
-
onError: (error)=>{
|
|
323
|
-
this.logger.error(browser.ERROR_IMPORT_PRIVATE_KEY, error);
|
|
324
|
-
onError == null ? void 0 : onError(error);
|
|
325
|
-
},
|
|
326
326
|
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
327
327
|
// update wallet map
|
|
328
328
|
const checksumAddress = viem.getAddress(accountAddress);
|
|
@@ -341,7 +341,8 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
341
341
|
}
|
|
342
342
|
});
|
|
343
343
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
344
|
-
}
|
|
344
|
+
},
|
|
345
|
+
onError
|
|
345
346
|
});
|
|
346
347
|
// Wait for the ceremony to complete before proceeding
|
|
347
348
|
await ceremonyCompletePromise;
|
package/index.esm.js
CHANGED
|
@@ -142,7 +142,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
142
142
|
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
async signMessage({ message, accountAddress, password = undefined, signedSessionId, mfaToken }) {
|
|
145
|
+
async signMessage({ message, accountAddress, password = undefined, signedSessionId, mfaToken, context, onError }) {
|
|
146
146
|
await this.verifyPassword({
|
|
147
147
|
accountAddress,
|
|
148
148
|
password,
|
|
@@ -155,6 +155,9 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
155
155
|
}
|
|
156
156
|
// Format the message for EVM signing
|
|
157
157
|
const formattedMessage = formatEVMMessage(message, this.logger);
|
|
158
|
+
const resolvedContext = context != null ? context : {
|
|
159
|
+
evmMessage: message
|
|
160
|
+
};
|
|
158
161
|
// Sign the message using MPC
|
|
159
162
|
const signatureEcdsa = await this.sign({
|
|
160
163
|
message: formattedMessage,
|
|
@@ -163,9 +166,8 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
163
166
|
password,
|
|
164
167
|
signedSessionId,
|
|
165
168
|
mfaToken,
|
|
166
|
-
context:
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
+
context: resolvedContext,
|
|
170
|
+
onError
|
|
169
171
|
});
|
|
170
172
|
// Serialize the signature
|
|
171
173
|
const serializedSignature = serializeECDSASignature(signatureEcdsa, this.logger);
|
|
@@ -192,7 +194,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
192
194
|
throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
|
-
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken }) {
|
|
197
|
+
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken, onError }) {
|
|
196
198
|
await this.verifyPassword({
|
|
197
199
|
accountAddress: senderAddress,
|
|
198
200
|
password,
|
|
@@ -214,7 +216,8 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
214
216
|
mfaToken,
|
|
215
217
|
context: {
|
|
216
218
|
evmTransaction: mapTransactionToEvmTransaction(transaction)
|
|
217
|
-
}
|
|
219
|
+
},
|
|
220
|
+
onError
|
|
218
221
|
});
|
|
219
222
|
if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
|
|
220
223
|
throw new Error('Invalid signature format returned from MPC signing');
|
|
@@ -235,7 +238,7 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
235
238
|
throw error;
|
|
236
239
|
}
|
|
237
240
|
}
|
|
238
|
-
async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId, mfaToken }) {
|
|
241
|
+
async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId, mfaToken, onError }) {
|
|
239
242
|
await this.verifyPassword({
|
|
240
243
|
accountAddress,
|
|
241
244
|
password,
|
|
@@ -257,7 +260,8 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
257
260
|
mfaToken,
|
|
258
261
|
context: {
|
|
259
262
|
evmTypedData: typedData
|
|
260
|
-
}
|
|
263
|
+
},
|
|
264
|
+
onError
|
|
261
265
|
});
|
|
262
266
|
const serializedSignature = serializeECDSASignature(signatureEcdsa, this.logger);
|
|
263
267
|
return serializedSignature;
|
|
@@ -317,10 +321,6 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
317
321
|
chainName,
|
|
318
322
|
privateKey: formattedPrivateKey,
|
|
319
323
|
thresholdSignatureScheme,
|
|
320
|
-
onError: (error)=>{
|
|
321
|
-
this.logger.error(ERROR_IMPORT_PRIVATE_KEY, error);
|
|
322
|
-
onError == null ? void 0 : onError(error);
|
|
323
|
-
},
|
|
324
324
|
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
325
325
|
// update wallet map
|
|
326
326
|
const checksumAddress = getAddress(accountAddress);
|
|
@@ -339,7 +339,8 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
339
339
|
}
|
|
340
340
|
});
|
|
341
341
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
342
|
-
}
|
|
342
|
+
},
|
|
343
|
+
onError
|
|
343
344
|
});
|
|
344
345
|
// Wait for the ceremony to complete before proceeding
|
|
345
346
|
await ceremonyCompletePromise;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/evm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.142",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/browser": "0.0.
|
|
7
|
+
"@dynamic-labs-wallet/browser": "0.0.142",
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "^0.0.758"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DynamicWalletClient, DynamicWalletClientProps, EcdsaKeygenResult, EcdsaPublicKey, Ed25519KeygenResult, ThresholdSignatureScheme } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
2
3
|
import { type Chain, type PublicClient, type SignableMessage, type TransactionSerializable, type TypedData } from 'viem';
|
|
3
4
|
export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
4
5
|
readonly chainName = "EVM";
|
|
@@ -17,31 +18,35 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
17
18
|
publicKeyHex: string;
|
|
18
19
|
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
19
20
|
}>;
|
|
20
|
-
signMessage({ message, accountAddress, password, signedSessionId, mfaToken, }: {
|
|
21
|
+
signMessage({ message, accountAddress, password, signedSessionId, mfaToken, context, onError, }: {
|
|
21
22
|
message: string;
|
|
22
23
|
accountAddress: string;
|
|
23
24
|
password?: string;
|
|
24
25
|
signedSessionId: string;
|
|
25
26
|
mfaToken?: string;
|
|
27
|
+
context?: SignMessageContext;
|
|
28
|
+
onError?: (error: Error) => void;
|
|
26
29
|
}): Promise<`0x${string}`>;
|
|
27
30
|
verifyMessageSignature({ accountAddress, message, signature, }: {
|
|
28
31
|
accountAddress: string;
|
|
29
32
|
message: SignableMessage;
|
|
30
33
|
signature: any;
|
|
31
34
|
}): Promise<boolean>;
|
|
32
|
-
signTransaction({ senderAddress, transaction, password, signedSessionId, mfaToken, }: {
|
|
35
|
+
signTransaction({ senderAddress, transaction, password, signedSessionId, mfaToken, onError, }: {
|
|
33
36
|
senderAddress: string;
|
|
34
37
|
transaction: TransactionSerializable;
|
|
35
38
|
password?: string;
|
|
36
39
|
signedSessionId: string;
|
|
37
40
|
mfaToken?: string;
|
|
41
|
+
onError?: (error: Error) => void;
|
|
38
42
|
}): Promise<string>;
|
|
39
|
-
signTypedData({ accountAddress, typedData, password, signedSessionId, mfaToken, }: {
|
|
43
|
+
signTypedData({ accountAddress, typedData, password, signedSessionId, mfaToken, onError, }: {
|
|
40
44
|
accountAddress: string;
|
|
41
45
|
typedData: TypedData;
|
|
42
46
|
password?: string;
|
|
43
47
|
signedSessionId: string;
|
|
44
48
|
mfaToken?: string;
|
|
49
|
+
onError?: (error: Error) => void;
|
|
45
50
|
}): Promise<`0x${string}`>;
|
|
46
51
|
deriveAccountAddress({ rawPublicKey }: {
|
|
47
52
|
rawPublicKey: EcdsaPublicKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EAEd,mBAAmB,EAUnB,wBAAwB,EAEzB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EAEd,mBAAmB,EAUnB,wBAAwB,EAEzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,KAAK,EAIV,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAYd,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,KAAK,EACL,YAAY,EACZ,QAA0B,EAC1B,UAAU,GACX,EAAE,wBAAwB;IAc3B,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,EAC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