酱油
酱油 构建、编译和验证Sauce程序:其程序执行方式为
生态布特上的字节代码. 一个用于EVM和SVM的TypeScript包. 发表于 @eco-incorp/sauce。 。 。 .
npm install @eco-incorp/sauce
运行时间 引擎 (链上解释器 这些程序执行) 生活在单独的
eco-incorp/v12复发. 这回电..eco-incorp/sauce- 是开发者制作的Sauce软件包 目标 这个.
只有节点. 编译器通过 createRequire (数量) node 构建为普通JS读取a
兄长 .wasm )和路径路径导入 node:fs编号 :node:path因此,快速启动
建造者和 /compiler 都需要节点运行时间。 注册和解码子路径导入否
节点构建和工作在任何地方: /verify, (中文(简体) ), /chains, (中文(简体) ), /deployments, (中文(简体) ), /protocols/*, (中文(简体) ), /evm/engine
财务报告和审定财务报表 /svm/engine编辑
编译器包确实运送了浏览器的构建,但是这个包并没有暴露出来.
SauceScript编译器作为依赖性随而来. 没有可选的同龄人.
快速启动
在目的地链上打开一条路由,SDK编译程序并组装意图:
import { routes } from "@eco-incorp/sauce";
// Both deadlines are ABSOLUTE unix timestamps, not durations: the chain compares
// `block.timestamp > route.deadline`. And rewardDeadline must be >= deadline — a solver may fulfil
// right up to the route deadline, so an earlier reward deadline is already refundable by then.
// pot, portal, sourcePortal, creator and prover are addresses for YOUR deployment; the package
// ships no defaults for those. Token addresses it does ship — see the registry note below.
const now = BigInt(Math.floor(Date.now() / 1000));
const built = routes
.openRoute("base", "function main() { return 1n; }", {
source: "ethereum", // the SOURCE chain — where the reward is posted
pot, // the Pot on the destination chain, which runs the program
portal, // the DESTINATION Portal — lands in route.portal
sourcePortal, // the SOURCE Portal — where the intent is published
creator,
prover,
deadline: now + 3600n,
rewardDeadline: now + 7200n,
})
.reward([{ token: usdc, amount: 1_000_000n }]);
built.compiled.bytecode[0]; // the program
built.intent; // the assembled Intent
built.publishCalldata(); // calldata for sourcePortal — omit sourcePortal above and this throws
常见的代号地址已经存在 : routes.TOKEN_REGISTRY 携带探测器 USDC 财务报告和审定财务报表
WETH 以任何符号包裹的原生生物
它实际上报告(polygon's WPOL),以及 USDT 只有乐观和乐观. USDT 缺席
在别处,因为一行只登记在已部署合同本身的计数器下 symbol()
字符串等同它: 带宽多边形和弧度部署返回 USDT0编号 :USD₮0 财务报告和审定财务报表
炸掉那道门 基地从未被探测过 所以,缺一行的意思是"不是来源 核实在下面
滴答,不是"没有部署" tokenDefines 无论如何,如果想要任何密钥, 都会覆盖它.
询问 routes.knownTokenSymbols(requireChain('polygon')) 连锁店到底装了什么 看一个
与 routes.registryTokenAddress(requireChain('base'), 'USDC') (单位:千美元)requireChain 是根导出 --
见 书记官处返回 a bigint,或 undefined 当链子没有
带有符号 -- -- 不是 0x 字符串,如果需要,请自行格式化:
'0x' + address.toString(16).padStart(40, '0') 给出基础 USDC 为
0x833589fcd6edb6e08f4c7c32d4f71b54bda02913。 。 。 . openRoute 并把它们折成
环境定义, 这样路由体可以写 USDC.transfer(to, amount) 完全没有配置.
routes.openRoute(destination, …) 是链条全球前进,所以
Base(sauce, options).reward(…) 同一个电话。 这些全局器安装在 globalThis 作为
导入软件包的副作用——它们是 没有 出口,所以 import { Base } 失败。 通过设置选择退出 globalThis.__ECO_ROUTES_NO_GLOBALS__ = true 在第一次导入之前 - 没错
在模块评价中读取,所以事后设定为为时已晚,默默无所事事. 之后
事实上, uninstallRouteGlobals() 就是那个能起作用的 或只是使用 routes.openRoute 忽略
他们.
.reward() 如上,取一个符号-挂载数组。 A 类 赤裸的宽度 是一种自然的回报
.reward(1_000_000n) (原始内容存档于2013-10-12). posts 1e6 wei of the source chain's gas sorder, not 1 USDC.
路由体是无附加说明的 SauceScript. SDK运行源头重写在身体上之前 以及那些简单的联署材料
function main(): Uint256 { … }被拒绝。 附加说明 直接拨打编译器(下方)时,SauceScript是好的,只是没有经过一条路由.
不写入 SauceScript 构建程序
这个 token, (中文(简体) ), swap 财务报告和审定财务报表 deposit 命名空间为您发送 SauceScript . token 返回源代码
及其基底; swap 财务报告和审定财务报表 deposit 返回一个空字符串, 以底盘为分离
常数 :
import { routes, token } from "@eco-incorp/sauce";
// toSauceScript returns the baseDirs the program's own imports need, alongside the source
const { source, baseDirs } = token.Token.transfer({
token: usdc,
to: recipient,
amount: 1_000_000n,
}).toSauceScript("evm");
const built = routes
.openRoute("base", source, { ...options, compile: { baseDirs: [...baseDirs] } })
.reward(reward);
这个 baseDirs 物质: 已发射的程序 import { IERC20 } from "./artifacts/IERC20.json", (中文(简体) ),
和一条路由提供符号底盘 只有在它自己的 USDC.transfer(…) 重写
火灾——不是已经排放的建造者的来源。 没有它们,编译失败
那个进口。 展开它们: toSauceScript阵列是 readonly,选择不是.
.source(target) 如果你有补给,就只给你来源 baseDirs 你自己来.
swap 财务报告和审定财务报表 deposit 没有 toSauceScript。它们直接返回源头,所以每个对齐它的
自己的常数 :
import { routes, swap, deposit } from "@eco-incorp/sauce";
routes
.openRoute("base", swap.swapSource(spec), {
...options,
compile: { baseDirs: [...swap.SWAP_BASE_DIRS] },
})
.reward(reward);
routes
.openRoute("base", deposit.depositSource(spec), {
...options,
compile: { baseDirs: [...deposit.DEPOSIT_BASE_DIRS] },
})
.reward(reward);
routes.compileSauceRoute 是下面的下层, 如果您想要编译的调用没有
意图——它返回 { calls, compiled, source } 没有 .reward()。 。 。 .
在SVM目标上,这条路由路径不起作用. toSauceScript('svm') 发射 main 键入
账户参数——该参数列表 实值 (a) 账户清单,因此不能删除
路由运行一个基于橡树的存取器重写拒绝注释. compile: { accessors: false } 绕过剖面,但路径仍然需要
execution.code 命名一个已经设置的代码账户, 因此, 除非您已经设置了一个代码账户, 编译
直接的源头.
编译器
/compiler 重新导出已出版的 Rust/wasm SauceScript 编译器 :
import { compile } from "@eco-incorp/sauce/compiler";
const { bytecode } = compile({
target: "evm", // or 'svm'
entry: "main.js",
resolve: (path) => bytesFor(path), // module BYTES (Uint8Array), or undefined
});
main 可能需要参数。 他们以32字节的大字尾的字作为运行时间到达的
程序,打开 两者 因此,一个程序为许多参数集服务——编译时间替代是
defines 换句话说.
这适用于 直接 compile路径槽 compiled.bytecode[0] 作为厨师
成分和附件无参数尾巴,所以参数化 main 在路由中读取过尾端
拥有自己的成分。 使用 defines 对于路线,参数 程序你组装自己.
A 类 bytes 参数不添加——它占用了固定的编译时间长度,所以尾部不是
统一32字节单词,一旦出现.
两个调用都返回了参数布局,所以调用者自己建立尾巴. 当心
CompileResult 你们有两种不同的形状:
| 形状 | 从 | |
|---|---|---|
| 编译器 | { bytecode: Uint8Array; manifest? } | 一个直接 compile |
| sDK的车 | { bytecode: Uint8Array[]; warnings: string[] } | built.compiled, (中文(简体) ), compileSauceRoute |
SDK的车 bytecode 是一个组件列表,所以 compiled.bytecode[0] 是第一部分,不是
第一字节。 打开 特别志愿人员 a 一个 Account- 类型参数根本不是一个有效载荷参数:它成为
显示于COMPILER的账户 CompileResult.manifest ——路由接合使其脱落
(单位:千美元)rs-compile.ts),这样 built.compiled.manifest 实值 undefined 没有错误。 一个 SVM 呼叫器
需要通过 svm/ 直接说.
A 类 main 从尾部掉下来的 没有它自己的返回类型, 一个生的 compile 拒绝它
(单位:千美元)`main` does not return on every path) (中文(简体) ). 制作的程式每经过一次都会击中它
- 多数人这样做,但不是全部,是落后的 Token.balanceOf 输出 a return,并注明
一个 : void 会打破它。 要么自己记下来function main(): void { … })或经历
routes.compileSauceRoute为你做了笔记 注意,一个需要
(destination, sauce, execution, options): 需要执行连接, 和一个 SVM 目的地
需要一个已经安装的缓冲器, 因此它是路由路径, 而不是一个赤裸的编译帮助 .
书记官处
129个协议和39个有包裹的克恩链船——38个EVM+索拉纳:
import { listProtocols, getProtocol, requireChain } from "@eco-incorp/sauce";
listProtocols().length; // 129
getProtocol("uniswap-v3"); // metadata: category, per-chain deployments, audit status
// (ABIs live on the subpath: '@eco-incorp/sauce/protocols/uniswap-v3')
requireChain 财务报告和审定财务报表 getChain 读取不同的登记册: CANONICAL_CHAINS 拥有全部39个,而
chains 出口额为38个EVM中的33个 unichain, (中文(简体) ), sonic, (中文(简体) ), ronin, (中文(简体) ), plasma 财务报告和审定财务报表 ink 为:
胆小但没参加 所以 getChain(130) 实值 undefined 地点 requireChain('unichain')
决定.
requireChain("base").id; // 8453 — reads CANONICAL_CHAINS (all 39)
子路径
| 子路径 | 这是什么 |
|---|---|
. | dSL路线, token编号 :swap编号 :deposit 链式+协议登记册的构建者 |
/compiler | 酱油脚本编译器 |
/actions | 路由-有意降低(actionsToSauce),AMM/桥梁动作原始人 |
/protocols/* | 一个协议的ABIs和元数据,例如. /protocols/uniswap-v3 |
/chains, (中文(简体) ), /deployments | 警犬链清单;已部署的合同地址 |
/recipes | 已运出的程序( 套接字、 CCTP 分拆传输) 及其来源 |
/svm, (中文(简体) ), /svm/engine, (中文(简体) ), /svm/verify | SVM 客户端、 账户解析、 引擎控制、 结算验证 |
/recipes/settle.sauce.ts, (中文(简体) ), /svm/recipes/settle.sauce.ts | 为复制字节的合作伙伴提供和解程序源 |
/evm/engine | EVM 引擎辅助器 |
/verify | 解码 遗留 v1- 语法 和解程序. viem-只有浏览器安全 |
/skills | 每个协议的AI技能文件 |
/verify 用于已连载的程序: 它读取已退休的 TypeScript 的 v1 预设
已发射编译器 。 这个SDK今天建立的程序不是v1-语法,所以会拒绝.
校验您所构建的程序意味着从同一来源重编并比较字节.
/svm/verify 对 SVM 和解程序进行精确的处理; 软件包中没有 EVM 对应程序
今天,一个EVM呼叫器 应用了技术本身.
发展
pnpm install
pnpm build # sdk + actions
pnpm typecheck
pnpm test
出版
标记驱动,通过 .github/workflows/publish.yml数字 :
git tag v1.2.3 && git push origin v1.2.3
工作流程在运行者内部的标签上刻出版本(npm version --no-git-tag-version(中文(简体) )
并出版给 仅限 npmjs.com编辑 version 内 package.json 因此,这并非造成
真理和会读出比最新版本更古老的——这是预期的.