@dynamic-labs-wallet/evm 1.1.39 → 1.1.41

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 CHANGED
@@ -508,7 +508,7 @@ const parseLimits = (limits)=>({
508
508
  maxPriorityFeePerGas: parseLimit(limits.maxPriorityFeePerGas, 'maxPriorityFeePerGas'),
509
509
  maxTotalFee: parseLimit(limits.maxTotalFee, 'maxTotalFee')
510
510
  });
511
- const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, refreshLimits })=>{
511
+ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, refreshLimits, refreshableNonce = false })=>{
512
512
  var _parsed_accessList;
513
513
  const parsed = viem.parseTransaction(transaction);
514
514
  var _parsed_accessList_length;
@@ -536,7 +536,7 @@ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, re
536
536
  throw new Error('Transaction exceeds signing intent limits');
537
537
  }
538
538
  var _parsed_value, _parsed_data;
539
- return {
539
+ const prepared = {
540
540
  operation: {
541
541
  kind: 'transaction',
542
542
  chainName: 'EVM',
@@ -549,6 +549,10 @@ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, re
549
549
  },
550
550
  limits
551
551
  };
552
+ if (refreshableNonce) prepared.lifetime = {
553
+ refreshable: 'nonce'
554
+ };
555
+ return prepared;
552
556
  };
553
557
  const safeNumber = (value, name)=>{
554
558
  const parsed = parseLimit(value, name);
@@ -593,11 +597,19 @@ const safeNumber = (value, name)=>{
593
597
  };
594
598
  /**
595
599
  * Reconstructs an unsigned EIP-1559 transaction from an approved intent.
596
- * Only gas and fee values may change, within the approved limits.
597
- */ const resumeEvmTransactionSigningIntent = ({ intent })=>{
600
+ * Only gas and fee values may change, within the approved limits, plus the
601
+ * nonce when the intent signed a refreshable nonce. That nonce (`lifetimeValue`,
602
+ * decimal) is optional: without it, the nonce from the signed operation is used.
603
+ */ const resumeEvmTransactionSigningIntent = ({ intent, lifetimeValue })=>{
604
+ var _intent_lifetime;
598
605
  if (intent.operation.kind !== 'transaction' || intent.operation.chainName !== 'EVM' || !intent.limits) {
599
606
  throw new Error('Stored signing intent is not an EVM transaction');
600
607
  }
608
+ const refreshableNonce = ((_intent_lifetime = intent.lifetime) == null ? void 0 : _intent_lifetime.refreshable) === 'nonce';
609
+ if (lifetimeValue !== undefined && !refreshableNonce) {
610
+ throw new Error('A nonce can be supplied only when the EVM transaction intent has a refreshable nonce');
611
+ }
612
+ const nonce = lifetimeValue != null ? lifetimeValue : intent.operation.nonce;
601
613
  const { operation, limits } = intent;
602
614
  const parsedLimits = parseLimits(limits);
603
615
  if (parsedLimits.maxGas === 0n || parsedLimits.maxFeePerGas === 0n) {
@@ -617,7 +629,7 @@ const safeNumber = (value, name)=>{
617
629
  gas,
618
630
  maxFeePerGas,
619
631
  maxPriorityFeePerGas,
620
- nonce: safeNumber(operation.nonce, 'nonce'),
632
+ nonce: safeNumber(nonce, 'nonce'),
621
633
  to: operation.to ? viem.getAddress(operation.to) : undefined,
622
634
  type: 'eip1559',
623
635
  value: parseLimit(operation.value, 'value')
@@ -627,7 +639,7 @@ const safeNumber = (value, name)=>{
627
639
  refreshLimits: limits,
628
640
  transaction
629
641
  });
630
- 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) {
642
+ 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 !== nonce) {
631
643
  throw new Error('Stored EVM transaction intent is malformed');
632
644
  }
633
645
  return transaction;
package/index.esm.js CHANGED
@@ -506,7 +506,7 @@ const parseLimits = (limits)=>({
506
506
  maxPriorityFeePerGas: parseLimit(limits.maxPriorityFeePerGas, 'maxPriorityFeePerGas'),
507
507
  maxTotalFee: parseLimit(limits.maxTotalFee, 'maxTotalFee')
508
508
  });
509
- const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, refreshLimits })=>{
509
+ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, refreshLimits, refreshableNonce = false })=>{
510
510
  var _parsed_accessList;
511
511
  const parsed = parseTransaction(transaction);
512
512
  var _parsed_accessList_length;
@@ -534,7 +534,7 @@ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, re
534
534
  throw new Error('Transaction exceeds signing intent limits');
535
535
  }
536
536
  var _parsed_value, _parsed_data;
