Skip to content

Commit

Permalink
Release v2 for columbus-5 and bombay-9 (#114)
Browse files Browse the repository at this point in the history
* update for bombay-9 testnet

Co-authored-by: Yun Yeo <[email protected]>
Co-authored-by: brycepratt <[email protected]>
Co-authored-by: Jon Lund Steffensen <[email protected]>
  • Loading branch information
4 people authored Aug 13, 2021
1 parent ab9d7cd commit 34fb928
Show file tree
Hide file tree
Showing 107 changed files with 13,057 additions and 43,452 deletions.
8 changes: 3 additions & 5 deletions integration-tests/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ async function main(): Promise<void> {

const instantiate = new MsgInstantiateContract(
test1.key.accAddress,
null,
+codeId, // code ID
{
count: 0,
}, // InitMsg
{ uluna: 10000000, ukrw: 1000000 }, // init coins
false // migratable
{ count: 0, }, // InitMsg
{ uluna: 10000000, ukrw: 1000000 } // init coins
);

const instantiateTx = await test1.createAndSignTx({
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/estimateFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const test1 = lt.wallets.test1;
const test2 = lt.wallets.test2;

async function main() {
const { data: tequilaGasPrices } = await Axios.get(
'https://tequila-fcd.terra.dev/v1/txs/gas_prices'
const { data: gasPrices } = await Axios.get(
'https://bombay-fcd.terra.dev/v1/txs/gas_prices'
);

const tequila = new LCDClient({
chainID: 'tequila-0004',
URL: 'https://tequila-fcd.terra.dev',
gasPrices: tequilaGasPrices,
chainID: 'bombay-9',
URL: 'https://bombay-lcd.terra.dev',
gasPrices,
});

// Test raw estimate fee function with specified gas
Expand Down
44 changes: 44 additions & 0 deletions integration-tests/executeContract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { LCDClient, MnemonicKey, MsgExecuteContract, Wallet } from '../src';

const client = new LCDClient({
chainID: 'bombay-9',
URL: 'https://bombay-lcd.terra.dev',
});

// LocalTerra test1 terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v
const mk = new MnemonicKey({
mnemonic:
'notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius',
});

const wallet = client.wallet(mk);

async function main() {
const execute = new MsgExecuteContract(
wallet.key.accAddress, // sender
'terra156v8s539wtz0sjpn8y8a8lfg8fhmwa7fy22aff', // contract account address
// handle msg
{
swap: {
offer_asset: {
amount: '1000000',
info: {
native_token: {
denom: 'uluna',
},
},
},
},
},
{ uluna: 1000000 } // coins
);

const executeTx = await wallet.createAndSignTx({
msgs: [execute],
});

const executeTxResult = await client.tx.broadcastSync(executeTx);
console.log(executeTxResult);
}

main().catch(console.error);
145 changes: 145 additions & 0 deletions integration-tests/msgauth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import {
LCDClient,
MnemonicKey,
Wallet,
MsgGrantAuthorization,
SendAuthorization,
MsgSend,
Coins,
MsgExecAuthorized,
MsgRevokeAuthorization,
} from '../src';

function grant(
granter: Wallet,
grantee: Wallet,
spendLimit: Coins.Input,
expiration: Date
) {
const msgs = [
new MsgGrantAuthorization(
granter.key.accAddress,
grantee.key.accAddress,
new SendAuthorization(spendLimit),
expiration
),
];

return granter.createAndSignTx({ msgs });
}

function sendAuthorized(
granter: Wallet,
grantee: Wallet,
to: string,
amount: Coins.Input
) {
const msgs = [
new MsgExecAuthorized(grantee.key.accAddress, [
new MsgSend(
granter.key.accAddress, // From test1
to,
amount
),
]),
];

return grantee.createAndSignTx({ msgs });
}

function revoke(granter: Wallet, grantee: Wallet, msg_type_url: string) {
const msgs = [
new MsgRevokeAuthorization(
granter.key.accAddress,
grantee.key.accAddress,
msg_type_url
),
];

return granter.createAndSignTx({ msgs });
}

async function main() {
const client = new LCDClient({
URL: 'http://localhost:1317',
chainID: 'localterra',
gasPrices: '169.77ukrw',
});

// Granter (terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v)
const granter = client.wallet(
new MnemonicKey({
mnemonic:
'notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius',
})
);

// Grantee (terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp)
const grantee = client.wallet(
new MnemonicKey({
mnemonic:
'quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty',
})
);

// MsgGrantAuthorization
await grant(
granter,
grantee,
// Set enough spend limit since it will be decreased upon every MsgSend transactions
'1000000000000000ukrw',
// expire after 100 year
new Date('2050-01-01')
)
.then(tx => client.tx.broadcast(tx))
.then(console.info)
.catch(err => {
if (err.response) {
console.error(err.response.data);
} else {
console.error(err.message);
}
});

// MsgExecAuthorized of MsgSend
await sendAuthorized(
granter,
grantee,
// Test3
'terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95',
'2000000000000ukrw'
)
.then(tx => client.tx.broadcast(tx))
.then(console.info)
.catch(err => {
if (err.response) {
// unauthorized: authorization not found: failed to execute message; message index: 0: failed to simulate tx
// happenes when there's not enough amount of granted amount of token

// insufficient funds: insufficient account funds; ...
// happenes when granter does not have enough amount of token
console.error(err.response.data);
} else {
console.error(err.message);
}
});

// MsgRevokeAuthorization
await revoke(granter, grantee, '/cosmos.bank.v1beta1.MsgSend')
.then(tx => client.tx.broadcast(tx))
.then(console.info)
.catch(err => {
if (err.response) {
// unauthorized: authorization not found: failed to execute message; message index: 0: failed to simulate tx
// happenes when there's not enough amount of granted amount of token

// insufficient funds: insufficient account funds; ...
// happenes when granter does not have enough amount of token
console.error(err.response.data);
} else {
console.error(err.message);
}
});
}

main().catch(console.error);
42 changes: 21 additions & 21 deletions integration-tests/paramchangeproposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,32 @@ const proposal = new ParameterChangeProposal('testing params', 'yay!', {
SlashFractionDowntime: new Dec(213.123),
},
treasury: {
taxpolicy: new PolicyConstraints(0, 100, new Coin('unused', 0), 3),
rewardpolicy: new PolicyConstraints(
TaxPolicy: new PolicyConstraints(0, 100, new Coin('unused', 0), 3),
RewardPolicy: new PolicyConstraints(
0,
1023423340,
new Coin('unused', 0),
3
),
seigniorageburdentarget: new Dec('2342.234234'),
miningincrement: new Dec(23423423423.234234234234982),
windowshort: 50,
windowlong: 2,
windowprobation: 30,
SeigniorageBurdenTarget: new Dec('2342.234234'),
MiningIncrement: new Dec(23423423423.234234234234982),
WindowShort: 50,
WindowLong: 2,
WindowProbation: 30,
},
oracle: {
voteperiod: 345345,
votethreshold: new Dec('2342.234333'),
rewardband: new Dec('234343'),
rewarddistributionwindow: 345345,
slashfraction: new Dec(23423.232343),
slashwindow: 343311,
minvalidperwindow: new Dec(2342.234234),
VotePeriod: 345345,
VoteThreshold: new Dec('2342.234333'),
RewardBand: new Dec('234343'),
RewardDistributionWindow: 345345,
SlashFraction: new Dec(23423.232343),
SlashWindow: 343311,
MinValidPerWindow: new Dec(2342.234234),
},
market: {
poolrecoveryperiod: 234234234,
basepool: new Dec(232323232),
minstabilityspread: new Dec(343434),
PoolRecoveryPeriod: 234234234,
BasePool: new Dec(232323232),
MinStabilitySpread: new Dec(343434),
},
gov: {
depositparams: {
Expand All @@ -76,7 +76,7 @@ const proposal = new ParameterChangeProposal('testing params', 'yay!', {
tallyparams: {
quorum: new Dec(234234.2334),
threshold: new Dec(23423.2323),
veto: new Dec(1232.234),
veto_threshold: new Dec(1232.234),
},
},
mint: {
Expand All @@ -88,9 +88,9 @@ const proposal = new ParameterChangeProposal('testing params', 'yay!', {
GoalBonded: new Dec(0.01),
},
wasm: {
maxcontractgas: 1000000,
maxcontractmsgsize: 1000000,
maxcontractsize: 1000000,
MaxContractGas: 1000000,
MaxContractMsgSize: 1000000,
MaxContractSize: 1000000,
},
});

Expand Down
35 changes: 35 additions & 0 deletions integration-tests/send.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { LCDClient, MsgSend, MnemonicKey } from '../src';

// create a key out of a mnemonic
const mk = new MnemonicKey({
mnemonic:
'notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius',
});

// To use LocalTerra
const terra = new LCDClient({
URL: 'http://localhost:1317',
chainID: 'localterra',
gasPrices: '169.77ukrw',
});

// a wallet can be created out of any key
// wallets abstract transaction building
const wallet = terra.wallet(mk);

// create a simple message that moves coin balances
const send = new MsgSend(
'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v',
'terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp',
{ uluna: 1000000, ukrw: 1230201, uusd: 1312029 }
);

wallet
.createAndSignTx({
msgs: [send],
memo: 'test from terra.js!',
})
.then(tx => terra.tx.broadcast(tx))
.then(result => {
console.log(`TX hash: ${result.txhash}`);
});
39 changes: 39 additions & 0 deletions integration-tests/submitProposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
Dec,
LCDClient,
MnemonicKey,
MsgSubmitProposal,
TextProposal,
CommunityPoolSpendProposal,
ParameterChangeProposal,
} from '../src';

const client = new LCDClient({
chainID: 'bombay-9',
URL: 'https://bombay-lcd.terra.dev',
});

// LocalTerra test1 terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v
const mk = new MnemonicKey({
mnemonic:
'notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius',
});

const wallet = client.wallet(mk);

async function main() {
const execute = new MsgSubmitProposal(
new TaxRateUpdateProposal('tax rate test', 'tax rate test', new Dec(0.2)),
{ uluna: 10000000 },
wallet.key.accAddress
);

const executeTx = await wallet.createAndSignTx({
msgs: [execute],
});

const executeTxResult = await client.tx.broadcastSync(executeTx);
console.log(executeTxResult);
}

main().catch(console.error);
4 changes: 2 additions & 2 deletions integration-tests/validatorsWithVotingPower.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { LCDClient } from '../src';

const terra = new LCDClient({
chainID: 'columbus-4',
URL: 'https://lcd.terra.dev',
chainID: 'bombay-9',
URL: 'https://bombay-lcd.terra.dev',
});

terra.utils.validatorsWithVotingPower().then(x => console.log(x));
Loading

0 comments on commit 34fb928

Please sign in to comment.