@projectsolo/solo-mission-mcp 0.21.13 → 0.22.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/DEVELOPER_README.md +1 -1
- package/README.md +96 -12
- package/dist/chunk-NUGGTARW.js +196 -0
- package/dist/{chunk-TKRT2V2W.js → chunk-OP4QYTL4.js} +5 -0
- package/dist/{client-LDWK5HLP.js → client-NS6J6IO2.js} +1 -1
- package/dist/deployment-UCUWVIPJ.js +43 -0
- package/dist/escrowErrors-4XSAYLGT.js +56 -0
- package/dist/index.js +244 -162
- package/dist/verify-7EUVRUAS.js +445 -0
- package/dist/{wallet-V4T4NTCM.js → wallet-LX7SI5RE.js} +28 -14
- package/dist/wire-RLDY4AJR.js +24 -0
- package/package.json +1 -1
- package/src/config.ts +11 -0
- package/src/index.ts +1 -1
- package/src/scripts/check-tools-against-spec.ts +3 -3
- package/src/solana/deployment.test.ts +61 -0
- package/src/solana/deployment.ts +89 -0
- package/src/solana/escrowErrors.ts +78 -0
- package/src/solana/fixtures/config-account.json +6 -0
- package/src/solana/fixtures/funding-transaction-v2-lottery.json +49 -0
- package/src/solana/fixtures/funding-transaction-v2-plain.json +46 -0
- package/src/solana/fixtures/solo_escrow.v2.idl-excerpt.json +683 -0
- package/src/solana/verify.test.ts +605 -78
- package/src/solana/verify.ts +545 -84
- package/src/solana/wallet.test.ts +85 -2
- package/src/solana/wallet.ts +74 -31
- package/src/solana/wire.test.ts +129 -0
- package/src/solana/wire.ts +264 -0
- package/src/tools/missions.ts +56 -119
- package/src/tools/solana.test.ts +356 -0
- package/src/tools/solana.ts +309 -70
- package/src/tools/tracks.ts +1 -1
- package/dist/verify-KAETIGV5.js +0 -136
- /package/src/solana/fixtures/{funding-transaction.json → funding-transaction-v1.json} +0 -0
package/dist/verify-KAETIGV5.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// src/solana/verify.ts
|
|
2
|
-
var eqAmount = (a, b) => {
|
|
3
|
-
try {
|
|
4
|
-
return BigInt(a) === BigInt(b);
|
|
5
|
-
} catch {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
async function verifyFundingTransaction(input) {
|
|
10
|
-
const { Transaction, PublicKey } = await import("@solana/web3.js");
|
|
11
|
-
const problems = [];
|
|
12
|
-
const tx = Transaction.from(Buffer.from(input.transaction_base64, "base64"));
|
|
13
|
-
if (tx.instructions.length !== 1) {
|
|
14
|
-
problems.push(
|
|
15
|
-
`expected exactly 1 instruction, found ${tx.instructions.length} \u2014 additional instructions would be authorised by the same signature`
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
const ix = tx.instructions[0];
|
|
19
|
-
const programId = ix?.programId?.toBase58() ?? "(none)";
|
|
20
|
-
if (programId !== input.expected_program_id) {
|
|
21
|
-
problems.push(`program is ${programId}, expected ${input.expected_program_id}`);
|
|
22
|
-
}
|
|
23
|
-
if (programId !== input.accounts.program_id) {
|
|
24
|
-
problems.push(
|
|
25
|
-
`transaction program ${programId} disagrees with the quoted accounts.program_id ${input.accounts.program_id}`
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
const signers = (ix?.keys ?? []).filter((k) => k.isSigner).map((k) => k.pubkey.toBase58());
|
|
29
|
-
if (signers.length !== 1 || signers[0] !== input.expected.sponsor) {
|
|
30
|
-
problems.push(
|
|
31
|
-
`expected the sponsor ${input.expected.sponsor} to be the only signer, found [${signers.join(", ")}]`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
if (tx.feePayer?.toBase58() !== input.expected.sponsor) {
|
|
35
|
-
problems.push(
|
|
36
|
-
`fee payer is ${tx.feePayer?.toBase58() ?? "(unset)"}, expected ${input.expected.sponsor}`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
const keyList = (ix?.keys ?? []).map((k) => k.pubkey.toBase58());
|
|
40
|
-
for (const [label, expected] of [
|
|
41
|
-
["mint", input.expected.mint],
|
|
42
|
-
["sponsor", input.expected.sponsor]
|
|
43
|
-
]) {
|
|
44
|
-
if (!keyList.includes(expected)) {
|
|
45
|
-
problems.push(`${label} ${expected} does not appear in the transaction's accounts`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (input.accounts.mint !== input.expected.mint) {
|
|
49
|
-
problems.push(`quoted mint ${input.accounts.mint}, expected ${input.expected.mint}`);
|
|
50
|
-
}
|
|
51
|
-
if (input.accounts.vault === input.accounts.sponsor_token_account) {
|
|
52
|
-
problems.push("escrow vault equals the sponsor token account \u2014 the budget would not be escrowed");
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
for (const [label, addr] of [
|
|
56
|
-
["task", input.accounts.task],
|
|
57
|
-
["vault", input.accounts.vault]
|
|
58
|
-
]) {
|
|
59
|
-
if (PublicKey.isOnCurve(new PublicKey(addr).toBytes())) {
|
|
60
|
-
problems.push(`${label} ${addr} is not a program-derived address \u2014 someone holds its key`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} catch {
|
|
64
|
-
problems.push("task or vault is not a valid address");
|
|
65
|
-
}
|
|
66
|
-
const d = input.declared;
|
|
67
|
-
const e = input.expected;
|
|
68
|
-
if (!eqAmount(d.budget, e.budget_raw)) {
|
|
69
|
-
problems.push(`budget is ${d.budget}, expected ${e.budget_raw}`);
|
|
70
|
-
}
|
|
71
|
-
if (!eqAmount(d.base_pool, e.base_pool_raw)) {
|
|
72
|
-
problems.push(`base_pool is ${d.base_pool}, expected ${e.base_pool_raw}`);
|
|
73
|
-
}
|
|
74
|
-
if (d.lottery_winner_count !== e.lottery_winner_count) {
|
|
75
|
-
problems.push(
|
|
76
|
-
`lottery_winner_count is ${d.lottery_winner_count}, expected ${e.lottery_winner_count}`
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
if (!eqAmount(d.lottery_prize_per_winner, e.lottery_prize_per_winner_raw)) {
|
|
80
|
-
problems.push(
|
|
81
|
-
`lottery_prize_per_winner is ${d.lottery_prize_per_winner}, expected ${e.lottery_prize_per_winner_raw}`
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
if (!eqAmount(d.qualify_deadline, String(e.qualify_deadline))) {
|
|
85
|
-
problems.push(`qualify_deadline is ${d.qualify_deadline}, expected ${e.qualify_deadline}`);
|
|
86
|
-
}
|
|
87
|
-
if (!eqAmount(d.settlement_deadline, String(e.settlement_deadline))) {
|
|
88
|
-
problems.push(
|
|
89
|
-
`settlement_deadline is ${d.settlement_deadline}, expected ${e.settlement_deadline}`
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
if (!/^[0-9a-f]{64}$/i.test(d.seed_commit)) {
|
|
93
|
-
problems.push(`seed_commit is not 32 bytes of hex: ${d.seed_commit}`);
|
|
94
|
-
}
|
|
95
|
-
const data = ix?.data ?? Buffer.alloc(0);
|
|
96
|
-
if (data.length !== 8 + 8 + 8 + 4 + 8 + 8 + 8 + 32) {
|
|
97
|
-
problems.push(
|
|
98
|
-
`instruction data is ${data.length} bytes, expected 84 for create_task \u2014 this is not the instruction it claims to be`
|
|
99
|
-
);
|
|
100
|
-
} else {
|
|
101
|
-
const encoded = {
|
|
102
|
-
budget: data.readBigUInt64LE(8).toString(),
|
|
103
|
-
base_pool: data.readBigUInt64LE(16).toString(),
|
|
104
|
-
lottery_winner_count: data.readUInt32LE(24),
|
|
105
|
-
lottery_prize_per_winner: data.readBigUInt64LE(28).toString(),
|
|
106
|
-
qualify_deadline: data.readBigInt64LE(36).toString(),
|
|
107
|
-
settlement_deadline: data.readBigInt64LE(44).toString(),
|
|
108
|
-
seed_commit: data.subarray(52, 84).toString("hex")
|
|
109
|
-
};
|
|
110
|
-
for (const key of Object.keys(encoded)) {
|
|
111
|
-
const inBytes = String(encoded[key]);
|
|
112
|
-
const quoted = String(d[key]);
|
|
113
|
-
const same = key === "seed_commit" || key === "lottery_winner_count" ? inBytes.toLowerCase() === quoted.toLowerCase() : eqAmount(inBytes, quoted);
|
|
114
|
-
if (!same) {
|
|
115
|
-
problems.push(
|
|
116
|
-
`the transaction encodes ${key}=${inBytes} but the response quoted ${quoted} \u2014 the backend described one thing and built another`
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
ok: problems.length === 0,
|
|
123
|
-
problems,
|
|
124
|
-
summary: {
|
|
125
|
-
program_id: programId,
|
|
126
|
-
instruction_count: tx.instructions.length,
|
|
127
|
-
signers,
|
|
128
|
-
budget: d.budget,
|
|
129
|
-
mint: input.accounts.mint,
|
|
130
|
-
task: input.accounts.task
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
verifyFundingTransaction
|
|
136
|
-
};
|
|
File without changes
|