@dynamic-labs-wallet/evm 1.1.21 → 1.1.22
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 +55 -6
- package/index.esm.js +54 -7
- package/package.json +3 -3
- package/src/index.d.ts +2 -1
- package/src/index.d.ts.map +1 -1
- package/src/signingIntent.d.ts +8 -1
- package/src/signingIntent.d.ts.map +1 -1
- package/src/utils.d.ts +1 -0
- package/src/utils.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -63,13 +63,14 @@ const formatTypedData = (typedData)=>{
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
+
const serializeEcdsaSignature = (signature)=>viem.serializeSignature({
|
|
67
|
+
r: `0x${Buffer.from(signature.r).toString('hex')}`,
|
|
68
|
+
s: `0x${Buffer.from(signature.s).toString('hex')}`,
|
|
69
|
+
v: BigInt(signature.v)
|
|
70
|
+
});
|
|
66
71
|
const serializeECDSASignature = (signature, logger)=>{
|
|
67
72
|
try {
|
|
68
|
-
return
|
|
69
|
-
r: `0x${Buffer.from(signature.r).toString('hex')}`,
|
|
70
|
-
s: `0x${Buffer.from(signature.s).toString('hex')}`,
|
|
71
|
-
v: BigInt(signature.v)
|
|
72
|
-
});
|
|
73
|
+
return serializeEcdsaSignature(signature);
|
|
73
74
|
} catch (error) {
|
|
74
75
|
logger.error('[DynamicWaasWalletClient]: Error serializing ECDSA signature:', error);
|
|
75
76
|
throw error;
|
|
@@ -478,7 +479,7 @@ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, re
|
|
|
478
479
|
maxTotalFee: decimal(gas * maxFeePerGas)
|
|
479
480
|
};
|
|
480
481
|
const parsedLimits = parseLimits(limits);
|
|
481
|
-
if (parsedLimits.maxGas < gas || parsedLimits.maxFeePerGas < maxFeePerGas || parsedLimits.maxPriorityFeePerGas < maxPriorityFeePerGas || parsedLimits.maxPriorityFeePerGas > parsedLimits.maxFeePerGas ||
|
|
482
|
+
if (parsedLimits.maxGas < gas || parsedLimits.maxFeePerGas < maxFeePerGas || parsedLimits.maxPriorityFeePerGas < maxPriorityFeePerGas || parsedLimits.maxPriorityFeePerGas > parsedLimits.maxFeePerGas || gas * maxFeePerGas > parsedLimits.maxTotalFee) {
|
|
482
483
|
throw new Error('Transaction exceeds signing intent limits');
|
|
483
484
|
}
|
|
484
485
|
var _parsed_value, _parsed_data;
|
|
@@ -496,6 +497,54 @@ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, re
|
|
|
496
497
|
limits
|
|
497
498
|
};
|
|
498
499
|
};
|
|
500
|
+
const safeNumber = (value, name)=>{
|
|
501
|
+
const parsed = parseLimit(value, name);
|
|
502
|
+
if (parsed > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error(`Invalid ${name} signing value`);
|
|
503
|
+
return Number(parsed);
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Reconstructs an unsigned EIP-1559 transaction from an approved intent.
|
|
507
|
+
* Only gas and fee values may change, within the approved limits.
|
|
508
|
+
*/ const resumeEvmTransactionSigningIntent = ({ intent })=>{
|
|
509
|
+
if (intent.operation.kind !== 'transaction' || intent.operation.chainName !== 'EVM' || !intent.limits) {
|
|
510
|
+
throw new Error('Stored signing intent is not an EVM transaction');
|
|
511
|
+
}
|
|
512
|
+
const { operation, limits } = intent;
|
|
513
|
+
const parsedLimits = parseLimits(limits);
|
|
514
|
+
if (parsedLimits.maxGas === 0n || parsedLimits.maxFeePerGas === 0n) {
|
|
515
|
+
throw new Error('Stored EVM transaction intent has unusable fee limits');
|
|
516
|
+
}
|
|
517
|
+
const gas = parsedLimits.maxGas;
|
|
518
|
+
// The signed total-fee ceiling can be tighter than the independent gas and
|
|
519
|
+
// fee ceilings, so derive the largest fee cap that satisfies all three.
|
|
520
|
+
const maxFeePerGas = parsedLimits.maxTotalFee / gas < parsedLimits.maxFeePerGas ? parsedLimits.maxTotalFee / gas : parsedLimits.maxFeePerGas;
|
|
521
|
+
if (maxFeePerGas === 0n) {
|
|
522
|
+
throw new Error('Stored EVM transaction intent has unusable fee limits');
|
|
523
|
+
}
|
|
524
|
+
const maxPriorityFeePerGas = parsedLimits.maxPriorityFeePerGas < maxFeePerGas ? parsedLimits.maxPriorityFeePerGas : maxFeePerGas;
|
|
525
|
+
const transaction = viem.serializeTransaction({
|
|
526
|
+
chainId: safeNumber(operation.chainId, 'chainId'),
|
|
527
|
+
data: operation.data,
|
|
528
|
+
gas,
|
|
529
|
+
maxFeePerGas,
|
|
530
|
+
maxPriorityFeePerGas,
|
|
531
|
+
nonce: safeNumber(operation.nonce, 'nonce'),
|
|
532
|
+
to: operation.to ? viem.getAddress(operation.to) : undefined,
|
|
533
|
+
type: 'eip1559',
|
|
534
|
+
value: parseLimit(operation.value, 'value')
|
|
535
|
+
});
|
|
536
|
+
const reconstructed = prepareEvmTransactionSigningOperation({
|
|
537
|
+
accountAddress: intent.accountAddress,
|
|
538
|
+
refreshLimits: limits,
|
|
539
|
+
transaction
|
|
540
|
+
});
|
|
541
|
+
if (reconstructed.operation.chainId !== operation.chainId || reconstructed.operation.from !== operation.from || reconstructed.operation.to !== operation.to || reconstructed.operation.value !== operation.value || reconstructed.operation.data !== operation.data || reconstructed.operation.nonce !== operation.nonce) {
|
|
542
|
+
throw new Error('Stored EVM transaction intent is malformed');
|
|
543
|
+
}
|
|
544
|
+
return transaction;
|
|
545
|
+
};
|
|
499
546
|
|
|
500
547
|
exports.DynamicEvmWalletClient = DynamicEvmWalletClient;
|
|
501
548
|
exports.prepareEvmTransactionSigningOperation = prepareEvmTransactionSigningOperation;
|
|
549
|
+
exports.resumeEvmTransactionSigningIntent = resumeEvmTransactionSigningIntent;
|
|
550
|
+
exports.serializeEcdsaSignature = serializeEcdsaSignature;
|
package/index.esm.js
CHANGED
|
@@ -61,13 +61,14 @@ const formatTypedData = (typedData)=>{
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
const serializeEcdsaSignature = (signature)=>serializeSignature({
|
|
65
|
+
r: `0x${Buffer.from(signature.r).toString('hex')}`,
|
|
66
|
+
s: `0x${Buffer.from(signature.s).toString('hex')}`,
|
|
67
|
+
v: BigInt(signature.v)
|
|
68
|
+
});
|
|
64
69
|
const serializeECDSASignature = (signature, logger)=>{
|
|
65
70
|
try {
|
|
66
|
-
return
|
|
67
|
-
r: `0x${Buffer.from(signature.r).toString('hex')}`,
|
|
68
|
-
s: `0x${Buffer.from(signature.s).toString('hex')}`,
|
|
69
|
-
v: BigInt(signature.v)
|
|
70
|
-
});
|
|
71
|
+
return serializeEcdsaSignature(signature);
|
|
71
72
|
} catch (error) {
|
|
72
73
|
logger.error('[DynamicWaasWalletClient]: Error serializing ECDSA signature:', error);
|
|
73
74
|
throw error;
|
|
@@ -476,7 +477,7 @@ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, re
|
|
|
476
477
|
maxTotalFee: decimal(gas * maxFeePerGas)
|
|
477
478
|
};
|
|
478
479
|
const parsedLimits = parseLimits(limits);
|
|
479
|
-
if (parsedLimits.maxGas < gas || parsedLimits.maxFeePerGas < maxFeePerGas || parsedLimits.maxPriorityFeePerGas < maxPriorityFeePerGas || parsedLimits.maxPriorityFeePerGas > parsedLimits.maxFeePerGas ||
|
|
480
|
+
if (parsedLimits.maxGas < gas || parsedLimits.maxFeePerGas < maxFeePerGas || parsedLimits.maxPriorityFeePerGas < maxPriorityFeePerGas || parsedLimits.maxPriorityFeePerGas > parsedLimits.maxFeePerGas || gas * maxFeePerGas > parsedLimits.maxTotalFee) {
|
|
480
481
|
throw new Error('Transaction exceeds signing intent limits');
|
|
481
482
|
}
|
|
482
483
|
var _parsed_value, _parsed_data;
|
|
@@ -494,5 +495,51 @@ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, re
|
|
|
494
495
|
limits
|
|
495
496
|
};
|
|
496
497
|
};
|
|
498
|
+
const safeNumber = (value, name)=>{
|
|
499
|
+
const parsed = parseLimit(value, name);
|
|
500
|
+
if (parsed > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error(`Invalid ${name} signing value`);
|
|
501
|
+
return Number(parsed);
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Reconstructs an unsigned EIP-1559 transaction from an approved intent.
|
|
505
|
+
* Only gas and fee values may change, within the approved limits.
|
|
506
|
+
*/ const resumeEvmTransactionSigningIntent = ({ intent })=>{
|
|
507
|
+
if (intent.operation.kind !== 'transaction' || intent.operation.chainName !== 'EVM' || !intent.limits) {
|
|
508
|
+
throw new Error('Stored signing intent is not an EVM transaction');
|
|
509
|
+
}
|
|
510
|
+
const { operation, limits } = intent;
|
|
511
|
+
const parsedLimits = parseLimits(limits);
|
|
512
|
+
if (parsedLimits.maxGas === 0n || parsedLimits.maxFeePerGas === 0n) {
|
|
513
|
+
throw new Error('Stored EVM transaction intent has unusable fee limits');
|
|
514
|
+
}
|
|
515
|
+
const gas = parsedLimits.maxGas;
|
|
516
|
+
// The signed total-fee ceiling can be tighter than the independent gas and
|
|
517
|
+
// fee ceilings, so derive the largest fee cap that satisfies all three.
|
|
518
|
+
const maxFeePerGas = parsedLimits.maxTotalFee / gas < parsedLimits.maxFeePerGas ? parsedLimits.maxTotalFee / gas : parsedLimits.maxFeePerGas;
|
|
519
|
+
if (maxFeePerGas === 0n) {
|
|
520
|
+
throw new Error('Stored EVM transaction intent has unusable fee limits');
|
|
521
|
+
}
|
|
522
|
+
const maxPriorityFeePerGas = parsedLimits.maxPriorityFeePerGas < maxFeePerGas ? parsedLimits.maxPriorityFeePerGas : maxFeePerGas;
|
|
523
|
+
const transaction = serializeTransaction({
|
|
524
|
+
chainId: safeNumber(operation.chainId, 'chainId'),
|
|
525
|
+
data: operation.data,
|
|
526
|
+
gas,
|
|
527
|
+
maxFeePerGas,
|
|
528
|
+
maxPriorityFeePerGas,
|
|
529
|
+
nonce: safeNumber(operation.nonce, 'nonce'),
|
|
530
|
+
to: operation.to ? getAddress(operation.to) : undefined,
|
|
531
|
+
type: 'eip1559',
|
|
532
|
+
value: parseLimit(operation.value, 'value')
|
|
533
|
+
});
|
|
534
|
+
const reconstructed = prepareEvmTransactionSigningOperation({
|
|
535
|
+
accountAddress: intent.accountAddress,
|
|
536
|
+
refreshLimits: limits,
|
|
537
|
+
transaction
|
|
538
|
+
});
|
|
539
|
+
if (reconstructed.operation.chainId !== operation.chainId || reconstructed.operation.from !== operation.from || reconstructed.operation.to !== operation.to || reconstructed.operation.value !== operation.value || reconstructed.operation.data !== operation.data || reconstructed.operation.nonce !== operation.nonce) {
|
|
540
|
+
throw new Error('Stored EVM transaction intent is malformed');
|
|
541
|
+
}
|
|
542
|
+
return transaction;
|
|
543
|
+
};
|
|
497
544
|
|
|
498
|
-
export { DynamicEvmWalletClient, prepareEvmTransactionSigningOperation };
|
|
545
|
+
export { DynamicEvmWalletClient, prepareEvmTransactionSigningOperation, resumeEvmTransactionSigningIntent, serializeEcdsaSignature };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/evm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/browser": "1.1.
|
|
8
|
-
"@dynamic-labs-wallet/core": "1.1.
|
|
7
|
+
"@dynamic-labs-wallet/browser": "1.1.22",
|
|
8
|
+
"@dynamic-labs-wallet/core": "1.1.22",
|
|
9
9
|
"@dynamic-labs/sdk-api-core": "0.50.0"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
|
-
export { prepareEvmTransactionSigningOperation } from './signingIntent.js';
|
|
2
|
+
export { prepareEvmTransactionSigningOperation, resumeEvmTransactionSigningIntent } from './signingIntent.js';
|
|
3
|
+
export { serializeEcdsaSignature } from './utils.js';
|
|
3
4
|
//# 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,mBAAmB,CAAC;AAClC,OAAO,EAAE,qCAAqC,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,qCAAqC,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
package/src/signingIntent.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import type { EvmSigningIntentLimits, PreparedTransactionSigningIntent } from '@dynamic-labs-wallet/core';
|
|
1
|
+
import type { EvmSigningIntentLimits, PreparedTransactionSigningIntent, SigningIntent } from '@dynamic-labs-wallet/core';
|
|
2
2
|
export declare const prepareEvmTransactionSigningOperation: ({ transaction, accountAddress, refreshLimits, }: {
|
|
3
3
|
transaction: string;
|
|
4
4
|
accountAddress: string;
|
|
5
5
|
refreshLimits?: EvmSigningIntentLimits;
|
|
6
6
|
}) => PreparedTransactionSigningIntent;
|
|
7
|
+
/**
|
|
8
|
+
* Reconstructs an unsigned EIP-1559 transaction from an approved intent.
|
|
9
|
+
* Only gas and fee values may change, within the approved limits.
|
|
10
|
+
*/
|
|
11
|
+
export declare const resumeEvmTransactionSigningIntent: ({ intent }: {
|
|
12
|
+
intent: SigningIntent;
|
|
13
|
+
}) => string;
|
|
7
14
|
//# sourceMappingURL=signingIntent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signingIntent.d.ts","sourceRoot":"","sources":["../../packages/src/signingIntent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"signingIntent.d.ts","sourceRoot":"","sources":["../../packages/src/signingIntent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,gCAAgC,EAChC,aAAa,EACd,MAAM,2BAA2B,CAAC;AAiBnC,eAAO,MAAM,qCAAqC,oDAI/C;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,sBAAsB,CAAC;CACxC,KAAG,gCAmDH,CAAC;AAQF;;;GAGG;AACH,eAAO,MAAM,iCAAiC,eAAgB;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,KAAG,MAmDzF,CAAC"}
|
package/src/utils.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export declare const formatEVMMessage: (message_: string | {
|
|
|
7
7
|
export declare const formatTypedData: (typedData: TypedData | {
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
}) => string;
|
|
10
|
+
export declare const serializeEcdsaSignature: (signature: EcdsaSignature) => `0x${string}`;
|
|
10
11
|
export declare const serializeECDSASignature: (signature: EcdsaSignature, logger: ILogger) => `0x${string}`;
|
|
11
12
|
//# 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":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAA2B,SAAS,EAAE,MAAM,MAAM,CAAC;AAI/D,eAAO,MAAM,gBAAgB,aAAc,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,UAAU,OAAO,kBAahG,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,WA6BhF,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,cAAc,UAAU,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAA2B,SAAS,EAAE,MAAM,MAAM,CAAC;AAI/D,eAAO,MAAM,gBAAgB,aAAc,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,UAAU,OAAO,kBAahG,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,WA6BhF,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,cAAc,kBAK7D,CAAC;AAEL,eAAO,MAAM,uBAAuB,cAAe,cAAc,UAAU,OAAO,kBAOjF,CAAC"}
|