@bananapus/nana-sdk-core 3.1.0 → 3.3.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/dist/cjs/v6/cashOut.d.ts.map +1 -1
- package/dist/cjs/v6/cashOut.js +11 -39
- package/dist/cjs/v6/cashOut.js.map +1 -1
- package/dist/cjs/v6/executionErrors.d.ts +49 -0
- package/dist/cjs/v6/executionErrors.d.ts.map +1 -0
- package/dist/cjs/v6/executionErrors.js +288 -0
- package/dist/cjs/v6/executionErrors.js.map +1 -0
- package/dist/cjs/v6/index.d.ts +1 -0
- package/dist/cjs/v6/index.d.ts.map +1 -1
- package/dist/cjs/v6/index.js +3 -1
- package/dist/cjs/v6/index.js.map +1 -1
- package/dist/cjs/v6/pay.d.ts +43 -19
- package/dist/cjs/v6/pay.d.ts.map +1 -1
- package/dist/cjs/v6/pay.js +158 -35
- package/dist/cjs/v6/pay.js.map +1 -1
- package/dist/esm/v6/cashOut.d.ts.map +1 -1
- package/dist/esm/v6/cashOut.js +11 -39
- package/dist/esm/v6/cashOut.js.map +1 -1
- package/dist/esm/v6/executionErrors.d.ts +49 -0
- package/dist/esm/v6/executionErrors.d.ts.map +1 -0
- package/dist/esm/v6/executionErrors.js +284 -0
- package/dist/esm/v6/executionErrors.js.map +1 -0
- package/dist/esm/v6/index.d.ts +1 -0
- package/dist/esm/v6/index.d.ts.map +1 -1
- package/dist/esm/v6/index.js +1 -0
- package/dist/esm/v6/index.js.map +1 -1
- package/dist/esm/v6/pay.d.ts +43 -19
- package/dist/esm/v6/pay.d.ts.map +1 -1
- package/dist/esm/v6/pay.js +159 -36
- package/dist/esm/v6/pay.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Hex } from "viem";
|
|
2
|
+
/** Why a payment reverted, as a stable code apps and agents branch on. */
|
|
3
|
+
export type PayFailureReason = "TERMINAL_UNDER_MIN" | "BUYBACK_SLIPPAGE_EXCEEDED" | "BUYBACK_DERIVED_FLOOR_NOT_MET" | "BUYBACK_SWAP_AMOUNT_TOO_HIGH" | "ROUTER_SLIPPAGE_EXCEEDED" | "ROUTER_NO_ROUTE" | "TOKEN_NOT_ACCEPTED" | "PAYMENTS_PAUSED" | "NO_RULESET" | "ALLOWANCE_TOO_LOW" | "ALLOWANCE_EXPIRED" | "BALANCE_TOO_LOW" | "UNEXPECTED_ETH" | "NFT_SOLD_OUT" | "NFT_UNAVAILABLE" | "NFT_PRICE_ABOVE_PAYMENT" | "NFT_OVERSPENDING";
|
|
4
|
+
/**
|
|
5
|
+
* A decoded payment revert. `received` and `minimum` are set when the
|
|
6
|
+
* payment fell short of a minimum: the payer can lower `minReturnedTokens`
|
|
7
|
+
* (or raise the slippage it was floored by) and retry.
|
|
8
|
+
*/
|
|
9
|
+
export interface PayFailure {
|
|
10
|
+
reason: PayFailureReason;
|
|
11
|
+
/** What the payment would have settled, in the minimum's units. */
|
|
12
|
+
received?: bigint;
|
|
13
|
+
/** The minimum it fell short of. */
|
|
14
|
+
minimum?: bigint;
|
|
15
|
+
/** One plain sentence to show the payer. */
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
18
|
+
interface KnownRevert {
|
|
19
|
+
reason: PayFailureReason;
|
|
20
|
+
name: string;
|
|
21
|
+
selector: Hex;
|
|
22
|
+
params: readonly ("uint256" | "address")[];
|
|
23
|
+
/** Argument positions of the settled amount and the minimum it missed. */
|
|
24
|
+
shortfall?: readonly [number, number];
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The first known revert in an error. Revert data, in its own field or quoted
|
|
29
|
+
* in the error's text, counts only as a bare selector or a selector with
|
|
30
|
+
* exactly its arguments, never as the start of a longer value such as an
|
|
31
|
+
* address or calldata, and the call or request viem quotes is left out. Amounts come
|
|
32
|
+
* from revert data or a decoded error; otherwise a selector or a whole error
|
|
33
|
+
* name names the reason alone.
|
|
34
|
+
*/
|
|
35
|
+
export declare function matchKnownRevert(error: unknown, reasons?: readonly PayFailureReason[]): {
|
|
36
|
+
known: KnownRevert;
|
|
37
|
+
args?: readonly unknown[];
|
|
38
|
+
} | null;
|
|
39
|
+
/**
|
|
40
|
+
* Decode why a payment reverted, from a simulation or transaction error
|
|
41
|
+
* (viem or wallet, however nested) or raw revert data. Covers the terminal's
|
|
42
|
+
* minimum, the buyback hook's minimum and floor, the router's conversion,
|
|
43
|
+
* paused or unready projects, token approvals and balances, and NFT tiers.
|
|
44
|
+
* A shortfall carries `received` and `minimum`, so the payer can lower the
|
|
45
|
+
* minimum and retry. Unknown reverts return null.
|
|
46
|
+
*/
|
|
47
|
+
export declare function decodePayFailure(error: unknown): PayFailure | null;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=executionErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executionErrors.d.ts","sourceRoot":"","sources":["../../../src/v6/executionErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAuB,MAAM,MAAM,CAAC;AAyDhD,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GACxB,oBAAoB,GACpB,2BAA2B,GAC3B,+BAA+B,GAC/B,8BAA8B,GAC9B,0BAA0B,GAC1B,iBAAiB,GACjB,oBAAoB,GACpB,iBAAiB,GACjB,YAAY,GACZ,mBAAmB,GACnB,mBAAmB,GACnB,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,yBAAyB,GACzB,kBAAkB,CAAC;AAEvB;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,gBAAgB,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,WAAW;IACnB,MAAM,EAAE,gBAAgB,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,EAAE,CAAC;IAC3C,0EAA0E;IAC1E,SAAS,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAiMD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,GACpC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,GAAG,IAAI,CA2C1D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAUlE"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { decodeAbiParameters } from "viem";
|
|
2
|
+
const HEX = /^0x[0-9a-f]*$/i;
|
|
3
|
+
function collectEvidence(value, evidence, asMessage = false, seen = new Set(), depth = 0) {
|
|
4
|
+
if (depth > 8 || value === null || value === undefined || seen.has(value)) {
|
|
5
|
+
return evidence;
|
|
6
|
+
}
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
(!asMessage && HEX.test(value)
|
|
9
|
+
? evidence.payloads
|
|
10
|
+
: evidence.messages).push(value);
|
|
11
|
+
return evidence;
|
|
12
|
+
}
|
|
13
|
+
if (typeof value !== "object")
|
|
14
|
+
return evidence;
|
|
15
|
+
seen.add(value);
|
|
16
|
+
const record = value;
|
|
17
|
+
if (typeof record.errorName === "string") {
|
|
18
|
+
evidence.decoded.push({
|
|
19
|
+
name: record.errorName,
|
|
20
|
+
...(Array.isArray(record.args) ? { args: record.args } : {}),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const next = (item, message) => collectEvidence(item, evidence, message, seen, depth + 1);
|
|
24
|
+
for (const item of [record.raw, record.data, record.signature]) {
|
|
25
|
+
next(item, false);
|
|
26
|
+
}
|
|
27
|
+
// A viem error's full message repeats the call it made, arguments and all;
|
|
28
|
+
// its short message and details are the error itself.
|
|
29
|
+
const message = typeof record.shortMessage === "string" ? undefined : record.message;
|
|
30
|
+
for (const item of [record.shortMessage, message, record.details]) {
|
|
31
|
+
next(item, true);
|
|
32
|
+
}
|
|
33
|
+
next(record.cause, false);
|
|
34
|
+
next(record.error, false);
|
|
35
|
+
return evidence;
|
|
36
|
+
}
|
|
37
|
+
const LOWER_MINIMUM = "so lower your minimum or try again.";
|
|
38
|
+
const ALLOWANCE_MESSAGE = "The token approval is less than the payment, so approve the full amount and try again.";
|
|
39
|
+
const UNEXPECTED_ETH_MESSAGE = "A payment in this token cannot also send ETH.";
|
|
40
|
+
const KNOWN_REVERTS = [
|
|
41
|
+
{
|
|
42
|
+
reason: "BUYBACK_SLIPPAGE_EXCEEDED",
|
|
43
|
+
name: "JBBuybackHook_SpecifiedSlippageExceeded",
|
|
44
|
+
selector: "0xe2d708a9",
|
|
45
|
+
params: ["uint256", "uint256"],
|
|
46
|
+
shortfall: [0, 1],
|
|
47
|
+
message: `The price moved and this payment would get fewer tokens than your minimum, ${LOWER_MINIMUM}`,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
reason: "TERMINAL_UNDER_MIN",
|
|
51
|
+
name: "JBMultiTerminal_UnderMin",
|
|
52
|
+
selector: "0x6b2bb382",
|
|
53
|
+
params: ["uint256", "uint256"],
|
|
54
|
+
shortfall: [0, 1],
|
|
55
|
+
message: `This payment would get fewer tokens than your minimum, ${LOWER_MINIMUM}`,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
reason: "BUYBACK_DERIVED_FLOOR_NOT_MET",
|
|
59
|
+
name: "JBBuybackHook_DerivedFloorNotMet",
|
|
60
|
+
selector: "0xe490a239",
|
|
61
|
+
params: ["uint256", "uint256"],
|
|
62
|
+
shortfall: [0, 1],
|
|
63
|
+
message: "The token's price moved too fast to buy safely, so wait a few minutes and try again.",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
reason: "ROUTER_SLIPPAGE_EXCEEDED",
|
|
67
|
+
name: "JBRouterTerminal_SlippageExceeded",
|
|
68
|
+
selector: "0x1dbd2ab5",
|
|
69
|
+
params: ["uint256", "uint256"],
|
|
70
|
+
shortfall: [0, 1],
|
|
71
|
+
message: "The price moved while converting your payment, so raise your slippage or try again.",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
reason: "BUYBACK_SWAP_AMOUNT_TOO_HIGH",
|
|
75
|
+
name: "JBBuybackHook_InsufficientPayAmount",
|
|
76
|
+
selector: "0xcc8704dd",
|
|
77
|
+
params: ["uint256", "uint256"],
|
|
78
|
+
message: "The amount set aside to buy tokens is more than the payment.",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
reason: "ROUTER_NO_ROUTE",
|
|
82
|
+
name: "JBRouterTerminal_NoRouteFound",
|
|
83
|
+
selector: "0x52027b4a",
|
|
84
|
+
params: ["uint256", "address"],
|
|
85
|
+
message: "This token cannot be converted into one the project accepts.",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
reason: "ROUTER_NO_ROUTE",
|
|
89
|
+
name: "JBRouterTerminal_NoPoolFound",
|
|
90
|
+
selector: "0x04400f4a",
|
|
91
|
+
params: ["address", "address"],
|
|
92
|
+
message: "This token cannot be converted into one the project accepts.",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
reason: "TOKEN_NOT_ACCEPTED",
|
|
96
|
+
name: "JBMultiTerminal_TokenNotAccepted",
|
|
97
|
+
selector: "0xecb6c1d6",
|
|
98
|
+
params: ["address"],
|
|
99
|
+
message: "This project does not accept this token.",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
reason: "PAYMENTS_PAUSED",
|
|
103
|
+
name: "JBTerminalStore_RulesetPaymentPaused",
|
|
104
|
+
selector: "0x8dc14446",
|
|
105
|
+
params: ["uint256", "uint256"],
|
|
106
|
+
message: "This project is not accepting payments right now.",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
reason: "NO_RULESET",
|
|
110
|
+
name: "JBTerminalStore_RulesetNotFound",
|
|
111
|
+
selector: "0x453ebd8f",
|
|
112
|
+
params: ["uint256"],
|
|
113
|
+
message: "This project is not set up to accept payments yet.",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
reason: "ALLOWANCE_TOO_LOW",
|
|
117
|
+
name: "JBMultiTerminal_PermitAllowanceNotEnough",
|
|
118
|
+
selector: "0xc7e994ba",
|
|
119
|
+
params: ["uint256", "uint256"],
|
|
120
|
+
message: ALLOWANCE_MESSAGE,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
reason: "ALLOWANCE_TOO_LOW",
|
|
124
|
+
name: "ERC20InsufficientAllowance",
|
|
125
|
+
selector: "0xfb8f41b2",
|
|
126
|
+
params: ["address", "uint256", "uint256"],
|
|
127
|
+
message: ALLOWANCE_MESSAGE,
|
|
128
|
+
},
|
|
129
|
+
...[
|
|
130
|
+
["JBRouterTerminal_PermitAllowanceNotEnough", "0x7686b38a"],
|
|
131
|
+
["JBRouterTerminalRegistry_PermitAllowanceNotEnough", "0x3a521783"],
|
|
132
|
+
["JBRouterTerminalGateway_PermitAllowanceNotEnough", "0x0f420d6e"],
|
|
133
|
+
].map(([name, selector]) => ({
|
|
134
|
+
reason: "ALLOWANCE_TOO_LOW",
|
|
135
|
+
name,
|
|
136
|
+
selector,
|
|
137
|
+
params: ["uint256", "uint256"],
|
|
138
|
+
message: ALLOWANCE_MESSAGE,
|
|
139
|
+
})),
|
|
140
|
+
{
|
|
141
|
+
reason: "ALLOWANCE_TOO_LOW",
|
|
142
|
+
name: "InsufficientAllowance",
|
|
143
|
+
selector: "0xf96fb071",
|
|
144
|
+
params: ["uint256"],
|
|
145
|
+
message: ALLOWANCE_MESSAGE,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
reason: "ALLOWANCE_EXPIRED",
|
|
149
|
+
name: "AllowanceExpired",
|
|
150
|
+
selector: "0xd81b2f2e",
|
|
151
|
+
params: ["uint256"],
|
|
152
|
+
message: "The token approval has expired, so approve it again and retry.",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
reason: "BALANCE_TOO_LOW",
|
|
156
|
+
name: "ERC20InsufficientBalance",
|
|
157
|
+
selector: "0xe450d38c",
|
|
158
|
+
params: ["address", "uint256", "uint256"],
|
|
159
|
+
message: "Your token balance is less than the payment.",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
reason: "UNEXPECTED_ETH",
|
|
163
|
+
name: "JBMultiTerminal_NoMsgValueAllowed",
|
|
164
|
+
selector: "0x3ad385fd",
|
|
165
|
+
params: ["uint256"],
|
|
166
|
+
message: UNEXPECTED_ETH_MESSAGE,
|
|
167
|
+
},
|
|
168
|
+
...[
|
|
169
|
+
["JBRouterTerminal_NoMsgValueAllowed", "0x90b2b3e2"],
|
|
170
|
+
["JBRouterTerminalRegistry_NoMsgValueAllowed", "0x0fa1a882"],
|
|
171
|
+
["JBRouterTerminalGateway_NoMsgValueAllowed", "0x49ce25f0"],
|
|
172
|
+
].map(([name, selector]) => ({
|
|
173
|
+
reason: "UNEXPECTED_ETH",
|
|
174
|
+
name,
|
|
175
|
+
selector,
|
|
176
|
+
params: ["uint256"],
|
|
177
|
+
message: UNEXPECTED_ETH_MESSAGE,
|
|
178
|
+
})),
|
|
179
|
+
{
|
|
180
|
+
reason: "NFT_SOLD_OUT",
|
|
181
|
+
name: "JB721TiersHookStore_InsufficientSupplyRemaining",
|
|
182
|
+
selector: "0x90a08e24",
|
|
183
|
+
params: ["uint256"],
|
|
184
|
+
message: "One of the NFTs you picked is sold out.",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
reason: "NFT_UNAVAILABLE",
|
|
188
|
+
name: "JB721TiersHookStore_TierRemoved",
|
|
189
|
+
selector: "0x8145a027",
|
|
190
|
+
params: ["uint256"],
|
|
191
|
+
message: "One of the NFTs you picked is no longer available.",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
reason: "NFT_UNAVAILABLE",
|
|
195
|
+
name: "JB721TiersHookStore_UnrecognizedTier",
|
|
196
|
+
selector: "0xa6fe1eee",
|
|
197
|
+
params: ["uint256"],
|
|
198
|
+
message: "One of the NFTs you picked is no longer available.",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
reason: "NFT_PRICE_ABOVE_PAYMENT",
|
|
202
|
+
name: "JB721TiersHookStore_PriceExceedsAmount",
|
|
203
|
+
selector: "0xee890b46",
|
|
204
|
+
params: ["uint256", "uint256"],
|
|
205
|
+
message: "The payment is less than the price of the NFTs you picked.",
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
reason: "NFT_OVERSPENDING",
|
|
209
|
+
name: "JB721TiersHook_Overspending",
|
|
210
|
+
selector: "0x42b9988e",
|
|
211
|
+
params: ["uint256"],
|
|
212
|
+
message: "This project takes only the exact price of the NFTs you pick.",
|
|
213
|
+
},
|
|
214
|
+
];
|
|
215
|
+
/**
|
|
216
|
+
* The first known revert in an error. Revert data, in its own field or quoted
|
|
217
|
+
* in the error's text, counts only as a bare selector or a selector with
|
|
218
|
+
* exactly its arguments, never as the start of a longer value such as an
|
|
219
|
+
* address or calldata, and the call or request viem quotes is left out. Amounts come
|
|
220
|
+
* from revert data or a decoded error; otherwise a selector or a whole error
|
|
221
|
+
* name names the reason alone.
|
|
222
|
+
*/
|
|
223
|
+
export function matchKnownRevert(error, reasons) {
|
|
224
|
+
const known = reasons
|
|
225
|
+
? KNOWN_REVERTS.filter((k) => reasons.includes(k.reason))
|
|
226
|
+
: KNOWN_REVERTS;
|
|
227
|
+
const { payloads, decoded, messages } = collectEvidence(error, {
|
|
228
|
+
payloads: [],
|
|
229
|
+
decoded: [],
|
|
230
|
+
messages: [],
|
|
231
|
+
});
|
|
232
|
+
// A revert is its selector alone, or its selector and exactly its arguments.
|
|
233
|
+
const exact = (hex) => {
|
|
234
|
+
const lower = hex.toLowerCase();
|
|
235
|
+
const match = known.find((k) => lower.startsWith(k.selector));
|
|
236
|
+
if (!match)
|
|
237
|
+
return null;
|
|
238
|
+
if (lower.length === 10)
|
|
239
|
+
return { known: match };
|
|
240
|
+
if (lower.length !== 10 + 64 * match.params.length)
|
|
241
|
+
return null;
|
|
242
|
+
const args = decodeAbiParameters(match.params.map((type) => ({ type })), `0x${lower.slice(10)}`);
|
|
243
|
+
return { known: match, args };
|
|
244
|
+
};
|
|
245
|
+
// An HTTP error's details can quote the request body.
|
|
246
|
+
const text = messages.join("\n").replace(/request body:[^\n]*/gi, "");
|
|
247
|
+
const quoted = [
|
|
248
|
+
...text.matchAll(/(?<![0-9a-fx])0x[0-9a-f]{8}(?:[0-9a-f]{64})*(?![0-9a-f])/gi),
|
|
249
|
+
].map(([hex]) => hex);
|
|
250
|
+
const found = [...payloads, ...quoted].map(exact).filter((m) => !!m);
|
|
251
|
+
const withArgs = found.find((m) => m.args);
|
|
252
|
+
if (withArgs)
|
|
253
|
+
return withArgs;
|
|
254
|
+
for (const { name, args } of decoded) {
|
|
255
|
+
const match = known.find((k) => k.name.toLowerCase() === name.toLowerCase());
|
|
256
|
+
if (match)
|
|
257
|
+
return { known: match, ...(args ? { args } : {}) };
|
|
258
|
+
}
|
|
259
|
+
if (found[0])
|
|
260
|
+
return found[0];
|
|
261
|
+
const match = known.find((k) => new RegExp(`\\b${k.name}\\b`, "i").test(text));
|
|
262
|
+
return match ? { known: match } : null;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Decode why a payment reverted, from a simulation or transaction error
|
|
266
|
+
* (viem or wallet, however nested) or raw revert data. Covers the terminal's
|
|
267
|
+
* minimum, the buyback hook's minimum and floor, the router's conversion,
|
|
268
|
+
* paused or unready projects, token approvals and balances, and NFT tiers.
|
|
269
|
+
* A shortfall carries `received` and `minimum`, so the payer can lower the
|
|
270
|
+
* minimum and retry. Unknown reverts return null.
|
|
271
|
+
*/
|
|
272
|
+
export function decodePayFailure(error) {
|
|
273
|
+
const matched = matchKnownRevert(error);
|
|
274
|
+
if (!matched)
|
|
275
|
+
return null;
|
|
276
|
+
const { known, args } = matched;
|
|
277
|
+
const failure = { reason: known.reason, message: known.message };
|
|
278
|
+
if (known.shortfall && args) {
|
|
279
|
+
failure.received = args[known.shortfall[0]];
|
|
280
|
+
failure.minimum = args[known.shortfall[1]];
|
|
281
|
+
}
|
|
282
|
+
return failure;
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=executionErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executionErrors.js","sourceRoot":"","sources":["../../../src/v6/executionErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAYhD,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAE7B,SAAS,eAAe,CACtB,KAAc,EACd,QAAwB,EACxB,SAAS,GAAG,KAAK,EACjB,OAAO,IAAI,GAAG,EAAW,EACzB,KAAK,GAAG,CAAC;IAET,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;YAC5B,CAAC,CAAC,QAAQ,CAAC,QAAQ;YACnB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CACpB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC/C,IAAI,CAA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C,SAAS,IAAI,IAAI,EAAE,CAAC;QAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAW,CAAC;QACtD,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAW,CAAC;IACvD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/esm/v6/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./priceFeeds.js";
|
|
|
13
13
|
export * from "./permit2.js";
|
|
14
14
|
export * from "./projectPayers.js";
|
|
15
15
|
export * from "./cashOut.js";
|
|
16
|
+
export { decodePayFailure, type PayFailure, type PayFailureReason, } from "./executionErrors.js";
|
|
16
17
|
export * from "./nft.js";
|
|
17
18
|
export * from "./nftInventory.js";
|
|
18
19
|
export * from "./defifa.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,aAAa,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"}
|
package/dist/esm/v6/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./priceFeeds.js";
|
|
|
13
13
|
export * from "./permit2.js";
|
|
14
14
|
export * from "./projectPayers.js";
|
|
15
15
|
export * from "./cashOut.js";
|
|
16
|
+
export { decodePayFailure, } from "./executionErrors.js";
|
|
16
17
|
export * from "./nft.js";
|
|
17
18
|
export * from "./nftInventory.js";
|
|
18
19
|
export * from "./defifa.js";
|
package/dist/esm/v6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,iBAAiB,GAGlB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,gBAAgB,GAGjB,MAAM,sBAAsB,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,iBAAiB,GAGlB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
package/dist/esm/v6/pay.d.ts
CHANGED
|
@@ -67,8 +67,12 @@ export interface PayPreview {
|
|
|
67
67
|
* reports zero; the hook's pay specification carries the swap quote. This folds
|
|
68
68
|
* it in with the router terminal's scoring rule (see
|
|
69
69
|
* {@link effectivePayPreview}), for the hook the buyback registry resolves for
|
|
70
|
-
* the project, 1.4 or 1.1.1
|
|
71
|
-
*
|
|
70
|
+
* the project, 1.4 or 1.1.1, or for buyback 1.4 when the ruleset calls it
|
|
71
|
+
* directly. It only recognizes that hook's spec: it sends `metadata` as given,
|
|
72
|
+
* and a direct hook reads only an entry keyed to its own address, so
|
|
73
|
+
* registry-keyed metadata is ignored there. {@link prepareUserPay} rekeys it.
|
|
74
|
+
* The swap figure ignores pool fees and price impact, so use
|
|
75
|
+
* {@link prepareUserPay} for a payment's minimum.
|
|
72
76
|
*
|
|
73
77
|
* @param client A viem public client on the given chain.
|
|
74
78
|
* @param args.chainId The chain to preview on.
|
|
@@ -122,25 +126,40 @@ export interface PreparedUserPay {
|
|
|
122
126
|
* Prepare a person's payment with {@link buildUserPayMetadata}: preview it,
|
|
123
127
|
* and set the minimum the terminal enforces on the beneficiary's balance.
|
|
124
128
|
*
|
|
125
|
-
* When the project's buyback hook
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
129
|
+
* When the project's buyback hook has a pool in the paid token, this quotes
|
|
130
|
+
* that pool (fee and price impact included) and sends the slippage-floored
|
|
131
|
+
* quote as an explicit minimum, so the payer gets the pool's rate whenever it
|
|
132
|
+
* beats minting. The hook compares that minimum to the swap output plus the
|
|
133
|
+
* leftover mint: the whole leftover mint when the swapped tokens go through
|
|
134
|
+
* the reserved split (`skipSplits` false, and always on hook 1.1.1, which
|
|
135
|
+
* ignores `skipSplits`), its beneficiary share when they skip it. The
|
|
136
|
+
* terminal minimum is the beneficiary's part of that guarantee, plus what the
|
|
137
|
+
* terminal issues itself (such as for NFT splits). The quoted payment is
|
|
138
|
+
* previewed again first, and stays on the mint path if the hook would not
|
|
139
|
+
* swap with that minimum. Without a quote the hook routes by its TWAP floor,
|
|
140
|
+
* which reaches zero on large buys against a thin pool and sends them to
|
|
141
|
+
* minting even when the pool pays far more.
|
|
132
142
|
*
|
|
133
|
-
* Otherwise (no pool,
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
143
|
+
* Otherwise (no pool, a router converting the token first, or a failed quote)
|
|
144
|
+
* the minimum is the payer's mint entitlement when the hook would swap, since
|
|
145
|
+
* the hook never settles below it, and the terminal's own issuance when it
|
|
146
|
+
* would not. If the payment then reverts, {@link decodePayFailure} says why.
|
|
147
|
+
*
|
|
148
|
+
* When the ruleset calls buyback hook 1.4 directly (or through the omnichain
|
|
149
|
+
* deployer) instead of through the registry, the metadata is keyed to the hook,
|
|
150
|
+
* which reads nothing else.
|
|
137
151
|
*
|
|
138
152
|
* @param args.slippageBps Tolerance on the pool quote and on the fallback
|
|
139
153
|
* minimum. Defaults to 100 (1%).
|
|
154
|
+
* @param args.skipSplits Whether the beneficiary keeps the swapped tokens
|
|
155
|
+
* without the reserved split. Defaults to true, as a person's pay card does;
|
|
156
|
+
* pass false for payments that should honor the project's splits, such as
|
|
157
|
+
* fees or revenue routed into a project.
|
|
140
158
|
*/
|
|
141
|
-
export declare function prepareUserPay(client: PublicClient, { tiers, slippageBps, ...args }: PayArgs & {
|
|
159
|
+
export declare function prepareUserPay(client: PublicClient, { tiers, slippageBps, skipSplits, ...args }: PayArgs & {
|
|
142
160
|
tiers?: UserPayTiers;
|
|
143
161
|
slippageBps?: bigint;
|
|
162
|
+
skipSplits?: boolean;
|
|
144
163
|
}): Promise<PreparedUserPay>;
|
|
145
164
|
/**
|
|
146
165
|
* Build pay metadata instructing a project's JB721 tiers hook to mint specific tiers.
|
|
@@ -189,21 +208,26 @@ export interface UserPayTiers {
|
|
|
189
208
|
}
|
|
190
209
|
/**
|
|
191
210
|
* The pay metadata a person's pay card sends: the buyback registry's quote
|
|
192
|
-
* `(0, minimumSwapAmountOut, skipSplits
|
|
193
|
-
* payment buys NFTs. Prefer {@link prepareUserPay}, which picks the minimum
|
|
211
|
+
* `(0, minimumSwapAmountOut, skipSplits)`, plus the 721 tiers when the
|
|
212
|
+
* payment buys NFTs. Prefer {@link prepareUserPay}, which picks the minimum
|
|
213
|
+
* and the hook. `hook` keys the quote to a buyback hook the ruleset calls
|
|
214
|
+
* directly instead of to the registry.
|
|
194
215
|
*
|
|
195
216
|
* The registry rekeys its quote to the project's resolved hook. On buyback 1.4
|
|
196
217
|
* the hook buys from the pool only when that gives the payer more than their
|
|
197
|
-
* share of a mint
|
|
198
|
-
*
|
|
218
|
+
* share of a mint. With `skipSplits` true (the default) it hands the swapped
|
|
219
|
+
* tokens over without the reserved split; with false they go through the
|
|
220
|
+
* split. Minting always goes through the split. A zero swap amount swaps the
|
|
199
221
|
* whole payment. A zero minimum routes by the hook's TWAP floor; a nonzero one
|
|
200
222
|
* replaces it and reverts below it. The terminal's `minReturnedTokens` checks
|
|
201
223
|
* the beneficiary's balance change, which counts the swapped tokens.
|
|
202
224
|
*/
|
|
203
|
-
export declare function buildUserPayMetadata({ chainId, tiers, minimumSwapAmountOut, }: {
|
|
225
|
+
export declare function buildUserPayMetadata({ chainId, tiers, minimumSwapAmountOut, skipSplits, hook, }: {
|
|
204
226
|
chainId: JBChainId;
|
|
205
227
|
tiers?: UserPayTiers;
|
|
206
228
|
minimumSwapAmountOut?: bigint;
|
|
229
|
+
skipSplits?: boolean;
|
|
230
|
+
hook?: Address;
|
|
207
231
|
}): Hex;
|
|
208
232
|
export {};
|
|
209
233
|
//# sourceMappingURL=pay.d.ts.map
|
package/dist/esm/v6/pay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pay.d.ts","sourceRoot":"","sources":["../../../src/v6/pay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,YAAY,
|
|
1
|
+
{"version":3,"file":"pay.d.ts","sourceRoot":"","sources":["../../../src/v6/pay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,YAAY,EAIb,MAAM,MAAM,CAAC;AAMd,OAAO,EAEL,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AASxC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE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