@bankofai/x402-evm 1.0.0-beta.0
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/README.md +172 -0
- package/dist/cjs/auth-capture/client/index.d.ts +44 -0
- package/dist/cjs/auth-capture/client/index.js +298 -0
- package/dist/cjs/auth-capture/client/index.js.map +1 -0
- package/dist/cjs/batch-settlement/client/file-storage.d.ts +47 -0
- package/dist/cjs/batch-settlement/client/file-storage.js +116 -0
- package/dist/cjs/batch-settlement/client/file-storage.js.map +1 -0
- package/dist/cjs/batch-settlement/client/index.d.ts +111 -0
- package/dist/cjs/batch-settlement/client/index.js +1565 -0
- package/dist/cjs/batch-settlement/client/index.js.map +1 -0
- package/dist/cjs/batch-settlement/facilitator/index.d.ts +72 -0
- package/dist/cjs/batch-settlement/facilitator/index.js +2102 -0
- package/dist/cjs/batch-settlement/facilitator/index.js.map +1 -0
- package/dist/cjs/batch-settlement/server/file-storage.d.ts +53 -0
- package/dist/cjs/batch-settlement/server/file-storage.js +181 -0
- package/dist/cjs/batch-settlement/server/file-storage.js.map +1 -0
- package/dist/cjs/batch-settlement/server/index.d.ts +491 -0
- package/dist/cjs/batch-settlement/server/index.js +1978 -0
- package/dist/cjs/batch-settlement/server/index.js.map +1 -0
- package/dist/cjs/batch-settlement/server/redis-storage.d.ts +87 -0
- package/dist/cjs/batch-settlement/server/redis-storage.js +181 -0
- package/dist/cjs/batch-settlement/server/redis-storage.js.map +1 -0
- package/dist/cjs/client/agent-wallet.d.ts +69 -0
- package/dist/cjs/client/agent-wallet.js +84 -0
- package/dist/cjs/client/agent-wallet.js.map +1 -0
- package/dist/cjs/exact/client/index.d.ts +63 -0
- package/dist/cjs/exact/client/index.js +739 -0
- package/dist/cjs/exact/client/index.js.map +1 -0
- package/dist/cjs/exact/facilitator/index.d.ts +141 -0
- package/dist/cjs/exact/facilitator/index.js +1989 -0
- package/dist/cjs/exact/facilitator/index.js.map +1 -0
- package/dist/cjs/exact/server/index.d.ts +118 -0
- package/dist/cjs/exact/server/index.js +326 -0
- package/dist/cjs/exact/server/index.js.map +1 -0
- package/dist/cjs/exact/v1/client/index.d.ts +38 -0
- package/dist/cjs/exact/v1/client/index.js +193 -0
- package/dist/cjs/exact/v1/client/index.js.map +1 -0
- package/dist/cjs/exact/v1/facilitator/index.d.ts +84 -0
- package/dist/cjs/exact/v1/facilitator/index.js +739 -0
- package/dist/cjs/exact/v1/facilitator/index.js.map +1 -0
- package/dist/cjs/facilitator/agent-wallet.d.ts +109 -0
- package/dist/cjs/facilitator/agent-wallet.js +105 -0
- package/dist/cjs/facilitator/agent-wallet.js.map +1 -0
- package/dist/cjs/index.d.ts +338 -0
- package/dist/cjs/index.js +2860 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/permit2-DK5A8alk.d.ts +729 -0
- package/dist/cjs/permit2-DhJRUcgY.d.ts +729 -0
- package/dist/cjs/rpc-DULZzRne.d.ts +13 -0
- package/dist/cjs/scheme-7ehldYoO.d.ts +307 -0
- package/dist/cjs/scheme-BjBJzHF7.d.ts +307 -0
- package/dist/cjs/scheme-DWgpkDgz.d.ts +47 -0
- package/dist/cjs/signer-BFelv8DL.d.ts +170 -0
- package/dist/cjs/storage-6W5MO46W.d.ts +50 -0
- package/dist/cjs/storage-CHNote8s.d.ts +81 -0
- package/dist/cjs/storage-DjCv5IPh.d.ts +81 -0
- package/dist/cjs/types-CKd3Xoi1.d.ts +180 -0
- package/dist/cjs/types-DIt9uAUy.d.ts +180 -0
- package/dist/cjs/upto/client/index.d.ts +34 -0
- package/dist/cjs/upto/client/index.js +509 -0
- package/dist/cjs/upto/client/index.js.map +1 -0
- package/dist/cjs/upto/facilitator/index.d.ts +54 -0
- package/dist/cjs/upto/facilitator/index.js +1313 -0
- package/dist/cjs/upto/facilitator/index.js.map +1 -0
- package/dist/cjs/upto/server/index.d.ts +69 -0
- package/dist/cjs/upto/server/index.js +296 -0
- package/dist/cjs/upto/server/index.js.map +1 -0
- package/dist/cjs/v1/index.d.ts +40 -0
- package/dist/cjs/v1/index.js +199 -0
- package/dist/cjs/v1/index.js.map +1 -0
- package/dist/esm/auth-capture/client/index.d.mts +44 -0
- package/dist/esm/auth-capture/client/index.mjs +8 -0
- package/dist/esm/auth-capture/client/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/client/file-storage.d.mts +47 -0
- package/dist/esm/batch-settlement/client/file-storage.mjs +63 -0
- package/dist/esm/batch-settlement/client/file-storage.mjs.map +1 -0
- package/dist/esm/batch-settlement/client/index.d.mts +111 -0
- package/dist/esm/batch-settlement/client/index.mjs +58 -0
- package/dist/esm/batch-settlement/client/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/facilitator/index.d.mts +72 -0
- package/dist/esm/batch-settlement/facilitator/index.mjs +1252 -0
- package/dist/esm/batch-settlement/facilitator/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/file-storage.d.mts +53 -0
- package/dist/esm/batch-settlement/server/file-storage.mjs +128 -0
- package/dist/esm/batch-settlement/server/file-storage.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/index.d.mts +491 -0
- package/dist/esm/batch-settlement/server/index.mjs +1640 -0
- package/dist/esm/batch-settlement/server/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/redis-storage.d.mts +87 -0
- package/dist/esm/batch-settlement/server/redis-storage.mjs +156 -0
- package/dist/esm/batch-settlement/server/redis-storage.mjs.map +1 -0
- package/dist/esm/chunk-2EUQTNJO.mjs +38 -0
- package/dist/esm/chunk-2EUQTNJO.mjs.map +1 -0
- package/dist/esm/chunk-3WZF6722.mjs +36 -0
- package/dist/esm/chunk-3WZF6722.mjs.map +1 -0
- package/dist/esm/chunk-E4Z7PNXC.mjs +275 -0
- package/dist/esm/chunk-E4Z7PNXC.mjs.map +1 -0
- package/dist/esm/chunk-GQVMVP4N.mjs +911 -0
- package/dist/esm/chunk-GQVMVP4N.mjs.map +1 -0
- package/dist/esm/chunk-H2EYJIZL.mjs +489 -0
- package/dist/esm/chunk-H2EYJIZL.mjs.map +1 -0
- package/dist/esm/chunk-H3KPLYGI.mjs +152 -0
- package/dist/esm/chunk-H3KPLYGI.mjs.map +1 -0
- package/dist/esm/chunk-HYABYUBD.mjs +432 -0
- package/dist/esm/chunk-HYABYUBD.mjs.map +1 -0
- package/dist/esm/chunk-I2DVUHM5.mjs +123 -0
- package/dist/esm/chunk-I2DVUHM5.mjs.map +1 -0
- package/dist/esm/chunk-JK7SLLF7.mjs +34 -0
- package/dist/esm/chunk-JK7SLLF7.mjs.map +1 -0
- package/dist/esm/chunk-JNT7C46S.mjs +352 -0
- package/dist/esm/chunk-JNT7C46S.mjs.map +1 -0
- package/dist/esm/chunk-MACPBXCT.mjs +415 -0
- package/dist/esm/chunk-MACPBXCT.mjs.map +1 -0
- package/dist/esm/chunk-P3QOX3QZ.mjs +113 -0
- package/dist/esm/chunk-P3QOX3QZ.mjs.map +1 -0
- package/dist/esm/chunk-QVATVA3J.mjs +47 -0
- package/dist/esm/chunk-QVATVA3J.mjs.map +1 -0
- package/dist/esm/chunk-SHJFA25H.mjs +159 -0
- package/dist/esm/chunk-SHJFA25H.mjs.map +1 -0
- package/dist/esm/chunk-TW7Z65AO.mjs +34 -0
- package/dist/esm/chunk-TW7Z65AO.mjs.map +1 -0
- package/dist/esm/chunk-U4HCGTLU.mjs +35 -0
- package/dist/esm/chunk-U4HCGTLU.mjs.map +1 -0
- package/dist/esm/chunk-VS3RYAYE.mjs +80 -0
- package/dist/esm/chunk-VS3RYAYE.mjs.map +1 -0
- package/dist/esm/chunk-W6ON4LG2.mjs +39 -0
- package/dist/esm/chunk-W6ON4LG2.mjs.map +1 -0
- package/dist/esm/chunk-XG2JLZVJ.mjs +627 -0
- package/dist/esm/chunk-XG2JLZVJ.mjs.map +1 -0
- package/dist/esm/chunk-ZCJRY5LQ.mjs +162 -0
- package/dist/esm/chunk-ZCJRY5LQ.mjs.map +1 -0
- package/dist/esm/client/agent-wallet.d.mts +69 -0
- package/dist/esm/client/agent-wallet.mjs +36 -0
- package/dist/esm/client/agent-wallet.mjs.map +1 -0
- package/dist/esm/exact/client/index.d.mts +63 -0
- package/dist/esm/exact/client/index.mjs +25 -0
- package/dist/esm/exact/client/index.mjs.map +1 -0
- package/dist/esm/exact/facilitator/index.d.mts +141 -0
- package/dist/esm/exact/facilitator/index.mjs +694 -0
- package/dist/esm/exact/facilitator/index.mjs.map +1 -0
- package/dist/esm/exact/server/index.d.mts +118 -0
- package/dist/esm/exact/server/index.mjs +153 -0
- package/dist/esm/exact/server/index.mjs.map +1 -0
- package/dist/esm/exact/v1/client/index.d.mts +38 -0
- package/dist/esm/exact/v1/client/index.mjs +12 -0
- package/dist/esm/exact/v1/client/index.mjs.map +1 -0
- package/dist/esm/exact/v1/facilitator/index.d.mts +84 -0
- package/dist/esm/exact/v1/facilitator/index.mjs +12 -0
- package/dist/esm/exact/v1/facilitator/index.mjs.map +1 -0
- package/dist/esm/facilitator/agent-wallet.d.mts +109 -0
- package/dist/esm/facilitator/agent-wallet.mjs +74 -0
- package/dist/esm/facilitator/agent-wallet.mjs.map +1 -0
- package/dist/esm/index.d.mts +338 -0
- package/dist/esm/index.mjs +144 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/permit2-DhJRUcgY.d.mts +729 -0
- package/dist/esm/rpc-DULZzRne.d.mts +13 -0
- package/dist/esm/scheme-CkNhpXrG.d.mts +307 -0
- package/dist/esm/scheme-D8ZbykGV.d.mts +47 -0
- package/dist/esm/signer-BFelv8DL.d.mts +170 -0
- package/dist/esm/storage-6W5MO46W.d.mts +50 -0
- package/dist/esm/storage-BEzTEiUr.d.mts +81 -0
- package/dist/esm/types-DIt9uAUy.d.mts +180 -0
- package/dist/esm/upto/client/index.d.mts +34 -0
- package/dist/esm/upto/client/index.mjs +22 -0
- package/dist/esm/upto/client/index.mjs.map +1 -0
- package/dist/esm/upto/facilitator/index.d.mts +54 -0
- package/dist/esm/upto/facilitator/index.mjs +507 -0
- package/dist/esm/upto/facilitator/index.mjs.map +1 -0
- package/dist/esm/upto/server/index.d.mts +69 -0
- package/dist/esm/upto/server/index.mjs +124 -0
- package/dist/esm/upto/server/index.mjs.map +1 -0
- package/dist/esm/v1/index.d.mts +40 -0
- package/dist/esm/v1/index.mjs +18 -0
- package/dist/esm/v1/index.mjs.map +1 -0
- package/package.json +250 -0
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/exact/v1/facilitator/index.ts
|
|
21
|
+
var facilitator_exports = {};
|
|
22
|
+
__export(facilitator_exports, {
|
|
23
|
+
ExactEvmSchemeV1: () => ExactEvmSchemeV12
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(facilitator_exports);
|
|
26
|
+
|
|
27
|
+
// src/shared/extensions/gasSponsoring.ts
|
|
28
|
+
var import_viem5 = require("viem");
|
|
29
|
+
|
|
30
|
+
// src/constants.ts
|
|
31
|
+
var authorizationTypes = {
|
|
32
|
+
TransferWithAuthorization: [
|
|
33
|
+
{ name: "from", type: "address" },
|
|
34
|
+
{ name: "to", type: "address" },
|
|
35
|
+
{ name: "value", type: "uint256" },
|
|
36
|
+
{ name: "validAfter", type: "uint256" },
|
|
37
|
+
{ name: "validBefore", type: "uint256" },
|
|
38
|
+
{ name: "nonce", type: "bytes32" }
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
var eip3009ABI = [
|
|
42
|
+
{
|
|
43
|
+
inputs: [
|
|
44
|
+
{ name: "from", type: "address" },
|
|
45
|
+
{ name: "to", type: "address" },
|
|
46
|
+
{ name: "value", type: "uint256" },
|
|
47
|
+
{ name: "validAfter", type: "uint256" },
|
|
48
|
+
{ name: "validBefore", type: "uint256" },
|
|
49
|
+
{ name: "nonce", type: "bytes32" },
|
|
50
|
+
{ name: "v", type: "uint8" },
|
|
51
|
+
{ name: "r", type: "bytes32" },
|
|
52
|
+
{ name: "s", type: "bytes32" }
|
|
53
|
+
],
|
|
54
|
+
name: "transferWithAuthorization",
|
|
55
|
+
outputs: [],
|
|
56
|
+
stateMutability: "nonpayable",
|
|
57
|
+
type: "function"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
inputs: [
|
|
61
|
+
{ name: "from", type: "address" },
|
|
62
|
+
{ name: "to", type: "address" },
|
|
63
|
+
{ name: "value", type: "uint256" },
|
|
64
|
+
{ name: "validAfter", type: "uint256" },
|
|
65
|
+
{ name: "validBefore", type: "uint256" },
|
|
66
|
+
{ name: "nonce", type: "bytes32" },
|
|
67
|
+
{ name: "signature", type: "bytes" }
|
|
68
|
+
],
|
|
69
|
+
name: "transferWithAuthorization",
|
|
70
|
+
outputs: [],
|
|
71
|
+
stateMutability: "nonpayable",
|
|
72
|
+
type: "function"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
inputs: [{ name: "account", type: "address" }],
|
|
76
|
+
name: "balanceOf",
|
|
77
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
78
|
+
stateMutability: "view",
|
|
79
|
+
type: "function"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
inputs: [],
|
|
83
|
+
name: "version",
|
|
84
|
+
outputs: [{ name: "", type: "string" }],
|
|
85
|
+
stateMutability: "view",
|
|
86
|
+
type: "function"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
inputs: [],
|
|
90
|
+
name: "name",
|
|
91
|
+
outputs: [{ name: "", type: "string" }],
|
|
92
|
+
stateMutability: "view",
|
|
93
|
+
type: "function"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
inputs: [
|
|
97
|
+
{ name: "authorizer", type: "address" },
|
|
98
|
+
{ name: "nonce", type: "bytes32" }
|
|
99
|
+
],
|
|
100
|
+
name: "authorizationState",
|
|
101
|
+
outputs: [{ name: "", type: "bool" }],
|
|
102
|
+
stateMutability: "view",
|
|
103
|
+
type: "function"
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
// src/utils.ts
|
|
108
|
+
var import_viem = require("viem");
|
|
109
|
+
|
|
110
|
+
// src/exact/client/eip2612.ts
|
|
111
|
+
var import_viem2 = require("viem");
|
|
112
|
+
|
|
113
|
+
// src/exact/client/erc20approval.ts
|
|
114
|
+
var import_viem3 = require("viem");
|
|
115
|
+
|
|
116
|
+
// src/shared/rpc.ts
|
|
117
|
+
var import_viem4 = require("viem");
|
|
118
|
+
|
|
119
|
+
// src/shared/extensions/builderCode.ts
|
|
120
|
+
var BUILDER_CODE_KEY = "builder-code";
|
|
121
|
+
var BUILDER_CODE_RESOLVER = async (context, ctx) => {
|
|
122
|
+
const ext = context.getExtension(BUILDER_CODE_KEY);
|
|
123
|
+
if (!ext?.buildDataSuffix) {
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
return ext.buildDataSuffix(ctx);
|
|
127
|
+
};
|
|
128
|
+
var DATA_SUFFIX_RESOLVERS = [BUILDER_CODE_RESOLVER];
|
|
129
|
+
async function resolveDataSuffix(context, ctx) {
|
|
130
|
+
if (!context) {
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
const parts = [];
|
|
134
|
+
for (const resolver of DATA_SUFFIX_RESOLVERS) {
|
|
135
|
+
const suffix = await resolver(context, ctx);
|
|
136
|
+
if (suffix && suffix !== "0x" && suffix.length > 2) {
|
|
137
|
+
parts.push(suffix);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (parts.length === 0) {
|
|
141
|
+
return void 0;
|
|
142
|
+
}
|
|
143
|
+
if (parts.length === 1) {
|
|
144
|
+
return parts[0];
|
|
145
|
+
}
|
|
146
|
+
return parts.reduce((acc, part, index) => {
|
|
147
|
+
if (index === 0) {
|
|
148
|
+
return part;
|
|
149
|
+
}
|
|
150
|
+
const stripped = part.startsWith("0x") ? part.slice(2) : part;
|
|
151
|
+
return `${acc}${stripped}`;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/exact/v1/facilitator/scheme.ts
|
|
156
|
+
var import_viem9 = require("viem");
|
|
157
|
+
|
|
158
|
+
// src/exact/v1/client/scheme.ts
|
|
159
|
+
var import_viem6 = require("viem");
|
|
160
|
+
|
|
161
|
+
// src/v1/index.ts
|
|
162
|
+
var EVM_NETWORK_CHAIN_ID_MAP = {
|
|
163
|
+
ethereum: 1,
|
|
164
|
+
sepolia: 11155111,
|
|
165
|
+
abstract: 2741,
|
|
166
|
+
"abstract-testnet": 11124,
|
|
167
|
+
"base-sepolia": 84532,
|
|
168
|
+
base: 8453,
|
|
169
|
+
"avalanche-fuji": 43113,
|
|
170
|
+
avalanche: 43114,
|
|
171
|
+
iotex: 4689,
|
|
172
|
+
sei: 1329,
|
|
173
|
+
"sei-testnet": 1328,
|
|
174
|
+
polygon: 137,
|
|
175
|
+
"polygon-amoy": 80002,
|
|
176
|
+
peaq: 3338,
|
|
177
|
+
story: 1514,
|
|
178
|
+
educhain: 41923,
|
|
179
|
+
"skale-base-sepolia": 324705682,
|
|
180
|
+
megaeth: 4326,
|
|
181
|
+
monad: 143,
|
|
182
|
+
stable: 988,
|
|
183
|
+
"stable-testnet": 2201
|
|
184
|
+
};
|
|
185
|
+
var NETWORKS = Object.keys(EVM_NETWORK_CHAIN_ID_MAP);
|
|
186
|
+
function getEvmChainIdV1(network) {
|
|
187
|
+
const chainId = EVM_NETWORK_CHAIN_ID_MAP[network];
|
|
188
|
+
if (!chainId) {
|
|
189
|
+
throw new Error(`Unsupported v1 network: ${network}`);
|
|
190
|
+
}
|
|
191
|
+
return chainId;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// src/exact/facilitator/errors.ts
|
|
195
|
+
var ErrInvalidScheme = "invalid_exact_evm_scheme";
|
|
196
|
+
var ErrNetworkMismatch = "invalid_exact_evm_network_mismatch";
|
|
197
|
+
var ErrMissingEip712Domain = "invalid_exact_evm_missing_eip712_domain";
|
|
198
|
+
var ErrRecipientMismatch = "invalid_exact_evm_recipient_mismatch";
|
|
199
|
+
var ErrInvalidSignature = "invalid_exact_evm_signature";
|
|
200
|
+
var ErrValidBeforeExpired = "invalid_exact_evm_payload_authorization_valid_before";
|
|
201
|
+
var ErrValidAfterInFuture = "invalid_exact_evm_payload_authorization_valid_after";
|
|
202
|
+
var ErrInvalidAuthorizationValue = "invalid_exact_evm_authorization_value";
|
|
203
|
+
var ErrUndeployedSmartWallet = "invalid_exact_evm_payload_undeployed_smart_wallet";
|
|
204
|
+
var ErrTransactionFailed = "invalid_exact_evm_transaction_failed";
|
|
205
|
+
var ErrEip3009TokenNameMismatch = "invalid_exact_evm_token_name_mismatch";
|
|
206
|
+
var ErrEip3009TokenVersionMismatch = "invalid_exact_evm_token_version_mismatch";
|
|
207
|
+
var ErrEip3009NotSupported = "invalid_exact_evm_eip3009_not_supported";
|
|
208
|
+
var ErrEip3009NonceAlreadyUsed = "invalid_exact_evm_nonce_already_used";
|
|
209
|
+
var ErrEip3009InsufficientBalance = "invalid_exact_evm_insufficient_balance";
|
|
210
|
+
var ErrEip3009SimulationFailed = "invalid_exact_evm_transaction_simulation_failed";
|
|
211
|
+
var ErrFactoryNotAllowed = "eip6492_factory_not_allowed";
|
|
212
|
+
|
|
213
|
+
// src/exact/facilitator/eip3009-utils.ts
|
|
214
|
+
var import_viem8 = require("viem");
|
|
215
|
+
|
|
216
|
+
// src/multicall.ts
|
|
217
|
+
var import_viem7 = require("viem");
|
|
218
|
+
var MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
219
|
+
var multicall3ABI = [
|
|
220
|
+
{
|
|
221
|
+
inputs: [
|
|
222
|
+
{ name: "requireSuccess", type: "bool" },
|
|
223
|
+
{
|
|
224
|
+
name: "calls",
|
|
225
|
+
type: "tuple[]",
|
|
226
|
+
components: [
|
|
227
|
+
{ name: "target", type: "address" },
|
|
228
|
+
{ name: "callData", type: "bytes" }
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
name: "tryAggregate",
|
|
233
|
+
outputs: [
|
|
234
|
+
{
|
|
235
|
+
name: "returnData",
|
|
236
|
+
type: "tuple[]",
|
|
237
|
+
components: [
|
|
238
|
+
{ name: "success", type: "bool" },
|
|
239
|
+
{ name: "returnData", type: "bytes" }
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
stateMutability: "payable",
|
|
244
|
+
type: "function"
|
|
245
|
+
}
|
|
246
|
+
];
|
|
247
|
+
async function multicall(readContract, calls) {
|
|
248
|
+
const aggregateCalls = calls.map((call) => {
|
|
249
|
+
if ("callData" in call) {
|
|
250
|
+
return { target: call.address, callData: call.callData };
|
|
251
|
+
}
|
|
252
|
+
const callData = (0, import_viem7.encodeFunctionData)({
|
|
253
|
+
abi: call.abi,
|
|
254
|
+
functionName: call.functionName,
|
|
255
|
+
args: call.args
|
|
256
|
+
});
|
|
257
|
+
return { target: call.address, callData };
|
|
258
|
+
});
|
|
259
|
+
const rawResults = await readContract({
|
|
260
|
+
address: MULTICALL3_ADDRESS,
|
|
261
|
+
abi: multicall3ABI,
|
|
262
|
+
functionName: "tryAggregate",
|
|
263
|
+
args: [false, aggregateCalls]
|
|
264
|
+
});
|
|
265
|
+
return rawResults.map((raw, i) => {
|
|
266
|
+
if (!raw.success) {
|
|
267
|
+
return {
|
|
268
|
+
status: "failure",
|
|
269
|
+
error: new Error(`multicall: call reverted (returnData: ${raw.returnData})`)
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
const call = calls[i];
|
|
273
|
+
if ("callData" in call) {
|
|
274
|
+
return { status: "success", result: void 0 };
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
const decoded = (0, import_viem7.decodeFunctionResult)({
|
|
278
|
+
abi: call.abi,
|
|
279
|
+
functionName: call.functionName,
|
|
280
|
+
data: raw.returnData
|
|
281
|
+
});
|
|
282
|
+
return { status: "success", result: decoded };
|
|
283
|
+
} catch (err) {
|
|
284
|
+
return {
|
|
285
|
+
status: "failure",
|
|
286
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/exact/facilitator/eip3009-utils.ts
|
|
293
|
+
async function simulateEip3009Transfer(signer, erc20Address, payload, eip6492Deployment) {
|
|
294
|
+
const auth = payload.authorization;
|
|
295
|
+
const transferArgs = [
|
|
296
|
+
(0, import_viem8.getAddress)(auth.from),
|
|
297
|
+
(0, import_viem8.getAddress)(auth.to),
|
|
298
|
+
BigInt(auth.value),
|
|
299
|
+
BigInt(auth.validAfter),
|
|
300
|
+
BigInt(auth.validBefore),
|
|
301
|
+
auth.nonce
|
|
302
|
+
];
|
|
303
|
+
if (eip6492Deployment) {
|
|
304
|
+
const { signature: innerSignature } = (0, import_viem8.parseErc6492Signature)(payload.signature);
|
|
305
|
+
const transferCalldata = (0, import_viem8.encodeFunctionData)({
|
|
306
|
+
abi: eip3009ABI,
|
|
307
|
+
functionName: "transferWithAuthorization",
|
|
308
|
+
args: [...transferArgs, innerSignature]
|
|
309
|
+
});
|
|
310
|
+
try {
|
|
311
|
+
const results = await multicall(signer.readContract.bind(signer), [
|
|
312
|
+
{
|
|
313
|
+
address: (0, import_viem8.getAddress)(eip6492Deployment.factoryAddress),
|
|
314
|
+
callData: eip6492Deployment.factoryCalldata
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
address: erc20Address,
|
|
318
|
+
callData: transferCalldata
|
|
319
|
+
}
|
|
320
|
+
]);
|
|
321
|
+
return results[1]?.status === "success";
|
|
322
|
+
} catch {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const sig = payload.signature;
|
|
327
|
+
const sigLength = sig.startsWith("0x") ? sig.length - 2 : sig.length;
|
|
328
|
+
const isECDSA = sigLength === 130;
|
|
329
|
+
try {
|
|
330
|
+
if (isECDSA) {
|
|
331
|
+
const parsedSig = (0, import_viem8.parseSignature)(sig);
|
|
332
|
+
await signer.readContract({
|
|
333
|
+
address: erc20Address,
|
|
334
|
+
abi: eip3009ABI,
|
|
335
|
+
functionName: "transferWithAuthorization",
|
|
336
|
+
args: [
|
|
337
|
+
...transferArgs,
|
|
338
|
+
parsedSig.v ?? parsedSig.yParity,
|
|
339
|
+
parsedSig.r,
|
|
340
|
+
parsedSig.s
|
|
341
|
+
]
|
|
342
|
+
});
|
|
343
|
+
} else {
|
|
344
|
+
await signer.readContract({
|
|
345
|
+
address: erc20Address,
|
|
346
|
+
abi: eip3009ABI,
|
|
347
|
+
functionName: "transferWithAuthorization",
|
|
348
|
+
args: [...transferArgs, sig]
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
return true;
|
|
352
|
+
} catch {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
async function diagnoseEip3009SimulationFailure(signer, erc20Address, payload, requirements, amountRequired) {
|
|
357
|
+
const payer = payload.authorization.from;
|
|
358
|
+
const diagnosticCalls = [
|
|
359
|
+
{
|
|
360
|
+
address: erc20Address,
|
|
361
|
+
abi: eip3009ABI,
|
|
362
|
+
functionName: "balanceOf",
|
|
363
|
+
args: [payload.authorization.from]
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
address: erc20Address,
|
|
367
|
+
abi: eip3009ABI,
|
|
368
|
+
functionName: "name"
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
address: erc20Address,
|
|
372
|
+
abi: eip3009ABI,
|
|
373
|
+
functionName: "version"
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
address: erc20Address,
|
|
377
|
+
abi: eip3009ABI,
|
|
378
|
+
functionName: "authorizationState",
|
|
379
|
+
args: [payload.authorization.from, payload.authorization.nonce]
|
|
380
|
+
}
|
|
381
|
+
];
|
|
382
|
+
try {
|
|
383
|
+
const results = await multicall(signer.readContract.bind(signer), diagnosticCalls);
|
|
384
|
+
const [balanceResult, nameResult, versionResult, authStateResult] = results;
|
|
385
|
+
if (authStateResult.status === "failure") {
|
|
386
|
+
return { isValid: false, invalidReason: ErrEip3009NotSupported, payer };
|
|
387
|
+
}
|
|
388
|
+
if (authStateResult.status === "success" && authStateResult.result === true) {
|
|
389
|
+
return { isValid: false, invalidReason: ErrEip3009NonceAlreadyUsed, payer };
|
|
390
|
+
}
|
|
391
|
+
if (nameResult.status === "success" && requirements.extra?.name && nameResult.result !== requirements.extra.name) {
|
|
392
|
+
return { isValid: false, invalidReason: ErrEip3009TokenNameMismatch, payer };
|
|
393
|
+
}
|
|
394
|
+
if (versionResult.status === "success" && requirements.extra?.version && versionResult.result !== requirements.extra.version) {
|
|
395
|
+
return { isValid: false, invalidReason: ErrEip3009TokenVersionMismatch, payer };
|
|
396
|
+
}
|
|
397
|
+
if (balanceResult.status === "success") {
|
|
398
|
+
const balance = balanceResult.result;
|
|
399
|
+
if (balance < BigInt(amountRequired)) {
|
|
400
|
+
return {
|
|
401
|
+
isValid: false,
|
|
402
|
+
invalidReason: ErrEip3009InsufficientBalance,
|
|
403
|
+
payer
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
} catch {
|
|
408
|
+
}
|
|
409
|
+
return { isValid: false, invalidReason: ErrEip3009SimulationFailed, payer };
|
|
410
|
+
}
|
|
411
|
+
async function executeTransferWithAuthorization(signer, erc20Address, payload, dataSuffix) {
|
|
412
|
+
const { signature } = (0, import_viem8.parseErc6492Signature)(payload.signature);
|
|
413
|
+
const signatureLength = signature.startsWith("0x") ? signature.length - 2 : signature.length;
|
|
414
|
+
const isECDSA = signatureLength === 130;
|
|
415
|
+
const auth = payload.authorization;
|
|
416
|
+
const baseArgs = [
|
|
417
|
+
(0, import_viem8.getAddress)(auth.from),
|
|
418
|
+
(0, import_viem8.getAddress)(auth.to),
|
|
419
|
+
BigInt(auth.value),
|
|
420
|
+
BigInt(auth.validAfter),
|
|
421
|
+
BigInt(auth.validBefore),
|
|
422
|
+
auth.nonce
|
|
423
|
+
];
|
|
424
|
+
let signatureArgs;
|
|
425
|
+
if (isECDSA) {
|
|
426
|
+
const parsedSig = (0, import_viem8.parseSignature)(signature);
|
|
427
|
+
signatureArgs = [
|
|
428
|
+
parsedSig.v || parsedSig.yParity,
|
|
429
|
+
parsedSig.r,
|
|
430
|
+
parsedSig.s
|
|
431
|
+
];
|
|
432
|
+
} else {
|
|
433
|
+
signatureArgs = [signature];
|
|
434
|
+
}
|
|
435
|
+
return signer.writeContract({
|
|
436
|
+
address: erc20Address,
|
|
437
|
+
abi: eip3009ABI,
|
|
438
|
+
functionName: "transferWithAuthorization",
|
|
439
|
+
args: [...baseArgs, ...signatureArgs],
|
|
440
|
+
dataSuffix
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// src/exact/v1/facilitator/scheme.ts
|
|
445
|
+
var ExactEvmSchemeV12 = class {
|
|
446
|
+
/**
|
|
447
|
+
* Creates a new ExactEvmFacilitatorV1 instance.
|
|
448
|
+
*
|
|
449
|
+
* @param signer - The EVM signer for facilitator operations
|
|
450
|
+
* @param config - Optional configuration for the facilitator
|
|
451
|
+
*/
|
|
452
|
+
constructor(signer, config) {
|
|
453
|
+
this.signer = signer;
|
|
454
|
+
this.scheme = "exact";
|
|
455
|
+
this.caipFamily = "eip155:*";
|
|
456
|
+
this.config = {
|
|
457
|
+
eip6492AllowedFactories: config?.eip6492AllowedFactories ?? [],
|
|
458
|
+
simulateInSettle: config?.simulateInSettle ?? false
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Get mechanism-specific extra data for the supported kinds endpoint.
|
|
463
|
+
* For EVM, no extra data is needed.
|
|
464
|
+
*
|
|
465
|
+
* @param _ - The network identifier (unused for EVM)
|
|
466
|
+
* @returns undefined (EVM has no extra data)
|
|
467
|
+
*/
|
|
468
|
+
getExtra(_) {
|
|
469
|
+
return void 0;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Get signer addresses used by this facilitator.
|
|
473
|
+
* Returns all addresses this facilitator can use for signing/settling transactions.
|
|
474
|
+
*
|
|
475
|
+
* @param _ - The network identifier (unused for EVM, addresses are network-agnostic)
|
|
476
|
+
* @returns Array of facilitator wallet addresses
|
|
477
|
+
*/
|
|
478
|
+
getSigners(_) {
|
|
479
|
+
return [...this.signer.getAddresses()];
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Verifies a payment payload (V1).
|
|
483
|
+
*
|
|
484
|
+
* @param payload - The payment payload to verify
|
|
485
|
+
* @param requirements - The payment requirements
|
|
486
|
+
* @returns Promise resolving to verification response
|
|
487
|
+
*/
|
|
488
|
+
async verify(payload, requirements) {
|
|
489
|
+
return this._verify(payload, requirements);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Settles a payment by executing the transfer (V1).
|
|
493
|
+
*
|
|
494
|
+
* @param payload - The payment payload to settle
|
|
495
|
+
* @param requirements - The payment requirements
|
|
496
|
+
* @param context - Optional facilitator context for extension capabilities
|
|
497
|
+
* @returns Promise resolving to settlement response
|
|
498
|
+
*/
|
|
499
|
+
async settle(payload, requirements, context) {
|
|
500
|
+
const payloadV1 = payload;
|
|
501
|
+
const exactEvmPayload = payload.payload;
|
|
502
|
+
const valid = await this._verify(payload, requirements, {
|
|
503
|
+
simulate: this.config.simulateInSettle ?? false
|
|
504
|
+
});
|
|
505
|
+
if (!valid.isValid) {
|
|
506
|
+
return {
|
|
507
|
+
success: false,
|
|
508
|
+
network: payloadV1.network,
|
|
509
|
+
transaction: "",
|
|
510
|
+
errorReason: valid.invalidReason ?? ErrInvalidScheme,
|
|
511
|
+
payer: exactEvmPayload.authorization.from
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
try {
|
|
515
|
+
const { address: factoryAddress, data: factoryCalldata } = (0, import_viem9.parseErc6492Signature)(
|
|
516
|
+
exactEvmPayload.signature
|
|
517
|
+
);
|
|
518
|
+
if (factoryAddress && factoryCalldata && !(0, import_viem9.isAddressEqual)(factoryAddress, "0x0000000000000000000000000000000000000000")) {
|
|
519
|
+
const payerAddress = exactEvmPayload.authorization.from;
|
|
520
|
+
const bytecode = await this.signer.getCode({ address: payerAddress });
|
|
521
|
+
if (!bytecode || bytecode === "0x") {
|
|
522
|
+
const normalizedFactory = factoryAddress.toLowerCase();
|
|
523
|
+
const isAllowed = (this.config.eip6492AllowedFactories ?? []).some(
|
|
524
|
+
(allowed) => allowed.toLowerCase() === normalizedFactory
|
|
525
|
+
);
|
|
526
|
+
if (!isAllowed) {
|
|
527
|
+
return {
|
|
528
|
+
success: false,
|
|
529
|
+
errorReason: ErrFactoryNotAllowed,
|
|
530
|
+
transaction: "",
|
|
531
|
+
network: payloadV1.network,
|
|
532
|
+
payer: exactEvmPayload.authorization.from
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
const deployTx = await this.signer.sendTransaction({
|
|
536
|
+
to: factoryAddress,
|
|
537
|
+
data: factoryCalldata
|
|
538
|
+
});
|
|
539
|
+
await this.signer.waitForTransactionReceipt({ hash: deployTx });
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
const dataSuffix = await resolveDataSuffix(context, {
|
|
543
|
+
paymentPayload: payload,
|
|
544
|
+
paymentRequirements: requirements
|
|
545
|
+
});
|
|
546
|
+
const tx = await executeTransferWithAuthorization(
|
|
547
|
+
this.signer,
|
|
548
|
+
(0, import_viem9.getAddress)(requirements.asset),
|
|
549
|
+
exactEvmPayload,
|
|
550
|
+
dataSuffix
|
|
551
|
+
);
|
|
552
|
+
const receipt = await this.signer.waitForTransactionReceipt({ hash: tx });
|
|
553
|
+
if (receipt.status !== "success") {
|
|
554
|
+
return {
|
|
555
|
+
success: false,
|
|
556
|
+
errorReason: ErrTransactionFailed,
|
|
557
|
+
transaction: tx,
|
|
558
|
+
network: payloadV1.network,
|
|
559
|
+
payer: exactEvmPayload.authorization.from
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
return {
|
|
563
|
+
success: true,
|
|
564
|
+
transaction: tx,
|
|
565
|
+
network: payloadV1.network,
|
|
566
|
+
payer: exactEvmPayload.authorization.from
|
|
567
|
+
};
|
|
568
|
+
} catch (error) {
|
|
569
|
+
return {
|
|
570
|
+
success: false,
|
|
571
|
+
errorReason: error instanceof Error ? error.message : ErrTransactionFailed,
|
|
572
|
+
transaction: "",
|
|
573
|
+
network: payloadV1.network,
|
|
574
|
+
payer: exactEvmPayload.authorization.from
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Internal verify with optional simulation control.
|
|
580
|
+
*
|
|
581
|
+
* @param payload - The payment payload to verify
|
|
582
|
+
* @param requirements - The payment requirements
|
|
583
|
+
* @param options - Verification options (e.g. simulate)
|
|
584
|
+
* @returns Promise resolving to verification response
|
|
585
|
+
*/
|
|
586
|
+
async _verify(payload, requirements, options) {
|
|
587
|
+
const requirementsV1 = requirements;
|
|
588
|
+
const payloadV1 = payload;
|
|
589
|
+
const exactEvmPayload = payload.payload;
|
|
590
|
+
const payer = exactEvmPayload.authorization.from;
|
|
591
|
+
let eip6492Deployment;
|
|
592
|
+
if (payloadV1.scheme !== "exact" || requirements.scheme !== "exact") {
|
|
593
|
+
return {
|
|
594
|
+
isValid: false,
|
|
595
|
+
invalidReason: ErrInvalidScheme,
|
|
596
|
+
payer
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
let chainId;
|
|
600
|
+
try {
|
|
601
|
+
chainId = getEvmChainIdV1(payloadV1.network);
|
|
602
|
+
} catch {
|
|
603
|
+
return {
|
|
604
|
+
isValid: false,
|
|
605
|
+
invalidReason: ErrNetworkMismatch,
|
|
606
|
+
payer
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
if (!requirements.extra?.name || !requirements.extra?.version) {
|
|
610
|
+
return {
|
|
611
|
+
isValid: false,
|
|
612
|
+
invalidReason: ErrMissingEip712Domain,
|
|
613
|
+
payer
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
const { name, version } = requirements.extra;
|
|
617
|
+
const erc20Address = (0, import_viem9.getAddress)(requirements.asset);
|
|
618
|
+
if (payloadV1.network !== requirements.network) {
|
|
619
|
+
return {
|
|
620
|
+
isValid: false,
|
|
621
|
+
invalidReason: ErrNetworkMismatch,
|
|
622
|
+
payer
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
const permitTypedData = {
|
|
626
|
+
types: authorizationTypes,
|
|
627
|
+
primaryType: "TransferWithAuthorization",
|
|
628
|
+
domain: {
|
|
629
|
+
name,
|
|
630
|
+
version,
|
|
631
|
+
chainId,
|
|
632
|
+
verifyingContract: erc20Address
|
|
633
|
+
},
|
|
634
|
+
message: {
|
|
635
|
+
from: exactEvmPayload.authorization.from,
|
|
636
|
+
to: exactEvmPayload.authorization.to,
|
|
637
|
+
value: BigInt(exactEvmPayload.authorization.value),
|
|
638
|
+
validAfter: BigInt(exactEvmPayload.authorization.validAfter),
|
|
639
|
+
validBefore: BigInt(exactEvmPayload.authorization.validBefore),
|
|
640
|
+
nonce: exactEvmPayload.authorization.nonce
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
let isValid = false;
|
|
644
|
+
try {
|
|
645
|
+
isValid = await this.signer.verifyTypedData({
|
|
646
|
+
address: payer,
|
|
647
|
+
...permitTypedData,
|
|
648
|
+
signature: exactEvmPayload.signature
|
|
649
|
+
});
|
|
650
|
+
} catch {
|
|
651
|
+
isValid = false;
|
|
652
|
+
}
|
|
653
|
+
const signature = exactEvmPayload.signature;
|
|
654
|
+
const sigLen = signature.startsWith("0x") ? signature.length - 2 : signature.length;
|
|
655
|
+
const erc6492Data = (0, import_viem9.parseErc6492Signature)(signature);
|
|
656
|
+
const hasDeploymentInfo = erc6492Data.address && erc6492Data.data && !(0, import_viem9.isAddressEqual)(erc6492Data.address, "0x0000000000000000000000000000000000000000");
|
|
657
|
+
if (hasDeploymentInfo) {
|
|
658
|
+
eip6492Deployment = {
|
|
659
|
+
factoryAddress: erc6492Data.address,
|
|
660
|
+
factoryCalldata: erc6492Data.data
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
if (!isValid) {
|
|
664
|
+
const isSmartWallet = sigLen > 130;
|
|
665
|
+
if (!isSmartWallet) {
|
|
666
|
+
return {
|
|
667
|
+
isValid: false,
|
|
668
|
+
invalidReason: ErrInvalidSignature,
|
|
669
|
+
payer
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
const bytecode = await this.signer.getCode({ address: payer });
|
|
673
|
+
const isDeployed = bytecode && bytecode !== "0x";
|
|
674
|
+
if (!isDeployed && !hasDeploymentInfo) {
|
|
675
|
+
return {
|
|
676
|
+
isValid: false,
|
|
677
|
+
invalidReason: ErrUndeployedSmartWallet,
|
|
678
|
+
payer
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
if ((0, import_viem9.getAddress)(exactEvmPayload.authorization.to) !== (0, import_viem9.getAddress)(requirements.payTo)) {
|
|
683
|
+
return {
|
|
684
|
+
isValid: false,
|
|
685
|
+
invalidReason: ErrRecipientMismatch,
|
|
686
|
+
payer
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
690
|
+
if (BigInt(exactEvmPayload.authorization.validBefore) < BigInt(now + 6)) {
|
|
691
|
+
return {
|
|
692
|
+
isValid: false,
|
|
693
|
+
invalidReason: ErrValidBeforeExpired,
|
|
694
|
+
payer
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
if (BigInt(exactEvmPayload.authorization.validAfter) > BigInt(now)) {
|
|
698
|
+
return {
|
|
699
|
+
isValid: false,
|
|
700
|
+
invalidReason: ErrValidAfterInFuture,
|
|
701
|
+
payer
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
if (BigInt(exactEvmPayload.authorization.value) !== BigInt(requirementsV1.maxAmountRequired)) {
|
|
705
|
+
return {
|
|
706
|
+
isValid: false,
|
|
707
|
+
invalidReason: ErrInvalidAuthorizationValue,
|
|
708
|
+
payer
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
if (options?.simulate !== false) {
|
|
712
|
+
const simulationSucceeded = await simulateEip3009Transfer(
|
|
713
|
+
this.signer,
|
|
714
|
+
erc20Address,
|
|
715
|
+
exactEvmPayload,
|
|
716
|
+
eip6492Deployment
|
|
717
|
+
);
|
|
718
|
+
if (!simulationSucceeded) {
|
|
719
|
+
return diagnoseEip3009SimulationFailure(
|
|
720
|
+
this.signer,
|
|
721
|
+
erc20Address,
|
|
722
|
+
exactEvmPayload,
|
|
723
|
+
requirements,
|
|
724
|
+
requirementsV1.maxAmountRequired
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return {
|
|
729
|
+
isValid: true,
|
|
730
|
+
invalidReason: void 0,
|
|
731
|
+
payer
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
736
|
+
0 && (module.exports = {
|
|
737
|
+
ExactEvmSchemeV1
|
|
738
|
+
});
|
|
739
|
+
//# sourceMappingURL=index.js.map
|