@eco-incorp/sauce 0.99.5 → 0.99.6

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.
Files changed (81) hide show
  1. package/docs/concepts/architecture.md +4 -2
  2. package/docs/concepts/saucescript.md +19 -2
  3. package/docs/guides/builders-and-actions.md +4 -1
  4. package/docs/guides/compiling.md +5 -3
  5. package/docs/guides/intents.md +32 -2
  6. package/docs/guides/protocols-and-tokens.md +21 -1
  7. package/package.json +1 -1
  8. package/sdk/dist/embedded/skills.generated.js +6 -6
  9. package/sdk/dist/embedded/skills.generated.js.map +1 -1
  10. package/sdk/dist/embedded/sources.generated.js +2 -2
  11. package/sdk/dist/embedded/sources.generated.js.map +1 -1
  12. package/sdk/dist/plugin/index.d.ts +3 -2
  13. package/sdk/dist/plugin/index.d.ts.map +1 -1
  14. package/sdk/dist/plugin/index.js.map +1 -1
  15. package/sdk/dist/protocols/cbeth/functions.d.ts +2 -2
  16. package/sdk/dist/protocols/cbeth/functions.d.ts.map +1 -1
  17. package/sdk/dist/protocols/cbeth/functions.js +4 -6
  18. package/sdk/dist/protocols/cbeth/functions.js.map +1 -1
  19. package/sdk/dist/protocols/crvusd/functions.d.ts +2 -2
  20. package/sdk/dist/protocols/crvusd/functions.d.ts.map +1 -1
  21. package/sdk/dist/protocols/crvusd/functions.js +6 -6
  22. package/sdk/dist/protocols/erc20/functions.d.ts +3 -3
  23. package/sdk/dist/protocols/erc20/functions.d.ts.map +1 -1
  24. package/sdk/dist/protocols/erc20/functions.js +6 -9
  25. package/sdk/dist/protocols/erc20/functions.js.map +1 -1
  26. package/sdk/dist/protocols/frax/functions.d.ts +2 -2
  27. package/sdk/dist/protocols/frax/functions.d.ts.map +1 -1
  28. package/sdk/dist/protocols/frax/functions.js +6 -6
  29. package/sdk/dist/protocols/gho/functions.d.ts +2 -2
  30. package/sdk/dist/protocols/gho/functions.d.ts.map +1 -1
  31. package/sdk/dist/protocols/gho/functions.js +4 -6
  32. package/sdk/dist/protocols/gho/functions.js.map +1 -1
  33. package/sdk/dist/protocols/liquity-v2/functions.d.ts +2 -2
  34. package/sdk/dist/protocols/liquity-v2/functions.d.ts.map +1 -1
  35. package/sdk/dist/protocols/liquity-v2/functions.js +4 -6
  36. package/sdk/dist/protocols/liquity-v2/functions.js.map +1 -1
  37. package/sdk/dist/recipes/cctp-split.sauce.ts +3 -1
  38. package/sdk/dist/recipes/plain-transfer.sauce.ts +3 -0
  39. package/sdk/dist/routes/ast-walk.d.ts +4 -0
  40. package/sdk/dist/routes/ast-walk.d.ts.map +1 -1
  41. package/sdk/dist/routes/ast-walk.js +9 -2
  42. package/sdk/dist/routes/ast-walk.js.map +1 -1
  43. package/sdk/dist/routes/chain-exports.generated.d.ts.map +1 -1
  44. package/sdk/dist/routes/chain-exports.generated.js.map +1 -1
  45. package/sdk/dist/routes/index.d.ts +2 -2
  46. package/sdk/dist/routes/index.d.ts.map +1 -1
  47. package/sdk/dist/routes/index.js +1 -1
  48. package/sdk/dist/routes/index.js.map +1 -1
  49. package/sdk/dist/routes/intent-sugar.d.ts.map +1 -1
  50. package/sdk/dist/routes/intent-sugar.js +40 -23
  51. package/sdk/dist/routes/intent-sugar.js.map +1 -1
  52. package/sdk/dist/routes/sauce-route.d.ts.map +1 -1
  53. package/sdk/dist/routes/sauce-route.js +26 -23
  54. package/sdk/dist/routes/sauce-route.js.map +1 -1
  55. package/sdk/dist/routes/source-globals.generated.d.ts +7 -3
  56. package/sdk/dist/routes/source-globals.generated.d.ts.map +1 -1
  57. package/sdk/dist/routes/token-registry.d.ts.map +1 -1
  58. package/sdk/dist/routes/token-registry.js +6 -1
  59. package/sdk/dist/routes/token-registry.js.map +1 -1
  60. package/sdk/dist/routes/token-rewrite.d.ts +63 -28
  61. package/sdk/dist/routes/token-rewrite.d.ts.map +1 -1
  62. package/sdk/dist/routes/token-rewrite.js +390 -122
  63. package/sdk/dist/routes/token-rewrite.js.map +1 -1
  64. package/sdk/dist/token/api.d.ts +7 -4
  65. package/sdk/dist/token/api.d.ts.map +1 -1
  66. package/sdk/dist/token/api.js.map +1 -1
  67. package/sdk/dist/token/evm.js +2 -2
  68. package/sdk/dist/token/index.d.ts +3 -3
  69. package/sdk/dist/token/index.js +3 -3
  70. package/sdk/src/protocols/cbeth/functions.ts +4 -6
  71. package/sdk/src/protocols/crvusd/functions.ts +6 -6
  72. package/sdk/src/protocols/erc20/functions.ts +6 -9
  73. package/sdk/src/protocols/frax/functions.ts +6 -6
  74. package/sdk/src/protocols/gho/functions.ts +4 -6
  75. package/sdk/src/protocols/liquity-v2/functions.ts +4 -6
  76. package/sdk/src/skills/cbeth.md +4 -6
  77. package/sdk/src/skills/crvusd.md +6 -6
  78. package/sdk/src/skills/erc20.md +8 -10
  79. package/sdk/src/skills/frax.md +6 -6
  80. package/sdk/src/skills/gho.md +4 -6
  81. package/sdk/src/skills/liquity-v2.md +4 -6
