permissionless 0.1.39 → 0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # permissionless
2
2
 
3
+ ## 0.1.41
4
+
5
+ ### Patch Changes
6
+
7
+ - 299513dfee5054a3d59591f4bf11cb145783988d: Added decodeNonce util function
8
+
9
+ ## 0.1.40
10
+
11
+ ### Patch Changes
12
+
13
+ - be1c3dede45bdfbffe168735cbd48fd967684818: Added encodeNonce util function
14
+
3
15
  ## 0.1.39
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeNonce = void 0;
4
+ const viem_1 = require("viem");
5
+ function decodeNonce(nonce) {
6
+ const parsedNonce = BigInt((0, viem_1.toHex)(nonce, { size: 32 }));
7
+ const key = parsedNonce >> BigInt(64);
8
+ const sequence = parsedNonce & BigInt("0xFFFFFFFFFFFFFFFF");
9
+ return { key, sequence };
10
+ }
11
+ exports.decodeNonce = decodeNonce;
12
+ //# sourceMappingURL=decodeNonce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decodeNonce.js","sourceRoot":"","sources":["../../utils/decodeNonce.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAE5B,SAAgB,WAAW,CAAC,KAAa;IACrC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAA,YAAK,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAEtD,MAAM,GAAG,GAAG,WAAW,IAAI,MAAM,CAAC,EAAE,CAAC,CAAA;IACrC,MAAM,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAE3D,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAA;AAC5B,CAAC;AAPD,kCAOC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeNonce = void 0;
4
+ const viem_1 = require("viem");
5
+ function encodeNonce(args) {
6
+ const key = BigInt((0, viem_1.toHex)(args.key, { size: 24 }));
7
+ const sequence = BigInt((0, viem_1.toHex)(args.sequence, { size: 8 }));
8
+ return (key << BigInt(64)) + sequence;
9
+ }
10
+ exports.encodeNonce = encodeNonce;
11
+ //# sourceMappingURL=encodeNonce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeNonce.js","sourceRoot":"","sources":["../../utils/encodeNonce.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAE5B,SAAgB,WAAW,CAAC,IAAuC;IAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAA,YAAK,EAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAA,YAAK,EAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAE1D,OAAO,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAA;AACzC,CAAC;AALD,kCAKC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ENTRYPOINT_ADDRESS_V07 = exports.ENTRYPOINT_ADDRESS_V06 = exports.getEntryPointVersion = exports.getPackedUserOperation = exports.getAddressFromInitCodeOrPaymasterAndData = exports.providerToSmartAccountSigner = exports.isSmartAccountDeployed = exports.AccountOrClientNotFoundError = exports.signUserOperationHashWithECDSA = exports.walletClientToSmartAccountSigner = exports.getRequiredPrefund = exports.getUserOperationHash = exports.deepHexlify = exports.transactionReceiptStatus = exports.parseAccount = void 0;
3
+ exports.ENTRYPOINT_ADDRESS_V07 = exports.ENTRYPOINT_ADDRESS_V06 = exports.decodeNonce = exports.encodeNonce = exports.getEntryPointVersion = exports.getPackedUserOperation = exports.getAddressFromInitCodeOrPaymasterAndData = exports.providerToSmartAccountSigner = exports.isSmartAccountDeployed = exports.AccountOrClientNotFoundError = exports.signUserOperationHashWithECDSA = exports.walletClientToSmartAccountSigner = exports.getRequiredPrefund = exports.getUserOperationHash = exports.deepHexlify = exports.transactionReceiptStatus = exports.parseAccount = void 0;
4
4
  const deepHexlify_1 = require("./deepHexlify.js");
5
5
  Object.defineProperty(exports, "deepHexlify", { enumerable: true, get: function () { return deepHexlify_1.deepHexlify; } });
6
6
  Object.defineProperty(exports, "transactionReceiptStatus", { enumerable: true, get: function () { return deepHexlify_1.transactionReceiptStatus; } });
@@ -25,6 +25,10 @@ function parseAccount(account) {
25
25
  return account;
26
26
  }
27
27
  exports.parseAccount = parseAccount;
