@eco-incorp/sauce 0.99.0 → 0.99.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +29 -0
- package/README.md +69 -249
- package/actions/dist/to-sauce.d.ts.map +1 -1
- package/actions/dist/to-sauce.js +4 -5
- package/dev-tools/README.md +11 -170
- package/docs/README.md +39 -0
- package/docs/api/README.md +71 -0
- package/docs/api/compiler.md +234 -0
- package/docs/api/coverage.md +117 -0
- package/docs/api/routes.md +110 -0
- package/docs/concepts/architecture.md +134 -0
- package/docs/concepts/saucescript.md +172 -0
- package/docs/examples/README.md +34 -0
- package/docs/examples/compile-program.ts +20 -0
- package/docs/examples/evm-execution.ts +59 -0
- package/docs/examples/first-intent.ts +56 -0
- package/docs/examples/protocol-approval.ts +33 -0
- package/docs/guides/builders-and-actions.md +108 -0
- package/docs/guides/compiling.md +264 -0
- package/docs/guides/intents.md +158 -0
- package/docs/guides/nested-intents.md +79 -0
- package/docs/guides/protocols-and-tokens.md +116 -0
- package/docs/guides/quick-start.md +64 -0
- package/docs/guides/solana.md +196 -0
- package/docs/guides/verification.md +253 -0
- package/package.json +9 -4
- package/sdk/dist/artifacts/V12Deployments.json +82 -0
- package/sdk/dist/artifacts/V12RuntimeBytecode.json +1 -1
- package/sdk/dist/artifacts/svm/engine-devnet.so +0 -0
- package/sdk/dist/artifacts/svm/engine-mainnet.so +0 -0
- package/sdk/dist/artifacts/svm/engine-wire-devnet.json +3 -3
- package/sdk/dist/artifacts/svm/engine-wire-mainnet.json +3 -3
- package/sdk/dist/deployments/index.d.ts +15 -39
- package/sdk/dist/deployments/index.d.ts.map +1 -1
- package/sdk/dist/deployments/index.js +23 -39
- package/sdk/dist/deployments/index.js.map +1 -1
- package/sdk/dist/deployments/v12-addresses.d.ts +85 -0
- package/sdk/dist/deployments/v12-addresses.d.ts.map +1 -0
- package/sdk/dist/deployments/v12-addresses.js +51 -0
- package/sdk/dist/deployments/v12-addresses.js.map +1 -0
- package/sdk/dist/deployments/v12.generated.d.ts +3 -3
- package/sdk/dist/deployments/v12.generated.d.ts.map +1 -1
- package/sdk/dist/deployments/v12.generated.js +3 -3
- package/sdk/dist/deployments/v12.generated.js.map +1 -1
- package/sdk/dist/deposit/index.d.ts +28 -102
- package/sdk/dist/deposit/index.d.ts.map +1 -1
- package/sdk/dist/deposit/index.js.map +1 -1
- package/sdk/dist/deposit/params.d.ts +1 -1
- package/sdk/dist/deposit/params.js +2 -2
- package/sdk/dist/deposit/params.js.map +1 -1
- package/sdk/dist/deposit/source.d.ts +1 -1
- package/sdk/dist/deposit/source.d.ts.map +1 -1
- package/sdk/dist/deposit/source.js +18 -33
- package/sdk/dist/deposit/source.js.map +1 -1
- package/sdk/dist/deposit/types.d.ts +5 -4
- package/sdk/dist/deposit/types.d.ts.map +1 -1
- package/sdk/dist/evm/engine.d.ts +32 -0
- package/sdk/dist/evm/engine.d.ts.map +1 -1
- package/sdk/dist/evm/engine.js +2 -0
- package/sdk/dist/evm/engine.js.map +1 -1
- package/sdk/dist/index.d.ts +1 -0
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +2 -0
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/plugin/index.d.ts +16 -41
- package/sdk/dist/plugin/index.d.ts.map +1 -1
- package/sdk/dist/plugin/index.js +2 -6
- package/sdk/dist/plugin/index.js.map +1 -1
- package/sdk/dist/recipes/index.js +2 -2
- package/sdk/dist/recipes/settle.sauce.ts +1 -1
- package/sdk/dist/routes/index.d.ts +3 -3
- package/sdk/dist/routes/index.js +3 -3
- package/sdk/dist/routes/intent-dsl.d.ts +23 -10
- package/sdk/dist/routes/intent-dsl.d.ts.map +1 -1
- package/sdk/dist/routes/intent-dsl.js +19 -2
- package/sdk/dist/routes/intent-dsl.js.map +1 -1
- package/sdk/dist/routes/nest.d.ts +23 -0
- package/sdk/dist/routes/nest.d.ts.map +1 -1
- package/sdk/dist/routes/nest.js +2 -4
- package/sdk/dist/routes/nest.js.map +1 -1
- package/sdk/dist/routes/protocol-rewrite.d.ts +2 -2
- package/sdk/dist/routes/protocol-rewrite.d.ts.map +1 -1
- package/sdk/dist/routes/protocol-rewrite.js +19 -35
- package/sdk/dist/routes/protocol-rewrite.js.map +1 -1
- package/sdk/dist/routes/sauce-calls.d.ts +7 -13
- package/sdk/dist/routes/sauce-calls.d.ts.map +1 -1
- package/sdk/dist/routes/sauce-calls.js +6 -11
- package/sdk/dist/routes/sauce-calls.js.map +1 -1
- package/sdk/dist/routes/sauce-route.d.ts +24 -53
- package/sdk/dist/routes/sauce-route.d.ts.map +1 -1
- package/sdk/dist/routes/sauce-route.js +5 -6
- package/sdk/dist/routes/sauce-route.js.map +1 -1
- package/sdk/dist/routes/source-globals.generated.d.ts +931 -0
- package/sdk/dist/routes/source-globals.generated.d.ts.map +1 -0
- package/sdk/dist/routes/source-globals.generated.js +7 -0
- package/sdk/dist/routes/source-globals.generated.js.map +1 -0
- package/sdk/dist/std/token/token.svm.js +19 -14
- package/sdk/dist/svm/cpi-probe.d.ts +1 -1
- package/sdk/dist/svm/cpi-probe.d.ts.map +1 -1
- package/sdk/dist/svm/cpi-probe.js +5 -2
- package/sdk/dist/svm/cpi-probe.js.map +1 -1
- package/sdk/dist/svm/intent.d.ts +12 -40
- package/sdk/dist/svm/intent.d.ts.map +1 -1
- package/sdk/dist/svm/intent.js +22 -66
- package/sdk/dist/svm/intent.js.map +1 -1
- package/sdk/dist/svm/venues/byreal/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/byreal/index.js +4 -1
- package/sdk/dist/svm/venues/byreal/index.js.map +1 -1
- package/sdk/dist/svm/venues/carrot/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/carrot/index.js +4 -0
- package/sdk/dist/svm/venues/carrot/index.js.map +1 -1
- package/sdk/dist/svm/venues/cropper/index.d.ts +1 -1
- package/sdk/dist/svm/venues/cropper/index.js +1 -1
- package/sdk/dist/svm/venues/huma/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/huma/index.js +4 -1
- package/sdk/dist/svm/venues/huma/index.js.map +1 -1
- package/sdk/dist/svm/venues/index.d.ts +1 -0
- package/sdk/dist/svm/venues/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/index.js +1 -0
- package/sdk/dist/svm/venues/index.js.map +1 -1
- package/sdk/dist/svm/venues/math.d.ts +4 -1
- package/sdk/dist/svm/venues/math.d.ts.map +1 -1
- package/sdk/dist/svm/venues/math.js +4 -1
- package/sdk/dist/svm/venues/math.js.map +1 -1
- package/sdk/dist/svm/venues/meteora-damm-v1-stable/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/meteora-damm-v1-stable/index.js +4 -1
- package/sdk/dist/svm/venues/meteora-damm-v1-stable/index.js.map +1 -1
- package/sdk/dist/svm/venues/meteora-damm-v2/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/meteora-damm-v2/index.js +5 -2
- package/sdk/dist/svm/venues/meteora-damm-v2/index.js.map +1 -1
- package/sdk/dist/svm/venues/obric-v2/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/obric-v2/index.js +16 -5
- package/sdk/dist/svm/venues/obric-v2/index.js.map +1 -1
- package/sdk/dist/svm/venues/oracle-exponent.d.ts +82 -0
- package/sdk/dist/svm/venues/oracle-exponent.d.ts.map +1 -0
- package/sdk/dist/svm/venues/oracle-exponent.js +97 -0
- package/sdk/dist/svm/venues/oracle-exponent.js.map +1 -0
- package/sdk/dist/svm/venues/orca-legacy-token-swap/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/orca-legacy-token-swap/index.js +4 -1
- package/sdk/dist/svm/venues/orca-legacy-token-swap/index.js.map +1 -1
- package/sdk/dist/svm/venues/pumpswap/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/pumpswap/index.js +19 -13
- package/sdk/dist/svm/venues/pumpswap/index.js.map +1 -1
- package/sdk/dist/svm/venues/raydium-amm-v4/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/raydium-amm-v4/index.js +4 -1
- package/sdk/dist/svm/venues/raydium-amm-v4/index.js.map +1 -1
- package/sdk/dist/svm/venues/raydium-clmm/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/raydium-clmm/index.js +4 -1
- package/sdk/dist/svm/venues/raydium-clmm/index.js.map +1 -1
- package/sdk/dist/svm/venues/raydium-cp-swap/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/raydium-cp-swap/index.js +4 -1
- package/sdk/dist/svm/venues/raydium-cp-swap/index.js.map +1 -1
- package/sdk/dist/svm/venues/scorch/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/scorch/index.js +4 -1
- package/sdk/dist/svm/venues/scorch/index.js.map +1 -1
- package/sdk/dist/svm/venues/stabble-common.d.ts +1 -1
- package/sdk/dist/svm/venues/stabble-common.js +1 -1
- package/sdk/dist/svm/venues/types.d.ts +4 -1
- package/sdk/dist/svm/venues/types.d.ts.map +1 -1
- package/sdk/dist/svm/venues/woofi/index.d.ts.map +1 -1
- package/sdk/dist/svm/venues/woofi/index.js +4 -0
- package/sdk/dist/svm/venues/woofi/index.js.map +1 -1
- package/sdk/dist/svm/verify.d.ts +27 -133
- package/sdk/dist/svm/verify.d.ts.map +1 -1
- package/sdk/dist/svm/verify.js +72 -139
- package/sdk/dist/svm/verify.js.map +1 -1
- package/sdk/dist/swap/index.d.ts +16 -59
- package/sdk/dist/swap/index.d.ts.map +1 -1
- package/sdk/dist/swap/index.js +16 -59
- package/sdk/dist/swap/index.js.map +1 -1
- package/sdk/dist/token/source.d.ts.map +1 -1
- package/sdk/dist/token/source.js +4 -1
- package/sdk/dist/token/source.js.map +1 -1
- package/sdk/dist/verify/decode.d.ts +6 -6
- package/sdk/dist/verify/decode.js +7 -7
- package/sdk/dist/verify/index.js +2 -2
- package/sdk/dist/verify/intent.js +2 -2
- package/sdk/dist/verify/vectors.d.ts +1 -1
- package/sdk/dist/verify/vectors.d.ts.map +1 -1
- package/sdk/dist/verify/vectors.js +2 -2
- package/sdk/dist/verify/vectors.js.map +1 -1
- package/sdk/dist/verify/wire.d.ts +7 -4
- package/sdk/dist/verify/wire.d.ts.map +1 -1
- package/sdk/dist/verify/wire.js +7 -4
- package/sdk/dist/verify/wire.js.map +1 -1
package/LICENSE.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Eco Proprietary License 1.0
|
|
2
|
+
License text copyright (c) 2025-2026 Eco, Inc., All Rights Reserved.
|
|
3
|
+
-----------------------------------------------------------------------------
|
|
4
|
+
Parameters
|
|
5
|
+
Licensor: Eco, Inc.
|
|
6
|
+
Licensed Work: Sauce v1.0
|
|
7
|
+
The Licensed Work is (c) 2025-2026 Eco, Inc.
|
|
8
|
+
Authorized Contracts: The onchain contract addresses (if any) implementing the Licensed Work that
|
|
9
|
+
Eco, Inc. publishes and may update at docs.eco.com
|
|
10
|
+
Additional Use Grant: None
|
|
11
|
+
Change Licenses: None
|
|
12
|
+
-----------------------------------------------------------------------------
|
|
13
|
+
Terms
|
|
14
|
+
Subject to these terms, the Licensor grants you a limited, non-exclusive, non-transferable, revocable license to (i) view the Licensed Work; and (ii) interact with the Authorized Contracts by submitting transactions on supported networks (the "Permitted Uses"). No other rights are granted or implied. All rights not expressly granted are reserved.
|
|
15
|
+
|
|
16
|
+
You may not (and may not permit or enable others to: (i) copy, publish, distribute, host, mirror, or sublicense the Licensed Work, in whole or in part; (ii) modify, translate, adapt, or create derivative works of the Licensed Work; (iii) deploy, verify, or cause to be deployed any smart contract or other software that includes, is based on, or is a modified form of the Licensed Work; (iv) use any portion of the Licensed Work for any product or service, including as-a-service offerings, other than interacting with the Authorized Contracts as permitted above; (v) remove or alter copyright, license, or attribution notices; or (vi) use the Licensor's trademarks or logos except as required to reproduce notices.
|
|
17
|
+
|
|
18
|
+
Portions of the Licensed Work may include or reference third-party components under their own licenses. Those components remain governed by their respective licenses; nothing here limits your rights under those licenses, and nothing in those licenses expands your rights to the Licensed Work.
|
|
19
|
+
|
|
20
|
+
If your intended use falls outside the Permitted Uses you must obtain a separate commercial license from the Licensor or refrain from using the Licensed Work.
|
|
21
|
+
|
|
22
|
+
Any breach of this License immediately terminates your rights. Upon termination, you must cease all use and destroy all copies in your possession or control. Termination is without prejudice to any other remedies available to the Licensor, including injunctive relief.
|
|
23
|
+
|
|
24
|
+
For any Permitted Uses, you must retain this License text and all copyright notices.
|
|
25
|
+
|
|
26
|
+
THE LICENSED WORK IS UNDER DEVELOPMENT AND ACCESS TO AND USE OF IT IS SUBJECT TO LICENSOR'S APPROVAL. THE LICENSED WORK IS PROVIDED "AS IS" AND "AS AVAILABLE," WITHOUT WARRANTY OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY LAW, LICENSOR DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. LICENSOR WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR FOR LOST PROFITS, LOST DATA, OR BUSINESS INTERRUPTION, ARISING OUT OF OR RELATED TO THIS LICENSE OR THE LICENSED WORK, EVEN IF ADVISED OF THE POSSIBILITY.
|
|
27
|
+
-----------------------------------------------------------------------------
|
|
28
|
+
Notice
|
|
29
|
+
This is a proprietary license and is not an open source license. Permission to interact with the Authorized Contracts does not grant any right to copy, modify, distribute, or deploy the Licensed Work or derivative works.
|
package/README.md
CHANGED
|
@@ -1,276 +1,96 @@
|
|
|
1
1
|
# Sauce
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
execution time_ — no contract to deploy, no second block. This one package builds, compiles and
|
|
7
|
-
verifies those programs for both targets, and assembles them into cross-chain intents. Published as
|
|
8
|
-
`@eco-incorp/sauce`.
|
|
3
|
+
Write programmable transactions and Eco intents with **`@eco-incorp/sauce`**. The SDK compiles
|
|
4
|
+
SauceScript into bytecode for the Sauce EVM and Solana runtimes, resolves protocol contracts and
|
|
5
|
+
tokens, and builds the calls that execute your program.
|
|
9
6
|
|
|
10
7
|
```sh
|
|
11
8
|
npm install @eco-incorp/sauce
|
|
12
9
|
```
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
[Documentation](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/README.md) · [Quick start](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/quick-start.md) ·
|
|
12
|
+
[Examples](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/examples/README.md) · [API reference](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/api/README.md)
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
> `eco-incorp/v12` repo. This repo — `eco-incorp/sauce` — is the developer-facing Sauce package that
|
|
18
|
-
> _targets_ it. The EVM target is fully featured (audit planned); the SVM target is in active
|
|
19
|
-
> development, so a few paths below are EVM-only and say so.
|
|
14
|
+
Use Node.js **24 or newer**. The links open the Markdown manual and examples included in this package version. After installation, you can also open `node_modules/@eco-incorp/sauce/docs/README.md` locally.
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
sibling `.wasm` off disk), and the route path imports `node:fs`/`node:path`, so the Quickstart, the
|
|
23
|
-
builders and `/compiler` all require a Node runtime. The registry and decoding subpaths import no
|
|
24
|
-
Node builtin and work anywhere: `/verify`, `/chains`, `/deployments`, `/protocols/*`, `/evm/engine`
|
|
25
|
-
and `/svm/engine`. The
|
|
26
|
-
compiler package does ship a browser build, but this package does not expose it.
|
|
16
|
+
## Programs with protocol and token globals
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## How it works
|
|
31
|
-
|
|
32
|
-
A Sauce program is ordinary TypeScript — a `main()` function — that the compiler lowers to compact
|
|
33
|
-
bytecode. That bytecode runs on the Sauce engine inside a **single transaction**, so the whole
|
|
34
|
-
program is atomic: it reads live state from any number of contracts, branches on what it finds
|
|
35
|
-
(`if`/`else`, loops, arithmetic), and either commits or reverts as a whole. Nothing is deployed — the
|
|
36
|
-
program travels in calldata and executes once.
|
|
37
|
-
|
|
38
|
-
Because the decision happens at execution time, not at signing time, **best execution is a property
|
|
39
|
-
of the program**: it can read several venues and take the winner in the same transaction that
|
|
40
|
-
settles. The shipped recipes show the shape — `cctp-split` splits an amount across capped burns with
|
|
41
|
-
a loop; `settle` reads a Pot's balance and reverts the whole cook when an output would fall short of
|
|
42
|
-
a floor.
|
|
43
|
-
|
|
44
|
-
## Quickstart
|
|
45
|
-
|
|
46
|
-
A **route** packages a program as a cross-chain intent. Hand `openRoute` the destination chain and
|
|
47
|
-
the program source; the SDK compiles it and assembles the `Intent`:
|
|
18
|
+
This complete example builds an intent offline. The repeated-digit addresses and fee are fixtures;
|
|
19
|
+
no transaction is sent. Select a destination chain, then use its contracts and tokens in the program:
|
|
48
20
|
|
|
49
21
|
```ts
|
|
50
|
-
import
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
built.compiled.bytecode[0]; // the program
|
|
75
|
-
built.intent; // the assembled Intent
|
|
76
|
-
built.publishCalldata(); // calldata for sourcePortal — omit sourcePortal above and this throws
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Common token addresses are already there: `routes.TOKEN_REGISTRY` carries probe-verified `USDC` and
|
|
80
|
-
`WETH` for ethereum, optimism, polygon, base and arbitrum, the wrapped native under whatever symbol
|
|
81
|
-
it actually reports (polygon's is `WPOL`), and `USDT` on ethereum and optimism only. `USDT` is absent
|
|
82
|
-
elsewhere because a row is registered under a ticker only when the deployed contract's own `symbol()`
|
|
83
|
-
string-equals it: the Tether-migrated polygon and arbitrum deployments return `USDT0`/`USD₮0` and
|
|
84
|
-
fail that gate, and base's was never probed. So a missing row means "not provenance-verified under
|
|
85
|
-
that ticker", NOT "not deployed" — `tokenDefines` overrides any key when you want one anyway.
|
|
86
|
-
Ask `routes.knownTokenSymbols(requireChain('polygon'))` for what a chain actually carries. Look one up
|
|
87
|
-
with `routes.registryTokenAddress(requireChain('base'), 'USDC')` (`requireChain` is a root export --
|
|
88
|
-
see [Registries](#registries)), which returns a **`bigint`**, or `undefined` when that chain does not
|
|
89
|
-
carry the symbol -- not a `0x` string, so format it yourself if you need one:
|
|
90
|
-
`'0x' + address.toString(16).padStart(40, '0')` gives base USDC as
|
|
91
|
-
`0x833589fcd6edb6e08f4c7c32d4f71b54bda02913`. `openRoute` also folds them in as
|
|
92
|
-
ambient defines, so a route body can write `USDC.transfer(to, amount)` with no configuration at all.
|
|
93
|
-
|
|
94
|
-
`routes.openRoute(destination, …)` is what the chain globals forward to, so
|
|
95
|
-
`Base(sauce, options).reward(…)` is the same call. Those globals are installed on `globalThis` as a
|
|
96
|
-
side effect of importing the package — they are **not** exports, so `import { Base }` fails. Opt out by setting `globalThis.__ECO_ROUTES_NO_GLOBALS__ = true` **before the first import** — it is
|
|
97
|
-
read at module evaluation, so setting it afterwards is too late and silently does nothing. After the
|
|
98
|
-
fact, `uninstallRouteGlobals()` is the one that works. Or just use `routes.openRoute` and ignore
|
|
99
|
-
them.
|
|
100
|
-
|
|
101
|
-
`.reward()` takes a token-amount array as above. A **bare bigint** is a NATIVE reward —
|
|
102
|
-
`.reward(1_000_000n)` posts 1e6 wei of the source chain's gas token, not 1 USDC.
|
|
103
|
-
|
|
104
|
-
> **Route bodies are unannotated SauceScript.** The SDK runs source rewrites over the body before
|
|
105
|
-
> compiling, and those parse plain JS — `function main(): Uint256 { … }` is rejected. Annotated
|
|
106
|
-
> SauceScript is fine when you call the compiler directly (below), just not through a route.
|
|
107
|
-
|
|
108
|
-
## Building programs without writing SauceScript
|
|
109
|
-
|
|
110
|
-
The `token`, `swap` and `deposit` namespaces emit SauceScript for you. `token` returns the source
|
|
111
|
-
and its base dirs together; `swap` and `deposit` return a bare string, with base dirs as separate
|
|
112
|
-
constants:
|
|
113
|
-
|
|
114
|
-
```ts
|
|
115
|
-
import { routes, token } from "@eco-incorp/sauce";
|
|
116
|
-
|
|
117
|
-
// toSauceScript returns the baseDirs the program's own imports need, alongside the source
|
|
118
|
-
const { source, baseDirs } = token.Token.transfer({
|
|
119
|
-
token: usdc,
|
|
120
|
-
to: recipient,
|
|
121
|
-
amount: 1_000_000n,
|
|
122
|
-
}).toSauceScript("evm");
|
|
123
|
-
|
|
124
|
-
const built = routes
|
|
125
|
-
.openRoute("base", source, { ...options, compile: { baseDirs: [...baseDirs] } })
|
|
126
|
-
.reward(reward);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
The `baseDirs` matter: the emitted program does `import { IERC20 } from "./artifacts/IERC20.json"`,
|
|
130
|
-
and a route supplies token base dirs automatically only when its own `USDC.transfer(…)` rewrite
|
|
131
|
-
fires — which it does not for source a builder already emitted. Without them the compile fails on
|
|
132
|
-
that import. Spread them: `toSauceScript`'s array is `readonly`, the option is not.
|
|
133
|
-
|
|
134
|
-
`.source(target)` gives you the source alone if you are supplying `baseDirs` yourself.
|
|
135
|
-
|
|
136
|
-
`swap` and `deposit` have no `toSauceScript`. They return the source directly, so pair each with its
|
|
137
|
-
own constant:
|
|
138
|
-
|
|
139
|
-
```ts
|
|
140
|
-
import { routes, swap, deposit } from "@eco-incorp/sauce";
|
|
141
|
-
|
|
142
|
-
routes
|
|
143
|
-
.openRoute("base", swap.swapSource(spec), {
|
|
144
|
-
...options,
|
|
145
|
-
compile: { baseDirs: [...swap.SWAP_BASE_DIRS] },
|
|
146
|
-
})
|
|
147
|
-
.reward(reward);
|
|
148
|
-
|
|
149
|
-
routes
|
|
150
|
-
.openRoute("base", deposit.depositSource(spec), {
|
|
151
|
-
...options,
|
|
152
|
-
compile: { baseDirs: [...deposit.DEPOSIT_BASE_DIRS] },
|
|
153
|
-
})
|
|
154
|
-
.reward(reward);
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
`routes.compileSauceRoute` is the lower level underneath, if you want the compiled call without an
|
|
158
|
-
intent — it returns `{ calls, compiled, source }` and has no `.reward()`.
|
|
159
|
-
|
|
160
|
-
**On the SVM target this route path does not work.** `toSauceScript('svm')` emits `main` with typed
|
|
161
|
-
account parameters — that parameter list _is_ the account manifest, so it cannot be dropped — and a
|
|
162
|
-
route runs an acorn-based accessor rewrite that rejects annotations. `compile: { accessors: false }` gets past the parse, but a route then still requires
|
|
163
|
-
`execution.code` naming an already-staged code account, so unless you have staged one, compile
|
|
164
|
-
the source directly instead.
|
|
165
|
-
|
|
166
|
-
## The compiler
|
|
167
|
-
|
|
168
|
-
`/compiler` re-exports the published Rust/wasm SauceScript compiler:
|
|
169
|
-
|
|
170
|
-
```ts
|
|
171
|
-
import { compile } from "@eco-incorp/sauce/compiler";
|
|
172
|
-
|
|
173
|
-
const { bytecode } = compile({
|
|
174
|
-
target: "evm", // or 'svm'
|
|
175
|
-
entry: "main.js",
|
|
176
|
-
resolve: (path) => bytesFor(path), // module BYTES (Uint8Array), or undefined
|
|
22
|
+
import "@eco-incorp/sauce";
|
|
23
|
+
import type { routes } from "@eco-incorp/sauce";
|
|
24
|
+
|
|
25
|
+
// Offline fixtures. Read the destination Kitchen fee and use an Executor-owned Pot before use.
|
|
26
|
+
const executionFee = 1_000n;
|
|
27
|
+
const options: routes.IntentOptions = {
|
|
28
|
+
execution: {
|
|
29
|
+
pot: "0x1111111111111111111111111111111111111111",
|
|
30
|
+
engine: "0x2222222222222222222222222222222222222222",
|
|
31
|
+
value: executionFee,
|
|
32
|
+
},
|
|
33
|
+
nativeAmount: executionFee,
|
|
34
|
+
portal: "0x3333333333333333333333333333333333333333",
|
|
35
|
+
deadline: 2_000_000_000n,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const built = Base(() => {
|
|
39
|
+
USDC.approve(Uniswap.UniversalRouter, 1_000_000n);
|
|
40
|
+
}, options).reward({
|
|
41
|
+
source: "ethereum",
|
|
42
|
+
creator: "0x4444444444444444444444444444444444444444",
|
|
43
|
+
prover: "0x5555555555555555555555555555555555555555",
|
|
44
|
+
deadline: 2_000_003_600n,
|
|
45
|
+
nativeAmount: 0n,
|
|
177
46
|
});
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
`main` may take parameters. They arrive at run time as 32-byte big-endian words appended after the
|
|
181
|
-
program, on **both** targets, so one program serves many argument sets — compile-time substitution is
|
|
182
|
-
`defines` instead.
|
|
183
|
-
|
|
184
|
-
That applies to a **direct `compile`**. A route slots `compiled.bytecode[0]` in as the whole cook
|
|
185
|
-
ingredient and appends no argument tail, so a parameterized `main` in a route body reads past the end
|
|
186
|
-
of its own ingredient. Use `defines` for routes, parameters for programs you assemble yourself.
|
|
187
|
-
|
|
188
|
-
A `bytes` parameter is not padded — it occupies its fixed compile-time length, so the tail is not
|
|
189
|
-
uniformly 32-byte words once one is present.
|
|
190
|
-
|
|
191
|
-
Neither call returns an argument layout, so callers build the tail themselves. Mind which
|
|
192
|
-
`CompileResult` you have — there are two, and they are not the same shape:
|
|
193
47
|
|
|
194
|
-
|
|
195
|
-
| -------------- | ------------------------------------------------ | ------------------------------------- |
|
|
196
|
-
| the compiler's | `{ bytecode: Uint8Array; manifest? }` | a direct `compile` |
|
|
197
|
-
| the SDK's | `{ bytecode: Uint8Array[]; warnings: string[] }` | `built.compiled`, `compileSauceRoute` |
|
|
198
|
-
|
|
199
|
-
The SDK's `bytecode` is a list of SEGMENTS, so `compiled.bytecode[0]` is the first segment, not the
|
|
200
|
-
first byte. On **SVM** an `Account`-typed parameter is not a payload argument at all: it becomes the
|
|
201
|
-
account manifest in the COMPILER's `CompileResult.manifest` — the route seam drops it
|
|
202
|
-
(`rs-compile.ts`), so `built.compiled.manifest` is `undefined` with no error. An SVM caller that
|
|
203
|
-
needs the manifest compiles through `svm/` directly.
|
|
204
|
-
|
|
205
|
-
A `main` that falls off the end has no return type of its own, and a raw `compile` rejects it
|
|
206
|
-
(`` `main` does not return on every path ``). Generated programs hit this whenever they fall through
|
|
207
|
-
— which most do, though not all: a trailing `Token.balanceOf` emits a `return`, and annotating that
|
|
208
|
-
one `: void` would break it. Either annotate it yourself (`function main(): void { … }`) or go through
|
|
209
|
-
`routes.compileSauceRoute`, which annotates it for you. Note that one takes
|
|
210
|
-
`(destination, sauce, execution, options)`: the execution seam is required, and an SVM destination
|
|
211
|
-
needs an already-staged buffer, so it is the route path rather than a bare compile helper.
|
|
212
|
-
|
|
213
|
-
## Registries
|
|
214
|
-
|
|
215
|
-
129 protocols and 40 canonical chains ship with the package — 39 EVM plus Solana:
|
|
216
|
-
|
|
217
|
-
```ts
|
|
218
|
-
import { listProtocols, getProtocol, requireChain } from "@eco-incorp/sauce";
|
|
219
|
-
|
|
220
|
-
listProtocols().length; // 129
|
|
221
|
-
getProtocol("uniswap-v3"); // metadata: category, per-chain deployments, audit status
|
|
222
|
-
// (ABIs live on the subpath: '@eco-incorp/sauce/protocols/uniswap-v3')
|
|
48
|
+
console.log(built.hash().intentHash);
|
|
223
49
|
```
|
|
224
50
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
resolves.
|
|
51
|
+
The [quick start](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/quick-start.md) explains the setup, and the [examples](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/examples/README.md) are checked
|
|
52
|
+
against the SDK. The callback is compiled as source. Token and protocol names resolve on Base;
|
|
53
|
+
values from surrounding JavaScript must be supplied through compile-time `defines`.
|
|
229
54
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
55
|
+
Use `USDC.transfer(...)`, `USDC.balanceOf(...)`, `Token(address).approve(...)`, and linked protocol
|
|
56
|
+
methods in the same program. `Uniswap.UniversalRouter` is the family alias for
|
|
57
|
+
`UniswapV4.UniversalRouter`; available contracts and methods come from the
|
|
58
|
+
[accessor registry](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/api/coverage.md). The compiler checks chain availability and ABI fidelity.
|
|
233
59
|
|
|
234
|
-
##
|
|
60
|
+
## From a program to an intent
|
|
235
61
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
| `/compiler` | the SauceScript compiler |
|
|
240
|
-
| `/actions` | routing-intent lowering (`actionsToSauce`), AMM/bridge action primitives |
|
|
241
|
-
| `/protocols/*` | one protocol's ABIs and metadata, e.g. `/protocols/uniswap-v3` |
|
|
242
|
-
| `/chains`, `/deployments` | canonical chain list; deployed contract addresses |
|
|
243
|
-
| `/recipes` | shipped programs (settle, CCTP split-transfer) and their sources |
|
|
244
|
-
| `/svm`, `/svm/engine`, `/svm/verify` | SVM client, account resolution, engine harness, settle verification |
|
|
245
|
-
| `/recipes/settle.sauce.ts`, `/svm/recipes/settle.sauce.ts` | the settle program sources themselves, for partners reproducing bytes |
|
|
246
|
-
| `/evm/engine` | EVM engine helpers |
|
|
247
|
-
| `/verify` | decodes **legacy v1-grammar** settle programs. `viem`-only, browser-safe |
|
|
248
|
-
| `/skills` | AI skill files per protocol |
|
|
62
|
+
`Base(body, options).reward(reward)` compiles a destination program and constructs an Eco intent.
|
|
63
|
+
The result exposes the intent, bytecode, hashes, and Portal transaction requests. Your application
|
|
64
|
+
submits those requests. Direct Portal execution requires an Executor-owned Pot and native value for the Kitchen execution fee. Use `.nest(...)` to compose intents with separate executions and funding.
|
|
249
65
|
|
|
250
|
-
|
|
251
|
-
|
|
66
|
+
Use the direct Kitchen client for Solana execution. The legacy SVM intent helper is incompatible
|
|
67
|
+
with the released gated engine; the Solana guide below describes this boundary.
|
|
252
68
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
69
|
+
- [Create and fund an intent](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/intents.md)
|
|
70
|
+
- [Compose nested intents](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/nested-intents.md)
|
|
71
|
+
- [Build programs with token, swap, deposit, and action helpers](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/builders-and-actions.md)
|
|
72
|
+
- [Execute on Solana](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/solana.md)
|
|
73
|
+
- [Verify settlement programs](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/verification.md)
|
|
256
74
|
|
|
257
|
-
##
|
|
75
|
+
## Compiler and runtime
|
|
258
76
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
pnpm test
|
|
264
|
-
```
|
|
77
|
+
The SDK includes **`@eco-incorp/sauce-compiler`**, the Rust/WebAssembly SauceScript compiler, and
|
|
78
|
+
exposes it through `@eco-incorp/sauce/compiler`. Compile directly when you need entry arguments,
|
|
79
|
+
custom module resolution, or SVM account manifests. See the [compiler guide](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/compiling.md)
|
|
80
|
+
and [compiler API](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/api/compiler.md).
|
|
265
81
|
|
|
266
|
-
|
|
82
|
+
SauceScript supports contract calls, arithmetic, control flow, and composition within the
|
|
83
|
+
[compiler's language subset](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/concepts/saucescript.md). A program executes atomically in one
|
|
84
|
+
transaction on its target chain. Cross-chain intents coordinate separate transactions.
|
|
267
85
|
|
|
268
|
-
|
|
86
|
+
The root SDK and its compiler integration require Node.js **24 or newer**. The compiler dependency also has its
|
|
87
|
+
own browser entry point. See [architecture](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/concepts/architecture.md) for how the SDK,
|
|
88
|
+
compiler, and deployed runtime work together.
|
|
269
89
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
```
|
|
90
|
+
Current release pins: compiler **2.3.0**, EVM and SVM engines **1.0.1**, both Kitchens
|
|
91
|
+
**1.0.0**. Release addresses do not establish on-chain deployment status.
|
|
273
92
|
|
|
274
|
-
The
|
|
275
|
-
|
|
276
|
-
|
|
93
|
+
The EVM settle program compiles to **356 bytes** with a new verification hash. Recompile and
|
|
94
|
+
invalidate cached programs when upgrading; to verify existing 362-byte payloads, pass their
|
|
95
|
+
historical `{ hash, bytes: 362 }` pin to `validateSettleProgram` (see
|
|
96
|
+
[verification](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/verification.md)).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-sauce.d.ts","sourceRoot":"","sources":["../src/to-sauce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAeL,KAAK,OAAO,EACZ,KAAK,IAAI,EAET,KAAK,IAAI,EACV,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EACV,aAAa,EA2Cd,MAAM,YAAY,CAAC;AAkEpB,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;CACvB;AAMD,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"to-sauce.d.ts","sourceRoot":"","sources":["../src/to-sauce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAeL,KAAK,OAAO,EACZ,KAAK,IAAI,EAET,KAAK,IAAI,EACV,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EACV,aAAa,EA2Cd,MAAM,YAAY,CAAC;AAkEpB,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;CACvB;AAMD,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAiC9E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,UAAU,CAI5E;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,IAAI,EACd,WAAW,EAAE,OAAO,GACnB,YAAY,CA2Fd"}
|
package/actions/dist/to-sauce.js
CHANGED
|
@@ -74,12 +74,11 @@ export function actionsToSauceSource(actions) {
|
|
|
74
74
|
for (let i = 0; i < actions.length; i++) {
|
|
75
75
|
const action = actions[i];
|
|
76
76
|
const amountIn = resolveAmountIn(getExplicitAmount(action), action.amountRef, lastOutputSlot);
|
|
77
|
-
|
|
77
|
+
const nextAction = actions[i + 1];
|
|
78
78
|
const needsStore = action.saveOutputAs !== undefined ||
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
.
|
|
82
|
-
actions.slice(i + 1).some((a) => a.amountRef === action.saveOutputAs);
|
|
79
|
+
(nextAction !== undefined &&
|
|
80
|
+
getExplicitAmount(nextAction) === undefined &&
|
|
81
|
+
nextAction.amountRef === undefined);
|
|
83
82
|
const result = buildAction(emit, action, amountIn, needsStore);
|
|
84
83
|
body.push(...result.stmts);
|
|
85
84
|
if (needsStore) {
|
package/dev-tools/README.md
CHANGED
|
@@ -1,175 +1,16 @@
|
|
|
1
|
-
# Sauce
|
|
1
|
+
# Sauce example projects
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
To build an application with Sauce, install the SDK:
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pnpm install
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
# Start a local Hardhat network with Sauce deployed
|
|
15
|
-
npm run start:local
|
|
16
|
-
|
|
17
|
-
# Or start a forked mainnet (requires FORK_URL env var)
|
|
18
|
-
FORK_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY npm run start:fork
|
|
19
|
-
|
|
20
|
-
# Run a SauceScript
|
|
21
|
-
npm run sauce sauce/call.js [arg1] [arg2] ...
|
|
22
|
-
|
|
23
|
-
# Stop the network
|
|
24
|
-
npm run stop
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Scripts
|
|
28
|
-
|
|
29
|
-
| Command | Description |
|
|
30
|
-
| ---------------------- | -------------------------------------------- |
|
|
31
|
-
| `npm run start:local` | Start local Hardhat network and deploy Sauce |
|
|
32
|
-
| `npm run start:fork` | Start forked mainnet and deploy Sauce |
|
|
33
|
-
| `npm run stop` | Stop the running network |
|
|
34
|
-
| `npm run sauce <file>` | Compile and execute a SauceScript |
|
|
35
|
-
| `npm run build` | Compile TypeScript |
|
|
36
|
-
|
|
37
|
-
## Writing SauceScript
|
|
38
|
-
|
|
39
|
-
SauceScript files (`.js`) use JavaScript syntax that compiles to Sauce VM bytecode.
|
|
40
|
-
|
|
41
|
-
### Basic Example
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
function main() {
|
|
45
|
-
return 42;
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### With Arguments
|
|
50
|
-
|
|
51
|
-
Arguments are passed as parameters to `main()`:
|
|
52
|
-
|
|
53
|
-
```javascript
|
|
54
|
-
function main(a, b) {
|
|
55
|
-
return a + b;
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Run with: `npm run sauce script.js 10 20`
|
|
60
|
-
|
|
61
|
-
### Contract Calls
|
|
62
|
-
|
|
63
|
-
Import ABIs from npm packages and call external contracts:
|
|
64
|
-
|
|
65
|
-
```javascript
|
|
66
|
-
import { IUniswapV3Factory } from "@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Factory.sol/IUniswapV3Factory.json";
|
|
67
|
-
|
|
68
|
-
function main(factoryAddress, token0, token1) {
|
|
69
|
-
const factory = IUniswapV3Factory.at(factoryAddress);
|
|
70
|
-
return factory.getPool(token0, token1, 3000);
|
|
71
|
-
}
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add @eco-incorp/sauce
|
|
72
7
|
```
|
|
73
8
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
npm run sauce sauce/call.js \
|
|
78
|
-
0x1F98431c8aD98523631AE4a59f267346ea31F984 \
|
|
79
|
-
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
|
|
80
|
-
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Arguments
|
|
84
|
-
|
|
85
|
-
Positional arguments are RUNTIME values for `main`'s parameters. They are appended to the compiled
|
|
86
|
-
program as ABI-encoded words, so the program bytes are the same whatever you pass. They parse as:
|
|
87
|
-
|
|
88
|
-
- Decimal numbers: `123`, `456`, `-1`
|
|
89
|
-
- Hex values: `0x1a2b3c...` (over 32 bytes: passed as `bytes`)
|
|
90
|
-
|
|
91
|
-
A `NAME=VALUE` operand is a COMPILE-TIME define instead: it replaces the module's own `const NAME`
|
|
92
|
-
and is constant-folded, so a different value is a different program.
|
|
93
|
-
|
|
94
|
-
```javascript
|
|
95
|
-
const AMOUNT = 0n; // overridden by AMOUNT=4242
|
|
96
|
-
|
|
97
|
-
function main(a) {
|
|
98
|
-
return a + AMOUNT; // `a` comes from a positional arg
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Run with: `npm run sauce script.js 10 AMOUNT=4242`. The two are told apart by shape — a define's
|
|
103
|
-
name is an identifier, which no integer or hex literal can look like — so they may be interleaved.
|
|
104
|
-
|
|
105
|
-
A define's VALUE is one unsigned 256-bit word. `0x`-hex is passed through as written; any other
|
|
106
|
-
spelling JavaScript's `BigInt` reads (decimal, `0b`/`0o`, a leading `+`, leading zeros, surrounding
|
|
107
|
-
whitespace) is normalized to decimal, because the compiler's own define grammar accepts only decimal
|
|
108
|
-
or `0x`-hex. An empty, all-whitespace, negative, or non-integer value is rejected at the CLI.
|
|
109
|
-
|
|
110
|
-
## Project Structure
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
dev-tools/
|
|
114
|
-
├── scripts/
|
|
115
|
-
│ ├── run.ts # SauceScript runner
|
|
116
|
-
│ ├── deploy.ts # Sauce contract deployment
|
|
117
|
-
│ ├── start-local.sh # Start local network
|
|
118
|
-
│ ├── start-fork.sh # Start forked network
|
|
119
|
-
│ └── stop-local.sh # Stop network
|
|
120
|
-
├── src/
|
|
121
|
-
│ ├── contracts.ts # Contract helpers
|
|
122
|
-
│ └── runner.ts # Compilation & execution
|
|
123
|
-
├── sauce/
|
|
124
|
-
│ ├── js/ # Example SauceScripts (JavaScript)
|
|
125
|
-
│ │ ├── add.js
|
|
126
|
-
│ │ ├── call.js
|
|
127
|
-
│ │ ├── erc20.js
|
|
128
|
-
│ │ ├── example.js
|
|
129
|
-
│ │ └── fibonacci.js
|
|
130
|
-
│ └── ts/ # Example SauceScripts (TypeScript)
|
|
131
|
-
│ ├── add.ts
|
|
132
|
-
│ ├── call.ts
|
|
133
|
-
│ ├── erc20.ts
|
|
134
|
-
│ ├── example.ts
|
|
135
|
-
│ └── fibonacci.ts
|
|
136
|
-
├── test/
|
|
137
|
-
│ ├── examples.test.ts # Compilation tests for all examples
|
|
138
|
-
│ └── e2e.test.ts # End-to-end integration tests
|
|
139
|
-
└── artifacts/ # Sauce engine contract artifact
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Note:** The Sauce contract artifact is loaded from `engine/out/Sauce.sol/Sauce.json`. Run `forge build` in the engine folder if it doesn't exist.
|
|
143
|
-
|
|
144
|
-
## Local SVM e2e
|
|
145
|
-
|
|
146
|
-
`src/svm-local.ts` runs a compiled SVM program through the **real gated engine** in-process — no
|
|
147
|
-
validator, no credentials — using the same LiteSVM + kitchen + Pot orchestration the SDK's own suites
|
|
148
|
-
use (`sdk/test/svm/engine-harness.ts`). It is a repo-dev harness: `litesvm` is a dev dependency here,
|
|
149
|
-
like `hardhat` is for `start:local`. `test/svm-local.test.ts` is a runnable example.
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
import { compile } from "@eco-incorp/sauce/compiler";
|
|
153
|
-
import { runSvmProgramLocally } from "../src/svm-local";
|
|
154
|
-
|
|
155
|
-
const { bytecode, manifest } = compile({ target: "svm", entry: "main.js", resolve });
|
|
156
|
-
const { err, logs } = await runSvmProgramLocally(bytecode, manifest, { resolution: {} });
|
|
157
|
-
if (err) throw new Error(`cook rejected: ${err}\n${logs.join("\n")}`);
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
`resolution` maps the manifest's account refs to addresses (empty for a self-contained program). A
|
|
161
|
-
released engine refuses anything that did not arrive through a kitchen cook, so this asserts the gate
|
|
162
|
-
accepts what you built. It needs the engine binaries present — run
|
|
163
|
-
`pnpm --filter './sdk' sync-engine-artifacts --fetch-v12-engines`, and it skips when they are absent.
|
|
164
|
-
Run one program at a time (await each call): `runSvmProgramLocally` routes the client's RPC by
|
|
165
|
-
swapping `globalThis.fetch` for the length of a run, so overlapping calls would collide.
|
|
166
|
-
|
|
167
|
-
**Consumers** get the piece they cannot fetch themselves — the engine binaries — shipped in the
|
|
168
|
-
package and located by `@eco-incorp/sauce/svm/engine-artifacts` (`svmEnginePath` / `svmKitchenPath`).
|
|
169
|
-
With those plus their own `litesvm`, `svm-local.ts` is the reference harness to build local e2e tests
|
|
170
|
-
of their own SVM programs.
|
|
171
|
-
|
|
172
|
-
## Requirements
|
|
9
|
+
Follow the [quick start](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/quick-start.md)
|
|
10
|
+
and [executable examples](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/examples/README.md)
|
|
11
|
+
for compiling programs and constructing Eco intents in your own project. You can also open the installed manual at `node_modules/@eco-incorp/sauce/docs/README.md`.
|
|
173
12
|
|
|
174
|
-
-
|
|
175
|
-
|
|
13
|
+
The `sauce-dev-tools` scaffold contains older local deployment and execution scripts. Those scripts
|
|
14
|
+
target an earlier EVM contract interface and are incompatible with current Kitchen/Pot deployments.
|
|
15
|
+
Use the SDK's [execution guides](https://unpkg.com/@eco-incorp/sauce@0.99.2/docs/guides/compiling.md)
|
|
16
|
+
for current programs.
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Sauce documentation
|
|
2
|
+
|
|
3
|
+
Build programmable EVM and Solana transactions with `@eco-incorp/sauce`, and compose EVM
|
|
4
|
+
executions into Eco intents. Solana execution uses the direct Kitchen client; the
|
|
5
|
+
[legacy SVM intent helper](guides/solana.md#svm-destinations-in-eco-intents) is incompatible
|
|
6
|
+
with the released engine.
|
|
7
|
+
|
|
8
|
+
**New here?** Follow the [quick start](guides/quick-start.md), explore
|
|
9
|
+
[token and protocol globals](guides/protocols-and-tokens.md), then
|
|
10
|
+
[create and fund an intent](guides/intents.md). Complete programs live in the
|
|
11
|
+
[examples](examples/README.md).
|
|
12
|
+
|
|
13
|
+
## Concepts
|
|
14
|
+
|
|
15
|
+
| Read | Learn |
|
|
16
|
+
| ---------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
17
|
+
| [Architecture](concepts/architecture.md) | How the SDK, compiler package, on-chain engine, and Eco intents fit together |
|
|
18
|
+
| [SauceScript](concepts/saucescript.md) | Execution model, source closures, supported language constructs, and target differences |
|
|
19
|
+
|
|
20
|
+
## Guides
|
|
21
|
+
|
|
22
|
+
| Task | Guide |
|
|
23
|
+
| ----------------------------------------------------- | ------------------------------------------------------ |
|
|
24
|
+
| Install and build your first intent | [Quick start](guides/quick-start.md) |
|
|
25
|
+
| Use `USDC`, `Token(address)`, and protocol namespaces | [Protocols and tokens](guides/protocols-and-tokens.md) |
|
|
26
|
+
| Construct, fund, and inspect an intent | [Eco intents](guides/intents.md) |
|
|
27
|
+
| Compose multiple intent executions | [Nested intents](guides/nested-intents.md) |
|
|
28
|
+
| Compile directly and encode runtime arguments | [Compiling programs](guides/compiling.md) |
|
|
29
|
+
| Generate programs from structured inputs | [Builders and actions](guides/builders-and-actions.md) |
|
|
30
|
+
| Plan accounts, stage code, and execute on SVM | [Solana](guides/solana.md) |
|
|
31
|
+
| Check a settlement payload | [Verification](guides/verification.md) |
|
|
32
|
+
|
|
33
|
+
## Reference and examples
|
|
34
|
+
|
|
35
|
+
- [API entry points](api/README.md): published imports and where to find each feature.
|
|
36
|
+
- [Compiler API](api/compiler.md): compiler options, output metadata, and argument encoding.
|
|
37
|
+
- [Routes API](api/routes.md): execution options, intent builders, and Portal helpers.
|
|
38
|
+
- [Registry coverage](api/coverage.md): protocols, source globals, tokens, and chain registries.
|
|
39
|
+
- [Examples](examples/README.md): complete examples and how they are validated.
|