@dynamic-labs-wallet/node-evm 0.0.0-beta.316 → 0.0.0-pr354.0
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 -130
- package/index.esm.js +17 -120
- package/package.json +2 -3
- package/src/client/client.d.ts +1 -4
- package/src/client/client.d.ts.map +1 -1
- package/src/client/index.d.ts +0 -2
- package/src/client/index.d.ts.map +1 -1
- package/src/index.d.ts +0 -1
- package/src/index.d.ts.map +1 -1
- package/src/utils.d.ts +1 -3
- package/src/utils.d.ts.map +1 -1
- package/src/delegatedClient.d.ts +0 -43
- package/src/delegatedClient.d.ts.map +0 -1
package/index.cjs.js
CHANGED
|
@@ -23,17 +23,8 @@ const ERROR_SIGN_MESSAGE = 'Error signing message';
|
|
|
23
23
|
const ERROR_ACCOUNT_ADDRESS_REQUIRED = 'Account address is required';
|
|
24
24
|
const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
|
|
25
25
|
|
|
26
|
-
const formatEVMMessage = (
|
|
27
|
-
|
|
28
|
-
if (typeof message_ === 'string') return viem.stringToHex(message_);
|
|
29
|
-
if (typeof message_.raw === 'string') return message_.raw;
|
|
30
|
-
return viem.bytesToHex(message_.raw);
|
|
31
|
-
})();
|
|
32
|
-
const prefix = viem.stringToHex(`${EVM_SIGN_MESSAGE_PREFIX}${viem.size(message)}`);
|
|
33
|
-
return viem.concat([
|
|
34
|
-
prefix,
|
|
35
|
-
message
|
|
36
|
-
]);
|
|
26
|
+
const formatEVMMessage = (message)=>{
|
|
27
|
+
return `${EVM_SIGN_MESSAGE_PREFIX}${message.length}${message}`;
|
|
37
28
|
};
|
|
38
29
|
const serializeECDSASignature = (signature)=>{
|
|
39
30
|
return viem.serializeSignature({
|
|
@@ -83,16 +74,11 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
83
74
|
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
84
75
|
// update wallet map
|
|
85
76
|
const checksumAddress = viem.getAddress(accountAddress);
|
|
86
|
-
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
87
77
|
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
88
78
|
accountAddress: checksumAddress,
|
|
89
79
|
walletId,
|
|
90
80
|
chainName: this.chainName,
|
|
91
81
|
thresholdSignatureScheme,
|
|
92
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
93
|
-
index,
|
|
94
|
-
value
|
|
95
|
-
]))),
|
|
96
82
|
externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
|
|
97
83
|
});
|
|
98
84
|
this.logger.debug('walletMap updated for wallet', {
|
|
@@ -132,25 +118,29 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
132
118
|
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
133
119
|
}
|
|
134
120
|
}
|
|
135
|
-
async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares
|
|
121
|
+
async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares }) {
|
|
122
|
+
await this.verifyPassword({
|
|
123
|
+
accountAddress,
|
|
124
|
+
password,
|
|
125
|
+
walletOperation: node.WalletOperation.SIGN_MESSAGE
|
|
126
|
+
});
|
|
127
|
+
await this.getWallet({
|
|
128
|
+
accountAddress,
|
|
129
|
+
walletOperation: node.WalletOperation.SIGN_MESSAGE
|
|
130
|
+
});
|
|
136
131
|
try {
|
|
137
132
|
if (!accountAddress) {
|
|
138
133
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
139
134
|
}
|
|
140
135
|
// Format the message for EVM signing
|
|
141
136
|
const formattedMessage = formatEVMMessage(message);
|
|
142
|
-
const resolvedContext = context != null ? context : {
|
|
143
|
-
evmMessage: message
|
|
144
|
-
};
|
|
145
137
|
// Sign the message using MPC
|
|
146
138
|
const signatureEcdsa = await this.sign({
|
|
147
139
|
message: formattedMessage,
|
|
148
140
|
accountAddress: accountAddress,
|
|
149
141
|
chainName: this.chainName,
|
|
150
142
|
password,
|
|
151
|
-
externalServerKeyShares
|
|
152
|
-
context: resolvedContext,
|
|
153
|
-
onError
|
|
143
|
+
externalServerKeyShares
|
|
154
144
|
});
|
|
155
145
|
// Serialize the signature
|
|
156
146
|
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
@@ -263,24 +253,16 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
263
253
|
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
264
254
|
// update wallet map
|
|
265
255
|
const checksumAddress = viem.getAddress(accountAddress);
|
|
266
|
-
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
267
256
|
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
268
257
|
accountAddress: checksumAddress,
|
|
269
258
|
walletId,
|
|
270
259
|
chainName: this.chainName,
|
|
271
260
|
thresholdSignatureScheme,
|
|
272
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
273
|
-
index,
|
|
274
|
-
value
|
|
275
|
-
]))),
|
|
276
261
|
externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
|
|
277
262
|
});
|
|
278
263
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
279
264
|
},
|
|
280
|
-
onError
|
|
281
|
-
this.logger.error('importPrivateKey: onError', e);
|
|
282
|
-
onError == null ? void 0 : onError(e);
|
|
283
|
-
}
|
|
265
|
+
onError
|
|
284
266
|
});
|
|
285
267
|
// Wait for the ceremony to complete before proceeding
|
|
286
268
|
await ceremonyCompletePromise;
|
|
@@ -318,102 +300,4 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
318
300
|
}
|
|
319
301
|
}
|
|
320
302
|
|
|
321
|
-
/**
|
|
322
|
-
* Creates a delegated EVM wallet client for functional operations
|
|
323
|
-
*/ const createDelegatedEvmWalletClient = ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug = false })=>{
|
|
324
|
-
const baseClient = node.createDelegatedWalletClient({
|
|
325
|
-
environmentId,
|
|
326
|
-
baseApiUrl,
|
|
327
|
-
baseMPCRelayApiUrl,
|
|
328
|
-
apiKey,
|
|
329
|
-
debug
|
|
330
|
-
});
|
|
331
|
-
const evmClient = _extends({}, baseClient, {
|
|
332
|
-
chainName: 'EVM'
|
|
333
|
-
});
|
|
334
|
-
return evmClient;
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* Signs a message using delegated signing for EVM
|
|
338
|
-
*/ const delegatedSignMessage = async (client, { walletId, walletApiKey, keyShare, message, context, onError })=>{
|
|
339
|
-
try {
|
|
340
|
-
if (!keyShare || !walletId || !walletApiKey) {
|
|
341
|
-
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a message');
|
|
342
|
-
}
|
|
343
|
-
const formattedMessage = formatEVMMessage(message);
|
|
344
|
-
const resolvedContext = context != null ? context : {
|
|
345
|
-
evmMessage: message
|
|
346
|
-
};
|
|
347
|
-
const signatureEcdsa = await node.delegatedSignMessage(client, {
|
|
348
|
-
walletId,
|
|
349
|
-
walletApiKey,
|
|
350
|
-
keyShare,
|
|
351
|
-
message: formattedMessage,
|
|
352
|
-
chainName: client.chainName,
|
|
353
|
-
context: resolvedContext,
|
|
354
|
-
onError
|
|
355
|
-
});
|
|
356
|
-
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
357
|
-
return serializedSignature;
|
|
358
|
-
} catch (error) {
|
|
359
|
-
client.logger.error('Error in delegatedSignMessage', error);
|
|
360
|
-
throw error;
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
/**
|
|
364
|
-
* Signs a transaction using delegated signing for EVM
|
|
365
|
-
*/ const delegatedSignTransaction = async (client, { walletId, walletApiKey, keyShare, transaction })=>{
|
|
366
|
-
try {
|
|
367
|
-
// Serialize the transaction
|
|
368
|
-
const serializedTx = viem.serializeTransaction(transaction);
|
|
369
|
-
const serializedTxBytes = Uint8Array.from(Buffer.from(serializedTx.slice(2), 'hex'));
|
|
370
|
-
if (!(serializedTxBytes instanceof Uint8Array)) {
|
|
371
|
-
throw new Error('Invalid serializedTxBytes');
|
|
372
|
-
}
|
|
373
|
-
// Use the delegated sign message function from node package
|
|
374
|
-
const signatureEcdsa = await node.delegatedSignMessage(client, {
|
|
375
|
-
walletId,
|
|
376
|
-
walletApiKey,
|
|
377
|
-
keyShare,
|
|
378
|
-
message: serializedTxBytes,
|
|
379
|
-
chainName: client.chainName
|
|
380
|
-
});
|
|
381
|
-
if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
|
|
382
|
-
throw new Error('Invalid signature format returned from MPC signing');
|
|
383
|
-
}
|
|
384
|
-
// Construct the signed transaction
|
|
385
|
-
const r = `0x${Buffer.from(signatureEcdsa.r).toString('hex')}`;
|
|
386
|
-
const s = `0x${Buffer.from(signatureEcdsa.s).toString('hex')}`;
|
|
387
|
-
const v = BigInt(signatureEcdsa.v);
|
|
388
|
-
const signedTx = _extends({}, transaction, {
|
|
389
|
-
r: r,
|
|
390
|
-
s: s,
|
|
391
|
-
v: v
|
|
392
|
-
});
|
|
393
|
-
const serializedSignedTx = viem.serializeTransaction(signedTx);
|
|
394
|
-
return serializedSignedTx;
|
|
395
|
-
} catch (error) {
|
|
396
|
-
client.logger.error('Error in delegatedSignTransaction', error);
|
|
397
|
-
throw error;
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
/**
|
|
401
|
-
* Revoke delegation - delegates to the node package
|
|
402
|
-
*/ const revokeDelegation = async (client, params)=>{
|
|
403
|
-
return node.revokeDelegation(client, params);
|
|
404
|
-
};
|
|
405
|
-
|
|
406
303
|
exports.DynamicEvmWalletClient = DynamicEvmWalletClient;
|
|
407
|
-
exports.ERROR_ACCOUNT_ADDRESS_REQUIRED = ERROR_ACCOUNT_ADDRESS_REQUIRED;
|
|
408
|
-
exports.ERROR_CREATE_WALLET_ACCOUNT = ERROR_CREATE_WALLET_ACCOUNT;
|
|
409
|
-
exports.ERROR_KEYGEN_FAILED = ERROR_KEYGEN_FAILED;
|
|
410
|
-
exports.ERROR_SIGN_MESSAGE = ERROR_SIGN_MESSAGE;
|
|
411
|
-
exports.ERROR_VERIFY_MESSAGE_SIGNATURE = ERROR_VERIFY_MESSAGE_SIGNATURE;
|
|
412
|
-
exports.EVM_SIGN_MESSAGE_PREFIX = EVM_SIGN_MESSAGE_PREFIX;
|
|
413
|
-
exports.createDelegatedEvmWalletClient = createDelegatedEvmWalletClient;
|
|
414
|
-
exports.delegatedSignMessage = delegatedSignMessage;
|
|
415
|
-
exports.delegatedSignTransaction = delegatedSignTransaction;
|
|
416
|
-
exports.deriveAccountAddress = deriveAccountAddress;
|
|
417
|
-
exports.formatEVMMessage = formatEVMMessage;
|
|
418
|
-
exports.revokeDelegation = revokeDelegation;
|
|
419
|
-
exports.serializeECDSASignature = serializeECDSASignature;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MessageHash, DynamicWalletClient,
|
|
2
|
-
import {
|
|
1
|
+
import { MessageHash, DynamicWalletClient, getExternalServerKeyShareBackupInfo, WalletOperation } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import { getAddress, serializeSignature, createPublicClient, http, serializeTransaction } from 'viem';
|
|
3
3
|
import { mainnet } from 'viem/chains';
|
|
4
4
|
|
|
5
5
|
function _extends() {
|
|
@@ -21,17 +21,8 @@ const ERROR_SIGN_MESSAGE = 'Error signing message';
|
|
|
21
21
|
const ERROR_ACCOUNT_ADDRESS_REQUIRED = 'Account address is required';
|
|
22
22
|
const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
|
|
23
23
|
|
|
24
|
-
const formatEVMMessage = (
|
|
25
|
-
|
|
26
|
-
if (typeof message_ === 'string') return stringToHex(message_);
|
|
27
|
-
if (typeof message_.raw === 'string') return message_.raw;
|
|
28
|
-
return bytesToHex(message_.raw);
|
|
29
|
-
})();
|
|
30
|
-
const prefix = stringToHex(`${EVM_SIGN_MESSAGE_PREFIX}${size(message)}`);
|
|
31
|
-
return concat([
|
|
32
|
-
prefix,
|
|
33
|
-
message
|
|
34
|
-
]);
|
|
24
|
+
const formatEVMMessage = (message)=>{
|
|
25
|
+
return `${EVM_SIGN_MESSAGE_PREFIX}${message.length}${message}`;
|
|
35
26
|
};
|
|
36
27
|
const serializeECDSASignature = (signature)=>{
|
|
37
28
|
return serializeSignature({
|
|
@@ -81,16 +72,11 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
81
72
|
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
82
73
|
// update wallet map
|
|
83
74
|
const checksumAddress = getAddress(accountAddress);
|
|
84
|
-
const chainConfig = getMPCChainConfig(this.chainName);
|
|
85
75
|
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
86
76
|
accountAddress: checksumAddress,
|
|
87
77
|
walletId,
|
|
88
78
|
chainName: this.chainName,
|
|
89
79
|
thresholdSignatureScheme,
|
|
90
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
91
|
-
index,
|
|
92
|
-
value
|
|
93
|
-
]))),
|
|
94
80
|
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
95
81
|
});
|
|
96
82
|
this.logger.debug('walletMap updated for wallet', {
|
|
@@ -130,25 +116,29 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
130
116
|
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
131
117
|
}
|
|
132
118
|
}
|
|
133
|
-
async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares
|
|
119
|
+
async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares }) {
|
|
120
|
+
await this.verifyPassword({
|
|
121
|
+
accountAddress,
|
|
122
|
+
password,
|
|
123
|
+
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
124
|
+
});
|
|
125
|
+
await this.getWallet({
|
|
126
|
+
accountAddress,
|
|
127
|
+
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
128
|
+
});
|
|
134
129
|
try {
|
|
135
130
|
if (!accountAddress) {
|
|
136
131
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
137
132
|
}
|
|
138
133
|
// Format the message for EVM signing
|
|
139
134
|
const formattedMessage = formatEVMMessage(message);
|
|
140
|
-
const resolvedContext = context != null ? context : {
|
|
141
|
-
evmMessage: message
|
|
142
|
-
};
|
|
143
135
|
// Sign the message using MPC
|
|
144
136
|
const signatureEcdsa = await this.sign({
|
|
145
137
|
message: formattedMessage,
|
|
146
138
|
accountAddress: accountAddress,
|
|
147
139
|
chainName: this.chainName,
|
|
148
140
|
password,
|
|
149
|
-
externalServerKeyShares
|
|
150
|
-
context: resolvedContext,
|
|
151
|
-
onError
|
|
141
|
+
externalServerKeyShares
|
|
152
142
|
});
|
|
153
143
|
// Serialize the signature
|
|
154
144
|
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
@@ -261,24 +251,16 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
261
251
|
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
262
252
|
// update wallet map
|
|
263
253
|
const checksumAddress = getAddress(accountAddress);
|
|
264
|
-
const chainConfig = getMPCChainConfig(this.chainName);
|
|
265
254
|
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
266
255
|
accountAddress: checksumAddress,
|
|
267
256
|
walletId,
|
|
268
257
|
chainName: this.chainName,
|
|
269
258
|
thresholdSignatureScheme,
|
|
270
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
271
|
-
index,
|
|
272
|
-
value
|
|
273
|
-
]))),
|
|
274
259
|
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
275
260
|
});
|
|
276
261
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
277
262
|
},
|
|
278
|
-
onError
|
|
279
|
-
this.logger.error('importPrivateKey: onError', e);
|
|
280
|
-
onError == null ? void 0 : onError(e);
|
|
281
|
-
}
|
|
263
|
+
onError
|
|
282
264
|
});
|
|
283
265
|
// Wait for the ceremony to complete before proceeding
|
|
284
266
|
await ceremonyCompletePromise;
|
|
@@ -316,89 +298,4 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
316
298
|
}
|
|
317
299
|
}
|
|
318
300
|
|
|
319
|
-
|
|
320
|
-
* Creates a delegated EVM wallet client for functional operations
|
|
321
|
-
*/ const createDelegatedEvmWalletClient = ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug = false })=>{
|
|
322
|
-
const baseClient = createDelegatedWalletClient({
|
|
323
|
-
environmentId,
|
|
324
|
-
baseApiUrl,
|
|
325
|
-
baseMPCRelayApiUrl,
|
|
326
|
-
apiKey,
|
|
327
|
-
debug
|
|
328
|
-
});
|
|
329
|
-
const evmClient = _extends({}, baseClient, {
|
|
330
|
-
chainName: 'EVM'
|
|
331
|
-
});
|
|
332
|
-
return evmClient;
|
|
333
|
-
};
|
|
334
|
-
/**
|
|
335
|
-
* Signs a message using delegated signing for EVM
|
|
336
|
-
*/ const delegatedSignMessage = async (client, { walletId, walletApiKey, keyShare, message, context, onError })=>{
|
|
337
|
-
try {
|
|
338
|
-
if (!keyShare || !walletId || !walletApiKey) {
|
|
339
|
-
throw new Error('Delegated key share, wallet ID, and wallet API key are required to sign a message');
|
|
340
|
-
}
|
|
341
|
-
const formattedMessage = formatEVMMessage(message);
|
|
342
|
-
const resolvedContext = context != null ? context : {
|
|
343
|
-
evmMessage: message
|
|
344
|
-
};
|
|
345
|
-
const signatureEcdsa = await delegatedSignMessage$1(client, {
|
|
346
|
-
walletId,
|
|
347
|
-
walletApiKey,
|
|
348
|
-
keyShare,
|
|
349
|
-
message: formattedMessage,
|
|
350
|
-
chainName: client.chainName,
|
|
351
|
-
context: resolvedContext,
|
|
352
|
-
onError
|
|
353
|
-
});
|
|
354
|
-
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
355
|
-
return serializedSignature;
|
|
356
|
-
} catch (error) {
|
|
357
|
-
client.logger.error('Error in delegatedSignMessage', error);
|
|
358
|
-
throw error;
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
/**
|
|
362
|
-
* Signs a transaction using delegated signing for EVM
|
|
363
|
-
*/ const delegatedSignTransaction = async (client, { walletId, walletApiKey, keyShare, transaction })=>{
|
|
364
|
-
try {
|
|
365
|
-
// Serialize the transaction
|
|
366
|
-
const serializedTx = serializeTransaction(transaction);
|
|
367
|
-
const serializedTxBytes = Uint8Array.from(Buffer.from(serializedTx.slice(2), 'hex'));
|
|
368
|
-
if (!(serializedTxBytes instanceof Uint8Array)) {
|
|
369
|
-
throw new Error('Invalid serializedTxBytes');
|
|
370
|
-
}
|
|
371
|
-
// Use the delegated sign message function from node package
|
|
372
|
-
const signatureEcdsa = await delegatedSignMessage$1(client, {
|
|
373
|
-
walletId,
|
|
374
|
-
walletApiKey,
|
|
375
|
-
keyShare,
|
|
376
|
-
message: serializedTxBytes,
|
|
377
|
-
chainName: client.chainName
|
|
378
|
-
});
|
|
379
|
-
if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
|
|
380
|
-
throw new Error('Invalid signature format returned from MPC signing');
|
|
381
|
-
}
|
|
382
|
-
// Construct the signed transaction
|
|
383
|
-
const r = `0x${Buffer.from(signatureEcdsa.r).toString('hex')}`;
|
|
384
|
-
const s = `0x${Buffer.from(signatureEcdsa.s).toString('hex')}`;
|
|
385
|
-
const v = BigInt(signatureEcdsa.v);
|
|
386
|
-
const signedTx = _extends({}, transaction, {
|
|
387
|
-
r: r,
|
|
388
|
-
s: s,
|
|
389
|
-
v: v
|
|
390
|
-
});
|
|
391
|
-
const serializedSignedTx = serializeTransaction(signedTx);
|
|
392
|
-
return serializedSignedTx;
|
|
393
|
-
} catch (error) {
|
|
394
|
-
client.logger.error('Error in delegatedSignTransaction', error);
|
|
395
|
-
throw error;
|
|
396
|
-
}
|
|
397
|
-
};
|
|
398
|
-
/**
|
|
399
|
-
* Revoke delegation - delegates to the node package
|
|
400
|
-
*/ const revokeDelegation = async (client, params)=>{
|
|
401
|
-
return revokeDelegation$1(client, params);
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
export { DynamicEvmWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_VERIFY_MESSAGE_SIGNATURE, EVM_SIGN_MESSAGE_PREFIX, createDelegatedEvmWalletClient, delegatedSignMessage, delegatedSignTransaction, deriveAccountAddress, formatEVMMessage, revokeDelegation, serializeECDSASignature };
|
|
301
|
+
export { DynamicEvmWalletClient };
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-evm",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-pr354.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "0.0.0-
|
|
8
|
-
"@dynamic-labs/sdk-api-core": "^0.0.764"
|
|
7
|
+
"@dynamic-labs-wallet/node": "0.0.0-pr354.0"
|
|
9
8
|
},
|
|
10
9
|
"publishConfig": {
|
|
11
10
|
"access": "public"
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type ServerKeyShare, DynamicWalletClient, type EcdsaKeygenResult, type EcdsaPublicKey, type Ed25519KeygenResult, type ThresholdSignatureScheme, type DynamicWalletClientProps } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import { type PublicClient, type Chain, type SignableMessage, type TransactionSerializable } from 'viem';
|
|
3
|
-
import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
4
3
|
export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
5
4
|
readonly chainName = "EVM";
|
|
6
5
|
constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, debug, }: DynamicWalletClientProps);
|
|
@@ -28,13 +27,11 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
28
27
|
externalServerKeyShares: ServerKeyShare[];
|
|
29
28
|
walletId: string;
|
|
30
29
|
}>;
|
|
31
|
-
signMessage({ message, accountAddress, password, externalServerKeyShares,
|
|
30
|
+
signMessage({ message, accountAddress, password, externalServerKeyShares, }: {
|
|
32
31
|
message: string;
|
|
33
32
|
accountAddress: string;
|
|
34
33
|
password?: string;
|
|
35
34
|
externalServerKeyShares?: ServerKeyShare[];
|
|
36
|
-
context?: SignMessageContext;
|
|
37
|
-
onError?: (error: Error) => void;
|
|
38
35
|
}): Promise<`0x${string}`>;
|
|
39
36
|
verifyMessageSignature({ accountAddress, message, signature, }: {
|
|
40
37
|
accountAddress: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAG9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,KAAK,EA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.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,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
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,mBAAmB,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,7 +1,5 @@
|
|
|
1
1
|
import { type EcdsaSignature, type EcdsaPublicKey } from '@dynamic-labs-wallet/node';
|
|
2
|
-
export declare const formatEVMMessage: (
|
|
3
|
-
raw: string | Uint8Array;
|
|
4
|
-
}) => `0x${string}`;
|
|
2
|
+
export declare const formatEVMMessage: (message: string) => string;
|
|
5
3
|
export declare const serializeECDSASignature: (signature: EcdsaSignature) => `0x${string}`;
|
|
6
4
|
export declare const deriveAccountAddress: ({ rawPublicKey, }: {
|
|
7
5
|
rawPublicKey: EcdsaPublicKey;
|
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":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,gBAAgB,YAAa,MAAM,WAE/C,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,cAAc,kBAMhE,CAAC;AAEF,eAAO,MAAM,oBAAoB,sBAE9B;IACD,YAAY,EAAE,cAAc,CAAC;CAC9B;;;CAQA,CAAC"}
|
package/src/delegatedClient.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { DelegatedWalletClient, ServerKeyShare } from '@dynamic-labs-wallet/node';
|
|
2
|
-
import { type TransactionSerializable } from 'viem';
|
|
3
|
-
import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
4
|
-
export type DelegatedEvmClientConfig = {
|
|
5
|
-
environmentId: string;
|
|
6
|
-
baseApiUrl?: string;
|
|
7
|
-
baseMPCRelayApiUrl?: string;
|
|
8
|
-
apiKey: string;
|
|
9
|
-
debug?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export type DelegatedEvmWalletClient = DelegatedWalletClient & {
|
|
12
|
-
readonly chainName: 'EVM';
|
|
13
|
-
};
|
|
14
|
-
export type CreateDelegatedEvmClientProps = DelegatedEvmClientConfig;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a delegated EVM wallet client for functional operations
|
|
17
|
-
*/
|
|
18
|
-
export declare const createDelegatedEvmWalletClient: ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug, }: CreateDelegatedEvmClientProps) => DelegatedEvmWalletClient;
|
|
19
|
-
/**
|
|
20
|
-
* Signs a message using delegated signing for EVM
|
|
21
|
-
*/
|
|
22
|
-
export declare const delegatedSignMessage: (client: DelegatedEvmWalletClient, { walletId, walletApiKey, keyShare, message, context, onError, }: {
|
|
23
|
-
walletId: string;
|
|
24
|
-
walletApiKey: string;
|
|
25
|
-
keyShare: ServerKeyShare;
|
|
26
|
-
message: string;
|
|
27
|
-
context?: SignMessageContext;
|
|
28
|
-
onError?: (error: Error) => void;
|
|
29
|
-
}) => Promise<string>;
|
|
30
|
-
/**
|
|
31
|
-
* Signs a transaction using delegated signing for EVM
|
|
32
|
-
*/
|
|
33
|
-
export declare const delegatedSignTransaction: (client: DelegatedEvmWalletClient, { walletId, walletApiKey, keyShare, transaction, }: {
|
|
34
|
-
walletId: string;
|
|
35
|
-
walletApiKey: string;
|
|
36
|
-
keyShare: ServerKeyShare;
|
|
37
|
-
transaction: TransactionSerializable;
|
|
38
|
-
}) => Promise<string>;
|
|
39
|
-
/**
|
|
40
|
-
* Revoke delegation - delegates to the node package
|
|
41
|
-
*/
|
|
42
|
-
export declare const revokeDelegation: (client: DelegatedEvmWalletClient, params: any) => Promise<void>;
|
|
43
|
-
//# sourceMappingURL=delegatedClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delegatedClient.d.ts","sourceRoot":"","sources":["../../packages/src/delegatedClient.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,qBAAqB,EAErB,cAAc,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAwB,KAAK,uBAAuB,EAAE,MAAM,MAAM,CAAC;AAE1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,GAAG;IAC7D,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,wBAAwB,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,8BAA8B,sEAMxC,6BAA6B,KAAG,wBAelC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,wBAAwB,oEAQ7B;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAA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