@theoo/sdk 0.4.2 → 0.4.4
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/abi.d.ts +28 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +86 -0
- package/dist/abi.js.map +1 -0
- package/dist/client.d.ts +155 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +153 -25
- package/dist/client.js.map +1 -1
- package/dist/eip712.d.ts +17 -0
- package/dist/eip712.d.ts.map +1 -0
- package/dist/eip712.js +127 -0
- package/dist/eip712.js.map +1 -0
- package/dist/hash.d.ts +27 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +249 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/solana-vault.d.ts +140 -0
- package/dist/solana-vault.d.ts.map +1 -0
- package/dist/solana-vault.js +242 -0
- package/dist/solana-vault.js.map +1 -0
- package/dist/types.d.ts +275 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vault.d.ts +92 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +165 -0
- package/dist/vault.js.map +1 -0
- package/dist/verify.d.ts +82 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +669 -0
- package/dist/verify.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multisig vaults on Solana, client side: the encoding `theoo-vault` uses,
|
|
3
|
+
* and the addresses it derives, worked out here rather than taken from the
|
|
4
|
+
* server.
|
|
5
|
+
*
|
|
6
|
+
* As on the EVM side (`vault.ts`) the point is the approval. An owner
|
|
7
|
+
* approves proposal N by naming the hash of its instructions — sha256 of
|
|
8
|
+
* their canonical encoding — and that hash is computed here, from the
|
|
9
|
+
* instructions this app is about to show. If anything between the chain and
|
|
10
|
+
* the screen misrepresented the proposal, the vault refuses the approval
|
|
11
|
+
* instead of counting it. See `solana/programs/theoo-vault`.
|
|
12
|
+
*
|
|
13
|
+
* A vault has two addresses. Its **signer** (`address`) holds the SOL and is
|
|
14
|
+
* what its tokens answer to: show that one, and send to it. Its **config**
|
|
15
|
+
* holds the settings and is what instructions name; lamports sent to it are
|
|
16
|
+
* stuck there.
|
|
17
|
+
*/
|
|
18
|
+
import { base58Encode, base64Decode, base64Encode, bytesToHex, concatBytes, equalBytes, hexToBytes, pubkeyBytes, sha256, utf8 } from "./hash.js";
|
|
19
|
+
/** The vault program, at one id on every cluster that has it. */
|
|
20
|
+
export const SOLANA_VAULT_PROGRAM = "FiDvcBjYHp2gi135wSBhe4eNGoFafNkU3mn8AvYrFmzh";
|
|
21
|
+
/** The system program. */
|
|
22
|
+
export const SYSTEM_PROGRAM = "11111111111111111111111111111111";
|
|
23
|
+
/**
|
|
24
|
+
* The instructions sysvar. A member's proposal or vote names it last: it is
|
|
25
|
+
* how the vault sees that the member's seat is being used by their passkey,
|
|
26
|
+
* at the top of the transaction, and not by a session key.
|
|
27
|
+
*/
|
|
28
|
+
export const INSTRUCTIONS_SYSVAR = "Sysvar1nstructions1111111111111111111111111";
|
|
29
|
+
export const SOLANA_VAULT_LIMITS = { owners: 20, instructions: 8, accounts: 32, data: 1024, delay: 30 * 24 * 60 * 60 };
|
|
30
|
+
/** The program's instruction tags. */
|
|
31
|
+
export const SOLANA_VAULT_TAG = {
|
|
32
|
+
create: 0,
|
|
33
|
+
propose: 1,
|
|
34
|
+
approve: 2,
|
|
35
|
+
revoke: 3,
|
|
36
|
+
reject: 4,
|
|
37
|
+
cancel: 5,
|
|
38
|
+
execute: 6,
|
|
39
|
+
close: 7,
|
|
40
|
+
addOwner: 16,
|
|
41
|
+
removeOwner: 17,
|
|
42
|
+
replaceOwner: 18,
|
|
43
|
+
setThreshold: 19,
|
|
44
|
+
setDelay: 20,
|
|
45
|
+
};
|
|
46
|
+
const u16 = (n) => new Uint8Array([n & 0xff, (n >> 8) & 0xff]);
|
|
47
|
+
export function u64le(n) {
|
|
48
|
+
const out = new Uint8Array(8);
|
|
49
|
+
let v = BigInt(n);
|
|
50
|
+
for (let i = 0; i < 8; i++) {
|
|
51
|
+
out[i] = Number(v & 0xffn);
|
|
52
|
+
v >>= 8n;
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The canonical encoding of a proposal's instructions, as the program stores
|
|
58
|
+
* and hashes it: a count, then per instruction its program, its accounts
|
|
59
|
+
* (key, signer, writable) and its data with a two-byte length.
|
|
60
|
+
*/
|
|
61
|
+
export function encodeSolanaCalls(calls) {
|
|
62
|
+
if (calls.length > 255)
|
|
63
|
+
throw new Error("too many instructions to encode");
|
|
64
|
+
const parts = [new Uint8Array([calls.length])];
|
|
65
|
+
for (const c of calls) {
|
|
66
|
+
if (c.accounts.length > 255)
|
|
67
|
+
throw new Error("too many accounts to encode");
|
|
68
|
+
parts.push(pubkeyBytes(c.programId), new Uint8Array([c.accounts.length]));
|
|
69
|
+
for (const m of c.accounts)
|
|
70
|
+
parts.push(pubkeyBytes(m.pubkey), new Uint8Array([m.isSigner ? 1 : 0, m.isWritable ? 1 : 0]));
|
|
71
|
+
const data = base64Decode(c.data);
|
|
72
|
+
if (data.length > 0xffff)
|
|
73
|
+
throw new Error("instruction data too long to encode");
|
|
74
|
+
parts.push(u16(data.length), data);
|
|
75
|
+
}
|
|
76
|
+
return concatBytes(...parts);
|
|
77
|
+
}
|
|
78
|
+
/** What an approval of these instructions must name: sha256 of their encoding, hex. */
|
|
79
|
+
export function solanaCallsHash(calls) {
|
|
80
|
+
return bytesToHex(sha256(encodeSolanaCalls(calls)));
|
|
81
|
+
}
|
|
82
|
+
/* ── addresses ─────────────────────────────────────────────────────────── */
|
|
83
|
+
// ed25519: an address is "off the curve" when it is no point's encoding.
|
|
84
|
+
const P = (1n << 255n) - 19n;
|
|
85
|
+
const D = mod(-121665n * inv(121666n));
|
|
86
|
+
function mod(a) {
|
|
87
|
+
const r = a % P;
|
|
88
|
+
return r < 0n ? r + P : r;
|
|
89
|
+
}
|
|
90
|
+
function pow(b, e) {
|
|
91
|
+
let r = 1n;
|
|
92
|
+
b = mod(b);
|
|
93
|
+
while (e > 0n) {
|
|
94
|
+
if (e & 1n)
|
|
95
|
+
r = (r * b) % P;
|
|
96
|
+
b = (b * b) % P;
|
|
97
|
+
e >>= 1n;
|
|
98
|
+
}
|
|
99
|
+
return r;
|
|
100
|
+
}
|
|
101
|
+
function inv(a) {
|
|
102
|
+
return pow(a, P - 2n);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Whether 32 bytes decode to a point on ed25519, as the runtime decides it:
|
|
106
|
+
* y is the low 255 bits, little-endian; it is a point when x² = (y² − 1) /
|
|
107
|
+
* (d·y² + 1) has a root. A program-derived address must not be one.
|
|
108
|
+
*/
|
|
109
|
+
export function isOnCurve(b) {
|
|
110
|
+
let y = 0n;
|
|
111
|
+
for (let i = 31; i >= 0; i--)
|
|
112
|
+
y = (y << 8n) | BigInt(b[i]);
|
|
113
|
+
y = mod(y & ((1n << 255n) - 1n));
|
|
114
|
+
const y2 = (y * y) % P;
|
|
115
|
+
const x2 = mod((y2 - 1n) * inv(mod(D * y2 + 1n)));
|
|
116
|
+
// Euler's criterion: zero, or a square.
|
|
117
|
+
return x2 === 0n || pow(x2, (P - 1n) / 2n) === 1n;
|
|
118
|
+
}
|
|
119
|
+
/** `Pubkey::find_program_address`: the address and its bump. */
|
|
120
|
+
export function findProgramAddress(seeds, programId) {
|
|
121
|
+
const program = pubkeyBytes(programId);
|
|
122
|
+
for (let bump = 255; bump >= 0; bump--) {
|
|
123
|
+
const h = sha256(concatBytes(...seeds, new Uint8Array([bump]), program, utf8("ProgramDerivedAddress")));
|
|
124
|
+
if (!isOnCurve(h))
|
|
125
|
+
return [base58Encode(h), bump];
|
|
126
|
+
}
|
|
127
|
+
throw new Error("no program address for these seeds");
|
|
128
|
+
}
|
|
129
|
+
/** `sha256(owners ‖ threshold ‖ delay ‖ salt)`: what a vault's address commits to. */
|
|
130
|
+
function configSeed(owners, threshold, delay, salt) {
|
|
131
|
+
const s = hexToBytes(salt);
|
|
132
|
+
if (s.length !== 32)
|
|
133
|
+
throw new Error("salt must be 32 bytes");
|
|
134
|
+
return sha256(concatBytes(...owners.map(pubkeyBytes), new Uint8Array([threshold]), u64le(delay), s));
|
|
135
|
+
}
|
|
136
|
+
/** Where a vault's money is: its signer, derived from its config. */
|
|
137
|
+
export function solanaVaultSigner(config, program = SOLANA_VAULT_PROGRAM) {
|
|
138
|
+
return findProgramAddress([utf8("vault_signer"), pubkeyBytes(config)], program)[0];
|
|
139
|
+
}
|
|
140
|
+
/** A proposal's account. */
|
|
141
|
+
export function solanaProposalAddress(config, id, program = SOLANA_VAULT_PROGRAM) {
|
|
142
|
+
return findProgramAddress([utf8("proposal"), pubkeyBytes(config), u64le(id)], program)[0];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Where a vault with these settings is, on every cluster with the program:
|
|
146
|
+
* its `config`, and its `address` — the signer, where it holds its money.
|
|
147
|
+
* The address commits to all of them, so it can be shared, and funded,
|
|
148
|
+
* before the vault is created.
|
|
149
|
+
*/
|
|
150
|
+
export function predictSolanaVault(owners, threshold, delay, salt, program = SOLANA_VAULT_PROGRAM) {
|
|
151
|
+
const [config] = findProgramAddress([utf8("vault"), configSeed(owners, threshold, delay, salt)], program);
|
|
152
|
+
return { config, address: solanaVaultSigner(config, program) };
|
|
153
|
+
}
|
|
154
|
+
/** Whether `key` is the vault `vault` names, by its config or by its signer. */
|
|
155
|
+
export function isSolanaVault(config, vault, program = SOLANA_VAULT_PROGRAM) {
|
|
156
|
+
const want = pubkeyBytes(vault);
|
|
157
|
+
return equalBytes(config, want) || equalBytes(pubkeyBytes(solanaVaultSigner(base58Encode(config), program)), want);
|
|
158
|
+
}
|
|
159
|
+
/* ── proposals ─────────────────────────────────────────────────────────── */
|
|
160
|
+
const settings = (config, signer, data) => [
|
|
161
|
+
{
|
|
162
|
+
programId: SOLANA_VAULT_PROGRAM,
|
|
163
|
+
accounts: [
|
|
164
|
+
{ pubkey: config, isSigner: false, isWritable: true },
|
|
165
|
+
{ pubkey: signer, isSigner: true, isWritable: false },
|
|
166
|
+
],
|
|
167
|
+
data: base64Encode(data),
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
/**
|
|
171
|
+
* Instructions for the common proposals. `vault` is the vault as the server
|
|
172
|
+
* shows it: what it pays from is its `address`, the signer, which the
|
|
173
|
+
* proposal signs as; settings changes name its `config`.
|
|
174
|
+
*/
|
|
175
|
+
export const solanaVaultCalls = {
|
|
176
|
+
/** Send lamports from the vault. */
|
|
177
|
+
send: (vault, to, lamports) => [
|
|
178
|
+
{
|
|
179
|
+
programId: SYSTEM_PROGRAM,
|
|
180
|
+
accounts: [
|
|
181
|
+
{ pubkey: vault.address, isSigner: true, isWritable: true },
|
|
182
|
+
{ pubkey: to, isSigner: false, isWritable: true },
|
|
183
|
+
],
|
|
184
|
+
data: base64Encode(concatBytes(new Uint8Array([2, 0, 0, 0]), u64le(BigInt(lamports)))),
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
addOwner: (vault, owner, threshold) => settings(vault.config, vault.address, concatBytes(new Uint8Array([SOLANA_VAULT_TAG.addOwner]), pubkeyBytes(owner), new Uint8Array([threshold]))),
|
|
188
|
+
removeOwner: (vault, owner, threshold) => settings(vault.config, vault.address, concatBytes(new Uint8Array([SOLANA_VAULT_TAG.removeOwner]), pubkeyBytes(owner), new Uint8Array([threshold]))),
|
|
189
|
+
replaceOwner: (vault, owner, next) => settings(vault.config, vault.address, concatBytes(new Uint8Array([SOLANA_VAULT_TAG.replaceOwner]), pubkeyBytes(owner), pubkeyBytes(next))),
|
|
190
|
+
setThreshold: (vault, threshold) => settings(vault.config, vault.address, new Uint8Array([SOLANA_VAULT_TAG.setThreshold, threshold])),
|
|
191
|
+
setDelay: (vault, seconds) => settings(vault.config, vault.address, concatBytes(new Uint8Array([SOLANA_VAULT_TAG.setDelay]), u64le(seconds))),
|
|
192
|
+
};
|
|
193
|
+
const le = (b, at, n) => {
|
|
194
|
+
let v = 0n;
|
|
195
|
+
for (let i = n - 1; i >= 0; i--)
|
|
196
|
+
v = (v << 8n) | BigInt(b[at + i]);
|
|
197
|
+
return v;
|
|
198
|
+
};
|
|
199
|
+
/** Turn one of a proposal's instructions into what it does, for the vault `vault`. */
|
|
200
|
+
export function describeSolanaCall(vault, c) {
|
|
201
|
+
const d = base64Decode(c.data);
|
|
202
|
+
const raw = { kind: "call", programId: c.programId, accounts: c.accounts.length, dataBytes: d.length };
|
|
203
|
+
const [a0, a1] = c.accounts;
|
|
204
|
+
if (c.programId === SYSTEM_PROGRAM && d.length === 12 && le(d, 0, 4) === 2n && c.accounts.length === 2 && a0.pubkey === vault.address) {
|
|
205
|
+
return { kind: "send", to: a1.pubkey, lamports: le(d, 4, 8) };
|
|
206
|
+
}
|
|
207
|
+
if (c.programId === SOLANA_VAULT_PROGRAM && a0 && a0.pubkey !== vault.config) {
|
|
208
|
+
const votes = { 1: "propose", 2: "approve", 3: "revoke", 4: "reject", 5: "cancel" };
|
|
209
|
+
const vote = votes[d[0]];
|
|
210
|
+
if (vote === "propose")
|
|
211
|
+
return { kind: "vote_in", vault: a0.pubkey, vote, proposal: null };
|
|
212
|
+
if (vote && d.length === (vote === "approve" ? 41 : 9))
|
|
213
|
+
return { kind: "vote_in", vault: a0.pubkey, vote, proposal: Number(le(d, 1, 8)) };
|
|
214
|
+
}
|
|
215
|
+
if (c.programId === SOLANA_VAULT_PROGRAM && a0?.pubkey === vault.config) {
|
|
216
|
+
const key = (at) => base58Encode(d.slice(at, at + 32));
|
|
217
|
+
switch (d[0]) {
|
|
218
|
+
case SOLANA_VAULT_TAG.addOwner:
|
|
219
|
+
if (d.length === 34)
|
|
220
|
+
return { kind: "add_owner", owner: key(1), threshold: d[33] };
|
|
221
|
+
break;
|
|
222
|
+
case SOLANA_VAULT_TAG.removeOwner:
|
|
223
|
+
if (d.length === 34)
|
|
224
|
+
return { kind: "remove_owner", owner: key(1), threshold: d[33] };
|
|
225
|
+
break;
|
|
226
|
+
case SOLANA_VAULT_TAG.replaceOwner:
|
|
227
|
+
if (d.length === 65)
|
|
228
|
+
return { kind: "replace_owner", owner: key(1), with: key(33) };
|
|
229
|
+
break;
|
|
230
|
+
case SOLANA_VAULT_TAG.setThreshold:
|
|
231
|
+
if (d.length === 2)
|
|
232
|
+
return { kind: "threshold", threshold: d[1] };
|
|
233
|
+
break;
|
|
234
|
+
case SOLANA_VAULT_TAG.setDelay:
|
|
235
|
+
if (d.length === 9)
|
|
236
|
+
return { kind: "delay", seconds: Number(le(d, 1, 8)) };
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return raw;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=solana-vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana-vault.js","sourceRoot":"","sources":["../src/solana-vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjJ,iEAAiE;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,8CAA8C,CAAC;AAEnF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,6CAA6C,CAAC;AAEjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAA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KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAE,EAAE,CAAC;gBACvF,MAAM;YACR,KAAK,gBAAgB,CAAC,YAAY;gBAChC,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE;oBAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACpF,MAAM;YACR,KAAK,gBAAgB,CAAC,YAAY;gBAChC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC;gBACnE,MAAM;YACR,KAAK,gBAAgB,CAAC,QAAQ;gBAC5B,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3E,MAAM;QACV,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -350,6 +350,14 @@ export type OperationKind = {
|
|
|
350
350
|
} | {
|
|
351
351
|
kind: "upgrade_account";
|
|
352
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Up to 16 calls in order, all or none, under one passkey signature: an
|
|
355
|
+
* approval and the call that spends it belong together. ERC-4337 only.
|
|
356
|
+
*/
|
|
357
|
+
| {
|
|
358
|
+
kind: "batch";
|
|
359
|
+
calls: ChainCall[];
|
|
360
|
+
}
|
|
353
361
|
/** A cross-chain swap LI.FI routed and Theoo checked (`me.money.quoteBridge`). */
|
|
354
362
|
| {
|
|
355
363
|
kind: "bridge";
|
|
@@ -375,7 +383,117 @@ export type OperationKind = {
|
|
|
375
383
|
| {
|
|
376
384
|
kind: "espees_sell_dispute";
|
|
377
385
|
order: string;
|
|
386
|
+
}
|
|
387
|
+
/** Make a multisig. The user's own account must be one of its owners. */
|
|
388
|
+
| {
|
|
389
|
+
kind: "vault_create";
|
|
390
|
+
vault: VaultSpec;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* As an owner, put calls up for approval; proposing approves. With `run`
|
|
394
|
+
* (the default), a proposal this approval alone makes ready runs at once.
|
|
395
|
+
*/
|
|
396
|
+
| {
|
|
397
|
+
kind: "vault_propose";
|
|
398
|
+
vault: string;
|
|
399
|
+
calls: VaultCall[];
|
|
400
|
+
run?: boolean;
|
|
401
|
+
}
|
|
402
|
+
/** Approve proposal `proposal`, naming the hash of the calls that were shown. */
|
|
403
|
+
| {
|
|
404
|
+
kind: "vault_approve";
|
|
405
|
+
vault: string;
|
|
406
|
+
proposal: number;
|
|
407
|
+
callsHash: string;
|
|
408
|
+
run?: boolean;
|
|
409
|
+
} | {
|
|
410
|
+
kind: "vault_revoke";
|
|
411
|
+
vault: string;
|
|
412
|
+
proposal: number;
|
|
413
|
+
} | {
|
|
414
|
+
kind: "vault_reject";
|
|
415
|
+
vault: string;
|
|
416
|
+
proposal: number;
|
|
417
|
+
} | {
|
|
418
|
+
kind: "vault_cancel";
|
|
419
|
+
vault: string;
|
|
420
|
+
proposal: number;
|
|
421
|
+
} | {
|
|
422
|
+
kind: "vault_execute";
|
|
423
|
+
vault: string;
|
|
424
|
+
proposal: number;
|
|
378
425
|
};
|
|
426
|
+
/**
|
|
427
|
+
* One call a multisig proposal makes. `gas`, when set, is exactly the gas the
|
|
428
|
+
* call gets when it runs — part of what is approved, so whoever runs it can't
|
|
429
|
+
* starve a call into a contract that tolerates failing sub-calls (a multicall
|
|
430
|
+
* allowing failures, a router with revertible steps). Leave it out for a
|
|
431
|
+
* transfer, or any call that reverts as a whole when it runs out.
|
|
432
|
+
*/
|
|
433
|
+
export interface VaultCall {
|
|
434
|
+
to: string;
|
|
435
|
+
value?: string | number | bigint;
|
|
436
|
+
data?: string;
|
|
437
|
+
gas?: number;
|
|
438
|
+
}
|
|
439
|
+
/** A multisig to make. */
|
|
440
|
+
export interface VaultSpec {
|
|
441
|
+
/** For the people in it; kept by Theoo, not on chain. */
|
|
442
|
+
name?: string;
|
|
443
|
+
/** Addresses, in order — hex on EVM, base58 on Solana: the order is part of the vault's address. */
|
|
444
|
+
owners: string[];
|
|
445
|
+
/** Names for owners, by address, shown to the vault's members. */
|
|
446
|
+
labels?: Record<string, string>;
|
|
447
|
+
/** How many owners must approve, 1 to `owners.length`. */
|
|
448
|
+
threshold: number;
|
|
449
|
+
/** Seconds an approved proposal waits before it can run, up to 30 days. */
|
|
450
|
+
delay?: number;
|
|
451
|
+
/** 32 bytes of hex. Omit for a new vault; give the same one to make the same vault on another chain. */
|
|
452
|
+
salt?: string;
|
|
453
|
+
}
|
|
454
|
+
/** Where a proposal stands. The last five are final. */
|
|
455
|
+
export type VaultProposalState = "open" | "waiting" | "ready" | "executed" | "cancelled" | "rejected" | "expired" | "stale" | "missing";
|
|
456
|
+
export interface VaultSummary {
|
|
457
|
+
chain: number;
|
|
458
|
+
address: string;
|
|
459
|
+
name: string | null;
|
|
460
|
+
/** False until the operation that makes it lands. */
|
|
461
|
+
deployed: boolean;
|
|
462
|
+
owners: string[];
|
|
463
|
+
threshold: number;
|
|
464
|
+
/** Seconds. */
|
|
465
|
+
delay: number;
|
|
466
|
+
/** Native balance, decimal wei. */
|
|
467
|
+
balance: string;
|
|
468
|
+
proposalCount: number;
|
|
469
|
+
}
|
|
470
|
+
export interface VaultProposal {
|
|
471
|
+
id: number;
|
|
472
|
+
state: VaultProposalState;
|
|
473
|
+
proposer: string;
|
|
474
|
+
createdAt: number;
|
|
475
|
+
expiresAt: number;
|
|
476
|
+
/** When it may run; 0 until enough owners approve. */
|
|
477
|
+
readyAt: number;
|
|
478
|
+
/** What the chain says the calls hash to. An approval re-computes it from `calls`. */
|
|
479
|
+
callsHash: string;
|
|
480
|
+
approvedBy: string[];
|
|
481
|
+
rejectedBy: string[];
|
|
482
|
+
calls: VaultCall[];
|
|
483
|
+
youApproved: boolean;
|
|
484
|
+
youRejected: boolean;
|
|
485
|
+
}
|
|
486
|
+
export interface VaultDetail extends VaultSummary {
|
|
487
|
+
/** The user's own address on this chain. */
|
|
488
|
+
you: string;
|
|
489
|
+
isOwner: boolean;
|
|
490
|
+
labels: Record<string, string>;
|
|
491
|
+
epoch: number;
|
|
492
|
+
/** Its creation settings, to make the same vault on another chain. */
|
|
493
|
+
spec: Partial<VaultSpec>;
|
|
494
|
+
/** Newest first. */
|
|
495
|
+
proposals: VaultProposal[];
|
|
496
|
+
}
|
|
379
497
|
/** A token swaps may use on a chain, read from its own contract. */
|
|
380
498
|
export interface MoneyToken {
|
|
381
499
|
chain: number;
|
|
@@ -498,6 +616,12 @@ export interface PreparedOperation {
|
|
|
498
616
|
sponsored: boolean;
|
|
499
617
|
deploys: boolean;
|
|
500
618
|
session?: string | null;
|
|
619
|
+
/**
|
|
620
|
+
* What `challenge` is the hash of, so the SDK can rebuild it before the
|
|
621
|
+
* passkey signs: `{ type: "userOp", entryPoint, userOp }` or
|
|
622
|
+
* `{ type: "legacy", nonce, call }`.
|
|
623
|
+
*/
|
|
624
|
+
payload?: unknown;
|
|
501
625
|
}
|
|
502
626
|
export type OperationState = "prepared" | "submitted" | "included" | "failed" | "expired";
|
|
503
627
|
export interface OperationStatus {
|
|
@@ -609,7 +733,110 @@ export type SolanaAction = {
|
|
|
609
733
|
| {
|
|
610
734
|
kind: "batch";
|
|
611
735
|
actions: SolanaAction[];
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Make a multisig vault. Owners are base58, and the user's own account
|
|
739
|
+
* must be one of them. Theoo pays the rent and holds no seat.
|
|
740
|
+
*
|
|
741
|
+
* This and the vault actions below are written by Theoo's server from
|
|
742
|
+
* these fields, and checked here before the passkey signs them.
|
|
743
|
+
*/
|
|
744
|
+
| {
|
|
745
|
+
kind: "vault_create";
|
|
746
|
+
vault: VaultSpec;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* As an owner, put instructions up for approval; proposing approves.
|
|
750
|
+
* `vault` is the vault's `config` (its money address is taken too). Each
|
|
751
|
+
* instruction may name the vault's signer — its `address` — as a signer,
|
|
752
|
+
* and nobody else.
|
|
753
|
+
*/
|
|
754
|
+
| {
|
|
755
|
+
kind: "vault_propose";
|
|
756
|
+
vault: string;
|
|
757
|
+
calls: SolanaInstruction[];
|
|
758
|
+
}
|
|
759
|
+
/** Approve proposal `proposal`, naming the hash of the instructions that were shown. */
|
|
760
|
+
| {
|
|
761
|
+
kind: "vault_approve";
|
|
762
|
+
vault: string;
|
|
763
|
+
proposal: number;
|
|
764
|
+
callsHash: string;
|
|
765
|
+
} | {
|
|
766
|
+
kind: "vault_revoke";
|
|
767
|
+
vault: string;
|
|
768
|
+
proposal: number;
|
|
769
|
+
} | {
|
|
770
|
+
kind: "vault_reject";
|
|
771
|
+
vault: string;
|
|
772
|
+
proposal: number;
|
|
773
|
+
} | {
|
|
774
|
+
kind: "vault_cancel";
|
|
775
|
+
vault: string;
|
|
776
|
+
proposal: number;
|
|
612
777
|
};
|
|
778
|
+
/** One Solana instruction, as a vault proposal carries it. `data` is base64. */
|
|
779
|
+
export interface SolanaInstruction {
|
|
780
|
+
programId: string;
|
|
781
|
+
accounts: SolanaAccountMeta[];
|
|
782
|
+
data: string;
|
|
783
|
+
}
|
|
784
|
+
/** A Solana multisig. */
|
|
785
|
+
export interface SolanaVaultSummary {
|
|
786
|
+
cluster: string;
|
|
787
|
+
/** Where it holds its SOL and what its tokens answer to: the address to show, and to send to. */
|
|
788
|
+
address: string;
|
|
789
|
+
/** Its settings account. Instructions name it; never send to it. */
|
|
790
|
+
config: string;
|
|
791
|
+
name: string | null;
|
|
792
|
+
/** False until the operation that makes it lands. */
|
|
793
|
+
deployed: boolean;
|
|
794
|
+
owners: string[];
|
|
795
|
+
threshold: number;
|
|
796
|
+
/** Seconds. */
|
|
797
|
+
delay: number;
|
|
798
|
+
/** Lamports at `address`, decimal. */
|
|
799
|
+
balance: string;
|
|
800
|
+
proposalCount: number;
|
|
801
|
+
}
|
|
802
|
+
export interface SolanaVaultProposal {
|
|
803
|
+
id: number;
|
|
804
|
+
/** The proposal's own account. */
|
|
805
|
+
account: string;
|
|
806
|
+
/** For a `closed` proposal: the final state Theoo saw, or `missing`. */
|
|
807
|
+
state: VaultProposalState;
|
|
808
|
+
proposer: string;
|
|
809
|
+
createdAt: number;
|
|
810
|
+
expiresAt: number;
|
|
811
|
+
/** When it may run: once enough current approvals have each waited the whole delay. 0 until then. */
|
|
812
|
+
readyAt: number;
|
|
813
|
+
/** What the chain says the instructions hash to. An approval re-computes it from `calls`. */
|
|
814
|
+
callsHash: string;
|
|
815
|
+
approvedBy: string[];
|
|
816
|
+
/** When each of `approvedBy` approved, in the same order. */
|
|
817
|
+
approvalTimes: number[];
|
|
818
|
+
rejectedBy: string[];
|
|
819
|
+
calls: SolanaInstruction[];
|
|
820
|
+
/** Who paid its rent, and gets it back once it is closed. */
|
|
821
|
+
payer: string;
|
|
822
|
+
/** Its account is gone — closed once final — and this is what Theoo last saw of it. */
|
|
823
|
+
closed: boolean;
|
|
824
|
+
youApproved: boolean;
|
|
825
|
+
youRejected: boolean;
|
|
826
|
+
}
|
|
827
|
+
export interface SolanaVaultDetail extends SolanaVaultSummary {
|
|
828
|
+
/** The user's own account on this cluster. */
|
|
829
|
+
you: string;
|
|
830
|
+
isOwner: boolean;
|
|
831
|
+
labels: Record<string, string>;
|
|
832
|
+
epoch: number;
|
|
833
|
+
/** Its creation settings, and its `config`. */
|
|
834
|
+
spec: Partial<VaultSpec> & {
|
|
835
|
+
config?: string;
|
|
836
|
+
};
|
|
837
|
+
/** Newest first. */
|
|
838
|
+
proposals: SolanaVaultProposal[];
|
|
839
|
+
}
|
|
613
840
|
/**
|
|
614
841
|
* A Solana session key. The same bounded delegate as on the EVM side, minus
|
|
615
842
|
* the selector: a Solana instruction has no four-byte function id, so the
|
|
@@ -675,12 +902,16 @@ export interface PreparedSolanaOperation {
|
|
|
675
902
|
initializes: boolean;
|
|
676
903
|
/** For `grant_session` and `revoke_session`: the key concerned. */
|
|
677
904
|
session?: string | null;
|
|
905
|
+
/** The program, base58: with `account`, `nonce` and `action`, what `challenge` is the hash of. */
|
|
906
|
+
programId?: string;
|
|
907
|
+
/** The action as the program decodes it, hex. */
|
|
908
|
+
action?: string;
|
|
678
909
|
}
|
|
679
910
|
export interface SolanaOperationStatus {
|
|
680
911
|
id: string;
|
|
681
912
|
cluster: string;
|
|
682
913
|
account: string;
|
|
683
|
-
kind: "transfer" | "invoke" | "enable_recovery" | "cancel_recovery" | "grant_session" | "renew_session" | "revoke_session" | "session_call";
|
|
914
|
+
kind: "transfer" | "invoke" | "enable_recovery" | "cancel_recovery" | "grant_session" | "renew_session" | "revoke_session" | "session_call" | "vault_create" | "vault_propose" | "vault_approve" | "vault_revoke" | "vault_reject" | "vault_cancel" | "vault_execute";
|
|
684
915
|
/** The session key this operation granted, revoked or acted under. */
|
|
685
916
|
session?: string | null;
|
|
686
917
|
summary: Record<string, unknown>;
|
|
@@ -759,6 +990,49 @@ export interface BridgeQuote {
|
|
|
759
990
|
summary: string;
|
|
760
991
|
warning: string | null;
|
|
761
992
|
}
|
|
993
|
+
/** Where a user stands with Bachs: their own account there, its naira number, and where money goes. */
|
|
994
|
+
export interface BachsStatus {
|
|
995
|
+
/** Bachs is configured on this server. */
|
|
996
|
+
available: boolean;
|
|
997
|
+
buyEnabled: boolean;
|
|
998
|
+
cashoutEnabled: boolean;
|
|
999
|
+
/** The user has an account at Bachs. */
|
|
1000
|
+
linked: boolean;
|
|
1001
|
+
/** Bachs has approved naira deposits for it. */
|
|
1002
|
+
depositsActive: boolean;
|
|
1003
|
+
payoutsActive: boolean;
|
|
1004
|
+
/** Where to send naira: a permanent account number, the user's own. */
|
|
1005
|
+
nairaAccount: {
|
|
1006
|
+
accountNumber: string;
|
|
1007
|
+
bankName: string;
|
|
1008
|
+
} | null;
|
|
1009
|
+
/** What naira arrives as, and where: always this user's own Theoo account. */
|
|
1010
|
+
receive: {
|
|
1011
|
+
chain: number;
|
|
1012
|
+
asset: string;
|
|
1013
|
+
code: string;
|
|
1014
|
+
address: string;
|
|
1015
|
+
} | null;
|
|
1016
|
+
/** Where a cash-out lands, as Bachs named it from the bank. */
|
|
1017
|
+
bank: {
|
|
1018
|
+
bankName: string;
|
|
1019
|
+
accountName: string;
|
|
1020
|
+
last4: string;
|
|
1021
|
+
} | null;
|
|
1022
|
+
receiveOptions: Array<{
|
|
1023
|
+
chain: number;
|
|
1024
|
+
asset: string;
|
|
1025
|
+
}>;
|
|
1026
|
+
/** False until Bachs names a crypto deposit address through its API. */
|
|
1027
|
+
cashoutPayInReady: boolean;
|
|
1028
|
+
}
|
|
1029
|
+
export interface BachsOnboardRequest {
|
|
1030
|
+
email: string;
|
|
1031
|
+
firstName?: string;
|
|
1032
|
+
lastName?: string;
|
|
1033
|
+
/** A page on one of the project's origins; Bachs sends the user back there. */
|
|
1034
|
+
returnUrl: string;
|
|
1035
|
+
}
|
|
762
1036
|
/** Selling ESPEES back to the desk, on a chain. */
|
|
763
1037
|
export interface SellInfo {
|
|
764
1038
|
open: boolean;
|