diff --git a/contracts/injective-auction-pool/src/executions.rs b/contracts/injective-auction-pool/src/executions.rs index e48b51f..4b6dbe3 100644 --- a/contracts/injective-auction-pool/src/executions.rs +++ b/contracts/injective-auction-pool/src/executions.rs @@ -303,7 +303,6 @@ pub fn settle_auction( let current_auction_round_response = query_current_auction(deps.as_ref())?; let current_auction_round = current_auction_round_response.auction_round; - // .ok_or(ContractError::CurrentAuctionQueryError)?; // prevents the contract from settling the auction if the auction round has not finished if current_auction_round.u64() == unsettled_auction.auction_round { diff --git a/contracts/injective-auction-pool/src/helpers.rs b/contracts/injective-auction-pool/src/helpers.rs index e3dd71b..8155a7f 100644 --- a/contracts/injective-auction-pool/src/helpers.rs +++ b/contracts/injective-auction-pool/src/helpers.rs @@ -1,9 +1,9 @@ use std::str::FromStr; use cosmwasm_std::{ - attr, instantiate2_address, to_json_binary, Addr, Attribute, BankMsg, Binary, CodeInfoResponse, - Coin, CosmosMsg, Decimal, Deps, DepsMut, Env, MessageInfo, OverflowError, QueryRequest, - StdResult, Uint128, WasmMsg, + attr, instantiate2_address, to_json_binary, Attribute, BankMsg, Binary, CanonicalAddr, + CodeInfoResponse, Coin, CosmosMsg, Decimal, Deps, DepsMut, Env, Instantiate2AddressError, + MessageInfo, OverflowError, QueryRequest, StdResult, Uint128, WasmMsg, }; use crate::{ @@ -11,6 +11,17 @@ use crate::{ ContractError, }; +// Function to create a truncated address +pub fn my_address( + checksum: &[u8], + creator: &CanonicalAddr, + salt: &[u8], +) -> Result { + let full_address = instantiate2_address(checksum, creator, salt)?; + let truncated_address = &full_address.0[..20]; // Truncate to the first 20 bytes + Ok(CanonicalAddr(Binary(truncated_address.to_vec()))) +} + /// Starts a new auction pub(crate) fn new_auction_round( deps: DepsMut, @@ -120,8 +131,7 @@ pub(crate) fn new_auction_round( ); let salt = Binary::from(seed.as_bytes()); - let treasure_chest_address = - Addr::unchecked(instantiate2_address(&checksum, &creator, &salt)?.to_string()); + let treasure_chest_address = my_address(&checksum, &creator, &salt)?.to_string(); let denom = format!( "factory/{}/auction.{}", @@ -149,14 +159,14 @@ pub(crate) fn new_auction_round( TREASURE_CHEST_CONTRACTS.save( deps.storage, unsettled_auction.auction_round, - &treasure_chest_address, + &deps.api.addr_validate(&treasure_chest_address)?, )?; // transfer previous token factory's admin rights to the treasury chest contract messages.push(config.token_factory_type.change_admin( env.contract.address.clone(), &denom, - treasure_chest_address.clone(), + deps.api.addr_validate(&treasure_chest_address)?, )); // create a new denom for the current auction round diff --git a/deploy/testnet-02-auction.txt b/deploy/testnet-02-auction.txt index 531125e..c46f76a 100644 --- a/deploy/testnet-02-auction.txt +++ b/deploy/testnet-02-auction.txt @@ -43,14 +43,15 @@ tx_auction=6849A8FD2CCD67E4E24E62D5C27BB2CAF09D75DDB4A3932CE5A32CD200E215FB export AUCTION_CONTRACT=$(injectived query tx $tx_auction|jq -r '.events[]| select(.type=="cosmwasm.wasm.v1.EventContractInstantiated").attributes[] |select(.key=="contract_address").value '|tr -d '"') echo $AUCTION_CONTRACT -#export AUCTION_CONTRACT=inj1r467s95lrzf005pw4x6grzhhtnmw9lx93lcpek +# export AUCTION_CONTRACT=inj1r467s95lrzf005pw4x6grzhhtnmw9lx93lcpek # export AUCTION_CONTRACT=inj1s9dzsqrrq09z46ye7ffa9fldg3dt0e2cvx6yla +# export AUCTION_CONTRACT=inj1dlyumvy7rfmq534hnh8et2ft58zpm0d84vjkfd -injectived query wasm cs smart $AUCTION_CONTRACT '{"query_current_auction_basket":{}}' -injectived query wasm cs smart $AUCTION_CONTRACT '{"whitelisted_addresses":{}}' -injectived query wasm cs smart $AUCTION_CONTRACT '{"funds_locked":{}}' -injectived query wasm cs smart $AUCTION_CONTRACT '{"bidding_balance":{}}' -injectived query wasm cs smart $AUCTION_CONTRACT '{"unsettled_auction":{}}' +injectived query wasm cs smart $AUCTION_CONTRACT '{"current_auction_basket":{}}' | jq +injectived query wasm cs smart $AUCTION_CONTRACT '{"whitelisted_addresses":{}}' | jq +injectived query wasm cs smart $AUCTION_CONTRACT '{"funds_locked":{}}' | jq +injectived query wasm cs smart $AUCTION_CONTRACT '{"bidding_balance":{}}' | jq +injectived query wasm cs smart $AUCTION_CONTRACT '{"config":{}}' | jq # add address to whitelist injectived tx wasm execute $AUCTION_CONTRACT '{"update_white_listed_addresses":{"add":["inj12nn88vtuf893cpfkke23dszpr5uccqj2zqukt6"], "remove":[]}}' \ @@ -105,6 +106,5 @@ injectived tx wasm execute $AUCTION_CONTRACT '{"exit_pool":{}}' --from inj1cdugm # exit pool injectived tx wasm execute inj1kar690fes35rm0dx5zcjwt5pjhtvcf572w3ffe '{"exit_pool":{}}' --from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto --amount 102factory/$AUCTION_CONTRACT/auction.0 --node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 | jq - # settle auction -injectived tx wasm execute inj1kar690fes35rm0dx5zcjwt5pjhtvcf572w3ffe '{"settle_auction":{"auction_round":108,"auction_winner":"inj1dlyumvy7rfmq534hnh8et2ft58zpm0d84vjkfd", "auction_winning_bid":"16000000000000"}}' --from $FROM --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto --node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 | jq +injectived tx wasm execute $AUCTION_CONTRACT '{"settle_auction":{"auction_round":108, "auction_winner":"inj1dlyumvy7rfmq534hnh8et2ft58zpm0d84vjkfd", "auction_winning_bid": "7230370850000000000001"}}' --from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto --node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 | jq \ No newline at end of file