@@ -1,84 +1,219 @@
1
1
  /**
2
- * ERC20 token member rewrite -- two rewrites sharing one acorn parse, one shadow computation, and
3
- * one reverse-ordered textual splice over the ORIGINAL source (U4's own technique):
2
+ * ERC-20 token syntax in a route body, lowered before the compiler sees it.
4
3
  *
5
- * U4 (call position): `<Sym>.transfer/.approve/.balanceOf(...)` -> `IERC20.at(<Sym>).<method>(...)`
6
- * sugar (value position): `<holder>.<Sym>` -> `IERC20.at(<addr>n).balanceOf(<holder>)`
4
+ * Two passes, each one acorn parse and one reverse-ordered textual splice over its input:
7
5
  *
8
- * `<Sym>` in both is a name in `tokens` (the chain's resolved token-address map -- see
9
- * `token-registry.ts#resolveTokenMap`, the DEFAULT source; a caller may still pass a bare
10
- * `ReadonlySet<string>` of symbols with no addresses, which runs U4 only -- see the signature doc).
6
+ * `rewriteTokenMembers` — a registry token SYMBOL:
7
+ * writes (call position): `<Sym>.transfer/.approve/.transferFrom(...)` -> `@sauce/token`'s function
8
+ * read (call position): `<Sym>.balanceOf(...)` -> `IERC20.at(<Sym>).balanceOf(...)`
9
+ * sugar (value position): `<holder>.<Sym>` -> `IERC20.at(<addr>n).balanceOf(<holder>)`
11
10
  *
12
- * RECOGNITION IS DISJOINT BY CONSTRUCTION, not by priority ordering: U4 needs `<Sym>` as the member
13
- * chain's HEAD with a REWRITABLE_METHODS member under a CALL parent; the sugar needs `<Sym>` as the
14
- * MEMBER with a non-call, non-lvalue parent and an authorized HOLDER as the object. A token symbol
15
- * can never simultaneously satisfy both shapes for the same node, so the two passes' site lists
16
- * never overlap and can be spliced together with a single reverse-ordered pass. `USDC.balanceOf(x)`
17
- * is U4's (and `token-registry.ts`'s module-eval guard -- no registry symbol may equal a
18
- * REWRITABLE_METHODS name -- is what keeps that permanent); `x.USDC` is the sugar's; `USDC.WETH` is
19
- * neither's (left untouched -- see the sugar's holder-rejection rule below).
11
+ * `rewriteTokenFactory` — the `Token(<addr>)` wrapper, for any address:
12
+ * `Token(<addr>).<write>(...)`, and `t.<write>(...)` on `const t = Token(<addr>)` -> `@sauce/token`
13
+ * `Token(<addr>).<read>(...)`, and `t.<read>(...)` likewise -> `IERC20.at(...)`
20
14
  *
21
- * Shadowing-aware, CONSERVATIVELY, on the TOKEN name only (both rewrites): SauceScript shares scope
22
- * across `if`/`while`/bare-block bodies (the real compiler's `processIfStatement`/
23
- * `processWhileStatement` never push a new scope -- see this repo's CLAUDE.md's repeated shadow-fix
24
- * notes), so a name first `let`/`const`-declared inside a branch is NOT block-scoped away once the
25
- * branch ends. Rather than re-deriving that exact position-sensitive rule, this pass is
26
- * deliberately coarser and still sound: if a name anywhere in the WHOLE program is
27
- * `let`/`const`-declared or is a function parameter, EVERY occurrence of that name anywhere in the
28
- * program is left un-rewritten. The sugar's HOLDER name is deliberately NOT shadow-checked -- a
29
- * local variable IS the intended holder.
15
+ * EVERY WRITE IS OPENZEPPELIN `SafeERC20`. A write lowers to the `@sauce/token` library function
16
+ * of the same name, with the token moved to the front: `USDC.transfer(to, amount)` becomes
17
+ * `transfer(USDC, to, amount)`. That function is the SDK's one implementation of a token write —
18
+ * empty returndata accepted only from an address with code, anything else decoded as a word that
19
+ * must equal 1, and `approve` as `forceApprove` (see `std/token/token.evm.js`). The typed
20
+ * `IERC20.at(t).transfer(...)` this used to emit decodes the ABI's declared `bool`, so it reverted
21
+ * the whole program on a token that returns nothing (USDT) and accepted one that returns `false`.
22
+ * The reads keep the typed binding: a `uint256` is always returned, so there is nothing to check.
30
23
  *
31
- * A method name outside the three-op allowlist (U4), or an unresolvable/rejected holder (sugar), is
32
- * left completely untouched -- it fails closed at compile (an ordinary compile error), never a new
33
- * failure mode this pass introduces. This is the isolation half of the design: a token symbol in
34
- * MEMBER position is indistinguishable from an ordinary struct-field read, so this pass does not
35
- * OWN it and must never clobber a genuine member access.
24
+ * The library is imported under the names in `SAFE_WRITES` (`import { transfer as
25
+ * __sauce_transfer } from "@sauce/token"`), never its own, so a program that declares its own
26
+ * `transfer` keeps it. `tokenImportLines` renders the imports a rewrite needs; the caller prepends
27
+ * them, because both passes run over one source and must share one import block. `@sauce/token`
28
+ * resolves inside the SDK (`embedded/resolve.ts`), so no caller resolver has to serve it.
29
+ *
30
+ * An explicit `IERC20.at(addr).transfer(...)` is NOT this syntax and is left alone: it is the raw
31
+ * ABI call, the escape hatch for a caller who wants exactly that, and it is not `SafeERC20`.
32
+ *
33
+ * RECOGNITION IS DISJOINT BY CONSTRUCTION, not by priority ordering: a symbol write or read needs
34
+ * `<Sym>` as the member chain's HEAD with a REWRITABLE_METHODS member under a CALL parent; the
35
+ * balance sugar needs `<Sym>` as the MEMBER with a non-call, non-lvalue parent and an authorized
36
+ * HOLDER as the object. A token symbol can never satisfy both shapes for the same node, so the site
37
+ * lists never overlap. `USDC.balanceOf(x)` is the read's (and `token-registry.ts`'s module-eval
38
+ * guard -- no registry symbol may equal a REWRITABLE_METHODS name -- keeps that permanent);
39
+ * `x.USDC` is the sugar's; `USDC.WETH` is neither's (left untouched -- see the holder rule below).
40
+ *
41
+ * Shadowing-aware, CONSERVATIVELY, on the TOKEN name only: if a name anywhere in the WHOLE program
42
+ * is bound (`let`/`const`, a parameter, an import, ...), EVERY occurrence of it is left un-rewritten,
43
+ * rather than re-deriving the compiler's own scoping rules. A user who declares `USDC` or `Token`
44
+ * owns the name. The sugar's HOLDER name is deliberately NOT shadow-checked -- a local variable IS
45
+ * the intended holder.
46
+ *
47
+ * A symbol method outside REWRITABLE_METHODS, or an unresolvable holder, is left untouched and fails
48
+ * closed at compile. A `Token(...)` call in any position this module cannot lower is REFUSED with an
49
+ * error naming the spellings that work — never passed through as the typed binding, which would
50
+ * quietly be the unchecked write again.
36
51
  */
