feat: migrate smart-updown contract to SPL-token (фантики)

- create_bet: escrow фантиков с bettor на vault (PDA[global,vault]) через anchor_spl::token
- close_bet: выплата фантиков из vault на bettor (CPI с signer_seeds vault)
- state/constants: comments про единицы (token units decimals=6), + VAULT_SEED
- IDL регенерирован (idl/ + relayer/idl/) с аккаунтами bettor_token/vault_token/token_program
- тесты обновлены под токен (10/10 + doctest)
This commit is contained in:
Caffeine
2026-09-09 22:00:41 +03:00
parent ff2289e68d
commit 45d64d45a7
10 changed files with 1106 additions and 120 deletions
+422 -6
View File
@@ -294,6 +294,7 @@ dependencies = [
"anchor-derive-accounts",
"anchor-derive-serde",
"anchor-derive-space",
"anchor-lang-idl",
"base64 0.21.7",
"bincode",
"borsh 0.10.4",
@@ -311,6 +312,7 @@ dependencies = [
"anchor-lang-idl-spec",
"anyhow",
"heck 0.3.3",
"regex",
"serde",
"serde_json",
"sha2 0.10.9",
@@ -326,6 +328,21 @@ dependencies = [
"serde",
]
[[package]]
name = "anchor-spl"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c08cb5d762c0694f74bd02c9a5b04ea53cefc496e2c27b3234acffca5cd076b"
dependencies = [
"anchor-lang",
"spl-associated-token-account",
"spl-pod",
"spl-token",
"spl-token-2022",
"spl-token-group-interface",
"spl-token-metadata-interface",
]
[[package]]
name = "anchor-syn"
version = "0.31.1"
@@ -334,6 +351,7 @@ checksum = "5dc7a6d90cc643df0ed2744862cdf180587d1e5d28936538c18fc8908489ed67"
dependencies = [
"anyhow",
"bs58",
"cargo_toml",
"heck 0.3.3",
"proc-macro2",
"quote",
@@ -892,6 +910,16 @@ dependencies = [
"libc",
]
[[package]]
name = "cargo_toml"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a98356df42a2eb1bd8f1793ae4ee4de48e384dd974ce5eac8eee802edb7492be"
dependencies = [
"serde",
"toml 0.8.23",
]
[[package]]
name = "cc"
version = "1.4.4"
@@ -3171,7 +3199,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
dependencies = [
"toml",
"toml 0.5.11",
]
[[package]]
@@ -3180,7 +3208,7 @@ version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
dependencies = [
"toml_edit",
"toml_edit 0.25.13+spec-1.1.0",
]
[[package]]
@@ -3854,6 +3882,15 @@ dependencies = [
"zmij",
]
[[package]]
name = "serde_spanned"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
dependencies = [
"serde",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -4035,6 +4072,8 @@ name = "smart-updown"
version = "0.1.0"
dependencies = [
"anchor-lang",
"anchor-spl",
"solana-account",
"solana-client",
"solana-clock",
"solana-keypair",
@@ -4042,6 +4081,8 @@ dependencies = [
"solana-pubkey",
"solana-signer",
"solana-transaction",
"spl-associated-token-account",
"spl-token",
"tokio",
]
@@ -6046,6 +6087,12 @@ dependencies = [
"solana-sdk-ids",
]
[[package]]
name = "solana-security-txt"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c94a02d486b28f219a4f8f5d7dd93cbfbb93c9f466cb7871c22e50cd5ae9a7a2"
[[package]]
name = "solana-seed-derivable"
version = "2.2.1"
@@ -6977,6 +7024,81 @@ dependencies = [
"lock_api",
]
[[package]]
name = "spl-associated-token-account"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76fee7d65013667032d499adc3c895e286197a35a0d3a4643c80e7fd3e9969e3"
dependencies = [
"borsh 1.8.1",
"num-derive",
"num-traits",
"solana-program",
"spl-associated-token-account-client",
"spl-token",
"spl-token-2022",
"thiserror 1.0.69",
]
[[package]]
name = "spl-associated-token-account-client"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f8349dbcbe575f354f9a533a21f272f3eb3808a49e2fdc1c34393b88ba76cb"
dependencies = [
"solana-instruction",
"solana-pubkey",
]
[[package]]
name = "spl-discriminator"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7398da23554a31660f17718164e31d31900956054f54f52d5ec1be51cb4f4b3"
dependencies = [
"bytemuck",
"solana-program-error",
"solana-sha256-hasher",
"spl-discriminator-derive",
]
[[package]]
name = "spl-discriminator-derive"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9e8418ea6269dcfb01c712f0444d2c75542c04448b480e87de59d2865edc750"
dependencies = [
"quote",
"spl-discriminator-syn",
"syn 2.0.119",
]
[[package]]
name = "spl-discriminator-syn"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d1dbc82ab91422345b6df40a79e2b78c7bce1ebb366da323572dd60b7076b67"
dependencies = [
"proc-macro2",
"quote",
"sha2 0.10.9",
"syn 2.0.119",
"thiserror 1.0.69",
]
[[package]]
name = "spl-elgamal-registry"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce0f668975d2b0536e8a8fd60e56a05c467f06021dae037f1d0cfed0de2e231d"
dependencies = [
"bytemuck",
"solana-program",
"solana-zk-sdk",
"spl-pod",
"spl-token-confidential-transfer-proof-extraction",
]
[[package]]
name = "spl-generic-token"
version = "1.0.1"
@@ -6987,6 +7109,250 @@ dependencies = [
"solana-pubkey",
]
[[package]]
name = "spl-memo"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f09647c0974e33366efeb83b8e2daebb329f0420149e74d3a4bd2c08cf9f7cb"
dependencies = [
"solana-account-info",
"solana-instruction",
"solana-msg",
"solana-program-entrypoint",
"solana-program-error",
"solana-pubkey",
]
[[package]]
name = "spl-pod"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d994afaf86b779104b4a95ba9ca75b8ced3fdb17ee934e38cb69e72afbe17799"
dependencies = [
"borsh 1.8.1",
"bytemuck",
"bytemuck_derive",
"num-derive",
"num-traits",
"solana-decode-error",
"solana-msg",
"solana-program-error",
"solana-program-option",
"solana-pubkey",
"solana-zk-sdk",
"thiserror 2.0.20",
]
[[package]]
name = "spl-program-error"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d39b5186f42b2b50168029d81e58e800b690877ef0b30580d107659250da1d1"
dependencies = [
"num-derive",
"num-traits",
"solana-program",
"spl-program-error-derive",
"thiserror 1.0.69",
]
[[package]]
name = "spl-program-error-derive"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d375dd76c517836353e093c2dbb490938ff72821ab568b545fd30ab3256b3e"
dependencies = [
"proc-macro2",
"quote",
"sha2 0.10.9",
"syn 2.0.119",
]
[[package]]
name = "spl-tlv-account-resolution"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd99ff1e9ed2ab86e3fd582850d47a739fec1be9f4661cba1782d3a0f26805f3"
dependencies = [
"bytemuck",
"num-derive",
"num-traits",
"solana-account-info",
"solana-decode-error",
"solana-instruction",
"solana-msg",
"solana-program-error",
"solana-pubkey",
"spl-discriminator",
"spl-pod",
"spl-program-error",
"spl-type-length-value",
"thiserror 1.0.69",
]
[[package]]
name = "spl-token"
version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed320a6c934128d4f7e54fe00e16b8aeaecf215799d060ae14f93378da6dc834"
dependencies = [
"arrayref",
"bytemuck",
"num-derive",
"num-traits",
"num_enum",
"solana-program",
"thiserror 1.0.69",
]
[[package]]
name = "spl-token-2022"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b27f7405010ef816587c944536b0eafbcc35206ab6ba0f2ca79f1d28e488f4f"
dependencies = [
"arrayref",
"bytemuck",
"num-derive",
"num-traits",
"num_enum",
"solana-program",
"solana-security-txt",
"solana-zk-sdk",
"spl-elgamal-registry",
"spl-memo",
"spl-pod",
"spl-token",
"spl-token-confidential-transfer-ciphertext-arithmetic",
"spl-token-confidential-transfer-proof-extraction",
"spl-token-confidential-transfer-proof-generation",
"spl-token-group-interface",
"spl-token-metadata-interface",
"spl-transfer-hook-interface",
"spl-type-length-value",
"thiserror 1.0.69",
]
[[package]]
name = "spl-token-confidential-transfer-ciphertext-arithmetic"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "170378693c5516090f6d37ae9bad2b9b6125069be68d9acd4865bbe9fc8499fd"
dependencies = [
"base64 0.22.1",
"bytemuck",
"solana-curve25519",
"solana-zk-sdk",
]
[[package]]
name = "spl-token-confidential-transfer-proof-extraction"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eff2d6a445a147c9d6dd77b8301b1e116c8299601794b558eafa409b342faf96"
dependencies = [
"bytemuck",
"solana-curve25519",
"solana-program",
"solana-zk-sdk",
"spl-pod",
"thiserror 2.0.20",
]
[[package]]
name = "spl-token-confidential-transfer-proof-generation"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8627184782eec1894de8ea26129c61303f1f0adeed65c20e0b10bc584f09356d"
dependencies = [
"curve25519-dalek 4.1.3",
"solana-zk-sdk",
"thiserror 1.0.69",
]
[[package]]
name = "spl-token-group-interface"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d595667ed72dbfed8c251708f406d7c2814a3fa6879893b323d56a10bedfc799"
dependencies = [
"bytemuck",
"num-derive",
"num-traits",
"solana-decode-error",
"solana-instruction",
"solana-msg",
"solana-program-error",
"solana-pubkey",
"spl-discriminator",
"spl-pod",
"thiserror 1.0.69",
]
[[package]]
name = "spl-token-metadata-interface"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfb9c89dbc877abd735f05547dcf9e6e12c00c11d6d74d8817506cab4c99fdbb"
dependencies = [
"borsh 1.8.1",
"num-derive",
"num-traits",
"solana-borsh",
"solana-decode-error",
"solana-instruction",
"solana-msg",
"solana-program-error",
"solana-pubkey",
"spl-discriminator",
"spl-pod",
"spl-type-length-value",
"thiserror 1.0.69",
]
[[package]]
name = "spl-transfer-hook-interface"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4aa7503d52107c33c88e845e1351565050362c2314036ddf19a36cd25137c043"
dependencies = [
"arrayref",
"bytemuck",
"num-derive",
"num-traits",
"solana-account-info",
"solana-cpi",
"solana-decode-error",
"solana-instruction",
"solana-msg",
"solana-program-error",
"solana-pubkey",
"spl-discriminator",
"spl-pod",
"spl-program-error",
"spl-tlv-account-resolution",
"spl-type-length-value",
"thiserror 1.0.69",
]
[[package]]
name = "spl-type-length-value"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba70ef09b13af616a4c987797870122863cba03acc4284f226a4473b043923f9"
dependencies = [
"bytemuck",
"num-derive",
"num-traits",
"solana-account-info",
"solana-decode-error",
"solana-msg",
"solana-program-error",
"spl-discriminator",
"spl-pod",
"thiserror 1.0.69",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.1"
@@ -7157,7 +7523,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom 0.3.4",
"getrandom 0.4.3",
"once_cell",
"rustix",
"windows-sys 0.61.2",
@@ -7409,6 +7775,27 @@ dependencies = [
"serde",
]
[[package]]
name = "toml"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime 0.6.11",
"toml_edit 0.22.27",
]
[[package]]
name = "toml_datetime"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
dependencies = [
"serde",
]
[[package]]
name = "toml_datetime"
version = "1.1.1+spec-1.1.0"
@@ -7418,6 +7805,20 @@ dependencies = [
"serde_core",
]
[[package]]
name = "toml_edit"
version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime 0.6.11",
"toml_write",
"winnow 0.7.15",
]
[[package]]
name = "toml_edit"
version = "0.25.13+spec-1.1.0"
@@ -7425,9 +7826,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b"
dependencies = [
"indexmap",
"toml_datetime",
"toml_datetime 1.1.1+spec-1.1.0",
"toml_parser",
"winnow",
"winnow 1.0.4",
]
[[package]]
@@ -7436,9 +7837,15 @@ version = "1.1.3+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56"
dependencies = [
"winnow",
"winnow 1.0.4",
]
[[package]]
name = "toml_write"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
[[package]]
name = "tower"
version = "0.5.3"
@@ -8021,6 +8428,15 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winnow"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945"
dependencies = [
"memchr",
]
[[package]]
name = "winnow"
version = "1.0.4"