Skip to content

Commit

Permalink
scripts update
Browse files Browse the repository at this point in the history
  • Loading branch information
hard-nett committed Apr 15, 2024
1 parent edb8431 commit ca9ae66
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 77 deletions.
22 changes: 11 additions & 11 deletions packages/revenue/terp-fee/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{coin, coins, Addr, BankMsg, Coin, Decimal, Event, MessageInfo, Uint128};
use cw_utils::{may_pay, PaymentError};
use terp_sdk::{create_fund_community_pool_msg, Response, SubMsg, NATIVE_FEE_DENOM};
use terp_sdk::{create_fund_community_pool_msg, Response, SubMsg, NATIVE_DENOM};
use thiserror::Error;

// governance parameters
Expand All @@ -15,7 +15,7 @@ pub fn checked_fair_burn(
res: &mut Response,
) -> Result<(), FeeError> {
// Use may_pay because fees could be 0. Add check to avoid transferring 0 funds
let payment = may_pay(info, NATIVE_FEE_DENOM)?;
let payment = may_pay(info, NATIVE_DENOM)?;
if payment.u128() < fee {
return Err(FeeError::InsufficientFee(fee, payment.u128()));
};
Expand Down Expand Up @@ -76,7 +76,7 @@ pub fn fair_burn(fee: u128, developer: Option<Addr>, res: &mut Response) {

// calculate the fair burn fee
let burn_fee = (Uint128::from(fee) * Decimal::percent(FEE_BURN_PERCENT)).u128();
let burn_coin = coins(burn_fee, NATIVE_FEE_DENOM);
let burn_coin = coins(burn_fee, NATIVE_DENOM);
res.messages
.push(SubMsg::new(BankMsg::Burn { amount: burn_coin }));
event = event.add_attribute("burn_amount", Uint128::from(burn_fee).to_string());
Expand All @@ -87,15 +87,15 @@ pub fn fair_burn(fee: u128, developer: Option<Addr>, res: &mut Response) {
if let Some(dev) = developer {
res.messages.push(SubMsg::new(BankMsg::Send {
to_address: dev.to_string(),
amount: coins(remainder, NATIVE_FEE_DENOM),
amount: coins(remainder, NATIVE_DENOM),
}));
event = event.add_attribute("dev", dev.to_string());
event = event.add_attribute("dev_amount", Uint128::from(remainder).to_string());
} else {
res.messages
.push(SubMsg::new(create_fund_community_pool_msg(coins(
remainder,
NATIVE_FEE_DENOM,
NATIVE_DENOM,
))));
event = event.add_attribute("dist_amount", Uint128::from(remainder).to_string());
}
Expand All @@ -115,7 +115,7 @@ pub enum FeeError {
#[cfg(test)]
mod tests {
use cosmwasm_std::{coins, Addr, BankMsg};
use terp_sdk::{create_fund_community_pool_msg, Response, NATIVE_FEE_DENOM};
use terp_sdk::{create_fund_community_pool_msg, Response, NATIVE_DENOM};

use crate::{fair_burn, SubMsg};

Expand All @@ -127,7 +127,7 @@ mod tests {
let burn_msg = SubMsg::new(BankMsg::Burn {
amount: coins(4, "uthiol".to_string()),
});
let dist_msg = SubMsg::new(create_fund_community_pool_msg(coins(5, NATIVE_FEE_DENOM)));
let dist_msg = SubMsg::new(create_fund_community_pool_msg(coins(5, NATIVE_DENOM)));
assert_eq!(res.messages.len(), 2);
assert_eq!(res.messages[0], burn_msg);
assert_eq!(res.messages[1], dist_msg);
Expand All @@ -140,10 +140,10 @@ mod tests {
fair_burn(9u128, Some(Addr::unchecked("jeret")), &mut res);
let bank_msg = SubMsg::new(BankMsg::Send {
to_address: "jeret".to_string(),
amount: coins(5, NATIVE_FEE_DENOM),
amount: coins(5, NATIVE_DENOM),
});
let burn_msg = SubMsg::new(BankMsg::Burn {
amount: coins(4, NATIVE_FEE_DENOM),
amount: coins(4, NATIVE_DENOM),
});
assert_eq!(res.messages.len(), 2);
assert_eq!(res.messages[0], burn_msg);
Expand All @@ -157,10 +157,10 @@ mod tests {
fair_burn(1420u128, Some(Addr::unchecked("eret")), &mut res);
let bank_msg = SubMsg::new(BankMsg::Send {
to_address: "eret".to_string(),
amount: coins(710, NATIVE_FEE_DENOM),
amount: coins(710, NATIVE_DENOM),
});
let burn_msg = SubMsg::new(BankMsg::Burn {
amount: coins(710, NATIVE_FEE_DENOM),
amount: coins(710, NATIVE_DENOM),
});
assert_eq!(res.messages.len(), 2);
assert_eq!(res.messages[0], burn_msg);
Expand Down
17 changes: 6 additions & 11 deletions packages/utils/terp-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ mod route;


pub const NATIVE_DENOM: &str = "uterp";

pub const NATIVE_BOND_DENOM: &str = "uterp";
pub const NATIVE_FEE_DENOM: &str = "uthiol";

pub const TEST_BOND_DENOM: &str = "uterpx";
pub const TEST_FEE_DENOM: &str = "uthiolx";

pub const GENESIS_MINT_START_TIME: u64 = 1647032400000000000;


Expand All @@ -34,10 +29,10 @@ pub use route::TerpRoute;
// extern "C" fn requires_terpnetwork() {}

pub fn terps(amount: impl Into<u128>) -> Vec<Coin> {
coins(amount.into(), NATIVE_BOND_DENOM)
coins(amount.into(), NATIVE_DENOM)
}
pub fn thiols(amount: impl Into<u128>) -> Vec<Coin> {
coins(amount.into(), NATIVE_FEE_DENOM)
coins(amount.into(), NATIVE_DENOM)
}

pub fn test_terps(amount: impl Into<u128>) -> Vec<Coin> {
Expand All @@ -48,19 +43,19 @@ pub fn test_thiols(amount: impl Into<u128>) -> Vec<Coin> {
}

pub fn terp(amount: impl Into<u128>) -> Coin {
coin(amount.into(), NATIVE_BOND_DENOM)
coin(amount.into(), NATIVE_DENOM)
}

pub fn thiol(amount: impl Into<u128>) -> Coin {
coin(amount.into(), NATIVE_FEE_DENOM)
coin(amount.into(), NATIVE_DENOM)
}

pub fn test_terp(amount: impl Into<u128>) -> Coin {
coin(amount.into(), NATIVE_BOND_DENOM)
coin(amount.into(), NATIVE_DENOM)
}

pub fn test_thiol(amount: impl Into<u128>) -> Coin {
coin(amount.into(), NATIVE_FEE_DENOM)
coin(amount.into(), NATIVE_DENOM)
}

pub fn send_terps_msg(to_address: &Addr, amount: impl Into<u128>) -> BankMsg {
Expand Down
39 changes: 22 additions & 17 deletions scripts/nft/flex/01-init-factory.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
# KEY=$(terpd keys show $ADMIN | jq -r .name)
FACTORY_CODE_ID=121
MINTER_CODE_ID=122

MSG=$(cat <<EOF
{
"params": {
"code_id": 80,
"allowed_terp721_code_ids": [83],
"code_id": $MINTER_CODE_ID,
"allowed_terp721_code_ids": [128,68],
"frozen": false,
"creation_fee": {"amount": "20000000000","denom": "uthiolx"},
"min_mint_price": {"amount": "0","denom": "uthiolx"},
"creation_fee": {"amount": "200","denom": "uterp"},
"min_mint_price": {"amount": "0","denom": "uterp"},
"mint_fee_bps": 500,
"max_trading_offset_secs": 604800,
"extension": {
"max_token_limit": 10000,
"max_per_address_limit": 50,
"airdrop_mint_price": {"denom": "uthiolx","amount": "0"},
"airdrop_mint_price": {"denom": "uterp","amount": "0"},
"airdrop_mint_fee_bps": 10000,
"shuffle_fee": {"amount": "500000000","denom": "uthiolx"}
"shuffle_fee": {"amount": "500000000","denom": "uterp"}
}
}
}
EOF
)
echo $MSG

response_command='terpd tx wasm instantiate $FACTORY_CODE_ID "$MSG" --label="vendingfactory" --no-admin --from test1 --gas-prices 0.05uthiolx --gas-adjustment 1.7 --gas auto --chain-id 90u-4 -b sync -o json --yes -o json';
response=$(eval $response_command);
echo $response;

terpd tx wasm instantiate $FACTORY_CODE_ID "$MSG" --label "FeaturedFlexVendingMinterFactory" \
--admin $ADMIN \
--gas-prices 0.025uthiolx --gas 5000000 \
--from $ADMIN \
--generate-only > unsignedTx.json

# terpd tx sign unsignedTx.json \
# --multisig=$ADMIN --from $USER --output-document=$KEY.json \
# --chain-id $CHAIN_ID
if [ -n "$response" ]; then
txhash=$(echo "$response" | jq -r '.txhash')
echo 'waiting for tx to process'
sleep 6;
tx_response=$(terpd q tx $txhash -o json)

# terpd tx multisign unsignedTx.json $MULTISIG_NAME $1 $2 $3 > signedTx.json

# terpd tx broadcast signedTx.json
contract_address=$(echo "$tx_response" | jq -r '.logs[].events[] | select(.type == "instantiate") | .attributes[] | select(.key == "_contract_address") | .value')
echo "Contract Address: $contract_address"
else
echo "Error: Empty response"
fi

10 changes: 5 additions & 5 deletions scripts/nft/terp721-updatable/01-init-factory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ MSG=$(cat <<EOF
"code_id": $MINTER_CODE_ID,
"allowed_terp721_code_ids": [128,68],
"frozen": false,
"creation_fee": {"amount": "10", "denom": "uterpx"},
"min_mint_price": {"amount": "0", "denom": "uterpx"},
"creation_fee": {"amount": "10", "denom": "uterp"},
"min_mint_price": {"amount": "0", "denom": "uterp"},
"mint_fee_bps": 1000,
"max_trading_offset_secs": 604800,
"extension": {
"max_token_limit": 10000,
"max_per_address_limit": 50,
"airdrop_mint_price": { "denom": "uterpx", "amount": "0" },
"airdrop_mint_price": { "denom": "uterp", "amount": "0" },
"airdrop_mint_fee_bps": 10000,
"shuffle_fee": { "amount": "50", "denom": "uterpx" }
"shuffle_fee": { "amount": "50", "denom": "uterp" }
}
}
}
EOF
)
# echo $MSG

response_command='terpd tx wasm i $FACTORY_CODE_ID "$MSG" --label "Factory" --no-admin --gas-prices 0.05uthiolx --gas auto --gas-adjustment 1.9 --from test1 -y -b sync -o json --chain-id 90u-4';
response_command='terpd tx wasm i $FACTORY_CODE_ID "$MSG" --label "Factory" --no-admin --gas-prices 0.05uterp --gas auto --gas-adjustment 1.9 --from wtf -y -b sync -o json ';
response=$(eval $response_command);
# echo $response

Expand Down
4 changes: 2 additions & 2 deletions scripts/nft/terp721-updatable/02-create-minter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MSG=$(cat <<EOF
"base_token_uri": "ipfs://bafybeic3tpnekc44dvapiv3readanraixczuvvpeo7clptt3e4yjffzjzy/IMG_3756.JPG",
"start_time": "$(echo $TIME)000000000",
"num_tokens": 1000,
"mint_price": { "amount": "100", "denom": "uterpx" },
"mint_price": { "amount": "100", "denom": "uterp" },
"per_address_limit": 30
},
"collection_params": {
Expand All @@ -59,7 +59,7 @@ EOF
)

echo $MSG
response_command='terpd tx wasm execute $FACTORY "$MSG" --amount 10uterpx --gas-prices 0.025uthiolx --gas auto --gas-adjustment 1.9 --from test1 -b block -o json';
response_command='terpd tx wasm execute $FACTORY "$MSG" --amount 10uterp --gas-prices 0.025uterp --gas auto --gas-adjustment 1.9 --from test1 -b block -o json';
response=$(eval $response_command);
echo $response

Expand Down
17 changes: 9 additions & 8 deletions scripts/nft/vending-init.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
FACTORY_CODE_ID=117
MINTER_CODE_ID=118
FACTORY_CODE_ID=135
MINTER_CODE_ID=136

MSG=$(cat <<EOF
{
"params": {
"code_id": $MINTER_CODE_ID,
"allowed_terp721_code_ids": [83,68],
"allowed_terp721_code_ids": [68,128],
"frozen": false,
"creation_fee": { "amount": "1000000000", "denom": "uthiolx" },
"min_mint_price": { "amount": "50000000", "denom": "uthiolx" },
"creation_fee": { "amount": "1000000000", "denom": "uterp" },
"min_mint_price": { "amount": "50000000", "denom": "uterp" },
"mint_fee_bps": 1000,
"max_trading_offset_secs": 1209600,
"extension": {
"max_token_limit": 10000,
"max_per_address_limit": 50,
"airdrop_mint_price": { "amount": "0", "denom": "uthiolx" },
"airdrop_mint_price": { "amount": "0", "denom": "uterp" },
"airdrop_mint_fee_bps": 0,
"shuffle_fee": { "amount": "100000000", "denom": "uthiolx" }
"shuffle_fee": { "amount": "100000000", "denom": "uterp" }
}
}
}
Expand All @@ -38,4 +38,5 @@ echo $response;
echo "Contract Address: $contract_address"
else
echo "Error: Empty response"
fi
fi

14 changes: 7 additions & 7 deletions scripts/nft/zero-mint-fee/01-init-factory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
# terpd config output json

KEY=$(terpd keys show $ADMIN | jq -r .name)
FACTORY_CODE_ID=
MINTER_CODE_ID=
FACTORY_CODE_ID=121
MINTER_CODE_ID=122

MSG=$(cat <<EOF
{
"params": {
"code_id": $MINTER_CODE_ID,
"allowed_terp721_code_ids": [1979],
"allowed_terp721_code_ids": [68,128],
"frozen": false,
"creation_fee": {"amount": "5000000000", "denom": "uthiolx"},
"min_mint_price": {"amount": "0", "denom": "uthiolx"},
"creation_fee": {"amount": "5000000", "denom": "uterp"},
"min_mint_price": {"amount": "0", "denom": "uterp"},
"mint_fee_bps": 1000,
"max_trading_offset_secs": 604800,
"extension": {
"max_token_limit": 10000,
"max_per_address_limit": 50,
"airdrop_mint_price": { "denom": "uthiolx", "amount": "0" },
"airdrop_mint_price": { "denom": "uterp", "amount": "0" },
"airdrop_mint_fee_bps": 10000,
"shuffle_fee": { "amount": "500000000", "denom": "uthiolx" }
"shuffle_fee": { "amount": "500000000", "denom": "uterp" }
}
}
}
Expand Down
35 changes: 20 additions & 15 deletions scripts/revenue/residual-registry-instantiate.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CODE_ID=2753
CODE_ID=133
MSG=$(cat <<EOF
{
"config": {
Expand All @@ -9,19 +9,24 @@ MSG=$(cat <<EOF
EOF
)

FROM="hot-wallet"
FROM="test1"
ADMIN=""
CHAIN_ID="elgafar-1"
NODE="https://"
CHAIN_ID="90u-4"

terpd tx wasm instantiate $CODE_ID "$MSG" \
--label "terp-fair-burn" \
--from "$FROM" \
--chain-id "$CHAIN_ID" \
--node "$NODE" \
--gas-prices auto \
--gas-adjustment 1.7 \
--gas auto \
--admin "$ADMIN" \
-b block \
-o json | jq .
response_command='terpd tx wasm i $CODE_ID "$MSG" --label "terp-fair-burn" --from "$FROM" --chain-id "$CHAIN_ID" --gas-prices 0.05uthiolx --gas-adjustment 1.7 --gas auto --admin "$FROM" -b sync -y -o json'
response=$(eval $response_command);
echo $response;


if [ -n "$response" ]; then
txhash=$(echo "$response" | jq -r '.txhash')
echo 'waiting for tx to process'
sleep 6;
tx_response=$(terpd q tx $txhash -o json)

contract_address=$(echo "$tx_response" | jq -r '.logs[].events[] | select(.type == "instantiate") | .attributes[] | select(.key == "_contract_address") | .value')
echo "Contract Address: $contract_address"
else
echo "Error: Empty response"
fi

2 changes: 1 addition & 1 deletion scripts/upload.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
for d in ./artifacts/*.wasm; do
echo $d;
response_command="terpd tx wasm store $d --from test1 --gas-prices 0.05uthiolx --gas-adjustment 1.7 --gas auto --chain-id 90u-4 -b async --yes -o json";
response_command="terpd tx wasm store $d --from test1 --gas-prices 0.05uthiol --gas-adjustment 1.7 --gas auto --chain-id 120u-1 -b async --yes -o json";
response=$(eval $response_command);
if [ -n "$response" ]; then
txhash=$(echo "$response" | jq -r '.txhash')
Expand Down

0 comments on commit ca9ae66

Please sign in to comment.