@shippedcalls/sdk 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +85 -2
- package/dist/abi.d.ts +1623 -0
- package/dist/abi.js +2096 -0
- package/dist/abi.js.map +1 -0
- package/dist/canonical.d.ts +2 -0
- package/dist/canonical.js +25 -0
- package/dist/canonical.js.map +1 -0
- package/dist/chain.d.ts +19 -0
- package/dist/chain.js +38 -0
- package/dist/chain.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +294 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +154 -0
- package/dist/client.js +402 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +51 -0
- package/dist/errors.js.map +1 -0
- package/dist/hashes.d.ts +12 -0
- package/dist/hashes.js +25 -0
- package/dist/hashes.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/odds.d.ts +40 -0
- package/dist/odds.js +70 -0
- package/dist/odds.js.map +1 -0
- package/dist/types.d.ts +406 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +32 -4
- package/skill/SKILL.md +60 -0
- package/skill/references/api.md +59 -0
- package/skill/references/funding.md +27 -0
- package/skill/references/settlement.md +39 -0
- package/skill/references/write-path.md +66 -0
- package/skill/scripts/calls.sh +3 -0
- package/src/abi.ts +2098 -0
- package/src/canonical.ts +24 -0
- package/src/chain.ts +41 -0
- package/src/cli.ts +286 -0
- package/src/client.ts +430 -0
- package/src/errors.ts +49 -0
- package/src/hashes.ts +32 -0
- package/src/index.ts +8 -0
- package/src/odds.ts +79 -0
- package/src/types.ts +299 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { type Account, type Address, type Hash, type Transport } from "viem";
|
|
2
|
+
import { type Side } from "./odds.js";
|
|
3
|
+
import type { CallDetail, CallRow, CallStatus, CallType, Leaderboard, OpenInput, Opened, Player, Positions, Prepared, Proof, Quote, RecentBet, Settlement, ShippedAgent, TapeItem } from "./types.js";
|
|
4
|
+
export interface ClientOptions {
|
|
5
|
+
/** The API's origin. https://calls.shipped.bond by default. */
|
|
6
|
+
api?: string;
|
|
7
|
+
/** One endpoint, a comma-separated list or an array, tried in order. A public list with fallback by default. */
|
|
8
|
+
rpc?: string | readonly string[];
|
|
9
|
+
/** A private key, or `account` for any viem account. Reads need neither. */
|
|
10
|
+
privateKey?: string;
|
|
11
|
+
account?: Account;
|
|
12
|
+
/** The most one bet may stake, wei. 0.01 ETH by default. */
|
|
13
|
+
maxStake?: bigint;
|
|
14
|
+
chainId?: number;
|
|
15
|
+
factory?: Address;
|
|
16
|
+
fetch?: typeof fetch;
|
|
17
|
+
/** A viem transport in place of `rpc`. */
|
|
18
|
+
transport?: Transport;
|
|
19
|
+
}
|
|
20
|
+
export declare const DEFAULT_MAX_STAKE: bigint;
|
|
21
|
+
export declare const DEFAULT_MAX_BOND: bigint;
|
|
22
|
+
export declare function sideOf(side: unknown): Side;
|
|
23
|
+
export declare function accountFromKey(privateKey: string): Account;
|
|
24
|
+
/** Shipped's mainnet registry opened with a test bond, so its public bond numbers count from the one after it. */
|
|
25
|
+
export declare const bondIdOf: (number: number, chainId?: number) => number;
|
|
26
|
+
/** The hashes a Call opens with, computed here. `open` checks the API's against them before it spends anything. */
|
|
27
|
+
export declare function prepareOpen(input: OpenInput, chainId?: number): Prepared;
|
|
28
|
+
export declare function createClient(options?: ClientOptions): {
|
|
29
|
+
/** The wallet this client signs with, if any. */
|
|
30
|
+
address: `0x${string}` | null;
|
|
31
|
+
chainId: number;
|
|
32
|
+
factory: `0x${string}`;
|
|
33
|
+
calls(filters?: {
|
|
34
|
+
status?: CallStatus;
|
|
35
|
+
type?: CallType;
|
|
36
|
+
subject?: string;
|
|
37
|
+
sort?: "closing" | "lopsided" | "pot" | "newest";
|
|
38
|
+
limit?: number;
|
|
39
|
+
offset?: number;
|
|
40
|
+
}): Promise<CallRow[]>;
|
|
41
|
+
call: (address: string) => Promise<CallDetail>;
|
|
42
|
+
/** The latest bets across every Call, or every bet on one Call with `call`. */
|
|
43
|
+
bets({ call, limit }?: {
|
|
44
|
+
call?: string;
|
|
45
|
+
limit?: number;
|
|
46
|
+
}): Promise<RecentBet[] | CallDetail["bets"]>;
|
|
47
|
+
tape({ limit }?: {
|
|
48
|
+
limit?: number;
|
|
49
|
+
}): Promise<TapeItem[]>;
|
|
50
|
+
leaderboard: (filters?: {
|
|
51
|
+
window?: "week" | "all";
|
|
52
|
+
board?: "profit" | "best" | "streak" | "openers";
|
|
53
|
+
limit?: number;
|
|
54
|
+
me?: string;
|
|
55
|
+
}) => Promise<Leaderboard>;
|
|
56
|
+
player: (address?: string) => Promise<Player>;
|
|
57
|
+
/** Shipped agents: name, rule and wallet. */
|
|
58
|
+
agents(): Promise<ShippedAgent[]>;
|
|
59
|
+
proof: () => Promise<Proof>;
|
|
60
|
+
/**
|
|
61
|
+
* What `amount` wei on `side` pays with the pools as they stand. Reads the pools from the chain, and from the API if
|
|
62
|
+
* no endpoint answers. Later bets move the payout until betting closes.
|
|
63
|
+
*/
|
|
64
|
+
quote(address: string, side: Side | string, amount: bigint): Promise<Quote>;
|
|
65
|
+
/** One wallet's open positions and settled Calls from the API, with its balance and what it can claim from the chain. */
|
|
66
|
+
positions(address?: string): Promise<Positions>;
|
|
67
|
+
isCall: (address: string) => Promise<boolean>;
|
|
68
|
+
pool: (address: string, side: Side | string) => Promise<bigint>;
|
|
69
|
+
status: (address: string) => Promise<CallStatus>;
|
|
70
|
+
odds(address: string): Promise<{
|
|
71
|
+
holdsBps: number;
|
|
72
|
+
breaksBps: number;
|
|
73
|
+
holdsMultiple: number | null;
|
|
74
|
+
breaksMultiple: number | null;
|
|
75
|
+
pools: {
|
|
76
|
+
holds: bigint;
|
|
77
|
+
breaks: bigint;
|
|
78
|
+
};
|
|
79
|
+
}>;
|
|
80
|
+
payoutOf: (address: string, who?: string) => Promise<bigint>;
|
|
81
|
+
stake: (address: string, side: Side | string, who?: string) => Promise<bigint>;
|
|
82
|
+
balance: (who?: string) => Promise<bigint>;
|
|
83
|
+
/**
|
|
84
|
+
* Stakes `amount` wei on `side`. Refuses an amount over `maxStake` and an address that is not one of the factory's
|
|
85
|
+
* Calls before anything goes out; simulates first, so a bet the contract would refuse costs nothing.
|
|
86
|
+
*/
|
|
87
|
+
bet(address: string, side: Side | string, amount: bigint, { maxStake: cap }?: {
|
|
88
|
+
maxStake?: bigint;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
call: `0x${string}`;
|
|
91
|
+
side: Side;
|
|
92
|
+
amount: string;
|
|
93
|
+
pools: {
|
|
94
|
+
holds: string;
|
|
95
|
+
breaks: string;
|
|
96
|
+
} | null;
|
|
97
|
+
hash: Hash;
|
|
98
|
+
block: number;
|
|
99
|
+
gasUsed: string;
|
|
100
|
+
fee: import("./types.js").Wei;
|
|
101
|
+
explorerUrl: string | null;
|
|
102
|
+
}>;
|
|
103
|
+
/** Collects winnings or a refund once the Call is Final or Voided. The money only ever goes to the wallet that sends this. */
|
|
104
|
+
claim: (address: string) => Promise<{
|
|
105
|
+
call: `0x${string}`;
|
|
106
|
+
amount: string | null;
|
|
107
|
+
hash: Hash;
|
|
108
|
+
block: number;
|
|
109
|
+
gasUsed: string;
|
|
110
|
+
fee: import("./types.js").Wei;
|
|
111
|
+
explorerUrl: string | null;
|
|
112
|
+
}>;
|
|
113
|
+
/** Pays the opener's bond and fee share. Anyone can send it; the money only ever goes to the opener. */
|
|
114
|
+
claimOpener: (address: string) => Promise<{
|
|
115
|
+
call: `0x${string}`;
|
|
116
|
+
opener: `0x${string}` | null;
|
|
117
|
+
amount: string | null;
|
|
118
|
+
hash: Hash;
|
|
119
|
+
block: number;
|
|
120
|
+
gasUsed: string;
|
|
121
|
+
fee: import("./types.js").Wei;
|
|
122
|
+
explorerUrl: string | null;
|
|
123
|
+
}>;
|
|
124
|
+
/** Makes a Settled Call Final once its dispute window has passed. Anyone can send it. */
|
|
125
|
+
finalize: (address: string) => Promise<{
|
|
126
|
+
call: `0x${string}`;
|
|
127
|
+
hash: Hash;
|
|
128
|
+
block: number;
|
|
129
|
+
gasUsed: string;
|
|
130
|
+
fee: import("./types.js").Wei;
|
|
131
|
+
explorerUrl: string | null;
|
|
132
|
+
}>;
|
|
133
|
+
/** Disputes a settled result inside its window, posting the dispute bond (0.02 ETH). The court rules; the bond comes back if it flips the result. */
|
|
134
|
+
dispute: (address: string) => Promise<{
|
|
135
|
+
call: `0x${string}`;
|
|
136
|
+
bond: string;
|
|
137
|
+
hash: Hash;
|
|
138
|
+
block: number;
|
|
139
|
+
gasUsed: string;
|
|
140
|
+
fee: import("./types.js").Wei;
|
|
141
|
+
explorerUrl: string | null;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* Opens a Call. Stores the sentence and spec with `POST /v1/calls` first, because Shipped settles from the stored
|
|
145
|
+
* spec, checks the API's hashes against its own, then sends `CallsFactory.open` with the bond.
|
|
146
|
+
*/
|
|
147
|
+
open(input: OpenInput): Promise<Opened>;
|
|
148
|
+
/**
|
|
149
|
+
* Checks a settlement: fetches the evidence record the API serves, hashes its canonical JSON and compares that and
|
|
150
|
+
* the record's outcome with the chain.
|
|
151
|
+
*/
|
|
152
|
+
verifySettlement(address: string): Promise<Settlement>;
|
|
153
|
+
};
|
|
154
|
+
export type CallsClient = ReturnType<typeof createClient>;
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { formatEther, getAddress, isAddress, parseEventLogs } from "viem";
|
|
2
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
3
|
+
import { callAbi, factoryAbi } from "./abi.js";
|
|
4
|
+
import { hashJson } from "./canonical.js";
|
|
5
|
+
import { API_URL, CHAIN_ID, clientsFor, DEEDS, EXPLORER, FACTORY, rpcEndpoints } from "./chain.js";
|
|
6
|
+
import { CallsError, describe } from "./errors.js";
|
|
7
|
+
import { callTextHash, canonicalPostUrl, normalizeHandle, parsePostUrl, postRefHash, specHash, subjectHash, ZERO_HASH } from "./hashes.js";
|
|
8
|
+
import { MIN_BET, MIN_OPENER_BOND, odds, quoteOf } from "./odds.js";
|
|
9
|
+
export const DEFAULT_MAX_STAKE = 10n ** 16n;
|
|
10
|
+
export const DEFAULT_MAX_BOND = MIN_OPENER_BOND;
|
|
11
|
+
const STATUS = ["open", "settled", "disputed", "final", "voided"];
|
|
12
|
+
const TYPES = ["posted", "onchain", "price", "deed"];
|
|
13
|
+
const SIDE_CODE = { holds: 1, breaks: 2 };
|
|
14
|
+
const OUTCOME = [null, "holds", "breaks"];
|
|
15
|
+
const SHELF_READS = 50;
|
|
16
|
+
const deedsCoreAbi = [
|
|
17
|
+
{
|
|
18
|
+
type: "function",
|
|
19
|
+
name: "core",
|
|
20
|
+
stateMutability: "view",
|
|
21
|
+
inputs: [{ name: "deedId", type: "uint256" }],
|
|
22
|
+
outputs: [
|
|
23
|
+
{ name: "creator", type: "address" },
|
|
24
|
+
{ name: "status", type: "uint8" },
|
|
25
|
+
{ name: "asset", type: "address" },
|
|
26
|
+
{ name: "deadline", type: "uint64" },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
const BOND_OPEN = 1;
|
|
31
|
+
export function sideOf(side) {
|
|
32
|
+
const name = String(side).toLowerCase();
|
|
33
|
+
if (name === "holds" || name === "1")
|
|
34
|
+
return "holds";
|
|
35
|
+
if (name === "breaks" || name === "2")
|
|
36
|
+
return "breaks";
|
|
37
|
+
throw new CallsError("Pick a side: holds or breaks.", "bad_side");
|
|
38
|
+
}
|
|
39
|
+
function addressOf(value, what = "Call") {
|
|
40
|
+
if (typeof value === "string" && isAddress(value, { strict: false }))
|
|
41
|
+
return getAddress(value);
|
|
42
|
+
throw new CallsError(`Use a ${what} address: 0x and 40 hex characters.`, "bad_address");
|
|
43
|
+
}
|
|
44
|
+
const query = (params) => {
|
|
45
|
+
const q = new URLSearchParams();
|
|
46
|
+
for (const [key, value] of Object.entries(params))
|
|
47
|
+
if (value != null && value !== "")
|
|
48
|
+
q.set(key, String(value));
|
|
49
|
+
const text = q.toString();
|
|
50
|
+
return text ? `?${text}` : "";
|
|
51
|
+
};
|
|
52
|
+
const toTx = (receipt, chainId) => ({
|
|
53
|
+
hash: receipt.transactionHash,
|
|
54
|
+
block: Number(receipt.blockNumber),
|
|
55
|
+
gasUsed: receipt.gasUsed.toString(),
|
|
56
|
+
fee: (receipt.gasUsed * receipt.effectiveGasPrice).toString(),
|
|
57
|
+
explorerUrl: chainId === CHAIN_ID ? `${EXPLORER}/tx/${receipt.transactionHash}` : null,
|
|
58
|
+
});
|
|
59
|
+
export function accountFromKey(privateKey) {
|
|
60
|
+
try {
|
|
61
|
+
return privateKeyToAccount((privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`));
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
throw new CallsError("That private key is not valid: 32 bytes of hex.", "bad_key");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Shipped's mainnet registry opened with a test bond, so its public bond numbers count from the one after it. */
|
|
68
|
+
export const bondIdOf = (number, chainId = CHAIN_ID) => number + (chainId === CHAIN_ID ? 2 : 1) - 1;
|
|
69
|
+
/** The hashes a Call opens with, computed here. `open` checks the API's against them before it spends anything. */
|
|
70
|
+
export function prepareOpen(input, chainId = CHAIN_ID) {
|
|
71
|
+
const bondNumber = input.bondNumber;
|
|
72
|
+
if (bondNumber != null && !(Number.isInteger(bondNumber) && bondNumber > 0))
|
|
73
|
+
throw new CallsError("A bond number is a positive whole number.", "bad_bond_number");
|
|
74
|
+
const spec = bondNumber != null ? { type: "deed", deedId: bondIdOf(bondNumber, chainId) } : input.spec;
|
|
75
|
+
if (!spec || typeof spec !== "object")
|
|
76
|
+
throw new CallsError("Give the Call an evidence spec: see /v1/schemas/<type>.json.", "bad_spec");
|
|
77
|
+
const type = spec.type;
|
|
78
|
+
const callType = TYPES.indexOf(type);
|
|
79
|
+
if (callType < 0)
|
|
80
|
+
throw new CallsError("The spec's type has to be posted, onchain, price or deed.", "bad_spec");
|
|
81
|
+
const bond = input.bond ?? MIN_OPENER_BOND;
|
|
82
|
+
const isBond = type === "deed";
|
|
83
|
+
const named = normalizeHandle(input.handle ?? spec.handle ?? "");
|
|
84
|
+
const handle = isBond ? "" : named || parsePostUrl(input.postUrl)?.handle || "";
|
|
85
|
+
if (input.postUrl && !parsePostUrl(input.postUrl))
|
|
86
|
+
throw new CallsError("Paste a link to a post on X.", "bad_post_url");
|
|
87
|
+
const postUrl = input.postUrl ? canonicalPostUrl(input.postUrl, named || undefined) : null;
|
|
88
|
+
return {
|
|
89
|
+
type,
|
|
90
|
+
callType,
|
|
91
|
+
spec: spec,
|
|
92
|
+
handle: handle || null,
|
|
93
|
+
postUrl,
|
|
94
|
+
bond: bond.toString(),
|
|
95
|
+
hashes: {
|
|
96
|
+
subject: isBond ? ZERO_HASH : subjectHash(handle),
|
|
97
|
+
postRef: postRefHash(postUrl),
|
|
98
|
+
callTextHash: callTextHash(input.callText),
|
|
99
|
+
evidenceSpec: specHash(spec),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function createClient(options = {}) {
|
|
104
|
+
const chainId = options.chainId ?? CHAIN_ID;
|
|
105
|
+
const factory = options.factory ?? FACTORY;
|
|
106
|
+
const origin = (options.api ?? API_URL).replace(/\/$/, "");
|
|
107
|
+
const account = options.account ?? (options.privateKey ? accountFromKey(options.privateKey) : undefined);
|
|
108
|
+
const { reads, writes } = clientsFor({ chainId, urls: rpcEndpoints(options.rpc), account, transport: options.transport });
|
|
109
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
110
|
+
const maxStake = options.maxStake ?? DEFAULT_MAX_STAKE;
|
|
111
|
+
let chainChecked = false;
|
|
112
|
+
async function request(path, init) {
|
|
113
|
+
let res;
|
|
114
|
+
try {
|
|
115
|
+
res = await doFetch(`${origin}${path}`, { signal: AbortSignal.timeout(20_000), ...init });
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
throw new CallsError("Shipped Calls did not answer. Try again shortly.", "api_unavailable");
|
|
119
|
+
}
|
|
120
|
+
const body = (await res.json().catch(() => null));
|
|
121
|
+
if (res.ok && body)
|
|
122
|
+
return body;
|
|
123
|
+
throw new CallsError(body?.error ?? "Shipped Calls did not answer as expected. Try again shortly.", `api_${res.status}`, res.status);
|
|
124
|
+
}
|
|
125
|
+
const read = (address, abi, functionName, args = []) => reads.readContract({ address, abi, functionName, args });
|
|
126
|
+
const callRead = (address, functionName, args = []) => read(address, callAbi, functionName, args);
|
|
127
|
+
async function guarded(work) {
|
|
128
|
+
try {
|
|
129
|
+
return await work();
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
throw describe(error);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const isCall = (address) => read(factory, factoryAbi, "isCall", [address]);
|
|
136
|
+
async function mustBeCall(value) {
|
|
137
|
+
const address = addressOf(value);
|
|
138
|
+
if (!(await isCall(address)))
|
|
139
|
+
throw new CallsError("That address is not a Call of the Shipped Calls factory, so nothing was sent.", "not_a_call");
|
|
140
|
+
return address;
|
|
141
|
+
}
|
|
142
|
+
function wallet() {
|
|
143
|
+
if (!account)
|
|
144
|
+
throw new CallsError("Set a wallet to send this: CALLS_PRIVATE_KEY, or `privateKey` or `account` in code.", "no_wallet");
|
|
145
|
+
return account;
|
|
146
|
+
}
|
|
147
|
+
const walletOr = (value) => (value ? addressOf(value, "wallet") : wallet().address);
|
|
148
|
+
async function assertChain() {
|
|
149
|
+
if (chainChecked)
|
|
150
|
+
return;
|
|
151
|
+
const actual = await reads.getChainId();
|
|
152
|
+
if (actual !== chainId)
|
|
153
|
+
throw new CallsError(`This RPC endpoint serves chain ${actual}, not chain ${chainId}.`, "wrong_chain");
|
|
154
|
+
chainChecked = true;
|
|
155
|
+
}
|
|
156
|
+
// Simulates first, so a write the contract would refuse never reaches the chain and costs nothing. A quarter over
|
|
157
|
+
// the estimate, as Shipped's own services send.
|
|
158
|
+
async function send(params) {
|
|
159
|
+
const from = wallet();
|
|
160
|
+
await assertChain();
|
|
161
|
+
const call = { ...params, account: from };
|
|
162
|
+
const { request: simulated } = await reads.simulateContract(call);
|
|
163
|
+
const estimate = await reads.estimateContractGas(call);
|
|
164
|
+
const hash = await writes.writeContract({ ...simulated, gas: (estimate * 5n + 3n) / 4n });
|
|
165
|
+
const receipt = await reads.waitForTransactionReceipt({ hash, pollingInterval: 1_000 });
|
|
166
|
+
if (receipt.status !== "success")
|
|
167
|
+
throw new CallsError("The transaction failed onchain.", "reverted");
|
|
168
|
+
return receipt;
|
|
169
|
+
}
|
|
170
|
+
const eventOf = (receipt, abi, eventName) => parseEventLogs({ abi, logs: receipt.logs, eventName })[0]?.args;
|
|
171
|
+
async function chainQuote(address, side, amount) {
|
|
172
|
+
const [member, status, closeAt, holds, breaks, block] = await Promise.all([
|
|
173
|
+
isCall(address),
|
|
174
|
+
callRead(address, "status").catch(() => null),
|
|
175
|
+
callRead(address, "closeAt").catch(() => null),
|
|
176
|
+
callRead(address, "pool", [1]).catch(() => null),
|
|
177
|
+
callRead(address, "pool", [2]).catch(() => null),
|
|
178
|
+
reads.getBlock({ blockTag: "latest" }),
|
|
179
|
+
]);
|
|
180
|
+
if (!member)
|
|
181
|
+
throw new CallsError("That address is not a Call of the Shipped Calls factory.", "not_a_call");
|
|
182
|
+
if (status == null || closeAt == null || holds == null || breaks == null)
|
|
183
|
+
throw new CallsError("Robinhood Chain did not answer on any RPC endpoint. Try again, or set CALLS_RPC_URL.", "rpc_unavailable");
|
|
184
|
+
const pools = { holds, breaks };
|
|
185
|
+
const q = quoteOf(pools, side, amount);
|
|
186
|
+
return {
|
|
187
|
+
call: address,
|
|
188
|
+
side,
|
|
189
|
+
amount: amount.toString(),
|
|
190
|
+
status: STATUS[status],
|
|
191
|
+
bettingOpen: status === 0 && block.timestamp < closeAt,
|
|
192
|
+
closeAt: Number(closeAt),
|
|
193
|
+
minBet: MIN_BET.toString(),
|
|
194
|
+
pools: { holds: holds.toString(), breaks: breaks.toString() },
|
|
195
|
+
poolsAfter: { holds: q.poolsAfter.holds.toString(), breaks: q.poolsAfter.breaks.toString() },
|
|
196
|
+
impliedBps: q.impliedBps,
|
|
197
|
+
impliedBpsAfter: q.impliedBpsAfter,
|
|
198
|
+
payout: q.payout.toString(),
|
|
199
|
+
profit: q.profit.toString(),
|
|
200
|
+
multiple: q.multiple,
|
|
201
|
+
refund: q.refund,
|
|
202
|
+
source: "chain",
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const client = {
|
|
206
|
+
/** The wallet this client signs with, if any. */
|
|
207
|
+
address: account?.address ?? null,
|
|
208
|
+
chainId,
|
|
209
|
+
factory,
|
|
210
|
+
// Reads from the API. It follows the chain by up to a minute; the chain reads below do not.
|
|
211
|
+
async calls(filters = {}) {
|
|
212
|
+
return (await request(`/v1/calls${query(filters)}`)).calls;
|
|
213
|
+
},
|
|
214
|
+
call: async (address) => request(`/v1/calls/${addressOf(address)}`),
|
|
215
|
+
/** The latest bets across every Call, or every bet on one Call with `call`. */
|
|
216
|
+
async bets({ call, limit } = {}) {
|
|
217
|
+
if (call)
|
|
218
|
+
return (await client.call(call)).bets;
|
|
219
|
+
return (await request(`/v1/bets/recent${query({ limit })}`)).bets;
|
|
220
|
+
},
|
|
221
|
+
async tape({ limit } = {}) {
|
|
222
|
+
return (await request(`/v1/tape${query({ limit })}`)).items;
|
|
223
|
+
},
|
|
224
|
+
leaderboard: (filters = {}) => request(`/v1/leaderboard${query(filters)}`),
|
|
225
|
+
player: async (address) => request(`/v1/players/${walletOr(address)}`),
|
|
226
|
+
/** Shipped agents: name, rule and wallet. */
|
|
227
|
+
async agents() {
|
|
228
|
+
return (await request("/v1/agents")).agents;
|
|
229
|
+
},
|
|
230
|
+
proof: () => request("/v1/proof"),
|
|
231
|
+
/**
|
|
232
|
+
* What `amount` wei on `side` pays with the pools as they stand. Reads the pools from the chain, and from the API if
|
|
233
|
+
* no endpoint answers. Later bets move the payout until betting closes.
|
|
234
|
+
*/
|
|
235
|
+
async quote(address, side, amount) {
|
|
236
|
+
const call = addressOf(address);
|
|
237
|
+
const name = sideOf(side);
|
|
238
|
+
if (amount < MIN_BET)
|
|
239
|
+
throw new CallsError("The minimum bet is 0.001 ETH.", "BetTooSmall");
|
|
240
|
+
try {
|
|
241
|
+
return await chainQuote(call, name, amount);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
if (error instanceof CallsError && error.code !== "rpc_unavailable")
|
|
245
|
+
throw error;
|
|
246
|
+
return request(`/v1/calls/${call}/quote${query({ side: name, amount })}`);
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
/** One wallet's open positions and settled Calls from the API, with its balance and what it can claim from the chain. */
|
|
250
|
+
async positions(address) {
|
|
251
|
+
const who = walletOr(address);
|
|
252
|
+
const [player, balance] = await Promise.all([client.player(who), reads.getBalance({ address: who }).catch(() => null)]);
|
|
253
|
+
const settled = await Promise.all(player.shelf.slice(0, SHELF_READS).map(async (row) => ({ ...row, owed: await client.payoutOf(row.call, who).then(String, () => null) })));
|
|
254
|
+
return { address: who, balance: balance == null ? null : balance.toString(), positions: player.positions, settled, week: player.week, all: player.all };
|
|
255
|
+
},
|
|
256
|
+
// Reads from the chain, current to the block.
|
|
257
|
+
isCall: (address) => guarded(() => isCall(addressOf(address))),
|
|
258
|
+
pool: (address, side) => guarded(() => callRead(addressOf(address), "pool", [SIDE_CODE[sideOf(side)]])),
|
|
259
|
+
status: (address) => guarded(async () => STATUS[await callRead(addressOf(address), "status")]),
|
|
260
|
+
async odds(address) {
|
|
261
|
+
const [holds, breaks] = await Promise.all([client.pool(address, "holds"), client.pool(address, "breaks")]);
|
|
262
|
+
return { pools: { holds, breaks }, ...odds({ holds, breaks }) };
|
|
263
|
+
},
|
|
264
|
+
payoutOf: (address, who) => guarded(() => callRead(addressOf(address), "payoutOf", [walletOr(who)])),
|
|
265
|
+
stake: (address, side, who) => guarded(() => callRead(addressOf(address), "stake", [walletOr(who), SIDE_CODE[sideOf(side)]])),
|
|
266
|
+
balance: (who) => guarded(() => reads.getBalance({ address: walletOr(who) })),
|
|
267
|
+
/**
|
|
268
|
+
* Stakes `amount` wei on `side`. Refuses an amount over `maxStake` and an address that is not one of the factory's
|
|
269
|
+
* Calls before anything goes out; simulates first, so a bet the contract would refuse costs nothing.
|
|
270
|
+
*/
|
|
271
|
+
async bet(address, side, amount, { maxStake: cap = maxStake } = {}) {
|
|
272
|
+
const name = sideOf(side);
|
|
273
|
+
if (amount > cap)
|
|
274
|
+
throw new CallsError(`${formatEther(amount)} ETH is over the ${formatEther(cap)} ETH limit on one bet. Raise the limit to place it.`, "over_max_stake");
|
|
275
|
+
return guarded(async () => {
|
|
276
|
+
const call = await mustBeCall(address);
|
|
277
|
+
const receipt = await send({ address: call, abi: callAbi, functionName: "bet", args: [SIDE_CODE[name]], value: amount });
|
|
278
|
+
const placed = eventOf(receipt, callAbi, "Bet");
|
|
279
|
+
return { ...toTx(receipt, chainId), call, side: name, amount: amount.toString(), pools: placed ? { holds: placed.holdsPool.toString(), breaks: placed.breaksPool.toString() } : null };
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
/** Collects winnings or a refund once the Call is Final or Voided. The money only ever goes to the wallet that sends this. */
|
|
283
|
+
claim: (address) => guarded(async () => {
|
|
284
|
+
const call = await mustBeCall(address);
|
|
285
|
+
const receipt = await send({ address: call, abi: callAbi, functionName: "claim" });
|
|
286
|
+
const paid = eventOf(receipt, callAbi, "Claimed");
|
|
287
|
+
return { ...toTx(receipt, chainId), call, amount: paid?.amount.toString() ?? null };
|
|
288
|
+
}),
|
|
289
|
+
/** Pays the opener's bond and fee share. Anyone can send it; the money only ever goes to the opener. */
|
|
290
|
+
claimOpener: (address) => guarded(async () => {
|
|
291
|
+
const call = await mustBeCall(address);
|
|
292
|
+
const receipt = await send({ address: call, abi: callAbi, functionName: "claimOpener" });
|
|
293
|
+
const paid = eventOf(receipt, callAbi, "OpenerPaid");
|
|
294
|
+
return { ...toTx(receipt, chainId), call, opener: paid?.opener ?? null, amount: paid?.amount.toString() ?? null };
|
|
295
|
+
}),
|
|
296
|
+
/** Makes a Settled Call Final once its dispute window has passed. Anyone can send it. */
|
|
297
|
+
finalize: (address) => guarded(async () => {
|
|
298
|
+
const call = await mustBeCall(address);
|
|
299
|
+
return { ...toTx(await send({ address: call, abi: callAbi, functionName: "finalize" }), chainId), call };
|
|
300
|
+
}),
|
|
301
|
+
/** Disputes a settled result inside its window, posting the dispute bond (0.02 ETH). The court rules; the bond comes back if it flips the result. */
|
|
302
|
+
dispute: (address) => guarded(async () => {
|
|
303
|
+
const call = await mustBeCall(address);
|
|
304
|
+
const bond = await callRead(call, "DISPUTE_BOND");
|
|
305
|
+
return { ...toTx(await send({ address: call, abi: callAbi, functionName: "dispute", value: bond }), chainId), call, bond: bond.toString() };
|
|
306
|
+
}),
|
|
307
|
+
/**
|
|
308
|
+
* Opens a Call. Stores the sentence and spec with `POST /v1/calls` first, because Shipped settles from the stored
|
|
309
|
+
* spec, checks the API's hashes against its own, then sends `CallsFactory.open` with the bond.
|
|
310
|
+
*/
|
|
311
|
+
async open(input) {
|
|
312
|
+
const prepared = prepareOpen(input, chainId);
|
|
313
|
+
const bond = BigInt(prepared.bond);
|
|
314
|
+
const maxBond = input.maxBond ?? DEFAULT_MAX_BOND;
|
|
315
|
+
if (bond > maxBond)
|
|
316
|
+
throw new CallsError(`A ${formatEther(bond)} ETH bond is over the ${formatEther(maxBond)} ETH limit. Raise the limit to post it.`, "over_max_bond");
|
|
317
|
+
wallet();
|
|
318
|
+
return guarded(async () => {
|
|
319
|
+
await assertChain();
|
|
320
|
+
const stored = await request("/v1/calls", {
|
|
321
|
+
method: "POST",
|
|
322
|
+
headers: { "content-type": "application/json" },
|
|
323
|
+
body: JSON.stringify({
|
|
324
|
+
type: prepared.type,
|
|
325
|
+
callText: input.callText,
|
|
326
|
+
spec: prepared.spec,
|
|
327
|
+
...(prepared.handle ? { handle: prepared.handle } : {}),
|
|
328
|
+
...(input.postUrl ? { postUrl: input.postUrl } : {}),
|
|
329
|
+
...(input.postText ? { postText: input.postText } : {}),
|
|
330
|
+
...(prepared.type === "onchain" && input.deadline != null ? { deadline: input.deadline } : {}),
|
|
331
|
+
}),
|
|
332
|
+
});
|
|
333
|
+
const local = prepared.hashes;
|
|
334
|
+
if (stored.callType !== prepared.callType || stored.subject !== local.subject || stored.postRef !== local.postRef || stored.callTextHash !== local.callTextHash || stored.evidenceSpec !== local.evidenceSpec) {
|
|
335
|
+
throw new CallsError("The API answered other hashes than this Call hashes to, so nothing was sent. If it quotes a post, pass the author's handle.", "hash_mismatch");
|
|
336
|
+
}
|
|
337
|
+
const { closeAt, deadline } = await timesFor(prepared, stored, input);
|
|
338
|
+
const receipt = await send({
|
|
339
|
+
address: factory,
|
|
340
|
+
abi: [...factoryAbi, ...callAbi.filter((item) => item.type === "error")],
|
|
341
|
+
functionName: "open",
|
|
342
|
+
args: [local.subject, local.postRef, local.callTextHash, prepared.callType, BigInt(closeAt), BigInt(deadline), local.evidenceSpec, deedIdOf(prepared)],
|
|
343
|
+
value: bond,
|
|
344
|
+
});
|
|
345
|
+
const opened = eventOf(receipt, factoryAbi, "CallOpened");
|
|
346
|
+
if (!opened)
|
|
347
|
+
throw new CallsError("The transaction landed without a CallOpened event.", "no_event");
|
|
348
|
+
return { ...toTx(receipt, chainId), address: opened.call, callText: input.callText.trim(), closeAt, deadline, bond: prepared.bond, hashes: local };
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
/**
|
|
352
|
+
* Checks a settlement: fetches the evidence record the API serves, hashes its canonical JSON and compares that and
|
|
353
|
+
* the record's outcome with the chain.
|
|
354
|
+
*/
|
|
355
|
+
async verifySettlement(address) {
|
|
356
|
+
const call = addressOf(address);
|
|
357
|
+
return guarded(async () => {
|
|
358
|
+
const [statusCode, outcomeCode, evidenceHash] = await Promise.all([callRead(call, "status"), callRead(call, "outcome"), callRead(call, "evidenceHash")]);
|
|
359
|
+
const status = STATUS[statusCode];
|
|
360
|
+
const outcome = OUTCOME[outcomeCode] ?? null;
|
|
361
|
+
const onChain = evidenceHash === ZERO_HASH ? null : evidenceHash;
|
|
362
|
+
const base = { call, status, outcome, evidenceHash: onChain, record: null };
|
|
363
|
+
if (status === "open")
|
|
364
|
+
return { ...base, verified: null, note: "This Call has not been settled yet." };
|
|
365
|
+
if (status === "voided" && !onChain)
|
|
366
|
+
return { ...base, verified: null, note: "This Call was voided: every stake comes back, and no evidence decides it." };
|
|
367
|
+
if (!onChain)
|
|
368
|
+
return { ...base, verified: null, note: "A Call on a bond settles from the bond's final ruling, which the contract reads from Shipped's registry itself. There is no evidence hash to compare." };
|
|
369
|
+
const detail = await client.call(call);
|
|
370
|
+
if (!detail.evidenceHash)
|
|
371
|
+
return { ...base, verified: null, note: "The API has not reached this settlement yet: it follows the chain by up to a minute. Try again shortly." };
|
|
372
|
+
if (!detail.evidence || detail.evidence.hash.toLowerCase() !== onChain.toLowerCase())
|
|
373
|
+
return { ...base, verified: false, note: "The API serves no evidence record for the hash onchain." };
|
|
374
|
+
const res = await doFetch(`${origin}${detail.evidence.url}`, { signal: AbortSignal.timeout(20_000) });
|
|
375
|
+
if (!res.ok)
|
|
376
|
+
throw new CallsError("The API did not serve the evidence record.", `api_${res.status}`, res.status);
|
|
377
|
+
const parsed = (await res.json());
|
|
378
|
+
const redacted = "redacted" in parsed;
|
|
379
|
+
const hash = redacted ? null : hashJson(parsed);
|
|
380
|
+
const facts = { url: `${origin}${detail.evidence.url}`, hash, outcome: parsed.outcome, fetchedAt: parsed.fetchedAt, source: parsed.source, redacted };
|
|
381
|
+
if (redacted)
|
|
382
|
+
return { ...base, record: facts, verified: null, note: "A post in this record is no longer shown on X, so its text is left out and this copy cannot hash to the evidence hash onchain." };
|
|
383
|
+
const sameHash = hash.toLowerCase() === onChain.toLowerCase();
|
|
384
|
+
const sameOutcome = String(parsed.outcome).toLowerCase() === outcome;
|
|
385
|
+
const verified = sameHash && sameOutcome;
|
|
386
|
+
return { ...base, record: facts, verified, note: verified ? "The record hashes to the evidence hash onchain and names the same outcome." : sameHash ? "The record hashes to the evidence hash onchain, but names another outcome than the chain." : "The record does not hash to the evidence hash onchain." };
|
|
387
|
+
});
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
async function timesFor(prepared, stored, input) {
|
|
391
|
+
if (stored.suggested)
|
|
392
|
+
return { deadline: stored.suggested.deadline, closeAt: Math.min(input.closeAt ?? stored.suggested.closeAt, stored.suggested.closeAt) };
|
|
393
|
+
const [, status, , bondDeadline] = await read(DEEDS, deedsCoreAbi, "core", [deedIdOf(prepared)]);
|
|
394
|
+
if (status !== BOND_OPEN)
|
|
395
|
+
throw new CallsError("Calls can only be opened on an open Shipped bond.", "BadDeed");
|
|
396
|
+
const deadline = input.deadline ?? Number(bondDeadline);
|
|
397
|
+
return { deadline, closeAt: input.closeAt ?? deadline };
|
|
398
|
+
}
|
|
399
|
+
return client;
|
|
400
|
+
}
|
|
401
|
+
const deedIdOf = (prepared) => (prepared.type === "deed" ? BigInt(prepared.spec.deedId) : 0n);
|
|
402
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAA4F,MAAM,MAAM,CAAC;AACpK,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,QA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.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Every failure the SDK raises: one sentence to show, and a code to branch on. A revert's code is its error name. */
|
|
2
|
+
export declare class CallsError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly status?: number | undefined;
|
|
5
|
+
name: string;
|
|
6
|
+
constructor(message: string, code: string, status?: number | undefined);
|
|
7
|
+
}
|
|
8
|
+
export declare const NOT_ENOUGH_ETH = "Not enough ETH to cover this and gas.";
|
|
9
|
+
/** One sentence for a failed read or write. RPC URLs can carry keys, so nothing from the transport is passed on. */
|
|
10
|
+
export declare function describe(error: unknown): CallsError;
|