@swarm-tips/client 0.0.0 → 0.1.1
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/README.md +17 -1
- package/SBOM.spdx.json +1558 -0
- package/dist/cli/swarm-tx.d.ts +2 -0
- package/dist/cli/swarm-tx.js +46 -0
- package/dist/cli/vow-verify.d.ts +2 -0
- package/dist/cli/vow-verify.js +69 -0
- package/dist/contracts/generated/coordination_game.d.ts +6107 -0
- package/dist/contracts/generated/coordination_game.js +1 -0
- package/dist/contracts/generated/shillbot.d.ts +4209 -0
- package/dist/contracts/generated/shillbot.js +1 -0
- package/dist/contracts/idl/coordination_game.json +6101 -0
- package/dist/contracts/idl/shillbot.json +4203 -0
- package/dist/contracts/index.d.ts +33 -0
- package/dist/contracts/index.js +84 -0
- package/dist/coordination-game/battery.d.ts +40 -0
- package/dist/coordination-game/battery.js +82 -0
- package/dist/coordination-game/index.d.ts +4 -0
- package/dist/coordination-game/index.js +3 -0
- package/dist/coordination-game/outcome-oracle.d.ts +53 -0
- package/dist/coordination-game/outcome-oracle.js +136 -0
- package/dist/evm/index.d.ts +3 -0
- package/dist/evm/index.js +6 -0
- package/dist/evm/sign.d.ts +12 -0
- package/dist/evm/sign.js +23 -0
- package/dist/evm/testing.d.ts +21 -0
- package/dist/evm/testing.js +34 -0
- package/dist/evm/tx.d.ts +27 -0
- package/dist/evm/tx.js +18 -0
- package/dist/evm/wallet.d.ts +58 -0
- package/dist/evm/wallet.js +182 -0
- package/dist/inbox/client.d.ts +189 -0
- package/dist/inbox/client.js +334 -0
- package/dist/inbox/index.d.ts +2 -0
- package/dist/inbox/index.js +4 -0
- package/dist/inbox/solana.d.ts +11 -0
- package/dist/inbox/solana.js +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/shillbot/index.d.ts +115 -0
- package/dist/shillbot/index.js +327 -0
- package/dist/shillbot/payout-oracle.d.ts +63 -0
- package/dist/shillbot/payout-oracle.js +172 -0
- package/dist/shillbot/switchboard.d.ts +27 -0
- package/dist/shillbot/switchboard.js +205 -0
- package/dist/vow/decoders/extension.d.ts +62 -0
- package/dist/vow/decoders/extension.js +48 -0
- package/dist/vow/decoders/shillbot.d.ts +59 -0
- package/dist/vow/decoders/shillbot.js +130 -0
- package/dist/vow/discriminator.d.ts +12 -0
- package/dist/vow/discriminator.js +25 -0
- package/dist/vow/index.d.ts +7 -0
- package/dist/vow/index.js +5 -0
- package/dist/vow/schema.d.ts +14 -0
- package/dist/vow/schema.js +132 -0
- package/dist/vow/types.d.ts +107 -0
- package/dist/vow/types.js +1 -0
- package/dist/vow/verify.d.ts +23 -0
- package/dist/vow/verify.js +145 -0
- package/package.json +99 -6
- package/index.js +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { Connection } from "@solana/web3.js";
|
|
4
|
+
import { buildTransaction, inspectTransaction, signAndBroadcast, verifyIntent, } from "../shillbot/index.js";
|
|
5
|
+
async function input() {
|
|
6
|
+
const path = process.argv[3];
|
|
7
|
+
const raw = path
|
|
8
|
+
? await readFile(path, "utf8")
|
|
9
|
+
: await new Promise((resolve, reject) => {
|
|
10
|
+
const chunks = [];
|
|
11
|
+
process.stdin.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
12
|
+
process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
13
|
+
process.stdin.on("error", reject);
|
|
14
|
+
});
|
|
15
|
+
return JSON.parse(raw);
|
|
16
|
+
}
|
|
17
|
+
async function main() {
|
|
18
|
+
const command = process.argv[2];
|
|
19
|
+
const value = await input();
|
|
20
|
+
if (command === "build") {
|
|
21
|
+
process.stdout.write(`${JSON.stringify(buildTransaction(value))}\n`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (command === "inspect") {
|
|
25
|
+
process.stdout.write(`${JSON.stringify(inspectTransaction(String(value.transaction)))}\n`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (command === "verify") {
|
|
29
|
+
const result = verifyIntent(String(value.transaction), value.intent);
|
|
30
|
+
process.stdout.write(`${JSON.stringify({ valid: true, inspection: result })}\n`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (command === "broadcast") {
|
|
34
|
+
const connection = new Connection(String(value.rpcUrl), "confirmed");
|
|
35
|
+
// Broadcast accepts only an already-signed wire transaction. The callback
|
|
36
|
+
// returns it unchanged; the SDK never reads private-key files.
|
|
37
|
+
const signature = await signAndBroadcast(connection, String(value.transaction), async (transaction) => transaction);
|
|
38
|
+
process.stdout.write(`${JSON.stringify({ signature })}\n`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
throw new Error("usage: swarm-tx <build|inspect|verify|broadcast> [input.json]; otherwise JSON is read from stdin");
|
|
42
|
+
}
|
|
43
|
+
main().catch((error) => {
|
|
44
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `vow-verify <attestation.json> [--rpc <url>]`
|
|
4
|
+
*
|
|
5
|
+
* MVP CLI entrypoint. Reads a VOW v1 attestation from a file path or
|
|
6
|
+
* stdin, runs the full 7-step verifier against the named network's
|
|
7
|
+
* default RPC (or the `--rpc` override), prints the verdict as JSON.
|
|
8
|
+
*
|
|
9
|
+
* Exits with code 0 on `valid: true`, code 1 on `valid: false`, code
|
|
10
|
+
* 2 on usage error / unreadable file.
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync } from "node:fs";
|
|
13
|
+
import { Connection } from "@solana/web3.js";
|
|
14
|
+
import { verifyV1 } from "../vow/verify.js";
|
|
15
|
+
import { shillbotProtocol } from "../vow/decoders/shillbot.js";
|
|
16
|
+
const DEFAULT_RPC = {
|
|
17
|
+
mainnet: "https://api.mainnet-beta.solana.com",
|
|
18
|
+
devnet: "https://api.devnet.solana.com",
|
|
19
|
+
};
|
|
20
|
+
async function main() {
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
|
|
23
|
+
process.stderr.write("Usage: vow-verify <attestation.json> [--rpc <url>]\n" +
|
|
24
|
+
" vow-verify - [--rpc <url>] (read from stdin)\n");
|
|
25
|
+
return 2;
|
|
26
|
+
}
|
|
27
|
+
const path = args[0];
|
|
28
|
+
let rpcUrlOverride;
|
|
29
|
+
for (let i = 1; i < args.length; i++) {
|
|
30
|
+
if (args[i] === "--rpc" && i + 1 < args.length) {
|
|
31
|
+
rpcUrlOverride = args[i + 1];
|
|
32
|
+
i++;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
let raw;
|
|
36
|
+
try {
|
|
37
|
+
raw = path === "-" ? readStdinSync() : readFileSync(path, "utf8");
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
process.stderr.write(`failed to read ${path}: ${e.message}\n`);
|
|
41
|
+
return 2;
|
|
42
|
+
}
|
|
43
|
+
let attestation;
|
|
44
|
+
try {
|
|
45
|
+
attestation = JSON.parse(raw);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
process.stderr.write(`invalid JSON in ${path}: ${e.message}\n`);
|
|
49
|
+
return 2;
|
|
50
|
+
}
|
|
51
|
+
const network = typeof attestation === "object" &&
|
|
52
|
+
attestation !== null &&
|
|
53
|
+
typeof attestation.network === "string"
|
|
54
|
+
? attestation.network
|
|
55
|
+
: "mainnet";
|
|
56
|
+
const rpcUrl = rpcUrlOverride ?? DEFAULT_RPC[network] ?? DEFAULT_RPC.mainnet;
|
|
57
|
+
const rpc = new Connection(rpcUrl, "confirmed");
|
|
58
|
+
const verdict = await verifyV1(attestation, shillbotProtocol, rpc);
|
|
59
|
+
process.stdout.write(JSON.stringify(verdict, null, 2) + "\n");
|
|
60
|
+
return verdict.valid ? 0 : 1;
|
|
61
|
+
}
|
|
62
|
+
function readStdinSync() {
|
|
63
|
+
// Sync read works on Node 16+ for piped input (small files).
|
|
64
|
+
return readFileSync(0, "utf8");
|
|
65
|
+
}
|
|
66
|
+
main().then((code) => process.exit(code), (err) => {
|
|
67
|
+
process.stderr.write(`unexpected error: ${err.message}\n`);
|
|
68
|
+
process.exit(2);
|
|
69
|
+
});
|