37
52
  import * as acorn from "acorn";
38
- import { walk, collectDeclaredNames } from "./ast-walk.js";
53
+ import { walk, collectDeclaredNames, countDeclarations } from "./ast-walk.js";
39
54
  import { formatBigint } from "../deposit/format.js";
55
+ import { ERC20_IMPORT_LINE } from "../token/evm.js";
40
56
  import { isChainKey, resolveNamespace } from "./accessor-index.js";
57
+ /**
58
+ * The ERC-20 writes the token syntax offers: each lowers to the `@sauce/token` function of the same
59
+ * name, imported under `local`, with the token as its first argument ahead of `params`.
60
+ */
61
+ export const SAFE_WRITES = {
62
+ transfer: { local: "__sauce_transfer", params: ["to", "amount"] },
63
+ approve: { local: "__sauce_approve", params: ["spender", "amount"] },
64
+ transferFrom: { local: "__sauce_transferFrom", params: ["from", "to", "amount"] },
65
+ };
66
+ /** Every method the SYMBOL syntax lowers: the writes, plus the one read it has always offered. */
41
67
  export const REWRITABLE_METHODS = new Set([
42
68
  "transfer",
43
69
  "approve",
70
+ "transferFrom",
44
71
  "balanceOf",
45
72
  ]);
