diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..f31de6c --- /dev/null +++ b/.cargo/config @@ -0,0 +1,3 @@ +[alias] +wasm = "build --release --target wasm32-unknown-unknown" +unit-test = "test --lib" diff --git a/.gitignore b/.gitignore index eca2c7c..4b75762 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ artifacts/ # Data and key files scripts/data/ scripts/keys/ + +# Misc notes +notes.txt diff --git a/Cargo.lock b/Cargo.lock index 28c993d..b54699a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,24 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" + [[package]] name = "block-buffer" version = "0.9.0" @@ -31,37 +43,37 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" [[package]] name = "cosmwasm-crypto" -version = "0.16.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b110e31d47bd265e17ec88dd7328fcf40e1ee67a6131c1ab492f77fef8cd83" +checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd" dependencies = [ "digest", "ed25519-zebra", "k256", - "rand_core 0.5.1", + "rand_core 0.6.3", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "0.16.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0faf9bad5eb0a43a00406e64f8d33407a06bd1826fa976195a69db70e6c18d9d" +checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4" dependencies = [ "syn", ] [[package]] name = "cosmwasm-std" -version = "0.16.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0d4e46ab20939af6366a71783324ae4babdedb111f0dd797d063a2e68718bc" +checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195" dependencies = [ "base64", "cosmwasm-crypto", @@ -91,9 +103,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.2.11" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" dependencies = [ "generic-array", "rand_core 0.6.3", @@ -126,9 +138,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "0.9.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e401ed71bd64abb9b91151a9ff4f7b34e81b2b3eceab23e3cb67fe47e39938" +checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a" dependencies = [ "cosmwasm-std", "schemars", @@ -136,10 +148,10 @@ dependencies = [ ] [[package]] -name = "cw0" -version = "0.9.1" +name = "cw-utils" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d759bb5418a3bdf091e1f1be17de2a15d95d2be4fee28045c2e461f4c6d9d1ca" +checksum = "9dbaecb78c8e8abfd6b4258c7f4fbeb5c49a5e45ee4d910d3240ee8e1d714e1b" dependencies = [ "cosmwasm-std", "schemars", @@ -149,9 +161,9 @@ dependencies = [ [[package]] name = "cw2" -version = "0.9.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6380164fb236412ff43c7ca075d95847c6fa8c51b2d3a513c23127a0f2a8f6" +checksum = "04cf4639517490dd36b333bbd6c4fbd92e325fd0acf4683b41753bc5eb63bfc1" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -161,25 +173,25 @@ dependencies = [ [[package]] name = "cw20" -version = "0.9.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac49b013ca1e355fd988cc1926acc9a16d7fd45cfb595ee330455582a788b100" +checksum = "4cb782b8f110819a4eb5dbbcfed25ffba49ec16bbe32b4ad8da50a5ce68fec05" dependencies = [ "cosmwasm-std", - "cw0", + "cw-utils", "schemars", "serde", ] [[package]] name = "cw20-base" -version = "0.9.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b731a291b63cc26d484b159e8469f0965b0082a20e874616f869537b31d64bb" +checksum = "0306e606581f4fb45e82bcbb7f0333179ed53dd949c6523f01a99b4bfc1475a0" dependencies = [ "cosmwasm-std", "cw-storage-plus", - "cw0", + "cw-utils", "cw2", "cw20", "schemars", @@ -189,9 +201,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ "const-oid", ] @@ -213,51 +225,54 @@ checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" dependencies = [ "der", "elliptic-curve", - "hmac", + "rfc6979", "signature", ] [[package]] name = "ed25519-zebra" -version = "2.2.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a128b76af6dd4b427e34a6fd43dc78dbfe73672ec41ff615a2414c1a0ad0409" +checksum = "403ef3e961ab98f0ba902771d29f842058578bb1ce7e3c59dad5a6a93e784c69" dependencies = [ "curve25519-dalek", "hex", - "rand_core 0.5.1", + "rand_core 0.6.3", "serde", "sha2", "thiserror", + "zeroize", ] [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" dependencies = [ + "base16ct", "crypto-bigint", + "der", "ff", "generic-array", "group", - "pkcs8", "rand_core 0.6.3", + "sec1", "subtle", "zeroize", ] [[package]] name = "ff" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" dependencies = [ "rand_core 0.6.3", "subtle", @@ -303,9 +318,9 @@ dependencies = [ [[package]] name = "group" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" dependencies = [ "ff", "rand_core 0.6.3", @@ -336,13 +351,14 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "k256" -version = "0.9.6" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "sec1", "sha2", ] @@ -360,12 +376,13 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ "der", "spki", + "zeroize", ] [[package]] @@ -404,6 +421,17 @@ dependencies = [ "getrandom 0.2.6", ] +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + [[package]] name = "ryu" version = "1.0.9" @@ -434,6 +462,19 @@ dependencies = [ "syn", ] +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "serde" version = "1.0.136" @@ -445,9 +486,9 @@ dependencies = [ [[package]] name = "serde-json-wasm" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "042ac496d97e5885149d34139bad1d617192770d7eb8f1866da2317ff4501853" +checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" dependencies = [ "serde", ] @@ -510,10 +551,11 @@ dependencies = [ [[package]] name = "spki" -version = "0.4.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ + "base64ct", "der", ] @@ -525,18 +567,17 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "steak" -version = "1.0.0" +version = "2.0.0" dependencies = [ "cosmwasm-std", "cw20", "schemars", "serde", - "terra-cosmwasm", ] [[package]] name = "steak-hub" -version = "1.0.0" +version = "2.0.0" dependencies = [ "cosmwasm-std", "cw-storage-plus", @@ -544,12 +585,11 @@ dependencies = [ "cw20-base", "serde", "steak", - "terra-cosmwasm", ] [[package]] name = "steak-token" -version = "1.0.0" +version = "2.0.0" dependencies = [ "cosmwasm-std", "cw20", @@ -573,17 +613,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "terra-cosmwasm" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552f18cba2b535d1f8c0e3b3f37696820b954bc7535d2e33909f2a6342302718" -dependencies = [ - "cosmwasm-std", - "schemars", - "serde", -] - [[package]] name = "thiserror" version = "1.0.30" diff --git a/README.md b/README.md index c29f369..ac96c10 100644 --- a/README.md +++ b/README.md @@ -13,23 +13,41 @@ A previous version ([v1.0.0-rc0](https://github.com/st4k3h0us3/steak-contracts/r ## Deployment -### Mainnet +### Mainnet (phoenix-1) -| Contract | Address | -| ------------------- | ---------------------------------------------- | -| Steak Hub | [`terra15qr8ev2c0a0jswjtfrhfaj5ucgkhjd7la2shlg`](https://terrasco.pe/mainnet/address/terra15qr8ev2c0a0jswjtfrhfaj5ucgkhjd7la2shlg) | -| Steak Token | [`terra1rl4zyexjphwgx6v3ytyljkkc4mrje2pyznaclv`](https://terrasco.pe/mainnet/address/terra1rl4zyexjphwgx6v3ytyljkkc4mrje2pyznaclv) | -| STEAK-LUNA Pair | [`terra14q0cgunptuym048a4y2awt8a7fl9acudmfzk5e`](https://terrasco.pe/mainnet/address/terra14q0cgunptuym048a4y2awt8a7fl9acudmfzk5e) | -| STEAK-LUNA LP Token | [`terra1pwc77c6a588cualln2uypyyvg5r76tfaazgk62`](https://terrasco.pe/mainnet/address/terra1pwc77c6a588cualln2uypyyvg5r76tfaazgk62) | +| Contract | Address | +| ------------------- | --------- | +| Steak Hub | [`tbd`]() | +| Steak Token | [`tbd`]() | +| STEAK-LUNA Pair | [`tbd`]() | +| STEAK-LUNA LP Token | [`tbd`]() | + +### Testnet (pisco-1) + +| Contract | Address | +| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Steak Hub | [`terra1lm7d4zr97rzp3a22szdv6ucpeyckyl2l2wh6jc9qrga78eyrvamsjgs5q6`](https://finder.terra.money/testnet/address/terra1lm7d4zr97rzp3a22szdv6ucpeyckyl2l2wh6jc9qrga78eyrvamsjgs5q6) | +| Steak Token | [`terra1q02glqy2gcl9kavshhh9tzr3l7cjwjwk7mhatd9h9nc243gq73esdat6wj`](https://finder.terra.money/testnet/address/terra1q02glqy2gcl9kavshhh9tzr3l7cjwjwk7mhatd9h9nc243gq73esdat6wj) | +| STEAK-LUNA Pair | [`tbd`]() | +| STEAK-LUNA LP Token | [`tbd`]() | + +### Classic mainnet (columbus-5) + +| Contract | Address | +| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | +| Steak Hub | [`terra15qr8ev2c0a0jswjtfrhfaj5ucgkhjd7la2shlg`](https://finder.terra.money/classic/address/terra15qr8ev2c0a0jswjtfrhfaj5ucgkhjd7la2shlg) | +| Steak Token | [`terra1rl4zyexjphwgx6v3ytyljkkc4mrje2pyznaclv`](https://finder.terra.money/classic/address/terra1rl4zyexjphwgx6v3ytyljkkc4mrje2pyznaclv) | +| STEAK-LUNA Pair | [`terra14q0cgunptuym048a4y2awt8a7fl9acudmfzk5e`](https://finder.terra.money/classic/address/terra14q0cgunptuym048a4y2awt8a7fl9acudmfzk5e) | +| STEAK-LUNA LP Token | [`terra1pwc77c6a588cualln2uypyyvg5r76tfaazgk62`](https://finder.terra.money/classic/address/terra1pwc77c6a588cualln2uypyyvg5r76tfaazgk62) | -### Testnet +### Classic testnet (bombay-12) | Contract | Address | | ------------------- | ---------------------------------------------- | -| Steak Hub | [`terra1xshrfs3lp7nwkdfh3067vfsf3kmweygfsc3hzy`](https://terrasco.pe/testnet/address/terra1xshrfs3lp7nwkdfh3067vfsf3kmweygfsc3hzy) | -| Steak Token | [`terra1awhvtkm553rszxtvnuda4fe2r6rjjj7hjwzv0w`](https://terrasco.pe/testnet/address/terra1awhvtkm553rszxtvnuda4fe2r6rjjj7hjwzv0w) | -| STEAK-LUNA Pair | [`terra1x3tyfme7y84mv3y6ftugllrln5y7ewhf36davz`](https://terrasco.pe/testnet/address/terra1x3tyfme7y84mv3y6ftugllrln5y7ewhf36davz) | -| STEAK-LUNA LP Token | [`terra1exla7lyc8g85szpntmcs5f2rvvg5gwwn7jekje`](https://terrasco.pe/testnet/address/terra1exla7lyc8g85szpntmcs5f2rvvg5gwwn7jekje) | +| Steak Hub | `terra1xshrfs3lp7nwkdfh3067vfsf3kmweygfsc3hzy` | +| Steak Token | `terra1awhvtkm553rszxtvnuda4fe2r6rjjj7hjwzv0w` | +| STEAK-LUNA Pair | `terra1x3tyfme7y84mv3y6ftugllrln5y7ewhf36davz` | +| STEAK-LUNA LP Token | `terra1exla7lyc8g85szpntmcs5f2rvvg5gwwn7jekje` | ## License diff --git a/contracts/hub/Cargo.toml b/contracts/hub/Cargo.toml index 730aea1..84415c0 100644 --- a/contracts/hub/Cargo.toml +++ b/contracts/hub/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "steak-hub" -version = "1.0.0" -authors = ["larry "] +version = "2.0.0" +authors = ["larry ", "PFC "] edition = "2018" license = "GPL-3.0-or-later" repository = "https://github.com/st4k3h0us3/steak-contracts" @@ -13,12 +13,11 @@ crate-type = ["cdylib", "rlib"] backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-std = { version = "0.16", features = ["staking"] } -cw20 = "0.9" -cw20-base = { version = "0.9", features = ["library"] } -cw-storage-plus = "0.9" +cosmwasm-std = { version = "1.0", features = ["staking"] } +cw20 = "0.13" +cw20-base = { version = "0.13", features = ["library"] } +cw-storage-plus = "0.13" steak = { path = "../../packages/steak" } -terra-cosmwasm = "2.2" [dev-dependencies] serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/hub/src/contract.rs b/contracts/hub/src/contract.rs index da7859d..99c0943 100644 --- a/contracts/hub/src/contract.rs +++ b/contracts/hub/src/contract.rs @@ -3,7 +3,6 @@ use cosmwasm_std::{ StdError, StdResult, }; use cw20::Cw20ReceiveMsg; -use terra_cosmwasm::TerraMsgWrapper; use steak::hub::{CallbackMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, ReceiveMsg}; @@ -22,12 +21,7 @@ pub fn instantiate( } #[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { +pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> StdResult { let api = deps.api; match msg { ExecuteMsg::Receive(cw20_msg) => receive(deps, env, info, cw20_msg), @@ -70,7 +64,7 @@ fn receive( env: Env, info: MessageInfo, cw20_msg: Cw20ReceiveMsg, -) -> StdResult> { +) -> StdResult { let api = deps.api; match from_binary(&cw20_msg.msg)? { ReceiveMsg::QueueUnbond { @@ -81,7 +75,7 @@ fn receive( let steak_token = state.steak_token.load(deps.storage)?; if info.sender != steak_token { return Err(StdError::generic_err( - format!("expecting Steak token, received {}", info.sender) + format!("expecting Steak token, received {}", info.sender), )); } @@ -100,13 +94,12 @@ fn callback( env: Env, info: MessageInfo, callback_msg: CallbackMsg, -) -> StdResult> { +) -> StdResult { if env.contract.address != info.sender { return Err(StdError::generic_err("callbacks can only be invoked by the contract itself")); } match callback_msg { - CallbackMsg::Swap {} => execute::swap(deps), CallbackMsg::Reinvest {} => execute::reinvest(deps, env), } } @@ -115,23 +108,8 @@ fn callback( pub fn reply(deps: DepsMut, env: Env, reply: Reply) -> StdResult { match reply.id { 1 => execute::register_steak_token(deps, unwrap_reply(reply)?), - 2 => execute::register_received_coins( - deps, - env, - unwrap_reply(reply)?.events, - "coin_received", - "receiver", - "amount", - ), - 3 => execute::register_received_coins( - deps, - env, - unwrap_reply(reply)?.events, - "swap", - "recipient", - "swap_coin", - ), - id => Err(StdError::generic_err(format!("invalid reply id: {}; must be 1-3", id))), + 2 => execute::register_received_coins(deps, env, unwrap_reply(reply)?.events), + id => Err(StdError::generic_err(format!("invalid reply id: {}; must be 1-2", id))), } } @@ -160,6 +138,6 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { } #[entry_point] -pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult> { +pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { Ok(Response::new()) } diff --git a/contracts/hub/src/execute.rs b/contracts/hub/src/execute.rs index f50cc93..3964144 100644 --- a/contracts/hub/src/execute.rs +++ b/contracts/hub/src/execute.rs @@ -1,17 +1,15 @@ -use std::collections::HashSet; use std::str::FromStr; use cosmwasm_std::{ to_binary, Addr, BankMsg, Coin, CosmosMsg, DepsMut, DistributionMsg, Env, Event, Order, - Response, StdError, StdResult, SubMsg, SubMsgExecutionResponse, Uint128, WasmMsg, + Response, StdError, StdResult, SubMsg, SubMsgResponse, Uint128, WasmMsg, }; use cw20::{Cw20ExecuteMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg; -use terra_cosmwasm::{create_swap_msg, TerraMsgWrapper, TerraQuerier}; use steak::hub::{Batch, CallbackMsg, ExecuteMsg, InstantiateMsg, PendingBatch, UnbondRequest}; -use crate::helpers::{query_cw20_total_supply, query_delegations, query_delegation}; +use crate::helpers::{query_cw20_total_supply, query_delegation, query_delegations}; use crate::math::{ compute_mint_amount, compute_redelegations_for_rebalancing, compute_redelegations_for_removal, compute_unbond_amount, compute_undelegations, reconcile_batches, @@ -63,23 +61,20 @@ pub fn instantiate(deps: DepsMut, env: Env, msg: InstantiateMsg) -> StdResult StdResult { +pub fn register_steak_token(deps: DepsMut, response: SubMsgResponse) -> StdResult { let state = State::default(); let event = response .events .iter() - .find(|event| event.ty == "instantiate_contract") - .ok_or_else(|| StdError::generic_err("cannot find `instantiate_contract` event"))?; + .find(|event| event.ty == "instantiate") + .ok_or_else(|| StdError::generic_err("cannot find `instantiate` event"))?; let contract_addr_str = &event .attributes .iter() - .find(|attr| attr.key == "contract_address") - .ok_or_else(|| StdError::generic_err("cannot find `contract_address` attribute"))? + .find(|attr| attr.key == "_contract_address") + .ok_or_else(|| StdError::generic_err("cannot find `_contract_address` attribute"))? .value; let contract_addr = deps.api.addr_validate(contract_addr_str)?; @@ -105,7 +100,7 @@ pub fn bond( env: Env, receiver: Addr, uluna_to_bond: Uint128, -) -> StdResult> { +) -> StdResult { let state = State::default(); let steak_token = state.steak_token.load(deps.storage)?; let validators = state.validators.load(deps.storage)?; @@ -131,12 +126,9 @@ pub fn bond( let usteak_supply = query_cw20_total_supply(&deps.querier, &steak_token)?; let usteak_to_mint = compute_mint_amount(usteak_supply, uluna_to_bond, &delegations); - let delegate_submsg = SubMsg::reply_on_success( - new_delegation.to_cosmos_msg(), - 2, - ); + let delegate_submsg = SubMsg::reply_on_success(new_delegation.to_cosmos_msg(), 2); - let mint_msg: CosmosMsg = CosmosMsg::Wasm(WasmMsg::Execute { + let mint_msg: CosmosMsg = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: steak_token.into(), msg: to_binary(&Cw20ExecuteMsg::Mint { recipient: receiver.to_string(), @@ -159,7 +151,7 @@ pub fn bond( .add_attribute("action", "steakhub/bond")) } -pub fn harvest(deps: DepsMut, env: Env) -> StdResult> { +pub fn harvest(deps: DepsMut, env: Env) -> StdResult { let withdraw_submsgs = deps .querier .query_all_delegations(&env.contract.address)? @@ -174,62 +166,21 @@ pub fn harvest(deps: DepsMut, env: Env) -> StdResult> }) .collect::>(); - let callback_msgs = vec![CallbackMsg::Swap {}, CallbackMsg::Reinvest {}] - .iter() - .map(|callback| callback.into_cosmos_msg(&env.contract.address)) - .collect::>>()?; + let callback_msg = CallbackMsg::Reinvest {}.into_cosmos_msg(&env.contract.address)?; Ok(Response::new() .add_submessages(withdraw_submsgs) - .add_messages(callback_msgs) + .add_message(callback_msg) .add_attribute("action", "steakhub/harvest")) } -pub fn swap(deps: DepsMut) -> StdResult> { - let state = State::default(); - let mut unlocked_coins = state.unlocked_coins.load(deps.storage)?; - - let all_denoms = unlocked_coins - .iter() - .cloned() - .map(|coin| coin.denom) - .filter(|denom| denom != "uluna") - .collect::>(); - - let known_denoms = TerraQuerier::new(&deps.querier) - .query_exchange_rates("uluna".to_string(), all_denoms)? - .exchange_rates - .into_iter() - .map(|item| item.quote_denom) - .collect::>(); - - let swap_submsgs = unlocked_coins - .iter() - .cloned() - .filter(|coin| known_denoms.contains(&coin.denom)) - .map(|coin| { - SubMsg::reply_on_success( - create_swap_msg(coin, "uluna".to_string()), - 3, - ) - }) - .collect::>(); - - unlocked_coins.retain(|coin| !known_denoms.contains(&coin.denom)); - state.unlocked_coins.save(deps.storage, &unlocked_coins)?; - - Ok(Response::new() - .add_submessages(swap_submsgs) - .add_attribute("action", "steakhub/swap")) -} - /// NOTE: /// 1. When delegation Luna here, we don't need to use a `SubMsg` to handle the received coins, /// because we have already withdrawn all claimable staking rewards previously in the same atomic /// execution. /// 2. Same as with `bond`, in the latest implementation we only delegate staking rewards with the /// validator that has the smallest delegation amount. -pub fn reinvest(deps: DepsMut, env: Env) -> StdResult> { +pub fn reinvest(deps: DepsMut, env: Env) -> StdResult { let state = State::default(); let validators = state.validators.load(deps.storage)?; let mut unlocked_coins = state.unlocked_coins.load(deps.storage)?; @@ -265,23 +216,20 @@ pub fn reinvest(deps: DepsMut, env: Env) -> StdResult> .add_attribute("action", "steakhub/reinvest")) } -/// NOTE: a `SubMsgExecutionResponse` may contain multiple coin-receiving events, must handle them indivitually +/// NOTE: a `SubMsgResponse` may contain multiple coin-receiving events, must handle them individually pub fn register_received_coins( deps: DepsMut, env: Env, mut events: Vec, - event_type: &str, - receiver_key: &str, - received_coins_key: &str ) -> StdResult { - events.retain(|event| event.ty == event_type); + events.retain(|event| event.ty == "coin_received"); if events.is_empty() { return Ok(Response::new()); } let mut received_coins = Coins(vec![]); for event in &events { - received_coins.add_many(&parse_coin_receiving_event(&env, event, receiver_key, received_coins_key)?)?; + received_coins.add_many(&parse_coin_receiving_event(&env, event)?)?; } let state = State::default(); @@ -291,37 +239,31 @@ pub fn register_received_coins( Ok(coins.0) })?; - Ok(Response::new() - .add_attribute("action", "steakhub/register_received_coins")) + Ok(Response::new().add_attribute("action", "steakhub/register_received_coins")) } -fn parse_coin_receiving_event( - env: &Env, - event: &Event, - receiver_key: &str, - received_coins_key: &str -) -> StdResult { +fn parse_coin_receiving_event(env: &Env, event: &Event) -> StdResult { let receiver = &event .attributes .iter() - .find(|attr| attr.key == receiver_key) - .ok_or_else(|| StdError::generic_err(format!("cannot find `{}` attribute", receiver_key)))? + .find(|attr| attr.key == "receiver") + .ok_or_else(|| StdError::generic_err("cannot find `receiver` attribute"))? .value; - let received_coins_str = &event + let amount_str = &event .attributes .iter() - .find(|attr| attr.key == received_coins_key) - .ok_or_else(|| StdError::generic_err(format!("cannot find `{}` attribute", received_coins_key)))? + .find(|attr| attr.key == "amount") + .ok_or_else(|| StdError::generic_err("cannot find `amount` attribute"))? .value; - let received_coins = if *receiver == env.contract.address { - Coins::from_str(received_coins_str)? + let amount = if *receiver == env.contract.address { + Coins::from_str(amount_str)? } else { Coins(vec![]) }; - Ok(received_coins) + Ok(amount) } //-------------------------------------------------------------------------------------------------- @@ -333,7 +275,7 @@ pub fn queue_unbond( env: Env, receiver: Addr, usteak_to_burn: Uint128, -) -> StdResult> { +) -> StdResult { let state = State::default(); let mut pending_batch = state.pending_batch.load(deps.storage)?; @@ -342,7 +284,7 @@ pub fn queue_unbond( state.unbond_requests.update( deps.storage, - (pending_batch.id.into(), &receiver), + (pending_batch.id, &receiver), |x| -> StdResult<_> { let mut request = x.unwrap_or_else(|| UnbondRequest { id: pending_batch.id, @@ -354,7 +296,7 @@ pub fn queue_unbond( }, )?; - let mut msgs: Vec> = vec![]; + let mut msgs: Vec = vec![]; if env.block.time.seconds() >= pending_batch.est_unbond_start_time { msgs.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: env.contract.address.into(), @@ -376,7 +318,7 @@ pub fn queue_unbond( .add_attribute("action", "steakhub/queue_unbond")) } -pub fn submit_batch(deps: DepsMut, env: Env) -> StdResult> { +pub fn submit_batch(deps: DepsMut, env: Env) -> StdResult { let state = State::default(); let steak_token = state.steak_token.load(deps.storage)?; let validators = state.validators.load(deps.storage)?; @@ -386,14 +328,15 @@ pub fn submit_batch(deps: DepsMut, env: Env) -> StdResult StdResult StdResult StdResult> { +pub fn reconcile(deps: DepsMut, env: Env) -> StdResult { let state = State::default(); let current_time = env.block.time.seconds(); @@ -476,10 +419,7 @@ pub fn reconcile(deps: DepsMut, env: Env) -> StdResult .filter(|b| current_time > b.est_unbond_end_time) .collect::>(); - let uluna_expected_received: Uint128 = batches - .iter() - .map(|b| b.uluna_unclaimed) - .sum(); + let uluna_expected_received: Uint128 = batches.iter().map(|b| b.uluna_unclaimed).sum(); if uluna_expected_received.is_zero() { return Ok(Response::new()); @@ -491,23 +431,19 @@ pub fn reconcile(deps: DepsMut, env: Env) -> StdResult let uluna_expected = uluna_expected_received + uluna_expected_unlocked; let uluna_actual = deps.querier.query_balance(&env.contract.address, "uluna")?.amount; - if uluna_actual >= uluna_expected { - return Ok(Response::new()); + let uluna_to_deduct = uluna_expected.checked_sub(uluna_actual).unwrap_or_else(|_| Uint128::zero()); + if !uluna_to_deduct.is_zero() { + reconcile_batches(&mut batches, uluna_expected - uluna_actual); } - let uluna_to_deduct = uluna_expected - uluna_actual; - - reconcile_batches(&mut batches, uluna_to_deduct); - for batch in &batches { - state.previous_batches.save(deps.storage, batch.id.into(), batch)?; + state.previous_batches.save(deps.storage, batch.id, batch)?; } let ids = batches .iter() .map(|b| b.id.to_string()) - .collect::>() - .join(","); + .collect::>().join(","); let event = Event::new("steakhub/reconciled") .add_attribute("ids", ids) @@ -523,7 +459,7 @@ pub fn withdraw_unbonded( env: Env, user: Addr, receiver: Addr, -) -> StdResult> { +) -> StdResult { let state = State::default(); let current_time = env.block.time.seconds(); @@ -551,7 +487,7 @@ pub fn withdraw_unbonded( let mut total_uluna_to_refund = Uint128::zero(); let mut ids: Vec = vec![]; for request in &requests { - if let Ok(mut batch) = state.previous_batches.load(deps.storage, request.id.into()) { + if let Ok(mut batch) = state.previous_batches.load(deps.storage, request.id) { if batch.reconciled && batch.est_unbond_end_time < current_time { let uluna_to_refund = batch .uluna_unclaimed @@ -564,12 +500,12 @@ pub fn withdraw_unbonded( batch.uluna_unclaimed -= uluna_to_refund; if batch.total_shares.is_zero() { - state.previous_batches.remove(deps.storage, request.id.into())?; + state.previous_batches.remove(deps.storage, request.id)?; } else { - state.previous_batches.save(deps.storage, batch.id.into(), &batch)?; + state.previous_batches.save(deps.storage, batch.id, &batch)?; } - state.unbond_requests.remove(deps.storage, (request.id.into(), &user))?; + state.unbond_requests.remove(deps.storage, (request.id, &user))?; } } } @@ -601,7 +537,7 @@ pub fn withdraw_unbonded( // Ownership and management logics //-------------------------------------------------------------------------------------------------- -pub fn rebalance(deps: DepsMut, env: Env) -> StdResult> { +pub fn rebalance(deps: DepsMut, env: Env) -> StdResult { let state = State::default(); let validators = state.validators.load(deps.storage)?; @@ -625,11 +561,7 @@ pub fn rebalance(deps: DepsMut, env: Env) -> StdResult .add_attribute("action", "steakhub/rebalance")) } -pub fn add_validator( - deps: DepsMut, - sender: Addr, - validator: String, -) -> StdResult> { +pub fn add_validator(deps: DepsMut, sender: Addr, validator: String) -> StdResult { let state = State::default(); state.assert_owner(deps.storage, &sender)?; @@ -645,9 +577,7 @@ pub fn add_validator( let event = Event::new("steakhub/validator_added") .add_attribute("validator", validator); - Ok(Response::new() - .add_event(event) - .add_attribute("action", "steakhub/add_validator")) + Ok(Response::new().add_event(event).add_attribute("action", "steakhub/add_validator")) } pub fn remove_validator( @@ -655,7 +585,7 @@ pub fn remove_validator( env: Env, sender: Addr, validator: String, -) -> StdResult> { +) -> StdResult { let state = State::default(); state.assert_owner(deps.storage, &sender)?; @@ -686,21 +616,16 @@ pub fn remove_validator( .add_attribute("action", "steakhub/remove_validator")) } -pub fn transfer_ownership( - deps: DepsMut, - sender: Addr, - new_owner: String, -) -> StdResult> { +pub fn transfer_ownership(deps: DepsMut, sender: Addr, new_owner: String) -> StdResult { let state = State::default(); state.assert_owner(deps.storage, &sender)?; state.new_owner.save(deps.storage, &deps.api.addr_validate(&new_owner)?)?; - Ok(Response::new() - .add_attribute("action", "steakhub/transfer_ownership")) + Ok(Response::new().add_attribute("action", "steakhub/transfer_ownership")) } -pub fn accept_ownership(deps: DepsMut, sender: Addr) -> StdResult> { +pub fn accept_ownership(deps: DepsMut, sender: Addr) -> StdResult { let state = State::default(); let previous_owner = state.owner.load(deps.storage)?; @@ -717,7 +642,5 @@ pub fn accept_ownership(deps: DepsMut, sender: Addr) -> StdResult StdResult { +pub(crate) fn unwrap_reply(reply: Reply) -> StdResult { reply.result.into_result().map_err(StdError::generic_err) } @@ -72,14 +72,14 @@ pub(crate) fn parse_coin(s: &str) -> StdResult { pub(crate) fn parse_received_fund(funds: &[Coin], denom: &str) -> StdResult { if funds.len() != 1 { return Err(StdError::generic_err( - format!("must deposit exactly one coin; received {}", funds.len()) + format!("must deposit exactly one coin; received {}", funds.len()), )); } let fund = &funds[0]; if fund.denom != denom { return Err(StdError::generic_err( - format!("expected {} deposit, received {}", denom, fund.denom) + format!("expected {} deposit, received {}", denom, fund.denom), )); } diff --git a/contracts/hub/src/queries.rs b/contracts/hub/src/queries.rs index 310685d..55f73de 100644 --- a/contracts/hub/src/queries.rs +++ b/contracts/hub/src/queries.rs @@ -1,5 +1,5 @@ -use cosmwasm_std::{Decimal, Deps, Env, Order, StdResult, Uint128}; -use cw_storage_plus::{Bound, U64Key}; +use cosmwasm_std::{Addr, Decimal, Deps, Env, Order, StdResult, Uint128}; +use cw_storage_plus::{Bound, CwIntKey}; use steak::hub::{ Batch, ConfigResponse, PendingBatch, StateResponse, UnbondRequestsByBatchResponseItem, @@ -55,7 +55,7 @@ pub fn pending_batch(deps: Deps) -> StdResult { pub fn previous_batch(deps: Deps, id: u64) -> StdResult { let state = State::default(); - state.previous_batches.load(deps.storage, id.into()) + state.previous_batches.load(deps.storage, id) } pub fn previous_batches( @@ -65,8 +65,8 @@ pub fn previous_batches( ) -> StdResult> { let state = State::default(); + let start = start_after.map(Bound::exclusive); let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(|id| Bound::exclusive(U64Key::from(id))); state .previous_batches @@ -87,12 +87,19 @@ pub fn unbond_requests_by_batch( ) -> StdResult> { let state = State::default(); + let addr: Addr; + let start = match start_after { + None => None, + Some(addr_str) => { + addr = deps.api.addr_validate(&addr_str)?; + Some(Bound::exclusive(&addr)) + }, + }; let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); state .unbond_requests - .prefix(id.into()) + .prefix(id) .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { @@ -110,8 +117,12 @@ pub fn unbond_requests_by_user( ) -> StdResult> { let state = State::default(); + let start = start_after.map(|id| { + let mut key = vec![0u8, 8u8]; // when `u64` are used as keys, they are prefixed with the length, which is [0, 8] + key.extend(id.to_cw_bytes()); + Bound::exclusive(key) + }); let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(|id| Bound::exclusive(U64Key::from(id))); state .unbond_requests diff --git a/contracts/hub/src/state.rs b/contracts/hub/src/state.rs index a7bfc66..8e251a5 100644 --- a/contracts/hub/src/state.rs +++ b/contracts/hub/src/state.rs @@ -1,5 +1,5 @@ -use cosmwasm_std::{Addr, Coin, Storage, StdError, StdResult}; -use cw_storage_plus::{Index, IndexList, IndexedMap, Item, MultiIndex, U64Key}; +use cosmwasm_std::{Addr, Coin, StdError, StdResult, Storage}; +use cw_storage_plus::{Index, IndexList, IndexedMap, Item, MultiIndex}; use steak::hub::{Batch, PendingBatch, UnbondRequest}; @@ -23,23 +23,23 @@ pub(crate) struct State<'a> { /// The current batch of unbonding requests queded to be executed pub pending_batch: Item<'a, PendingBatch>, /// Previous batches that have started unbonding but not yet finished - pub previous_batches: IndexedMap<'a, U64Key, Batch, PreviousBatchesIndexes<'a>>, + pub previous_batches: IndexedMap<'a, u64, Batch, PreviousBatchesIndexes<'a>>, /// Users' shares in unbonding batches - pub unbond_requests: IndexedMap<'a, (U64Key, &'a Addr), UnbondRequest, UnbondRequestsIndexes<'a>>, + pub unbond_requests: IndexedMap<'a, (u64, &'a Addr), UnbondRequest, UnbondRequestsIndexes<'a>>, } impl Default for State<'static> { fn default() -> Self { let pb_indexes = PreviousBatchesIndexes { reconciled: MultiIndex::new( - |d: &Batch, k: Vec| (d.reconciled.into(), k), + |d: &Batch| d.reconciled.into(), "previous_batches", "previous_batches__reconciled", ), }; let ubr_indexes = UnbondRequestsIndexes { user: MultiIndex::new( - |d: &UnbondRequest, k: Vec| (d.user.clone().into(), k), + |d: &UnbondRequest| d.user.clone().into(), "unbond_requests", "unbond_requests__user", ), @@ -72,7 +72,7 @@ impl<'a> State<'a> { pub(crate) struct PreviousBatchesIndexes<'a> { // pk goes to second tuple element - pub reconciled: MultiIndex<'a, (BooleanKey, Vec), Batch>, + pub reconciled: MultiIndex<'a, BooleanKey, Batch, Vec>, } impl<'a> IndexList for PreviousBatchesIndexes<'a> { @@ -84,7 +84,7 @@ impl<'a> IndexList for PreviousBatchesIndexes<'a> { pub(crate) struct UnbondRequestsIndexes<'a> { // pk goes to second tuple element - pub user: MultiIndex<'a, (String, Vec), UnbondRequest>, + pub user: MultiIndex<'a, String, UnbondRequest, Vec>, } impl<'a> IndexList for UnbondRequestsIndexes<'a> { diff --git a/contracts/hub/src/testing/custom_querier.rs b/contracts/hub/src/testing/custom_querier.rs index 821b2b8..6fcfcd6 100644 --- a/contracts/hub/src/testing/custom_querier.rs +++ b/contracts/hub/src/testing/custom_querier.rs @@ -1,30 +1,28 @@ use std::collections::HashMap; -use cosmwasm_std::testing::{MOCK_CONTRACT_ADDR, BankQuerier, StakingQuerier}; +use cosmwasm_std::testing::{BankQuerier, StakingQuerier, MOCK_CONTRACT_ADDR}; use cosmwasm_std::{ - from_binary, from_slice, Addr, Coin, Decimal, FullDelegation, Querier, QuerierResult, + from_binary, from_slice, Addr, Coin, Empty, FullDelegation, Querier, QuerierResult, QueryRequest, SystemError, WasmQuery, }; use cw20::Cw20QueryMsg; -use terra_cosmwasm::TerraQueryWrapper; use crate::types::Delegation; use super::cw20_querier::Cw20Querier; use super::helpers::err_unsupported_query; -use super::terra_querier::TerraQuerier; #[derive(Default)] pub(super) struct CustomQuerier { pub cw20_querier: Cw20Querier, - pub terra_querier: TerraQuerier, + // pub terra_querier: TerraQuerier, pub bank_querier: BankQuerier, pub staking_querier: StakingQuerier, } impl Querier for CustomQuerier { fn raw_query(&self, bin_request: &[u8]) -> QuerierResult { - let request: QueryRequest = match from_slice(bin_request) { + let request: QueryRequest<_> = match from_slice(bin_request) { Ok(v) => v, Err(e) => { return Err(SystemError::InvalidRequest { @@ -54,20 +52,7 @@ impl CustomQuerier { } pub fn set_cw20_total_supply(&mut self, token: &str, total_supply: u128) { - self.cw20_querier - .total_supplies - .insert(token.to_string(), total_supply); - } - - pub fn set_terra_exchange_rate( - &mut self, - base_denom: &str, - quote_denom: &str, - exchange_rate: Decimal, - ) { - self.terra_querier - .exchange_rates - .insert((base_denom.to_string(), quote_denom.to_string()), exchange_rate); + self.cw20_querier.total_supplies.insert(token.to_string(), total_supply); } pub fn set_bank_balances(&mut self, balances: &[Coin]) { @@ -89,7 +74,7 @@ impl CustomQuerier { self.staking_querier = StakingQuerier::new("uluna", &[], &fds); } - pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { + pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { match request { QueryRequest::Wasm(WasmQuery::Smart { contract_addr, @@ -102,11 +87,6 @@ impl CustomQuerier { err_unsupported_query(msg) }, - QueryRequest::Custom(TerraQueryWrapper { - route: _, - query_data, - }) => self.terra_querier.handle_query(query_data), - QueryRequest::Bank(query) => self.bank_querier.query(query), QueryRequest::Staking(query) => self.staking_querier.query(query), diff --git a/contracts/hub/src/testing/helpers.rs b/contracts/hub/src/testing/helpers.rs index 1d88733..123a511 100644 --- a/contracts/hub/src/testing/helpers.rs +++ b/contracts/hub/src/testing/helpers.rs @@ -23,6 +23,7 @@ pub(super) fn mock_dependencies() -> OwnedDeps Env { time: Timestamp::from_seconds(timestamp), chain_id: "cosmos-testnet-14002".to_string(), }, + transaction: None, contract: ContractInfo { address: Addr::unchecked(MOCK_CONTRACT_ADDR), }, diff --git a/contracts/hub/src/testing/mod.rs b/contracts/hub/src/testing/mod.rs index 084c097..c631ac9 100644 --- a/contracts/hub/src/testing/mod.rs +++ b/contracts/hub/src/testing/mod.rs @@ -1,5 +1,4 @@ mod custom_querier; mod cw20_querier; mod helpers; -mod terra_querier; mod tests; diff --git a/contracts/hub/src/testing/terra_querier.rs b/contracts/hub/src/testing/terra_querier.rs deleted file mode 100644 index 47c79b5..0000000 --- a/contracts/hub/src/testing/terra_querier.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::collections::HashMap; - -use cosmwasm_std::{to_binary, Decimal, QuerierResult, SystemError, SystemResult}; -use terra_cosmwasm::{ExchangeRateItem, ExchangeRatesResponse, TerraQuery}; - -use super::helpers::err_unsupported_query; - -#[derive(Default)] -pub struct TerraQuerier { - /// Maps (base_denom, quote_denom) pair to exchange rate - pub exchange_rates: HashMap<(String, String), Decimal>, -} - -impl TerraQuerier { - /// We only implement the `exchange_rates` query as that is the only one we need in the unit tests - /// - /// NOTE: When querying exchange rates, Terra's oracle module behaves in the following way: - /// - If `quote_denoms` contains _at least one_ known denom (meaning a denom that has exchange - /// rate defined), the query will be successful, and the response will contain the exchange - /// rates of only known denoms and omit denoms that are not known; - /// - If `quote_denoms` only contains unknown denoms, the query fails. - /// - /// Examples: - /// - [Success](https://bombay-fcd.terra.dev/wasm/contracts/terra1xf8kh2r7n06wk0mdhq0tgcrcyv90snjzfxfacg/store?query_msg=%7B%22ExchangeRates%22:[%22uusd%22,%22ukrw%22,%22ibc%2F0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B%22]%7D), - /// where the unknown denom (`ibc/...`) is omitted from the response - /// - [Fail](https://bombay-fcd.terra.dev/wasm/contracts/terra1xf8kh2r7n06wk0mdhq0tgcrcyv90snjzfxfacg/store?query_msg=%7B%22ExchangeRates%22:[%22ibc%2F0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B%22]%7D), - /// if the query only contains the unknown denom - /// - /// We emulate this behaviour in our mock querier. - pub fn handle_query(&self, query: &TerraQuery) -> QuerierResult { - if let TerraQuery::ExchangeRates { - base_denom, - quote_denoms, - } = query - { - let exchange_rates: Vec = quote_denoms - .iter() - .map(|quote_denom| { - self.exchange_rates.get(&(base_denom.clone(), quote_denom.clone())).map( - |rate| ExchangeRateItem { - quote_denom: quote_denom.clone(), - exchange_rate: *rate, - }, - ) - }) - .filter(|item| item.is_some()) - .map(|item| item.unwrap()) - .collect(); - - if exchange_rates.is_empty() { - return SystemResult::Err(SystemError::InvalidRequest { - error: format!("[mock] quote_denoms are all unknown"), - request: Default::default(), - }); - } - - return Ok(to_binary(&ExchangeRatesResponse { - base_denom: base_denom.into(), - exchange_rates, - }) - .into()) - .into(); - } - - err_unsupported_query(query) - } -} diff --git a/contracts/hub/src/testing/tests.rs b/contracts/hub/src/testing/tests.rs index 99d3b6b..bf5f15a 100644 --- a/contracts/hub/src/testing/tests.rs +++ b/contracts/hub/src/testing/tests.rs @@ -3,11 +3,10 @@ use std::str::FromStr; use cosmwasm_std::testing::{mock_env, mock_info, MockApi, MockStorage, MOCK_CONTRACT_ADDR}; use cosmwasm_std::{ to_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, DistributionMsg, Event, Order, OwnedDeps, - Reply, ReplyOn, StdError, SubMsg, SubMsgExecutionResponse, Uint128, WasmMsg, + Reply, ReplyOn, StdError, SubMsg, SubMsgResponse, Uint128, WasmMsg, }; use cw20::{Cw20ExecuteMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg; -use terra_cosmwasm::{TerraMsg, TerraMsgWrapper, TerraRoute}; use steak::hub::{ Batch, CallbackMsg, ConfigResponse, ExecuteMsg, InstantiateMsg, PendingBatch, QueryMsg, @@ -17,7 +16,9 @@ use steak::hub::{ use crate::contract::{execute, instantiate, reply}; use crate::helpers::{parse_coin, parse_received_fund}; -use crate::math::{compute_undelegations, compute_redelegations_for_removal, compute_redelegations_for_rebalancing}; +use crate::math::{ + compute_redelegations_for_rebalancing, compute_redelegations_for_removal, compute_undelegations, +}; use crate::state::State; use crate::types::{Coins, Delegation, Redelegation, Undelegation}; @@ -74,18 +75,16 @@ fn setup_test() -> OwnedDeps { ) ); - let event = Event::new("instantiate_contract") - .add_attribute("creator", MOCK_CONTRACT_ADDR) - .add_attribute("admin", "admin") + let event = Event::new("instantiate") .add_attribute("code_id", "69420") - .add_attribute("contract_address", "steak_token"); + .add_attribute("_contract_address", "steak_token"); let res = reply( deps.as_mut(), mock_env_at_timestamp(10000), Reply { id: 1, - result: cosmwasm_std::ContractResult::Ok(SubMsgExecutionResponse { + result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { events: vec![event], data: None, }), @@ -264,7 +263,7 @@ fn harvesting() { ) .unwrap(); - assert_eq!(res.messages.len(), 5); + assert_eq!(res.messages.len(), 4); assert_eq!( res.messages[0], SubMsg::reply_on_success( @@ -294,19 +293,6 @@ fn harvesting() { ); assert_eq!( res.messages[3], - SubMsg { - id: 0, - msg: CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: MOCK_CONTRACT_ADDR.to_string(), - msg: to_binary(&ExecuteMsg::Callback(CallbackMsg::Swap {})).unwrap(), - funds: vec![] - }), - gas_limit: None, - reply_on: ReplyOn::Never - } - ); - assert_eq!( - res.messages[4], SubMsg { id: 0, msg: CosmosMsg::Wasm(WasmMsg::Execute { @@ -335,7 +321,7 @@ fn registering_unlocked_coins() { mock_env(), Reply { id: 2, - result: cosmwasm_std::ContractResult::Ok(SubMsgExecutionResponse { + result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { events: vec![event], data: None, }), @@ -354,119 +340,6 @@ fn registering_unlocked_coins() { Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), ] ); - - // After swapping, we parse the `swap` event to find the received amount - let event = Event::new("swap") - .add_attribute("offer", "25959uusd") - .add_attribute("trader", MOCK_CONTRACT_ADDR.to_string()) - .add_attribute("recipient", MOCK_CONTRACT_ADDR.to_string()) - .add_attribute("swap_coin", "243uluna") - .add_attribute("swap_fee", "1uluna"); - - reply( - deps.as_mut(), - mock_env(), - Reply { - id: 3, - result: cosmwasm_std::ContractResult::Ok(SubMsgExecutionResponse { - events: vec![event], - data: None, - }), - }, - ) - .unwrap(); - - let unlocked_coins = state.unlocked_coins.load(deps.as_ref().storage).unwrap(); - assert_eq!( - unlocked_coins, - vec![ - Coin::new(123, "ukrw"), - Coin::new(477, "uluna"), // 234 (balance prior to swap) + 243 (swap proceedings) - Coin::new(345, "uusd"), - Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), - ] - ); -} - -#[test] -fn swapping() { - let mut deps = setup_test(); - let state = State::default(); - - // Only denoms that has exchange rates defined in the oracle module can be swapped to Luna - deps.querier.set_terra_exchange_rate( - "uluna", - "ukrw", - Decimal::from_str("129108.193653786399948012").unwrap(), - ); - deps.querier.set_terra_exchange_rate( - "uluna", - "usdr", - Decimal::from_str("77.056327779353129245").unwrap(), - ); - deps.querier.set_terra_exchange_rate( - "uluna", - "uusd", - Decimal::from_str("105.476484668836552061").unwrap(), - ); - - // After withdrawing staking rewards, we have some unlocked coins. Some can be swapped for Luna, - // some can't. - state.unlocked_coins.save( - deps.as_mut().storage, - &vec![ - Coin::new(123, "ukrw"), - Coin::new(234, "uluna"), - Coin::new(345, "uusd"), - Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), - ] - ).unwrap(); - - let res = execute( - deps.as_mut(), - mock_env(), - mock_info(MOCK_CONTRACT_ADDR, &[]), - ExecuteMsg::Callback(CallbackMsg::Swap {}), - ) - .unwrap(); - - assert_eq!(res.messages.len(), 2); - assert_eq!( - res.messages[0], - SubMsg::reply_on_success( - CosmosMsg::Custom(TerraMsgWrapper { - route: TerraRoute::Market, - msg_data: TerraMsg::Swap { - offer_coin: Coin::new(123, "ukrw"), - ask_denom: "uluna".to_string() - } - }), - 3 - ) - ); - assert_eq!( - res.messages[1], - SubMsg::reply_on_success( - CosmosMsg::Custom(TerraMsgWrapper { - route: TerraRoute::Market, - msg_data: TerraMsg::Swap { - offer_coin: Coin::new(345, "uusd"), - ask_denom: "uluna".to_string() - } - }), - 3 - ) - ); - - // Storage should have been updated - let unlocked_coins = state.unlocked_coins.load(deps.as_ref().storage).unwrap(); - assert_eq!( - unlocked_coins, - vec![ - Coin::new(234, "uluna"), - Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), - ] - ); } #[test] @@ -481,13 +354,16 @@ fn reinvesting() { ]); // After the swaps, `unlocked_coins` should contain only uluna and unknown denoms - state.unlocked_coins.save( - deps.as_mut().storage, - &vec![ - Coin::new(234, "uluna"), - Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), - ] - ).unwrap(); + state + .unlocked_coins + .save( + deps.as_mut().storage, + &vec![ + Coin::new(234, "uluna"), + Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), + ], + ) + .unwrap(); // Bob has the smallest amount of delegations, so all proceeds go to him let res = execute( @@ -789,7 +665,7 @@ fn reconciling() { total_shares: Uint128::new(1567), uluna_unclaimed: Uint128::new(1629), // 1.040 Luna per Steak est_unbond_end_time: 40000, // not yet finished unbonding, ignored - } + }, ]; for previous_batch in &previous_batches { @@ -799,13 +675,18 @@ fn reconciling() { .unwrap(); } - state.unlocked_coins.save(deps.as_mut().storage, &vec![ - Coin::new(10000, "uluna"), - Coin::new(234, "ukrw"), - Coin::new(345, "uusd"), - Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), - ]) - .unwrap(); + state + .unlocked_coins + .save( + deps.as_mut().storage, + &vec![ + Coin::new(10000, "uluna"), + Coin::new(234, "ukrw"), + Coin::new(345, "uusd"), + Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), + ], + ) + .unwrap(); deps.querier.set_bank_balances(&[ Coin::new(12345, "uluna"), @@ -818,8 +699,9 @@ fn reconciling() { deps.as_mut(), mock_env_at_timestamp(35000), mock_info("worker", &[]), - ExecuteMsg::Reconcile {} - ).unwrap(); + ExecuteMsg::Reconcile {}, + ) + .unwrap(); // Expected received: batch 2 + batch 3 = 1385 + 1506 = 2891 // Expected unlocked: 10000 @@ -928,7 +810,7 @@ fn withdrawing_unbonded() { }, Batch { id: 3, - reconciled: false, // finished unbonding, but not reconciled; ignored + reconciled: false, // finished unbonding, but not reconciled; ignored total_shares: Uint128::new(45678), uluna_unclaimed: Uint128::new(47276), // 1.035 Luna per Steak est_unbond_end_time: 20000, @@ -938,8 +820,8 @@ fn withdrawing_unbonded() { reconciled: true, total_shares: Uint128::new(56789), uluna_unclaimed: Uint128::new(59060), // 1.040 Luna per Steak - est_unbond_end_time: 30000, // reconciled, but not yet finished unbonding; ignored - } + est_unbond_end_time: 30000, // reconciled, but not yet finished unbonding; ignored + }, ]; for previous_batch in &previous_batches { @@ -1025,9 +907,7 @@ fn withdrawing_unbonded() { let err = state.previous_batches.load(deps.as_ref().storage, 2u64.into()).unwrap_err(); assert_eq!( err, - StdError::NotFound { - kind: "steak::hub::Batch".to_string() - } + StdError::NotFound { kind: "steak::hub::Batch".to_string() } ); // User 1's unbond requests in batches 1 and 2 should have been deleted @@ -1042,15 +922,11 @@ fn withdrawing_unbonded() { assert_eq!( err1, - StdError::NotFound { - kind: "steak::hub::UnbondRequest".to_string() - } + StdError::NotFound { kind: "steak::hub::UnbondRequest".to_string() } ); assert_eq!( err2, - StdError::NotFound { - kind: "steak::hub::UnbondRequest".to_string() - } + StdError::NotFound { kind: "steak::hub::UnbondRequest".to_string() } ); // User 3 attempt to withdraw; also specifying a receiver @@ -1094,9 +970,7 @@ fn withdrawing_unbonded() { assert_eq!( err, - StdError::NotFound { - kind: "steak::hub::UnbondRequest".to_string() - } + StdError::NotFound { kind: "steak::hub::UnbondRequest".to_string() } ); } @@ -1109,7 +983,9 @@ fn adding_validator() { deps.as_mut(), mock_env(), mock_info("jake", &[]), - ExecuteMsg::AddValidator { validator: "dave".to_string() }, + ExecuteMsg::AddValidator { + validator: "dave".to_string(), + }, ) .unwrap_err(); @@ -1119,7 +995,9 @@ fn adding_validator() { deps.as_mut(), mock_env(), mock_info("larry", &[]), - ExecuteMsg::AddValidator { validator: "alice".to_string() }, + ExecuteMsg::AddValidator { + validator: "alice".to_string(), + }, ) .unwrap_err(); @@ -1129,7 +1007,9 @@ fn adding_validator() { deps.as_mut(), mock_env(), mock_info("larry", &[]), - ExecuteMsg::AddValidator { validator: "dave".to_string() }, + ExecuteMsg::AddValidator { + validator: "dave".to_string(), + }, ) .unwrap(); @@ -1138,7 +1018,12 @@ fn adding_validator() { let validators = state.validators.load(deps.as_ref().storage).unwrap(); assert_eq!( validators, - vec![String::from("alice"), String::from("bob"), String::from("charlie"), String::from("dave")], + vec![ + String::from("alice"), + String::from("bob"), + String::from("charlie"), + String::from("dave") + ], ); } @@ -1157,7 +1042,9 @@ fn removing_validator() { deps.as_mut(), mock_env(), mock_info("jake", &[]), - ExecuteMsg::RemoveValidator { validator: "charlie".to_string() }, + ExecuteMsg::RemoveValidator { + validator: "charlie".to_string(), + }, ) .unwrap_err(); @@ -1167,7 +1054,9 @@ fn removing_validator() { deps.as_mut(), mock_env(), mock_info("larry", &[]), - ExecuteMsg::RemoveValidator { validator: "dave".to_string() }, + ExecuteMsg::RemoveValidator { + validator: "dave".to_string(), + }, ) .unwrap_err(); @@ -1181,31 +1070,24 @@ fn removing_validator() { deps.as_mut(), mock_env(), mock_info("larry", &[]), - ExecuteMsg::RemoveValidator { validator: "charlie".to_string() }, + ExecuteMsg::RemoveValidator { + validator: "charlie".to_string(), + }, ) .unwrap(); assert_eq!(res.messages.len(), 2); assert_eq!( res.messages[0], - SubMsg::reply_on_success( - Redelegation::new("charlie", "alice", 170833).to_cosmos_msg(), - 2, - ), + SubMsg::reply_on_success(Redelegation::new("charlie", "alice", 170833).to_cosmos_msg(), 2,), ); assert_eq!( res.messages[1], - SubMsg::reply_on_success( - Redelegation::new("charlie", "bob", 170833).to_cosmos_msg(), - 2, - ), + SubMsg::reply_on_success(Redelegation::new("charlie", "bob", 170833).to_cosmos_msg(), 2,), ); let validators = state.validators.load(deps.as_ref().storage).unwrap(); - assert_eq!( - validators, - vec![String::from("alice"), String::from("bob")], - ); + assert_eq!(validators, vec![String::from("alice"), String::from("bob")],); } #[test] @@ -1217,7 +1099,9 @@ fn transferring_ownership() { deps.as_mut(), mock_env(), mock_info("jake", &[]), - ExecuteMsg::TransferOwnership { new_owner: "jake".to_string() }, + ExecuteMsg::TransferOwnership { + new_owner: "jake".to_string(), + }, ) .unwrap_err(); @@ -1227,7 +1111,9 @@ fn transferring_ownership() { deps.as_mut(), mock_env(), mock_info("larry", &[]), - ExecuteMsg::TransferOwnership { new_owner: "jake".to_string() }, + ExecuteMsg::TransferOwnership { + new_owner: "jake".to_string(), + }, ) .unwrap(); @@ -1250,7 +1136,7 @@ fn transferring_ownership() { deps.as_mut(), mock_env(), mock_info("jake", &[]), - ExecuteMsg::AcceptOwnership {}, + ExecuteMsg::AcceptOwnership {} ) .unwrap(); @@ -1443,13 +1329,17 @@ fn querying_unbond_requests() { limit: None, }, ); - assert_eq!( - res, - vec![ - unbond_requests[0].clone().into(), - unbond_requests[3].clone().into(), - ] + assert_eq!(res, vec![unbond_requests[0].clone().into(), unbond_requests[3].clone().into()]); + + let res: Vec = query_helper( + deps.as_ref(), + QueryMsg::UnbondRequestsByUser { + user: "alice".to_string(), + start_after: Some(2), + limit: None, + }, ); + assert_eq!(res, vec![unbond_requests[3].clone().into()]); } //-------------------------------------------------------------------------------------------------- @@ -1545,10 +1435,7 @@ fn computing_redelegations_for_rebalancing() { Redelegation::new("charlie", "evan", 38126), ]; - assert_eq!( - compute_redelegations_for_rebalancing(¤t_delegations), - expected, - ); + assert_eq!(compute_redelegations_for_rebalancing(¤t_delegations), expected,); } //-------------------------------------------------------------------------------------------------- diff --git a/contracts/hub/src/types/keys.rs b/contracts/hub/src/types/keys.rs index a99080c..5c2af96 100644 --- a/contracts/hub/src/types/keys.rs +++ b/contracts/hub/src/types/keys.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use cw_storage_plus::{Prefixer, PrimaryKey}; +use cw_storage_plus::{Key, Prefixer, PrimaryKey}; #[derive(Clone, Debug, PartialEq, Eq)] pub struct BooleanKey { @@ -30,14 +30,16 @@ impl From for BooleanKey { impl<'a> PrimaryKey<'a> for BooleanKey { type Prefix = (); type SubPrefix = (); + type Suffix = (); + type SuperSuffix = (); - fn key(&self) -> Vec<&[u8]> { + fn key(&self) -> Vec { self.wrapped.key() } } impl<'a> Prefixer<'a> for BooleanKey { - fn prefix(&self) -> Vec<&[u8]> { + fn prefix(&self) -> Vec { self.wrapped.prefix() } } diff --git a/contracts/hub/src/types/staking.rs b/contracts/hub/src/types/staking.rs index cad39c9..f50dedb 100644 --- a/contracts/hub/src/types/staking.rs +++ b/contracts/hub/src/types/staking.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Coin, CosmosMsg, StakingMsg}; -use terra_cosmwasm::TerraMsgWrapper; +//use terra_cosmwasm::TerraMsgWrapper; #[derive(Clone)] #[cfg_attr(test, derive(Debug, PartialEq))] @@ -16,7 +16,7 @@ impl Delegation { } } - pub fn to_cosmos_msg(&self) -> CosmosMsg { + pub fn to_cosmos_msg(&self) -> CosmosMsg { CosmosMsg::Staking(StakingMsg::Delegate { validator: self.validator.clone(), amount: Coin::new(self.amount, "uluna"), @@ -38,7 +38,7 @@ impl Undelegation { } } - pub fn to_cosmos_msg(&self) -> CosmosMsg { + pub fn to_cosmos_msg(&self) -> CosmosMsg { CosmosMsg::Staking(StakingMsg::Undelegate { validator: self.validator.clone(), amount: Coin::new(self.amount, "uluna"), @@ -62,7 +62,7 @@ impl Redelegation { } } - pub fn to_cosmos_msg(&self) -> CosmosMsg { + pub fn to_cosmos_msg(&self) -> CosmosMsg { CosmosMsg::Staking(StakingMsg::Redelegate { src_validator: self.src.clone(), dst_validator: self.dst.clone(), diff --git a/contracts/token/Cargo.toml b/contracts/token/Cargo.toml index d304439..5fb6a06 100644 --- a/contracts/token/Cargo.toml +++ b/contracts/token/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "steak-token" -version = "1.0.0" -authors = ["larry "] +version = "2.0.0" +authors = ["larry ","PFC "] edition = "2018" license = "GPL-3.0-or-later" repository = "https://github.com/st4k3h0us3/steak-contracts" @@ -13,6 +13,6 @@ crate-type = ["cdylib", "rlib"] backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-std = { version = "0.16", features = ["staking"] } -cw20 = "0.9" -cw20-base = { version = "0.9", features = ["library"] } +cosmwasm-std = { version = "1.0.0", features = ["staking"] } +cw20 = "0.13.4" +cw20-base = { version = "0.13.4", features = ["library"] } diff --git a/contracts/token/src/lib.rs b/contracts/token/src/lib.rs index 9c636cf..427b1e8 100644 --- a/contracts/token/src/lib.rs +++ b/contracts/token/src/lib.rs @@ -56,14 +56,16 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { #[cfg(test)] mod tests { - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage}; + use cosmwasm_std::testing::{ + mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage, + }; use cosmwasm_std::{OwnedDeps, Uint128}; - use cw20_base::state::{BALANCES, TokenInfo}; + use cw20_base::state::{TokenInfo, BALANCES}; use super::*; fn setup_test() -> OwnedDeps { - let mut deps = mock_dependencies(&[]); + let mut deps = mock_dependencies(); TOKEN_INFO .save( @@ -85,16 +87,14 @@ mod tests { .save( deps.as_mut().storage, &Addr::unchecked("steak_hub"), - &Uint128::new(100) - ) + &Uint128::new(100)) .unwrap(); BALANCES .save( deps.as_mut().storage, &Addr::unchecked("alice"), - &Uint128::new(100) - ) + &Uint128::new(100)) .unwrap(); deps diff --git a/packages/steak/Cargo.toml b/packages/steak/Cargo.toml index f912bc9..bbdd500 100644 --- a/packages/steak/Cargo.toml +++ b/packages/steak/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "steak" -version = "1.0.0" -authors = ["larry "] +version = "2.0.0" +authors = ["larry ", "PFC "] edition = "2018" description = "Liquid staking protocol for the cosmos" license = "GPL-3.0-or-later" @@ -9,8 +9,8 @@ homepage = "https://steak.club" repository = "https://github.com/st4k3h0us3/steak-contracts" [dependencies] -cosmwasm-std = "0.16" -cw20 = "0.9" +cosmwasm-std = "1.0" +cw20 = "0.13" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } -terra-cosmwasm = "2.2" + diff --git a/packages/steak/src/hub.rs b/packages/steak/src/hub.rs index 91a84c7..b793be1 100644 --- a/packages/steak/src/hub.rs +++ b/packages/steak/src/hub.rs @@ -2,7 +2,6 @@ use cosmwasm_std::{to_binary, Addr, Coin, CosmosMsg, Decimal, Empty, StdResult, use cw20::Cw20ReceiveMsg; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use terra_cosmwasm::TerraMsgWrapper; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InstantiateMsg { @@ -42,7 +41,7 @@ pub enum ExecuteMsg { validator: String, }, /// Remove a validator from the whitelist; callable by the owner - RemoveValidator{ + RemoveValidator { validator: String, }, /// Transfer ownership to another account; will not take effect unless the new owner accepts @@ -76,14 +75,12 @@ pub enum ReceiveMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum CallbackMsg { - /// Swap Terra stablecoins held by the contract to Luna - Swap {}, /// Following the swaps, stake the Luna acquired to the whitelisted validators Reinvest {}, } impl CallbackMsg { - pub fn into_cosmos_msg(&self, contract_addr: &Addr) -> StdResult> { + pub fn into_cosmos_msg(&self, contract_addr: &Addr) -> StdResult { Ok(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: contract_addr.to_string(), msg: to_binary(&ExecuteMsg::Callback(self.clone()))?, diff --git a/scripts/2_deploy.ts b/scripts/2_deploy.ts index dc7ec7b..81ce769 100644 --- a/scripts/2_deploy.ts +++ b/scripts/2_deploy.ts @@ -79,7 +79,6 @@ async function uploadCode(deployer: Wallet, path: string) { hubCodeId, msg ); - const address = - result.logs[0].eventsByType.instantiate_contract.contract_address[0]; + const address = result.logs[0].eventsByType["instantiate_contract"]["contract_address"][0]; console.log(`Contract instantiated! Address: ${address}`); })(); diff --git a/scripts/helpers.ts b/scripts/helpers.ts index bd4e58f..7831cd4 100644 --- a/scripts/helpers.ts +++ b/scripts/helpers.ts @@ -22,13 +22,13 @@ const DEFAULT_GAS_SETTINGS = { export function createLCDClient(network: string): LCDClient { if (network === "mainnet") { return new LCDClient({ - chainID: "columbus-5", + chainID: "phoenix-1", URL: "https://lcd.terra.dev", }); } else if (network === "testnet") { return new LCDClient({ - chainID: "bombay-12", - URL: "https://bombay-lcd.terra.dev", + chainID: "pisco-1", + URL: "https://terra-testnet-api.polkachu.com/", }); } else if (network === "localterra") { return new LocalTerra(); diff --git a/scripts/package-lock.json b/scripts/package-lock.json index 9abddd4..f0cb54c 100644 --- a/scripts/package-lock.json +++ b/scripts/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@terra-money/terra.js": "^3.0.8", + "@terra-money/terra.js": "^3.1.2", "promptly": "^3.2.0", "ts-node": "^10.7.0", "yargs": "^17.4.0" @@ -83,6 +83,17 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "node_modules/@improbable-eng/grpc-web": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/@improbable-eng/grpc-web/-/grpc-web-0.14.1.tgz", + "integrity": "sha512-XaIYuunepPxoiGVLLHmlnVminUGzBTnXr8Wv7khzmLWbNw4TCwJKX09GSMJlKhu/TRk6gms0ySFxewaETSBqgw==", + "dependencies": { + "browser-headers": "^0.4.1" + }, + "peerDependencies": { + "google-protobuf": "^3.14.0" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -121,7 +132,7 @@ "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", - "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==" }, "node_modules/@protobufjs/base64": { "version": "1.1.2", @@ -136,12 +147,12 @@ "node_modules/@protobufjs/eventemitter": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", - "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==" }, "node_modules/@protobufjs/fetch": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", - "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", "dependencies": { "@protobufjs/aspromise": "^1.1.1", "@protobufjs/inquire": "^1.1.0" @@ -150,35 +161,47 @@ "node_modules/@protobufjs/float": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", - "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==" }, "node_modules/@protobufjs/inquire": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", - "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==" }, "node_modules/@protobufjs/path": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", - "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==" }, "node_modules/@protobufjs/pool": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", - "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==" }, "node_modules/@protobufjs/utf8": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", - "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" + }, + "node_modules/@terra-money/legacy.proto": { + "name": "@terra-money/terra.proto", + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.1.7.tgz", + "integrity": "sha512-NXD7f6pQCulvo6+mv6MAPzhOkUzRjgYVuHZE/apih+lVnPG5hDBU0rRYnOGGofwvKT5/jQoOENnFn/gioWWnyQ==", + "dependencies": { + "google-protobuf": "^3.17.3", + "long": "^4.0.0", + "protobufjs": "~6.11.2" + } }, "node_modules/@terra-money/terra.js": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/@terra-money/terra.js/-/terra.js-3.0.9.tgz", - "integrity": "sha512-jC7E8SjYiUV7nTk8g3LwQhJXlW5t2aiulB6Qg+K9dWpNzfqMn1ovuOD250gyx9aFaCilbDVLzPiZJLLbKPCO0w==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@terra-money/terra.js/-/terra.js-3.1.2.tgz", + "integrity": "sha512-jEvgujX/gbXzq6aTlYORw4chuk8b46weIArThDmpvQN8c3P3GrcMZYsI7uPUFtoWhcKO8+qI++dWzIIFoNhmMQ==", "dependencies": { - "@terra-money/terra.proto": "^0.1.7", - "axios": "^0.24.0", + "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", + "@terra-money/terra.proto": "^0.2.0-beta.4", + "axios": "^0.26.1", "bech32": "^2.0.0", "bip32": "^2.0.6", "bip39": "^3.0.3", @@ -196,10 +219,11 @@ } }, "node_modules/@terra-money/terra.proto": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.1.7.tgz", - "integrity": "sha512-NXD7f6pQCulvo6+mv6MAPzhOkUzRjgYVuHZE/apih+lVnPG5hDBU0rRYnOGGofwvKT5/jQoOENnFn/gioWWnyQ==", + "version": "0.2.0-beta.4", + "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.2.0-beta.4.tgz", + "integrity": "sha512-ALwIOpiZgpELvUO27+Lgc4qQz6k5NB58YsUHX2Bf7gocspShRftps5kjj/bovZs/M6AO4J7Qj07QJRBekMinMA==", "dependencies": { + "@improbable-eng/grpc-web": "^0.14.1", "google-protobuf": "^3.17.3", "long": "^4.0.0", "protobufjs": "~6.11.2" @@ -232,9 +256,9 @@ "dev": true }, "node_modules/@types/long": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", - "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", + "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" }, "node_modules/@types/node": { "version": "17.0.23", @@ -536,11 +560,11 @@ } }, "node_modules/axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", "dependencies": { - "follow-redirects": "^1.14.4" + "follow-redirects": "^1.14.8" } }, "node_modules/balanced-match": { @@ -638,6 +662,11 @@ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" }, + "node_modules/browser-headers": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/browser-headers/-/browser-headers-0.4.1.tgz", + "integrity": "sha512-CA9hsySZVo9371qEHjHZtYxV2cFtVj5Wj/ZHi8ooEsrtm4vOnl9Y9HmyYWk9q+05d7K3rdoAE0j3MVEFVvtQtg==" + }, "node_modules/bs58": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", @@ -1216,9 +1245,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz", + "integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==", "funding": [ { "type": "individual", @@ -1320,9 +1349,9 @@ } }, "node_modules/google-protobuf": { - "version": "3.19.4", - "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.19.4.tgz", - "integrity": "sha512-OIPNCxsG2lkIvf+P5FNfJ/Km95CsXOBecS9ZcAU6m2Rq3svc0Apl9nB3GMDNKfQ9asNv4KjyAqGwPQFrVle3Yg==" + "version": "3.20.1", + "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.20.1.tgz", + "integrity": "sha512-XMf1+O32FjYIV3CYu6Tuh5PNbfNEU5Xu22X+Xkdb/DUexFlCzhvv7d5Iirm4AOwn8lv4al1YvIhzGrg2j9Zfzw==" }, "node_modules/has-flag": { "version": "4.0.0", @@ -1756,9 +1785,9 @@ } }, "node_modules/protobufjs": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.2.tgz", - "integrity": "sha512-4BQJoPooKJl2G9j3XftkIXjoC9C0Av2NOrWmbLWT1vH32GcSUHjM0Arra6UfTsVyfMAuFzaLucXn1sadxJydAw==", + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", "hasInstallScript": true, "dependencies": { "@protobufjs/aspromise": "^1.1.2", @@ -2427,6 +2456,14 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "@improbable-eng/grpc-web": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/@improbable-eng/grpc-web/-/grpc-web-0.14.1.tgz", + "integrity": "sha512-XaIYuunepPxoiGVLLHmlnVminUGzBTnXr8Wv7khzmLWbNw4TCwJKX09GSMJlKhu/TRk6gms0ySFxewaETSBqgw==", + "requires": { + "browser-headers": "^0.4.1" + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2456,7 +2493,7 @@ "@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", - "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==" }, "@protobufjs/base64": { "version": "1.1.2", @@ -2471,12 +2508,12 @@ "@protobufjs/eventemitter": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", - "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==" }, "@protobufjs/fetch": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", - "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", "requires": { "@protobufjs/aspromise": "^1.1.1", "@protobufjs/inquire": "^1.1.0" @@ -2485,35 +2522,46 @@ "@protobufjs/float": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", - "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==" }, "@protobufjs/inquire": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", - "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==" }, "@protobufjs/path": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", - "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==" }, "@protobufjs/pool": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", - "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==" }, "@protobufjs/utf8": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", - "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" + }, + "@terra-money/legacy.proto": { + "version": "npm:@terra-money/terra.proto@0.1.7", + "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.1.7.tgz", + "integrity": "sha512-NXD7f6pQCulvo6+mv6MAPzhOkUzRjgYVuHZE/apih+lVnPG5hDBU0rRYnOGGofwvKT5/jQoOENnFn/gioWWnyQ==", + "requires": { + "google-protobuf": "^3.17.3", + "long": "^4.0.0", + "protobufjs": "~6.11.2" + } }, "@terra-money/terra.js": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/@terra-money/terra.js/-/terra.js-3.0.9.tgz", - "integrity": "sha512-jC7E8SjYiUV7nTk8g3LwQhJXlW5t2aiulB6Qg+K9dWpNzfqMn1ovuOD250gyx9aFaCilbDVLzPiZJLLbKPCO0w==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@terra-money/terra.js/-/terra.js-3.1.2.tgz", + "integrity": "sha512-jEvgujX/gbXzq6aTlYORw4chuk8b46weIArThDmpvQN8c3P3GrcMZYsI7uPUFtoWhcKO8+qI++dWzIIFoNhmMQ==", "requires": { - "@terra-money/terra.proto": "^0.1.7", - "axios": "^0.24.0", + "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", + "@terra-money/terra.proto": "^0.2.0-beta.4", + "axios": "^0.26.1", "bech32": "^2.0.0", "bip32": "^2.0.6", "bip39": "^3.0.3", @@ -2528,10 +2576,11 @@ } }, "@terra-money/terra.proto": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.1.7.tgz", - "integrity": "sha512-NXD7f6pQCulvo6+mv6MAPzhOkUzRjgYVuHZE/apih+lVnPG5hDBU0rRYnOGGofwvKT5/jQoOENnFn/gioWWnyQ==", + "version": "0.2.0-beta.4", + "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.2.0-beta.4.tgz", + "integrity": "sha512-ALwIOpiZgpELvUO27+Lgc4qQz6k5NB58YsUHX2Bf7gocspShRftps5kjj/bovZs/M6AO4J7Qj07QJRBekMinMA==", "requires": { + "@improbable-eng/grpc-web": "^0.14.1", "google-protobuf": "^3.17.3", "long": "^4.0.0", "protobufjs": "~6.11.2" @@ -2564,9 +2613,9 @@ "dev": true }, "@types/long": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", - "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", + "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" }, "@types/node": { "version": "17.0.23", @@ -2752,11 +2801,11 @@ "dev": true }, "axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", "requires": { - "follow-redirects": "^1.14.4" + "follow-redirects": "^1.14.8" } }, "balanced-match": { @@ -2852,6 +2901,11 @@ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" }, + "browser-headers": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/browser-headers/-/browser-headers-0.4.1.tgz", + "integrity": "sha512-CA9hsySZVo9371qEHjHZtYxV2cFtVj5Wj/ZHi8ooEsrtm4vOnl9Y9HmyYWk9q+05d7K3rdoAE0j3MVEFVvtQtg==" + }, "bs58": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", @@ -3309,9 +3363,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz", + "integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==" }, "fs.realpath": { "version": "1.0.0", @@ -3375,9 +3429,9 @@ } }, "google-protobuf": { - "version": "3.19.4", - "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.19.4.tgz", - "integrity": "sha512-OIPNCxsG2lkIvf+P5FNfJ/Km95CsXOBecS9ZcAU6m2Rq3svc0Apl9nB3GMDNKfQ9asNv4KjyAqGwPQFrVle3Yg==" + "version": "3.20.1", + "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.20.1.tgz", + "integrity": "sha512-XMf1+O32FjYIV3CYu6Tuh5PNbfNEU5Xu22X+Xkdb/DUexFlCzhvv7d5Iirm4AOwn8lv4al1YvIhzGrg2j9Zfzw==" }, "has-flag": { "version": "4.0.0", @@ -3716,9 +3770,9 @@ } }, "protobufjs": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.2.tgz", - "integrity": "sha512-4BQJoPooKJl2G9j3XftkIXjoC9C0Av2NOrWmbLWT1vH32GcSUHjM0Arra6UfTsVyfMAuFzaLucXn1sadxJydAw==", + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", "requires": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", diff --git a/scripts/package.json b/scripts/package.json index 2d185e5..d60ba38 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@terra-money/terra.js": "^3.0.8", + "@terra-money/terra.js": "^3.1.2", "promptly": "^3.2.0", "ts-node": "^10.7.0", "yargs": "^17.4.0"