@dynamic-labs-wallet/evm 0.0.0-preview.57 → 0.0.1-paolo-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 +225 -97
- package/index.esm.js +219 -91
- package/package.json +7 -5
- package/src/client/client.d.ts +39 -15
- package/src/client/client.d.ts.map +1 -1
- package/src/client/constants.d.ts +0 -5
- package/src/client/constants.d.ts.map +1 -1
- package/src/client/helpers.d.ts +5 -0
- package/src/client/helpers.d.ts.map +1 -0
- package/src/client/index.d.ts +1 -1
- package/src/client/index.d.ts.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.d.ts.map +1 -1
- package/src/utils.d.ts +9 -3
- package/src/utils.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var browser = require('@dynamic-labs-wallet/browser');
|
|
4
4
|
var viem = require('viem');
|
|
5
|
+
var accounts = require('viem/accounts');
|
|
5
6
|
var chains = require('viem/chains');
|
|
6
7
|
|
|
7
8
|
function _extends() {
|
|
@@ -16,22 +17,58 @@ function _extends() {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const EVM_SIGN_MESSAGE_PREFIX = `\x19Ethereum Signed Message:\n`;
|
|
19
|
-
// Error messages
|
|
20
|
-
const ERROR_KEYGEN_FAILED = 'Error with keygen';
|
|
21
|
-
const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating evm wallet account';
|
|
22
|
-
const ERROR_SIGN_MESSAGE = 'Error signing message';
|
|
23
|
-
const ERROR_ACCOUNT_ADDRESS_REQUIRED = 'Account address is required';
|
|
24
|
-
const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
|
|
25
20
|
|
|
26
|
-
const formatEVMMessage = (
|
|
27
|
-
|
|
21
|
+
const formatEVMMessage = (message_, logger)=>{
|
|
22
|
+
try {
|
|
23
|
+
const message = (()=>{
|
|
24
|
+
if (typeof message_ === 'string') return viem.stringToHex(message_);
|
|
25
|
+
if (typeof message_.raw === 'string') return message_.raw;
|
|
26
|
+
return viem.bytesToHex(message_.raw);
|
|
27
|
+
})();
|
|
28
|
+
const prefix = viem.stringToHex(`${EVM_SIGN_MESSAGE_PREFIX}${viem.size(message)}`);
|
|
29
|
+
return viem.concat([
|
|
30
|
+
prefix,
|
|
31
|
+
message
|
|
32
|
+
]);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
logger.error('[DynamicWaasWalletClient]: Error formatting EVM message:', error);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const formatTypedData = (typedData)=>{
|
|
39
|
+
return viem.hashTypedData(typedData).slice(2);
|
|
28
40
|
};
|
|
29
|
-
const serializeECDSASignature = (signature)=>{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
const serializeECDSASignature = (signature, logger)=>{
|
|
42
|
+
try {
|
|
43
|
+
return viem.serializeSignature({
|
|
44
|
+
r: `0x${Buffer.from(signature.r).toString('hex')}`,
|
|
45
|
+
s: `0x${Buffer.from(signature.s).toString('hex')}`,
|
|
46
|
+
v: BigInt(signature.v)
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
logger.error('[DynamicWaasWalletClient]: Error serializing ECDSA signature:', error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const checkRawPublicKeyInstance = (rawPublicKey)=>{
|
|
55
|
+
if (!(rawPublicKey instanceof browser.EcdsaPublicKey)) {
|
|
56
|
+
throw new Error('Invalid raw public key');
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const mapTransactionToEvmTransaction = (transaction)=>{
|
|
60
|
+
var _transaction_to, _transaction_chainId;
|
|
61
|
+
return {
|
|
62
|
+
to: (_transaction_to = transaction.to) != null ? _transaction_to : '',
|
|
63
|
+
data: transaction.data,
|
|
64
|
+
gas: transaction.gas ? `0x${transaction.gas.toString(16)}` : undefined,
|
|
65
|
+
gasPrice: transaction.gasPrice ? `0x${transaction.gasPrice.toString(16)}` : undefined,
|
|
66
|
+
maxFeePerGas: transaction.maxFeePerGas ? `0x${transaction.maxFeePerGas.toString(16)}` : undefined,
|
|
67
|
+
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? `0x${transaction.maxPriorityFeePerGas.toString(16)}` : undefined,
|
|
68
|
+
nonce: transaction.nonce,
|
|
69
|
+
value: transaction.value ? `0x${transaction.value.toString(16)}` : undefined,
|
|
70
|
+
chainId: (_transaction_chainId = transaction.chainId) != null ? _transaction_chainId : 0
|
|
71
|
+
};
|
|
35
72
|
};
|
|
36
73
|
|
|
37
74
|
class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
@@ -41,13 +78,21 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
41
78
|
transport: viem.http(rpcUrl)
|
|
42
79
|
});
|
|
43
80
|
}
|
|
44
|
-
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
81
|
+
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError, signedSessionId, traceContext }) {
|
|
45
82
|
try {
|
|
83
|
+
// Create a promise that will resolve when the ceremony is complete
|
|
84
|
+
let ceremonyCeremonyCompleteResolver;
|
|
85
|
+
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
86
|
+
ceremonyCeremonyCompleteResolver = resolve;
|
|
87
|
+
});
|
|
46
88
|
// Generate key shares for given threshold signature scheme (TSS)
|
|
47
89
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
48
90
|
chainName: this.chainName,
|
|
49
91
|
thresholdSignatureScheme,
|
|
50
|
-
onError
|
|
92
|
+
onError: (error)=>{
|
|
93
|
+
this.logger.error(browser.ERROR_CREATE_WALLET_ACCOUNT, error);
|
|
94
|
+
onError == null ? void 0 : onError(error);
|
|
95
|
+
},
|
|
51
96
|
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
52
97
|
// update wallet map
|
|
53
98
|
const checksumAddress = viem.getAddress(accountAddress);
|
|
@@ -58,68 +103,82 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
58
103
|
thresholdSignatureScheme,
|
|
59
104
|
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
60
105
|
});
|
|
106
|
+
this.logger.debug('walletMap updated for wallet', {
|
|
107
|
+
context: {
|
|
108
|
+
accountAddress,
|
|
109
|
+
walletId,
|
|
110
|
+
walletMap: this.walletMap
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
// Resolve the promise when ceremony is complete
|
|
114
|
+
ceremonyCeremonyCompleteResolver(undefined);
|
|
61
115
|
}
|
|
62
116
|
});
|
|
117
|
+
// Wait for the ceremony to complete before proceeding
|
|
118
|
+
await ceremonyCompletePromise;
|
|
63
119
|
if (!rawPublicKey || !clientKeyShares) {
|
|
64
|
-
throw new Error(ERROR_KEYGEN_FAILED);
|
|
120
|
+
throw new Error(browser.ERROR_KEYGEN_FAILED);
|
|
65
121
|
}
|
|
122
|
+
checkRawPublicKeyInstance(rawPublicKey);
|
|
66
123
|
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
67
124
|
rawPublicKey: rawPublicKey
|
|
68
125
|
});
|
|
69
126
|
// 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
127
|
await this.setClientKeySharesToLocalStorage({
|
|
73
128
|
accountAddress,
|
|
74
129
|
clientKeyShares,
|
|
75
130
|
overwriteOrMerge: 'overwrite'
|
|
76
131
|
});
|
|
77
|
-
|
|
78
|
-
void this.storeEncryptedBackupByWalletWithRetry({
|
|
132
|
+
await this.storeEncryptedBackupByWalletWithRetry({
|
|
79
133
|
accountAddress,
|
|
80
134
|
clientKeyShares,
|
|
81
|
-
password
|
|
135
|
+
password,
|
|
136
|
+
signedSessionId
|
|
82
137
|
});
|
|
83
138
|
return {
|
|
84
139
|
accountAddress,
|
|
85
140
|
rawPublicKey,
|
|
86
|
-
publicKeyHex
|
|
87
|
-
clientKeyShares
|
|
141
|
+
publicKeyHex
|
|
88
142
|
};
|
|
89
143
|
} catch (error) {
|
|
90
|
-
this.logger.error(ERROR_CREATE_WALLET_ACCOUNT, error);
|
|
91
|
-
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
144
|
+
this.logger.error(browser.ERROR_CREATE_WALLET_ACCOUNT, error);
|
|
145
|
+
throw new Error(browser.ERROR_CREATE_WALLET_ACCOUNT);
|
|
92
146
|
}
|
|
93
147
|
}
|
|
94
|
-
async signMessage({ message, accountAddress, password = undefined }) {
|
|
148
|
+
async signMessage({ message, accountAddress, password = undefined, signedSessionId, mfaToken, context, onError, traceContext }) {
|
|
95
149
|
await this.verifyPassword({
|
|
96
150
|
accountAddress,
|
|
97
151
|
password,
|
|
98
|
-
walletOperation: browser.WalletOperation.SIGN_MESSAGE
|
|
99
|
-
|
|
100
|
-
await this.getWallet({
|
|
101
|
-
accountAddress,
|
|
102
|
-
walletOperation: browser.WalletOperation.SIGN_MESSAGE
|
|
152
|
+
walletOperation: browser.WalletOperation.SIGN_MESSAGE,
|
|
153
|
+
signedSessionId
|
|
103
154
|
});
|
|
104
155
|
try {
|
|
105
156
|
if (!accountAddress) {
|
|
106
|
-
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
157
|
+
throw new Error(browser.ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
107
158
|
}
|
|
108
159
|
// Format the message for EVM signing
|
|
109
|
-
const formattedMessage = formatEVMMessage(message);
|
|
160
|
+
const formattedMessage = formatEVMMessage(message, this.logger);
|
|
161
|
+
const resolvedContext = context != null ? context : {
|
|
162
|
+
evmMessage: message
|
|
163
|
+
};
|
|
110
164
|
// Sign the message using MPC
|
|
111
165
|
const signatureEcdsa = await this.sign({
|
|
112
166
|
message: formattedMessage,
|
|
113
167
|
accountAddress: accountAddress,
|
|
114
168
|
chainName: this.chainName,
|
|
115
|
-
password
|
|
169
|
+
password,
|
|
170
|
+
signedSessionId,
|
|
171
|
+
mfaToken,
|
|
172
|
+
context: resolvedContext,
|
|
173
|
+
onError,
|
|
174
|
+
traceContext
|
|
116
175
|
});
|
|
117
176
|
// Serialize the signature
|
|
118
|
-
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
177
|
+
const serializedSignature = serializeECDSASignature(signatureEcdsa, this.logger);
|
|
119
178
|
return serializedSignature;
|
|
120
179
|
} catch (error) {
|
|
121
|
-
this.logger.error(ERROR_SIGN_MESSAGE, error);
|
|
122
|
-
throw new Error(ERROR_SIGN_MESSAGE);
|
|
180
|
+
this.logger.error(browser.ERROR_SIGN_MESSAGE, error);
|
|
181
|
+
throw new Error(browser.ERROR_SIGN_MESSAGE);
|
|
123
182
|
}
|
|
124
183
|
}
|
|
125
184
|
async verifyMessageSignature({ accountAddress, message, signature }) {
|
|
@@ -135,15 +194,16 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
135
194
|
});
|
|
136
195
|
return verified;
|
|
137
196
|
} catch (error) {
|
|
138
|
-
this.logger.error(ERROR_VERIFY_MESSAGE_SIGNATURE, error);
|
|
139
|
-
throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
197
|
+
this.logger.error(browser.ERROR_VERIFY_MESSAGE_SIGNATURE, error);
|
|
198
|
+
throw new Error(browser.ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
140
199
|
}
|
|
141
200
|
}
|
|
142
|
-
async signTransaction({ senderAddress, transaction, password = undefined }) {
|
|
201
|
+
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken, context, onError, traceContext }) {
|
|
143
202
|
await this.verifyPassword({
|
|
144
203
|
accountAddress: senderAddress,
|
|
145
204
|
password,
|
|
146
|
-
walletOperation: browser.WalletOperation.SIGN_TRANSACTION
|
|
205
|
+
walletOperation: browser.WalletOperation.SIGN_TRANSACTION,
|
|
206
|
+
signedSessionId
|
|
147
207
|
});
|
|
148
208
|
const serializedTx = viem.serializeTransaction(transaction);
|
|
149
209
|
const serializedTxBytes = Uint8Array.from(Buffer.from(serializedTx.slice(2), 'hex'));
|
|
@@ -155,7 +215,14 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
155
215
|
message: serializedTxBytes,
|
|
156
216
|
accountAddress: senderAddress,
|
|
157
217
|
chainName: this.chainName,
|
|
158
|
-
password
|
|
218
|
+
password,
|
|
219
|
+
signedSessionId,
|
|
220
|
+
mfaToken,
|
|
221
|
+
context: _extends({}, context, {
|
|
222
|
+
evmTransaction: mapTransactionToEvmTransaction(transaction)
|
|
223
|
+
}),
|
|
224
|
+
onError,
|
|
225
|
+
traceContext
|
|
159
226
|
});
|
|
160
227
|
if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
|
|
161
228
|
throw new Error('Invalid signature format returned from MPC signing');
|
|
@@ -176,6 +243,39 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
176
243
|
throw error;
|
|
177
244
|
}
|
|
178
245
|
}
|
|
246
|
+
async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId, mfaToken, onError, traceContext }) {
|
|
247
|
+
await this.verifyPassword({
|
|
248
|
+
accountAddress,
|
|
249
|
+
password,
|
|
250
|
+
walletOperation: browser.WalletOperation.SIGN_MESSAGE,
|
|
251
|
+
signedSessionId
|
|
252
|
+
});
|
|
253
|
+
try {
|
|
254
|
+
if (!accountAddress) {
|
|
255
|
+
throw new Error(browser.ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
256
|
+
}
|
|
257
|
+
const formattedTypedData = formatTypedData(typedData);
|
|
258
|
+
const signatureEcdsa = await this.sign({
|
|
259
|
+
message: formattedTypedData,
|
|
260
|
+
accountAddress: accountAddress,
|
|
261
|
+
chainName: this.chainName,
|
|
262
|
+
password,
|
|
263
|
+
signedSessionId,
|
|
264
|
+
isFormatted: true,
|
|
265
|
+
mfaToken,
|
|
266
|
+
context: {
|
|
267
|
+
evmTypedData: typedData
|
|
268
|
+
},
|
|
269
|
+
onError,
|
|
270
|
+
traceContext
|
|
271
|
+
});
|
|
272
|
+
const serializedSignature = serializeECDSASignature(signatureEcdsa, this.logger);
|
|
273
|
+
return serializedSignature;
|
|
274
|
+
} catch (error) {
|
|
275
|
+
this.logger.error(browser.ERROR_SIGN_TYPED_DATA, error);
|
|
276
|
+
throw new Error(browser.ERROR_SIGN_TYPED_DATA);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
179
279
|
deriveAccountAddress({ rawPublicKey }) {
|
|
180
280
|
const serializedUncompressed = rawPublicKey.serializeUncompressed();
|
|
181
281
|
const firstByteRemoved = serializedUncompressed.slice(1);
|
|
@@ -188,23 +288,22 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
188
288
|
publicKeyHex
|
|
189
289
|
};
|
|
190
290
|
}
|
|
191
|
-
async exportPrivateKey({ accountAddress,
|
|
291
|
+
async exportPrivateKey({ accountAddress, password = undefined, signedSessionId, mfaToken, traceContext }) {
|
|
192
292
|
await this.verifyPassword({
|
|
193
293
|
accountAddress,
|
|
194
294
|
password,
|
|
195
|
-
walletOperation: browser.WalletOperation.EXPORT_PRIVATE_KEY
|
|
295
|
+
walletOperation: browser.WalletOperation.EXPORT_PRIVATE_KEY,
|
|
296
|
+
signedSessionId
|
|
196
297
|
});
|
|
197
298
|
const { derivedPrivateKey } = await this.exportKey({
|
|
198
299
|
accountAddress,
|
|
199
|
-
displayContainer,
|
|
200
300
|
chainName: this.chainName,
|
|
201
|
-
password
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
container: displayContainer
|
|
301
|
+
password,
|
|
302
|
+
signedSessionId,
|
|
303
|
+
mfaToken,
|
|
304
|
+
traceContext
|
|
206
305
|
});
|
|
207
|
-
|
|
306
|
+
return derivedPrivateKey;
|
|
208
307
|
}
|
|
209
308
|
async offlineExportPrivateKey({ keyShares, derivationPath }) {
|
|
210
309
|
const { derivedPrivateKey } = await this.offlineExportKey({
|
|
@@ -216,65 +315,94 @@ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
|
|
|
216
315
|
derivedPrivateKey
|
|
217
316
|
};
|
|
218
317
|
}
|
|
219
|
-
async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
accountAddress: checksumAddress,
|
|
231
|
-
walletId,
|
|
232
|
-
chainName: this.chainName,
|
|
233
|
-
thresholdSignatureScheme,
|
|
234
|
-
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
235
|
-
});
|
|
318
|
+
async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError, signedSessionId, publicAddressCheck }) {
|
|
319
|
+
try {
|
|
320
|
+
let ceremonyCeremonyCompleteResolver;
|
|
321
|
+
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
322
|
+
ceremonyCeremonyCompleteResolver = resolve;
|
|
323
|
+
});
|
|
324
|
+
if (publicAddressCheck) {
|
|
325
|
+
const keypair = accounts.privateKeyToAccount(privateKey);
|
|
326
|
+
if (keypair.address !== publicAddressCheck) {
|
|
327
|
+
throw new Error(`Public address mismatch: derived address ${keypair.address} !== public address ${publicAddressCheck}`);
|
|
328
|
+
}
|
|
236
329
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
330
|
+
//remove 0x if it exists
|
|
331
|
+
const formattedPrivateKey = privateKey.startsWith('0x') ? privateKey.slice(2) : privateKey;
|
|
332
|
+
const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
|
|
333
|
+
chainName,
|
|
334
|
+
privateKey: formattedPrivateKey,
|
|
335
|
+
thresholdSignatureScheme,
|
|
336
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
337
|
+
// update wallet map
|
|
338
|
+
const checksumAddress = viem.getAddress(accountAddress);
|
|
339
|
+
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
340
|
+
accountAddress: checksumAddress,
|
|
341
|
+
walletId,
|
|
342
|
+
chainName: this.chainName,
|
|
343
|
+
thresholdSignatureScheme,
|
|
344
|
+
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
345
|
+
});
|
|
346
|
+
this.logger.debug('walletMap updated for wallet', {
|
|
347
|
+
context: {
|
|
348
|
+
accountAddress,
|
|
349
|
+
walletId,
|
|
350
|
+
walletMap: this.walletMap
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
ceremonyCeremonyCompleteResolver(undefined);
|
|
354
|
+
},
|
|
355
|
+
onError
|
|
356
|
+
});
|
|
357
|
+
// Wait for the ceremony to complete before proceeding
|
|
358
|
+
await ceremonyCompletePromise;
|
|
359
|
+
if (!rawPublicKey || !clientKeyShares) {
|
|
360
|
+
throw new Error(browser.ERROR_IMPORT_PRIVATE_KEY);
|
|
361
|
+
}
|
|
362
|
+
checkRawPublicKeyInstance(rawPublicKey);
|
|
363
|
+
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
364
|
+
rawPublicKey: rawPublicKey
|
|
365
|
+
});
|
|
366
|
+
// Update client key shares in wallet map
|
|
367
|
+
await this.setClientKeySharesToLocalStorage({
|
|
368
|
+
accountAddress,
|
|
369
|
+
clientKeyShares,
|
|
370
|
+
overwriteOrMerge: 'overwrite'
|
|
371
|
+
});
|
|
372
|
+
await this.storeEncryptedBackupByWalletWithRetry({
|
|
373
|
+
accountAddress,
|
|
374
|
+
clientKeyShares,
|
|
375
|
+
password,
|
|
376
|
+
signedSessionId
|
|
377
|
+
});
|
|
378
|
+
return {
|
|
379
|
+
accountAddress,
|
|
380
|
+
rawPublicKey,
|
|
381
|
+
publicKeyHex
|
|
382
|
+
};
|
|
383
|
+
} catch (error) {
|
|
384
|
+
this.logger.error(browser.ERROR_IMPORT_PRIVATE_KEY, error);
|
|
385
|
+
onError == null ? void 0 : onError(error);
|
|
386
|
+
throw error;
|
|
240
387
|
}
|
|
241
|
-
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
242
|
-
rawPublicKey: rawPublicKey
|
|
243
|
-
});
|
|
244
|
-
// Update client key shares in wallet map
|
|
245
|
-
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
246
|
-
// TODO: remove this once iframe handling for secret shares is implemented
|
|
247
|
-
await this.setClientKeySharesToLocalStorage({
|
|
248
|
-
accountAddress,
|
|
249
|
-
clientKeyShares,
|
|
250
|
-
overwriteOrMerge: 'overwrite'
|
|
251
|
-
});
|
|
252
|
-
// Backup the new wallet without waiting for the promise to resolve
|
|
253
|
-
void this.storeEncryptedBackupByWalletWithRetry({
|
|
254
|
-
accountAddress,
|
|
255
|
-
clientKeyShares,
|
|
256
|
-
password
|
|
257
|
-
});
|
|
258
|
-
return {
|
|
259
|
-
accountAddress,
|
|
260
|
-
rawPublicKey,
|
|
261
|
-
publicKeyHex,
|
|
262
|
-
clientKeyShares
|
|
263
|
-
};
|
|
264
388
|
}
|
|
265
389
|
async getEvmWallets() {
|
|
266
390
|
const wallets = await this.getWallets();
|
|
267
391
|
const evmWallets = wallets.filter((wallet)=>wallet.chainName === 'eip155');
|
|
268
392
|
return evmWallets;
|
|
269
393
|
}
|
|
270
|
-
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug }){
|
|
394
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, featureFlags, authMode = browser.AuthMode.HEADER, sdkVersion, forwardMPCClient }){
|
|
271
395
|
super({
|
|
272
396
|
environmentId,
|
|
273
397
|
authToken,
|
|
274
398
|
baseApiUrl,
|
|
275
399
|
baseMPCRelayApiUrl,
|
|
276
400
|
storageKey,
|
|
277
|
-
debug
|
|
401
|
+
debug,
|
|
402
|
+
featureFlags,
|
|
403
|
+
authMode,
|
|
404
|
+
sdkVersion,
|
|
405
|
+
forwardMPCClient
|
|
278
406
|
}), this.chainName = 'EVM';
|
|
279
407
|
}
|
|
280
408
|
}
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DynamicWalletClient, getClientKeyShareBackupInfo, WalletOperation, MessageHash } from '@dynamic-labs-wallet/browser';
|
|
2
|
-
import { serializeSignature, createPublicClient, http, getAddress, serializeTransaction } from 'viem';
|
|
1
|
+
import { EcdsaPublicKey, DynamicWalletClient, getClientKeyShareBackupInfo, ERROR_CREATE_WALLET_ACCOUNT, ERROR_KEYGEN_FAILED, WalletOperation, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_SIGN_MESSAGE, ERROR_VERIFY_MESSAGE_SIGNATURE, ERROR_SIGN_TYPED_DATA, MessageHash, ERROR_IMPORT_PRIVATE_KEY, AuthMode } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import { stringToHex, bytesToHex, size, concat, serializeSignature, hashTypedData, createPublicClient, http, getAddress, serializeTransaction } from 'viem';
|
|
3
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
4
|
import { mainnet } from 'viem/chains';
|
|
4
5
|
|
|
5
6
|
function _extends() {
|
|
@@ -14,22 +15,58 @@ function _extends() {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
const EVM_SIGN_MESSAGE_PREFIX = `\x19Ethereum Signed Message:\n`;
|
|
17
|
-
// Error messages
|
|
18
|
-
const ERROR_KEYGEN_FAILED = 'Error with keygen';
|
|
19
|
-
const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating evm wallet account';
|
|
20
|
-
const ERROR_SIGN_MESSAGE = 'Error signing message';
|
|
21
|
-
const ERROR_ACCOUNT_ADDRESS_REQUIRED = 'Account address is required';
|
|
22
|
-
const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
|
|
23
18
|
|
|
24
|
-
const formatEVMMessage = (
|
|
25
|
-
|
|
19
|
+
const formatEVMMessage = (message_, logger)=>{
|
|
20
|
+
try {
|
|
21
|
+
const message = (()=>{
|
|
22
|
+
if (typeof message_ === 'string') return stringToHex(message_);
|
|
23
|
+
if (typeof message_.raw === 'string') return message_.raw;
|
|
24
|
+
return bytesToHex(message_.raw);
|
|
25
|
+
})();
|
|
26
|
+
const prefix = stringToHex(`${EVM_SIGN_MESSAGE_PREFIX}${size(message)}`);
|
|
27
|
+
return concat([
|
|
28
|
+
prefix,
|
|
29
|
+
message
|
|
30
|
+
]);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
logger.error('[DynamicWaasWalletClient]: Error formatting EVM message:', error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const formatTypedData = (typedData)=>{
|
|
37
|
+
return hashTypedData(typedData).slice(2);
|
|
26
38
|
};
|
|
27
|
-
const serializeECDSASignature = (signature)=>{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
const serializeECDSASignature = (signature, logger)=>{
|
|
40
|
+
try {
|
|
41
|
+
return serializeSignature({
|
|
42
|
+
r: `0x${Buffer.from(signature.r).toString('hex')}`,
|
|
43
|
+
s: `0x${Buffer.from(signature.s).toString('hex')}`,
|
|
44
|
+
v: BigInt(signature.v)
|
|
45
|
+
});
|
|
46
|
+
} catch (error) {
|
|
47
|
+
logger.error('[DynamicWaasWalletClient]: Error serializing ECDSA signature:', error);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const checkRawPublicKeyInstance = (rawPublicKey)=>{
|
|
53
|
+
if (!(rawPublicKey instanceof EcdsaPublicKey)) {
|
|
54
|
+
throw new Error('Invalid raw public key');
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const mapTransactionToEvmTransaction = (transaction)=>{
|
|
58
|
+
var _transaction_to, _transaction_chainId;
|
|
59
|
+
return {
|
|
60
|
+
to: (_transaction_to = transaction.to) != null ? _transaction_to : '',
|
|
61
|
+
data: transaction.data,
|
|
62
|
+
gas: transaction.gas ? `0x${transaction.gas.toString(16)}` : undefined,
|
|
63
|
+
gasPrice: transaction.gasPrice ? `0x${transaction.gasPrice.toString(16)}` : undefined,
|
|
64
|
+
maxFeePerGas: transaction.maxFeePerGas ? `0x${transaction.maxFeePerGas.toString(16)}` : undefined,
|
|
65
|
+
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? `0x${transaction.maxPriorityFeePerGas.toString(16)}` : undefined,
|
|
66
|
+
nonce: transaction.nonce,
|
|
67
|
+
value: transaction.value ? `0x${transaction.value.toString(16)}` : undefined,
|
|
68
|
+
chainId: (_transaction_chainId = transaction.chainId) != null ? _transaction_chainId : 0
|
|
69
|
+
};
|
|
33
70
|
};
|
|
34
71
|
|
|
35
72
|
class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
@@ -39,13 +76,21 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
39
76
|
transport: http(rpcUrl)
|
|
40
77
|
});
|
|
41
78
|
}
|
|
42
|
-
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
79
|
+
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError, signedSessionId, traceContext }) {
|
|
43
80
|
try {
|
|
81
|
+
// Create a promise that will resolve when the ceremony is complete
|
|
82
|
+
let ceremonyCeremonyCompleteResolver;
|
|
83
|
+
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
84
|
+
ceremonyCeremonyCompleteResolver = resolve;
|
|
85
|
+
});
|
|
44
86
|
// Generate key shares for given threshold signature scheme (TSS)
|
|
45
87
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
46
88
|
chainName: this.chainName,
|
|
47
89
|
thresholdSignatureScheme,
|
|
48
|
-
onError
|
|
90
|
+
onError: (error)=>{
|
|
91
|
+
this.logger.error(ERROR_CREATE_WALLET_ACCOUNT, error);
|
|
92
|
+
onError == null ? void 0 : onError(error);
|
|
93
|
+
},
|
|
49
94
|
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
50
95
|
// update wallet map
|
|
51
96
|
const checksumAddress = getAddress(accountAddress);
|
|
@@ -56,64 +101,78 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
56
101
|
thresholdSignatureScheme,
|
|
57
102
|
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
58
103
|
});
|
|
104
|
+
this.logger.debug('walletMap updated for wallet', {
|
|
105
|
+
context: {
|
|
106
|
+
accountAddress,
|
|
107
|
+
walletId,
|
|
108
|
+
walletMap: this.walletMap
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
// Resolve the promise when ceremony is complete
|
|
112
|
+
ceremonyCeremonyCompleteResolver(undefined);
|
|
59
113
|
}
|
|
60
114
|
});
|
|
115
|
+
// Wait for the ceremony to complete before proceeding
|
|
116
|
+
await ceremonyCompletePromise;
|
|
61
117
|
if (!rawPublicKey || !clientKeyShares) {
|
|
62
118
|
throw new Error(ERROR_KEYGEN_FAILED);
|
|
63
119
|
}
|
|
120
|
+
checkRawPublicKeyInstance(rawPublicKey);
|
|
64
121
|
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
65
122
|
rawPublicKey: rawPublicKey
|
|
66
123
|
});
|
|
67
124
|
// 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
125
|
await this.setClientKeySharesToLocalStorage({
|
|
71
126
|
accountAddress,
|
|
72
127
|
clientKeyShares,
|
|
73
128
|
overwriteOrMerge: 'overwrite'
|
|
74
129
|
});
|
|
75
|
-
|
|
76
|
-
void this.storeEncryptedBackupByWalletWithRetry({
|
|
130
|
+
await this.storeEncryptedBackupByWalletWithRetry({
|
|
77
131
|
accountAddress,
|
|
78
132
|
clientKeyShares,
|
|
79
|
-
password
|
|
133
|
+
password,
|
|
134
|
+
signedSessionId
|
|
80
135
|
});
|
|
81
136
|
return {
|
|
82
137
|
accountAddress,
|
|
83
138
|
rawPublicKey,
|
|
84
|
-
publicKeyHex
|
|
85
|
-
clientKeyShares
|
|
139
|
+
publicKeyHex
|
|
86
140
|
};
|
|
87
141
|
} catch (error) {
|
|
88
142
|
this.logger.error(ERROR_CREATE_WALLET_ACCOUNT, error);
|
|
89
143
|
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
90
144
|
}
|
|
91
145
|
}
|
|
92
|
-
async signMessage({ message, accountAddress, password = undefined }) {
|
|
146
|
+
async signMessage({ message, accountAddress, password = undefined, signedSessionId, mfaToken, context, onError, traceContext }) {
|
|
93
147
|
await this.verifyPassword({
|
|
94
148
|
accountAddress,
|
|
95
149
|
password,
|
|
96
|
-
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
97
|
-
|
|
98
|
-
await this.getWallet({
|
|
99
|
-
accountAddress,
|
|
100
|
-
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
150
|
+
walletOperation: WalletOperation.SIGN_MESSAGE,
|
|
151
|
+
signedSessionId
|
|
101
152
|
});
|
|
102
153
|
try {
|
|
103
154
|
if (!accountAddress) {
|
|
104
155
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
105
156
|
}
|
|
106
157
|
// Format the message for EVM signing
|
|
107
|
-
const formattedMessage = formatEVMMessage(message);
|
|
158
|
+
const formattedMessage = formatEVMMessage(message, this.logger);
|
|
159
|
+
const resolvedContext = context != null ? context : {
|
|
160
|
+
evmMessage: message
|
|
161
|
+
};
|
|
108
162
|
// Sign the message using MPC
|
|
109
163
|
const signatureEcdsa = await this.sign({
|
|
110
164
|
message: formattedMessage,
|
|
111
165
|
accountAddress: accountAddress,
|
|
112
166
|
chainName: this.chainName,
|
|
113
|
-
password
|
|
167
|
+
password,
|
|
168
|
+
signedSessionId,
|
|
169
|
+
mfaToken,
|
|
170
|
+
context: resolvedContext,
|
|
171
|
+
onError,
|
|
172
|
+
traceContext
|
|
114
173
|
});
|
|
115
174
|
// Serialize the signature
|
|
116
|
-
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
175
|
+
const serializedSignature = serializeECDSASignature(signatureEcdsa, this.logger);
|
|
117
176
|
return serializedSignature;
|
|
118
177
|
} catch (error) {
|
|
119
178
|
this.logger.error(ERROR_SIGN_MESSAGE, error);
|
|
@@ -137,11 +196,12 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
137
196
|
throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
138
197
|
}
|
|
139
198
|
}
|
|
140
|
-
async signTransaction({ senderAddress, transaction, password = undefined }) {
|
|
199
|
+
async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, mfaToken, context, onError, traceContext }) {
|
|
141
200
|
await this.verifyPassword({
|
|
142
201
|
accountAddress: senderAddress,
|
|
143
202
|
password,
|
|
144
|
-
walletOperation: WalletOperation.SIGN_TRANSACTION
|
|
203
|
+
walletOperation: WalletOperation.SIGN_TRANSACTION,
|
|
204
|
+
signedSessionId
|
|
145
205
|
});
|
|
146
206
|
const serializedTx = serializeTransaction(transaction);
|
|
147
207
|
const serializedTxBytes = Uint8Array.from(Buffer.from(serializedTx.slice(2), 'hex'));
|
|
@@ -153,7 +213,14 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
153
213
|
message: serializedTxBytes,
|
|
154
214
|
accountAddress: senderAddress,
|
|
155
215
|
chainName: this.chainName,
|
|
156
|
-
password
|
|
216
|
+
password,
|
|
217
|
+
signedSessionId,
|
|
218
|
+
mfaToken,
|
|
219
|
+
context: _extends({}, context, {
|
|
220
|
+
evmTransaction: mapTransactionToEvmTransaction(transaction)
|
|
221
|
+
}),
|
|
222
|
+
onError,
|
|
223
|
+
traceContext
|
|
157
224
|
});
|
|
158
225
|
if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
|
|
159
226
|
throw new Error('Invalid signature format returned from MPC signing');
|
|
@@ -174,6 +241,39 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
174
241
|
throw error;
|
|
175
242
|
}
|
|
176
243
|
}
|
|
244
|
+
async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId, mfaToken, onError, traceContext }) {
|
|
245
|
+
await this.verifyPassword({
|
|
246
|
+
accountAddress,
|
|
247
|
+
password,
|
|
248
|
+
walletOperation: WalletOperation.SIGN_MESSAGE,
|
|
249
|
+
signedSessionId
|
|
250
|
+
});
|
|
251
|
+
try {
|
|
252
|
+
if (!accountAddress) {
|
|
253
|
+
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
254
|
+
}
|
|
255
|
+
const formattedTypedData = formatTypedData(typedData);
|
|
256
|
+
const signatureEcdsa = await this.sign({
|
|
257
|
+
message: formattedTypedData,
|
|
258
|
+
accountAddress: accountAddress,
|
|
259
|
+
chainName: this.chainName,
|
|
260
|
+
password,
|
|
261
|
+
signedSessionId,
|
|
262
|
+
isFormatted: true,
|
|
263
|
+
mfaToken,
|
|
264
|
+
context: {
|
|
265
|
+
evmTypedData: typedData
|
|
266
|
+
},
|
|
267
|
+
onError,
|
|
268
|
+
traceContext
|
|
269
|
+
});
|
|
270
|
+
const serializedSignature = serializeECDSASignature(signatureEcdsa, this.logger);
|
|
271
|
+
return serializedSignature;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
this.logger.error(ERROR_SIGN_TYPED_DATA, error);
|
|
274
|
+
throw new Error(ERROR_SIGN_TYPED_DATA);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
177
277
|
deriveAccountAddress({ rawPublicKey }) {
|
|
178
278
|
const serializedUncompressed = rawPublicKey.serializeUncompressed();
|
|
179
279
|
const firstByteRemoved = serializedUncompressed.slice(1);
|
|
@@ -186,23 +286,22 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
186
286
|
publicKeyHex
|
|
187
287
|
};
|
|
188
288
|
}
|
|
189
|
-
async exportPrivateKey({ accountAddress,
|
|
289
|
+
async exportPrivateKey({ accountAddress, password = undefined, signedSessionId, mfaToken, traceContext }) {
|
|
190
290
|
await this.verifyPassword({
|
|
191
291
|
accountAddress,
|
|
192
292
|
password,
|
|
193
|
-
walletOperation: WalletOperation.EXPORT_PRIVATE_KEY
|
|
293
|
+
walletOperation: WalletOperation.EXPORT_PRIVATE_KEY,
|
|
294
|
+
signedSessionId
|
|
194
295
|
});
|
|
195
296
|
const { derivedPrivateKey } = await this.exportKey({
|
|
196
297
|
accountAddress,
|
|
197
|
-
displayContainer,
|
|
198
298
|
chainName: this.chainName,
|
|
199
|
-
password
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
container: displayContainer
|
|
299
|
+
password,
|
|
300
|
+
signedSessionId,
|
|
301
|
+
mfaToken,
|
|
302
|
+
traceContext
|
|
204
303
|
});
|
|
205
|
-
|
|
304
|
+
return derivedPrivateKey;
|
|
206
305
|
}
|
|
207
306
|
async offlineExportPrivateKey({ keyShares, derivationPath }) {
|
|
208
307
|
const { derivedPrivateKey } = await this.offlineExportKey({
|
|
@@ -214,65 +313,94 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
214
313
|
derivedPrivateKey
|
|
215
314
|
};
|
|
216
315
|
}
|
|
217
|
-
async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
accountAddress: checksumAddress,
|
|
229
|
-
walletId,
|
|
230
|
-
chainName: this.chainName,
|
|
231
|
-
thresholdSignatureScheme,
|
|
232
|
-
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
233
|
-
});
|
|
316
|
+
async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError, signedSessionId, publicAddressCheck }) {
|
|
317
|
+
try {
|
|
318
|
+
let ceremonyCeremonyCompleteResolver;
|
|
319
|
+
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
320
|
+
ceremonyCeremonyCompleteResolver = resolve;
|
|
321
|
+
});
|
|
322
|
+
if (publicAddressCheck) {
|
|
323
|
+
const keypair = privateKeyToAccount(privateKey);
|
|
324
|
+
if (keypair.address !== publicAddressCheck) {
|
|
325
|
+
throw new Error(`Public address mismatch: derived address ${keypair.address} !== public address ${publicAddressCheck}`);
|
|
326
|
+
}
|
|
234
327
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
328
|
+
//remove 0x if it exists
|
|
329
|
+
const formattedPrivateKey = privateKey.startsWith('0x') ? privateKey.slice(2) : privateKey;
|
|
330
|
+
const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
|
|
331
|
+
chainName,
|
|
332
|
+
privateKey: formattedPrivateKey,
|
|
333
|
+
thresholdSignatureScheme,
|
|
334
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
335
|
+
// update wallet map
|
|
336
|
+
const checksumAddress = getAddress(accountAddress);
|
|
337
|
+
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
338
|
+
accountAddress: checksumAddress,
|
|
339
|
+
walletId,
|
|
340
|
+
chainName: this.chainName,
|
|
341
|
+
thresholdSignatureScheme,
|
|
342
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
343
|
+
});
|
|
344
|
+
this.logger.debug('walletMap updated for wallet', {
|
|
345
|
+
context: {
|
|
346
|
+
accountAddress,
|
|
347
|
+
walletId,
|
|
348
|
+
walletMap: this.walletMap
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
ceremonyCeremonyCompleteResolver(undefined);
|
|
352
|
+
},
|
|
353
|
+
onError
|
|
354
|
+
});
|
|
355
|
+
// Wait for the ceremony to complete before proceeding
|
|
356
|
+
await ceremonyCompletePromise;
|
|
357
|
+
if (!rawPublicKey || !clientKeyShares) {
|
|
358
|
+
throw new Error(ERROR_IMPORT_PRIVATE_KEY);
|
|
359
|
+
}
|
|
360
|
+
checkRawPublicKeyInstance(rawPublicKey);
|
|
361
|
+
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
362
|
+
rawPublicKey: rawPublicKey
|
|
363
|
+
});
|
|
364
|
+
// Update client key shares in wallet map
|
|
365
|
+
await this.setClientKeySharesToLocalStorage({
|
|
366
|
+
accountAddress,
|
|
367
|
+
clientKeyShares,
|
|
368
|
+
overwriteOrMerge: 'overwrite'
|
|
369
|
+
});
|
|
370
|
+
await this.storeEncryptedBackupByWalletWithRetry({
|
|
371
|
+
accountAddress,
|
|
372
|
+
clientKeyShares,
|
|
373
|
+
password,
|
|
374
|
+
signedSessionId
|
|
375
|
+
});
|
|
376
|
+
return {
|
|
377
|
+
accountAddress,
|
|
378
|
+
rawPublicKey,
|
|
379
|
+
publicKeyHex
|
|
380
|
+
};
|
|
381
|
+
} catch (error) {
|
|
382
|
+
this.logger.error(ERROR_IMPORT_PRIVATE_KEY, error);
|
|
383
|
+
onError == null ? void 0 : onError(error);
|
|
384
|
+
throw error;
|
|
238
385
|
}
|
|
239
|
-
const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
|
|
240
|
-
rawPublicKey: rawPublicKey
|
|
241
|
-
});
|
|
242
|
-
// Update client key shares in wallet map
|
|
243
|
-
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
244
|
-
// TODO: remove this once iframe handling for secret shares is implemented
|
|
245
|
-
await this.setClientKeySharesToLocalStorage({
|
|
246
|
-
accountAddress,
|
|
247
|
-
clientKeyShares,
|
|
248
|
-
overwriteOrMerge: 'overwrite'
|
|
249
|
-
});
|
|
250
|
-
// Backup the new wallet without waiting for the promise to resolve
|
|
251
|
-
void this.storeEncryptedBackupByWalletWithRetry({
|
|
252
|
-
accountAddress,
|
|
253
|
-
clientKeyShares,
|
|
254
|
-
password
|
|
255
|
-
});
|
|
256
|
-
return {
|
|
257
|
-
accountAddress,
|
|
258
|
-
rawPublicKey,
|
|
259
|
-
publicKeyHex,
|
|
260
|
-
clientKeyShares
|
|
261
|
-
};
|
|
262
386
|
}
|
|
263
387
|
async getEvmWallets() {
|
|
264
388
|
const wallets = await this.getWallets();
|
|
265
389
|
const evmWallets = wallets.filter((wallet)=>wallet.chainName === 'eip155');
|
|
266
390
|
return evmWallets;
|
|
267
391
|
}
|
|
268
|
-
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug }){
|
|
392
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, featureFlags, authMode = AuthMode.HEADER, sdkVersion, forwardMPCClient }){
|
|
269
393
|
super({
|
|
270
394
|
environmentId,
|
|
271
395
|
authToken,
|
|
272
396
|
baseApiUrl,
|
|
273
397
|
baseMPCRelayApiUrl,
|
|
274
398
|
storageKey,
|
|
275
|
-
debug
|
|
399
|
+
debug,
|
|
400
|
+
featureFlags,
|
|
401
|
+
authMode,
|
|
402
|
+
sdkVersion,
|
|
403
|
+
forwardMPCClient
|
|
276
404
|
}), this.chainName = 'EVM';
|
|
277
405
|
}
|
|
278
406
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/evm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1-paolo-1",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/browser": "0.0.
|
|
7
|
+
"@dynamic-labs-wallet/browser": "0.0.1-paolo-1",
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "^0.0.818",
|
|
9
|
+
"@faker-js/faker": "^9.5.0"
|
|
7
10
|
},
|
|
8
11
|
"peerDependencies": {
|
|
9
|
-
"viem": "
|
|
12
|
+
"viem": "2.38.2"
|
|
10
13
|
},
|
|
11
14
|
"nx": {
|
|
12
15
|
"sourceRoot": "packages/evm/src",
|
|
@@ -16,7 +19,6 @@
|
|
|
16
19
|
"build": {}
|
|
17
20
|
}
|
|
18
21
|
},
|
|
19
|
-
"type": "module",
|
|
20
22
|
"main": "./index.cjs.js",
|
|
21
23
|
"module": "./index.esm.js",
|
|
22
24
|
"types": "./index.esm.d.ts",
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
"types": "./index.esm.d.ts",
|
|
27
29
|
"import": "./index.esm.js",
|
|
28
30
|
"require": "./index.cjs.js",
|
|
29
|
-
"default": "./index.
|
|
31
|
+
"default": "./index.esm.js"
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
}
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,65 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { DynamicWalletClient, type DynamicWalletClientProps, type EcdsaKeygenResult, type EcdsaPublicKey, type Ed25519KeygenResult, type ThresholdSignatureScheme, type TraceContext } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
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";
|
|
5
|
-
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, }: DynamicWalletClientProps);
|
|
6
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, featureFlags, authMode, sdkVersion, forwardMPCClient, }: DynamicWalletClientProps);
|
|
6
7
|
createViemPublicClient({ chain, rpcUrl, }: {
|
|
7
8
|
chain: Chain;
|
|
8
9
|
rpcUrl?: string;
|
|
9
10
|
}): PublicClient;
|
|
10
|
-
createWalletAccount({ thresholdSignatureScheme, password, onError, }: {
|
|
11
|
+
createWalletAccount({ thresholdSignatureScheme, password, onError, signedSessionId, traceContext, }: {
|
|
11
12
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
12
13
|
password?: string;
|
|
13
14
|
onError?: (error: Error) => void;
|
|
15
|
+
signedSessionId: string;
|
|
16
|
+
traceContext?: TraceContext;
|
|
14
17
|
}): Promise<{
|
|
15
18
|
accountAddress: string;
|
|
16
19
|
publicKeyHex: string;
|
|
17
|
-
rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
|
|
18
|
-
clientKeyShares: ClientKeyShare[];
|
|
20
|
+
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
19
21
|
}>;
|
|
20
|
-
signMessage({ message, accountAddress, password, }: {
|
|
22
|
+
signMessage({ message, accountAddress, password, signedSessionId, mfaToken, context, onError, traceContext, }: {
|
|
21
23
|
message: string;
|
|
22
24
|
accountAddress: string;
|
|
23
25
|
password?: string;
|
|
26
|
+
signedSessionId: string;
|
|
27
|
+
mfaToken?: string;
|
|
28
|
+
context?: SignMessageContext;
|
|
29
|
+
onError?: (error: Error) => void;
|
|
30
|
+
traceContext?: TraceContext;
|
|
24
31
|
}): Promise<`0x${string}`>;
|
|
25
32
|
verifyMessageSignature({ accountAddress, message, signature, }: {
|
|
26
33
|
accountAddress: string;
|
|
27
34
|
message: SignableMessage;
|
|
28
35
|
signature: any;
|
|
29
36
|
}): Promise<boolean>;
|
|
30
|
-
signTransaction({ senderAddress, transaction, password, }: {
|
|
37
|
+
signTransaction({ senderAddress, transaction, password, signedSessionId, mfaToken, context, onError, traceContext, }: {
|
|
31
38
|
senderAddress: string;
|
|
32
39
|
transaction: TransactionSerializable;
|
|
33
40
|
password?: string;
|
|
41
|
+
signedSessionId: string;
|
|
42
|
+
mfaToken?: string;
|
|
43
|
+
context?: SignMessageContext;
|
|
44
|
+
onError?: (error: Error) => void;
|
|
45
|
+
traceContext?: TraceContext;
|
|
34
46
|
}): Promise<string>;
|
|
47
|
+
signTypedData({ accountAddress, typedData, password, signedSessionId, mfaToken, onError, traceContext, }: {
|
|
48
|
+
accountAddress: string;
|
|
49
|
+
typedData: TypedData;
|
|
50
|
+
password?: string;
|
|
51
|
+
signedSessionId: string;
|
|
52
|
+
mfaToken?: string;
|
|
53
|
+
onError?: (error: Error) => void;
|
|
54
|
+
traceContext?: TraceContext;
|
|
55
|
+
}): Promise<`0x${string}`>;
|
|
35
56
|
deriveAccountAddress({ rawPublicKey }: {
|
|
36
57
|
rawPublicKey: EcdsaPublicKey;
|
|
37
58
|
}): {
|
|
38
59
|
accountAddress: `0x${string}`;
|
|
39
|
-
publicKeyHex:
|
|
60
|
+
publicKeyHex: string;
|
|
40
61
|
};
|
|
41
|
-
exportPrivateKey({ accountAddress,
|
|
62
|
+
exportPrivateKey({ accountAddress, password, signedSessionId, mfaToken, traceContext, }: {
|
|
42
63
|
accountAddress: string;
|
|
43
|
-
displayContainer: HTMLElement;
|
|
44
64
|
password?: string;
|
|
45
|
-
|
|
65
|
+
signedSessionId: string;
|
|
66
|
+
mfaToken?: string;
|
|
67
|
+
traceContext?: TraceContext;
|
|
68
|
+
}): Promise<string | undefined>;
|
|
46
69
|
offlineExportPrivateKey({ keyShares, derivationPath, }: {
|
|
47
70
|
keyShares: (EcdsaKeygenResult | Ed25519KeygenResult)[];
|
|
48
71
|
derivationPath?: string;
|
|
49
72
|
}): Promise<{
|
|
50
73
|
derivedPrivateKey: string | undefined;
|
|
51
74
|
}>;
|
|
52
|
-
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, }: {
|
|
75
|
+
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, signedSessionId, publicAddressCheck, }: {
|
|
53
76
|
privateKey: string;
|
|
54
77
|
chainName: string;
|
|
55
78
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
56
79
|
password?: string;
|
|
57
80
|
onError?: (error: Error) => void;
|
|
81
|
+
signedSessionId: string;
|
|
82
|
+
publicAddressCheck?: string;
|
|
58
83
|
}): Promise<{
|
|
59
84
|
accountAddress: string;
|
|
60
85
|
publicKeyHex: string;
|
|
61
|
-
rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
|
|
62
|
-
clientKeyShares: ClientKeyShare[];
|
|
86
|
+
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
63
87
|
}>;
|
|
64
88
|
getEvmWallets(): Promise<any>;
|
|
65
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EAUxB,KAAK,wBAAwB,EAE7B,KAAK,YAAY,EAClB,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;AAad,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,EACV,gBAAgB,GACjB,EAAE,wBAAwB;IAe3B,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,EACP,eAAe,EACf,YAAY,GACb,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QACjC,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,YAAY,CAAC;KAC7B,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;KAChE,CAAC;IA6EI,WAAW,CAAC,EAChB,OAAO,EACP,cAAc,EACd,QAAoB,EACpB,eAAe,EACf,QAAQ,EACR,OAAO,EACP,OAAO,EACP,YAAY,GACb,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,kBAAkB,CAAC;QAC7B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QACjC,YAAY,CAAC,EAAE,YAAY,CAAC;KAC7B;IA2CK,sBAAsB,CAAC,EAC3B,cAAc,EACd,OAAO,EACP,SAAS,GACV,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,eAAe,CAAC;QACzB,SAAS,EAAE,GAAG,CAAC;KAChB;IAmBK,eAAe,CAAC,EACpB,aAAa,EACb,WAAW,EACX,QAAoB,EACpB,eAAe,EACf,QAAQ,EACR,OAAO,EACP,OAAO,EACP,YAAY,GACb,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,uBAAuB,CAAC;QACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,kBAAkB,CAAC;QAC7B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QACjC,YAAY,CAAC,EAAE,YAAY,CAAC;KAC7B,GAAG,OAAO,CAAC,MAAM,CAAC;IA4Db,aAAa,CAAC,EAClB,cAAc,EACd,SAAS,EACT,QAAoB,EACpB,eAAe,EACf,QAAQ,EACR,OAAO,EACP,YAAY,GACb,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,SAAS,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QACjC,YAAY,CAAC,EAAE,YAAY,CAAC;KAC7B;IA0CD,oBAAoB,CAAC,EAAE,YAAY,EAAE,EAAE;QAAE,YAAY,EAAE,cAAc,CAAA;KAAE;;;;IAUjE,gBAAgB,CAAC,EACrB,cAAc,EACd,QAAoB,EACpB,eAAe,EACf,QAAQ,EACR,YAAY,GACb,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,YAAY,CAAC;KAC7B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAoBzB,uBAAuB,CAAC,EAC5B,SAAS,EACT,cAAc,GACf,EAAE;QACD,SAAS,EAAE,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,EAAE,CAAC;QACvD,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;;;IAUK,gBAAgB,CAAC,EACrB,UAAU,EACV,SAAS,EACT,wBAAwB,EACxB,QAAoB,EACpB,OAAO,EACP,eAAe,EACf,kBAAkB,GACnB,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QACjC,eAAe,EAAE,MAAM,CAAC;QACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;KAChE,CAAC;IAqFI,aAAa;CAOpB"}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
export declare const EVM_SIGN_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
|
|
2
|
-
export declare const ERROR_KEYGEN_FAILED = "Error with keygen";
|
|
3
|
-
export declare const ERROR_CREATE_WALLET_ACCOUNT = "Error creating evm wallet account";
|
|
4
|
-
export declare const ERROR_SIGN_MESSAGE = "Error signing message";
|
|
5
|
-
export declare const ERROR_ACCOUNT_ADDRESS_REQUIRED = "Account address is required";
|
|
6
|
-
export declare const ERROR_VERIFY_MESSAGE_SIGNATURE = "Error verifying message signature";
|
|
7
2
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,qCAAmC,CAAC
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,qCAAmC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SignMessageEvmTransaction } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import type { TransactionSerializable } from 'viem';
|
|
3
|
+
export declare const checkRawPublicKeyInstance: (rawPublicKey: any) => void;
|
|
4
|
+
export declare const mapTransactionToEvmTransaction: (transaction: TransactionSerializable) => SignMessageEvmTransaction;
|
|
5
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/client/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,MAAM,CAAC;AAEpD,eAAO,MAAM,yBAAyB,iBAAkB,GAAG,SAI1D,CAAC;AAEF,eAAO,MAAM,8BAA8B,gBAC5B,uBAAuB,KACnC,yBAgBD,CAAC"}
|
package/src/client/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './client';
|
|
1
|
+
export * from './client.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './client';
|
|
1
|
+
export * from './client/index.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
package/src/utils.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { EcdsaSignature } from '@dynamic-labs-wallet/browser';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import type { EcdsaSignature, Logger } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import type { TypedData } from 'viem';
|
|
3
|
+
export declare const formatEVMMessage: (message_: string | {
|
|
4
|
+
raw: string | Uint8Array;
|
|
5
|
+
}, logger: Logger) => `0x${string}`;
|
|
6
|
+
export declare const formatTypedData: (typedData: TypedData | {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}) => string;
|
|
9
|
+
export declare const serializeECDSASignature: (signature: EcdsaSignature, logger: Logger) => `0x${string}`;
|
|
4
10
|
//# sourceMappingURL=utils.d.ts.map
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAA2B,SAAS,EAAE,MAAM,MAAM,CAAC;AAW/D,eAAO,MAAM,gBAAgB,aACjB,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,UACvC,MAAM,kBAmBf,CAAC;AAEF,eAAO,MAAM,eAAe,cACf,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,WAGlD,CAAC;AAEF,eAAO,MAAM,uBAAuB,cACvB,cAAc,UACjB,MAAM,kBAef,CAAC"}
|