@dynamic-labs-wallet/node-evm 0.0.167 → 0.0.169
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 +107 -4
- package/index.esm.js +106 -7
- package/package.json +3 -2
- package/src/client/client.d.ts +4 -1
- package/src/client/client.d.ts.map +1 -1
- package/src/delegatedClient.d.ts +42 -0
- package/src/delegatedClient.d.ts.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/utils.d.ts +3 -1
- package/src/utils.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -23,8 +23,17 @@ 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
|
-
|
|
26
|
+
const formatEVMMessage = (message_)=>{
|
|
27
|
+
const message = (()=>{
|
|
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
|
+
]);
|
|
28
37
|
};
|
|
29
38
|
const serializeECDSASignature = (signature)=>{
|
|
30
39
|
return viem.serializeSignature({
|
|
@@ -123,20 +132,25 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
123
132
|
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
124
133
|
}
|
|
125
134
|
}
|
|
126
|
-
async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares }) {
|
|
135
|
+
async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares, context, onError }) {
|
|
127
136
|
try {
|
|
128
137
|
if (!accountAddress) {
|
|
129
138
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
130
139
|
}
|
|
131
140
|
// Format the message for EVM signing
|
|
132
141
|
const formattedMessage = formatEVMMessage(message);
|
|
142
|
+
const resolvedContext = context != null ? context : {
|
|
143
|
+
evmMessage: message
|
|
144
|
+
};
|
|
133
145
|
// Sign the message using MPC
|
|
134
146
|
const signatureEcdsa = await this.sign({
|
|
135
147
|
message: formattedMessage,
|
|
136
148
|
accountAddress: accountAddress,
|
|
137
149
|
chainName: this.chainName,
|
|
138
150
|
password,
|
|
139
|
-
externalServerKeyShares
|
|
151
|
+
externalServerKeyShares,
|
|
152
|
+
context: resolvedContext,
|
|
153
|
+
onError
|
|
140
154
|
});
|
|
141
155
|
// Serialize the signature
|
|
142
156
|
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
@@ -304,6 +318,91 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
304
318
|
}
|
|
305
319
|
}
|
|
306
320
|
|
|
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
|
+
|
|
307
406
|
exports.DynamicEvmWalletClient = DynamicEvmWalletClient;
|
|
308
407
|
exports.ERROR_ACCOUNT_ADDRESS_REQUIRED = ERROR_ACCOUNT_ADDRESS_REQUIRED;
|
|
309
408
|
exports.ERROR_CREATE_WALLET_ACCOUNT = ERROR_CREATE_WALLET_ACCOUNT;
|
|
@@ -311,6 +410,10 @@ exports.ERROR_KEYGEN_FAILED = ERROR_KEYGEN_FAILED;
|
|
|
311
410
|
exports.ERROR_SIGN_MESSAGE = ERROR_SIGN_MESSAGE;
|
|
312
411
|
exports.ERROR_VERIFY_MESSAGE_SIGNATURE = ERROR_VERIFY_MESSAGE_SIGNATURE;
|
|
313
412
|
exports.EVM_SIGN_MESSAGE_PREFIX = EVM_SIGN_MESSAGE_PREFIX;
|
|
413
|
+
exports.createDelegatedEvmWalletClient = createDelegatedEvmWalletClient;
|
|
414
|
+
exports.delegatedSignMessage = delegatedSignMessage;
|
|
415
|
+
exports.delegatedSignTransaction = delegatedSignTransaction;
|
|
314
416
|
exports.deriveAccountAddress = deriveAccountAddress;
|
|
315
417
|
exports.formatEVMMessage = formatEVMMessage;
|
|
418
|
+
exports.revokeDelegation = revokeDelegation;
|
|
316
419
|
exports.serializeECDSASignature = serializeECDSASignature;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MessageHash, DynamicWalletClient, getMPCChainConfig, getExternalServerKeyShareBackupInfo, WalletOperation } from '@dynamic-labs-wallet/node';
|
|
2
|
-
import { serializeSignature, getAddress, createPublicClient, http, serializeTransaction } from 'viem';
|
|
1
|
+
import { MessageHash, DynamicWalletClient, getMPCChainConfig, getExternalServerKeyShareBackupInfo, WalletOperation, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, revokeDelegation as revokeDelegation$1 } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import { stringToHex, bytesToHex, size, concat, serializeSignature, getAddress, createPublicClient, http, serializeTransaction } from 'viem';
|
|
3
3
|
import { mainnet } from 'viem/chains';
|
|
4
4
|
|
|
5
5
|
function _extends() {
|
|
@@ -21,8 +21,17 @@ 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
|
-
|
|
24
|
+
const formatEVMMessage = (message_)=>{
|
|
25
|
+
const message = (()=>{
|
|
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
|
+
]);
|
|
26
35
|
};
|
|
27
36
|
const serializeECDSASignature = (signature)=>{
|
|
28
37
|
return serializeSignature({
|
|
@@ -121,20 +130,25 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
121
130
|
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
122
131
|
}
|
|
123
132
|
}
|
|
124
|
-
async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares }) {
|
|
133
|
+
async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares, context, onError }) {
|
|
125
134
|
try {
|
|
126
135
|
if (!accountAddress) {
|
|
127
136
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
128
137
|
}
|
|
129
138
|
// Format the message for EVM signing
|
|
130
139
|
const formattedMessage = formatEVMMessage(message);
|
|
140
|
+
const resolvedContext = context != null ? context : {
|
|
141
|
+
evmMessage: message
|
|
142
|
+
};
|
|
131
143
|
// Sign the message using MPC
|
|
132
144
|
const signatureEcdsa = await this.sign({
|
|
133
145
|
message: formattedMessage,
|
|
134
146
|
accountAddress: accountAddress,
|
|
135
147
|
chainName: this.chainName,
|
|
136
148
|
password,
|
|
137
|
-
externalServerKeyShares
|
|
149
|
+
externalServerKeyShares,
|
|
150
|
+
context: resolvedContext,
|
|
151
|
+
onError
|
|
138
152
|
});
|
|
139
153
|
// Serialize the signature
|
|
140
154
|
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
@@ -302,4 +316,89 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
302
316
|
}
|
|
303
317
|
}
|
|
304
318
|
|
|
305
|
-
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-evm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.169",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "0.0.
|
|
7
|
+
"@dynamic-labs-wallet/node": "0.0.169",
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "^0.0.764"
|
|
8
9
|
},
|
|
9
10
|
"publishConfig": {
|
|
10
11
|
"access": "public"
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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';
|
|
3
4
|
export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
4
5
|
readonly chainName = "EVM";
|
|
5
6
|
constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, debug, }: DynamicWalletClientProps);
|
|
@@ -27,11 +28,13 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
27
28
|
externalServerKeyShares: ServerKeyShare[];
|
|
28
29
|
walletId: string;
|
|
29
30
|
}>;
|
|
30
|
-
signMessage({ message, accountAddress, password, externalServerKeyShares, }: {
|
|
31
|
+
signMessage({ message, accountAddress, password, externalServerKeyShares, context, onError, }: {
|
|
31
32
|
message: string;
|
|
32
33
|
accountAddress: string;
|
|
33
34
|
password?: string;
|
|
34
35
|
externalServerKeyShares?: ServerKeyShare[];
|
|
36
|
+
context?: SignMessageContext;
|
|
37
|
+
onError?: (error: Error) => void;
|
|
35
38
|
}): Promise<`0x${string}`>;
|
|
36
39
|
verifyMessageSignature({ accountAddress, message, signature, }: {
|
|
37
40
|
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,EAI9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,KAAK,EAEV,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE7B,MAAM,MAAM,CAAC;
|
|
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,EAI9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,KAAK,EAEV,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE7B,MAAM,MAAM,CAAC;AAcd,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,KAAK,GACN,EAAE,wBAAwB;IAS3B,sBAAsB,CAAC,EACrB,KAAK,EACL,MAAM,GACP,EAAE;QACD,KAAK,EAAE,KAAK,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,YAAY;IAOhB;;;;;;;OAOG;IAEG,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,OAAO,EACP,0BAAkC,GACnC,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,QAAoB,EACpB,uBAAuB,GACxB,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;KAC5C;;;IAgBK,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;;;IASD;;;;;;;;;OASG;IACG,gBAAgB,CAAC,EACrB,UAAU,EACV,SAAS,EACT,wBAAwB,EACxB,QAAoB,EACpB,0BAAkC,EAClC,OAAO,GACR,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,0BAA0B,CAAC,EAAE,OAAO,CAAC;QACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KAClC,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;QAC/D,uBAAuB,EAAE,cAAc,EAAE,CAAC;KAC3C,CAAC;IA8DI,aAAa;CAOpB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* Creates a delegated EVM wallet client for functional operations
|
|
16
|
+
*/
|
|
17
|
+
export declare const createDelegatedEvmWalletClient: ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug, }: DelegatedEvmClientConfig) => DelegatedEvmWalletClient;
|
|
18
|
+
/**
|
|
19
|
+
* Signs a message using delegated signing for EVM
|
|
20
|
+
*/
|
|
21
|
+
export declare const delegatedSignMessage: (client: DelegatedEvmWalletClient, { walletId, walletApiKey, keyShare, message, context, onError, }: {
|
|
22
|
+
walletId: string;
|
|
23
|
+
walletApiKey: string;
|
|
24
|
+
keyShare: ServerKeyShare;
|
|
25
|
+
message: string;
|
|
26
|
+
context?: SignMessageContext;
|
|
27
|
+
onError?: (error: Error) => void;
|
|
28
|
+
}) => Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Signs a transaction using delegated signing for EVM
|
|
31
|
+
*/
|
|
32
|
+
export declare const delegatedSignTransaction: (client: DelegatedEvmWalletClient, { walletId, walletApiKey, keyShare, transaction, }: {
|
|
33
|
+
walletId: string;
|
|
34
|
+
walletApiKey: string;
|
|
35
|
+
keyShare: ServerKeyShare;
|
|
36
|
+
transaction: TransactionSerializable;
|
|
37
|
+
}) => Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Revoke delegation - delegates to the node package
|
|
40
|
+
*/
|
|
41
|
+
export declare const revokeDelegation: (client: DelegatedEvmWalletClient, params: any) => Promise<void>;
|
|
42
|
+
//# sourceMappingURL=delegatedClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegatedClient.d.ts","sourceRoot":"","sources":["../../packages/src/delegatedClient.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,qBAAqB,EAErB,cAAc,EACf,MAAM,2B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
|
|
|
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;AAClC,cAAc,sBAAsB,CAAC"}
|
package/src/utils.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type EcdsaSignature, type EcdsaPublicKey } from '@dynamic-labs-wallet/node';
|
|
2
|
-
export declare const formatEVMMessage: (
|
|
2
|
+
export declare const formatEVMMessage: (message_: string | {
|
|
3
|
+
raw: string | Uint8Array;
|
|
4
|
+
}) => `0x${string}`;
|
|
3
5
|
export declare const serializeECDSASignature: (signature: EcdsaSignature) => `0x${string}`;
|
|
4
6
|
export declare const deriveAccountAddress: ({ rawPublicKey, }: {
|
|
5
7
|
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":"AAQA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAC;AAGnC,eAAO,MAAM,gBAAgB,aACjB,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,kBAShD,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,cAAc,kBAMhE,CAAC;AAEF,eAAO,MAAM,oBAAoB,sBAE9B;IACD,YAAY,EAAE,cAAc,CAAC;CAC9B;;;CAQA,CAAC"}
|