scripts: Deploy hackatom contract in wasmd
This commit is contained in:
parent
833b46a713
commit
27d723f6d9
76
scripts/wasmd/deploy_hackatom.js
Executable file
76
scripts/wasmd/deploy_hackatom.js
Executable file
@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
const { DirectSecp256k1HdWallet } = require("@cosmjs/proto-signing");
|
||||
const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm-stargate");
|
||||
const fs = require("fs");
|
||||
|
||||
const endpoint = "http://localhost:26659";
|
||||
const alice = {
|
||||
mnemonic: "enlist hip relief stomach skate base shallow young switch frequent cry park",
|
||||
address0: "wasm14qemq0vw6y3gc3u3e0aty2e764u4gs5lndxgyk",
|
||||
address1: "wasm1hhg2rlu9jscacku2wwckws7932qqqu8xm5ca8y",
|
||||
address2: "wasm1xv9tklw7d82sezh9haa573wufgy59vmwnxhnsl",
|
||||
address3: "wasm17yg9mssjenmc3jkqth6ulcwj9cxujrxxg9nmzk",
|
||||
address4: "wasm1f7j7ryulwjfe9ljplvhtcaxa6wqgula3nh873j",
|
||||
};
|
||||
|
||||
const codeMeta = {
|
||||
source: "https://crates.io/api/v1/crates/hackatom/not-yet-released/download",
|
||||
builder: "cosmwasm/rust-optimizer:0.9.1",
|
||||
};
|
||||
|
||||
const inits = [
|
||||
{
|
||||
label: "From deploy_hackatom.js (0)",
|
||||
msg: {
|
||||
beneficiary: alice.address0,
|
||||
verifier: alice.address0,
|
||||
},
|
||||
admin: undefined,
|
||||
},
|
||||
{
|
||||
label: "From deploy_hackatom.js (1)",
|
||||
msg: {
|
||||
beneficiary: alice.address1,
|
||||
verifier: alice.address1,
|
||||
},
|
||||
admin: undefined,
|
||||
},
|
||||
{
|
||||
label: "From deploy_hackatom.js (2)",
|
||||
msg: {
|
||||
beneficiary: alice.address2,
|
||||
verifier: alice.address2,
|
||||
},
|
||||
admin: alice.address1,
|
||||
},
|
||||
];
|
||||
|
||||
async function main() {
|
||||
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(alice.mnemonic, undefined, "wasm");
|
||||
const client = await SigningCosmWasmClient.connectWithWallet(endpoint, wallet);
|
||||
|
||||
const wasm = fs.readFileSync(__dirname + "/contracts/hackatom.wasm");
|
||||
const uploadReceipt = await client.upload(alice.address0, wasm, codeMeta, "Upload hackatom contract");
|
||||
console.info(`Upload succeeded. Receipt: ${JSON.stringify(uploadReceipt)}`);
|
||||
|
||||
for (const { label, msg, admin } of inits) {
|
||||
const { contractAddress } = await client.instantiate(alice.address0, uploadReceipt.codeId, msg, label, {
|
||||
memo: `Create a hackatom instance in deploy_hackatom.js`,
|
||||
admin: admin,
|
||||
});
|
||||
console.info(`Contract instantiated at ${contractAddress}`);
|
||||
}
|
||||
}
|
||||
|
||||
main().then(
|
||||
() => {
|
||||
console.info("All done, let the coins flow.");
|
||||
process.exit(0);
|
||||
},
|
||||
(error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
},
|
||||
);
|
||||
@ -5,7 +5,7 @@ command -v shellcheck >/dev/null && shellcheck "$0"
|
||||
echo "Waiting for blockchain and REST server to be available ..."
|
||||
timeout 60 bash -c "until curl -s http://localhost:1319/node_info > /dev/null; do sleep 0.5; done"
|
||||
# The chain is unreliable in the first second of its existence (https://gist.github.com/webmaster128/8175692d4af5e6c572fddda7a9ef437c)
|
||||
sleep 1
|
||||
sleep 2
|
||||
echo "Waiting for height to be >= 1 ..."
|
||||
timeout 20 bash -c "until [ \"\$( curl -s http://localhost:1319/blocks/latest | jq -r '.block.header.height // 0' )\" -ge 1 ]; do sleep 0.5; done"
|
||||
echo "Okay, thank you for your patience."
|
||||
@ -25,7 +25,7 @@ SCRIPT_DIR="$(realpath "$(dirname "$0")")"
|
||||
cd "$SCRIPT_DIR/contracts"
|
||||
sha256sum --check checksums.sha256
|
||||
)
|
||||
# "$SCRIPT_DIR/deploy_hackatom.js"
|
||||
"$SCRIPT_DIR/deploy_hackatom.js"
|
||||
# "$SCRIPT_DIR/deploy_erc20.js"
|
||||
# "$SCRIPT_DIR/deploy_cw3.js"
|
||||
# "$SCRIPT_DIR/deploy_cw1.js"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user