Upgrade anchor to 0.24.2
This commit is contained in:
parent
115349edb3
commit
eb46a030d1
|
@ -50,7 +50,21 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "105c443a613f29212755fb6c5f946fa82dcf94a80528f643e0faa9d9faeb626b"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-access-control"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9b75d05b6b4ac9d95bb6e3b786b27d3a708c4c5a87c92ffaa25bbe9ae4c5d91"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -64,7 +78,22 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdae15851aa41972e9c18c987613c50a916c48c88c97ea3316156a5c772e5faa"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"anyhow",
|
||||
"bs58 0.4.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-account"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "485351a6d8157750d10d88c8e256f1bf8339262b2220ae9125aed3471309b5de"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"anyhow",
|
||||
"bs58 0.4.0",
|
||||
"proc-macro2",
|
||||
|
@ -79,7 +108,18 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6356865217881d0bbea8aa70625937bec6d9952610f1ba2a2452a8e427000687"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-constant"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc632c540913dd051a78b00587cc47f57013d303163ddfaf4fa18717f7ccc1e0"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
]
|
||||
|
@ -90,7 +130,19 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebe998ce4e6e0cb0e291d1a1626bd30791cdfdd9d05523111bdf4fd053f08636"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-error"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b5bd1dcfa7f3bc22dacef233d70a9e0bee269c4ac484510662f257cba2353a1"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
|
@ -102,7 +154,20 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c5810498a20554c20354f5648b6041172f2035e58d09ad40dc051dc0d1501f80"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-event"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c6f9e6ce551ac9a177a45c99a65699a860c9e95fac68675138af1246e2591b0"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -115,7 +180,21 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac83f085b2be8b3a3412989cf96cf7f683561db7d357c5aa4aa11d48bbb22213"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"anyhow",
|
||||
"heck 0.3.3",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-interface"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d104aa17418cb329ed7418b227e083d5f326a27f26ce98f5d92e33da62a5f459"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"anyhow",
|
||||
"heck 0.3.3",
|
||||
"proc-macro2",
|
||||
|
@ -129,7 +208,20 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73c56be575d89abcb192afa29deb87b2cdb3c39033abc02f2d16e6af999b23b7"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-program"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6831b920b173c004ddf7ae1167d1d25e9f002ffcb1773bbc5c7ce532a4441e1"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -142,7 +234,20 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62ab002353b01fcb4f72cca256d5d62db39f9ff39b1d072280deee9798f1f524"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-attribute-state"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cde147b10c71d95dc679785db0b5f3abac0091f789167aa62ac0135e2f54e8b9"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -155,7 +260,20 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9e653cdb322078d95221384c4a527a403560e509ac7cb2b53d3bd664b23c4d6"
|
||||
dependencies = [
|
||||
"anchor-syn",
|
||||
"anchor-syn 0.20.1",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-derive-accounts"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cde98a0e1a56046b040ff591dfda391f88917af2b6487d02b45093c05be3514"
|
||||
dependencies = [
|
||||
"anchor-syn 0.24.2",
|
||||
"anyhow",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -168,15 +286,39 @@ version = "0.20.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4815ad6334fd2f561f7ddcc3cfbeed87ed3003724171bd80ebe6383d5173ee8f"
|
||||
dependencies = [
|
||||
"anchor-attribute-access-control",
|
||||
"anchor-attribute-account",
|
||||
"anchor-attribute-constant",
|
||||
"anchor-attribute-error",
|
||||
"anchor-attribute-event",
|
||||
"anchor-attribute-interface",
|
||||
"anchor-attribute-program",
|
||||
"anchor-attribute-state",
|
||||
"anchor-derive-accounts",
|
||||
"anchor-attribute-access-control 0.20.1",
|
||||
"anchor-attribute-account 0.20.1",
|
||||
"anchor-attribute-constant 0.20.1",
|
||||
"anchor-attribute-error 0.20.1",
|
||||
"anchor-attribute-event 0.20.1",
|
||||
"anchor-attribute-interface 0.20.1",
|
||||
"anchor-attribute-program 0.20.1",
|
||||
"anchor-attribute-state 0.20.1",
|
||||
"anchor-derive-accounts 0.20.1",
|
||||
"arrayref",
|
||||
"base64 0.13.0",
|
||||
"bincode",
|
||||
"borsh",
|
||||
"bytemuck",
|
||||
"solana-program",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-lang"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a85dd2c5e29e20c7f4701a43724d6cd5406d0ee5694705522e43da0f26542a84"
|
||||
dependencies = [
|
||||
"anchor-attribute-access-control 0.24.2",
|
||||
"anchor-attribute-account 0.24.2",
|
||||
"anchor-attribute-constant 0.24.2",
|
||||
"anchor-attribute-error 0.24.2",
|
||||
"anchor-attribute-event 0.24.2",
|
||||
"anchor-attribute-interface 0.24.2",
|
||||
"anchor-attribute-program 0.24.2",
|
||||
"anchor-attribute-state 0.24.2",
|
||||
"anchor-derive-accounts 0.24.2",
|
||||
"arrayref",
|
||||
"base64 0.13.0",
|
||||
"bincode",
|
||||
|
@ -188,11 +330,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anchor-spl"
|
||||
version = "0.20.1"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ea94b04fc9a0aaae4d4473b0595fb5f55b6c9b38e0d6f596df8c8060f95f096"
|
||||
checksum = "0188c33b4a3c124c4e593f2b440415aaea70a7650fac6ba0772395385d71c003"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
"anchor-lang 0.24.2",
|
||||
"solana-program",
|
||||
"spl-associated-token-account",
|
||||
"spl-token",
|
||||
|
@ -217,6 +359,25 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anchor-syn"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03549dc2eae0b20beba6333b14520e511822a6321cdb1760f841064a69347316"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bs58 0.3.1",
|
||||
"heck 0.3.3",
|
||||
"proc-macro2",
|
||||
"proc-macro2-diagnostics",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"syn",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.55"
|
||||
|
@ -833,26 +994,6 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enum-iterator"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6"
|
||||
dependencies = [
|
||||
"enum-iterator-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enum-iterator-derive"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enum-ordinalize"
|
||||
version = "3.1.10"
|
||||
|
@ -2285,9 +2426,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-address-lookup-table-program"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0369417da252129c0bc74e818beb11e84a6b6aecd517b29d2c2808cddca1492b"
|
||||
checksum = "e0d3ae01e1aa350228312868f4275460bd6f2945fe3b0ebf4d86f8e1d0b02acd"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytemuck",
|
||||
|
@ -2305,9 +2446,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-banks-client"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3d4cf0f95bfbc40e6983c5a530476275d0f5b95b7db04173b0a5ac7977eaf00"
|
||||
checksum = "f355273a7898a93be213d1fc24b35eef385cdb97260b506b3831e36c9a0bfa3a"
|
||||
dependencies = [
|
||||
"borsh",
|
||||
"futures",
|
||||
|
@ -2322,9 +2463,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-banks-interface"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fff2fed480f0b0698678c76d51d6adf66d6398c05cc7fdf1b65ac80f18e218c"
|
||||
checksum = "27e8ee8f457f0e4ea18a3a2ba8c454d4fd3126cea9630a6f17de36ee5b61c892"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"solana-sdk",
|
||||
|
@ -2333,9 +2474,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-banks-server"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ab002c21afd114317fab2f21251ce5d7937692b903ed6856923dc580bdfb8d"
|
||||
checksum = "134b7366ee56251c4f312104f77af725d5855072ec5d114fddff5a19b461fe42"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"futures",
|
||||
|
@ -2351,9 +2492,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-bloom"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e725d8fb099cc9972dce4228e1128a2d31676a5e4bfa753912c306cdc502ea49"
|
||||
checksum = "60d9e40fa9c8f2faa0a52c3777ce06df43250b43901a38bfee057e9eae340d04"
|
||||
dependencies = [
|
||||
"bv",
|
||||
"fnv",
|
||||
|
@ -2370,9 +2511,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-bpf-loader-program"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8df32772715fec1e153ce9a5a965785322686fd80e60d7e023d24cd3def1f6d1"
|
||||
checksum = "fa9a05b8a19e803d9d05d8df3a58e98280b52977b17211459e36c36386990059"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"byteorder",
|
||||
|
@ -2388,9 +2529,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-bucket-map"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87db847d4b8d38920625cc1f35caf6a65d684db93f1ef3810fbe059c772a8a66"
|
||||
checksum = "fe1d8d78cc13320db78606dda3699143ceb7a2c4685d43522d7848a54af7b66d"
|
||||
dependencies = [
|
||||
"fs_extra",
|
||||
"log",
|
||||
|
@ -2405,9 +2546,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-compute-budget-program"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63c4955206f7f19d0462f49c1001af4aa867e8de106170f8ebbb6db373579b4e"
|
||||
checksum = "4b14d59fffbd8fcf666d7ebd977c289f072acd735a890226d32bfaa9e318edb3"
|
||||
dependencies = [
|
||||
"solana-program-runtime",
|
||||
"solana-sdk",
|
||||
|
@ -2415,9 +2556,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-config-program"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b48ae3996c82a7b4a0552ba4a19871cddb00a440e5b50b0e4afb8c56f7865c92"
|
||||
checksum = "e1a3634cfb004b1698b34d17aad6a7c13f272242d332608748bae3bd4adf05e2"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"chrono",
|
||||
|
@ -2429,9 +2570,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbb58e258da28e714904b62a1e8b7de5b01d349420a88409c84cb57264699021"
|
||||
checksum = "3129f7367168973c21989602df241bfbf890450d2d8912b9b07e820101a070eb"
|
||||
dependencies = [
|
||||
"bs58 0.4.0",
|
||||
"bv",
|
||||
|
@ -2449,9 +2590,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi-macro"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f9c141ee23138a001bf94a9850fff3c8804e52fa36c151a8a4699f60bd55f74"
|
||||
checksum = "d03ddde7f8bcc5a3847de5723efae88aea18931e559611a8cb0827d9add83f96"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2461,9 +2602,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b63b04c1a2077f2eadb3c63988a14bc4fa4419f291fea7112a9c595db1e63b"
|
||||
checksum = "8151da49e5338abba3cac5fbeda754e0ff02dfe2e6ac26f76928d0435170b6fc"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
@ -2472,9 +2613,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-measure"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8b1bfded346a894946ca4055da1ed3c09cf6878292afc2c5f011290a65cd713"
|
||||
checksum = "5f2bb4fc58acc5eb0200bdc2e47ab0d087342f40c412cdb06e6389f97af276b2"
|
||||
dependencies = [
|
||||
"log",
|
||||
"solana-sdk",
|
||||
|
@ -2482,9 +2623,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-metrics"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c90c25622d5a2ceca6769cb0c3d4038c0b1e54ac1257c19ad9818cb40e4283a"
|
||||
checksum = "389a663316a2c28be5947fd4e2d1f7ee6eecda6d1c24b08188546f31825861d4"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"gethostname",
|
||||
|
@ -2496,9 +2637,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-program"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c41b2af0be4fc039852c74926a8a026e97f9b1d7c02c15610bb6a614268a4ea"
|
||||
checksum = "3981394cc258fe1cb058b75bd5031eff01140ba0fa9b5a802b5c30f439ebeeba"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"bincode",
|
||||
|
@ -2539,9 +2680,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-program-runtime"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce923873f6b36649cebbb047b4b99c0005666bae32db24625b3dbd3d1908e98e"
|
||||
checksum = "7e0d4527c5b9203357e1bc070279b2714b6cc1abd5cd9c2264159f6cc7386eaa"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"bincode",
|
||||
|
@ -2563,9 +2704,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-program-test"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6006d2fb499a3d2ae528ece71688409e24f7d11e97fb5d4b3059f64ec54ce8f4"
|
||||
checksum = "d554d670d40add2b09e86edccdf955714dd3ec8b6c44bb7284f43509b5229c4c"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.12.3",
|
||||
|
@ -2587,9 +2728,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-rayon-threadlimit"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8460f02bf10feb60704c0eb6874fa1cc36246d832b28ea481cda94aa5860e5e8"
|
||||
checksum = "cbd6c70547188458e12a576d387d925b03dcdc7f9c7eac84473dbb0c3805264c"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"num_cpus",
|
||||
|
@ -2597,20 +2738,20 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-runtime"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8f83c92b1b55719ebff972a45e22cbe6a808760cc1ac2dac8ddd53ee3694d3e"
|
||||
checksum = "a22926084f4843a42a651b7744b9b5b620e60dee3ddf46e0257dceb3c47b04be"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"bincode",
|
||||
"blake3",
|
||||
"bv",
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"bzip2",
|
||||
"crossbeam-channel",
|
||||
"dashmap",
|
||||
"dir-diff",
|
||||
"enum-iterator",
|
||||
"flate2",
|
||||
"fnv",
|
||||
"index_list",
|
||||
|
@ -2652,9 +2793,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-sdk"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73ca3ff8e6bf6ccb39dfbb834601febc1c872e9ffd5c7e25fb9fe636a67e9690"
|
||||
checksum = "8f0b4eb7e8574748aa1f2c1c99594abfa97bfe21f1355e5f2ad5341ad1984cb7"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"base64 0.13.0",
|
||||
|
@ -2703,9 +2844,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "238b93350286f73c2bd94c1a307bb0226a2f78070937bcf273bf968859f8cc39"
|
||||
checksum = "7584154d8716cc4b2ad3cf7df3cf8e2be2639f85a0e63e6440eebc33cee97291"
|
||||
dependencies = [
|
||||
"bs58 0.4.0",
|
||||
"proc-macro2",
|
||||
|
@ -2716,9 +2857,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-send-transaction-service"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28357ff694194267f520a872a568c948a94aa1ef67974bdfbb78b7cdb7325d7d"
|
||||
checksum = "8a736c40e28b8cb0d13a747e06a74e3c96fe836202c708f63d3e7bca65dfeb49"
|
||||
dependencies = [
|
||||
"log",
|
||||
"solana-logger",
|
||||
|
@ -2729,9 +2870,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-stake-program"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "123b42d0785e39363ba6337561e6f9e0a5970d918a6292cc24b7e71e75e41136"
|
||||
checksum = "6ced08967dd1d702f0d11bc68c704722000267fe90eb1991f7a8632d20866163"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"log",
|
||||
|
@ -2752,9 +2893,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-vote-program"
|
||||
version = "1.9.5"
|
||||
version = "1.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c618782e54ec7d65e13531a576b7fd49352cbfc0d8d082badd65d280534ea35"
|
||||
checksum = "288e3fe7fd38b2542fc1751bb738e4b7d08f77b6974c62bcaee320ebfa6c32a2"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"log",
|
||||
|
@ -2774,9 +2915,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana_rbpf"
|
||||
version = "0.2.21"
|
||||
version = "0.2.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fb565d026461ba89d1d92cc36cf0882fba44076559c3bbed1e8a9888112b3d7"
|
||||
checksum = "41e138f6d6d4eb6a65f8e9f01ca620bc9907d79648d5038a69dd3f07b6ed3f1f"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"combine",
|
||||
|
@ -3300,7 +3441,7 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
|||
name = "voter-stake-registry"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
"anchor-lang 0.24.2",
|
||||
"anchor-spl",
|
||||
"base64 0.13.0",
|
||||
"bincode",
|
||||
|
@ -3323,7 +3464,7 @@ dependencies = [
|
|||
name = "voter-stake-registry-cli"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
"anchor-lang 0.20.1",
|
||||
"anyhow",
|
||||
"base64 0.13.0",
|
||||
"clap",
|
||||
|
|
|
@ -19,8 +19,8 @@ test-bpf = []
|
|||
|
||||
[dependencies]
|
||||
# a) for deployment use these
|
||||
anchor-lang = "0.20.1"
|
||||
anchor-spl = { version = "0.20.1" }
|
||||
anchor-lang = { version = "0.24.2", features = ["init-if-needed"] }
|
||||
anchor-spl = { version = "0.24.2" }
|
||||
# b) while testing, use below dependencies for debugging instead of above ones
|
||||
# anchor-lang = { git = "https://github.com/microwavedcola1/anchor.git", branch = "master-debug" }
|
||||
# anchor-spl = { git = "https://github.com/microwavedcola1/anchor.git", branch = "master-debug", features = ["governance"]}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use anchor_lang::prelude::*;
|
||||
|
||||
#[error]
|
||||
pub enum ErrorCode {
|
||||
#[error_code]
|
||||
pub enum VsrError {
|
||||
// 6000 / 0x1770
|
||||
#[msg("Exchange rate must be greater than zero")]
|
||||
InvalidRate,
|
||||
|
|
|
@ -7,35 +7,30 @@ macro_rules! vote_weight_record {
|
|||
pub struct VoterWeightRecord(spl_governance_addin_api::voter_weight::VoterWeightRecord);
|
||||
|
||||
impl anchor_lang::AccountDeserialize for VoterWeightRecord {
|
||||
fn try_deserialize(buf: &mut &[u8]) -> std::result::Result<Self, ProgramError> {
|
||||
fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
|
||||
let mut data = buf;
|
||||
let vwr: spl_governance_addin_api::voter_weight::VoterWeightRecord =
|
||||
anchor_lang::AnchorDeserialize::deserialize(&mut data)
|
||||
.map_err(|_| anchor_lang::__private::ErrorCode::AccountDidNotDeserialize)?;
|
||||
.map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotDeserialize)?;
|
||||
if !solana_program::program_pack::IsInitialized::is_initialized(&vwr) {
|
||||
return Err(anchor_lang::__private::ErrorCode::AccountDidNotSerialize.into());
|
||||
return Err(anchor_lang::error::ErrorCode::AccountDidNotSerialize.into());
|
||||
}
|
||||
Ok(VoterWeightRecord(vwr))
|
||||
}
|
||||
|
||||
fn try_deserialize_unchecked(
|
||||
buf: &mut &[u8],
|
||||
) -> std::result::Result<Self, ProgramError> {
|
||||
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
|
||||
let mut data = buf;
|
||||
let vwr: spl_governance_addin_api::voter_weight::VoterWeightRecord =
|
||||
anchor_lang::AnchorDeserialize::deserialize(&mut data)
|
||||
.map_err(|_| anchor_lang::__private::ErrorCode::AccountDidNotDeserialize)?;
|
||||
.map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotDeserialize)?;
|
||||
Ok(VoterWeightRecord(vwr))
|
||||
}
|
||||
}
|
||||
|
||||
impl anchor_lang::AccountSerialize for VoterWeightRecord {
|
||||
fn try_serialize<W: std::io::Write>(
|
||||
&self,
|
||||
writer: &mut W,
|
||||
) -> std::result::Result<(), ProgramError> {
|
||||
fn try_serialize<W: std::io::Write>(&self, writer: &mut W) -> anchor_lang::Result<()> {
|
||||
anchor_lang::AnchorSerialize::serialize(&self.0, writer)
|
||||
.map_err(|_| anchor_lang::__private::ErrorCode::AccountDidNotSerialize)?;
|
||||
.map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotSerialize)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ pub fn clawback(ctx: Context<Clawback>, deposit_entry_index: u8) -> Result<()> {
|
|||
let deposit_entry = voter.active_deposit_mut(deposit_entry_index)?;
|
||||
require!(
|
||||
deposit_entry.allow_clawback,
|
||||
ErrorCode::ClawbackNotAllowedOnDeposit
|
||||
VsrError::ClawbackNotAllowedOnDeposit
|
||||
);
|
||||
|
||||
let curr_ts = registrar.clock_unix_timestamp();
|
||||
|
@ -74,7 +74,7 @@ pub fn clawback(ctx: Context<Clawback>, deposit_entry_index: u8) -> Result<()> {
|
|||
// Update deposit book keeping.
|
||||
require!(
|
||||
locked_amount <= deposit_entry.amount_deposited_native,
|
||||
InternalProgramError
|
||||
VsrError::InternalProgramError
|
||||
);
|
||||
deposit_entry.amount_deposited_native -= locked_amount;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ pub struct CloseDepositEntry<'info> {
|
|||
pub fn close_deposit_entry(ctx: Context<CloseDepositEntry>, deposit_entry_index: u8) -> Result<()> {
|
||||
let voter = &mut ctx.accounts.voter.load_mut()?;
|
||||
let d = voter.active_deposit_mut(deposit_entry_index)?;
|
||||
require!(d.amount_deposited_native == 0, VotingTokenNonZero);
|
||||
require!(d.amount_deposited_native == 0, VsrError::VotingTokenNonZero);
|
||||
|
||||
// Deposits that have clawback enabled are guaranteed to live until the end
|
||||
// of their locking period. That ensures a deposit can't be closed and reopenend
|
||||
|
@ -32,7 +32,7 @@ pub fn close_deposit_entry(ctx: Context<CloseDepositEntry>, deposit_entry_index:
|
|||
if d.allow_clawback {
|
||||
require!(
|
||||
d.lockup.expired(Clock::get()?.unix_timestamp),
|
||||
DepositStillLocked
|
||||
VsrError::DepositStillLocked
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,13 +43,16 @@ pub fn close_voter<'key, 'accounts, 'remaining, 'info>(
|
|||
let amount = voter.deposits.iter().fold(0u64, |sum, d| {
|
||||
sum.checked_add(d.amount_deposited_native).unwrap()
|
||||
});
|
||||
require!(amount == 0, VotingTokenNonZero);
|
||||
require!(amount == 0, VsrError::VotingTokenNonZero);
|
||||
|
||||
let voter_seeds = voter_seeds!(voter);
|
||||
for account in &mut ctx.remaining_accounts.iter() {
|
||||
let token = Account::<TokenAccount>::try_from(&account.clone()).unwrap();
|
||||
require!(token.owner == ctx.accounts.voter.key(), InvalidAuthority);
|
||||
require!(token.amount == 0, VaultTokenNonZero);
|
||||
require!(
|
||||
token.owner == ctx.accounts.voter.key(),
|
||||
VsrError::InvalidAuthority
|
||||
);
|
||||
require!(token.amount == 0, VsrError::VaultTokenNonZero);
|
||||
|
||||
let cpi_accounts = CloseAccount {
|
||||
account: account.to_account_info(),
|
||||
|
|
|
@ -78,22 +78,28 @@ pub fn configure_voting_mint(
|
|||
lockup_saturation_secs: u64,
|
||||
grant_authority: Option<Pubkey>,
|
||||
) -> Result<()> {
|
||||
require!(lockup_saturation_secs > 0, LockupSaturationMustBePositive);
|
||||
require!(
|
||||
lockup_saturation_secs > 0,
|
||||
VsrError::LockupSaturationMustBePositive
|
||||
);
|
||||
let registrar = &mut ctx.accounts.registrar.load_mut()?;
|
||||
let mint = ctx.accounts.mint.key();
|
||||
let idx = idx as usize;
|
||||
require!(
|
||||
idx < registrar.voting_mints.len(),
|
||||
OutOfBoundsVotingMintConfigIndex
|
||||
VsrError::OutOfBoundsVotingMintConfigIndex
|
||||
);
|
||||
|
||||
// Either it's reconfiguring an existing mint with the correct index,
|
||||
// or configuring a new mint on an unused index.
|
||||
match registrar.voting_mint_config_index(mint) {
|
||||
Ok(existing_idx) => require!(existing_idx == idx, VotingMintConfiguredWithDifferentIndex),
|
||||
Ok(existing_idx) => require!(
|
||||
existing_idx == idx,
|
||||
VsrError::VotingMintConfiguredWithDifferentIndex
|
||||
),
|
||||
Err(_) => require!(
|
||||
!registrar.voting_mints[idx].in_use(),
|
||||
VotingMintConfigIndexAlreadyInUse
|
||||
VsrError::VotingMintConfigIndexAlreadyInUse
|
||||
),
|
||||
};
|
||||
|
||||
|
|
|
@ -74,10 +74,10 @@ pub fn create_deposit_entry(
|
|||
// Get and set up the deposit entry.
|
||||
require!(
|
||||
voter.deposits.len() > deposit_entry_index as usize,
|
||||
OutOfBoundsDepositEntryIndex
|
||||
VsrError::OutOfBoundsDepositEntryIndex
|
||||
);
|
||||
let d_entry = &mut voter.deposits[deposit_entry_index as usize];
|
||||
require!(!d_entry.is_used, UnusedDepositEntryIndex);
|
||||
require!(!d_entry.is_used, VsrError::UnusedDepositEntryIndex);
|
||||
|
||||
let curr_ts = registrar.clock_unix_timestamp();
|
||||
let start_ts = if let Some(v) = start_ts {
|
||||
|
|
|
@ -6,14 +6,13 @@ use spl_governance::state::realm;
|
|||
use std::mem::size_of;
|
||||
|
||||
#[derive(Accounts)]
|
||||
#[instruction(registrar_bump: u8)]
|
||||
pub struct CreateRegistrar<'info> {
|
||||
/// The voting registrar. There can only be a single registrar
|
||||
/// per governance realm and governing mint.
|
||||
#[account(
|
||||
init,
|
||||
seeds = [realm.key().as_ref(), b"registrar".as_ref(), realm_governing_token_mint.key().as_ref()],
|
||||
bump = registrar_bump,
|
||||
bump,
|
||||
payer = payer,
|
||||
space = 8 + size_of::<Registrar>()
|
||||
)]
|
||||
|
@ -65,7 +64,7 @@ pub fn create_registrar(ctx: Context<CreateRegistrar>, registrar_bump: u8) -> Re
|
|||
)?;
|
||||
require!(
|
||||
realm.authority.unwrap() == ctx.accounts.realm_authority.key(),
|
||||
ErrorCode::InvalidRealmAuthority
|
||||
VsrError::InvalidRealmAuthority
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -5,14 +5,13 @@ use anchor_lang::solana_program::sysvar::instructions as tx_instructions;
|
|||
use std::mem::size_of;
|
||||
|
||||
#[derive(Accounts)]
|
||||
#[instruction(voter_bump: u8, voter_weight_record_bump: u8)]
|
||||
pub struct CreateVoter<'info> {
|
||||
pub registrar: AccountLoader<'info, Registrar>,
|
||||
|
||||
#[account(
|
||||
init,
|
||||
seeds = [registrar.key().as_ref(), b"voter".as_ref(), voter_authority.key().as_ref()],
|
||||
bump = voter_bump,
|
||||
bump,
|
||||
payer = payer,
|
||||
space = 8 + size_of::<Voter>(),
|
||||
)]
|
||||
|
@ -28,7 +27,7 @@ pub struct CreateVoter<'info> {
|
|||
#[account(
|
||||
init,
|
||||
seeds = [registrar.key().as_ref(), b"voter-weight-record".as_ref(), voter_authority.key().as_ref()],
|
||||
bump = voter_weight_record_bump,
|
||||
bump,
|
||||
payer = payer,
|
||||
space = size_of::<VoterWeightRecord>(),
|
||||
)]
|
||||
|
@ -63,7 +62,7 @@ pub fn create_voter(
|
|||
let current_ixn = tx_instructions::load_instruction_at_checked(current_index, &ixns)?;
|
||||
require!(
|
||||
current_ixn.program_id == *ctx.program_id,
|
||||
ErrorCode::ForbiddenCpi
|
||||
VsrError::ForbiddenCpi
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ pub fn deposit(ctx: Context<Deposit>, deposit_entry_index: u8, amount: u64) -> R
|
|||
let mint_idx = registrar.voting_mint_config_index(ctx.accounts.deposit_token.mint)?;
|
||||
require!(
|
||||
mint_idx == d_entry.voting_mint_config_idx as usize,
|
||||
InvalidMint
|
||||
VsrError::InvalidMint
|
||||
);
|
||||
|
||||
// Adding funds to a lockup that is already in progress can be complicated
|
||||
|
|
|
@ -7,22 +7,13 @@ use std::convert::TryFrom;
|
|||
use std::mem::size_of;
|
||||
|
||||
#[derive(Accounts)]
|
||||
#[instruction(
|
||||
voter_bump: u8,
|
||||
voter_weight_record_bump: u8,
|
||||
kind: LockupKind,
|
||||
start_ts: Option<u64>,
|
||||
periods: u32,
|
||||
allow_clawback: bool,
|
||||
amount: u64,
|
||||
)]
|
||||
pub struct Grant<'info> {
|
||||
pub registrar: AccountLoader<'info, Registrar>,
|
||||
|
||||
#[account(
|
||||
init_if_needed,
|
||||
seeds = [registrar.key().as_ref(), b"voter".as_ref(), voter_authority.key().as_ref()],
|
||||
bump = voter_bump,
|
||||
bump,
|
||||
payer = payer,
|
||||
space = 8 + size_of::<Voter>(),
|
||||
)]
|
||||
|
@ -37,7 +28,7 @@ pub struct Grant<'info> {
|
|||
#[account(
|
||||
init_if_needed,
|
||||
seeds = [registrar.key().as_ref(), b"voter-weight-record".as_ref(), voter_authority.key().as_ref()],
|
||||
bump = voter_weight_record_bump,
|
||||
bump,
|
||||
payer = payer,
|
||||
space = size_of::<VoterWeightRecord>(),
|
||||
)]
|
||||
|
@ -130,7 +121,7 @@ pub fn grant(
|
|||
grant_authority == registrar.realm_authority
|
||||
|| grant_authority == mint_config.grant_authority
|
||||
|| grant_authority == voter_authority,
|
||||
InvalidAuthority
|
||||
VsrError::InvalidAuthority
|
||||
);
|
||||
|
||||
// Init the voter if it hasn't been already.
|
||||
|
@ -162,7 +153,7 @@ pub fn grant(
|
|||
.deposits
|
||||
.iter()
|
||||
.position(|d_entry| !d_entry.is_used)
|
||||
.ok_or(ErrorCode::DepositEntryFull)?;
|
||||
.ok_or(VsrError::DepositEntryFull)?;
|
||||
let d_entry = &mut voter.deposits[free_entry_idx];
|
||||
|
||||
let curr_ts = registrar.clock_unix_timestamp();
|
||||
|
|
|
@ -49,12 +49,15 @@ pub fn internal_transfer_locked(
|
|||
|
||||
// Allowing transfers from clawback-enabled deposits could be used to avoid
|
||||
// clawback by making proposal instructions target the wrong entry index.
|
||||
require!(!source.allow_clawback, InvalidChangeToClawbackDepositEntry);
|
||||
require!(
|
||||
!source.allow_clawback,
|
||||
VsrError::InvalidChangeToClawbackDepositEntry
|
||||
);
|
||||
|
||||
// Reduce source amounts
|
||||
require!(
|
||||
amount <= source.amount_initially_locked_native,
|
||||
InsufficientLockedTokens
|
||||
VsrError::InsufficientLockedTokens
|
||||
);
|
||||
source.amount_deposited_native = source.amount_deposited_native.checked_sub(amount).unwrap();
|
||||
source.amount_initially_locked_native =
|
||||
|
@ -65,15 +68,15 @@ pub fn internal_transfer_locked(
|
|||
target.resolve_vesting(curr_ts)?;
|
||||
require!(
|
||||
target.voting_mint_config_idx == source_mint_idx,
|
||||
InvalidMint
|
||||
VsrError::InvalidMint
|
||||
);
|
||||
require!(
|
||||
target.lockup.seconds_left(curr_ts) >= source_seconds_left,
|
||||
InvalidLockupPeriod
|
||||
VsrError::InvalidLockupPeriod
|
||||
);
|
||||
require!(
|
||||
target.lockup.kind.strictness() >= source_strictness,
|
||||
InvalidLockupKind
|
||||
VsrError::InvalidLockupKind
|
||||
);
|
||||
|
||||
// Add target amounts
|
||||
|
|
|
@ -41,7 +41,7 @@ pub fn internal_transfer_unlocked(
|
|||
// Reduce source amounts
|
||||
require!(
|
||||
amount <= source.amount_unlocked(curr_ts),
|
||||
InsufficientUnlockedTokens
|
||||
VsrError::InsufficientUnlockedTokens
|
||||
);
|
||||
source.amount_deposited_native = source.amount_deposited_native.checked_sub(amount).unwrap();
|
||||
|
||||
|
@ -49,7 +49,7 @@ pub fn internal_transfer_unlocked(
|
|||
let target = voter.active_deposit_mut(target_deposit_entry_index)?;
|
||||
require!(
|
||||
target.voting_mint_config_idx == source_mint_idx,
|
||||
InvalidMint
|
||||
VsrError::InvalidMint
|
||||
);
|
||||
|
||||
// Add target amounts
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::error::*;
|
||||
use crate::events::*;
|
||||
use crate::state::*;
|
||||
use anchor_lang::prelude::*;
|
||||
|
|
|
@ -37,15 +37,18 @@ pub fn reset_lockup(
|
|||
require!(
|
||||
(periods as u64).checked_mul(kind.period_secs()).unwrap()
|
||||
>= source.lockup.seconds_left(curr_ts),
|
||||
InvalidLockupPeriod
|
||||
VsrError::InvalidLockupPeriod
|
||||
);
|
||||
require!(
|
||||
kind.strictness() >= source.lockup.kind.strictness(),
|
||||
InvalidLockupKind
|
||||
VsrError::InvalidLockupKind
|
||||
);
|
||||
|
||||
// Don't re-lock clawback deposits. Users must withdraw and create a new one.
|
||||
require!(!source.allow_clawback, InvalidChangeToClawbackDepositEntry);
|
||||
require!(
|
||||
!source.allow_clawback,
|
||||
VsrError::InvalidChangeToClawbackDepositEntry
|
||||
);
|
||||
|
||||
// Change the deposit entry.
|
||||
let d_entry = voter.active_deposit_mut(deposit_entry_index)?;
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn set_time_offset(ctx: Context<SetTimeOffset>, time_offset: i64) -> Result<
|
|||
let registrar = &mut ctx.accounts.registrar.load_mut()?;
|
||||
require!(
|
||||
registrar.governance_program_id == allowed_program,
|
||||
ErrorCode::DebugInstruction
|
||||
VsrError::DebugInstruction
|
||||
);
|
||||
registrar.time_offset = time_offset;
|
||||
Ok(())
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::error::*;
|
||||
use crate::state::*;
|
||||
use anchor_lang::prelude::*;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::error::*;
|
||||
use crate::state::*;
|
||||
use anchor_lang::prelude::*;
|
||||
|
||||
|
|
|
@ -105,17 +105,17 @@ pub fn withdraw(ctx: Context<Withdraw>, deposit_entry_index: u8, amount: u64) ->
|
|||
let deposit_entry = voter.active_deposit_mut(deposit_entry_index)?;
|
||||
require!(
|
||||
deposit_entry.amount_unlocked(curr_ts) >= amount,
|
||||
InsufficientUnlockedTokens
|
||||
VsrError::InsufficientUnlockedTokens
|
||||
);
|
||||
require!(
|
||||
mint_idx == deposit_entry.voting_mint_config_idx as usize,
|
||||
ErrorCode::InvalidMint
|
||||
VsrError::InvalidMint
|
||||
);
|
||||
|
||||
// Bookkeeping for withdrawn funds.
|
||||
require!(
|
||||
amount <= deposit_entry.amount_deposited_native,
|
||||
InternalProgramError
|
||||
VsrError::InternalProgramError
|
||||
);
|
||||
deposit_entry.amount_deposited_native = deposit_entry
|
||||
.amount_deposited_native
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use anchor_lang::prelude::*;
|
||||
use error::*;
|
||||
use instructions::*;
|
||||
use state::*;
|
||||
|
||||
|
|
|
@ -95,11 +95,11 @@ impl DepositEntry {
|
|||
)?;
|
||||
require!(
|
||||
locked_vote_weight <= max_locked_vote_weight,
|
||||
InternalErrorBadLockupVoteWeight
|
||||
VsrError::InternalErrorBadLockupVoteWeight
|
||||
);
|
||||
baseline_vote_weight
|
||||
.checked_add(locked_vote_weight)
|
||||
.ok_or(Error::ErrorCode(ErrorCode::VoterWeightOverflow))
|
||||
.ok_or_else(|| error!(VsrError::VoterWeightOverflow))
|
||||
}
|
||||
|
||||
/// Vote power contribution from locked funds only.
|
||||
|
@ -364,14 +364,14 @@ impl DepositEntry {
|
|||
let vested_amount = self.vested(curr_ts)?;
|
||||
require!(
|
||||
vested_amount <= self.amount_initially_locked_native,
|
||||
InternalProgramError
|
||||
VsrError::InternalProgramError
|
||||
);
|
||||
self.amount_initially_locked_native = self
|
||||
.amount_initially_locked_native
|
||||
.checked_sub(vested_amount)
|
||||
.unwrap();
|
||||
self.lockup.remove_past_periods(curr_ts)?;
|
||||
require!(self.vested(curr_ts)? == 0, InternalProgramError);
|
||||
require!(self.vested(curr_ts)? == 0, VsrError::InternalProgramError);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,9 +70,9 @@ impl Lockup {
|
|||
) -> Result<Self> {
|
||||
require!(
|
||||
start_ts < curr_ts + MAX_LOCKUP_IN_FUTURE_SECS,
|
||||
DepositStartTooFarInFuture
|
||||
VsrError::DepositStartTooFarInFuture
|
||||
);
|
||||
require!(periods <= MAX_LOCKUP_PERIODS, InvalidLockupPeriod);
|
||||
require!(periods <= MAX_LOCKUP_PERIODS, VsrError::InvalidLockupPeriod);
|
||||
Ok(Self {
|
||||
kind,
|
||||
start_ts,
|
||||
|
@ -138,7 +138,10 @@ impl Lockup {
|
|||
}
|
||||
|
||||
let lockup_secs = self.seconds_left(self.start_ts);
|
||||
require!(lockup_secs % period_secs == 0, InvalidLockupPeriod);
|
||||
require!(
|
||||
lockup_secs % period_secs == 0,
|
||||
VsrError::InvalidLockupPeriod
|
||||
);
|
||||
|
||||
Ok(lockup_secs.checked_div(period_secs).unwrap())
|
||||
}
|
||||
|
@ -151,8 +154,11 @@ impl Lockup {
|
|||
.start_ts
|
||||
.checked_add(i64::try_from(periods.checked_mul(period_secs).unwrap()).unwrap())
|
||||
.unwrap();
|
||||
require!(self.start_ts <= self.end_ts, InternalProgramError);
|
||||
require!(self.period_current(curr_ts)? == 0, InternalProgramError);
|
||||
require!(self.start_ts <= self.end_ts, VsrError::InternalProgramError);
|
||||
require!(
|
||||
self.period_current(curr_ts)? == 0,
|
||||
VsrError::InternalProgramError
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ impl Registrar {
|
|||
self.voting_mints
|
||||
.iter()
|
||||
.position(|r| r.mint == mint)
|
||||
.ok_or(Error::ErrorCode(ErrorCode::VotingMintNotFound))
|
||||
.ok_or_else(|| error!(VsrError::VotingMintNotFound))
|
||||
}
|
||||
|
||||
pub fn max_vote_weight(&self, mint_accounts: &[AccountInfo]) -> Result<u64> {
|
||||
|
@ -52,14 +52,14 @@ impl Registrar {
|
|||
let mint_account = mint_accounts
|
||||
.iter()
|
||||
.find(|a| a.key() == voting_mint_config.mint)
|
||||
.ok_or(Error::ErrorCode(ErrorCode::VotingMintNotFound))?;
|
||||
.ok_or_else(|| error!(VsrError::VotingMintNotFound))?;
|
||||
let mint = Account::<Mint>::try_from(mint_account)?;
|
||||
sum = sum
|
||||
.checked_add(voting_mint_config.baseline_vote_weight(mint.supply)?)
|
||||
.ok_or(Error::ErrorCode(ErrorCode::VoterWeightOverflow))?;
|
||||
.ok_or_else(|| error!(VsrError::VoterWeightOverflow))?;
|
||||
sum = sum
|
||||
.checked_add(voting_mint_config.max_extra_lockup_vote_weight(mint.supply)?)
|
||||
.ok_or(Error::ErrorCode(ErrorCode::VoterWeightOverflow))?;
|
||||
.ok_or_else(|| error!(VsrError::VoterWeightOverflow))?;
|
||||
Ok(sum)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ impl Voter {
|
|||
curr_ts: i64,
|
||||
at_ts: i64,
|
||||
) -> Result<u64> {
|
||||
require!(at_ts >= curr_ts, InvalidTimestampArguments);
|
||||
require!(at_ts >= curr_ts, VsrError::InvalidTimestampArguments);
|
||||
self.deposits
|
||||
.iter()
|
||||
.filter(|d| d.is_used)
|
||||
|
@ -73,9 +73,12 @@ impl Voter {
|
|||
|
||||
pub fn active_deposit_mut(&mut self, index: u8) -> Result<&mut DepositEntry> {
|
||||
let index = index as usize;
|
||||
require!(index < self.deposits.len(), OutOfBoundsDepositEntryIndex);
|
||||
require!(
|
||||
index < self.deposits.len(),
|
||||
VsrError::OutOfBoundsDepositEntryIndex
|
||||
);
|
||||
let d = &mut self.deposits[index];
|
||||
require!(d.is_used, UnusedDepositEntryIndex);
|
||||
require!(d.is_used, VsrError::UnusedDepositEntryIndex);
|
||||
Ok(d)
|
||||
}
|
||||
|
||||
|
@ -92,7 +95,7 @@ impl Voter {
|
|||
)?;
|
||||
require!(
|
||||
record.governing_token_owner == self.voter_authority,
|
||||
InvalidTokenOwnerRecord
|
||||
VsrError::InvalidTokenOwnerRecord
|
||||
);
|
||||
Ok(record)
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ impl VotingMintConfig {
|
|||
};
|
||||
u64::try_from(val).ok()
|
||||
};
|
||||
compute().ok_or(Error::ErrorCode(ErrorCode::VoterWeightOverflow))
|
||||
compute().ok_or_else(|| error!(VsrError::VoterWeightOverflow))
|
||||
}
|
||||
|
||||
/// Apply a factor in SCALED_FACTOR_BASE units.
|
||||
|
@ -71,7 +71,7 @@ impl VotingMintConfig {
|
|||
)
|
||||
.ok()
|
||||
};
|
||||
compute().ok_or(Error::ErrorCode(ErrorCode::VoterWeightOverflow))
|
||||
compute().ok_or_else(|| error!(VsrError::VoterWeightOverflow))
|
||||
}
|
||||
|
||||
/// The vote weight a deposit of a number of native tokens should have.
|
||||
|
|
|
@ -46,9 +46,14 @@ impl AddPacked for ProgramTest {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
pub struct ProgramOutput {
|
||||
pub logs: Vec<String>,
|
||||
pub data: Vec<String>,
|
||||
}
|
||||
struct LoggerWrapper {
|
||||
inner: env_logger::Logger,
|
||||
program_log: Arc<RwLock<Vec<String>>>,
|
||||
output: Arc<RwLock<ProgramOutput>>,
|
||||
}
|
||||
|
||||
impl Log for LoggerWrapper {
|
||||
|
@ -63,7 +68,9 @@ impl Log for LoggerWrapper {
|
|||
{
|
||||
let msg = record.args().to_string();
|
||||
if let Some(data) = msg.strip_prefix("Program log: ") {
|
||||
self.program_log.write().unwrap().push(data.into());
|
||||
self.output.write().unwrap().logs.push(data.into());
|
||||
} else if let Some(data) = msg.strip_prefix("Program data: ") {
|
||||
self.output.write().unwrap().data.push(data.into());
|
||||
}
|
||||
}
|
||||
self.inner.log(record);
|
||||
|
@ -92,10 +99,10 @@ impl TestContext {
|
|||
env_logger::Builder::from_env(env_logger::Env::new().default_filter_or(log_filter))
|
||||
.format_timestamp_nanos()
|
||||
.build();
|
||||
let program_log_capture = Arc::new(RwLock::new(vec![]));
|
||||
let program_output = Arc::new(RwLock::new(ProgramOutput::default()));
|
||||
let _ = log::set_boxed_logger(Box::new(LoggerWrapper {
|
||||
inner: env_logger,
|
||||
program_log: program_log_capture.clone(),
|
||||
output: program_output.clone(),
|
||||
}));
|
||||
|
||||
let addin_program_id = voter_stake_registry::id();
|
||||
|
@ -209,7 +216,7 @@ impl TestContext {
|
|||
let solana = Arc::new(SolanaCookie {
|
||||
context: RefCell::new(context),
|
||||
rent,
|
||||
program_log: program_log_capture.clone(),
|
||||
program_output: program_output.clone(),
|
||||
});
|
||||
|
||||
TestContext {
|
||||
|
|
|
@ -18,7 +18,7 @@ use spl_token::*;
|
|||
pub struct SolanaCookie {
|
||||
pub context: RefCell<ProgramTestContext>,
|
||||
pub rent: Rent,
|
||||
pub program_log: Arc<RwLock<Vec<String>>>,
|
||||
pub program_output: Arc<RwLock<super::ProgramOutput>>,
|
||||
}
|
||||
|
||||
impl SolanaCookie {
|
||||
|
@ -28,7 +28,7 @@ impl SolanaCookie {
|
|||
instructions: &[Instruction],
|
||||
signers: Option<&[&Keypair]>,
|
||||
) -> Result<(), TransportError> {
|
||||
self.program_log.write().unwrap().clear();
|
||||
*self.program_output.write().unwrap() = super::ProgramOutput::default();
|
||||
|
||||
let mut context = self.context.borrow_mut();
|
||||
|
||||
|
@ -127,7 +127,7 @@ impl SolanaCookie {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn program_log(&self) -> Vec<String> {
|
||||
self.program_log.read().unwrap().clone()
|
||||
pub fn program_output(&self) -> super::ProgramOutput {
|
||||
self.program_output.read().unwrap().clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,12 +109,11 @@ async fn test_log_voter_info() -> Result<(), TransportError> {
|
|||
context.solana.advance_clock_by_slots(2).await;
|
||||
|
||||
addin.log_voter_info(®istrar, &voter, 0).await;
|
||||
let log = context.solana.program_log();
|
||||
assert_eq!(log[1], "voter");
|
||||
assert_eq!(log[3], "deposit_entries");
|
||||
let data_log = context.solana.program_output().data;
|
||||
assert_eq!(data_log.len(), 2);
|
||||
|
||||
let voter_event =
|
||||
deserialize_event::<voter_stake_registry::events::VoterInfo>(&log[2]).unwrap();
|
||||
deserialize_event::<voter_stake_registry::events::VoterInfo>(&data_log[0]).unwrap();
|
||||
assert_eq!(voter_event.voting_power_baseline, 12000);
|
||||
assert_eq!(
|
||||
voter_event.voting_power,
|
||||
|
@ -122,7 +121,7 @@ async fn test_log_voter_info() -> Result<(), TransportError> {
|
|||
);
|
||||
|
||||
let deposit_event =
|
||||
deserialize_event::<voter_stake_registry::events::DepositEntryInfo>(&log[4]).unwrap();
|
||||
deserialize_event::<voter_stake_registry::events::DepositEntryInfo>(&data_log[1]).unwrap();
|
||||
assert_eq!(deposit_event.deposit_entry_index, 0);
|
||||
assert_eq!(deposit_event.voting_mint_config_index, 0);
|
||||
assert_eq!(deposit_event.unlocked, 1000);
|
||||
|
|
Loading…
Reference in New Issue