diff --git a/docs/faucet.Dockerfile b/docs/faucet.Dockerfile index d863b964..6717cea8 100644 --- a/docs/faucet.Dockerfile +++ b/docs/faucet.Dockerfile @@ -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 diff --git a/scripts/wasmd/contracts/checksums.sha256 b/scripts/wasmd/contracts/checksums.sha256 index b36dcaa7..1b838408 100644 --- a/scripts/wasmd/contracts/checksums.sha256 +++ b/scripts/wasmd/contracts/checksums.sha256 @@ -1 +1,2 @@ b26861a6aa9858585ed905a590272735bd4fe8177c708940236224e8c9ff73ca cw-erc20.wasm +66128c5c0cd38e6b908b03d41eba8c9e9befb79b34683e334d7a8bbe74d5df41 cw-nameservice.wasm diff --git a/scripts/wasmd/contracts/cw-nameservice.wasm b/scripts/wasmd/contracts/cw-nameservice.wasm new file mode 100644 index 00000000..507127c0 Binary files /dev/null and b/scripts/wasmd/contracts/cw-nameservice.wasm differ diff --git a/scripts/wasmd/deploy_nameservice.js b/scripts/wasmd/deploy_nameservice.js new file mode 100755 index 00000000..354162d4 --- /dev/null +++ b/scripts/wasmd/deploy_nameservice.js @@ -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); + }, +); diff --git a/scripts/wasmd/init.sh b/scripts/wasmd/init.sh index f465bb73..389f3725 100755 --- a/scripts/wasmd/init.sh +++ b/scripts/wasmd/init.sh @@ -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" diff --git a/scripts/wasmd/start.sh b/scripts/wasmd/start.sh index 48d03931..f0c56902 100755 --- a/scripts/wasmd/start.sh +++ b/scripts/wasmd/start.sh @@ -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."