73
+ const isSafeWrite = (method) => Object.hasOwn(SAFE_WRITES, method);
74
+ /** The package every write is lowered to. */
75
+ const STD_TOKEN = "@sauce/token";
76
+ /**
77
+ * The import lines a rewritten source needs, for the caller to prepend. The order is fixed, so a
78
+ * given program always gets the same text and so the same bytecode.
79
+ */
80
+ export function tokenImportLines({ writes, erc20 }) {
81
+ const lines = [];
82
+ if (erc20)
83
+ lines.push(ERC20_IMPORT_LINE);
84
+ const used = Object.keys(SAFE_WRITES).filter((write) => writes.has(write));
85
+ if (used.length > 0) {
86
+ const names = used.map((write) => `${write} as ${SAFE_WRITES[write].local}`).join(", ");
87
+ lines.push(`import { ${names} } from "${STD_TOKEN}";`);
88
+ }
89
+ return lines;
90
+ }
91
+ /** Splice from the end backward so earlier offsets stay valid. The ranges never overlap: a write
92
+ * only replaces the text BEFORE its first argument, so a site nested inside the arguments is
93
+ * spliced independently. */
94
+ function applySplices(source, splices) {
95
+ let out = source;
96
+ for (const site of [...splices].sort((a, b) => b.start - a.start)) {
97
+ out = out.slice(0, site.start) + site.replacement + out.slice(site.end);
98
+ }
99
+ return out;
100
+ }
101
+ function parse(source) {
102
+ // sourceType "module": a source may already carry its own `import` lines.
103
+ return acorn.parse(source, { ecmaVersion: "latest", sourceType: "module" });
104
+ }
105
+ /** A child node the node's type guarantees is there (`id` on a declarator, `left` on an
106
+ * assignment, ...). */
107
+ function child(node, key) {
108
+ return node[key];
109
+ }
46
110
  function tokenAddressOf(tokens, symbol) {
47
111
  return tokens instanceof Map ? tokens.get(symbol) : undefined;
48
112
  }
49
- // -- U4: <Sym>.transfer/.approve/.balanceOf(...) in CALL position ---------------------------------
50
- function collectMemberCallSites(program, tokens, shadowed) {
113
+ /** `<object>.<method>(...)`, non-computed and non-optional, or `undefined` for any other node. */
114
+ function methodCall(node) {
115
+ if (node.type !== "CallExpression" || node.optional)
116
+ return undefined;
117
+ const callee = node.callee;
118
+ if (!callee || callee.type !== "MemberExpression")
119
+ return undefined;
120
+ if (callee.computed)
121
+ return undefined;
122
+ if (callee.optional)
123
+ return undefined;
124
+ const object = callee.object;
125
+ const property = callee.property;
126
+ if (!object || property?.type !== "Identifier")
127
+ return undefined;
128
+ return {
129
+ call: node,
130
+ callee,
131
+ object,
132
+ method: property.name,
133
+ };
134
+ }
135
+ /** Every call that is a whole statement on its own — the only place a write can stand. */
136
+ function statementCalls(program) {
137
+ const calls = new Set();
138
+ walk(program, (n) => {
139
+ if (n.type === "ExpressionStatement")
140
+ calls.add(child(n, "expression"));
141
+ });
142
+ return calls;
143
+ }
144
+ /**
145
+ * A write's arguments, checked against the ERC-20 signature so a wrong count is reported in the
146
+ * terms the caller wrote rather than as the library function's arity.
147
+ *
148
+ * Also refuses a write whose result is read. The typed call returned the ABI's `bool`; a SafeERC20
149
+ * write returns nothing, because it reverts the program unless the token accepted it — there is no
150
+ * `false` left to report. Left to the compiler, this would fail on a `: void` function the caller
151
+ * never wrote.
152
+ */
153
+ function writeArguments(call, method, receiver, statements) {
154
+ const spelling = `\`${receiver}.${method}(...)\``;
155
+ if (!statements.has(call)) {
156
+ throw new Error(`${spelling} returns nothing, so its result cannot be used: a token write has SafeERC20 ` +
157
+ "semantics and reverts the program unless the token accepted it. Call it as a statement.");
158
+ }
159
+ const args = call.arguments ?? [];
160
+ const { params } = SAFE_WRITES[method];
161
+ if (args.length !== params.length || args.some((arg) => arg.type === "SpreadElement")) {
162
+ throw new Error(`${spelling} takes ${params.length} arguments (${params.join(", ")}), got ${args.length}.`);
163
+ }
164
+ return args;
165
+ }
166
+ /** A name the lowering imports under is the SDK's; a program that declares it cannot also get it. */
167
+ function assertLocalsFree(declared, writes) {
168
+ for (const write of writes) {
169
+ const { local } = SAFE_WRITES[write];
170
+ if (declared.has(local)) {
171
+ throw new Error(`\`${local}\` is reserved: a token's \`.${write}(...)\` is lowered to \`${STD_TOKEN}\`'s ` +
172
+ `\`${write}\`, imported under that name. Rename your \`${local}\`.`);
173
+ }
174
+ }
175
+ }
176
+ /** `<receiver>.<write>(a, b)` -> `<local>(<receiver>, a, b)`, for a receiver that is a name. */
177
+ function nameWriteSplice(site, name, statements) {
178
+ const method = site.method;
179
+ const [first] = writeArguments(site.call, method, name, statements);
180
+ return {
181
+ start: site.callee.start,
182
+ end: first.start,
183
+ replacement: `${SAFE_WRITES[method].local}(${name}, `,
184
+ };
185
+ }
186
+ // -- <Sym>.<method>(...) in CALL position --------------------------------------------------------
187
+ /** The symbol call sites, split by what they lower to: `writes` records each `@sauce/token` write
188
+ * used, and `reads` counts the sites left on the typed `IERC20` binding. */
189
+ function collectMemberCallSites(program, tokens, shadowed, writes) {
51
190
  const sites = [];
191
+ const statements = statementCalls(program);
192
+ let reads = 0;
52
193
  walk(program, (n) => {
53
- if (n.type !== "CallExpression")
54
- return;
55
- const callee = n.callee;
56
- if (!callee || callee.type !== "MemberExpression")
57
- return;
58
- const object = callee.object;
59
- const property = callee.property;
60
- const computed = callee.computed;
61
- if (computed)
62
- return; // `TOKEN["transfer"]` is out of scope for this narrow rewrite
63
- if (!object || object.type !== "Identifier")
194
+ const site = methodCall(n);
195
+ if (!site || site.object.type !== "Identifier")
64
196
  return;
65
- if (!property || property.type !== "Identifier")
66
- return;
67
- const symbol = object.name;
68
- const method = property.name;
197
+ const symbol = site.object.name;
69
198
  if (!tokens.has(symbol))
70
199
  return;
71
200
  if (shadowed.has(symbol))
72
201
  return;
73
- if (!REWRITABLE_METHODS.has(method))
202
+ if (!REWRITABLE_METHODS.has(site.method))
203
+ return;
204
+ if (isSafeWrite(site.method)) {
205
+ sites.push(nameWriteSplice(site, symbol, statements));
206
+ writes.add(site.method);
74
207
  return;
208
+ }
75
209
  sites.push({
76
- start: callee.start,
77
- end: callee.end,
78
- replacement: `IERC20.at(${symbol}).${method}`,
210
+ start: site.callee.start,
211
+ end: site.callee.end,
212
+ replacement: `IERC20.at(${symbol}).${site.method}`,
79
213
  });
214
+ reads++;
80
215
  });
81
- return sites;
216
+ return { sites, reads };
82
217
  }
83
218
  // -- balance sugar: <holder>.<Sym> in VALUE position -----------------------------------------------
84
219
  const HEX_ADDRESS_LITERAL_RE = /^0x[0-9a-fA-F]{40}n?$/;
@@ -174,101 +309,234 @@ function collectBalanceSites(program, tokens, shadowed, excluded, source) {
174
309
  });