28
+ const decodeNonce_1 = require("./decodeNonce.js");
29
+ Object.defineProperty(exports, "decodeNonce", { enumerable: true, get: function () { return decodeNonce_1.decodeNonce; } });
30
+ const encodeNonce_1 = require("./encodeNonce.js");
31
+ Object.defineProperty(exports, "encodeNonce", { enumerable: true, get: function () { return encodeNonce_1.encodeNonce; } });
28
32
  const getEntryPointVersion_1 = require("./getEntryPointVersion.js");
29
33
  Object.defineProperty(exports, "ENTRYPOINT_ADDRESS_V06", { enumerable: true, get: function () { return getEntryPointVersion_1.ENTRYPOINT_ADDRESS_V06; } });
30
34
  Object.defineProperty(exports, "ENTRYPOINT_ADDRESS_V07", { enumerable: true, get: function () { return getEntryPointVersion_1.ENTRYPOINT_ADDRESS_V07; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":";;;AACA,+CAAqE;AAkCjE,4FAlCK,yBAAW,OAkCL;AADX,yGAjCkB,sCAAwB,OAiClB;AAhC5B,yGAAqG;AA4CjG,yHA5CK,mFAAwC,OA4CL;AA3C5C,6DAG6B;AA+BzB,mGAhCA,uCAAkB,OAgCA;AA9BtB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EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;IACjD,OAAO,OAAO,CAAA;AAClB,CAAC;AAJD,oCAIC;AACD,+CAA2C;AA2BvC,4FA3BK,yBAAW,OA2BL;AA1Bf,+CAA2C;AAyBvC,4FAzBK,yBAAW,OAyBL;AAxBf,iEAI+B;AAsB3B,uGAzBA,6CAAsB,OAyBA;AACtB,uGAzBA,6CAAsB,OAyBA;AAJtB,qGApBA,2CAAoB,OAoBA;AAjBxB,qEAAiE;AAgB7D,uGAhBK,+CAAsB,OAgBL"}
@@ -0,0 +1,8 @@
1
+ import { toHex } from "viem";
2
+ export function decodeNonce(nonce) {
3
+ const parsedNonce = BigInt(toHex(nonce, { size: 32 }));
4
+ const key = parsedNonce >> BigInt(64);
5
+ const sequence = parsedNonce & BigInt("0xFFFFFFFFFFFFFFFF");
6
+ return { key, sequence };
7
+ }
8
+ //# sourceMappingURL=decodeNonce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decodeNonce.js","sourceRoot":"","sources":["../../utils/decodeNonce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAE5B,MAAM,UAAU,WAAW,CAAC,KAAa;IACrC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAEtD,MAAM,GAAG,GAAG,WAAW,IAAI,MAAM,CAAC,EAAE,CAAC,CAAA;IACrC,MAAM,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAE3D,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAA;AAC5B,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { toHex } from "viem";
2
+ export function encodeNonce(args) {
3
+ const key = BigInt(toHex(args.key, { size: 24 }));
4
+ const sequence = BigInt(toHex(args.sequence, { size: 8 }));
5
+ return (key << BigInt(64)) + sequence;
6
+ }
7
+ //# sourceMappingURL=encodeNonce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeNonce.js","sourceRoot":"","sources":["../../utils/encodeNonce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAE5B,MAAM,UAAU,WAAW,CAAC,IAAuC;IAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAE1D,OAAO,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAA;AACzC,CAAC"}
@@ -11,7 +11,9 @@ export function parseAccount(account) {
11
11
  return { address: account, type: "json-rpc" };
12
12
  return account;
13
13
  }
14
+ import { decodeNonce } from "./decodeNonce.js";
15
+ import { encodeNonce } from "./encodeNonce.js";
14
16
  import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07, getEntryPointVersion } from "./getEntryPointVersion.js";
15
17
  import { getPackedUserOperation } from "./getPackedUserOperation.js";
16
- export { transactionReceiptStatus, deepHexlify, getUserOperationHash, getRequiredPrefund, walletClientToSmartAccountSigner, signUserOperationHashWithECDSA, AccountOrClientNotFoundError, isSmartAccountDeployed, providerToSmartAccountSigner, getAddressFromInitCodeOrPaymasterAndData, getPackedUserOperation, getEntryPointVersion, ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 };
18
+ export { transactionReceiptStatus, deepHexlify, getUserOperationHash, getRequiredPrefund, walletClientToSmartAccountSigner, signUserOperationHashWithECDSA, AccountOrClientNotFoundError, isSmartAccountDeployed, providerToSmartAccountSigner, getAddressFromInitCodeOrPaymasterAndData, getPackedUserOperation, getEntryPointVersion, encodeNonce, decodeNonce, ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 };
17
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACrE,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAA;AACrG,OAAO,EAEH,kBAAkB,EACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAEH,oBAAoB,EACvB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,EACH,4BAA4B,EAE5B,8BAA8B,EACjC,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAA;AAErF,MAAM,UAAU,YAAY,CAAC,OAA0B;IACnD,IAAI,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;IACjD,OAAO,OAAO,CAAA;AAClB,CAAC;AACD,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EACH,wBAAwB,EACxB,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,EAGhC,8BAA8B,EAE9B,4BAA4B,EAC5B,sBAAsB,EACtB,4BAA4B,EAC5B,wCAAwC,EACxC,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACzB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts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ingURL=decodeNonce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decodeNonce.d.ts","sourceRoot":"","sources":["../../utils/decodeNonce.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAO5E"}
@@ -0,0 +1,5 @@
1
+ export declare function encodeNonce(args: {
2
+ key: bigint;
3
+ sequence: bigint;
4
+ }): bigint;
5
+ //# sourceMappingURL=encodeNonce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeNonce.d.ts","sourceRoot":"","sources":["../../utils/encodeNonce.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK3E"}
@@ -8,7 +8,9 @@ import { providerToSmartAccountSigner } from "./providerToSmartAccountSigner";
8
8
  import { AccountOrClientNotFoundError, type SignUserOperationHashWithECDSAParams, signUserOperationHashWithECDSA } from "./signUserOperationHashWithECDSA";
9
9
  import { walletClientToSmartAccountSigner } from "./walletClientToSmartAccountSigner";
10
10
  export declare function parseAccount(account: Address | Account): Account;
11
+ import { decodeNonce } from "./decodeNonce";
12
+ import { encodeNonce } from "./encodeNonce";
11
13
  import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07, getEntryPointVersion } from "./getEntryPointVersion";
12
14
  import { getPackedUserOperation } from "./getPackedUserOperation";
13
- export { transactionReceiptStatus, deepHexlify, getUserOperationHash, getRequiredPrefund, walletClientToSmartAccountSigner, type GetRequiredPrefundReturnType, type GetUserOperationHashParams, signUserOperationHashWithECDSA, type SignUserOperationHashWithECDSAParams, AccountOrClientNotFoundError, isSmartAccountDeployed, providerToSmartAccountSigner, getAddressFromInitCodeOrPaymasterAndData, getPackedUserOperation, getEntryPointVersion, ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 };
15
+ export { transactionReceiptStatus, deepHexlify, getUserOperationHash, getRequiredPrefund, walletClientToSmartAccountSigner, type GetRequiredPrefundReturnType, type GetUserOperationHashParams, signUserOperationHashWithECDSA, type SignUserOperationHashWithECDSAParams, AccountOrClientNotFoundError, isSmartAccountDeployed, providerToSmartAccountSigner, getAddressFromInitCodeOrPaymasterAndData, getPackedUserOperation, getEntryPointVersion, encodeNonce, decodeNonce, ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 };
14
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACrE,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAA;AACrG,OAAO,EACH,KAAK,4BAA4B,EACjC,kBAAkB,EACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACH,KAAK,0BAA0B,EAC/B,oBAAoB,EACvB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,EACH,4BAA4B,EAC5B,KAAK,oCAAoC,EACzC,8BAA8B,EACjC,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAA;AAErF,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAIhE;AACD,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,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,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EACH,wBAAwB,EACxB,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,EAChC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,8BAA8B,EAC9B,KAAK,oCAAoC,EACzC,4BAA4B,EAC5B,sBAAsB,EACtB,4BAA4B,EAC5B,wCAAwC,EACxC,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACzB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "permissionless",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "author": "Pimlico",
5
5
  "homepage": "https://docs.pimlico.io/permissionless",
6
6
  "repository": "github:pimlicolabs/permissionless.js",
@@ -0,0 +1,40 @@
1
+ import { describe, expect, test } from "vitest"
2
+ import { decodeNonce, encodeNonce } from "./index"
3
+
4
+ describe("decodeNonce", () => {
5
+ test("should encode key and sequence correctly", async () => {
6
+ const key = 123456789012345678901234n
7
+ const sequence = 9876543210n
8
+
9
+ const result = encodeNonce({ key, sequence })
10
+
11
+ const decodedNonce = decodeNonce(result)
12
+
13
+ expect(decodedNonce.key).toBe(key)
14
+ expect(decodedNonce.sequence).toBe(sequence)
15
+ })
16
+
17
+ test("should handle zero values correctly", () => {
18
+ const key = BigInt(0)
19
+ const sequence = BigInt(0)
20
+
21
+ const result = encodeNonce({ key, sequence })
22
+
23
+ const decodedNonce = decodeNonce(result)
24
+
25
+ expect(decodedNonce.key).toBe(key)
26
+ expect(decodedNonce.sequence).toBe(sequence)
27
+ })
28
+
29
+ test("should handle large values correctly", () => {
30
+ const key = BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFF")
31
+ const sequence = BigInt("0xFFFFFFFF")
32
+
33
+ const result = encodeNonce({ key, sequence })
34
+
35
+ const decodedNonce = decodeNonce(result)
36
+
37
+ expect(decodedNonce.key).toBe(key)
38
+ expect(decodedNonce.sequence).toBe(sequence)
39
+ })
40
+ })
@@ -0,0 +1,10 @@
1
+ import { toHex } from "viem"
2
+
3
+ export function decodeNonce(nonce: bigint): { key: bigint; sequence: bigint } {
4
+ const parsedNonce = BigInt(toHex(nonce, { size: 32 }))
5
+
6
+ const key = parsedNonce >> BigInt(64)
7
+ const sequence = parsedNonce & BigInt("0xFFFFFFFFFFFFFFFF")
8
+
9
+ return { key, sequence }
10
+ }
@@ -0,0 +1,38 @@
1
+ import { toHex } from "viem"
2
+ import { describe, expect, test } from "vitest"
3
+ import { encodeNonce } from "./index"
4
+
5
+ describe("encodeNonce", () => {
6
+ test("should encode key and sequence correctly", async () => {
7
+ const key = 123456789012345678901234n
8
+ const sequence = 9876543210n
9
+ const expectedKey = BigInt(toHex(key, { size: 24 }))
10
+ const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
11
+
12
+ const result = encodeNonce({ key, sequence })
13
+
14
+ expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
15
+ })
16
+
17
+ test("should handle zero values correctly", () => {
18
+ const key = BigInt(0)
19
+ const sequence = BigInt(0)
20
+ const expectedKey = BigInt(toHex(key, { size: 24 }))
21
+ const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
22
+
23
+ const result = encodeNonce({ key, sequence })
24
+
25
+ expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
26
+ })
27
+
28
+ test("should handle large values correctly", () => {
29
+ const key = BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFF")
30
+ const sequence = BigInt("0xFFFFFFFF")
31
+ const expectedKey = BigInt(toHex(key, { size: 24 }))
32
+ const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
33
+
34
+ const result = encodeNonce({ key, sequence })
35
+
36
+ expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
37
+ })
38
+ })
@@ -0,0 +1,8 @@
1
+ import { toHex } from "viem"
2
+
3
+ export function encodeNonce(args: { key: bigint; sequence: bigint }): bigint {
4
+ const key = BigInt(toHex(args.key, { size: 24 }))
5
+ const sequence = BigInt(toHex(args.sequence, { size: 8 }))
6
+
7
+ return (key << BigInt(64)) + sequence
8
+ }
package/utils/index.ts CHANGED
@@ -23,6 +23,8 @@ export function parseAccount(account: Address | Account): Account {
23
23
  return { address: account, type: "json-rpc" }
24
24
  return account
25
25
  }
26
+ import { decodeNonce } from "./decodeNonce"
27
+ import { encodeNonce } from "./encodeNonce"
26
28
  import {
27
29
  ENTRYPOINT_ADDRESS_V06,
28
30
  ENTRYPOINT_ADDRESS_V07,
@@ -47,6 +49,8 @@ export {
47
49
  getAddressFromInitCodeOrPaymasterAndData,
48
50
  getPackedUserOperation,
49
51
  getEntryPointVersion,
52
+ encodeNonce,
53
+ decodeNonce,
50
54
  ENTRYPOINT_ADDRESS_V06,
51
55
  ENTRYPOINT_ADDRESS_V07
52
56
  }