feat(relayer): migrate to SPL-token (фантики)
- ops: readGlobal читает vaultBalance (getTokenAccountBalance), createBet/closeBet передают bettorToken/vaultToken/tokenProgram, ensureVaultFunded наливает токен (mintTo, allowOwnerOffCurve) - pda: vaultPda([global,vault]), config:.env.new SMART_TOKEN_MINT, суммы в токен-единицах - check.ts: 14 проверок сигнатур создания create/close под новым токеновым IDL - @solana/spl-token dependency; .gitignore + node_modules/dist
This commit is contained in:
+141
-21
@@ -1,8 +1,7 @@
|
||||
/**
|
||||
* Program IDL in camelCase format in order to be used in JS/TS.
|
||||
*
|
||||
* Note that this is only a type helper and is not the actual IDL. The original
|
||||
* IDL can be found at `target/idl/smart_updown.json`.
|
||||
* Program IDL in camelCase format (see @anchor-lang/core convertIdlToCamelCase).
|
||||
* Mirrors relayer/idl/smart_updown.json but with names camelCased, exactly as
|
||||
* the runtime Program instance exposes them (methods/accounts/types).
|
||||
*/
|
||||
export type SmartUpdown = {
|
||||
"address": "9ALsnxXNzDBv3mokngCHbruRTWUZiWR7pf7vswS1fCpf",
|
||||
@@ -16,7 +15,14 @@ export type SmartUpdown = {
|
||||
{
|
||||
"name": "closeBet",
|
||||
"discriminator": [
|
||||
2
|
||||
185,
|
||||
206,
|
||||
13,
|
||||
184,
|
||||
176,
|
||||
108,
|
||||
140,
|
||||
107
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
@@ -63,15 +69,54 @@ export type SmartUpdown = {
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bettor",
|
||||
"docs": [
|
||||
"CHECK: recipient must be the bet's bettor and is validated in the handler."
|
||||
],
|
||||
"writable": true
|
||||
"name": "bettor"
|
||||
},
|
||||
{
|
||||
"name": "clock",
|
||||
"address": "SysvarC1ock11111111111111111111111111111111"
|
||||
},
|
||||
{
|
||||
"name": "vaultToken",
|
||||
"docs": [
|
||||
"Program-owned token vault: PDA([GLOBAL_SEED, VAULT_SEED]); payouts are paid out from here."
|
||||
],
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
103,
|
||||
108,
|
||||
111,
|
||||
98,
|
||||
97,
|
||||
108
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
118,
|
||||
97,
|
||||
117,
|
||||
108,
|
||||
116
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bettorToken",
|
||||
"docs": [
|
||||
"Bettor's SPL-token account; the payout is sent here."
|
||||
],
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"name": "tokenProgram",
|
||||
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
@@ -88,7 +133,14 @@ export type SmartUpdown = {
|
||||
{
|
||||
"name": "createBet",
|
||||
"discriminator": [
|
||||
1
|
||||
197,
|
||||
42,
|
||||
153,
|
||||
2,
|
||||
59,
|
||||
63,
|
||||
143,
|
||||
246
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
@@ -142,6 +194,49 @@ export type SmartUpdown = {
|
||||
{
|
||||
"name": "systemProgram",
|
||||
"address": "11111111111111111111111111111111"
|
||||
},
|
||||
{
|
||||
"name": "bettorToken",
|
||||
"docs": [
|
||||
"Bettor's SPL-token account (our \"fanti\" mint); bet amount is pulled from here."
|
||||
],
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"name": "vaultToken",
|
||||
"docs": [
|
||||
"Program-owned token vault: PDA([GLOBAL_SEED, VAULT_SEED]); bet amounts are escrowed here."
|
||||
],
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
103,
|
||||
108,
|
||||
111,
|
||||
98,
|
||||
97,
|
||||
108
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
118,
|
||||
97,
|
||||
117,
|
||||
108,
|
||||
116
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tokenProgram",
|
||||
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
@@ -166,7 +261,14 @@ export type SmartUpdown = {
|
||||
{
|
||||
"name": "initialize",
|
||||
"discriminator": [
|
||||
0
|
||||
175,
|
||||
175,
|
||||
109,
|
||||
31,
|
||||
13,
|
||||
152,
|
||||
155,
|
||||
237
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
@@ -220,7 +322,14 @@ export type SmartUpdown = {
|
||||
{
|
||||
"name": "update",
|
||||
"discriminator": [
|
||||
3
|
||||
219,
|
||||
200,
|
||||
88,
|
||||
176,
|
||||
158,
|
||||
63,
|
||||
253,
|
||||
127
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
@@ -386,10 +495,9 @@ export type SmartUpdown = {
|
||||
"types": [
|
||||
{
|
||||
"name": "bet",
|
||||
"serialization": "bytemuck",
|
||||
"repr": {
|
||||
"kind": "c"
|
||||
},
|
||||
"docs": [
|
||||
"Open bet. `amount` is in token base units (decimals = 6), not lamports."
|
||||
],
|
||||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
@@ -494,10 +602,13 @@ export type SmartUpdown = {
|
||||
},
|
||||
{
|
||||
"name": "global",
|
||||
"serialization": "bytemuck",
|
||||
"repr": {
|
||||
"kind": "c"
|
||||
},
|
||||
"docs": [
|
||||
"Global game state.",
|
||||
"",
|
||||
"All money-related fields are denominated in **SPL-token base units**",
|
||||
"(our \"fanti\" token, decimals = 6), not in lamports:",
|
||||
"`min_amount`/`max_amount` bound a bet amount in token units."
|
||||
],
|
||||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
@@ -547,6 +658,15 @@ export type SmartUpdown = {
|
||||
"name": "globalSeed",
|
||||
"type": "bytes",
|
||||
"value": "[103, 108, 111, 98, 97, 108]"
|
||||
},
|
||||
{
|
||||
"name": "vaultSeed",
|
||||
"docs": [
|
||||
"Vault PDA seed: the token vault lives at PDA([GLOBAL_SEED, VAULT_SEED]).",
|
||||
"It cannot reuse GLOBAL_SEED alone — that PDA address is the `global` state account itself."
|
||||
],
|
||||
"type": "bytes",
|
||||
"value": "[118, 97, 117, 108, 116]"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user