permissionless 0.1.38 → 0.1.40

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.40
4
+
5
+ ### Patch Changes
6
+
7
+ - be1c3dede45bdfbffe168735cbd48fd967684818: Added encodeNonce util function
8
+
9
+ ## 0.1.39
10
+
11
+ ### Patch Changes
12
+
13
+ - 3527daa505b73b343cbee257124d5416b7dff730: Fixed getSenderAddress, when rpc returns an UnknownRpcError
14
+
3
15
  ## 0.1.38
4
16
 
5
17
  ### Patch Changes
@@ -57,9 +57,11 @@ const getSenderAddress = async (client, args) => {
57
57
  });
58
58
  }
59
59
  catch (e) {
60
- const err = e;
61
- if (err.cause.name === "ContractFunctionRevertedError") {
62
- const revertError = err.cause;
60
+ const revertError = e.walk((err) => err instanceof viem_1.ContractFunctionRevertedError ||
61
+ err instanceof viem_1.RpcRequestError ||
62
+ err instanceof viem_1.InvalidInputRpcError ||
63
+ err instanceof viem_1.UnknownRpcError);
64
+ if (revertError instanceof viem_1.ContractFunctionRevertedError) {
63
65
  const errorName = revertError.data?.errorName ?? "";
64
66
  if (errorName === "SenderAddressResult" &&
65
67
  revertError.data?.args &&
@@ -67,60 +69,82 @@ const getSenderAddress = async (client, args) => {
67
69
  return revertError.data?.args[0];
68
70
  }
69
71
  }
70
- if (err.cause.name === "CallExecutionError") {
71
- const callExecutionError = err.cause;
72
- if (callExecutionError.cause.name === "RpcRequestError") {
73
- const revertError = callExecutionError.cause;
74
- const hexStringRegex = /0x[a-fA-F0-9]+/;
75
- const match = revertError.cause.data.match(hexStringRegex);
76
- if (!match) {
77
- throw new Error("Failed to parse revert bytes from RPC response");
78
- }
79
- const data = match[0];
80
- const error = (0, viem_1.decodeErrorResult)({
81
- abi: [
82
- {
83
- inputs: [
84
- {
85
- internalType: "address",
86
- name: "sender",
87
- type: "address"
88
- }
89
- ],
90
- name: "SenderAddressResult",
91
- type: "error"
92
- }
93
- ],
94
- data
95
- });
96
- return error.args[0];
72
+ if (revertError instanceof viem_1.RpcRequestError) {
73
+ const hexStringRegex = /0x[a-fA-F0-9]+/;
74
+ const match = revertError.cause.data.match(hexStringRegex);
75
+ if (!match) {
76
+ throw new Error("Failed to parse revert bytes from RPC response");
97
77
  }
98
- if (callExecutionError.cause.name === "InvalidInputRpcError") {
99
- const revertError = callExecutionError.cause;
100
- const hexStringRegex = /0x[a-fA-F0-9]+/;
101
- const match = revertError.cause.data.match(hexStringRegex);
102
- if (!match) {
103
- throw new Error("Failed to parse revert bytes from RPC response");
104
- }
105
- const data = match[0];
106
- const error = (0, viem_1.decodeErrorResult)({
107
- abi: [
108
- {
109
- inputs: [
110
- {
111
- internalType: "address",
112
- name: "sender",
113
- type: "address"
114
- }
115
- ],
116
- name: "SenderAddressResult",
117
- type: "error"
118
- }
119
- ],
120
- data
121
- });
122
- return error.args[0];
78
+ const data = match[0];
79
+ const error = (0, viem_1.decodeErrorResult)({
80
+ abi: [
81
+ {
82
+ inputs: [
83
+ {
84
+ internalType: "address",
85
+ name: "sender",
86
+ type: "address"
87
+ }
88
+ ],
89
+ name: "SenderAddressResult",
90
+ type: "error"
91
+ }
92
+ ],
93
+ data
94
+ });
95
+ return error.args[0];
96
+ }
97
+ if (revertError instanceof viem_1.InvalidInputRpcError) {
98
+ const hexStringRegex = /0x[a-fA-F0-9]+/;
99
+ const match = revertError.cause.data.match(hexStringRegex);
100
+ if (!match) {
101
+ throw new Error("Failed to parse revert bytes from RPC response");
102
+ }
103
+ const data = match[0];
104
+ const error = (0, viem_1.decodeErrorResult)({
105
+ abi: [
106
+ {
107
+ inputs: [
108
+ {
109
+ internalType: "address",
110
+ name: "sender",
111
+ type: "address"
112
+ }
113
+ ],
114
+ name: "SenderAddressResult",
115
+ type: "error"
116
+ }
117
+ ],
118
+ data
119
+ });
120
+ return error.args[0];
121
+ }
122
+ if (revertError instanceof viem_1.UnknownRpcError) {
123
+ const parsedBody = JSON.parse(revertError.cause.body);
124
+ const revertData = parsedBody.error.data;
125
+ const hexStringRegex = /0x[a-fA-F0-9]+/;
126
+ const match = revertData.match(hexStringRegex);
127
+ if (!match) {
128
+ throw new Error("Failed to parse revert bytes from RPC response");
123
129
  }
130
+ const data = match[0];
131
+ const error = (0, viem_1.decodeErrorResult)({
132
+ abi: [
133
+ {
134
+ inputs: [
135
+ {
136
+ internalType: "address",
137
+ name: "sender",
138
+ type: "address"
139
+ }
140
+ ],
141
+ name: "SenderAddressResult",
142
+ type: "error"
143
+ }
144
+ ],
145
+ data
146
+ });
147
+ return error.args[0];
124
148
  }
125
149
  throw e;
126
150
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getSenderAddress.js","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":";;;AAAA,+BAaa;AAEb,0CAA+C;AAC/C,sCAAsC;AAsBtC,MAAa,sBAAuB,SAAQ,gBAAS;IAGjD,YAAY,EACR,KAAK,EACL,UAAU,KACmC,EAAE;QAC/C,KAAK,CACD,0CACI,UAAU,CAAC,CAAC,CAAC,MAAM,UAAU,EAAE,CAAC,CAAC,CAAC,EACtC,iGAAiG,EACjG;YACI,KAAK;SACR,CACJ,CAAA;QAbI;;;;mBAAO,wBAAwB;WAAA;IAcxC,CAAC;CACJ;AAhBD,wDAgBC;AA2BM,MAAM,gBAAgB,GAAG,KAAK,EAKjC,MAAkC,EAClC,IAAkD,EAClC,EAAE;IAClB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAE3D,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACX,mEAAmE,CACtE,CAAA;IACL,CAAC;IAED,IAAI,CAAC;QACD,MAAM,IAAA,iBAAS,EACX,MAAM,EACN,0BAAgB,EAChB,kBAAkB,C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EAAE;wBACD;4BACI,MAAM,EAAE;gCACJ;oCACI,YAAY,EAAE,SAAS;oCACvB,IAAI,EAAE,QAAQ;oCACd,IAAI,EAAE,SAAS;iCAClB;6BACJ;4BACD,IAAI,EAAE,qBAAqB;4BAC3B,IAAI,EAAE,OAAO;yBAChB;qBACJ;oBACD,IAAI;iBACP,CAAC,CAAA;gBAEF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAY,CAAA;YACnC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,CAAA;IACX,CAAC;IAED,MAAM,IAAI,sBAAsB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAA;AACpD,CAAC,CAAA;AAvJY,QAAA,gBAAgB,oBAuJ5B"}
1
+ {"version":3,"file":"getSenderAddress.js","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":";;;AAAA,+BAca;AAEb,0CAA+C;AAC/C,sCAAsC;AAsBtC,MAAa,sBAAuB,SAAQ,gBAAS;IAGjD,YAAY,EACR,KAAK,EACL,UAAU,KACmC,EAAE;QAC/C,KAAK,CACD,0CACI,UAAU,CAAC,CAAC,CAAC,MAAM,UAAU,EAAE,CAAC,CAAC,CAAC,EACtC,iGAAiG,EACjG;YACI,KAAK;SACR,CACJ,CAAA;QAbI;;;;mBAAO,wBAAwB;WAAA;IAcxC,CAAC;CACJ;AAhBD,wDAgBC;AA2BM,MAAM,gBAAgB,GAAG,KAAK,EAKjC,MAAkC,EAClC,IAAkD,EAClC,EAAE;IAClB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAE3D,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACX,mEAAmE,CACtE,CAAA;IACL,CAAC;IAED,IAAI,CAAC;QACD,MAAM,IAAA,iBAAS,EACX,MAAM,EACN,0BAAgB,EAChB,kBAAkB,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AA;YAEF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAY,CAAA;QACnC,CAAC;QAED,IAAI,WAAW,YAAY,sBAAe,EAAE,CAAC;YACzC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CACxB,WAA8B,CAAC,KAAK,CAAC,IAAI,CAC7C,CAAA;YACD,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAA;YAExC,MAAM,cAAc,GAAG,gBAAgB,CAAA;YAEvC,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;YAE9C,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CACX,gDAAgD,CACnD,CAAA;YACL,CAAC;YAED,MAAM,IAAI,GAAQ,KAAK,CAAC,CAAC,CAAC,CAAA;YAE1B,MAAM,KAAK,GAAG,IAAA,wBAAiB,EAAC;gBAC5B,GAAG,EAAE;oBACD;wBACI,MAAM,EAAE;4BACJ;gCACI,YAAY,EAAE,SAAS;gCACvB,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,SAAS;6BAClB;yBACJ;wBACD,IAAI,EAAE,qBAAqB;wBAC3B,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,IAAI;aACP,CAAC,CAAA;YAEF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAY,CAAA;QACnC,CAAC;QAED,MAAM,CAAC,CAAA;IACX,CAAC;IAED,MAAM,IAAI,sBAAsB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAA;AACpD,CAAC,CAAA;AAxLY,QAAA,gBAAgB,oBAwL5B"}
@@ -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.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,8 @@ function parseAccount(account) {
25
25
  return account;
26
26
  }
27
27
  exports.parseAccount = parseAccount;
28
+ const encodeNonce_1 = require("./encodeNonce.js");
29
+ Object.defineProperty(exports, "encodeNonce", { enumerable: true, get: function () { return encodeNonce_1.encodeNonce; } });
28
30
  const getEntryPointVersion_1 = require("./getEntryPointVersion.js");
29
31
  Object.defineProperty(exports, "ENTRYPOINT_ADDRESS_V06", { enumerable: true, get: function () { return getEntryPointVersion_1.ENTRYPOINT_ADDRESS_V06; } });
30
32
  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,iEAG+B;AA0B3B,qGA3BA,2CAAoB,OA2BA;AAzBxB,qEAAiE;AAiC7D,uGAjCK,+CAAsB,OAiCL;AAhC1B,iFAA6E;AAiCzE,6GAjCK,2DAA4B,OAiCL;AAhChC,qFAIyC;AA0BrC,6GA7BA,6DAA4B,OA6BA;AAF5B,+GAzBA,+DAA8B,OAyBA;AAvBlC,yFAAqF;AAoBjF,iHApBK,mEAAgC,OAoBL;AAlBpC,SAAgB,YAAY,CAAC,OAA0B;IAC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 -1,4 +1,4 @@
1
- import { BaseError, concat, decodeErrorResult } from "viem";
1
+ import { BaseError, ContractFunctionRevertedError, InvalidInputRpcError, RpcRequestError, UnknownRpcError, concat, decodeErrorResult } from "viem";
2
2
  import { simulateContract } from "viem/actions";
3
3
  import { getAction } from "viem/utils";
4
4
  export class InvalidEntryPointError extends BaseError {
@@ -78,9 +78,11 @@ export const getSenderAddress = async (client, args) => {
78
78
  });
79
79
  }
80
80
  catch (e) {
81
- const err = e;
82
- if (err.cause.name === "ContractFunctionRevertedError") {
83
- const revertError = err.cause;
81
+ const revertError = e.walk((err) => err instanceof ContractFunctionRevertedError ||
82
+ err instanceof RpcRequestError ||
83
+ err instanceof InvalidInputRpcError ||
84
+ err instanceof UnknownRpcError);
85
+ if (revertError instanceof ContractFunctionRevertedError) {
84
86
  const errorName = revertError.data?.errorName ?? "";
85
87
  if (errorName === "SenderAddressResult" &&
86
88
  revertError.data?.args &&
@@ -88,63 +90,85 @@ export const getSenderAddress = async (client, args) => {
88
90
  return revertError.data?.args[0];
89
91
  }
90
92
  }
91
- if (err.cause.name === "CallExecutionError") {
92
- const callExecutionError = err.cause;
93
- if (callExecutionError.cause.name === "RpcRequestError") {
94
- const revertError = callExecutionError.cause;
95
- const hexStringRegex = /0x[a-fA-F0-9]+/;
96
- // biome-ignore lint/suspicious/noExplicitAny:
97
- const match = revertError.cause.data.match(hexStringRegex);
98
- if (!match) {
99
- throw new Error("Failed to parse revert bytes from RPC response");
100
- }
101
- const data = match[0];
102
- const error = decodeErrorResult({
103
- abi: [
104
- {
105
- inputs: [
106
- {
107
- internalType: "address",
108
- name: "sender",
109
- type: "address"
110
- }
111
- ],
112
- name: "SenderAddressResult",
113
- type: "error"
114
- }
115
- ],
116
- data
117
- });
118
- return error.args[0];
93
+ if (revertError instanceof RpcRequestError) {
94
+ const hexStringRegex = /0x[a-fA-F0-9]+/;
95
+ // biome-ignore lint/suspicious/noExplicitAny:
96
+ const match = revertError.cause.data.match(hexStringRegex);
97
+ if (!match) {
98
+ throw new Error("Failed to parse revert bytes from RPC response");
119
99
  }
120
- if (callExecutionError.cause.name === "InvalidInputRpcError") {
121
- //Ganache local testing returns "InvalidInputRpcError" with data in regular format
122
- const revertError = callExecutionError.cause;
123
- const hexStringRegex = /0x[a-fA-F0-9]+/;
124
- // biome-ignore lint/suspicious/noExplicitAny:
125
- const match = revertError.cause.data.match(hexStringRegex);
126
- if (!match) {
127
- throw new Error("Failed to parse revert bytes from RPC response");
128
- }
129
- const data = match[0];
130
- const error = decodeErrorResult({
131
- abi: [
132
- {
133
- inputs: [
134
- {
135
- internalType: "address",
136
- name: "sender",
137
- type: "address"
138
- }
139
- ],
140
- name: "SenderAddressResult",
141
- type: "error"
142
- }
143
- ],
144
- data
145
- });
146
- return error.args[0];
100
+ const data = match[0];
101
+ const error = decodeErrorResult({
102
+ abi: [
103
+ {
104
+ inputs: [
105
+ {
106
+ internalType: "address",
107
+ name: "sender",
108
+ type: "address"
109
+ }
110
+ ],
111
+ name: "SenderAddressResult",
112
+ type: "error"
113
+ }
114
+ ],
115
+ data
116
+ });
117
+ return error.args[0];
118
+ }
119
+ if (revertError instanceof InvalidInputRpcError) {
120
+ const hexStringRegex = /0x[a-fA-F0-9]+/;
121
+ // biome-ignore lint/suspicious/noExplicitAny:
122
+ const match = revertError.cause.data.match(hexStringRegex);
123
+ if (!match) {
124
+ throw new Error("Failed to parse revert bytes from RPC response");
125
+ }
126
+ const data = match[0];
127
+ const error = decodeErrorResult({
128
+ abi: [
129
+ {
130
+ inputs: [
131
+ {
132
+ internalType: "address",
133
+ name: "sender",
134
+ type: "address"
135
+ }
136
+ ],
137
+ name: "SenderAddressResult",
138
+ type: "error"
139
+ }
140
+ ],
141
+ data
142
+ });
143
+ return error.args[0];
144
+ }
145
+ if (revertError instanceof UnknownRpcError) {
146
+ const parsedBody = JSON.parse(revertError.cause.body);
147
+ const revertData = parsedBody.error.data;
148
+ const hexStringRegex = /0x[a-fA-F0-9]+/;
149
+ // biome-ignore lint/suspicious/noExplicitAny:
150
+ const match = revertData.match(hexStringRegex);
151
+ if (!match) {
152
+ throw new Error("Failed to parse revert bytes from RPC response");
147
153
  }
154
+ const data = match[0];
155
+ const error = decodeErrorResult({
156
+ abi: [
157
+ {
158
+ inputs: [
159
+ {
160
+ internalType: "address",
161
+ name: "sender",
162
+ type: "address"
163
+ }
164
+ ],
165
+ name: "SenderAddressResult",
166
+ type: "error"
167
+ }
168
+ ],
169
+ data
170
+ });
171
+ return error.args[0];
148
172
  }
149
173
  throw e;
150
174
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getSenderAddress.js","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,EAST,MAAM,EACN,iBAAiB,EACpB,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAsBtC,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAGjD,YAAY,EACR,KAAK,EACL,UAAU,KACmC,EAAE;QAC/C,KAAK,CACD,0CACI,UAAU,CAAC,CAAC,CAAC,MAAM,UAAU,EAAE,CAAC,CAAC,CAAC,EACtC,iGAAiG,EACjG;YACI,KAAK;SACR,CACJ,CAAA;QAbI;;;;mBAAO,wBAAwB;WAAA;IAcxC,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAKjC,MAAkC,EAClC,IAAkD,EAClC,EAAE;IAClB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAE3D,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACX,mEAAmE,CACtE,CAAA;IACL,CAAC;IAED,IAAI,C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AQ,KAAK,CAAC,CAAC,CAAC,CAAA;gBAE1B,MAAM,KAAK,GAAG,iBAAiB,CAAC;oBAC5B,GAAG,EAAE;wBACD;4BACI,MAAM,EAAE;gCACJ;oCACI,YAAY,EAAE,SAAS;oCACvB,IAAI,EAAE,QAAQ;oCACd,IAAI,EAAE,SAAS;iCAClB;6BACJ;4BACD,IAAI,EAAE,qBAAqB;4BAC3B,IAAI,EAAE,OAAO;yBAChB;qBACJ;oBACD,IAAI;iBACP,CAAC,CAAA;gBAEF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAY,CAAA;YACnC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,CAAA;IACX,CAAC;IAED,MAAM,IAAI,sBAAsB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAA;AACpD,CAAC,CAAA"}
1
+ {"version":3,"file":"getSenderAddress.js","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,EAIT,6BAA6B,EAE7B,oBAAoB,EACpB,eAAe,EAEf,eAAe,EACf,MAAM,EACN,iBAAiB,EACpB,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAsBtC,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAGjD,YAAY,EACR,KAAK,EACL,UAAU,KACmC,EAAE;QAC/C,KAAK,CACD,0CACI,UAAU,CAAC,CAAC,CAAC,MAAM,UAAU,EAAE,CAAC,CAAC,CAAC,EACtC,iGAAiG,EACjG;YACI,KAAK;SACR,CACJ,CAAA;QAbI;;;;mBAAO,wBAAwB;WAAA;IAcxC,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAKjC,MAAkC,EAClC,IAAkD,EAClC,EAAE;IAClB,MAAM,EAAE,QAA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EAAE,CAAC,CAAA;AACpD,CAAC,CAAA"}
@@ -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,8 @@ export function parseAccount(account) {
11
11
  return { address: account, type: "json-rpc" };
12
12
  return account;
13
13
  }
14
+ import { encodeNonce } from "./encodeNonce.js";
14
15
  import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07, getEntryPointVersion } from "./getEntryPointVersion.js";
15
16
  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 };
17
+ export { transactionReceiptStatus, deepHexlify, getUserOperationHash, getRequiredPrefund, walletClientToSmartAccountSigner, signUserOperationHashWithECDSA, AccountOrClientNotFoundError, isSmartAccountDeployed, providerToSmartAccountSigner, getAddressFromInitCodeOrPaymasterAndData, getPackedUserOperation, getEntryPointVersion, encodeNonce, ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 };
17
18
  //# 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,s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@ -1 +1 @@
1
- {"version":3,"file":"getSenderAddress.d.ts","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,OAAO,EACZ,SAAS,EAET,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,GAAG,EAER,KAAK,SAAS,EAGjB,MAAM,MAAM,CAAA;AAIb,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EACR,2BAA2B,EAC3B,UAAU,EACb,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,sBAAsB,CAAC,UAAU,SAAS,UAAU,IAC5D,UAAU,SAAS,2BAA2B,GACxC;IACI,QAAQ,EAAE,GAAG,CAAA;IACb,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,WAAW,CAAC,EAAE,KAAK,CAAA;CACtB,GACD;IACI,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,GAAG,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACnB,CAAA;AAEX,qBAAa,sBAAuB,SAAQ,SAAS;IACxC,IAAI,SAA2B;gBAE5B,EACR,KAAK,EACL,UAAU,EACb,GAAE;QAAE,KAAK,CAAC,EAAE,SAAS,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO;CAUtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB,0IAKjB,OAAO,UAAU,EAAE,MAAM,CAAC,oIAEnC,QAAQ,OAAO,CAgJjB,CAAA"}
1
+ {"version":3,"file":"getSenderAddress.d.ts","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,OAAO,EACZ,SAAS,EACT,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,GAAG,EAGR,KAAK,SAAS,EAIjB,MAAM,MAAM,CAAA;AAIb,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EACR,2BAA2B,EAC3B,UAAU,EACb,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,sBAAsB,CAAC,UAAU,SAAS,UAAU,IAC5D,UAAU,SAAS,2BAA2B,GACxC;IACI,QAAQ,EAAE,GAAG,CAAA;IACb,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,WAAW,CAAC,EAAE,KAAK,CAAA;CACtB,GACD;IACI,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,GAAG,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACnB,CAAA;AAEX,qBAAa,sBAAuB,SAAQ,SAAS;IACxC,IAAI,SAA2B;gBAE5B,EACR,KAAK,EACL,UAAU,EACb,GAAE;QAAE,KAAK,CAAC,EAAE,SAAS,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO;CAUtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB,0IAKjB,OAAO,UAAU,EAAE,MAAM,CAAC,oIAEnC,QAAQ,OAAO,CAiLjB,CAAA"}
@@ -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,8 @@ 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 { encodeNonce } from "./encodeNonce";
11
12
  import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07, getEntryPointVersion } from "./getEntryPointVersion";
12
13
  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 };
14
+ export { transactionReceiptStatus, deepHexlify, getUserOperationHash, getRequiredPrefund, walletClientToSmartAccountSigner, type GetRequiredPrefundReturnType, type GetUserOperationHashParams, signUserOperationHashWithECDSA, type SignUserOperationHashWithECDSAParams, AccountOrClientNotFoundError, isSmartAccountDeployed, providerToSmartAccountSigner, getAddressFromInitCodeOrPaymasterAndData, getPackedUserOperation, getEntryPointVersion, encodeNonce, ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 };
14
15
  //# 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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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,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,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,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,sBAAsB,EACtB,sBAAsB,EACzB,CAAA"}
@@ -3,7 +3,7 @@ import { generatePrivateKey } from "viem/accounts"
3
3
  import { describe, expect } from "vitest"
4
4
  import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
5
5
  import { getSimpleAccountClient } from "../../../permissionless-test/src/utils"
6
- import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../_types/types"
6
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../types"
7
7
  import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from "../../utils"
8
8
  import { getSenderAddress } from "./getSenderAddress"
9
9
 
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  type Address,
3
3
  BaseError,
4
- type CallExecutionErrorType,
5
4
  type Chain,
6
5
  type Client,
7
6
  type ContractFunctionExecutionErrorType,
8
- type ContractFunctionRevertedErrorType,
7
+ ContractFunctionRevertedError,
9
8
  type Hex,
10
- type RpcRequestErrorType,
9
+ InvalidInputRpcError,
10
+ RpcRequestError,
11
11
  type Transport,
12
+ UnknownRpcError,
12
13
  concat,
13
14
  decodeErrorResult
14
15
  } from "viem"
@@ -132,10 +133,15 @@ export const getSenderAddress = async <
132
133
  args: [initCode || concat([factory as Hex, factoryData as Hex])]
133
134
  })
134
135
  } catch (e) {
135
- const err = e as ContractFunctionExecutionErrorType
136
+ const revertError = (e as ContractFunctionExecutionErrorType).walk(
137
+ (err) =>
138
+ err instanceof ContractFunctionRevertedError ||
139
+ err instanceof RpcRequestError ||
140
+ err instanceof InvalidInputRpcError ||
141
+ err instanceof UnknownRpcError
142
+ )
136
143
 
137
- if (err.cause.name === "ContractFunctionRevertedError") {
138
- const revertError = err.cause as ContractFunctionRevertedErrorType
144
+ if (revertError instanceof ContractFunctionRevertedError) {
139
145
  const errorName = revertError.data?.errorName ?? ""
140
146
  if (
141
147
  errorName === "SenderAddressResult" &&
@@ -146,84 +152,112 @@ export const getSenderAddress = async <
146
152
  }
147
153
  }
148
154
 
149
- if (err.cause.name === "CallExecutionError") {
150
- const callExecutionError = err.cause as CallExecutionErrorType
151
- if (callExecutionError.cause.name === "RpcRequestError") {
152
- const revertError =
153
- callExecutionError.cause as RpcRequestErrorType
155
+ if (revertError instanceof RpcRequestError) {
156
+ const hexStringRegex = /0x[a-fA-F0-9]+/
157
+ // biome-ignore lint/suspicious/noExplicitAny:
158
+ const match = (revertError as unknown as any).cause.data.match(
159
+ hexStringRegex
160
+ )
154
161
 
155
- const hexStringRegex = /0x[a-fA-F0-9]+/
156
- // biome-ignore lint/suspicious/noExplicitAny:
157
- const match = (revertError as unknown as any).cause.data.match(
158
- hexStringRegex
162
+ if (!match) {
163
+ throw new Error(
164
+ "Failed to parse revert bytes from RPC response"
159
165
  )
166
+ }
160
167
 
161
- if (!match) {
162
- throw new Error(
163
- "Failed to parse revert bytes from RPC response"
164
- )
165
- }
168
+ const data: Hex = match[0]
166
169
 
167
- const data: Hex = match[0]
170
+ const error = decodeErrorResult({
171
+ abi: [
172
+ {
173
+ inputs: [
174
+ {
175
+ internalType: "address",
176
+ name: "sender",
177
+ type: "address"
178
+ }
179
+ ],
180
+ name: "SenderAddressResult",
181
+ type: "error"
182
+ }
183
+ ],
184
+ data
185
+ })
168
186
 
169
- const error = decodeErrorResult({
170
- abi: [
171
- {
172
- inputs: [
173
- {
174
- internalType: "address",
175
- name: "sender",
176
- type: "address"
177
- }
178
- ],
179
- name: "SenderAddressResult",
180
- type: "error"
181
- }
182
- ],
183
- data
184
- })
187
+ return error.args[0] as Address
188
+ }
189
+
190
+ if (revertError instanceof InvalidInputRpcError) {
191
+ const hexStringRegex = /0x[a-fA-F0-9]+/
192
+ // biome-ignore lint/suspicious/noExplicitAny:
193
+ const match = (revertError as unknown as any).cause.data.match(
194
+ hexStringRegex
195
+ )
185
196
 
186
- return error.args[0] as Address
197
+ if (!match) {
198
+ throw new Error(
199
+ "Failed to parse revert bytes from RPC response"
200
+ )
187
201
  }
188
202
 
189
- if (callExecutionError.cause.name === "InvalidInputRpcError") {
190
- //Ganache local testing returns "InvalidInputRpcError" with data in regular format
191
- const revertError =
192
- callExecutionError.cause as RpcRequestErrorType
203
+ const data: Hex = match[0]
193
204
 
194
- const hexStringRegex = /0x[a-fA-F0-9]+/
195
- // biome-ignore lint/suspicious/noExplicitAny:
196
- const match = (revertError as unknown as any).cause.data.match(
197
- hexStringRegex
198
- )
205
+ const error = decodeErrorResult({
206
+ abi: [
207
+ {
208
+ inputs: [
209
+ {
210
+ internalType: "address",
211
+ name: "sender",
212
+ type: "address"
213
+ }
214
+ ],
215
+ name: "SenderAddressResult",
216
+ type: "error"
217
+ }
218
+ ],
219
+ data
220
+ })
199
221
 
200
- if (!match) {
201
- throw new Error(
202
- "Failed to parse revert bytes from RPC response"
203
- )
204
- }
222
+ return error.args[0] as Address
223
+ }
205
224
 
206
- const data: Hex = match[0]
225
+ if (revertError instanceof UnknownRpcError) {
226
+ const parsedBody = JSON.parse(
227
+ (revertError as unknown as any).cause.body
228
+ )
229
+ const revertData = parsedBody.error.data
207
230
 
208
- const error = decodeErrorResult({
209
- abi: [
210
- {
211
- inputs: [
212
- {
213
- internalType: "address",
214
- name: "sender",
215
- type: "address"
216
- }
217
- ],
218
- name: "SenderAddressResult",
219
- type: "error"
220
- }
221
- ],
222
- data
223
- })
231
+ const hexStringRegex = /0x[a-fA-F0-9]+/
232
+ // biome-ignore lint/suspicious/noExplicitAny:
233
+ const match = revertData.match(hexStringRegex)
224
234
 
225
- return error.args[0] as Address
235
+ if (!match) {
236
+ throw new Error(
237
+ "Failed to parse revert bytes from RPC response"
238
+ )
226
239
  }
240
+
241
+ const data: Hex = match[0]
242
+
243
+ const error = decodeErrorResult({
244
+ abi: [
245
+ {
246
+ inputs: [
247
+ {
248
+ internalType: "address",
249
+ name: "sender",
250
+ type: "address"
251
+ }
252
+ ],
253
+ name: "SenderAddressResult",
254
+ type: "error"
255
+ }
256
+ ],
257
+ data
258
+ })
259
+
260
+ return error.args[0] as Address
227
261
  }
228
262
 
229
263
  throw e
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "permissionless",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "author": "Pimlico",
5
5
  "homepage": "https://docs.pimlico.io/permissionless",
6
6
  "repository": "github:pimlicolabs/permissionless.js",
@@ -0,0 +1,38 @@
1
+ import { encodeNonce } from "permissionless/utils"
2
+ import { toHex } from "viem"
3
+ import { describe, expect, test } from "vitest"
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,7 @@ export function parseAccount(account: Address | Account): Account {
23
23
  return { address: account, type: "json-rpc" }
24
24
  return account
25
25
  }
26
+ import { encodeNonce } from "./encodeNonce"
26
27
  import {
27
28
  ENTRYPOINT_ADDRESS_V06,
28
29
  ENTRYPOINT_ADDRESS_V07,
@@ -47,6 +48,7 @@ export {
47
48
  getAddressFromInitCodeOrPaymasterAndData,
48
49
  getPackedUserOperation,
49
50
  getEntryPointVersion,
51
+ encodeNonce,
50
52
  ENTRYPOINT_ADDRESS_V06,
51
53
  ENTRYPOINT_ADDRESS_V07
52
54
  }