Skip to content

Commit

Permalink
send tokens to accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds committed Aug 21, 2023
1 parent 3961079 commit aa56519
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages-ts/gauntlet-cosmos-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"preinstall": "node ../../scripts/require-yarn.js",
"gauntlet": "ts-node ./src/index.ts",
"lint": "tsc",
"test:debug:wasmd-up": "yarn ts-node ./test/scripts/startWasmdAndUpload.ts",
"test:debug": "yarn test:codegen && SKIP_WASMD_SETUP=true yarn test",
"dev:test:wasmd-up": "yarn ts-node ./test/scripts/startWasmdAndUpload.ts",
"dev:test": "yarn test:codegen && SKIP_WASMD_SETUP=true yarn test",
"test": "yarn test:codegen && SKIP_PROMPTS=true jest --runInBand --config ../../jest.config.js --selectProjects gauntlet-cosmos-contracts --passWithNoTests",
"test:codegen": "yarn node ./src/scripts/codegen.js",
"test:coverage": "yarn test --collectCoverage",
Expand Down
32 changes: 20 additions & 12 deletions packages-ts/gauntlet-cosmos-contracts/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing'
import { DirectSecp256k1HdWallet, coins } from '@cosmjs/proto-signing'
import { execSync } from 'child_process'
import { readFileSync, writeFileSync } from 'fs'
import path from 'path'

import UploadCmd from '../src/commands/tooling/upload'
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { GasPrice } from '@cosmjs/stargate'

const MNEMONIC =
'surround miss nominee dream gap cross assault thank captain prosper drop duty group candy wealth weather scale put'
Expand Down Expand Up @@ -70,21 +72,27 @@ export const startWasmdAndUpload = async () => {
const otherAddresses = accounts.map((a) => a.address).join(' ')
const wasmdScript = path.join(__dirname, '../../../scripts/wasmd.sh')

execSync(`${wasmdScript} ${otherAddresses}`)
execSync(wasmdScript)

// querying wasmd too soon will result in errors
await new Promise((f) => setTimeout(f, 10000))

const deployerWallet = await DirectSecp256k1HdWallet.fromMnemonic(MNEMONIC, { prefix: 'wasm' })
const deployerAccounts = await deployerWallet.getAccounts()
const deployerAccount = deployerAccounts[0]
const deployer = await SigningCosmWasmClient.connectWithSigner(NODE_URL, deployerWallet, {
gasPrice: GasPrice.fromString(DEFAULT_GAS_PRICE),
})

// initialize other accounts with some tokens
for (const a of accounts) {
await deployer.sendTokens(deployerAccount.address, a.address, coins("1", "ucosm"), "auto")
}

// retrieve default deployer account
const deployerAccount = await (async () => {
const deployerWallet = await DirectSecp256k1HdWallet.fromMnemonic(MNEMONIC, { prefix: 'wasm' })
const deployerAccounts = await deployerWallet.getAccounts()
return deployerAccounts[0]
})()
accounts = [deployerAccount, ...accounts]

console.log(`All accounts initialized ${deployerAccount.address} ${otherAddresses}`)

// querying wasmd too soon will result in errors
await new Promise((f) => setTimeout(f, 10000))

// upload contracts
process.env.SKIP_PROMPTS = 'true'

Expand All @@ -94,7 +102,7 @@ export const startWasmdAndUpload = async () => {
mnemonic: MNEMONIC,
nodeURL: NODE_URL,
gauntletTest: true,
defaultGasPrice: '0.025ucosm',
defaultGasPrice: DEFAULT_GAS_PRICE,
},
[],
)
Expand Down
3 changes: 1 addition & 2 deletions scripts/wasmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ docker run \
--name "${container_name}" \
"cosmwasm/wasmd:${container_version}" \
"./setup_and_run.sh" \
"${genesis_account}" \
"$@"
"${genesis_account}"

echo "Waiting for wasmd container to become ready.."
start_time=$(date +%s)
Expand Down

0 comments on commit aa56519

Please sign in to comment.