175
310
  return sites;
176
311
  }
177
- // -- Token(addr) factory: Token(<expr>) -> IERC20.at(<expr>) in ANY position ----------------------
312
+ // -- Token(addr): the wrapper, in call-receiver and binding position ------------------------------
178
313
  /** The DSL's global token WRAPPER name. */
179
314
  export const TOKEN_FACTORY_NAME = "Token";
315
+ function isFactoryCall(node) {
316
+ if (node.type !== "CallExpression" || node.optional)
317
+ return false;
318
+ const callee = node.callee;
319
+ return (callee?.type === "Identifier" &&
320
+ callee.name === TOKEN_FACTORY_NAME);
321
+ }
322
+ /** The single address argument of a `Token(...)` call. */
323
+ function factoryArgument(call) {
324
+ const args = call.arguments ?? [];
325
+ if (args.length !== 1 || args[0].type === "SpreadElement") {
326
+ throw new Error(`\`${TOKEN_FACTORY_NAME}(...)\` takes one argument, the token's address; got ${args.length}.`);
327
+ }
328
+ return args[0];
329
+ }
330
+ /** The refusal for a `Token(...)` this module cannot lower, naming the spellings that work. */
331
+ function refuseFactory(what) {
332
+ return new Error(`${what}. \`${TOKEN_FACTORY_NAME}(addr)\` is supported as the receiver of a call ` +
333
+ `(\`${TOKEN_FACTORY_NAME}(addr).transfer(to, amount)\`) or bound once to a local that is only ` +
334
+ `ever called (\`const t = ${TOKEN_FACTORY_NAME}(addr); t.approve(spender, amount)\`). Those, ` +
335
+ `\`<SYMBOL>.transfer(...)\` and \`${STD_TOKEN}\`'s \`transfer(token, to, amount)\` are the ` +
336
+ "token writes with SafeERC20 semantics; `IERC20.at(addr).transfer(...)` is the raw, " +
337
+ "unchecked ABI call.");
338
+ }
180
339
  /**
181
- * Rewrites every `Token(<expr>)` call to `IERC20.at(<expr>)` — the DSL's global token WRAPPER, the
182
- * `Token(addr)` sibling of the `<Sym>.transfer(...)` sugar above. This is what makes
183
- * `Token(addr).approve(spender, amt)` and `let t = Token(addr); t.approve(...)` compile in a route
184
- * body with no import: only the callee `Token` is replaced, so the result is the ordinary
185
- * `IERC20.at(addr)` binding the compiler already supports — it never sees a method call on a
186
- * `Token(...)` result (which the compiler's M1 subset rejects). Fires on ANY argument (a literal, a
187
- * variable, an ambient `USDC` define), so — unlike the symbol sugar — it does NOT depend on the
188
- * token-symbol map, and works on every EVM chain including registry-less ones.
340
+ * The `t.<method>(...)` calls of `const t = Token(...)`, or a refusal when `t` is anything other
341
+ * than one binding used only that way.
189
342
  *
190
- * Shadow-safe: a user who declares their own `Token` anywhere in the program owns the name, and
191
- * EVERY `Token(...)` call is then left untouched — the same conservative whole-program rule the
192
- * symbol rewrite applies. `collectDeclaredNames` decides that, and it covers every binding form,
193
- * `import { Token }` and `class Token` included: an imported `Token` is the user's own by any
194
- * reading, and rewriting past it would silently redirect their call to an ERC20 they never named.
195
- * Purely textual, acorn-range-driven, like the rest of this module.
343
+ * The conditions are what make replacing the binding's VALUE with the address sound: declared
344
+ * exactly once in the whole program (so every `t` is this `t`), never assigned, and never read
345
+ * except as a call receiver (so nothing sees the value change from a contract binding to an
346
+ * address). Whole-program, like the shadow rule, rather than scope-exact: over-refusing is an error
347
+ * a caller can act on, while under-refusing would lower a call on some other `t`.
348
+ */
349
+ function bindingCalls(program, declarator, name, declarations) {
350
+ const at = `\`${name} = ${TOKEN_FACTORY_NAME}(...)\``;
351
+ if ((declarations.get(name) ?? 0) !== 1) {
352
+ throw refuseFactory(`${at}: \`${name}\` is declared more than once`);
353
+ }
354
+ const receivers = new Map();
355
+ // Identifiers that are a NAME rather than a read of the variable: the declaration itself, a
356
+ // member property (`x.t`), and a non-shorthand object key (`{ t: 1 }`).
357
+ const names = new Set([child(declarator, "id")]);
358
+ const assigned = new Set();
359
+ walk(program, (n) => {
360
+ const site = methodCall(n);
361
+ if (site?.object.type === "Identifier" && site.object.name === name) {
362
+ receivers.set(site.object, site);
363
+ }
364
+ if (n.type === "MemberExpression" && !n.computed) {
365
+ names.add(child(n, "property"));
366
+ }
367
+ if (n.type === "Property") {
368
+ const { computed, shorthand } = n;
369
+ if (!computed && !shorthand)
370
+ names.add(child(n, "key"));
371
+ }
372
+ if (n.type === "AssignmentExpression")
373
+ walk(child(n, "left"), (m) => assigned.add(m));
374
+ if (n.type === "UpdateExpression")
375
+ assigned.add(child(n, "argument"));
376
+ });
377
+ walk(program, (n) => {
378
+ if (n.type !== "Identifier" || n.name !== name)
379
+ return;
380
+ if (names.has(n) || receivers.has(n))
381
+ return;
382
+ throw refuseFactory(assigned.has(n)
383
+ ? `${at}: \`${name}\` is reassigned`
384
+ : `${at}: \`${name}\` is used other than as \`${name}.<method>(...)\``);
385
+ });
386
+ return [...receivers.values()];
387
+ }
388
+ /**
389
+ * Lowers every `Token(<expr>)` — the DSL's global token WRAPPER, the any-address sibling of the
390
+ * symbol syntax above. It fires on ANY argument (a literal, a variable, an ambient `USDC` define),
391
+ * so it does not depend on the token-symbol map and works on every EVM chain.
392
+ *
393
+ * Two positions are lowered, and the compiler never sees a method call on a `Token(...)` result
394
+ * (which its M1 subset rejects):
395
+ *
396
+ * - `Token(a).<write>(x, y)` -> `<local>(a, x, y)`, the `@sauce/token` write; `Token(a).<read>(x)`
397
+ * -> `IERC20.at(a).<read>(x)`.
398
+ * - `const t = Token(a)` -> `const t = a`, with each `t.<method>(...)` lowered the same way, by
399
+ * name. The binding now holds the ADDRESS, evaluated once where it was, so a later change to
400
+ * whatever `a` read cannot reach the calls. See `bindingCalls` for when a binding qualifies.
401
+ *
402
+ * Any other `Token(...)` — an argument, a return value, a reassigned or passed-around binding — is
403
+ * refused rather than left as the typed binding, which would be the unchecked write again.
404
+ *
405
+ * Shadow-safe: a user who binds `Token` anywhere in the program owns the name, and EVERY
406
+ * `Token(...)` is then left untouched — the same whole-program rule the symbol rewrite applies,
407
+ * covering every binding form, `import { Token }` and `class Token` included.
196
408
  */
