Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into feat/devnets
Browse files Browse the repository at this point in the history
# Conflicts:
#	deploy/testnet-02-auction.txt
  • Loading branch information
PFC-developer committed Aug 5, 2024
2 parents 722c0d4 + bc1da48 commit 0c99934
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
1 change: 0 additions & 1 deletion contracts/injective-auction-pool/src/executions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 17 additions & 7 deletions contracts/injective-auction-pool/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
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::{
state::{Auction, BIDDING_BALANCE, CONFIG, TREASURE_CHEST_CONTRACTS, UNSETTLED_AUCTION},
ContractError,
};

// Function to create a truncated address
pub fn my_address(
checksum: &[u8],
creator: &CanonicalAddr,
salt: &[u8],
) -> Result<CanonicalAddr, Instantiate2AddressError> {
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,
Expand Down Expand Up @@ -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.{}",
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions deploy/testnet-02-auction.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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":[]}}' \
Expand Down Expand Up @@ -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

0 comments on commit 0c99934

Please sign in to comment.