537
- return {
537
+ const prepared = {
538
538
  operation: {
539
539
  kind: 'transaction',
540
540
  chainName: 'EVM',
@@ -547,6 +547,10 @@ const prepareEvmTransactionSigningOperation = ({ transaction, accountAddress, re
547
547
  },
548
548
  limits
549
549
  };
550
+ if (refreshableNonce) prepared.lifetime = {
551
+ refreshable: 'nonce'
552
+ };
553
+ return prepared;
550
554
  };
551
555
  const safeNumber = (value, name)=>{
552
556
  const parsed = parseLimit(value, name);
@@ -591,11 +595,19 @@ const safeNumber = (value, name)=>{
591
595
  };
592
596
  /**
593
597
  * Reconstructs an unsigned EIP-1559 transaction from an approved intent.
594
- * Only gas and fee values may change, within the approved limits.
595
- */ const resumeEvmTransactionSigningIntent = ({ intent })=>{
598
+ * Only gas and fee values may change, within the approved limits, plus the
599
+ * nonce when the intent signed a refreshable nonce. That nonce (`lifetimeValue`,
600
+ * decimal) is optional: without it, the nonce from the signed operation is used.
601
+ */ const resumeEvmTransactionSigningIntent = ({ intent, lifetimeValue })=>{
602
+ var _intent_lifetime;
596
603
  if (intent.operation.kind !== 'transaction' || intent.operation.chainName !== 'EVM' || !intent.limits) {
597
604
  throw new Error('Stored signing intent is not an EVM transaction');
598
605
  }
606
+ const refreshableNonce = ((_intent_lifetime = intent.lifetime) == null ? void 0 : _intent_lifetime.refreshable) === 'nonce';
607
+ if (lifetimeValue !== undefined && !refreshableNonce) {
608
+ throw new Error('A nonce can be supplied only when the EVM transaction intent has a refreshable nonce');
609
+ }
610
+ const nonce = lifetimeValue != null ? lifetimeValue : intent.operation.nonce;
599
611
  const { operation, limits } = intent;
600
612
  const parsedLimits = parseLimits(limits);
601
613
  if (parsedLimits.maxGas === 0n || parsedLimits.maxFeePerGas === 0n) {
@@ -615,7 +627,7 @@ const safeNumber = (value, name)=>{
615
627
  gas,
616
628
  maxFeePerGas,
617
629
  maxPriorityFeePerGas,
618
- nonce: safeNumber(operation.nonce, 'nonce'),
630
+ nonce: safeNumber(nonce, 'nonce'),
619
631
  to: operation.to ? getAddress(operation.to) : undefined,
620
632
  type: 'eip1559',
621
633
  value: parseLimit(operation.value, 'value')
@@ -625,7 +637,7 @@ const safeNumber = (value, name)=>{
625
637
  refreshLimits: limits,
626
638
  transaction
627
639
  });
628
- 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) {
640
+ 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 !== nonce) {
629
641
  throw new Error('Stored EVM transaction intent is malformed');
630
642
  }
631
643
  return transaction;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/evm",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/browser": "1.1.39",
8
- "@dynamic-labs-wallet/core": "1.1.39",
7
+ "@dynamic-labs-wallet/browser": "1.1.41",
8
+ "@dynamic-labs-wallet/core": "1.1.41",
9
9
  "@dynamic-labs/sdk-api-core": "0.50.0"
10
10
  },
11
11
  "peerDependencies": {
@@ -1,12 +1,11 @@
1
- import type { EvmSigningIntentLimits, PreparedTransactionSigningIntent, SigningIntent } from '@dynamic-labs-wallet/core';
2
- export declare const prepareEvmTransactionSigningOperation: ({ transaction, accountAddress, refreshLimits, }: {
1
+ import type { Eip7702AuthOperation, EvmSigningIntentLimits, PreparedEvmTransactionSigningIntent, SigningIntent } from '@dynamic-labs-wallet/core';
2
+ export declare const prepareEvmTransactionSigningOperation: ({ transaction, accountAddress, refreshLimits, refreshableNonce, }: {
3
3
  transaction: string;
4
4
  accountAddress: string;
5
5
  refreshLimits?: EvmSigningIntentLimits;
6
- }) => PreparedTransactionSigningIntent;
7
- type Eip7702AuthOperation = Extract<SigningIntent['operation'], {
8
- kind: 'eip7702Auth';
9
- }>;
6
+ /** Explicit opt-in to sign a refreshable nonce. Absent by default, which keeps the nonce pinned. */
7
+ refreshableNonce?: boolean;
8
+ }) => PreparedEvmTransactionSigningIntent;
10
9
  type Eip7702Auth = Eip7702AuthOperation['eip7702Auth'];
11
10
  /**
12
11
  * Builds the intent operation for an EIP-7702 authorization; `payload` is the hash the wallet signs.
@@ -23,10 +22,13 @@ export declare const eip7702AuthorizationFromOperation: ({ operation }: {
23
22
  }) => Eip7702Auth;
24
23
  /**
25
24
  * Reconstructs an unsigned EIP-1559 transaction from an approved intent.
26
- * Only gas and fee values may change, within the approved limits.
25
+ * Only gas and fee values may change, within the approved limits, plus the
26
+ * nonce when the intent signed a refreshable nonce. That nonce (`lifetimeValue`,
27
+ * decimal) is optional: without it, the nonce from the signed operation is used.
27
28
  */
28
- export declare const resumeEvmTransactionSigningIntent: ({ intent }: {
29
+ export declare const resumeEvmTransactionSigningIntent: ({ intent, lifetimeValue, }: {
29
30
  intent: SigningIntent;
31
+ lifetimeValue?: string;
30
32
  }) => string;
31
33
  export {};
32
34
  //# 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,EACV,sBAAsB,EACtB,gCAAgC,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