permissionless 0.1.38 → 0.1.39
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 +6 -0
- package/_cjs/actions/public/getSenderAddress.js +79 -55
- package/_cjs/actions/public/getSenderAddress.js.map +1 -1
- package/_esm/actions/public/getSenderAddress.js +83 -59
- package/_esm/actions/public/getSenderAddress.js.map +1 -1
- package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
- package/actions/public/getSenderAddress.test.ts +1 -1
- package/actions/public/getSenderAddress.ts +104 -70
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -57,9 +57,11 @@ const getSenderAddress = async (client, args) => {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
catch (e) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
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 (
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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,+
|
|
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,CACrB,CAAC;YACE,OAAO,EAAE,UAAU;YACnB,GAAG,EAAE;gBACD;oBACI,MAAM,EAAE;wBACJ;4BACI,YAAY,EAAE,SAAS;4BACvB,IAAI,EAAE,QAAQ;4BACd,IAAI,EAAE,SAAS;yBAClB;qBACJ;oBACD,IAAI,EAAE,qBAAqB;oBAC3B,IAAI,EAAE,OAAO;iBAChB;gBACD;oBACI,MAAM,EAAE;wBACJ;4BACI,YAAY,EAAE,OAAO;4BACrB,IAAI,EAAE,UAAU;4BAChB,IAAI,EAAE,OAAO;yBAChB;qBACJ;oBACD,IAAI,EAAE,kBAAkB;oBACxB,OAAO,EAAE,EAAE;oBACX,eAAe,EAAE,YAAY;oBAC7B,IAAI,EAAE,UAAU;iBACnB;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AC;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"}
|
|
@@ -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
|
|
82
|
-
|
|
83
|
-
|
|
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 (
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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,
|
|
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,QAAQ,EAAE,UAAU,EAAE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pD,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSenderAddress.d.ts","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,OAAO,EACZ,SAAS,
|
|
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"}
|
|
@@ -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 "../../
|
|
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
|
-
|
|
7
|
+
ContractFunctionRevertedError,
|
|
9
8
|
type Hex,
|
|
10
|
-
|
|
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
|
|
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 (
|
|
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 (
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
hexStringRegex
|
|
162
|
+
if (!match) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
"Failed to parse revert bytes from RPC response"
|
|
159
165
|
)
|
|
166
|
+
}
|
|
160
167
|
|
|
161
|
-
|
|
162
|
-
throw new Error(
|
|
163
|
-
"Failed to parse revert bytes from RPC response"
|
|
164
|
-
)
|
|
165
|
-
}
|
|
168
|
+
const data: Hex = match[0]
|
|
166
169
|
|
|
167
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
197
|
+
if (!match) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
"Failed to parse revert bytes from RPC response"
|
|
200
|
+
)
|
|
187
201
|
}
|
|
188
202
|
|
|
189
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
"Failed to parse revert bytes from RPC response"
|
|
203
|
-
)
|
|
204
|
-
}
|
|
222
|
+
return error.args[0] as Address
|
|
223
|
+
}
|
|
205
224
|
|
|
206
|
-
|
|
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
|
-
|
|
209
|
-
|
|
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
|
-
|
|
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
|