Merge branch 'add-nameservice-scripts'

This commit is contained in:
Simon Warta 2020-02-27 15:25:05 +01:00
commit e1fdda61be
6 changed files with 57 additions and 2 deletions

View File

@ -5,7 +5,7 @@
# Coose from https://hub.docker.com/_/node/
FROM node:12.14.1-alpine
RUN yarn global add @cosmwasm/faucet@0.0.3
RUN yarn global add @cosmwasm/faucet@0.0.8
# Check it exists
RUN /usr/local/bin/cosmwasm-faucet version

View File

@ -1 +1,2 @@
b26861a6aa9858585ed905a590272735bd4fe8177c708940236224e8c9ff73ca cw-erc20.wasm
66128c5c0cd38e6b908b03d41eba8c9e9befb79b34683e334d7a8bbe74d5df41 cw-nameservice.wasm

Binary file not shown.

View File

@ -0,0 +1,53 @@
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/camelcase */
const { SigningCosmWasmClient, Secp256k1Pen } = require("@cosmwasm/sdk");
const fs = require("fs");
const httpUrl = "http://localhost:1317";
const faucet = {
mnemonic:
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone",
address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
};
const initFree = {
name: "Free",
};
const initLuxury = {
name: "Luxury",
purchase_price: {
denom: "ucosm",
amount: "2000000",
},
transfer_price: {
denom: "ucosm",
amount: "1000000",
},
};
async function main() {
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
const wasm = fs.readFileSync(__dirname + "/contracts/cw-nameservice.wasm");
const uploadReceipt = await client.upload(wasm, "Upload Name Service contract");
console.info(`Upload succeeded. Receipt: ${JSON.stringify(uploadReceipt)}`);
for (const initMsg of [initFree, initLuxury]) {
const memo = `Create an nameservice instance for ${initMsg.name}`;
const contractAddress = await client.instantiate(uploadReceipt.codeId, initMsg, memo);
console.info(`Contract instantiated for ${initMsg.name} at ${contractAddress}`);
}
}
main().then(
() => {
console.info("Done deploying nameservice instances.");
process.exit(0);
},
error => {
console.error(error);
process.exit(1);
},
);

View File

@ -10,3 +10,4 @@ echo "Okay, thank you for your patience."
SCRIPT_DIR="$(realpath "$(dirname "$0")")"
"$SCRIPT_DIR/deploy_erc20.js"
"$SCRIPT_DIR/deploy_nameservice.js"

View File

@ -34,7 +34,7 @@ echo "wasmd running and logging into $WASMD_LOGFILE"
# sleep 3 && cat "$WASMD_LOGFILE"
# Use a large timeout because of potentially long image download in `docker run`
if ! timeout 120 bash -c "until docker inspect -f '{{.State.Running}}' '$CONTAINER_NAME' &> /dev/null; do sleep 0.5; done"; then
if ! timeout 180 bash -c "until docker inspect -f '{{.State.Running}}' '$CONTAINER_NAME' &> /dev/null; do sleep 0.5; done"; then
echo "Container named '$CONTAINER_NAME' not running. We cannot continue." \
"This can happen when 'docker run' needs too long to download and start." \
"It might be worth retrying this step once the image is in the local docker cache."