197
409
  export function rewriteTokenFactory(source) {
410
+ const none = {
411
+ source,
412
+ rewrote: false,
413
+ sites: 0,
414
+ writes: new Set(),
415
+ erc20: false,
416
+ };
198
417
  // Cheap bail before parsing: no `Token` token, nothing to do (a mention in a comment/string still
199
418
  // parses, but that is rare and the parse is cheap).
200
- if (!source.includes(TOKEN_FACTORY_NAME)) {
201
- return { source, rewrote: false, sites: 0 };
202
- }
203
- const program = acorn.parse(source, {
204
- ecmaVersion: "latest",
205
- sourceType: "module",
419
+ if (!source.includes(TOKEN_FACTORY_NAME))
420
+ return none;
421
+ const program = parse(source);
422
+ const declarations = countDeclarations(program);
423
+ if (declarations.has(TOKEN_FACTORY_NAME))
424
+ return none;
425
+ const factories = new Set();
426
+ walk(program, (n) => {
427
+ if (isFactoryCall(n))
428
+ factories.add(n);
206
429
  });
207
- // A locally-declared `Token` shadows the global wrapper — skip the whole program, conservatively.
208
- // Every binding form counts, which is `collectDeclaredNames`'s whole job; this used to add its own
209
- // `FunctionDeclaration` walk on top and still missed `import { Token }` and `class Token`.
210
- if (collectDeclaredNames(program).has(TOKEN_FACTORY_NAME)) {
211
- return { source, rewrote: false, sites: 0 };
212
- }
213
- const sites = [];
430
+ if (factories.size === 0)
431
+ return none;
432
+ const splices = [];
433
+ const writes = new Set();
434
+ let erc20 = false;
435
+ const lowered = new Set();
436
+ const statements = statementCalls(program);
437
+ // `Token(a).<method>(...)`.
214
438
  walk(program, (n) => {
215
- if (n.type !== "CallExpression")
439
+ const site = methodCall(n);
440
+ if (!site || !factories.has(site.object))
216
441
  return;
217
- const callee = n.callee;
218
- if (!callee || callee.type !== "Identifier")
442
+ const address = factoryArgument(site.object);
443
+ lowered.add(site.object);
444
+ if (isSafeWrite(site.method)) {
445
+ const [first] = writeArguments(site.call, site.method, `${TOKEN_FACTORY_NAME}(...)`, statements);
446
+ // `Token(` -> `<local>(` and `).<method>(` -> `, `, leaving the address and the arguments in
447
+ // place so a rewrite inside either splices on its own.
448
+ splices.push({
449
+ start: site.object.start,
450
+ end: address.start,
451
+ replacement: `${SAFE_WRITES[site.method].local}(`,
452
+ }, { start: address.end, end: first.start, replacement: ", " });
453
+ writes.add(site.method);
219
454
  return;
220
- if (callee.name !== TOKEN_FACTORY_NAME)
455
+ }
456
+ const callee = child(site.object, "callee");
457
+ splices.push({ start: callee.start, end: callee.end, replacement: "IERC20.at" });
458
+ erc20 = true;
459
+ });
460
+ // `const t = Token(a)`, then only `t.<method>(...)`.
461
+ walk(program, (n) => {
462
+ if (n.type !== "VariableDeclarator")
221
463
  return;
222
- // Replace ONLY the callee identifier: `Token(<args>)` -> `IERC20.at(<args>)`. The args and the
223
- // surrounding `.approve(...)`/binding are left for the compiler.
224
- sites.push({ start: callee.start, end: callee.end, replacement: "IERC20.at" });
464
+ const init = n.init;
465
+ if (!init || !factories.has(init))
466
+ return;
467
+ const id = child(n, "id");
468
+ if (id.type !== "Identifier") {
469
+ throw refuseFactory(`A \`${TOKEN_FACTORY_NAME}(...)\` is destructured`);
470
+ }
471
+ const name = id.name;
472
+ const address = factoryArgument(init);
473
+ const calls = bindingCalls(program, n, name, declarations);
474
+ lowered.add(init);
475
+ splices.push({ start: init.start, end: address.start, replacement: "" }, { start: address.end, end: init.end, replacement: "" });
476
+ for (const site of calls) {
477
+ if (isSafeWrite(site.method)) {
478
+ splices.push(nameWriteSplice(site, name, statements));
479
+ writes.add(site.method);
480
+ continue;
481
+ }
482
+ splices.push({
483
+ start: site.object.start,
484
+ end: site.object.end,
485
+ replacement: `IERC20.at(${name})`,
486
+ });
487
+ erc20 = true;
488
+ }
225
489
  });
226
- if (sites.length === 0)
227
- return { source, rewrote: false, sites: 0 };
228
- const ordered = [...sites].sort((a, b) => b.start - a.start);
229
- let out = source;
230
- for (const site of ordered) {
231
- out = out.slice(0, site.start) + site.replacement + out.slice(site.end);
490
+ for (const call of factories) {
491
+ if (!lowered.has(call)) {
492
+ throw refuseFactory(`\`${source.slice(call.start, call.end)}\` is used as a value, not called or bound`);
493
+ }
232
494
  }
233
- return { source: out, rewrote: true, sites: sites.length };
495
+ assertLocalsFree(new Set(declarations.keys()), writes);
496
+ return {
497
+ source: applySplices(source, splices),
498
+ rewrote: true,
499
+ sites: factories.size,
500
+ writes,
501
+ erc20,
502
+ };
234
503
  }
235
504
  /**
236
- * Rewrites every `<Sym>.transfer/.approve/.balanceOf(...)` call (U4) and every `<holder>.<Sym>`
237
- * value-position read (balance sugar) whose `<Sym>` is in `tokens` (and not shadowed anywhere in
238
- * `source`) — see the module doc for the full disjointness argument. Purely textual surgery over
239
- * the ORIGINAL source, driven by acorn ranges — never a re-print of the AST, so everything else
240
- * (formatting, comments, unrelated code) survives byte-for-byte.
505
+ * Rewrites every `<Sym>.<method>(...)` call and every `<holder>.<Sym>` value-position read whose
506
+ * `<Sym>` is in `tokens` (and not shadowed anywhere in `source`) — see the module doc for the
507
+ * lowering and the disjointness argument. Purely textual surgery over the ORIGINAL source, driven by
508
+ * acorn ranges — never a re-print of the AST, so everything else (formatting, comments, unrelated
509
+ * code) survives byte-for-byte. Prepend `tokenImportLines(result)` before compiling the result.
241
510
  */
242
511
  export function rewriteTokenMembers(source, tokens) {
243
- if (tokens.size === 0) {
244
- return { source, rewrote: false, memberSites: 0, balanceSites: 0 };
245
- }
246
- // sourceType: "module" -- this pass now runs by DEFAULT (the registry provides addresses even
247
- // with no caller-supplied tokens), so it must tolerate a source that already carries a leading
248
- // `import { IERC20 } from "./artifacts/IERC20.json";` line, e.g. `nest.ts#nestedTransferProgram`.
249
- const program = acorn.parse(source, {
250
- ecmaVersion: "latest",
251
- sourceType: "module",
252
- });
512
+ const none = {
513
+ source,
514
+ rewrote: false,
515
+ memberSites: 0,
516
+ balanceSites: 0,
517
+ writes: new Set(),
518
+ erc20: false,
519
+ };
520
+ if (tokens.size === 0)
521
+ return none;
522
+ const program = parse(source);
253
523
  const shadowed = collectDeclaredNames(program);
254
- const memberSites = collectMemberCallSites(program, tokens, shadowed);
524
+ const writes = new Set();
525
+ const members = collectMemberCallSites(program, tokens, shadowed, writes);
255
526
  const exclusions = collectValuePositionExclusions(program);
256
527
  const balanceSites = collectBalanceSites(program, tokens, shadowed, exclusions, source);
257
- const allSites = [...memberSites, ...balanceSites];
258
- if (allSites.length === 0) {
259
- return { source, rewrote: false, memberSites: 0, balanceSites: 0 };
260
- }
261
- // Splice from the end backward so earlier offsets stay valid.
262
- const ordered = [...allSites].sort((a, b) => b.start - a.start);
263
- let out = source;
264
- for (const site of ordered) {
265
- out = out.slice(0, site.start) + site.replacement + out.slice(site.end);
266
- }
528
+ const allSites = [...members.sites, ...balanceSites];
529
+ if (allSites.length === 0)
530
+ return none;
531
+ assertLocalsFree(shadowed, writes);
267
532
  return {
268
- source: out,
533
+ source: applySplices(source, allSites),
269
534
  rewrote: true,
270
- memberSites: memberSites.length,
535
+ memberSites: members.sites.length,
271
536
  balanceSites: balanceSites.length,
537
+ writes,
538
+ // A symbol read and the balance sugar both name the typed binding; a write does not.
539
+ erc20: members.reads > 0 || balanceSites.length > 0,
272
540
  };
273
541
  }
274
542
  //# sourceMappingURL=token-rewrite.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-rewrite.js","sourceRoot":"","sources":["../../src/routes/token-rewrite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAgB,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,CAAC,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IAC7D,UAAU;IACV,SAAS;IACT,WAAW;CACZ,CAAC,CAAC;AAwBH,SAAS,cAAc,CAAC,MAAoB,EAAE,MAAc;IAC1D,OAAO,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChE,CAAC;AAED,oGAAoG;AAEpG,SAAS,sBAAsB,CAC7B,OAAgB,EAChB,MAAoB,EACpB,QAA6B;IAE7B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QAClB,IAAI,CAAC,CAAC,IAAI,KAAK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