@crewhaus/tool-evm-tx 0.1.1 → 0.1.3
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/package.json +10 -15
- package/src/index.test.ts +70 -0
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/tool-evm-tx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Built-in destructive EVM transaction tools (EvmSendTransaction, EvmSimulate). All destructive: true — gated by permission-engine approval + wallet-engine policy. §47 slice 1.",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"test": "bun test src"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@crewhaus/chain-adapter-base": "0.1.
|
|
16
|
-
"@crewhaus/errors": "0.1.
|
|
17
|
-
"@crewhaus/tool-builder": "0.1.
|
|
18
|
-
"@crewhaus/tool-catalog": "0.1.
|
|
19
|
-
"@crewhaus/wallet-engine": "0.1.
|
|
15
|
+
"@crewhaus/chain-adapter-base": "0.1.3",
|
|
16
|
+
"@crewhaus/errors": "0.1.3",
|
|
17
|
+
"@crewhaus/tool-builder": "0.1.3",
|
|
18
|
+
"@crewhaus/tool-catalog": "0.1.3",
|
|
19
|
+
"@crewhaus/wallet-engine": "0.1.3",
|
|
20
20
|
"zod": "^3.23.8"
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"author": {
|
|
24
24
|
"name": "Max Meier",
|
|
25
|
-
"email": "max@
|
|
26
|
-
"url": "https://
|
|
25
|
+
"email": "max@crewhaus.ai",
|
|
26
|
+
"url": "https://crewhaus.ai"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
29
29
|
"type": "git",
|
|
@@ -35,12 +35,7 @@
|
|
|
35
35
|
"url": "https://github.com/crewhaus/factory/issues"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
|
-
"access": "
|
|
38
|
+
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"files": [
|
|
41
|
-
"src",
|
|
42
|
-
"README.md",
|
|
43
|
-
"LICENSE",
|
|
44
|
-
"NOTICE"
|
|
45
|
-
]
|
|
40
|
+
"files": ["src", "README.md", "LICENSE", "NOTICE"]
|
|
46
41
|
}
|
package/src/index.test.ts
CHANGED
|
@@ -144,6 +144,76 @@ describe("EvmSendTransaction — happy path through wallet-engine", () => {
|
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
+
describe("resolver-binding guards", () => {
|
|
148
|
+
// These exercise the boot-time "resolver was never bound" branches, which
|
|
149
|
+
// are distinct from a bound resolver returning undefined. The setters assign
|
|
150
|
+
// the module-level resolver directly, so passing undefined clears them.
|
|
151
|
+
test("throws when no WalletResolver is bound", async () => {
|
|
152
|
+
setWalletResolver(undefined as unknown as (id: string) => undefined);
|
|
153
|
+
await expect(
|
|
154
|
+
EVM_TX_TOOL_MAP.evmSendTransaction.execute({
|
|
155
|
+
walletId: "treasury",
|
|
156
|
+
to: "0xusdc",
|
|
157
|
+
data: "0xabcd",
|
|
158
|
+
}),
|
|
159
|
+
).rejects.toThrow(/no WalletResolver bound/);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("throws when no TransactionPolicyResolver is bound", async () => {
|
|
163
|
+
// Wallet resolves OK so we get past requireWallet into requirePolicy.
|
|
164
|
+
setWalletResolver(() => WALLET);
|
|
165
|
+
setTransactionPolicyResolver(undefined as unknown as () => undefined);
|
|
166
|
+
await expect(
|
|
167
|
+
EVM_TX_TOOL_MAP.evmSendTransaction.execute({
|
|
168
|
+
walletId: "treasury",
|
|
169
|
+
to: "0xusdc",
|
|
170
|
+
data: "0xabcd",
|
|
171
|
+
}),
|
|
172
|
+
).rejects.toThrow(/no TransactionPolicyResolver bound/);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("throws when the policy resolver returns undefined", async () => {
|
|
176
|
+
setWalletResolver(() => WALLET);
|
|
177
|
+
setTransactionPolicyResolver(() => undefined);
|
|
178
|
+
await expect(
|
|
179
|
+
EVM_TX_TOOL_MAP.evmSendTransaction.execute({
|
|
180
|
+
walletId: "treasury",
|
|
181
|
+
to: "0xusdc",
|
|
182
|
+
data: "0xabcd",
|
|
183
|
+
}),
|
|
184
|
+
).rejects.toThrow(/no transaction_policy declared/);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("throws when no WalletEngineResolver is bound", async () => {
|
|
188
|
+
// Wallet + policy resolve OK so we reach requireEngine's unbound branch.
|
|
189
|
+
setWalletResolver(() => WALLET);
|
|
190
|
+
setTransactionPolicyResolver(() => POLICY);
|
|
191
|
+
setWalletEngineResolver(undefined as unknown as () => undefined);
|
|
192
|
+
await expect(
|
|
193
|
+
EVM_TX_TOOL_MAP.evmSendTransaction.execute({
|
|
194
|
+
walletId: "treasury",
|
|
195
|
+
contractId: "usdc",
|
|
196
|
+
to: "0xusdc",
|
|
197
|
+
data: "0xabcd",
|
|
198
|
+
}),
|
|
199
|
+
).rejects.toThrow(/no WalletEngine bound/);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("throws when the engine resolver returns undefined (EvmSimulate path)", async () => {
|
|
203
|
+
// EvmSimulate calls requireWallet then requireEngine; a bound resolver
|
|
204
|
+
// returning undefined exercises the `e === undefined` branch.
|
|
205
|
+
setWalletResolver(() => WALLET);
|
|
206
|
+
setWalletEngineResolver(() => undefined);
|
|
207
|
+
await expect(
|
|
208
|
+
EVM_TX_TOOL_MAP.evmSimulate.execute({
|
|
209
|
+
walletId: "treasury",
|
|
210
|
+
to: "0xusdc",
|
|
211
|
+
data: "0xabcd",
|
|
212
|
+
}),
|
|
213
|
+
).rejects.toThrow(/WalletEngine resolver returned undefined/);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
147
217
|
describe("EvmSimulate", () => {
|
|
148
218
|
test("returns success+gasUsed without broadcasting", async () => {
|
|
149
219
|
const engine = createWalletEngine({
|
package/src/index.ts
CHANGED
|
@@ -125,6 +125,8 @@ export const evmSendTransaction: RegisteredTool = buildTool({
|
|
|
125
125
|
// Pillar 3 sink-side: broadcasting a tx writes data permanently to a
|
|
126
126
|
// public ledger — the most-external sink we have.
|
|
127
127
|
scope: "external",
|
|
128
|
+
// FR-002 — declare the io-capability fact (RPC broadcast over the network).
|
|
129
|
+
ioCapability: "network",
|
|
128
130
|
// Pillar 3 intent gate: tx broadcast is destructive AND irreversible AND
|
|
129
131
|
// costs money. Mandatory justification gate.
|
|
130
132
|
requireJustification: true,
|