@newton-xyz/policy-pack-blockaid 4.0.0 → 5.0.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/index.cjs +39 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -10
- package/dist/index.d.ts +36 -10
- package/dist/index.js +39 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
PACK_LINK: () => PACK_LINK,
|
|
26
26
|
PACK_NAME: () => PACK_NAME,
|
|
27
27
|
PACK_VERSION: () => PACK_VERSION,
|
|
28
|
+
ParamsJsonSchema: () => ParamsJsonSchema,
|
|
28
29
|
ParamsSchema: () => ParamsSchema,
|
|
29
30
|
SecretsSchema: () => SecretsSchema,
|
|
30
31
|
WasmArgsSchema: () => WasmArgsSchema,
|
|
@@ -37,27 +38,31 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
38
|
|
|
38
39
|
// src/deployments.ts
|
|
39
40
|
var deployments = {
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
policyData: "
|
|
41
|
+
"1": {
|
|
42
|
+
prod: {
|
|
43
|
+
policyData: "0xa7ab76E81269f48b6C40132d2234A710b0B7A099",
|
|
43
44
|
wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq",
|
|
44
45
|
policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6",
|
|
45
|
-
deployedAt: "2026-06-
|
|
46
|
-
}
|
|
46
|
+
deployedAt: "2026-06-21"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"8453": {
|
|
47
50
|
prod: {
|
|
48
|
-
policyData: "
|
|
51
|
+
policyData: "0x33394324EA2a7a599B368bd73133cc02c1E04753",
|
|
49
52
|
wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq",
|
|
50
53
|
policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6",
|
|
51
|
-
deployedAt: "2026-06-
|
|
54
|
+
deployedAt: "2026-06-20"
|
|
52
55
|
}
|
|
53
56
|
},
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
policyData: "
|
|
57
|
+
"84532": {
|
|
58
|
+
prod: {
|
|
59
|
+
policyData: "0xa086D57d33d030A5209fED5f62be0014f09B0413",
|
|
57
60
|
wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq",
|
|
58
61
|
policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6",
|
|
59
62
|
deployedAt: "2026-06-16"
|
|
60
|
-
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"11155111": {
|
|
61
66
|
prod: {
|
|
62
67
|
policyData: "0x849b66977Ac8aCEB246A6b42379F2df4cD6a8DD1",
|
|
63
68
|
wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq",
|
|
@@ -90,6 +95,28 @@ var ParamsSchema = import_zod.z.object({
|
|
|
90
95
|
"Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts."
|
|
91
96
|
)
|
|
92
97
|
}).describe("Thresholds for the Blockaid transaction-time exploit gate").strict();
|
|
98
|
+
var ParamsJsonSchema = {
|
|
99
|
+
type: "object",
|
|
100
|
+
description: "Thresholds for the Blockaid transaction-time exploit gate",
|
|
101
|
+
properties: {
|
|
102
|
+
deny_features: {
|
|
103
|
+
type: "array",
|
|
104
|
+
items: {
|
|
105
|
+
type: "string"
|
|
106
|
+
},
|
|
107
|
+
description: "Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])"
|
|
108
|
+
},
|
|
109
|
+
max_outbound_inbound_ratio: {
|
|
110
|
+
type: "number",
|
|
111
|
+
description: "Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied."
|
|
112
|
+
},
|
|
113
|
+
require_received_shares: {
|
|
114
|
+
type: "boolean",
|
|
115
|
+
description: "Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts."
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
required: ["deny_features", "max_outbound_inbound_ratio", "require_received_shares"]
|
|
119
|
+
};
|
|
93
120
|
|
|
94
121
|
// src/prepare-query.ts
|
|
95
122
|
var CHAIN_BY_ID = {
|
|
@@ -151,6 +178,7 @@ var WasmArgsSchema = import_zod3.z.object({
|
|
|
151
178
|
var blockaid = {
|
|
152
179
|
id: `${PACK_NAME}/transaction-scan/v1`,
|
|
153
180
|
paramsSchema: ParamsSchema,
|
|
181
|
+
paramsJsonSchema: ParamsJsonSchema,
|
|
154
182
|
wasmArgsSchema: WasmArgsSchema,
|
|
155
183
|
secretsSchema: SecretsSchema,
|
|
156
184
|
prepareQuery,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/deployments.ts","../src/metadata.ts","../src/pack.ts","../src/params.ts","../src/prepare-query.ts","../src/secrets.ts","../src/wasm-args.ts"],"sourcesContent":["// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n\nexport * from \"./deployments\";\nexport * from \"./metadata\";\nexport * from \"./pack\";\nexport * from \"./params\";\nexport * from \"./secrets\";\nexport * from \"./wasm-args\";\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\nimport type { ChainId, Deployment, GatewayEnv } from \"@newton-xyz/policy-pack-shared\";\n\nexport const deployments = {\n\t\"84532\": {\n\t\tstagef: {\n\t\t\tpolicyData: \"0x1808Ad6D96E736D6867b4e0773e4641940Cff555\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t\tprod: {\n\t\t\tpolicyData: \"0xa086D57d33d030A5209fED5f62be0014f09B0413\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t},\n\t\"11155111\": {\n\t\tstagef: {\n\t\t\tpolicyData: \"0x97697E15119b85365eFa6eF3C2Dc704c177b6384\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t\tprod: {\n\t\t\tpolicyData: \"0x849b66977Ac8aCEB246A6b42379F2df4cD6a8DD1\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t},\n} as const satisfies Readonly<\n\tPartial<Record<ChainId, Readonly<Partial<Record<GatewayEnv, Deployment>>>>>\n>;\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\nexport const PACK_NAME = \"blockaid\" as const;\nexport const PACK_VERSION = \"0.0.1\" as const;\nexport const PACK_DESCRIPTION =\n\t\"Gates vault deposits at transaction-submission time using Blockaid's EVM transaction scan (validation + simulation) to catch malicious calldata, frontend-redirect attacks, and value-skim simulations\" as const;\nexport const PACK_LINK = \"https://www.blockaid.io\" as const;\nexport const PACK_AUTHOR = \"\" as const;\n","// Hand-written canonical export — survives `pnpm gen:bindings` regen.\n// The generated `index.ts` re-exports `pack.ts` when present.\nimport {\n\ttype OracleModule,\n\toracleModuleFromPack,\n\ttype PolicyPack,\n} from \"@newton-xyz/policy-pack-shared\";\nimport { deployments } from \"./deployments\";\nimport { PACK_AUTHOR, PACK_DESCRIPTION, PACK_LINK, PACK_NAME, PACK_VERSION } from \"./metadata\";\nimport { type Params, ParamsSchema } from \"./params\";\nimport { prepareQuery } from \"./prepare-query\";\nimport { type Secrets, SecretsSchema } from \"./secrets\";\nimport { type WasmArgs, WasmArgsSchema } from \"./wasm-args\";\n\nexport { type PrepareQueryOptions, prepareQuery } from \"./prepare-query\";\n\n/**\n * The Blockaid transaction-scan `PolicyPack`.\n *\n * Pass to `createShield(...)` from `@newton-xyz/newton-shield-sdk`. Encoding\n * for the on-chain `policyParams` blob is handled by `encodePolicyParams` /\n * `decodePolicyParams` in `@newton-xyz/policy-pack-shared` (UTF-8 JSON,\n * sorted keys) — not per-pack.\n *\n * `prepareQuery` derives the Blockaid `chain` slug from `publicClient.chain.id`\n * and reads `from`/`to`/`value`/`data` from the SDK's per-call options bag —\n * these mirror the on-chain transaction the depositor is about to submit, so\n * they can't be inferred from `PrepareQueryArgs` alone.\n */\nexport const blockaid: PolicyPack<Params, WasmArgs, Secrets> = {\n\tid: `${PACK_NAME}/transaction-scan/v1`,\n\tparamsSchema: ParamsSchema,\n\twasmArgsSchema: WasmArgsSchema,\n\tsecretsSchema: SecretsSchema,\n\tprepareQuery,\n\tdeployments,\n\tmetadata: {\n\t\tname: PACK_NAME,\n\t\tversion: PACK_VERSION,\n\t\tdescription: PACK_DESCRIPTION,\n\t\tauthor: PACK_AUTHOR || undefined,\n\t\tlink: PACK_LINK || undefined,\n\t},\n};\n\n/**\n * Composite-policy view of the blockaid pack. Pass to `defineComposite(...)`\n * (Phase 2 — see `docs/composite-policies.md`) when stacking blockaid with\n * other packs in one Shield. Strict subset of the `PolicyPack` above —\n * shares the same `id`, schemas, and deployments.\n */\nexport const blockaidOracleModule: OracleModule<Params, WasmArgs, Secrets> =\n\toracleModuleFromPack(blockaid);\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/params_schema.json\nimport { z } from \"zod\";\n\nexport const ParamsSchema = z\n\t.object({\n\t\tdeny_features: z\n\t\t\t.array(z.string())\n\t\t\t.describe(\n\t\t\t\t\"Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])\",\n\t\t\t),\n\t\tmax_outbound_inbound_ratio: z\n\t\t\t.number()\n\t\t\t.describe(\n\t\t\t\t\"Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied.\",\n\t\t\t),\n\t\trequire_received_shares: z\n\t\t\t.boolean()\n\t\t\t.describe(\n\t\t\t\t\"Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts.\",\n\t\t\t),\n\t})\n\t.describe(\"Thresholds for the Blockaid transaction-time exploit gate\")\n\t.strict();\n\nexport type Params = z.infer<typeof ParamsSchema>;\n","import type { PrepareQueryArgs, PrepareQueryResult } from \"@newton-xyz/policy-pack-shared\";\nimport type { WasmArgs } from \"./wasm-args\";\n\n/**\n * Blockaid maps EVM chain id → its own chain identifier slug. Keep this\n * aligned with whatever the AVS-side `policy.js` posts to Blockaid; if you\n * extend it, extend both sides together.\n */\nconst CHAIN_BY_ID: Readonly<Record<number, string>> = {\n\t1: \"ethereum\",\n\t8453: \"base\",\n\t42161: \"arbitrum\",\n\t10: \"optimism\",\n\t137: \"polygon\",\n\t56: \"bsc\",\n\t11155111: \"sepolia\",\n\t84532: \"base-sepolia\",\n};\n\n/**\n * Per-call inputs for Blockaid: every wasmArg (`from`, `to`, `value`, `data`)\n * mirrors the on-chain transaction the depositor is about to submit, so it\n * has to come from the SDK's intent context — `PrepareQueryArgs` (which only\n * carries `publicClient` + `target`) doesn't have any of it. The SDK forwards\n * these via `prepareQuery`'s second `options` arg (introduced in NEWT-1499).\n *\n * `chain` is derived from `publicClient.chain.id` so curators don't have to\n * keep the Blockaid slug list in sync separately.\n */\nexport interface PrepareQueryOptions {\n\treadonly from: string;\n\treadonly to: string;\n\treadonly value?: string;\n\treadonly data?: string;\n}\n\nexport async function prepareQuery(\n\t{ publicClient }: PrepareQueryArgs,\n\toptions?: PrepareQueryOptions,\n): Promise<PrepareQueryResult<WasmArgs>> {\n\tconst chainId = publicClient.chain?.id;\n\tif (chainId === undefined) {\n\t\tthrow new Error(\n\t\t\t\"policy-pack-blockaid: publicClient.chain is undefined. Pass a chain to viem's createPublicClient.\",\n\t\t);\n\t}\n\tconst chain = CHAIN_BY_ID[chainId];\n\tif (!chain) {\n\t\tthrow new Error(\n\t\t\t`policy-pack-blockaid: chain id ${chainId} is not in the Blockaid chain map. Add it to CHAIN_BY_ID before using this pack on this chain.`,\n\t\t);\n\t}\n\tif (!options?.from || !options?.to) {\n\t\tthrow new Error(\n\t\t\t\"policy-pack-blockaid: prepareQuery requires `from` and `to` in the options bag — these mirror the on-chain transaction the depositor is about to submit.\",\n\t\t);\n\t}\n\n\treturn {\n\t\twasmArgs: {\n\t\t\tchain,\n\t\t\tfrom: options.from,\n\t\t\tto: options.to,\n\t\t\tvalue: options.value,\n\t\t\tdata: options.data,\n\t\t},\n\t};\n}\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/secrets_schema.json\nimport { z } from \"zod\";\n\nexport const SecretsSchema = z.object({ BLOCKAID_API_KEY: z.string().min(1) }).strict();\n\nexport type Secrets = z.infer<typeof SecretsSchema>;\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/wasm_args_schema.json\nimport { z } from \"zod\";\n\nexport const WasmArgsSchema = z\n\t.object({\n\t\tchain: z.string().describe(\"Blockaid chain identifier (e.g. 'ethereum', 'base', 'arbitrum').\"),\n\t\tfrom: z.string().describe(\"Sender / account address (0x-prefixed 20-byte address).\"),\n\t\tto: z.string().describe(\"Recipient or contract address being called (0x-prefixed).\"),\n\t\tvalue: z\n\t\t\t.string()\n\t\t\t.describe(\n\t\t\t\t\"Transaction value in wei as a 0x-prefixed hex string. Defaults to '0x0' when omitted.\",\n\t\t\t)\n\t\t\t.optional(),\n\t\tdata: z\n\t\t\t.string()\n\t\t\t.describe(\"Transaction calldata as a 0x-prefixed hex string. Defaults to '0x' when omitted.\")\n\t\t\t.optional(),\n\t})\n\t.describe(\"Inputs passed to the Blockaid policy WASM at evaluation time\");\n\nexport type WasmArgs = z.infer<typeof WasmArgsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,cAAc;AAAA,EAC1B,SAAS;AAAA,IACR,QAAQ;AAAA,MACP,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,EACD;AAAA,EACA,YAAY;AAAA,IACX,QAAQ;AAAA,MACP,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MACh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IAAAA,cAAkB;AAEX,IAAM,gBAAgB,cAAE,OAAO,EAAE,kBAAkB,cAAE,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;;;ACFtF,IAAAC,cAAkB;AAEX,IAAM,iBAAiB,cAC5B,OAAO;AAAA,EACP,OAAO,cAAE,OAAO,EAAE,SAAS,kEAAkE;AAAA,EAC7F,MAAM,cAAE,OAAO,EAAE,SAAS,yDAAyD;AAAA,EACnF,IAAI,cAAE,OAAO,EAAE,SAAS,2DAA2D;AAAA,EACnF,OAAO,cACL,OAAO,EACP;AAAA,IACA;AAAA,EACD,EACC,SAAS;AAAA,EACX,MAAM,cACJ,OAAO,EACP,SAAS,kFAAkF,EAC3F,SAAS;AACZ,CAAC,EACA,SAAS,8DAA8D;;;AJQlE,IAAM,WAAkD;AAAA,EAC9D,IAAI,GAAG,SAAS;AAAA,EAChB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA,UAAU;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,QAAQ,eAAe;AAAA,IACvB,MAAM,aAAa;AAAA,EACpB;AACD;AAQO,IAAM,2BACZ,gDAAqB,QAAQ;","names":["import_zod","import_zod"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/deployments.ts","../src/metadata.ts","../src/pack.ts","../src/params.ts","../src/prepare-query.ts","../src/secrets.ts","../src/wasm-args.ts"],"sourcesContent":["// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n\nexport * from \"./deployments\";\nexport * from \"./metadata\";\nexport * from \"./pack\";\nexport * from \"./params\";\nexport * from \"./secrets\";\nexport * from \"./wasm-args\";\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\nimport type { ChainId, Deployment, GatewayEnv } from \"@newton-xyz/policy-pack-shared\";\n\nexport const deployments = {\n\t\"1\": {\n\t\tprod: {\n\t\t\tpolicyData: \"0xa7ab76E81269f48b6C40132d2234A710b0B7A099\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-21\",\n\t\t},\n\t},\n\t\"8453\": {\n\t\tprod: {\n\t\t\tpolicyData: \"0x33394324EA2a7a599B368bd73133cc02c1E04753\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-20\",\n\t\t},\n\t},\n\t\"84532\": {\n\t\tprod: {\n\t\t\tpolicyData: \"0xa086D57d33d030A5209fED5f62be0014f09B0413\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t},\n\t\"11155111\": {\n\t\tprod: {\n\t\t\tpolicyData: \"0x849b66977Ac8aCEB246A6b42379F2df4cD6a8DD1\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t},\n} as const satisfies Readonly<\n\tPartial<Record<ChainId, Readonly<Partial<Record<GatewayEnv, Deployment>>>>>\n>;\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\nexport const PACK_NAME = \"blockaid\" as const;\nexport const PACK_VERSION = \"0.0.1\" as const;\nexport const PACK_DESCRIPTION =\n\t\"Gates vault deposits at transaction-submission time using Blockaid's EVM transaction scan (validation + simulation) to catch malicious calldata, frontend-redirect attacks, and value-skim simulations\" as const;\nexport const PACK_LINK = \"https://www.blockaid.io\" as const;\nexport const PACK_AUTHOR = \"\" as const;\n","// Hand-written canonical export — survives `pnpm gen:bindings` regen.\n// The generated `index.ts` re-exports `pack.ts` when present.\nimport {\n\ttype OracleModule,\n\toracleModuleFromPack,\n\ttype PolicyPack,\n} from \"@newton-xyz/policy-pack-shared\";\nimport { deployments } from \"./deployments\";\nimport { PACK_AUTHOR, PACK_DESCRIPTION, PACK_LINK, PACK_NAME, PACK_VERSION } from \"./metadata\";\nimport { type Params, ParamsJsonSchema, ParamsSchema } from \"./params\";\nimport { prepareQuery } from \"./prepare-query\";\nimport { type Secrets, SecretsSchema } from \"./secrets\";\nimport { type WasmArgs, WasmArgsSchema } from \"./wasm-args\";\n\nexport { type PrepareQueryOptions, prepareQuery } from \"./prepare-query\";\n\n/**\n * The Blockaid transaction-scan `PolicyPack`.\n *\n * Pass to `createShield(...)` from `@newton-xyz/newton-shield-sdk`. Encoding\n * for the on-chain `policyParams` blob is handled by `encodePolicyParams` /\n * `decodePolicyParams` in `@newton-xyz/policy-pack-shared` (UTF-8 JSON,\n * sorted keys) — not per-pack.\n *\n * `prepareQuery` derives the Blockaid `chain` slug from `publicClient.chain.id`\n * and reads `from`/`to`/`value`/`data` from the SDK's per-call options bag —\n * these mirror the on-chain transaction the depositor is about to submit, so\n * they can't be inferred from `PrepareQueryArgs` alone.\n */\nexport const blockaid: PolicyPack<Params, WasmArgs, Secrets> = {\n\tid: `${PACK_NAME}/transaction-scan/v1`,\n\tparamsSchema: ParamsSchema,\n\tparamsJsonSchema: ParamsJsonSchema,\n\twasmArgsSchema: WasmArgsSchema,\n\tsecretsSchema: SecretsSchema,\n\tprepareQuery,\n\tdeployments,\n\tmetadata: {\n\t\tname: PACK_NAME,\n\t\tversion: PACK_VERSION,\n\t\tdescription: PACK_DESCRIPTION,\n\t\tauthor: PACK_AUTHOR || undefined,\n\t\tlink: PACK_LINK || undefined,\n\t},\n};\n\n/**\n * Composite-policy view of the blockaid pack. Pass to `defineComposite(...)`\n * (Phase 2 — see `docs/composite-policies.md`) when stacking blockaid with\n * other packs in one Shield. Strict subset of the `PolicyPack` above —\n * shares the same `id`, schemas, and deployments.\n */\nexport const blockaidOracleModule: OracleModule<Params, WasmArgs, Secrets> =\n\toracleModuleFromPack(blockaid);\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/params_schema.json\nimport { z } from \"zod\";\n\nexport const ParamsSchema = z\n\t.object({\n\t\tdeny_features: z\n\t\t\t.array(z.string())\n\t\t\t.describe(\n\t\t\t\t\"Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])\",\n\t\t\t),\n\t\tmax_outbound_inbound_ratio: z\n\t\t\t.number()\n\t\t\t.describe(\n\t\t\t\t\"Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied.\",\n\t\t\t),\n\t\trequire_received_shares: z\n\t\t\t.boolean()\n\t\t\t.describe(\n\t\t\t\t\"Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts.\",\n\t\t\t),\n\t})\n\t.describe(\"Thresholds for the Blockaid transaction-time exploit gate\")\n\t.strict();\n\nexport type Params = z.infer<typeof ParamsSchema>;\n\nexport const ParamsJsonSchema = {\n\ttype: \"object\",\n\tdescription: \"Thresholds for the Blockaid transaction-time exploit gate\",\n\tproperties: {\n\t\tdeny_features: {\n\t\t\ttype: \"array\",\n\t\t\titems: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t\"Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])\",\n\t\t},\n\t\tmax_outbound_inbound_ratio: {\n\t\t\ttype: \"number\",\n\t\t\tdescription:\n\t\t\t\t\"Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied.\",\n\t\t},\n\t\trequire_received_shares: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription:\n\t\t\t\t\"Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts.\",\n\t\t},\n\t},\n\trequired: [\"deny_features\", \"max_outbound_inbound_ratio\", \"require_received_shares\"],\n} as const;\n","import type { PrepareQueryArgs, PrepareQueryResult } from \"@newton-xyz/policy-pack-shared\";\nimport type { WasmArgs } from \"./wasm-args\";\n\n/**\n * Blockaid maps EVM chain id → its own chain identifier slug. Keep this\n * aligned with whatever the AVS-side `policy.js` posts to Blockaid; if you\n * extend it, extend both sides together.\n */\nconst CHAIN_BY_ID: Readonly<Record<number, string>> = {\n\t1: \"ethereum\",\n\t8453: \"base\",\n\t42161: \"arbitrum\",\n\t10: \"optimism\",\n\t137: \"polygon\",\n\t56: \"bsc\",\n\t11155111: \"sepolia\",\n\t84532: \"base-sepolia\",\n};\n\n/**\n * Per-call inputs for Blockaid: every wasmArg (`from`, `to`, `value`, `data`)\n * mirrors the on-chain transaction the depositor is about to submit, so it\n * has to come from the SDK's intent context — `PrepareQueryArgs` (which only\n * carries `publicClient` + `target`) doesn't have any of it. The SDK forwards\n * these via `prepareQuery`'s second `options` arg (introduced in NEWT-1499).\n *\n * `chain` is derived from `publicClient.chain.id` so curators don't have to\n * keep the Blockaid slug list in sync separately.\n */\nexport interface PrepareQueryOptions {\n\treadonly from: string;\n\treadonly to: string;\n\treadonly value?: string;\n\treadonly data?: string;\n}\n\nexport async function prepareQuery(\n\t{ publicClient }: PrepareQueryArgs,\n\toptions?: PrepareQueryOptions,\n): Promise<PrepareQueryResult<WasmArgs>> {\n\tconst chainId = publicClient.chain?.id;\n\tif (chainId === undefined) {\n\t\tthrow new Error(\n\t\t\t\"policy-pack-blockaid: publicClient.chain is undefined. Pass a chain to viem's createPublicClient.\",\n\t\t);\n\t}\n\tconst chain = CHAIN_BY_ID[chainId];\n\tif (!chain) {\n\t\tthrow new Error(\n\t\t\t`policy-pack-blockaid: chain id ${chainId} is not in the Blockaid chain map. Add it to CHAIN_BY_ID before using this pack on this chain.`,\n\t\t);\n\t}\n\tif (!options?.from || !options?.to) {\n\t\tthrow new Error(\n\t\t\t\"policy-pack-blockaid: prepareQuery requires `from` and `to` in the options bag — these mirror the on-chain transaction the depositor is about to submit.\",\n\t\t);\n\t}\n\n\treturn {\n\t\twasmArgs: {\n\t\t\tchain,\n\t\t\tfrom: options.from,\n\t\t\tto: options.to,\n\t\t\tvalue: options.value,\n\t\t\tdata: options.data,\n\t\t},\n\t};\n}\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/secrets_schema.json\nimport { z } from \"zod\";\n\nexport const SecretsSchema = z.object({ BLOCKAID_API_KEY: z.string().min(1) }).strict();\n\nexport type Secrets = z.infer<typeof SecretsSchema>;\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/wasm_args_schema.json\nimport { z } from \"zod\";\n\nexport const WasmArgsSchema = z\n\t.object({\n\t\tchain: z.string().describe(\"Blockaid chain identifier (e.g. 'ethereum', 'base', 'arbitrum').\"),\n\t\tfrom: z.string().describe(\"Sender / account address (0x-prefixed 20-byte address).\"),\n\t\tto: z.string().describe(\"Recipient or contract address being called (0x-prefixed).\"),\n\t\tvalue: z\n\t\t\t.string()\n\t\t\t.describe(\n\t\t\t\t\"Transaction value in wei as a 0x-prefixed hex string. Defaults to '0x0' when omitted.\",\n\t\t\t)\n\t\t\t.optional(),\n\t\tdata: z\n\t\t\t.string()\n\t\t\t.describe(\"Transaction calldata as a 0x-prefixed hex string. Defaults to '0x' when omitted.\")\n\t\t\t.optional(),\n\t})\n\t.describe(\"Inputs passed to the Blockaid policy WASM at evaluation time\");\n\nexport type WasmArgs = z.infer<typeof WasmArgsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,cAAc;AAAA,EAC1B,KAAK;AAAA,IACJ,MAAM;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,EACD;AAAA,EACA,QAAQ;AAAA,IACP,MAAM;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,EACD;AAAA,EACA,SAAS;AAAA,IACR,MAAM;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,EACD;AAAA,EACA,YAAY;AAAA,IACX,MAAM;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,EACD;AACD;;;ACnCO,IAAM,YAAY;AAClB,IAAM,eAAe;AACrB,IAAM,mBACZ;AACM,IAAM,YAAY;AAClB,IAAM,cAAc;;;ACL3B,gCAIO;;;ACHP,iBAAkB;AAEX,IAAM,eAAe,aAC1B,OAAO;AAAA,EACP,eAAe,aACb,MAAM,aAAE,OAAO,CAAC,EAChB;AAAA,IACA;AAAA,EACD;AAAA,EACD,4BAA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AkB;AAEX,IAAM,gBAAgB,cAAE,OAAO,EAAE,kBAAkB,cAAE,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;;;ACFtF,IAAAC,cAAkB;AAEX,IAAM,iBAAiB,cAC5B,OAAO;AAAA,EACP,OAAO,cAAE,OAAO,EAAE,SAAS,kEAAkE;AAAA,EAC7F,MAAM,cAAE,OAAO,EAAE,SAAS,yDAAyD;AAAA,EACnF,IAAI,cAAE,OAAO,EAAE,SAAS,2DAA2D;AAAA,EACnF,OAAO,cACL,OAAO,EACP;AAAA,IACA;AAAA,EACD,EACC,SAAS;AAAA,EACX,MAAM,cACJ,OAAO,EACP,SAAS,kFAAkF,EAC3F,SAAS;AACZ,CAAC,EACA,SAAS,8DAA8D;;;AJQlE,IAAM,WAAkD;AAAA,EAC9D,IAAI,GAAG,SAAS;AAAA,EAChB,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA,UAAU;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,QAAQ,eAAe;AAAA,IACvB,MAAM,aAAa;AAAA,EACpB;AACD;AAQO,IAAM,2BACZ,gDAAqB,QAAQ;","names":["import_zod","import_zod"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -2,27 +2,31 @@ import { PrepareQueryArgs, PrepareQueryResult, PolicyPack, OracleModule } from '
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const deployments: {
|
|
5
|
-
readonly "
|
|
6
|
-
readonly
|
|
7
|
-
readonly policyData: "
|
|
5
|
+
readonly "1": {
|
|
6
|
+
readonly prod: {
|
|
7
|
+
readonly policyData: "0xa7ab76E81269f48b6C40132d2234A710b0B7A099";
|
|
8
8
|
readonly wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq";
|
|
9
9
|
readonly policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6";
|
|
10
|
-
readonly deployedAt: "2026-06-
|
|
10
|
+
readonly deployedAt: "2026-06-21";
|
|
11
11
|
};
|
|
12
|
+
};
|
|
13
|
+
readonly "8453": {
|
|
12
14
|
readonly prod: {
|
|
13
|
-
readonly policyData: "
|
|
15
|
+
readonly policyData: "0x33394324EA2a7a599B368bd73133cc02c1E04753";
|
|
14
16
|
readonly wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq";
|
|
15
17
|
readonly policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6";
|
|
16
|
-
readonly deployedAt: "2026-06-
|
|
18
|
+
readonly deployedAt: "2026-06-20";
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
|
-
readonly "
|
|
20
|
-
readonly
|
|
21
|
-
readonly policyData: "
|
|
21
|
+
readonly "84532": {
|
|
22
|
+
readonly prod: {
|
|
23
|
+
readonly policyData: "0xa086D57d33d030A5209fED5f62be0014f09B0413";
|
|
22
24
|
readonly wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq";
|
|
23
25
|
readonly policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6";
|
|
24
26
|
readonly deployedAt: "2026-06-16";
|
|
25
27
|
};
|
|
28
|
+
};
|
|
29
|
+
readonly "11155111": {
|
|
26
30
|
readonly prod: {
|
|
27
31
|
readonly policyData: "0x849b66977Ac8aCEB246A6b42379F2df4cD6a8DD1";
|
|
28
32
|
readonly wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq";
|
|
@@ -52,6 +56,28 @@ declare const ParamsSchema: z.ZodObject<{
|
|
|
52
56
|
require_received_shares: boolean;
|
|
53
57
|
}>;
|
|
54
58
|
type Params = z.infer<typeof ParamsSchema>;
|
|
59
|
+
declare const ParamsJsonSchema: {
|
|
60
|
+
readonly type: "object";
|
|
61
|
+
readonly description: "Thresholds for the Blockaid transaction-time exploit gate";
|
|
62
|
+
readonly properties: {
|
|
63
|
+
readonly deny_features: {
|
|
64
|
+
readonly type: "array";
|
|
65
|
+
readonly items: {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
};
|
|
68
|
+
readonly description: "Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])";
|
|
69
|
+
};
|
|
70
|
+
readonly max_outbound_inbound_ratio: {
|
|
71
|
+
readonly type: "number";
|
|
72
|
+
readonly description: "Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied.";
|
|
73
|
+
};
|
|
74
|
+
readonly require_received_shares: {
|
|
75
|
+
readonly type: "boolean";
|
|
76
|
+
readonly description: "Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts.";
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
readonly required: readonly ["deny_features", "max_outbound_inbound_ratio", "require_received_shares"];
|
|
80
|
+
};
|
|
55
81
|
|
|
56
82
|
declare const SecretsSchema: z.ZodObject<{
|
|
57
83
|
BLOCKAID_API_KEY: z.ZodString;
|
|
@@ -123,4 +149,4 @@ declare const blockaid: PolicyPack<Params, WasmArgs, Secrets>;
|
|
|
123
149
|
*/
|
|
124
150
|
declare const blockaidOracleModule: OracleModule<Params, WasmArgs, Secrets>;
|
|
125
151
|
|
|
126
|
-
export { PACK_AUTHOR, PACK_DESCRIPTION, PACK_LINK, PACK_NAME, PACK_VERSION, type Params, ParamsSchema, type PrepareQueryOptions, type Secrets, SecretsSchema, type WasmArgs, WasmArgsSchema, blockaid, blockaidOracleModule, deployments, prepareQuery };
|
|
152
|
+
export { PACK_AUTHOR, PACK_DESCRIPTION, PACK_LINK, PACK_NAME, PACK_VERSION, type Params, ParamsJsonSchema, ParamsSchema, type PrepareQueryOptions, type Secrets, SecretsSchema, type WasmArgs, WasmArgsSchema, blockaid, blockaidOracleModule, deployments, prepareQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,27 +2,31 @@ import { PrepareQueryArgs, PrepareQueryResult, PolicyPack, OracleModule } from '
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const deployments: {
|
|
5
|
-
readonly "
|
|
6
|
-
readonly
|
|
7
|
-
readonly policyData: "
|
|
5
|
+
readonly "1": {
|
|
6
|
+
readonly prod: {
|
|
7
|
+
readonly policyData: "0xa7ab76E81269f48b6C40132d2234A710b0B7A099";
|
|
8
8
|
readonly wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq";
|
|
9
9
|
readonly policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6";
|
|
10
|
-
readonly deployedAt: "2026-06-
|
|
10
|
+
readonly deployedAt: "2026-06-21";
|
|
11
11
|
};
|
|
12
|
+
};
|
|
13
|
+
readonly "8453": {
|
|
12
14
|
readonly prod: {
|
|
13
|
-
readonly policyData: "
|
|
15
|
+
readonly policyData: "0x33394324EA2a7a599B368bd73133cc02c1E04753";
|
|
14
16
|
readonly wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq";
|
|
15
17
|
readonly policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6";
|
|
16
|
-
readonly deployedAt: "2026-06-
|
|
18
|
+
readonly deployedAt: "2026-06-20";
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
|
-
readonly "
|
|
20
|
-
readonly
|
|
21
|
-
readonly policyData: "
|
|
21
|
+
readonly "84532": {
|
|
22
|
+
readonly prod: {
|
|
23
|
+
readonly policyData: "0xa086D57d33d030A5209fED5f62be0014f09B0413";
|
|
22
24
|
readonly wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq";
|
|
23
25
|
readonly policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6";
|
|
24
26
|
readonly deployedAt: "2026-06-16";
|
|
25
27
|
};
|
|
28
|
+
};
|
|
29
|
+
readonly "11155111": {
|
|
26
30
|
readonly prod: {
|
|
27
31
|
readonly policyData: "0x849b66977Ac8aCEB246A6b42379F2df4cD6a8DD1";
|
|
28
32
|
readonly wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq";
|
|
@@ -52,6 +56,28 @@ declare const ParamsSchema: z.ZodObject<{
|
|
|
52
56
|
require_received_shares: boolean;
|
|
53
57
|
}>;
|
|
54
58
|
type Params = z.infer<typeof ParamsSchema>;
|
|
59
|
+
declare const ParamsJsonSchema: {
|
|
60
|
+
readonly type: "object";
|
|
61
|
+
readonly description: "Thresholds for the Blockaid transaction-time exploit gate";
|
|
62
|
+
readonly properties: {
|
|
63
|
+
readonly deny_features: {
|
|
64
|
+
readonly type: "array";
|
|
65
|
+
readonly items: {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
};
|
|
68
|
+
readonly description: "Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])";
|
|
69
|
+
};
|
|
70
|
+
readonly max_outbound_inbound_ratio: {
|
|
71
|
+
readonly type: "number";
|
|
72
|
+
readonly description: "Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied.";
|
|
73
|
+
};
|
|
74
|
+
readonly require_received_shares: {
|
|
75
|
+
readonly type: "boolean";
|
|
76
|
+
readonly description: "Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts.";
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
readonly required: readonly ["deny_features", "max_outbound_inbound_ratio", "require_received_shares"];
|
|
80
|
+
};
|
|
55
81
|
|
|
56
82
|
declare const SecretsSchema: z.ZodObject<{
|
|
57
83
|
BLOCKAID_API_KEY: z.ZodString;
|
|
@@ -123,4 +149,4 @@ declare const blockaid: PolicyPack<Params, WasmArgs, Secrets>;
|
|
|
123
149
|
*/
|
|
124
150
|
declare const blockaidOracleModule: OracleModule<Params, WasmArgs, Secrets>;
|
|
125
151
|
|
|
126
|
-
export { PACK_AUTHOR, PACK_DESCRIPTION, PACK_LINK, PACK_NAME, PACK_VERSION, type Params, ParamsSchema, type PrepareQueryOptions, type Secrets, SecretsSchema, type WasmArgs, WasmArgsSchema, blockaid, blockaidOracleModule, deployments, prepareQuery };
|
|
152
|
+
export { PACK_AUTHOR, PACK_DESCRIPTION, PACK_LINK, PACK_NAME, PACK_VERSION, type Params, ParamsJsonSchema, ParamsSchema, type PrepareQueryOptions, type Secrets, SecretsSchema, type WasmArgs, WasmArgsSchema, blockaid, blockaidOracleModule, deployments, prepareQuery };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
// src/deployments.ts
|
|
2
2
|
var deployments = {
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
policyData: "
|
|
3
|
+
"1": {
|
|
4
|
+
prod: {
|
|
5
|
+
policyData: "0xa7ab76E81269f48b6C40132d2234A710b0B7A099",
|
|
6
6
|
wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq",
|
|
7
7
|
policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6",
|
|
8
|
-
deployedAt: "2026-06-
|
|
9
|
-
}
|
|
8
|
+
deployedAt: "2026-06-21"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"8453": {
|
|
10
12
|
prod: {
|
|
11
|
-
policyData: "
|
|
13
|
+
policyData: "0x33394324EA2a7a599B368bd73133cc02c1E04753",
|
|
12
14
|
wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq",
|
|
13
15
|
policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6",
|
|
14
|
-
deployedAt: "2026-06-
|
|
16
|
+
deployedAt: "2026-06-20"
|
|
15
17
|
}
|
|
16
18
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
policyData: "
|
|
19
|
+
"84532": {
|
|
20
|
+
prod: {
|
|
21
|
+
policyData: "0xa086D57d33d030A5209fED5f62be0014f09B0413",
|
|
20
22
|
wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq",
|
|
21
23
|
policyCodeHash: "0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6",
|
|
22
24
|
deployedAt: "2026-06-16"
|
|
23
|
-
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"11155111": {
|
|
24
28
|
prod: {
|
|
25
29
|
policyData: "0x849b66977Ac8aCEB246A6b42379F2df4cD6a8DD1",
|
|
26
30
|
wasmCid: "bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq",
|
|
@@ -55,6 +59,28 @@ var ParamsSchema = z.object({
|
|
|
55
59
|
"Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts."
|
|
56
60
|
)
|
|
57
61
|
}).describe("Thresholds for the Blockaid transaction-time exploit gate").strict();
|
|
62
|
+
var ParamsJsonSchema = {
|
|
63
|
+
type: "object",
|
|
64
|
+
description: "Thresholds for the Blockaid transaction-time exploit gate",
|
|
65
|
+
properties: {
|
|
66
|
+
deny_features: {
|
|
67
|
+
type: "array",
|
|
68
|
+
items: {
|
|
69
|
+
type: "string"
|
|
70
|
+
},
|
|
71
|
+
description: "Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])"
|
|
72
|
+
},
|
|
73
|
+
max_outbound_inbound_ratio: {
|
|
74
|
+
type: "number",
|
|
75
|
+
description: "Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied."
|
|
76
|
+
},
|
|
77
|
+
require_received_shares: {
|
|
78
|
+
type: "boolean",
|
|
79
|
+
description: "Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts."
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
required: ["deny_features", "max_outbound_inbound_ratio", "require_received_shares"]
|
|
83
|
+
};
|
|
58
84
|
|
|
59
85
|
// src/prepare-query.ts
|
|
60
86
|
var CHAIN_BY_ID = {
|
|
@@ -116,6 +142,7 @@ var WasmArgsSchema = z3.object({
|
|
|
116
142
|
var blockaid = {
|
|
117
143
|
id: `${PACK_NAME}/transaction-scan/v1`,
|
|
118
144
|
paramsSchema: ParamsSchema,
|
|
145
|
+
paramsJsonSchema: ParamsJsonSchema,
|
|
119
146
|
wasmArgsSchema: WasmArgsSchema,
|
|
120
147
|
secretsSchema: SecretsSchema,
|
|
121
148
|
prepareQuery,
|
|
@@ -135,6 +162,7 @@ export {
|
|
|
135
162
|
PACK_LINK,
|
|
136
163
|
PACK_NAME,
|
|
137
164
|
PACK_VERSION,
|
|
165
|
+
ParamsJsonSchema,
|
|
138
166
|
ParamsSchema,
|
|
139
167
|
SecretsSchema,
|
|
140
168
|
WasmArgsSchema,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deployments.ts","../src/metadata.ts","../src/pack.ts","../src/params.ts","../src/prepare-query.ts","../src/secrets.ts","../src/wasm-args.ts"],"sourcesContent":["// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\nimport type { ChainId, Deployment, GatewayEnv } from \"@newton-xyz/policy-pack-shared\";\n\nexport const deployments = {\n\t\"84532\": {\n\t\tstagef: {\n\t\t\tpolicyData: \"0x1808Ad6D96E736D6867b4e0773e4641940Cff555\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t\tprod: {\n\t\t\tpolicyData: \"0xa086D57d33d030A5209fED5f62be0014f09B0413\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t},\n\t\"11155111\": {\n\t\tstagef: {\n\t\t\tpolicyData: \"0x97697E15119b85365eFa6eF3C2Dc704c177b6384\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t\tprod: {\n\t\t\tpolicyData: \"0x849b66977Ac8aCEB246A6b42379F2df4cD6a8DD1\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t},\n} as const satisfies Readonly<\n\tPartial<Record<ChainId, Readonly<Partial<Record<GatewayEnv, Deployment>>>>>\n>;\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\nexport const PACK_NAME = \"blockaid\" as const;\nexport const PACK_VERSION = \"0.0.1\" as const;\nexport const PACK_DESCRIPTION =\n\t\"Gates vault deposits at transaction-submission time using Blockaid's EVM transaction scan (validation + simulation) to catch malicious calldata, frontend-redirect attacks, and value-skim simulations\" as const;\nexport const PACK_LINK = \"https://www.blockaid.io\" as const;\nexport const PACK_AUTHOR = \"\" as const;\n","// Hand-written canonical export — survives `pnpm gen:bindings` regen.\n// The generated `index.ts` re-exports `pack.ts` when present.\nimport {\n\ttype OracleModule,\n\toracleModuleFromPack,\n\ttype PolicyPack,\n} from \"@newton-xyz/policy-pack-shared\";\nimport { deployments } from \"./deployments\";\nimport { PACK_AUTHOR, PACK_DESCRIPTION, PACK_LINK, PACK_NAME, PACK_VERSION } from \"./metadata\";\nimport { type Params, ParamsSchema } from \"./params\";\nimport { prepareQuery } from \"./prepare-query\";\nimport { type Secrets, SecretsSchema } from \"./secrets\";\nimport { type WasmArgs, WasmArgsSchema } from \"./wasm-args\";\n\nexport { type PrepareQueryOptions, prepareQuery } from \"./prepare-query\";\n\n/**\n * The Blockaid transaction-scan `PolicyPack`.\n *\n * Pass to `createShield(...)` from `@newton-xyz/newton-shield-sdk`. Encoding\n * for the on-chain `policyParams` blob is handled by `encodePolicyParams` /\n * `decodePolicyParams` in `@newton-xyz/policy-pack-shared` (UTF-8 JSON,\n * sorted keys) — not per-pack.\n *\n * `prepareQuery` derives the Blockaid `chain` slug from `publicClient.chain.id`\n * and reads `from`/`to`/`value`/`data` from the SDK's per-call options bag —\n * these mirror the on-chain transaction the depositor is about to submit, so\n * they can't be inferred from `PrepareQueryArgs` alone.\n */\nexport const blockaid: PolicyPack<Params, WasmArgs, Secrets> = {\n\tid: `${PACK_NAME}/transaction-scan/v1`,\n\tparamsSchema: ParamsSchema,\n\twasmArgsSchema: WasmArgsSchema,\n\tsecretsSchema: SecretsSchema,\n\tprepareQuery,\n\tdeployments,\n\tmetadata: {\n\t\tname: PACK_NAME,\n\t\tversion: PACK_VERSION,\n\t\tdescription: PACK_DESCRIPTION,\n\t\tauthor: PACK_AUTHOR || undefined,\n\t\tlink: PACK_LINK || undefined,\n\t},\n};\n\n/**\n * Composite-policy view of the blockaid pack. Pass to `defineComposite(...)`\n * (Phase 2 — see `docs/composite-policies.md`) when stacking blockaid with\n * other packs in one Shield. Strict subset of the `PolicyPack` above —\n * shares the same `id`, schemas, and deployments.\n */\nexport const blockaidOracleModule: OracleModule<Params, WasmArgs, Secrets> =\n\toracleModuleFromPack(blockaid);\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/params_schema.json\nimport { z } from \"zod\";\n\nexport const ParamsSchema = z\n\t.object({\n\t\tdeny_features: z\n\t\t\t.array(z.string())\n\t\t\t.describe(\n\t\t\t\t\"Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])\",\n\t\t\t),\n\t\tmax_outbound_inbound_ratio: z\n\t\t\t.number()\n\t\t\t.describe(\n\t\t\t\t\"Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied.\",\n\t\t\t),\n\t\trequire_received_shares: z\n\t\t\t.boolean()\n\t\t\t.describe(\n\t\t\t\t\"Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts.\",\n\t\t\t),\n\t})\n\t.describe(\"Thresholds for the Blockaid transaction-time exploit gate\")\n\t.strict();\n\nexport type Params = z.infer<typeof ParamsSchema>;\n","import type { PrepareQueryArgs, PrepareQueryResult } from \"@newton-xyz/policy-pack-shared\";\nimport type { WasmArgs } from \"./wasm-args\";\n\n/**\n * Blockaid maps EVM chain id → its own chain identifier slug. Keep this\n * aligned with whatever the AVS-side `policy.js` posts to Blockaid; if you\n * extend it, extend both sides together.\n */\nconst CHAIN_BY_ID: Readonly<Record<number, string>> = {\n\t1: \"ethereum\",\n\t8453: \"base\",\n\t42161: \"arbitrum\",\n\t10: \"optimism\",\n\t137: \"polygon\",\n\t56: \"bsc\",\n\t11155111: \"sepolia\",\n\t84532: \"base-sepolia\",\n};\n\n/**\n * Per-call inputs for Blockaid: every wasmArg (`from`, `to`, `value`, `data`)\n * mirrors the on-chain transaction the depositor is about to submit, so it\n * has to come from the SDK's intent context — `PrepareQueryArgs` (which only\n * carries `publicClient` + `target`) doesn't have any of it. The SDK forwards\n * these via `prepareQuery`'s second `options` arg (introduced in NEWT-1499).\n *\n * `chain` is derived from `publicClient.chain.id` so curators don't have to\n * keep the Blockaid slug list in sync separately.\n */\nexport interface PrepareQueryOptions {\n\treadonly from: string;\n\treadonly to: string;\n\treadonly value?: string;\n\treadonly data?: string;\n}\n\nexport async function prepareQuery(\n\t{ publicClient }: PrepareQueryArgs,\n\toptions?: PrepareQueryOptions,\n): Promise<PrepareQueryResult<WasmArgs>> {\n\tconst chainId = publicClient.chain?.id;\n\tif (chainId === undefined) {\n\t\tthrow new Error(\n\t\t\t\"policy-pack-blockaid: publicClient.chain is undefined. Pass a chain to viem's createPublicClient.\",\n\t\t);\n\t}\n\tconst chain = CHAIN_BY_ID[chainId];\n\tif (!chain) {\n\t\tthrow new Error(\n\t\t\t`policy-pack-blockaid: chain id ${chainId} is not in the Blockaid chain map. Add it to CHAIN_BY_ID before using this pack on this chain.`,\n\t\t);\n\t}\n\tif (!options?.from || !options?.to) {\n\t\tthrow new Error(\n\t\t\t\"policy-pack-blockaid: prepareQuery requires `from` and `to` in the options bag — these mirror the on-chain transaction the depositor is about to submit.\",\n\t\t);\n\t}\n\n\treturn {\n\t\twasmArgs: {\n\t\t\tchain,\n\t\t\tfrom: options.from,\n\t\t\tto: options.to,\n\t\t\tvalue: options.value,\n\t\t\tdata: options.data,\n\t\t},\n\t};\n}\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/secrets_schema.json\nimport { z } from \"zod\";\n\nexport const SecretsSchema = z.object({ BLOCKAID_API_KEY: z.string().min(1) }).strict();\n\nexport type Secrets = z.infer<typeof SecretsSchema>;\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/wasm_args_schema.json\nimport { z } from \"zod\";\n\nexport const WasmArgsSchema = z\n\t.object({\n\t\tchain: z.string().describe(\"Blockaid chain identifier (e.g. 'ethereum', 'base', 'arbitrum').\"),\n\t\tfrom: z.string().describe(\"Sender / account address (0x-prefixed 20-byte address).\"),\n\t\tto: z.string().describe(\"Recipient or contract address being called (0x-prefixed).\"),\n\t\tvalue: z\n\t\t\t.string()\n\t\t\t.describe(\n\t\t\t\t\"Transaction value in wei as a 0x-prefixed hex string. Defaults to '0x0' when omitted.\",\n\t\t\t)\n\t\t\t.optional(),\n\t\tdata: z\n\t\t\t.string()\n\t\t\t.describe(\"Transaction calldata as a 0x-prefixed hex string. Defaults to '0x' when omitted.\")\n\t\t\t.optional(),\n\t})\n\t.describe(\"Inputs passed to the Blockaid policy WASM at evaluation time\");\n\nexport type WasmArgs = z.infer<typeof WasmArgsSchema>;\n"],"mappings":";AAIO,IAAM,cAAc;AAAA,EAC1B,SAAS;AAAA,IACR,QAAQ;AAAA,MACP,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,EACD;AAAA,EACA,YAAY;AAAA,IACX,QAAQ;AAAA,MACP,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACb;AAAA,EACD;AACD;;;AC/BO,IAAM,YAAY;AAClB,IAAM,eAAe;AACrB,IAAM,m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AiBA,GAC5B,OAAO;AAAA,EACP,OAAOA,GAAE,OAAO,EAAE,SAAS,kEAAkE;AAAA,EAC7F,MAAMA,GAAE,OAAO,EAAE,SAAS,yDAAyD;AAAA,EACnF,IAAIA,GAAE,OAAO,EAAE,SAAS,2DAA2D;AAAA,EACnF,OAAOA,GACL,OAAO,EACP;AAAA,IACA;AAAA,EACD,EACC,SAAS;AAAA,EACX,MAAMA,GACJ,OAAO,EACP,SAAS,kFAAkF,EAC3F,SAAS;AACZ,CAAC,EACA,SAAS,8DAA8D;;;AJQlE,IAAM,WAAkD;AAAA,EAC9D,IAAI,GAAG,SAAS;AAAA,EAChB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA,UAAU;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,QAAQ,eAAe;AAAA,IACvB,MAAM,aAAa;AAAA,EACpB;AACD;AAQO,IAAM,uBACZ,qBAAqB,QAAQ;","names":["z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/deployments.ts","../src/metadata.ts","../src/pack.ts","../src/params.ts","../src/prepare-query.ts","../src/secrets.ts","../src/wasm-args.ts"],"sourcesContent":["// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\nimport type { ChainId, Deployment, GatewayEnv } from \"@newton-xyz/policy-pack-shared\";\n\nexport const deployments = {\n\t\"1\": {\n\t\tprod: {\n\t\t\tpolicyData: \"0xa7ab76E81269f48b6C40132d2234A710b0B7A099\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-21\",\n\t\t},\n\t},\n\t\"8453\": {\n\t\tprod: {\n\t\t\tpolicyData: \"0x33394324EA2a7a599B368bd73133cc02c1E04753\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-20\",\n\t\t},\n\t},\n\t\"84532\": {\n\t\tprod: {\n\t\t\tpolicyData: \"0xa086D57d33d030A5209fED5f62be0014f09B0413\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t},\n\t\"11155111\": {\n\t\tprod: {\n\t\t\tpolicyData: \"0x849b66977Ac8aCEB246A6b42379F2df4cD6a8DD1\",\n\t\t\twasmCid: \"bafybeifktjif3473eeunuozy6dcr6qs5z774yo27ufhezohtdgryobralq\",\n\t\t\tpolicyCodeHash: \"0xb95ee22e1aeda1008947322959dcd2b42dddeea426a63e3a28c4530f5f02eea6\",\n\t\t\tdeployedAt: \"2026-06-16\",\n\t\t},\n\t},\n} as const satisfies Readonly<\n\tPartial<Record<ChainId, Readonly<Partial<Record<GatewayEnv, Deployment>>>>>\n>;\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\nexport const PACK_NAME = \"blockaid\" as const;\nexport const PACK_VERSION = \"0.0.1\" as const;\nexport const PACK_DESCRIPTION =\n\t\"Gates vault deposits at transaction-submission time using Blockaid's EVM transaction scan (validation + simulation) to catch malicious calldata, frontend-redirect attacks, and value-skim simulations\" as const;\nexport const PACK_LINK = \"https://www.blockaid.io\" as const;\nexport const PACK_AUTHOR = \"\" as const;\n","// Hand-written canonical export — survives `pnpm gen:bindings` regen.\n// The generated `index.ts` re-exports `pack.ts` when present.\nimport {\n\ttype OracleModule,\n\toracleModuleFromPack,\n\ttype PolicyPack,\n} from \"@newton-xyz/policy-pack-shared\";\nimport { deployments } from \"./deployments\";\nimport { PACK_AUTHOR, PACK_DESCRIPTION, PACK_LINK, PACK_NAME, PACK_VERSION } from \"./metadata\";\nimport { type Params, ParamsJsonSchema, ParamsSchema } from \"./params\";\nimport { prepareQuery } from \"./prepare-query\";\nimport { type Secrets, SecretsSchema } from \"./secrets\";\nimport { type WasmArgs, WasmArgsSchema } from \"./wasm-args\";\n\nexport { type PrepareQueryOptions, prepareQuery } from \"./prepare-query\";\n\n/**\n * The Blockaid transaction-scan `PolicyPack`.\n *\n * Pass to `createShield(...)` from `@newton-xyz/newton-shield-sdk`. Encoding\n * for the on-chain `policyParams` blob is handled by `encodePolicyParams` /\n * `decodePolicyParams` in `@newton-xyz/policy-pack-shared` (UTF-8 JSON,\n * sorted keys) — not per-pack.\n *\n * `prepareQuery` derives the Blockaid `chain` slug from `publicClient.chain.id`\n * and reads `from`/`to`/`value`/`data` from the SDK's per-call options bag —\n * these mirror the on-chain transaction the depositor is about to submit, so\n * they can't be inferred from `PrepareQueryArgs` alone.\n */\nexport const blockaid: PolicyPack<Params, WasmArgs, Secrets> = {\n\tid: `${PACK_NAME}/transaction-scan/v1`,\n\tparamsSchema: ParamsSchema,\n\tparamsJsonSchema: ParamsJsonSchema,\n\twasmArgsSchema: WasmArgsSchema,\n\tsecretsSchema: SecretsSchema,\n\tprepareQuery,\n\tdeployments,\n\tmetadata: {\n\t\tname: PACK_NAME,\n\t\tversion: PACK_VERSION,\n\t\tdescription: PACK_DESCRIPTION,\n\t\tauthor: PACK_AUTHOR || undefined,\n\t\tlink: PACK_LINK || undefined,\n\t},\n};\n\n/**\n * Composite-policy view of the blockaid pack. Pass to `defineComposite(...)`\n * (Phase 2 — see `docs/composite-policies.md`) when stacking blockaid with\n * other packs in one Shield. Strict subset of the `PolicyPack` above —\n * shares the same `id`, schemas, and deployments.\n */\nexport const blockaidOracleModule: OracleModule<Params, WasmArgs, Secrets> =\n\toracleModuleFromPack(blockaid);\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/params_schema.json\nimport { z } from \"zod\";\n\nexport const ParamsSchema = z\n\t.object({\n\t\tdeny_features: z\n\t\t\t.array(z.string())\n\t\t\t.describe(\n\t\t\t\t\"Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])\",\n\t\t\t),\n\t\tmax_outbound_inbound_ratio: z\n\t\t\t.number()\n\t\t\t.describe(\n\t\t\t\t\"Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied.\",\n\t\t\t),\n\t\trequire_received_shares: z\n\t\t\t.boolean()\n\t\t\t.describe(\n\t\t\t\t\"Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts.\",\n\t\t\t),\n\t})\n\t.describe(\"Thresholds for the Blockaid transaction-time exploit gate\")\n\t.strict();\n\nexport type Params = z.infer<typeof ParamsSchema>;\n\nexport const ParamsJsonSchema = {\n\ttype: \"object\",\n\tdescription: \"Thresholds for the Blockaid transaction-time exploit gate\",\n\tproperties: {\n\t\tdeny_features: {\n\t\t\ttype: \"array\",\n\t\t\titems: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t\"Blockaid feature ids that, if present on a Warning-classified transaction, deny the deposit (e.g. ['unbounded_approval','honeypot','phishing'])\",\n\t\t},\n\t\tmax_outbound_inbound_ratio: {\n\t\t\ttype: \"number\",\n\t\t\tdescription:\n\t\t\t\t\"Maximum allowed simulated outbound-to-inbound USD value ratio. Above this, the transaction is treated as a value-skim and denied.\",\n\t\t},\n\t\trequire_received_shares: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription:\n\t\t\t\t\"Deny if the simulated state-diff shows the depositor receives no inbound asset (vault shares). Catches contracts that take funds without minting receipts.\",\n\t\t},\n\t},\n\trequired: [\"deny_features\", \"max_outbound_inbound_ratio\", \"require_received_shares\"],\n} as const;\n","import type { PrepareQueryArgs, PrepareQueryResult } from \"@newton-xyz/policy-pack-shared\";\nimport type { WasmArgs } from \"./wasm-args\";\n\n/**\n * Blockaid maps EVM chain id → its own chain identifier slug. Keep this\n * aligned with whatever the AVS-side `policy.js` posts to Blockaid; if you\n * extend it, extend both sides together.\n */\nconst CHAIN_BY_ID: Readonly<Record<number, string>> = {\n\t1: \"ethereum\",\n\t8453: \"base\",\n\t42161: \"arbitrum\",\n\t10: \"optimism\",\n\t137: \"polygon\",\n\t56: \"bsc\",\n\t11155111: \"sepolia\",\n\t84532: \"base-sepolia\",\n};\n\n/**\n * Per-call inputs for Blockaid: every wasmArg (`from`, `to`, `value`, `data`)\n * mirrors the on-chain transaction the depositor is about to submit, so it\n * has to come from the SDK's intent context — `PrepareQueryArgs` (which only\n * carries `publicClient` + `target`) doesn't have any of it. The SDK forwards\n * these via `prepareQuery`'s second `options` arg (introduced in NEWT-1499).\n *\n * `chain` is derived from `publicClient.chain.id` so curators don't have to\n * keep the Blockaid slug list in sync separately.\n */\nexport interface PrepareQueryOptions {\n\treadonly from: string;\n\treadonly to: string;\n\treadonly value?: string;\n\treadonly data?: string;\n}\n\nexport async function prepareQuery(\n\t{ publicClient }: PrepareQueryArgs,\n\toptions?: PrepareQueryOptions,\n): Promise<PrepareQueryResult<WasmArgs>> {\n\tconst chainId = publicClient.chain?.id;\n\tif (chainId === undefined) {\n\t\tthrow new Error(\n\t\t\t\"policy-pack-blockaid: publicClient.chain is undefined. Pass a chain to viem's createPublicClient.\",\n\t\t);\n\t}\n\tconst chain = CHAIN_BY_ID[chainId];\n\tif (!chain) {\n\t\tthrow new Error(\n\t\t\t`policy-pack-blockaid: chain id ${chainId} is not in the Blockaid chain map. Add it to CHAIN_BY_ID before using this pack on this chain.`,\n\t\t);\n\t}\n\tif (!options?.from || !options?.to) {\n\t\tthrow new Error(\n\t\t\t\"policy-pack-blockaid: prepareQuery requires `from` and `to` in the options bag — these mirror the on-chain transaction the depositor is about to submit.\",\n\t\t);\n\t}\n\n\treturn {\n\t\twasmArgs: {\n\t\t\tchain,\n\t\t\tfrom: options.from,\n\t\t\tto: options.to,\n\t\t\tvalue: options.value,\n\t\t\tdata: options.data,\n\t\t},\n\t};\n}\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/secrets_schema.json\nimport { z } from \"zod\";\n\nexport const SecretsSchema = z.object({ BLOCKAID_API_KEY: z.string().min(1) }).strict();\n\nexport type Secrets = z.infer<typeof SecretsSchema>;\n","// AUTO-GENERATED by scripts/generate-bindings.ts — DO NOT EDIT.\n// Source: AVS-side artifacts in this repo (run `pnpm gen:bindings` to regenerate).\n// Source schema: blockaid/wasm_args_schema.json\nimport { z } from \"zod\";\n\nexport const WasmArgsSchema = z\n\t.object({\n\t\tchain: z.string().describe(\"Blockaid chain identifier (e.g. 'ethereum', 'base', 'arbitrum').\"),\n\t\tfrom: z.string().describe(\"Sender / account address (0x-prefixed 20-byte address).\"),\n\t\tto: z.string().describe(\"Recipient or contract address being called (0x-prefixed).\"),\n\t\tvalue: z\n\t\t\t.string()\n\t\t\t.describe(\n\t\t\t\t\"Transaction value in wei as a 0x-prefixed hex string. Defaults to '0x0' when omitted.\",\n\t\t\t)\n\t\t\t.optional(),\n\t\tdata: z\n\t\t\t.string()\n\t\t\t.describe(\"Transaction calldata as a 0x-prefixed hex string. Defaults to '0x' when omitted.\")\n\t\t\t.optional(),\n\t})\n\t.describe(\"Inputs passed to the Blockaid policy WASM at evaluation time\");\n\nexport type WasmArgs = z.infer<typeof WasmArgsSchema>;\n"],"mappings":";AAIO,IAAM,cAAc;AAAA,EAC1B,KAAK;AAAA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CAAC,EACA,SAAS,8DAA8D;;;AJQlE,IAAM,WAAkD;AAAA,EAC9D,IAAI,GAAG,SAAS;AAAA,EAChB,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA,UAAU;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,QAAQ,eAAe;AAAA,IACvB,MAAM,aAAa;AAAA,EACpB;AACD;AAQO,IAAM,uBACZ,qBAAqB,QAAQ;","names":["z","z"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newton-xyz/policy-pack-blockaid",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Bindings-only Newton blockaid policy pack (zod schemas + deployments). No PolicyPack export yet — use with NewtonShield.guardedCall until pack.ts lands.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Newton Protocol <https://x.com/newton_xyz> (https://newton.xyz)",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"LICENSE"
|
|
42
42
|
],
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@newton-xyz/policy-pack-shared": "^0.
|
|
44
|
+
"@newton-xyz/policy-pack-shared": "^0.7.0",
|
|
45
45
|
"viem": "^2.0.0",
|
|
46
46
|
"zod": "^3.0.0"
|
|
47
47
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"typescript": "^5.5.0",
|
|
52
52
|
"viem": "^2.0.0",
|
|
53
53
|
"zod": "^3.23.0",
|
|
54
|
-
"@newton-xyz/policy-pack-shared": "0.
|
|
54
|
+
"@newton-xyz/policy-pack-shared": "0.7.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup",
|