@invisi-labs/protocol 1.1.7 → 1.2.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 +5 -0
- package/dist/chunk-7SS2YSEF.js +199 -0
- package/dist/chunk-7SS2YSEF.js.map +1 -0
- package/dist/{chunk-BYJ4LXCJ.js → chunk-HHJLFLVJ.js} +616 -714
- package/dist/chunk-HHJLFLVJ.js.map +1 -0
- package/dist/chunk-MVQQD5W5.js +487 -0
- package/dist/chunk-MVQQD5W5.js.map +1 -0
- package/dist/chunk-Z2XPYNMC.js +446 -0
- package/dist/chunk-Z2XPYNMC.js.map +1 -0
- package/dist/contracts.cjs +615 -713
- package/dist/contracts.cjs.map +1 -1
- package/dist/contracts.d.cts +5 -5
- package/dist/contracts.d.ts +5 -5
- package/dist/contracts.js +1 -1
- package/dist/credit.cjs +3367 -0
- package/dist/credit.cjs.map +1 -0
- package/dist/credit.d.cts +252 -0
- package/dist/credit.d.ts +252 -0
- package/dist/credit.js +53 -0
- package/dist/credit.js.map +1 -0
- package/dist/index.cjs +6054 -6053
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -893
- package/dist/index.d.ts +89 -893
- package/dist/index.js +2956 -3762
- package/dist/index.js.map +1 -1
- package/dist/note.cjs +3456 -0
- package/dist/note.cjs.map +1 -0
- package/dist/note.d.cts +232 -0
- package/dist/note.d.ts +232 -0
- package/dist/note.js +43 -0
- package/dist/note.js.map +1 -0
- package/dist/provenance.cjs +558 -0
- package/dist/provenance.cjs.map +1 -0
- package/dist/provenance.d.cts +188 -0
- package/dist/provenance.d.ts +188 -0
- package/dist/provenance.js +499 -0
- package/dist/provenance.js.map +1 -0
- package/dist/{types-Bvakbfeb.d.cts → types-CUnFzl5S.d.cts} +530 -590
- package/dist/{types-Bvakbfeb.d.ts → types-CUnFzl5S.d.ts} +530 -590
- package/dist/validation-8g0SQVE5.d.ts +235 -0
- package/dist/validation-MgURYiNF.d.cts +235 -0
- package/package.json +20 -5
- package/dist/chunk-BYJ4LXCJ.js.map +0 -1
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkDeadline,
|
|
3
|
+
deliveriesHash,
|
|
4
|
+
dense,
|
|
5
|
+
field,
|
|
6
|
+
known,
|
|
7
|
+
normalizeContext,
|
|
8
|
+
normalizeFee,
|
|
9
|
+
normalizeOpaqueDelivery,
|
|
10
|
+
normalizeSources,
|
|
11
|
+
notes,
|
|
12
|
+
pad,
|
|
13
|
+
uint,
|
|
14
|
+
word
|
|
15
|
+
} from "./chunk-7SS2YSEF.js";
|
|
16
|
+
import {
|
|
17
|
+
invisiProtocolAbi
|
|
18
|
+
} from "./chunk-HHJLFLVJ.js";
|
|
19
|
+
|
|
20
|
+
// src/credit/credit-create.ts
|
|
21
|
+
import { AbiCoder, Interface, getAddress, isHexString, dataLength } from "ethers";
|
|
22
|
+
import {
|
|
23
|
+
computeWalletAuthorizationDigest,
|
|
24
|
+
walletAuthorizationTypedData
|
|
25
|
+
} from "@invisi-labs/primitives";
|
|
26
|
+
var CREATE_CREDIT_FIELDS = [
|
|
27
|
+
"token",
|
|
28
|
+
"owner",
|
|
29
|
+
"revocationShard",
|
|
30
|
+
"revocationSlot",
|
|
31
|
+
"creditCommitment",
|
|
32
|
+
"deadline",
|
|
33
|
+
"feeRecipient",
|
|
34
|
+
"feeAmount"
|
|
35
|
+
];
|
|
36
|
+
function validateCreateCreditRequest(c, p, deliveries) {
|
|
37
|
+
known(p, CREATE_CREDIT_FIELDS);
|
|
38
|
+
const ctx = normalizeContext(c), owner = getAddress(p.owner), revocationShard = uint(p.revocationShard, 64, "revocationShard"), revocationSlot = uint(p.revocationSlot, 16, "revocationSlot"), creditCommitment = word(field(p.creditCommitment));
|
|
39
|
+
if (getAddress(p.token) !== ctx.tokenAddress || !BigInt(owner) || !revocationShard || !BigInt(creditCommitment))
|
|
40
|
+
throw Error("invalid Credit authority, token or commitment");
|
|
41
|
+
if (dense(deliveries, "deliveries").length !== 2) throw Error("deliveries count mismatch");
|
|
42
|
+
return {
|
|
43
|
+
...ctx,
|
|
44
|
+
...normalizeFee(p),
|
|
45
|
+
owner,
|
|
46
|
+
revocationShard,
|
|
47
|
+
revocationSlot,
|
|
48
|
+
creditCommitment,
|
|
49
|
+
deadline: checkDeadline(c, p.deadline),
|
|
50
|
+
deliveries: deliveries.map((d) => normalizeOpaqueDelivery(d, {}))
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function createCreditBaseInputs(c, p, d) {
|
|
54
|
+
const r = validateCreateCreditRequest(c, p, d), h = BigInt(deliveriesHash(d));
|
|
55
|
+
return [
|
|
56
|
+
r.chainId,
|
|
57
|
+
BigInt(r.protocolAddress),
|
|
58
|
+
BigInt(r.tokenAddress),
|
|
59
|
+
BigInt(r.owner),
|
|
60
|
+
r.revocationShard,
|
|
61
|
+
r.revocationSlot,
|
|
62
|
+
BigInt(r.creditCommitment),
|
|
63
|
+
r.deadline,
|
|
64
|
+
h >> 128n,
|
|
65
|
+
h & (1n << 128n) - 1n,
|
|
66
|
+
BigInt(r.feeRecipient),
|
|
67
|
+
r.feeAmount
|
|
68
|
+
].map(word);
|
|
69
|
+
}
|
|
70
|
+
function authorizedCreditInputs(c, operation, capacity, base) {
|
|
71
|
+
const digest = BigInt(
|
|
72
|
+
computeWalletAuthorizationDigest({
|
|
73
|
+
context: { chainId: c.chainId, protocolAddress: BigInt(c.protocolAddress) },
|
|
74
|
+
operation,
|
|
75
|
+
capacity,
|
|
76
|
+
words: base.map(BigInt)
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
return [...base, word(digest >> 128n), word(digest & (1n << 128n) - 1n)];
|
|
80
|
+
}
|
|
81
|
+
function createCreditPublicInputs(c, p, d) {
|
|
82
|
+
return authorizedCreditInputs(c, "create-credit", 1, createCreditBaseInputs(c, p, d));
|
|
83
|
+
}
|
|
84
|
+
function encodeCreateCreditTypedData(c, p, d) {
|
|
85
|
+
return walletAuthorizationTypedData({
|
|
86
|
+
context: { chainId: c.chainId, protocolAddress: BigInt(c.protocolAddress) },
|
|
87
|
+
operation: "create-credit",
|
|
88
|
+
capacity: 1,
|
|
89
|
+
words: createCreditBaseInputs(c, p, d).map(BigInt)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function encodeCreditProof(proof) {
|
|
93
|
+
if (!isHexString(proof) || !dataLength(proof)) throw Error("empty or malformed Credit proof");
|
|
94
|
+
return AbiCoder.defaultAbiCoder().encode(["uint8", "bytes"], [0, proof]);
|
|
95
|
+
}
|
|
96
|
+
function buildCreateCreditCalldata(p) {
|
|
97
|
+
const r = validateCreateCreditRequest(p.context, p.params, p.deliveries);
|
|
98
|
+
return {
|
|
99
|
+
data: new Interface(invisiProtocolAbi).encodeFunctionData("createCredit", [
|
|
100
|
+
encodeCreditProof(p.proof),
|
|
101
|
+
{ ...p.params, ...normalizeFee(p.params) },
|
|
102
|
+
p.deliveries
|
|
103
|
+
]),
|
|
104
|
+
approveAmount: r.feeAmount,
|
|
105
|
+
approvalRequirements: r.feeAmount ? [{ token: r.tokenAddress, payer: r.owner, amount: r.feeAmount }] : []
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/credit/credit-lifecycle.ts
|
|
110
|
+
import { Interface as Interface2, getAddress as getAddress2 } from "ethers";
|
|
111
|
+
import { creditPeriods, walletAuthorizationTypedData as walletAuthorizationTypedData2 } from "@invisi-labs/primitives";
|
|
112
|
+
var CREDIT_DRAW_CAPACITIES = [1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80];
|
|
113
|
+
function selectCreditDrawCircuit(count) {
|
|
114
|
+
if (!Number.isInteger(count) || count < 1 || count > 80)
|
|
115
|
+
throw Error("draw requires1..80 grants");
|
|
116
|
+
const capacity = CREDIT_DRAW_CAPACITIES.find((n) => count <= n);
|
|
117
|
+
return {
|
|
118
|
+
name: `credit_draw_slots${capacity}`,
|
|
119
|
+
capacity,
|
|
120
|
+
publicInputCount: 17 + 10 * capacity
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
var nonzero = (v) => {
|
|
124
|
+
const w = word(field(v));
|
|
125
|
+
if (!BigInt(w)) throw Error("zero commitment or nullifier");
|
|
126
|
+
return w;
|
|
127
|
+
};
|
|
128
|
+
function validateCreditDrawRequest(c, p, d) {
|
|
129
|
+
known(p, [
|
|
130
|
+
"token",
|
|
131
|
+
"sources",
|
|
132
|
+
"payers",
|
|
133
|
+
"grantRefs",
|
|
134
|
+
"nullifiers",
|
|
135
|
+
"creditCommitments",
|
|
136
|
+
"recoveryAmounts",
|
|
137
|
+
"noteCommitment",
|
|
138
|
+
"totalAmount",
|
|
139
|
+
"deadline",
|
|
140
|
+
"feeRecipient",
|
|
141
|
+
"feeAmount"
|
|
142
|
+
]);
|
|
143
|
+
const ctx = normalizeContext(c), ns = notes(p.nullifiers, "nullifiers").map(nonzero), profile = selectCreditDrawCircuit(ns.length), sources = normalizeSources(p.sources, ns.length, profile.capacity);
|
|
144
|
+
if (getAddress2(p.token) !== ctx.tokenAddress) throw Error("token context mismatch");
|
|
145
|
+
for (const k of ["creditCommitments", "recoveryAmounts"])
|
|
146
|
+
if (dense(p[k], k).length !== ns.length) throw Error(`${k} count mismatch`);
|
|
147
|
+
const creditCommitments = p.creditCommitments.map(nonzero), recoveryAmounts = p.recoveryAmounts.map((v) => word(field(v))), noteCommitment = nonzero(p.noteCommitment);
|
|
148
|
+
if ((/* @__PURE__ */ new Set([...creditCommitments, noteCommitment])).size !== ns.length + 1)
|
|
149
|
+
throw Error("duplicate commitment");
|
|
150
|
+
let prev = 0n;
|
|
151
|
+
if (!dense(p.payers, "payers").length || p.payers.length > ns.length)
|
|
152
|
+
throw Error("payer count out of bounds");
|
|
153
|
+
const payers = p.payers.map((payer) => {
|
|
154
|
+
known(payer, ["payer", "amount"]);
|
|
155
|
+
const address = getAddress2(payer.payer), amount = uint(payer.amount, 128, "payer amount");
|
|
156
|
+
if (BigInt(address) <= prev || !amount)
|
|
157
|
+
throw Error("payers must be sorted unique positive addresses with positive receipts");
|
|
158
|
+
prev = BigInt(address);
|
|
159
|
+
return { payer: address, amount };
|
|
160
|
+
});
|
|
161
|
+
if (dense(p.grantRefs, "grantRefs").length !== ns.length)
|
|
162
|
+
throw Error("grant reference count mismatch");
|
|
163
|
+
let previous;
|
|
164
|
+
const grantRefs = p.grantRefs.map((ref) => {
|
|
165
|
+
known(ref, ["payerIndex", "shard", "slot"]);
|
|
166
|
+
const r = {
|
|
167
|
+
payerIndex: uint(ref.payerIndex, 32),
|
|
168
|
+
shard: uint(ref.shard, 64),
|
|
169
|
+
slot: uint(ref.slot, 16)
|
|
170
|
+
};
|
|
171
|
+
if (r.payerIndex >= BigInt(payers.length) || !r.shard)
|
|
172
|
+
throw Error("invalid grant namespace");
|
|
173
|
+
if (previous && (r.payerIndex < previous.payerIndex || r.payerIndex === previous.payerIndex && (r.shard < previous.shard || r.shard === previous.shard && r.slot <= previous.slot)))
|
|
174
|
+
throw Error("grant references must be sorted unique payer/shard/slot");
|
|
175
|
+
previous = r;
|
|
176
|
+
return r;
|
|
177
|
+
});
|
|
178
|
+
const totalAmount = uint(p.totalAmount, 128, "totalAmount");
|
|
179
|
+
if (!totalAmount || payers.reduce((sum, p2) => sum + p2.amount, 0n) !== totalAmount)
|
|
180
|
+
throw Error("payer receipts must equal totalAmount");
|
|
181
|
+
if (normalizeFee(p).feeAmount >= totalAmount)
|
|
182
|
+
throw Error("Credit draw fee must leave a positive ordinary Note");
|
|
183
|
+
if (dense(d, "deliveries").length !== 2 * ns.length + 1)
|
|
184
|
+
throw Error("deliveries count mismatch");
|
|
185
|
+
if (c.timestamp === void 0) throw Error("explicit Credit draw timestamp required");
|
|
186
|
+
return {
|
|
187
|
+
...ctx,
|
|
188
|
+
...normalizeFee(p),
|
|
189
|
+
profile,
|
|
190
|
+
sources,
|
|
191
|
+
payers,
|
|
192
|
+
grantRefs,
|
|
193
|
+
nullifiers: ns,
|
|
194
|
+
creditCommitments,
|
|
195
|
+
recoveryAmounts,
|
|
196
|
+
noteCommitment,
|
|
197
|
+
totalAmount,
|
|
198
|
+
deadline: checkDeadline(c, p.deadline),
|
|
199
|
+
periods: creditPeriods(c.timestamp),
|
|
200
|
+
deliveries: d.map(
|
|
201
|
+
(v, i) => normalizeOpaqueDelivery(v, { allowEmpty: i === 2 * ns.length })
|
|
202
|
+
)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function creditDrawBaseInputs(c, p, d) {
|
|
206
|
+
const r = validateCreditDrawRequest(c, p, d), n = r.profile.capacity, h = BigInt(deliveriesHash(d));
|
|
207
|
+
return [
|
|
208
|
+
r.chainId,
|
|
209
|
+
BigInt(r.protocolAddress),
|
|
210
|
+
BigInt(r.tokenAddress),
|
|
211
|
+
BigInt(r.nullifiers.length),
|
|
212
|
+
BigInt(r.sources.length),
|
|
213
|
+
BigInt(r.payers.length),
|
|
214
|
+
...pad(
|
|
215
|
+
r.sources.map((s) => s.treeId),
|
|
216
|
+
n
|
|
217
|
+
),
|
|
218
|
+
...pad(
|
|
219
|
+
r.sources.map((s) => BigInt(s.merkleRoot)),
|
|
220
|
+
n
|
|
221
|
+
),
|
|
222
|
+
...pad(
|
|
223
|
+
r.payers.map((s) => BigInt(s.payer)),
|
|
224
|
+
n
|
|
225
|
+
),
|
|
226
|
+
...pad(
|
|
227
|
+
r.payers.map((s) => s.amount),
|
|
228
|
+
n
|
|
229
|
+
),
|
|
230
|
+
...pad(
|
|
231
|
+
r.grantRefs.map((s) => s.payerIndex),
|
|
232
|
+
n
|
|
233
|
+
),
|
|
234
|
+
...pad(
|
|
235
|
+
r.grantRefs.map((s) => s.shard),
|
|
236
|
+
n
|
|
237
|
+
),
|
|
238
|
+
...pad(
|
|
239
|
+
r.grantRefs.map((s) => s.slot),
|
|
240
|
+
n
|
|
241
|
+
),
|
|
242
|
+
...pad(r.nullifiers.map(BigInt), n),
|
|
243
|
+
...pad(r.creditCommitments.map(BigInt), n),
|
|
244
|
+
...pad(r.recoveryAmounts.map(BigInt), n),
|
|
245
|
+
BigInt(r.noteCommitment),
|
|
246
|
+
r.totalAmount,
|
|
247
|
+
r.deadline,
|
|
248
|
+
h >> 128n,
|
|
249
|
+
h & (1n << 128n) - 1n,
|
|
250
|
+
r.periods.currentDay,
|
|
251
|
+
r.periods.currentMonth,
|
|
252
|
+
BigInt(r.feeRecipient),
|
|
253
|
+
r.feeAmount
|
|
254
|
+
].map(word);
|
|
255
|
+
}
|
|
256
|
+
function creditDrawPublicInputs(c, p, d) {
|
|
257
|
+
return authorizedCreditInputs(
|
|
258
|
+
c,
|
|
259
|
+
"credit-draw",
|
|
260
|
+
selectCreditDrawCircuit(p.nullifiers.length).capacity,
|
|
261
|
+
creditDrawBaseInputs(c, p, d)
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
function encodeCreditDrawTypedData(c, p, d) {
|
|
265
|
+
return walletAuthorizationTypedData2({
|
|
266
|
+
context: { chainId: c.chainId, protocolAddress: BigInt(c.protocolAddress) },
|
|
267
|
+
operation: "credit-draw",
|
|
268
|
+
capacity: selectCreditDrawCircuit(p.nullifiers.length).capacity,
|
|
269
|
+
words: creditDrawBaseInputs(c, p, d).map(BigInt)
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function validateUpdateCreditRequest(c, p, d) {
|
|
273
|
+
known(p, [
|
|
274
|
+
"token",
|
|
275
|
+
"owner",
|
|
276
|
+
"source",
|
|
277
|
+
"nullifier",
|
|
278
|
+
"creditCommitment",
|
|
279
|
+
"revocationShard",
|
|
280
|
+
"revocationSlot",
|
|
281
|
+
"deadline",
|
|
282
|
+
"feeRecipient",
|
|
283
|
+
"feeAmount"
|
|
284
|
+
]);
|
|
285
|
+
const ctx = normalizeContext(c), owner = getAddress2(p.owner), revocationShard = uint(p.revocationShard, 64);
|
|
286
|
+
if (getAddress2(p.token) !== ctx.tokenAddress || !BigInt(owner) || !revocationShard)
|
|
287
|
+
throw Error("invalid update authority or token");
|
|
288
|
+
if (dense(d, "deliveries").length !== 2) throw Error("deliveries count mismatch");
|
|
289
|
+
return {
|
|
290
|
+
...ctx,
|
|
291
|
+
...normalizeFee(p),
|
|
292
|
+
owner,
|
|
293
|
+
source: normalizeSources([p.source], 1, 1)[0],
|
|
294
|
+
nullifier: nonzero(p.nullifier),
|
|
295
|
+
creditCommitment: nonzero(p.creditCommitment),
|
|
296
|
+
revocationShard,
|
|
297
|
+
revocationSlot: uint(p.revocationSlot, 16),
|
|
298
|
+
deadline: checkDeadline(c, p.deadline),
|
|
299
|
+
deliveries: d.map((v) => normalizeOpaqueDelivery(v, {}))
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function updateCreditBaseInputs(c, p, d) {
|
|
303
|
+
const r = validateUpdateCreditRequest(c, p, d), h = BigInt(deliveriesHash(d));
|
|
304
|
+
return [
|
|
305
|
+
r.chainId,
|
|
306
|
+
BigInt(r.protocolAddress),
|
|
307
|
+
BigInt(r.tokenAddress),
|
|
308
|
+
BigInt(r.owner),
|
|
309
|
+
r.source.treeId,
|
|
310
|
+
BigInt(r.source.merkleRoot),
|
|
311
|
+
BigInt(r.nullifier),
|
|
312
|
+
BigInt(r.creditCommitment),
|
|
313
|
+
r.revocationShard,
|
|
314
|
+
r.revocationSlot,
|
|
315
|
+
r.deadline,
|
|
316
|
+
h >> 128n,
|
|
317
|
+
h & (1n << 128n) - 1n,
|
|
318
|
+
BigInt(r.feeRecipient),
|
|
319
|
+
r.feeAmount
|
|
320
|
+
].map(word);
|
|
321
|
+
}
|
|
322
|
+
function updateCreditPublicInputs(c, p, d) {
|
|
323
|
+
return authorizedCreditInputs(c, "update-credit", 1, updateCreditBaseInputs(c, p, d));
|
|
324
|
+
}
|
|
325
|
+
function encodeUpdateCreditTypedData(c, p, d) {
|
|
326
|
+
return walletAuthorizationTypedData2({
|
|
327
|
+
context: { chainId: c.chainId, protocolAddress: BigInt(c.protocolAddress) },
|
|
328
|
+
operation: "update-credit",
|
|
329
|
+
capacity: 1,
|
|
330
|
+
words: updateCreditBaseInputs(c, p, d).map(BigInt)
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function buildCreditDrawCalldata(p) {
|
|
334
|
+
const r = validateCreditDrawRequest(p.context, p.params, p.deliveries);
|
|
335
|
+
return {
|
|
336
|
+
data: new Interface2(invisiProtocolAbi).encodeFunctionData("creditDraw", [
|
|
337
|
+
encodeCreditProof(p.proof),
|
|
338
|
+
{ ...p.params, ...normalizeFee(p.params) },
|
|
339
|
+
p.deliveries
|
|
340
|
+
]),
|
|
341
|
+
approveAmount: 0n,
|
|
342
|
+
approvalRequirements: r.payers.map((payer) => ({
|
|
343
|
+
token: r.tokenAddress,
|
|
344
|
+
payer: payer.payer,
|
|
345
|
+
amount: payer.amount
|
|
346
|
+
}))
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function buildUpdateCreditCalldata(p) {
|
|
350
|
+
const r = validateUpdateCreditRequest(p.context, p.params, p.deliveries);
|
|
351
|
+
return {
|
|
352
|
+
data: new Interface2(invisiProtocolAbi).encodeFunctionData("updateCredit", [
|
|
353
|
+
encodeCreditProof(p.proof),
|
|
354
|
+
{ ...p.params, ...normalizeFee(p.params) },
|
|
355
|
+
p.deliveries
|
|
356
|
+
]),
|
|
357
|
+
approveAmount: r.feeAmount,
|
|
358
|
+
approvalRequirements: r.feeAmount ? [{ token: r.tokenAddress, payer: r.owner, amount: r.feeAmount }] : []
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
var REVOKE_CREDIT_TYPES = {
|
|
362
|
+
RevokeCredit: [
|
|
363
|
+
{ name: "token", type: "address" },
|
|
364
|
+
{ name: "owner", type: "address" },
|
|
365
|
+
{ name: "shard", type: "uint64" },
|
|
366
|
+
{ name: "slot", type: "uint16" },
|
|
367
|
+
{ name: "deadline", type: "uint256" },
|
|
368
|
+
{ name: "feeRecipient", type: "address" },
|
|
369
|
+
{ name: "feeAmount", type: "uint256" }
|
|
370
|
+
]
|
|
371
|
+
};
|
|
372
|
+
function encodeRevokeCreditTypedData(c, p) {
|
|
373
|
+
known(p, ["token", "owner", "shard", "slot", "deadline", "feeRecipient", "feeAmount"]);
|
|
374
|
+
if (getAddress2(p.token) !== getAddress2(c.tokenAddress) || !BigInt(p.owner) || !uint(p.shard, 64))
|
|
375
|
+
throw Error("invalid revocation authority");
|
|
376
|
+
return {
|
|
377
|
+
domain: {
|
|
378
|
+
name: "InvisibleProtocol",
|
|
379
|
+
version: "1",
|
|
380
|
+
chainId: c.chainId,
|
|
381
|
+
verifyingContract: c.protocolAddress
|
|
382
|
+
},
|
|
383
|
+
types: REVOKE_CREDIT_TYPES,
|
|
384
|
+
primaryType: "RevokeCredit",
|
|
385
|
+
message: {
|
|
386
|
+
token: getAddress2(p.token),
|
|
387
|
+
owner: getAddress2(p.owner),
|
|
388
|
+
shard: uint(p.shard, 64),
|
|
389
|
+
slot: uint(p.slot, 16),
|
|
390
|
+
deadline: checkDeadline(c, p.deadline),
|
|
391
|
+
...normalizeFee(p)
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function buildRevokeCreditCalldata(p) {
|
|
396
|
+
encodeRevokeCreditTypedData(p.context, p.params);
|
|
397
|
+
if (p.signature === "0x" && (!p.caller || getAddress2(p.caller) !== getAddress2(p.params.owner)))
|
|
398
|
+
throw Error("direct revocation requires owner caller");
|
|
399
|
+
return {
|
|
400
|
+
data: new Interface2(invisiProtocolAbi).encodeFunctionData("revokeCredit", [
|
|
401
|
+
p.params.token,
|
|
402
|
+
p.params.owner,
|
|
403
|
+
p.params.shard,
|
|
404
|
+
p.params.slot,
|
|
405
|
+
p.params.deadline,
|
|
406
|
+
normalizeFee(p.params).feeRecipient,
|
|
407
|
+
normalizeFee(p.params).feeAmount,
|
|
408
|
+
p.signature
|
|
409
|
+
]),
|
|
410
|
+
approveAmount: normalizeFee(p.params).feeAmount,
|
|
411
|
+
approvalRequirements: normalizeFee(p.params).feeAmount ? [
|
|
412
|
+
{
|
|
413
|
+
token: p.params.token,
|
|
414
|
+
payer: p.params.owner,
|
|
415
|
+
amount: normalizeFee(p.params).feeAmount
|
|
416
|
+
}
|
|
417
|
+
] : []
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export {
|
|
422
|
+
CREATE_CREDIT_FIELDS,
|
|
423
|
+
validateCreateCreditRequest,
|
|
424
|
+
createCreditBaseInputs,
|
|
425
|
+
authorizedCreditInputs,
|
|
426
|
+
createCreditPublicInputs,
|
|
427
|
+
encodeCreateCreditTypedData,
|
|
428
|
+
encodeCreditProof,
|
|
429
|
+
buildCreateCreditCalldata,
|
|
430
|
+
CREDIT_DRAW_CAPACITIES,
|
|
431
|
+
selectCreditDrawCircuit,
|
|
432
|
+
validateCreditDrawRequest,
|
|
433
|
+
creditDrawBaseInputs,
|
|
434
|
+
creditDrawPublicInputs,
|
|
435
|
+
encodeCreditDrawTypedData,
|
|
436
|
+
validateUpdateCreditRequest,
|
|
437
|
+
updateCreditBaseInputs,
|
|
438
|
+
updateCreditPublicInputs,
|
|
439
|
+
encodeUpdateCreditTypedData,
|
|
440
|
+
buildCreditDrawCalldata,
|
|
441
|
+
buildUpdateCreditCalldata,
|
|
442
|
+
REVOKE_CREDIT_TYPES,
|
|
443
|
+
encodeRevokeCreditTypedData,
|
|
444
|
+
buildRevokeCreditCalldata
|
|
445
|
+
};
|
|
446
|
+
//# sourceMappingURL=chunk-Z2XPYNMC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/credit/credit-create.ts","../src/credit/credit-lifecycle.ts"],"sourcesContent":["import { normalizeFee } from \"../fees/fee\";\nimport { AbiCoder, Interface, getAddress, isHexString, dataLength } from \"ethers\";\nimport {\n computeWalletAuthorizationDigest,\n walletAuthorizationTypedData,\n} from \"@invisi-labs/primitives\";\nimport {\n invisiProtocolAbi,\n type Hex,\n type CreateCreditParams,\n type Delivery,\n} from \"../contracts/index\";\nimport {\n known,\n normalizeContext,\n field,\n word,\n uint,\n checkDeadline,\n dense,\n normalizeOpaqueDelivery,\n deliveriesHash,\n type TransactionContext,\n} from \"../validation\";\nexport const CREATE_CREDIT_FIELDS = [\n \"token\",\n \"owner\",\n \"revocationShard\",\n \"revocationSlot\",\n \"creditCommitment\",\n \"deadline\",\n \"feeRecipient\",\n \"feeAmount\",\n] as const;\nexport function validateCreateCreditRequest(\n c: TransactionContext,\n p: CreateCreditParams,\n deliveries: readonly Delivery[]\n) {\n known(p, CREATE_CREDIT_FIELDS);\n const ctx = normalizeContext(c),\n owner = getAddress(p.owner) as Hex,\n revocationShard = uint(p.revocationShard, 64, \"revocationShard\"),\n revocationSlot = uint(p.revocationSlot, 16, \"revocationSlot\"),\n creditCommitment = word(field(p.creditCommitment));\n if (\n getAddress(p.token) !== ctx.tokenAddress ||\n !BigInt(owner) ||\n !revocationShard ||\n !BigInt(creditCommitment)\n )\n throw Error(\"invalid Credit authority, token or commitment\");\n if (dense(deliveries, \"deliveries\").length !== 2) throw Error(\"deliveries count mismatch\");\n return {\n ...ctx,\n ...normalizeFee(p),\n owner,\n revocationShard,\n revocationSlot,\n creditCommitment,\n deadline: checkDeadline(c, p.deadline),\n deliveries: deliveries.map((d) => normalizeOpaqueDelivery(d, {})),\n };\n}\nexport function createCreditBaseInputs(\n c: TransactionContext,\n p: CreateCreditParams,\n d: readonly Delivery[]\n) {\n const r = validateCreateCreditRequest(c, p, d),\n h = BigInt(deliveriesHash(d));\n return [\n r.chainId,\n BigInt(r.protocolAddress),\n BigInt(r.tokenAddress),\n BigInt(r.owner),\n r.revocationShard,\n r.revocationSlot,\n BigInt(r.creditCommitment),\n r.deadline,\n h >> 128n,\n h & ((1n << 128n) - 1n),\n BigInt(r.feeRecipient),\n r.feeAmount,\n ].map(word);\n}\nexport function authorizedCreditInputs(\n c: TransactionContext,\n operation: \"create-credit\" | \"credit-draw\" | \"update-credit\",\n capacity: number,\n base: readonly Hex[]\n) {\n const digest = BigInt(\n computeWalletAuthorizationDigest({\n context: { chainId: c.chainId, protocolAddress: BigInt(c.protocolAddress) },\n operation,\n capacity,\n words: base.map(BigInt),\n })\n );\n return [...base, word(digest >> 128n), word(digest & ((1n << 128n) - 1n))];\n}\nexport function createCreditPublicInputs(\n c: TransactionContext,\n p: CreateCreditParams,\n d: readonly Delivery[]\n) {\n return authorizedCreditInputs(c, \"create-credit\", 1, createCreditBaseInputs(c, p, d));\n}\nexport function encodeCreateCreditTypedData(\n c: TransactionContext,\n p: CreateCreditParams,\n d: readonly Delivery[]\n) {\n return walletAuthorizationTypedData({\n context: { chainId: c.chainId, protocolAddress: BigInt(c.protocolAddress) },\n operation: \"create-credit\",\n capacity: 1,\n words: createCreditBaseInputs(c, p, d).map(BigInt),\n });\n}\nexport function encodeCreditProof(proof: Hex): Hex {\n if (!isHexString(proof) || !dataLength(proof)) throw Error(\"empty or malformed Credit proof\");\n return AbiCoder.defaultAbiCoder().encode([\"uint8\", \"bytes\"], [0, proof]) as Hex;\n}\nexport interface BuildCreateCreditCalldataParams {\n context: TransactionContext;\n proof: Hex;\n params: CreateCreditParams;\n deliveries: readonly Delivery[];\n}\nexport function buildCreateCreditCalldata(p: BuildCreateCreditCalldataParams) {\n const r = validateCreateCreditRequest(p.context, p.params, p.deliveries);\n return {\n data: new Interface(invisiProtocolAbi).encodeFunctionData(\"createCredit\", [\n encodeCreditProof(p.proof),\n { ...p.params, ...normalizeFee(p.params) },\n p.deliveries,\n ]) as Hex,\n approveAmount: r.feeAmount,\n approvalRequirements: r.feeAmount\n ? [{ token: r.tokenAddress, payer: r.owner, amount: r.feeAmount }]\n : [],\n };\n}\n","import { normalizeFee } from \"../fees/fee\";\nimport { Interface, getAddress } from \"ethers\";\nimport { creditPeriods, walletAuthorizationTypedData } from \"@invisi-labs/primitives\";\nimport {\n invisiProtocolAbi,\n type Hex,\n type CreditDrawParams,\n type UpdateCreditParams,\n type RevokeCreditParams,\n type Delivery,\n type CreditGrantRef,\n} from \"../contracts/index\";\nimport {\n normalizeContext,\n normalizeSources,\n normalizeOpaqueDelivery,\n known,\n uint,\n word,\n field,\n notes,\n dense,\n checkDeadline,\n deliveriesHash,\n pad,\n type TransactionContext,\n} from \"../validation\";\nimport { authorizedCreditInputs, encodeCreditProof } from \"./credit-create\";\nexport const CREDIT_DRAW_CAPACITIES = [1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80] as const;\nexport function selectCreditDrawCircuit(count: number) {\n if (!Number.isInteger(count) || count < 1 || count > 80)\n throw Error(\"draw requires1..80 grants\");\n const capacity = CREDIT_DRAW_CAPACITIES.find((n) => count <= n)!;\n return {\n name: `credit_draw_slots${capacity}`,\n capacity,\n publicInputCount: 17 + 10 * capacity,\n };\n}\nconst nonzero = (v: Hex) => {\n const w = word(field(v));\n if (!BigInt(w)) throw Error(\"zero commitment or nullifier\");\n return w;\n};\nexport function validateCreditDrawRequest(\n c: TransactionContext,\n p: CreditDrawParams,\n d: readonly Delivery[]\n) {\n known(p, [\n \"token\",\n \"sources\",\n \"payers\",\n \"grantRefs\",\n \"nullifiers\",\n \"creditCommitments\",\n \"recoveryAmounts\",\n \"noteCommitment\",\n \"totalAmount\",\n \"deadline\",\n \"feeRecipient\",\n \"feeAmount\",\n ]);\n const ctx = normalizeContext(c),\n ns = notes(p.nullifiers, \"nullifiers\").map(nonzero),\n profile = selectCreditDrawCircuit(ns.length),\n sources = normalizeSources(p.sources, ns.length, profile.capacity);\n if (getAddress(p.token) !== ctx.tokenAddress) throw Error(\"token context mismatch\");\n for (const k of [\"creditCommitments\", \"recoveryAmounts\"] as const)\n if (dense(p[k], k).length !== ns.length) throw Error(`${k} count mismatch`);\n const creditCommitments = p.creditCommitments.map(nonzero),\n recoveryAmounts = p.recoveryAmounts.map((v) => word(field(v))),\n noteCommitment = nonzero(p.noteCommitment);\n if (new Set([...creditCommitments, noteCommitment]).size !== ns.length + 1)\n throw Error(\"duplicate commitment\");\n let prev = 0n;\n if (!dense(p.payers, \"payers\").length || p.payers.length > ns.length)\n throw Error(\"payer count out of bounds\");\n const payers = p.payers.map((payer) => {\n known(payer, [\"payer\", \"amount\"]);\n const address = getAddress(payer.payer) as Hex,\n amount = uint(payer.amount, 128, \"payer amount\");\n if (BigInt(address) <= prev || !amount)\n throw Error(\"payers must be sorted unique positive addresses with positive receipts\");\n prev = BigInt(address);\n return { payer: address, amount };\n });\n if (dense(p.grantRefs, \"grantRefs\").length !== ns.length)\n throw Error(\"grant reference count mismatch\");\n let previous: CreditGrantRef | undefined;\n const grantRefs = p.grantRefs.map((ref) => {\n known(ref, [\"payerIndex\", \"shard\", \"slot\"]);\n const r = {\n payerIndex: uint(ref.payerIndex, 32),\n shard: uint(ref.shard, 64),\n slot: uint(ref.slot, 16),\n };\n if (r.payerIndex >= BigInt(payers.length) || !r.shard)\n throw Error(\"invalid grant namespace\");\n if (\n previous &&\n (r.payerIndex < previous.payerIndex ||\n (r.payerIndex === previous.payerIndex &&\n (r.shard < previous.shard ||\n (r.shard === previous.shard && r.slot <= previous.slot))))\n )\n throw Error(\"grant references must be sorted unique payer/shard/slot\");\n previous = r;\n return r;\n });\n const totalAmount = uint(p.totalAmount, 128, \"totalAmount\");\n if (!totalAmount || payers.reduce((sum, p) => sum + p.amount, 0n) !== totalAmount)\n throw Error(\"payer receipts must equal totalAmount\");\n if (normalizeFee(p).feeAmount >= totalAmount)\n throw Error(\"Credit draw fee must leave a positive ordinary Note\");\n if (dense(d, \"deliveries\").length !== 2 * ns.length + 1)\n throw Error(\"deliveries count mismatch\");\n if (c.timestamp === undefined) throw Error(\"explicit Credit draw timestamp required\");\n return {\n ...ctx,\n ...normalizeFee(p),\n profile,\n sources,\n payers,\n grantRefs,\n nullifiers: ns,\n creditCommitments,\n recoveryAmounts,\n noteCommitment,\n totalAmount,\n deadline: checkDeadline(c, p.deadline),\n periods: creditPeriods(c.timestamp),\n deliveries: d.map((v, i) =>\n normalizeOpaqueDelivery(v, { allowEmpty: i === 2 * ns.length })\n ),\n };\n}\nexport function creditDrawBaseInputs(\n c: TransactionContext,\n p: CreditDrawParams,\n d: readonly Delivery[]\n) {\n const r = validateCreditDrawRequest(c, p, d),\n n = r.profile.capacity,\n h = BigInt(deliveriesHash(d));\n return [\n r.chainId,\n BigInt(r.protocolAddress),\n BigInt(r.tokenAddress),\n BigInt(r.nullifiers.length),\n BigInt(r.sources.length),\n BigInt(r.payers.length),\n ...pad(\n r.sources.map((s) => s.treeId),\n n\n ),\n ...pad(\n r.sources.map((s) => BigInt(s.merkleRoot)),\n n\n ),\n ...pad(\n r.payers.map((s) => BigInt(s.payer)),\n n\n ),\n ...pad(\n r.payers.map((s) => s.amount),\n n\n ),\n ...pad(\n r.grantRefs.map((s) => s.payerIndex),\n n\n ),\n ...pad(\n r.grantRefs.map((s) => s.shard),\n n\n ),\n ...pad(\n r.grantRefs.map((s) => s.slot),\n n\n ),\n ...pad(r.nullifiers.map(BigInt), n),\n ...pad(r.creditCommitments.map(BigInt), n),\n ...pad(r.recoveryAmounts.map(BigInt), n),\n BigInt(r.noteCommitment),\n r.totalAmount,\n r.deadline,\n h >> 128n,\n h & ((1n << 128n) - 1n),\n r.periods.currentDay,\n r.periods.currentMonth,\n BigInt(r.feeRecipient),\n r.feeAmount,\n ].map(word);\n}\nexport function creditDrawPublicInputs(\n c: TransactionContext,\n p: CreditDrawParams,\n d: readonly Delivery[]\n) {\n return authorizedCreditInputs(\n c,\n \"credit-draw\",\n selectCreditDrawCircuit(p.nullifiers.length).capacity,\n creditDrawBaseInputs(c, p, d)\n );\n}\nexport function encodeCreditDrawTypedData(\n c: TransactionContext,\n p: CreditDrawParams,\n d: readonly Delivery[]\n) {\n return walletAuthorizationTypedData({\n context: { chainId: c.chainId, protocolAddress: BigInt(c.protocolAddress) },\n operation: \"credit-draw\",\n capacity: selectCreditDrawCircuit(p.nullifiers.length).capacity,\n words: creditDrawBaseInputs(c, p, d).map(BigInt),\n });\n}\nexport function validateUpdateCreditRequest(\n c: TransactionContext,\n p: UpdateCreditParams,\n d: readonly Delivery[]\n) {\n known(p, [\n \"token\",\n \"owner\",\n \"source\",\n \"nullifier\",\n \"creditCommitment\",\n \"revocationShard\",\n \"revocationSlot\",\n \"deadline\",\n \"feeRecipient\",\n \"feeAmount\",\n ]);\n const ctx = normalizeContext(c),\n owner = getAddress(p.owner) as Hex,\n revocationShard = uint(p.revocationShard, 64);\n if (getAddress(p.token) !== ctx.tokenAddress || !BigInt(owner) || !revocationShard)\n throw Error(\"invalid update authority or token\");\n if (dense(d, \"deliveries\").length !== 2) throw Error(\"deliveries count mismatch\");\n return {\n ...ctx,\n ...normalizeFee(p),\n owner,\n source: normalizeSources([p.source], 1, 1)[0]!,\n nullifier: nonzero(p.nullifier),\n creditCommitment: nonzero(p.creditCommitment),\n revocationShard,\n revocationSlot: uint(p.revocationSlot, 16),\n deadline: checkDeadline(c, p.deadline),\n deliveries: d.map((v) => normalizeOpaqueDelivery(v, {})),\n };\n}\nexport function updateCreditBaseInputs(\n c: TransactionContext,\n p: UpdateCreditParams,\n d: readonly Delivery[]\n) {\n const r = validateUpdateCreditRequest(c, p, d),\n h = BigInt(deliveriesHash(d));\n return [\n r.chainId,\n BigInt(r.protocolAddress),\n BigInt(r.tokenAddress),\n BigInt(r.owner),\n r.source.treeId,\n BigInt(r.source.merkleRoot),\n BigInt(r.nullifier),\n BigInt(r.creditCommitment),\n r.revocationShard,\n r.revocationSlot,\n r.deadline,\n h >> 128n,\n h & ((1n << 128n) - 1n),\n BigInt(r.feeRecipient),\n r.feeAmount,\n ].map(word);\n}\nexport function updateCreditPublicInputs(\n c: TransactionContext,\n p: UpdateCreditParams,\n d: readonly Delivery[]\n) {\n return authorizedCreditInputs(c, \"update-credit\", 1, updateCreditBaseInputs(c, p, d));\n}\nexport function encodeUpdateCreditTypedData(\n c: TransactionContext,\n p: UpdateCreditParams,\n d: readonly Delivery[]\n) {\n return walletAuthorizationTypedData({\n context: { chainId: c.chainId, protocolAddress: BigInt(c.protocolAddress) },\n operation: \"update-credit\",\n capacity: 1,\n words: updateCreditBaseInputs(c, p, d).map(BigInt),\n });\n}\nexport interface BuildCreditDrawCalldataParams {\n context: TransactionContext;\n proof: Hex;\n params: CreditDrawParams;\n deliveries: readonly Delivery[];\n}\nexport function buildCreditDrawCalldata(p: BuildCreditDrawCalldataParams) {\n const r = validateCreditDrawRequest(p.context, p.params, p.deliveries);\n return {\n data: new Interface(invisiProtocolAbi).encodeFunctionData(\"creditDraw\", [\n encodeCreditProof(p.proof),\n { ...p.params, ...normalizeFee(p.params) },\n p.deliveries,\n ]) as Hex,\n approveAmount: 0n,\n approvalRequirements: r.payers.map((payer) => ({\n token: r.tokenAddress,\n payer: payer.payer,\n amount: payer.amount,\n })),\n };\n}\nexport interface BuildUpdateCreditCalldataParams {\n context: TransactionContext;\n proof: Hex;\n params: UpdateCreditParams;\n deliveries: readonly Delivery[];\n}\nexport function buildUpdateCreditCalldata(p: BuildUpdateCreditCalldataParams) {\n const r = validateUpdateCreditRequest(p.context, p.params, p.deliveries);\n return {\n data: new Interface(invisiProtocolAbi).encodeFunctionData(\"updateCredit\", [\n encodeCreditProof(p.proof),\n { ...p.params, ...normalizeFee(p.params) },\n p.deliveries,\n ]) as Hex,\n approveAmount: r.feeAmount,\n approvalRequirements: r.feeAmount\n ? [{ token: r.tokenAddress, payer: r.owner, amount: r.feeAmount }]\n : [],\n };\n}\nexport const REVOKE_CREDIT_TYPES = {\n RevokeCredit: [\n { name: \"token\", type: \"address\" },\n { name: \"owner\", type: \"address\" },\n { name: \"shard\", type: \"uint64\" },\n { name: \"slot\", type: \"uint16\" },\n { name: \"deadline\", type: \"uint256\" },\n { name: \"feeRecipient\", type: \"address\" },\n { name: \"feeAmount\", type: \"uint256\" },\n ],\n};\nexport function encodeRevokeCreditTypedData(c: TransactionContext, p: RevokeCreditParams) {\n known(p, [\"token\", \"owner\", \"shard\", \"slot\", \"deadline\", \"feeRecipient\", \"feeAmount\"]);\n if (\n getAddress(p.token) !== getAddress(c.tokenAddress) ||\n !BigInt(p.owner) ||\n !uint(p.shard, 64)\n )\n throw Error(\"invalid revocation authority\");\n return {\n domain: {\n name: \"InvisibleProtocol\",\n version: \"1\",\n chainId: c.chainId,\n verifyingContract: c.protocolAddress,\n },\n types: REVOKE_CREDIT_TYPES,\n primaryType: \"RevokeCredit\" as const,\n message: {\n token: getAddress(p.token),\n owner: getAddress(p.owner),\n shard: uint(p.shard, 64),\n slot: uint(p.slot, 16),\n deadline: checkDeadline(c, p.deadline),\n ...normalizeFee(p),\n },\n };\n}\nexport interface BuildRevokeCreditCalldataParams {\n context: TransactionContext;\n params: RevokeCreditParams;\n signature: Hex;\n caller?: Hex;\n}\nexport function buildRevokeCreditCalldata(p: BuildRevokeCreditCalldataParams) {\n encodeRevokeCreditTypedData(p.context, p.params);\n if (p.signature === \"0x\" && (!p.caller || getAddress(p.caller) !== getAddress(p.params.owner)))\n throw Error(\"direct revocation requires owner caller\");\n return {\n data: new Interface(invisiProtocolAbi).encodeFunctionData(\"revokeCredit\", [\n p.params.token,\n p.params.owner,\n p.params.shard,\n p.params.slot,\n p.params.deadline,\n normalizeFee(p.params).feeRecipient,\n normalizeFee(p.params).feeAmount,\n p.signature,\n ]) as Hex,\n approveAmount: normalizeFee(p.params).feeAmount,\n approvalRequirements: normalizeFee(p.params).feeAmount\n ? [\n {\n token: p.params.token,\n payer: p.params.owner,\n amount: normalizeFee(p.params).feeAmount,\n },\n ]\n : [],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,SAAS,UAAU,WAAW,YAAY,aAAa,kBAAkB;AACzE;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAmBA,IAAM,uBAAuB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AACO,SAAS,4BACZ,GACA,GACA,YACF;AACE,QAAM,GAAG,oBAAoB;AAC7B,QAAM,MAAM,iBAAiB,CAAC,GAC1B,Q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,SAAS;AAAA,MACL,OAAOA,YAAW,EAAE,KAAK;AAAA,MACzB,OAAOA,YAAW,EAAE,KAAK;AAAA,MACzB,OAAO,KAAK,EAAE,OAAO,EAAE;AAAA,MACvB,MAAM,KAAK,EAAE,MAAM,EAAE;AAAA,MACrB,UAAU,cAAc,GAAG,EAAE,QAAQ;AAAA,MACrC,GAAG,aAAa,CAAC;AAAA,IACrB;AAAA,EACJ;AACJ;AAOO,SAAS,0BAA0B,GAAoC;AAC1E,8BAA4B,EAAE,SAAS,EAAE,MAAM;AAC/C,MAAI,EAAE,cAAc,SAAS,CAAC,EAAE,UAAUA,YAAW,EAAE,MAAM,MAAMA,YAAW,EAAE,OAAO,KAAK;AACxF,UAAM,MAAM,yCAAyC;AACzD,SAAO;AAAA,IACH,MAAM,IAAIG,WAAU,iBAAiB,EAAE,mBAAmB,gBAAgB;AAAA,MACtE,EAAE,OAAO;AAAA,MACT,EAAE,OAAO;AAAA,MACT,EAAE,OAAO;AAAA,MACT,EAAE,OAAO;AAAA,MACT,EAAE,OAAO;AAAA,MACT,aAAa,EAAE,MAAM,EAAE;AAAA,MACvB,aAAa,EAAE,MAAM,EAAE;AAAA,MACvB,EAAE;AAAA,IACN,CAAC;AAAA,IACD,eAAe,aAAa,EAAE,MAAM,EAAE;AAAA,IACtC,sBAAsB,aAAa,EAAE,MAAM,EAAE,YACvC;AAAA,MACI;AAAA,QACI,OAAO,EAAE,OAAO;AAAA,QAChB,OAAO,EAAE,OAAO;AAAA,QAChB,QAAQ,aAAa,EAAE,MAAM,EAAE;AAAA,MACnC;AAAA,IACJ,IACA,CAAC;AAAA,EACX;AACJ;","names":["Interface","getAddress","walletAuthorizationTypedData","getAddress","p","walletAuthorizationTypedData","Interface"]}
|