diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index 3890a07..df9c5ec 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -44,11 +44,11 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install stable toolchain + - name: Install toolchain uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.60.0 + toolchain: 1.71 override: true components: rustfmt, clippy diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml deleted file mode 100644 index a9d5979..0000000 --- a/.github/workflows/Release.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: release wasm - -on: - release: - types: [created] - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Install cargo-run-script - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-run-script - - name: Run cargo optimize - uses: actions-rs/cargo@v1 - with: - command: run-script - args: optimize - - name: Get release ID - id: get_release - uses: bruceadams/get-release@v1.2.3 - env: - GITHUB_TOKEN: ${{ github.token }} - - name: Upload optimized wasm - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ./artifacts/*.wasm - tag: ${{ github.ref }} - overwrite: true - file_glob: true diff --git a/src/contract.rs b/src/contract.rs index a7efc8c..3e6ab2b 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -14,7 +14,7 @@ use neutron_sdk::bindings::msg::{IbcFee, NeutronMsg}; use neutron_sdk::bindings::query::NeutronQuery; use neutron_sdk::bindings::types::ProtobufAny; use neutron_sdk::query::min_ibc_fee::query_min_ibc_fee; -use neutron_sdk::sudo::msg::{RequestPacketTimeoutHeight, SudoMsg}; +use neutron_sdk::sudo::msg::{RequestPacket, RequestPacketTimeoutHeight, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; use crate::error::ContractError; @@ -288,10 +288,28 @@ pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> StdResult { counterparty_channel_id, counterparty_version, ), + SudoMsg::Error { request, details } => sudo_error(deps, request, details), + SudoMsg::Timeout { request } => sudo_timeout(deps, request), _ => Ok(Response::default()), } } +fn sudo_error(deps: DepsMut, _request: RequestPacket, _details: String) -> StdResult { + let current_stage = STAGE.load(deps.storage)?; + let stage = previous_stage(current_stage)?; + STAGE.save(deps.storage, &stage)?; + + Ok(Response::default()) +} + +fn sudo_timeout(deps: DepsMut, _request: RequestPacket) -> StdResult { + let current_stage = STAGE.load(deps.storage)?; + let stage = previous_stage(current_stage)?; + STAGE.save(deps.storage, &stage)?; + + Ok(Response::default()) +} + fn sudo_open_ack( deps: DepsMut, _env: Env, @@ -335,3 +353,25 @@ fn min_ntrn_ibc_fee(deps: Deps) -> NeutronResult { .collect(), }) } + +fn previous_stage(stage: ExecuteMsg) -> StdResult { + let stages = [ + ExecuteMsg::ClaimUnclaimed {}, + ExecuteMsg::CreateHubICA {}, + ExecuteMsg::SendClaimedTokensToICA {}, + ExecuteMsg::FundCommunityPool {}, + ExecuteMsg::Done {}, + ]; + let i = stages + .iter() + .position(|s| *s == stage) + .ok_or_else(|| StdError::generic_err(format!("Incorrect stage: {:?}", stage)))?; + + if i == 0 { + return Err(StdError::generic_err( + "no previous stage for the first stage", + )); + } + + Ok(stages[i - 1].clone()) +}