@huuduynvc/permit2-sdk 1.3.1
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/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/allowanceTransfer.d.ts +36 -0
- package/dist/constants.d.ts +13 -0
- package/dist/domain.d.ts +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/permit2-sdk.cjs.development.js +1566 -0
- package/dist/permit2-sdk.cjs.development.js.map +1 -0
- package/dist/permit2-sdk.cjs.production.min.js +2 -0
- package/dist/permit2-sdk.cjs.production.min.js.map +1 -0
- package/dist/permit2-sdk.esm.js +1546 -0
- package/dist/permit2-sdk.esm.js.map +1 -0
- package/dist/providers/AllowanceProvider.d.ts +17 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/signatureTransfer.d.ts +41 -0
- package/package.json +40 -0
@@ -0,0 +1,1546 @@
|
|
1
|
+
import invariant from 'tiny-invariant';
|
2
|
+
import { _TypedDataEncoder } from '@ethersproject/hash';
|
3
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
4
|
+
import { Contract } from '@ethersproject/contracts';
|
5
|
+
|
6
|
+
// @deprecated please use permit2Address(chainId: number)
|
7
|
+
var PERMIT2_ADDRESS = '0x000000000022D473030F116dDEE9F6B43aC78BA3';
|
8
|
+
function permit2Address(chainId) {
|
9
|
+
switch (chainId) {
|
10
|
+
case 324:
|
11
|
+
return '0x0000000000225e31D15943971F47aD3022F714Fa';
|
12
|
+
default:
|
13
|
+
return PERMIT2_ADDRESS;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
var MaxUint48 = /*#__PURE__*/BigNumber.from('0xffffffffffff');
|
17
|
+
var MaxUint160 = /*#__PURE__*/BigNumber.from('0xffffffffffffffffffffffffffffffffffffffff');
|
18
|
+
var MaxUint256 = /*#__PURE__*/BigNumber.from('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
|
19
|
+
// alias max types for their usages
|
20
|
+
// allowance transfer types
|
21
|
+
var MaxAllowanceTransferAmount = MaxUint160;
|
22
|
+
var MaxAllowanceExpiration = MaxUint48;
|
23
|
+
var MaxOrderedNonce = MaxUint48;
|
24
|
+
// signature transfer types
|
25
|
+
var MaxSignatureTransferAmount = MaxUint256;
|
26
|
+
var MaxUnorderedNonce = MaxUint256;
|
27
|
+
var MaxSigDeadline = MaxUint256;
|
28
|
+
var InstantExpiration = /*#__PURE__*/BigNumber.from(0);
|
29
|
+
|
30
|
+
var PERMIT2_DOMAIN_NAME = 'Permit2';
|
31
|
+
function permit2Domain(permit2Address, chainId) {
|
32
|
+
return {
|
33
|
+
name: PERMIT2_DOMAIN_NAME,
|
34
|
+
chainId: chainId,
|
35
|
+
verifyingContract: permit2Address
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
var PERMIT_DETAILS = [{
|
40
|
+
name: 'token',
|
41
|
+
type: 'address'
|
42
|
+
}, {
|
43
|
+
name: 'amount',
|
44
|
+
type: 'uint160'
|
45
|
+
}, {
|
46
|
+
name: 'expiration',
|
47
|
+
type: 'uint48'
|
48
|
+
}, {
|
49
|
+
name: 'nonce',
|
50
|
+
type: 'uint48'
|
51
|
+
}];
|
52
|
+
var PERMIT_TYPES = {
|
53
|
+
PermitSingle: [{
|
54
|
+
name: 'details',
|
55
|
+
type: 'PermitDetails'
|
56
|
+
}, {
|
57
|
+
name: 'spender',
|
58
|
+
type: 'address'
|
59
|
+
}, {
|
60
|
+
name: 'sigDeadline',
|
61
|
+
type: 'uint256'
|
62
|
+
}],
|
63
|
+
PermitDetails: PERMIT_DETAILS
|
64
|
+
};
|
65
|
+
var PERMIT_BATCH_TYPES = {
|
66
|
+
PermitBatch: [{
|
67
|
+
name: 'details',
|
68
|
+
type: 'PermitDetails[]'
|
69
|
+
}, {
|
70
|
+
name: 'spender',
|
71
|
+
type: 'address'
|
72
|
+
}, {
|
73
|
+
name: 'sigDeadline',
|
74
|
+
type: 'uint256'
|
75
|
+
}],
|
76
|
+
PermitDetails: PERMIT_DETAILS
|
77
|
+
};
|
78
|
+
function isPermit(permit) {
|
79
|
+
return !Array.isArray(permit.details);
|
80
|
+
}
|
81
|
+
var AllowanceTransfer = /*#__PURE__*/function () {
|
82
|
+
/**
|
83
|
+
* Cannot be constructed.
|
84
|
+
*/
|
85
|
+
function AllowanceTransfer() {}
|
86
|
+
// return the data to be sent in a eth_signTypedData RPC call
|
87
|
+
// for signing the given permit data
|
88
|
+
AllowanceTransfer.getPermitData = function getPermitData(permit, permit2Address, chainId) {
|
89
|
+
!MaxSigDeadline.gte(permit.sigDeadline) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SIG_DEADLINE_OUT_OF_RANGE') : invariant(false) : void 0;
|
90
|
+
var domain = permit2Domain(permit2Address, chainId);
|
91
|
+
if (isPermit(permit)) {
|
92
|
+
validatePermitDetails(permit.details);
|
93
|
+
return {
|
94
|
+
domain: domain,
|
95
|
+
types: PERMIT_TYPES,
|
96
|
+
values: permit
|
97
|
+
};
|
98
|
+
} else {
|
99
|
+
permit.details.forEach(validatePermitDetails);
|
100
|
+
return {
|
101
|
+
domain: domain,
|
102
|
+
types: PERMIT_BATCH_TYPES,
|
103
|
+
values: permit
|
104
|
+
};
|
105
|
+
}
|
106
|
+
};
|
107
|
+
AllowanceTransfer.hash = function hash(permit, permit2Address, chainId) {
|
108
|
+
var _AllowanceTransfer$ge = AllowanceTransfer.getPermitData(permit, permit2Address, chainId),
|
109
|
+
domain = _AllowanceTransfer$ge.domain,
|
110
|
+
types = _AllowanceTransfer$ge.types,
|
111
|
+
values = _AllowanceTransfer$ge.values;
|
112
|
+
return _TypedDataEncoder.hash(domain, types, values);
|
113
|
+
};
|
114
|
+
return AllowanceTransfer;
|
115
|
+
}();
|
116
|
+
function validatePermitDetails(details) {
|
117
|
+
!MaxOrderedNonce.gte(details.nonce) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NONCE_OUT_OF_RANGE') : invariant(false) : void 0;
|
118
|
+
!MaxAllowanceTransferAmount.gte(details.amount) ? process.env.NODE_ENV !== "production" ? invariant(false, 'AMOUNT_OUT_OF_RANGE') : invariant(false) : void 0;
|
119
|
+
!MaxAllowanceExpiration.gte(details.expiration) ? process.env.NODE_ENV !== "production" ? invariant(false, 'EXPIRATION_OUT_OF_RANGE') : invariant(false) : void 0;
|
120
|
+
}
|
121
|
+
|
122
|
+
function _regeneratorRuntime() {
|
123
|
+
_regeneratorRuntime = function () {
|
124
|
+
return e;
|
125
|
+
};
|
126
|
+
var t,
|
127
|
+
e = {},
|
128
|
+
r = Object.prototype,
|
129
|
+
n = r.hasOwnProperty,
|
130
|
+
o = Object.defineProperty || function (t, e, r) {
|
131
|
+
t[e] = r.value;
|
132
|
+
},
|
133
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
134
|
+
a = i.iterator || "@@iterator",
|
135
|
+
c = i.asyncIterator || "@@asyncIterator",
|
136
|
+
u = i.toStringTag || "@@toStringTag";
|
137
|
+
function define(t, e, r) {
|
138
|
+
return Object.defineProperty(t, e, {
|
139
|
+
value: r,
|
140
|
+
enumerable: !0,
|
141
|
+
configurable: !0,
|
142
|
+
writable: !0
|
143
|
+
}), t[e];
|
144
|
+
}
|
145
|
+
try {
|
146
|
+
define({}, "");
|
147
|
+
} catch (t) {
|
148
|
+
define = function (t, e, r) {
|
149
|
+
return t[e] = r;
|
150
|
+
};
|
151
|
+
}
|
152
|
+
function wrap(t, e, r, n) {
|
153
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
154
|
+
a = Object.create(i.prototype),
|
155
|
+
c = new Context(n || []);
|
156
|
+
return o(a, "_invoke", {
|
157
|
+
value: makeInvokeMethod(t, r, c)
|
158
|
+
}), a;
|
159
|
+
}
|
160
|
+
function tryCatch(t, e, r) {
|
161
|
+
try {
|
162
|
+
return {
|
163
|
+
type: "normal",
|
164
|
+
arg: t.call(e, r)
|
165
|
+
};
|
166
|
+
} catch (t) {
|
167
|
+
return {
|
168
|
+
type: "throw",
|
169
|
+
arg: t
|
170
|
+
};
|
171
|
+
}
|
172
|
+
}
|
173
|
+
e.wrap = wrap;
|
174
|
+
var h = "suspendedStart",
|
175
|
+
l = "suspendedYield",
|
176
|
+
f = "executing",
|
177
|
+
s = "completed",
|
178
|
+
y = {};
|
179
|
+
function Generator() {}
|
180
|
+
function GeneratorFunction() {}
|
181
|
+
function GeneratorFunctionPrototype() {}
|
182
|
+
var p = {};
|
183
|
+
define(p, a, function () {
|
184
|
+
return this;
|
185
|
+
});
|
186
|
+
var d = Object.getPrototypeOf,
|
187
|
+
v = d && d(d(values([])));
|
188
|
+
v && v !== r && n.call(v, a) && (p = v);
|
189
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
190
|
+
function defineIteratorMethods(t) {
|
191
|
+
["next", "throw", "return"].forEach(function (e) {
|
192
|
+
define(t, e, function (t) {
|
193
|
+
return this._invoke(e, t);
|
194
|
+
});
|
195
|
+
});
|
196
|
+
}
|
197
|
+
function AsyncIterator(t, e) {
|
198
|
+
function invoke(r, o, i, a) {
|
199
|
+
var c = tryCatch(t[r], t, o);
|
200
|
+
if ("throw" !== c.type) {
|
201
|
+
var u = c.arg,
|
202
|
+
h = u.value;
|
203
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
204
|
+
invoke("next", t, i, a);
|
205
|
+
}, function (t) {
|
206
|
+
invoke("throw", t, i, a);
|
207
|
+
}) : e.resolve(h).then(function (t) {
|
208
|
+
u.value = t, i(u);
|
209
|
+
}, function (t) {
|
210
|
+
return invoke("throw", t, i, a);
|
211
|
+
});
|
212
|
+
}
|
213
|
+
a(c.arg);
|
214
|
+
}
|
215
|
+
var r;
|
216
|
+
o(this, "_invoke", {
|
217
|
+
value: function (t, n) {
|
218
|
+
function callInvokeWithMethodAndArg() {
|
219
|
+
return new e(function (e, r) {
|
220
|
+
invoke(t, n, e, r);
|
221
|
+
});
|
222
|
+
}
|
223
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
224
|
+
}
|
225
|
+
});
|
226
|
+
}
|
227
|
+
function makeInvokeMethod(e, r, n) {
|
228
|
+
var o = h;
|
229
|
+
return function (i, a) {
|
230
|
+
if (o === f) throw new Error("Generator is already running");
|
231
|
+
if (o === s) {
|
232
|
+
if ("throw" === i) throw a;
|
233
|
+
return {
|
234
|
+
value: t,
|
235
|
+
done: !0
|
236
|
+
};
|
237
|
+
}
|
238
|
+
for (n.method = i, n.arg = a;;) {
|
239
|
+
var c = n.delegate;
|
240
|
+
if (c) {
|
241
|
+
var u = maybeInvokeDelegate(c, n);
|
242
|
+
if (u) {
|
243
|
+
if (u === y) continue;
|
244
|
+
return u;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
248
|
+
if (o === h) throw o = s, n.arg;
|
249
|
+
n.dispatchException(n.arg);
|
250
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
251
|
+
o = f;
|
252
|
+
var p = tryCatch(e, r, n);
|
253
|
+
if ("normal" === p.type) {
|
254
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
255
|
+
return {
|
256
|
+
value: p.arg,
|
257
|
+
done: n.done
|
258
|
+
};
|
259
|
+
}
|
260
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
261
|
+
}
|
262
|
+
};
|
263
|
+
}
|
264
|
+
function maybeInvokeDelegate(e, r) {
|
265
|
+
var n = r.method,
|
266
|
+
o = e.iterator[n];
|
267
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
268
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
269
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
270
|
+
var a = i.arg;
|
271
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
272
|
+
}
|
273
|
+
function pushTryEntry(t) {
|
274
|
+
var e = {
|
275
|
+
tryLoc: t[0]
|
276
|
+
};
|
277
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
278
|
+
}
|
279
|
+
function resetTryEntry(t) {
|
280
|
+
var e = t.completion || {};
|
281
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
282
|
+
}
|
283
|
+
function Context(t) {
|
284
|
+
this.tryEntries = [{
|
285
|
+
tryLoc: "root"
|
286
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
287
|
+
}
|
288
|
+
function values(e) {
|
289
|
+
if (e || "" === e) {
|
290
|
+
var r = e[a];
|
291
|
+
if (r) return r.call(e);
|
292
|
+
if ("function" == typeof e.next) return e;
|
293
|
+
if (!isNaN(e.length)) {
|
294
|
+
var o = -1,
|
295
|
+
i = function next() {
|
296
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
297
|
+
return next.value = t, next.done = !0, next;
|
298
|
+
};
|
299
|
+
return i.next = i;
|
300
|
+
}
|
301
|
+
}
|
302
|
+
throw new TypeError(typeof e + " is not iterable");
|
303
|
+
}
|
304
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
305
|
+
value: GeneratorFunctionPrototype,
|
306
|
+
configurable: !0
|
307
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
308
|
+
value: GeneratorFunction,
|
309
|
+
configurable: !0
|
310
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
311
|
+
var e = "function" == typeof t && t.constructor;
|
312
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
313
|
+
}, e.mark = function (t) {
|
314
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
315
|
+
}, e.awrap = function (t) {
|
316
|
+
return {
|
317
|
+
__await: t
|
318
|
+
};
|
319
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
320
|
+
return this;
|
321
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
322
|
+
void 0 === i && (i = Promise);
|
323
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
324
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
325
|
+
return t.done ? t.value : a.next();
|
326
|
+
});
|
327
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
328
|
+
return this;
|
329
|
+
}), define(g, "toString", function () {
|
330
|
+
return "[object Generator]";
|
331
|
+
}), e.keys = function (t) {
|
332
|
+
var e = Object(t),
|
333
|
+
r = [];
|
334
|
+
for (var n in e) r.push(n);
|
335
|
+
return r.reverse(), function next() {
|
336
|
+
for (; r.length;) {
|
337
|
+
var t = r.pop();
|
338
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
339
|
+
}
|
340
|
+
return next.done = !0, next;
|
341
|
+
};
|
342
|
+
}, e.values = values, Context.prototype = {
|
343
|
+
constructor: Context,
|
344
|
+
reset: function (e) {
|
345
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
346
|
+
},
|
347
|
+
stop: function () {
|
348
|
+
this.done = !0;
|
349
|
+
var t = this.tryEntries[0].completion;
|
350
|
+
if ("throw" === t.type) throw t.arg;
|
351
|
+
return this.rval;
|
352
|
+
},
|
353
|
+
dispatchException: function (e) {
|
354
|
+
if (this.done) throw e;
|
355
|
+
var r = this;
|
356
|
+
function handle(n, o) {
|
357
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
358
|
+
}
|
359
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
360
|
+
var i = this.tryEntries[o],
|
361
|
+
a = i.completion;
|
362
|
+
if ("root" === i.tryLoc) return handle("end");
|
363
|
+
if (i.tryLoc <= this.prev) {
|
364
|
+
var c = n.call(i, "catchLoc"),
|
365
|
+
u = n.call(i, "finallyLoc");
|
366
|
+
if (c && u) {
|
367
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
368
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
369
|
+
} else if (c) {
|
370
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
371
|
+
} else {
|
372
|
+
if (!u) throw new Error("try statement without catch or finally");
|
373
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
374
|
+
}
|
375
|
+
}
|
376
|
+
}
|
377
|
+
},
|
378
|
+
abrupt: function (t, e) {
|
379
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
380
|
+
var o = this.tryEntries[r];
|
381
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
382
|
+
var i = o;
|
383
|
+
break;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
387
|
+
var a = i ? i.completion : {};
|
388
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
389
|
+
},
|
390
|
+
complete: function (t, e) {
|
391
|
+
if ("throw" === t.type) throw t.arg;
|
392
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
393
|
+
},
|
394
|
+
finish: function (t) {
|
395
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
396
|
+
var r = this.tryEntries[e];
|
397
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
398
|
+
}
|
399
|
+
},
|
400
|
+
catch: function (t) {
|
401
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
402
|
+
var r = this.tryEntries[e];
|
403
|
+
if (r.tryLoc === t) {
|
404
|
+
var n = r.completion;
|
405
|
+
if ("throw" === n.type) {
|
406
|
+
var o = n.arg;
|
407
|
+
resetTryEntry(r);
|
408
|
+
}
|
409
|
+
return o;
|
410
|
+
}
|
411
|
+
}
|
412
|
+
throw new Error("illegal catch attempt");
|
413
|
+
},
|
414
|
+
delegateYield: function (e, r, n) {
|
415
|
+
return this.delegate = {
|
416
|
+
iterator: values(e),
|
417
|
+
resultName: r,
|
418
|
+
nextLoc: n
|
419
|
+
}, "next" === this.method && (this.arg = t), y;
|
420
|
+
}
|
421
|
+
}, e;
|
422
|
+
}
|
423
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
424
|
+
try {
|
425
|
+
var info = gen[key](arg);
|
426
|
+
var value = info.value;
|
427
|
+
} catch (error) {
|
428
|
+
reject(error);
|
429
|
+
return;
|
430
|
+
}
|
431
|
+
if (info.done) {
|
432
|
+
resolve(value);
|
433
|
+
} else {
|
434
|
+
Promise.resolve(value).then(_next, _throw);
|
435
|
+
}
|
436
|
+
}
|
437
|
+
function _asyncToGenerator(fn) {
|
438
|
+
return function () {
|
439
|
+
var self = this,
|
440
|
+
args = arguments;
|
441
|
+
return new Promise(function (resolve, reject) {
|
442
|
+
var gen = fn.apply(self, args);
|
443
|
+
function _next(value) {
|
444
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
445
|
+
}
|
446
|
+
function _throw(err) {
|
447
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
448
|
+
}
|
449
|
+
_next(undefined);
|
450
|
+
});
|
451
|
+
};
|
452
|
+
}
|
453
|
+
function _extends() {
|
454
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
455
|
+
for (var i = 1; i < arguments.length; i++) {
|
456
|
+
var source = arguments[i];
|
457
|
+
for (var key in source) {
|
458
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
459
|
+
target[key] = source[key];
|
460
|
+
}
|
461
|
+
}
|
462
|
+
}
|
463
|
+
return target;
|
464
|
+
};
|
465
|
+
return _extends.apply(this, arguments);
|
466
|
+
}
|
467
|
+
|
468
|
+
var TOKEN_PERMISSIONS = [{
|
469
|
+
name: 'token',
|
470
|
+
type: 'address'
|
471
|
+
}, {
|
472
|
+
name: 'amount',
|
473
|
+
type: 'uint256'
|
474
|
+
}];
|
475
|
+
var PERMIT_TRANSFER_FROM_TYPES = {
|
476
|
+
PermitTransferFrom: [{
|
477
|
+
name: 'permitted',
|
478
|
+
type: 'TokenPermissions'
|
479
|
+
}, {
|
480
|
+
name: 'spender',
|
481
|
+
type: 'address'
|
482
|
+
}, {
|
483
|
+
name: 'nonce',
|
484
|
+
type: 'uint256'
|
485
|
+
}, {
|
486
|
+
name: 'deadline',
|
487
|
+
type: 'uint256'
|
488
|
+
}],
|
489
|
+
TokenPermissions: TOKEN_PERMISSIONS
|
490
|
+
};
|
491
|
+
var PERMIT_BATCH_TRANSFER_FROM_TYPES = {
|
492
|
+
PermitBatchTransferFrom: [{
|
493
|
+
name: 'permitted',
|
494
|
+
type: 'TokenPermissions[]'
|
495
|
+
}, {
|
496
|
+
name: 'spender',
|
497
|
+
type: 'address'
|
498
|
+
}, {
|
499
|
+
name: 'nonce',
|
500
|
+
type: 'uint256'
|
501
|
+
}, {
|
502
|
+
name: 'deadline',
|
503
|
+
type: 'uint256'
|
504
|
+
}],
|
505
|
+
TokenPermissions: TOKEN_PERMISSIONS
|
506
|
+
};
|
507
|
+
function permitTransferFromWithWitnessType(witness) {
|
508
|
+
return _extends({
|
509
|
+
PermitWitnessTransferFrom: [{
|
510
|
+
name: 'permitted',
|
511
|
+
type: 'TokenPermissions'
|
512
|
+
}, {
|
513
|
+
name: 'spender',
|
514
|
+
type: 'address'
|
515
|
+
}, {
|
516
|
+
name: 'nonce',
|
517
|
+
type: 'uint256'
|
518
|
+
}, {
|
519
|
+
name: 'deadline',
|
520
|
+
type: 'uint256'
|
521
|
+
}, {
|
522
|
+
name: 'witness',
|
523
|
+
type: witness.witnessTypeName
|
524
|
+
}],
|
525
|
+
TokenPermissions: TOKEN_PERMISSIONS
|
526
|
+
}, witness.witnessType);
|
527
|
+
}
|
528
|
+
function permitBatchTransferFromWithWitnessType(witness) {
|
529
|
+
return _extends({
|
530
|
+
PermitBatchWitnessTransferFrom: [{
|
531
|
+
name: 'permitted',
|
532
|
+
type: 'TokenPermissions[]'
|
533
|
+
}, {
|
534
|
+
name: 'spender',
|
535
|
+
type: 'address'
|
536
|
+
}, {
|
537
|
+
name: 'nonce',
|
538
|
+
type: 'uint256'
|
539
|
+
}, {
|
540
|
+
name: 'deadline',
|
541
|
+
type: 'uint256'
|
542
|
+
}, {
|
543
|
+
name: 'witness',
|
544
|
+
type: witness.witnessTypeName
|
545
|
+
}],
|
546
|
+
TokenPermissions: TOKEN_PERMISSIONS
|
547
|
+
}, witness.witnessType);
|
548
|
+
}
|
549
|
+
function isPermitTransferFrom(permit) {
|
550
|
+
return !Array.isArray(permit.permitted);
|
551
|
+
}
|
552
|
+
var SignatureTransfer = /*#__PURE__*/function () {
|
553
|
+
/**
|
554
|
+
* Cannot be constructed.
|
555
|
+
*/
|
556
|
+
function SignatureTransfer() {}
|
557
|
+
// return the data to be sent in a eth_signTypedData RPC call
|
558
|
+
// for signing the given permit data
|
559
|
+
SignatureTransfer.getPermitData = function getPermitData(permit, permit2Address, chainId, witness) {
|
560
|
+
!MaxSigDeadline.gte(permit.deadline) ? process.env.NODE_ENV !== "production" ? invariant(false, 'SIG_DEADLINE_OUT_OF_RANGE') : invariant(false) : void 0;
|
561
|
+
!MaxUnorderedNonce.gte(permit.nonce) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NONCE_OUT_OF_RANGE') : invariant(false) : void 0;
|
562
|
+
var domain = permit2Domain(permit2Address, chainId);
|
563
|
+
if (isPermitTransferFrom(permit)) {
|
564
|
+
validateTokenPermissions(permit.permitted);
|
565
|
+
var types = witness ? permitTransferFromWithWitnessType(witness) : PERMIT_TRANSFER_FROM_TYPES;
|
566
|
+
var values = witness ? Object.assign(permit, {
|
567
|
+
witness: witness.witness
|
568
|
+
}) : permit;
|
569
|
+
return {
|
570
|
+
domain: domain,
|
571
|
+
types: types,
|
572
|
+
values: values
|
573
|
+
};
|
574
|
+
} else {
|
575
|
+
permit.permitted.forEach(validateTokenPermissions);
|
576
|
+
var _types = witness ? permitBatchTransferFromWithWitnessType(witness) : PERMIT_BATCH_TRANSFER_FROM_TYPES;
|
577
|
+
var _values = witness ? Object.assign(permit, {
|
578
|
+
witness: witness.witness
|
579
|
+
}) : permit;
|
580
|
+
return {
|
581
|
+
domain: domain,
|
582
|
+
types: _types,
|
583
|
+
values: _values
|
584
|
+
};
|
585
|
+
}
|
586
|
+
};
|
587
|
+
SignatureTransfer.hash = function hash(permit, permit2Address, chainId, witness) {
|
588
|
+
var _SignatureTransfer$ge = SignatureTransfer.getPermitData(permit, permit2Address, chainId, witness),
|
589
|
+
domain = _SignatureTransfer$ge.domain,
|
590
|
+
types = _SignatureTransfer$ge.types,
|
591
|
+
values = _SignatureTransfer$ge.values;
|
592
|
+
return _TypedDataEncoder.hash(domain, types, values);
|
593
|
+
};
|
594
|
+
return SignatureTransfer;
|
595
|
+
}();
|
596
|
+
function validateTokenPermissions(permissions) {
|
597
|
+
!MaxSignatureTransferAmount.gte(permissions.amount) ? process.env.NODE_ENV !== "production" ? invariant(false, 'AMOUNT_OUT_OF_RANGE') : invariant(false) : void 0;
|
598
|
+
}
|
599
|
+
|
600
|
+
var Permit2Abi = [
|
601
|
+
{
|
602
|
+
inputs: [
|
603
|
+
],
|
604
|
+
name: "AllowanceExpired",
|
605
|
+
type: "error"
|
606
|
+
},
|
607
|
+
{
|
608
|
+
inputs: [
|
609
|
+
],
|
610
|
+
name: "ExcessiveInvalidation",
|
611
|
+
type: "error"
|
612
|
+
},
|
613
|
+
{
|
614
|
+
inputs: [
|
615
|
+
],
|
616
|
+
name: "InsufficientAllowance",
|
617
|
+
type: "error"
|
618
|
+
},
|
619
|
+
{
|
620
|
+
inputs: [
|
621
|
+
],
|
622
|
+
name: "InvalidAmount",
|
623
|
+
type: "error"
|
624
|
+
},
|
625
|
+
{
|
626
|
+
inputs: [
|
627
|
+
],
|
628
|
+
name: "InvalidContractSignature",
|
629
|
+
type: "error"
|
630
|
+
},
|
631
|
+
{
|
632
|
+
inputs: [
|
633
|
+
],
|
634
|
+
name: "InvalidNonce",
|
635
|
+
type: "error"
|
636
|
+
},
|
637
|
+
{
|
638
|
+
inputs: [
|
639
|
+
],
|
640
|
+
name: "InvalidSignature",
|
641
|
+
type: "error"
|
642
|
+
},
|
643
|
+
{
|
644
|
+
inputs: [
|
645
|
+
],
|
646
|
+
name: "InvalidSigner",
|
647
|
+
type: "error"
|
648
|
+
},
|
649
|
+
{
|
650
|
+
inputs: [
|
651
|
+
],
|
652
|
+
name: "LengthMismatch",
|
653
|
+
type: "error"
|
654
|
+
},
|
655
|
+
{
|
656
|
+
inputs: [
|
657
|
+
],
|
658
|
+
name: "NotSpender",
|
659
|
+
type: "error"
|
660
|
+
},
|
661
|
+
{
|
662
|
+
inputs: [
|
663
|
+
],
|
664
|
+
name: "SignatureExpired",
|
665
|
+
type: "error"
|
666
|
+
},
|
667
|
+
{
|
668
|
+
anonymous: false,
|
669
|
+
inputs: [
|
670
|
+
{
|
671
|
+
indexed: true,
|
672
|
+
internalType: "address",
|
673
|
+
name: "owner",
|
674
|
+
type: "address"
|
675
|
+
},
|
676
|
+
{
|
677
|
+
indexed: true,
|
678
|
+
internalType: "address",
|
679
|
+
name: "token",
|
680
|
+
type: "address"
|
681
|
+
},
|
682
|
+
{
|
683
|
+
indexed: true,
|
684
|
+
internalType: "address",
|
685
|
+
name: "spender",
|
686
|
+
type: "address"
|
687
|
+
},
|
688
|
+
{
|
689
|
+
indexed: false,
|
690
|
+
internalType: "uint160",
|
691
|
+
name: "amount",
|
692
|
+
type: "uint160"
|
693
|
+
},
|
694
|
+
{
|
695
|
+
indexed: false,
|
696
|
+
internalType: "uint48",
|
697
|
+
name: "expiration",
|
698
|
+
type: "uint48"
|
699
|
+
}
|
700
|
+
],
|
701
|
+
name: "Approval",
|
702
|
+
type: "event"
|
703
|
+
},
|
704
|
+
{
|
705
|
+
anonymous: false,
|
706
|
+
inputs: [
|
707
|
+
{
|
708
|
+
indexed: true,
|
709
|
+
internalType: "address",
|
710
|
+
name: "owner",
|
711
|
+
type: "address"
|
712
|
+
},
|
713
|
+
{
|
714
|
+
indexed: false,
|
715
|
+
internalType: "address",
|
716
|
+
name: "token",
|
717
|
+
type: "address"
|
718
|
+
},
|
719
|
+
{
|
720
|
+
indexed: false,
|
721
|
+
internalType: "address",
|
722
|
+
name: "spender",
|
723
|
+
type: "address"
|
724
|
+
}
|
725
|
+
],
|
726
|
+
name: "Lockdown",
|
727
|
+
type: "event"
|
728
|
+
},
|
729
|
+
{
|
730
|
+
anonymous: false,
|
731
|
+
inputs: [
|
732
|
+
{
|
733
|
+
indexed: true,
|
734
|
+
internalType: "address",
|
735
|
+
name: "owner",
|
736
|
+
type: "address"
|
737
|
+
},
|
738
|
+
{
|
739
|
+
indexed: true,
|
740
|
+
internalType: "address",
|
741
|
+
name: "token",
|
742
|
+
type: "address"
|
743
|
+
},
|
744
|
+
{
|
745
|
+
indexed: true,
|
746
|
+
internalType: "address",
|
747
|
+
name: "spender",
|
748
|
+
type: "address"
|
749
|
+
},
|
750
|
+
{
|
751
|
+
indexed: false,
|
752
|
+
internalType: "uint48",
|
753
|
+
name: "newNonce",
|
754
|
+
type: "uint48"
|
755
|
+
},
|
756
|
+
{
|
757
|
+
indexed: false,
|
758
|
+
internalType: "uint48",
|
759
|
+
name: "oldNonce",
|
760
|
+
type: "uint48"
|
761
|
+
}
|
762
|
+
],
|
763
|
+
name: "NonceInvalidation",
|
764
|
+
type: "event"
|
765
|
+
},
|
766
|
+
{
|
767
|
+
anonymous: false,
|
768
|
+
inputs: [
|
769
|
+
{
|
770
|
+
indexed: true,
|
771
|
+
internalType: "address",
|
772
|
+
name: "owner",
|
773
|
+
type: "address"
|
774
|
+
},
|
775
|
+
{
|
776
|
+
indexed: false,
|
777
|
+
internalType: "uint256",
|
778
|
+
name: "word",
|
779
|
+
type: "uint256"
|
780
|
+
},
|
781
|
+
{
|
782
|
+
indexed: false,
|
783
|
+
internalType: "uint256",
|
784
|
+
name: "mask",
|
785
|
+
type: "uint256"
|
786
|
+
}
|
787
|
+
],
|
788
|
+
name: "UnorderedNonceInvalidation",
|
789
|
+
type: "event"
|
790
|
+
},
|
791
|
+
{
|
792
|
+
inputs: [
|
793
|
+
],
|
794
|
+
name: "DOMAIN_SEPARATOR",
|
795
|
+
outputs: [
|
796
|
+
{
|
797
|
+
internalType: "bytes32",
|
798
|
+
name: "",
|
799
|
+
type: "bytes32"
|
800
|
+
}
|
801
|
+
],
|
802
|
+
stateMutability: "view",
|
803
|
+
type: "function"
|
804
|
+
},
|
805
|
+
{
|
806
|
+
inputs: [
|
807
|
+
{
|
808
|
+
internalType: "address",
|
809
|
+
name: "",
|
810
|
+
type: "address"
|
811
|
+
},
|
812
|
+
{
|
813
|
+
internalType: "address",
|
814
|
+
name: "",
|
815
|
+
type: "address"
|
816
|
+
},
|
817
|
+
{
|
818
|
+
internalType: "address",
|
819
|
+
name: "",
|
820
|
+
type: "address"
|
821
|
+
}
|
822
|
+
],
|
823
|
+
name: "allowance",
|
824
|
+
outputs: [
|
825
|
+
{
|
826
|
+
internalType: "uint160",
|
827
|
+
name: "amount",
|
828
|
+
type: "uint160"
|
829
|
+
},
|
830
|
+
{
|
831
|
+
internalType: "uint48",
|
832
|
+
name: "expiration",
|
833
|
+
type: "uint48"
|
834
|
+
},
|
835
|
+
{
|
836
|
+
internalType: "uint48",
|
837
|
+
name: "nonce",
|
838
|
+
type: "uint48"
|
839
|
+
}
|
840
|
+
],
|
841
|
+
stateMutability: "view",
|
842
|
+
type: "function"
|
843
|
+
},
|
844
|
+
{
|
845
|
+
inputs: [
|
846
|
+
{
|
847
|
+
internalType: "address",
|
848
|
+
name: "token",
|
849
|
+
type: "address"
|
850
|
+
},
|
851
|
+
{
|
852
|
+
internalType: "address",
|
853
|
+
name: "spender",
|
854
|
+
type: "address"
|
855
|
+
},
|
856
|
+
{
|
857
|
+
internalType: "uint160",
|
858
|
+
name: "amount",
|
859
|
+
type: "uint160"
|
860
|
+
},
|
861
|
+
{
|
862
|
+
internalType: "uint48",
|
863
|
+
name: "expiration",
|
864
|
+
type: "uint48"
|
865
|
+
}
|
866
|
+
],
|
867
|
+
name: "approve",
|
868
|
+
outputs: [
|
869
|
+
],
|
870
|
+
stateMutability: "nonpayable",
|
871
|
+
type: "function"
|
872
|
+
},
|
873
|
+
{
|
874
|
+
inputs: [
|
875
|
+
{
|
876
|
+
internalType: "address",
|
877
|
+
name: "token",
|
878
|
+
type: "address"
|
879
|
+
},
|
880
|
+
{
|
881
|
+
internalType: "address",
|
882
|
+
name: "spender",
|
883
|
+
type: "address"
|
884
|
+
},
|
885
|
+
{
|
886
|
+
internalType: "uint48",
|
887
|
+
name: "newNonce",
|
888
|
+
type: "uint48"
|
889
|
+
}
|
890
|
+
],
|
891
|
+
name: "invalidateNonces",
|
892
|
+
outputs: [
|
893
|
+
],
|
894
|
+
stateMutability: "nonpayable",
|
895
|
+
type: "function"
|
896
|
+
},
|
897
|
+
{
|
898
|
+
inputs: [
|
899
|
+
{
|
900
|
+
internalType: "uint256",
|
901
|
+
name: "wordPos",
|
902
|
+
type: "uint256"
|
903
|
+
},
|
904
|
+
{
|
905
|
+
internalType: "uint256",
|
906
|
+
name: "mask",
|
907
|
+
type: "uint256"
|
908
|
+
}
|
909
|
+
],
|
910
|
+
name: "invalidateUnorderedNonces",
|
911
|
+
outputs: [
|
912
|
+
],
|
913
|
+
stateMutability: "nonpayable",
|
914
|
+
type: "function"
|
915
|
+
},
|
916
|
+
{
|
917
|
+
inputs: [
|
918
|
+
{
|
919
|
+
components: [
|
920
|
+
{
|
921
|
+
internalType: "address",
|
922
|
+
name: "token",
|
923
|
+
type: "address"
|
924
|
+
},
|
925
|
+
{
|
926
|
+
internalType: "address",
|
927
|
+
name: "spender",
|
928
|
+
type: "address"
|
929
|
+
}
|
930
|
+
],
|
931
|
+
internalType: "struct IAllowanceTransfer.TokenSpenderPair[]",
|
932
|
+
name: "approvals",
|
933
|
+
type: "tuple[]"
|
934
|
+
}
|
935
|
+
],
|
936
|
+
name: "lockdown",
|
937
|
+
outputs: [
|
938
|
+
],
|
939
|
+
stateMutability: "nonpayable",
|
940
|
+
type: "function"
|
941
|
+
},
|
942
|
+
{
|
943
|
+
inputs: [
|
944
|
+
{
|
945
|
+
internalType: "address",
|
946
|
+
name: "",
|
947
|
+
type: "address"
|
948
|
+
},
|
949
|
+
{
|
950
|
+
internalType: "uint256",
|
951
|
+
name: "",
|
952
|
+
type: "uint256"
|
953
|
+
}
|
954
|
+
],
|
955
|
+
name: "nonceBitmap",
|
956
|
+
outputs: [
|
957
|
+
{
|
958
|
+
internalType: "uint256",
|
959
|
+
name: "",
|
960
|
+
type: "uint256"
|
961
|
+
}
|
962
|
+
],
|
963
|
+
stateMutability: "view",
|
964
|
+
type: "function"
|
965
|
+
},
|
966
|
+
{
|
967
|
+
inputs: [
|
968
|
+
{
|
969
|
+
internalType: "address",
|
970
|
+
name: "owner",
|
971
|
+
type: "address"
|
972
|
+
},
|
973
|
+
{
|
974
|
+
components: [
|
975
|
+
{
|
976
|
+
components: [
|
977
|
+
{
|
978
|
+
internalType: "address",
|
979
|
+
name: "token",
|
980
|
+
type: "address"
|
981
|
+
},
|
982
|
+
{
|
983
|
+
internalType: "uint160",
|
984
|
+
name: "amount",
|
985
|
+
type: "uint160"
|
986
|
+
},
|
987
|
+
{
|
988
|
+
internalType: "uint48",
|
989
|
+
name: "expiration",
|
990
|
+
type: "uint48"
|
991
|
+
},
|
992
|
+
{
|
993
|
+
internalType: "uint48",
|
994
|
+
name: "nonce",
|
995
|
+
type: "uint48"
|
996
|
+
}
|
997
|
+
],
|
998
|
+
internalType: "struct IAllowanceTransfer.PermitDetails[]",
|
999
|
+
name: "details",
|
1000
|
+
type: "tuple[]"
|
1001
|
+
},
|
1002
|
+
{
|
1003
|
+
internalType: "address",
|
1004
|
+
name: "spender",
|
1005
|
+
type: "address"
|
1006
|
+
},
|
1007
|
+
{
|
1008
|
+
internalType: "uint256",
|
1009
|
+
name: "sigDeadline",
|
1010
|
+
type: "uint256"
|
1011
|
+
}
|
1012
|
+
],
|
1013
|
+
internalType: "struct IAllowanceTransfer.PermitBatch",
|
1014
|
+
name: "permitBatch",
|
1015
|
+
type: "tuple"
|
1016
|
+
},
|
1017
|
+
{
|
1018
|
+
internalType: "bytes",
|
1019
|
+
name: "signature",
|
1020
|
+
type: "bytes"
|
1021
|
+
}
|
1022
|
+
],
|
1023
|
+
name: "permit",
|
1024
|
+
outputs: [
|
1025
|
+
],
|
1026
|
+
stateMutability: "nonpayable",
|
1027
|
+
type: "function"
|
1028
|
+
},
|
1029
|
+
{
|
1030
|
+
inputs: [
|
1031
|
+
{
|
1032
|
+
internalType: "address",
|
1033
|
+
name: "owner",
|
1034
|
+
type: "address"
|
1035
|
+
},
|
1036
|
+
{
|
1037
|
+
components: [
|
1038
|
+
{
|
1039
|
+
components: [
|
1040
|
+
{
|
1041
|
+
internalType: "address",
|
1042
|
+
name: "token",
|
1043
|
+
type: "address"
|
1044
|
+
},
|
1045
|
+
{
|
1046
|
+
internalType: "uint160",
|
1047
|
+
name: "amount",
|
1048
|
+
type: "uint160"
|
1049
|
+
},
|
1050
|
+
{
|
1051
|
+
internalType: "uint48",
|
1052
|
+
name: "expiration",
|
1053
|
+
type: "uint48"
|
1054
|
+
},
|
1055
|
+
{
|
1056
|
+
internalType: "uint48",
|
1057
|
+
name: "nonce",
|
1058
|
+
type: "uint48"
|
1059
|
+
}
|
1060
|
+
],
|
1061
|
+
internalType: "struct IAllowanceTransfer.PermitDetails",
|
1062
|
+
name: "details",
|
1063
|
+
type: "tuple"
|
1064
|
+
},
|
1065
|
+
{
|
1066
|
+
internalType: "address",
|
1067
|
+
name: "spender",
|
1068
|
+
type: "address"
|
1069
|
+
},
|
1070
|
+
{
|
1071
|
+
internalType: "uint256",
|
1072
|
+
name: "sigDeadline",
|
1073
|
+
type: "uint256"
|
1074
|
+
}
|
1075
|
+
],
|
1076
|
+
internalType: "struct IAllowanceTransfer.PermitSingle",
|
1077
|
+
name: "permitSingle",
|
1078
|
+
type: "tuple"
|
1079
|
+
},
|
1080
|
+
{
|
1081
|
+
internalType: "bytes",
|
1082
|
+
name: "signature",
|
1083
|
+
type: "bytes"
|
1084
|
+
}
|
1085
|
+
],
|
1086
|
+
name: "permit",
|
1087
|
+
outputs: [
|
1088
|
+
],
|
1089
|
+
stateMutability: "nonpayable",
|
1090
|
+
type: "function"
|
1091
|
+
},
|
1092
|
+
{
|
1093
|
+
inputs: [
|
1094
|
+
{
|
1095
|
+
components: [
|
1096
|
+
{
|
1097
|
+
components: [
|
1098
|
+
{
|
1099
|
+
internalType: "address",
|
1100
|
+
name: "token",
|
1101
|
+
type: "address"
|
1102
|
+
},
|
1103
|
+
{
|
1104
|
+
internalType: "uint256",
|
1105
|
+
name: "amount",
|
1106
|
+
type: "uint256"
|
1107
|
+
}
|
1108
|
+
],
|
1109
|
+
internalType: "struct ISignatureTransfer.TokenPermissions[]",
|
1110
|
+
name: "permitted",
|
1111
|
+
type: "tuple[]"
|
1112
|
+
},
|
1113
|
+
{
|
1114
|
+
internalType: "uint256",
|
1115
|
+
name: "nonce",
|
1116
|
+
type: "uint256"
|
1117
|
+
},
|
1118
|
+
{
|
1119
|
+
internalType: "uint256",
|
1120
|
+
name: "deadline",
|
1121
|
+
type: "uint256"
|
1122
|
+
}
|
1123
|
+
],
|
1124
|
+
internalType: "struct ISignatureTransfer.PermitBatchTransferFrom",
|
1125
|
+
name: "permit",
|
1126
|
+
type: "tuple"
|
1127
|
+
},
|
1128
|
+
{
|
1129
|
+
internalType: "address",
|
1130
|
+
name: "owner",
|
1131
|
+
type: "address"
|
1132
|
+
},
|
1133
|
+
{
|
1134
|
+
components: [
|
1135
|
+
{
|
1136
|
+
internalType: "address",
|
1137
|
+
name: "to",
|
1138
|
+
type: "address"
|
1139
|
+
},
|
1140
|
+
{
|
1141
|
+
internalType: "uint256",
|
1142
|
+
name: "requestedAmount",
|
1143
|
+
type: "uint256"
|
1144
|
+
}
|
1145
|
+
],
|
1146
|
+
internalType: "struct ISignatureTransfer.SignatureTransferDetails[]",
|
1147
|
+
name: "transferDetails",
|
1148
|
+
type: "tuple[]"
|
1149
|
+
},
|
1150
|
+
{
|
1151
|
+
internalType: "bytes",
|
1152
|
+
name: "signature",
|
1153
|
+
type: "bytes"
|
1154
|
+
}
|
1155
|
+
],
|
1156
|
+
name: "permitTransferFrom",
|
1157
|
+
outputs: [
|
1158
|
+
],
|
1159
|
+
stateMutability: "nonpayable",
|
1160
|
+
type: "function"
|
1161
|
+
},
|
1162
|
+
{
|
1163
|
+
inputs: [
|
1164
|
+
{
|
1165
|
+
components: [
|
1166
|
+
{
|
1167
|
+
components: [
|
1168
|
+
{
|
1169
|
+
internalType: "address",
|
1170
|
+
name: "token",
|
1171
|
+
type: "address"
|
1172
|
+
},
|
1173
|
+
{
|
1174
|
+
internalType: "uint256",
|
1175
|
+
name: "amount",
|
1176
|
+
type: "uint256"
|
1177
|
+
}
|
1178
|
+
],
|
1179
|
+
internalType: "struct ISignatureTransfer.TokenPermissions",
|
1180
|
+
name: "permitted",
|
1181
|
+
type: "tuple"
|
1182
|
+
},
|
1183
|
+
{
|
1184
|
+
internalType: "uint256",
|
1185
|
+
name: "nonce",
|
1186
|
+
type: "uint256"
|
1187
|
+
},
|
1188
|
+
{
|
1189
|
+
internalType: "uint256",
|
1190
|
+
name: "deadline",
|
1191
|
+
type: "uint256"
|
1192
|
+
}
|
1193
|
+
],
|
1194
|
+
internalType: "struct ISignatureTransfer.PermitTransferFrom",
|
1195
|
+
name: "permit",
|
1196
|
+
type: "tuple"
|
1197
|
+
},
|
1198
|
+
{
|
1199
|
+
internalType: "address",
|
1200
|
+
name: "owner",
|
1201
|
+
type: "address"
|
1202
|
+
},
|
1203
|
+
{
|
1204
|
+
internalType: "address",
|
1205
|
+
name: "to",
|
1206
|
+
type: "address"
|
1207
|
+
},
|
1208
|
+
{
|
1209
|
+
internalType: "uint256",
|
1210
|
+
name: "requestedAmount",
|
1211
|
+
type: "uint256"
|
1212
|
+
},
|
1213
|
+
{
|
1214
|
+
internalType: "bytes",
|
1215
|
+
name: "signature",
|
1216
|
+
type: "bytes"
|
1217
|
+
}
|
1218
|
+
],
|
1219
|
+
name: "permitTransferFrom",
|
1220
|
+
outputs: [
|
1221
|
+
],
|
1222
|
+
stateMutability: "nonpayable",
|
1223
|
+
type: "function"
|
1224
|
+
},
|
1225
|
+
{
|
1226
|
+
inputs: [
|
1227
|
+
{
|
1228
|
+
components: [
|
1229
|
+
{
|
1230
|
+
components: [
|
1231
|
+
{
|
1232
|
+
internalType: "address",
|
1233
|
+
name: "token",
|
1234
|
+
type: "address"
|
1235
|
+
},
|
1236
|
+
{
|
1237
|
+
internalType: "uint256",
|
1238
|
+
name: "amount",
|
1239
|
+
type: "uint256"
|
1240
|
+
}
|
1241
|
+
],
|
1242
|
+
internalType: "struct ISignatureTransfer.TokenPermissions",
|
1243
|
+
name: "permitted",
|
1244
|
+
type: "tuple"
|
1245
|
+
},
|
1246
|
+
{
|
1247
|
+
internalType: "uint256",
|
1248
|
+
name: "nonce",
|
1249
|
+
type: "uint256"
|
1250
|
+
},
|
1251
|
+
{
|
1252
|
+
internalType: "uint256",
|
1253
|
+
name: "deadline",
|
1254
|
+
type: "uint256"
|
1255
|
+
}
|
1256
|
+
],
|
1257
|
+
internalType: "struct ISignatureTransfer.PermitTransferFrom",
|
1258
|
+
name: "permit",
|
1259
|
+
type: "tuple"
|
1260
|
+
},
|
1261
|
+
{
|
1262
|
+
internalType: "address",
|
1263
|
+
name: "owner",
|
1264
|
+
type: "address"
|
1265
|
+
},
|
1266
|
+
{
|
1267
|
+
internalType: "address",
|
1268
|
+
name: "to",
|
1269
|
+
type: "address"
|
1270
|
+
},
|
1271
|
+
{
|
1272
|
+
internalType: "uint256",
|
1273
|
+
name: "requestedAmount",
|
1274
|
+
type: "uint256"
|
1275
|
+
},
|
1276
|
+
{
|
1277
|
+
internalType: "bytes32",
|
1278
|
+
name: "witness",
|
1279
|
+
type: "bytes32"
|
1280
|
+
},
|
1281
|
+
{
|
1282
|
+
internalType: "string",
|
1283
|
+
name: "witnessTypeName",
|
1284
|
+
type: "string"
|
1285
|
+
},
|
1286
|
+
{
|
1287
|
+
internalType: "string",
|
1288
|
+
name: "witnessType",
|
1289
|
+
type: "string"
|
1290
|
+
},
|
1291
|
+
{
|
1292
|
+
internalType: "bytes",
|
1293
|
+
name: "signature",
|
1294
|
+
type: "bytes"
|
1295
|
+
}
|
1296
|
+
],
|
1297
|
+
name: "permitWitnessTransferFrom",
|
1298
|
+
outputs: [
|
1299
|
+
],
|
1300
|
+
stateMutability: "nonpayable",
|
1301
|
+
type: "function"
|
1302
|
+
},
|
1303
|
+
{
|
1304
|
+
inputs: [
|
1305
|
+
{
|
1306
|
+
components: [
|
1307
|
+
{
|
1308
|
+
components: [
|
1309
|
+
{
|
1310
|
+
internalType: "address",
|
1311
|
+
name: "token",
|
1312
|
+
type: "address"
|
1313
|
+
},
|
1314
|
+
{
|
1315
|
+
internalType: "uint256",
|
1316
|
+
name: "amount",
|
1317
|
+
type: "uint256"
|
1318
|
+
}
|
1319
|
+
],
|
1320
|
+
internalType: "struct ISignatureTransfer.TokenPermissions[]",
|
1321
|
+
name: "permitted",
|
1322
|
+
type: "tuple[]"
|
1323
|
+
},
|
1324
|
+
{
|
1325
|
+
internalType: "uint256",
|
1326
|
+
name: "nonce",
|
1327
|
+
type: "uint256"
|
1328
|
+
},
|
1329
|
+
{
|
1330
|
+
internalType: "uint256",
|
1331
|
+
name: "deadline",
|
1332
|
+
type: "uint256"
|
1333
|
+
}
|
1334
|
+
],
|
1335
|
+
internalType: "struct ISignatureTransfer.PermitBatchTransferFrom",
|
1336
|
+
name: "permit",
|
1337
|
+
type: "tuple"
|
1338
|
+
},
|
1339
|
+
{
|
1340
|
+
internalType: "address",
|
1341
|
+
name: "owner",
|
1342
|
+
type: "address"
|
1343
|
+
},
|
1344
|
+
{
|
1345
|
+
components: [
|
1346
|
+
{
|
1347
|
+
internalType: "address",
|
1348
|
+
name: "to",
|
1349
|
+
type: "address"
|
1350
|
+
},
|
1351
|
+
{
|
1352
|
+
internalType: "uint256",
|
1353
|
+
name: "requestedAmount",
|
1354
|
+
type: "uint256"
|
1355
|
+
}
|
1356
|
+
],
|
1357
|
+
internalType: "struct ISignatureTransfer.SignatureTransferDetails[]",
|
1358
|
+
name: "transferDetails",
|
1359
|
+
type: "tuple[]"
|
1360
|
+
},
|
1361
|
+
{
|
1362
|
+
internalType: "bytes32",
|
1363
|
+
name: "witness",
|
1364
|
+
type: "bytes32"
|
1365
|
+
},
|
1366
|
+
{
|
1367
|
+
internalType: "string",
|
1368
|
+
name: "witnessTypeName",
|
1369
|
+
type: "string"
|
1370
|
+
},
|
1371
|
+
{
|
1372
|
+
internalType: "string",
|
1373
|
+
name: "witnessType",
|
1374
|
+
type: "string"
|
1375
|
+
},
|
1376
|
+
{
|
1377
|
+
internalType: "bytes",
|
1378
|
+
name: "signature",
|
1379
|
+
type: "bytes"
|
1380
|
+
}
|
1381
|
+
],
|
1382
|
+
name: "permitWitnessTransferFrom",
|
1383
|
+
outputs: [
|
1384
|
+
],
|
1385
|
+
stateMutability: "nonpayable",
|
1386
|
+
type: "function"
|
1387
|
+
},
|
1388
|
+
{
|
1389
|
+
inputs: [
|
1390
|
+
{
|
1391
|
+
internalType: "address",
|
1392
|
+
name: "token",
|
1393
|
+
type: "address"
|
1394
|
+
},
|
1395
|
+
{
|
1396
|
+
internalType: "address",
|
1397
|
+
name: "from",
|
1398
|
+
type: "address"
|
1399
|
+
},
|
1400
|
+
{
|
1401
|
+
internalType: "address",
|
1402
|
+
name: "to",
|
1403
|
+
type: "address"
|
1404
|
+
},
|
1405
|
+
{
|
1406
|
+
internalType: "uint160",
|
1407
|
+
name: "amount",
|
1408
|
+
type: "uint160"
|
1409
|
+
}
|
1410
|
+
],
|
1411
|
+
name: "transferFrom",
|
1412
|
+
outputs: [
|
1413
|
+
],
|
1414
|
+
stateMutability: "nonpayable",
|
1415
|
+
type: "function"
|
1416
|
+
},
|
1417
|
+
{
|
1418
|
+
inputs: [
|
1419
|
+
{
|
1420
|
+
internalType: "address",
|
1421
|
+
name: "from",
|
1422
|
+
type: "address"
|
1423
|
+
},
|
1424
|
+
{
|
1425
|
+
components: [
|
1426
|
+
{
|
1427
|
+
internalType: "address",
|
1428
|
+
name: "token",
|
1429
|
+
type: "address"
|
1430
|
+
},
|
1431
|
+
{
|
1432
|
+
internalType: "uint160",
|
1433
|
+
name: "amount",
|
1434
|
+
type: "uint160"
|
1435
|
+
},
|
1436
|
+
{
|
1437
|
+
internalType: "address",
|
1438
|
+
name: "to",
|
1439
|
+
type: "address"
|
1440
|
+
}
|
1441
|
+
],
|
1442
|
+
internalType: "struct IAllowanceTransfer.AllowanceTransferDetails[]",
|
1443
|
+
name: "transferDetails",
|
1444
|
+
type: "tuple[]"
|
1445
|
+
}
|
1446
|
+
],
|
1447
|
+
name: "transferFrom",
|
1448
|
+
outputs: [
|
1449
|
+
],
|
1450
|
+
stateMutability: "nonpayable",
|
1451
|
+
type: "function"
|
1452
|
+
}
|
1453
|
+
];
|
1454
|
+
|
1455
|
+
var AllowanceProvider = /*#__PURE__*/function () {
|
1456
|
+
function AllowanceProvider(provider, permit2Address) {
|
1457
|
+
this.provider = provider;
|
1458
|
+
this.permit2Address = permit2Address;
|
1459
|
+
this.permit2 = new Contract(this.permit2Address, Permit2Abi, this.provider);
|
1460
|
+
}
|
1461
|
+
var _proto = AllowanceProvider.prototype;
|
1462
|
+
_proto.getAllowanceData = /*#__PURE__*/function () {
|
1463
|
+
var _getAllowanceData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(token, owner, spender) {
|
1464
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1465
|
+
while (1) switch (_context.prev = _context.next) {
|
1466
|
+
case 0:
|
1467
|
+
_context.next = 2;
|
1468
|
+
return this.permit2.allowance(owner, token, spender);
|
1469
|
+
case 2:
|
1470
|
+
return _context.abrupt("return", _context.sent);
|
1471
|
+
case 3:
|
1472
|
+
case "end":
|
1473
|
+
return _context.stop();
|
1474
|
+
}
|
1475
|
+
}, _callee, this);
|
1476
|
+
}));
|
1477
|
+
function getAllowanceData(_x, _x2, _x3) {
|
1478
|
+
return _getAllowanceData.apply(this, arguments);
|
1479
|
+
}
|
1480
|
+
return getAllowanceData;
|
1481
|
+
}();
|
1482
|
+
_proto.getAllowance = /*#__PURE__*/function () {
|
1483
|
+
var _getAllowance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(token, owner, spender) {
|
1484
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1485
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1486
|
+
case 0:
|
1487
|
+
_context2.next = 2;
|
1488
|
+
return this.getAllowanceData(token, owner, spender);
|
1489
|
+
case 2:
|
1490
|
+
return _context2.abrupt("return", _context2.sent.amount);
|
1491
|
+
case 3:
|
1492
|
+
case "end":
|
1493
|
+
return _context2.stop();
|
1494
|
+
}
|
1495
|
+
}, _callee2, this);
|
1496
|
+
}));
|
1497
|
+
function getAllowance(_x4, _x5, _x6) {
|
1498
|
+
return _getAllowance.apply(this, arguments);
|
1499
|
+
}
|
1500
|
+
return getAllowance;
|
1501
|
+
}();
|
1502
|
+
_proto.getNonce = /*#__PURE__*/function () {
|
1503
|
+
var _getNonce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(token, owner, spender) {
|
1504
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1505
|
+
while (1) switch (_context3.prev = _context3.next) {
|
1506
|
+
case 0:
|
1507
|
+
_context3.next = 2;
|
1508
|
+
return this.getAllowanceData(token, owner, spender);
|
1509
|
+
case 2:
|
1510
|
+
return _context3.abrupt("return", _context3.sent.nonce);
|
1511
|
+
case 3:
|
1512
|
+
case "end":
|
1513
|
+
return _context3.stop();
|
1514
|
+
}
|
1515
|
+
}, _callee3, this);
|
1516
|
+
}));
|
1517
|
+
function getNonce(_x7, _x8, _x9) {
|
1518
|
+
return _getNonce.apply(this, arguments);
|
1519
|
+
}
|
1520
|
+
return getNonce;
|
1521
|
+
}();
|
1522
|
+
_proto.getExpiration = /*#__PURE__*/function () {
|
1523
|
+
var _getExpiration = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(token, owner, spender) {
|
1524
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
1525
|
+
while (1) switch (_context4.prev = _context4.next) {
|
1526
|
+
case 0:
|
1527
|
+
_context4.next = 2;
|
1528
|
+
return this.getAllowanceData(token, owner, spender);
|
1529
|
+
case 2:
|
1530
|
+
return _context4.abrupt("return", _context4.sent.expiration);
|
1531
|
+
case 3:
|
1532
|
+
case "end":
|
1533
|
+
return _context4.stop();
|
1534
|
+
}
|
1535
|
+
}, _callee4, this);
|
1536
|
+
}));
|
1537
|
+
function getExpiration(_x10, _x11, _x12) {
|
1538
|
+
return _getExpiration.apply(this, arguments);
|
1539
|
+
}
|
1540
|
+
return getExpiration;
|
1541
|
+
}();
|
1542
|
+
return AllowanceProvider;
|
1543
|
+
}();
|
1544
|
+
|
1545
|
+
export { AllowanceProvider, AllowanceTransfer, InstantExpiration, MaxAllowanceExpiration, MaxAllowanceTransferAmount, MaxOrderedNonce, MaxSigDeadline, MaxSignatureTransferAmount, MaxUint160, MaxUint256, MaxUint48, MaxUnorderedNonce, PERMIT2_ADDRESS, SignatureTransfer, permit2Address };
|
1546
|
+
//# sourceMappingURL=permit2-sdk.esm.js.map
|