From 3e5fbd494830c456d9c6676fae33472a00321c08 Mon Sep 17 00:00:00 2001 From: willclarktech Date: Tue, 4 Aug 2020 17:15:00 +0200 Subject: [PATCH 1/4] demo-staking -> :fire: --- packages/demo-staking/.eslintignore | 1 - packages/demo-staking/.gitignore | 3 - packages/demo-staking/.nycrc.yml | 1 - packages/demo-staking/README.md | 8 - packages/demo-staking/jasmine-testrunner.js | 33 --- packages/demo-staking/karma.conf.js | 47 ----- packages/demo-staking/nonces/1590408566 | 0 packages/demo-staking/nonces/1591794433 | 0 packages/demo-staking/nonces/1593326040 | 0 packages/demo-staking/nonces/1593614735 | 0 packages/demo-staking/nonces/1595941909 | 0 packages/demo-staking/nonces/1596020444 | 0 packages/demo-staking/nonces/1596461867 | 0 packages/demo-staking/nonces/README.txt | 1 - packages/demo-staking/package.json | 40 ---- packages/demo-staking/src/index.spec.ts | 146 -------------- packages/demo-staking/src/index.ts | 0 packages/demo-staking/src/schema.d.ts | 210 -------------------- packages/demo-staking/tsconfig.json | 12 -- packages/demo-staking/types/index.d.ts | 0 packages/demo-staking/webpack.web.config.js | 19 -- 21 files changed, 521 deletions(-) delete mode 120000 packages/demo-staking/.eslintignore delete mode 100644 packages/demo-staking/.gitignore delete mode 120000 packages/demo-staking/.nycrc.yml delete mode 100644 packages/demo-staking/README.md delete mode 100755 packages/demo-staking/jasmine-testrunner.js delete mode 100644 packages/demo-staking/karma.conf.js delete mode 100644 packages/demo-staking/nonces/1590408566 delete mode 100644 packages/demo-staking/nonces/1591794433 delete mode 100644 packages/demo-staking/nonces/1593326040 delete mode 100644 packages/demo-staking/nonces/1593614735 delete mode 100644 packages/demo-staking/nonces/1595941909 delete mode 100644 packages/demo-staking/nonces/1596020444 delete mode 100644 packages/demo-staking/nonces/1596461867 delete mode 100644 packages/demo-staking/nonces/README.txt delete mode 100644 packages/demo-staking/package.json delete mode 100644 packages/demo-staking/src/index.spec.ts delete mode 100644 packages/demo-staking/src/index.ts delete mode 100644 packages/demo-staking/src/schema.d.ts delete mode 100644 packages/demo-staking/tsconfig.json delete mode 100644 packages/demo-staking/types/index.d.ts delete mode 100644 packages/demo-staking/webpack.web.config.js diff --git a/packages/demo-staking/.eslintignore b/packages/demo-staking/.eslintignore deleted file mode 120000 index 86039baf..00000000 --- a/packages/demo-staking/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -../../.eslintignore \ No newline at end of file diff --git a/packages/demo-staking/.gitignore b/packages/demo-staking/.gitignore deleted file mode 100644 index 68bf3735..00000000 --- a/packages/demo-staking/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -build/ -dist/ -docs/ diff --git a/packages/demo-staking/.nycrc.yml b/packages/demo-staking/.nycrc.yml deleted file mode 120000 index 1f95ac55..00000000 --- a/packages/demo-staking/.nycrc.yml +++ /dev/null @@ -1 +0,0 @@ -../../.nycrc.yml \ No newline at end of file diff --git a/packages/demo-staking/README.md b/packages/demo-staking/README.md deleted file mode 100644 index eceb8751..00000000 --- a/packages/demo-staking/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# @cosmjs/demo-staking - -## License - -This package is part of the cosmjs repository, licensed under the Apache -License 2.0 (see -[NOTICE](https://github.com/CosmWasm/cosmjs/blob/master/NOTICE) and -[LICENSE](https://github.com/CosmWasm/cosmjs/blob/master/LICENSE)). diff --git a/packages/demo-staking/jasmine-testrunner.js b/packages/demo-staking/jasmine-testrunner.js deleted file mode 100755 index 7a17962e..00000000 --- a/packages/demo-staking/jasmine-testrunner.js +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node - -/* eslint-disable @typescript-eslint/naming-convention */ -require("source-map-support").install(); -const defaultSpecReporterConfig = require("../../jasmine-spec-reporter.config.json"); - -// setup Jasmine -const Jasmine = require("jasmine"); -const jasmine = new Jasmine(); -jasmine.loadConfig({ - spec_dir: "build", - spec_files: ["**/*.spec.js"], - helpers: [], - random: false, - seed: null, - stopSpecOnExpectationFailure: false, -}); -jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 15 * 1000; - -// setup reporter -const { SpecReporter } = require("jasmine-spec-reporter"); -const reporter = new SpecReporter({ - ...defaultSpecReporterConfig, - spec: { - ...defaultSpecReporterConfig.spec, - displaySuccessful: !process.argv.includes("--quiet"), - }, -}); - -// initialize and execute -jasmine.env.clearReporters(); -jasmine.addReporter(reporter); -jasmine.execute(); diff --git a/packages/demo-staking/karma.conf.js b/packages/demo-staking/karma.conf.js deleted file mode 100644 index 006da5fe..00000000 --- a/packages/demo-staking/karma.conf.js +++ /dev/null @@ -1,47 +0,0 @@ -module.exports = function (config) { - config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: ".", - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ["jasmine"], - - // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], - - client: { - jasmine: { - random: false, - timeoutInterval: 15000, - }, - }, - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ["progress", "kjhtml"], - - // web server port - port: 9876, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ["Firefox"], - - browserNoActivityTimeout: 90000, - - // Keep brower open for debugging. This is overridden by yarn scripts - singleRun: false, - }); -}; diff --git a/packages/demo-staking/nonces/1590408566 b/packages/demo-staking/nonces/1590408566 deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/nonces/1591794433 b/packages/demo-staking/nonces/1591794433 deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/nonces/1593326040 b/packages/demo-staking/nonces/1593326040 deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/nonces/1593614735 b/packages/demo-staking/nonces/1593614735 deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/nonces/1595941909 b/packages/demo-staking/nonces/1595941909 deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/nonces/1596020444 b/packages/demo-staking/nonces/1596020444 deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/nonces/1596461867 b/packages/demo-staking/nonces/1596461867 deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/nonces/README.txt b/packages/demo-staking/nonces/README.txt deleted file mode 100644 index 092fe732..00000000 --- a/packages/demo-staking/nonces/README.txt +++ /dev/null @@ -1 +0,0 @@ -Directory used to trigger lerna package updates for all packages diff --git a/packages/demo-staking/package.json b/packages/demo-staking/package.json deleted file mode 100644 index 07da15ae..00000000 --- a/packages/demo-staking/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@cosmjs/demo-staking", - "version": "0.22.0", - "description": "Demo interaction with the staking contract", - "author": "Simon Warta ", - "license": "Apache-2.0", - "main": "build/index.js", - "types": "types/index.d.ts", - "files": [ - "build/", - "types/", - "*.md", - "!*.spec.*", - "!**/testdata/" - ], - "repository": { - "type": "git", - "url": "https://github.com/CosmWasm/cosmjs/tree/master/packages/demo-staking" - }, - "private": true, - "scripts": { - "format": "prettier --write --loglevel warn \"./src/**/*.ts\"", - "lint": "eslint --max-warnings 0 \"**/*.{js,ts}\"", - "lint-fix": "eslint --max-warnings 0 \"**/*.{js,ts}\" --fix", - "move-types": "shx rm -rf ./types/* && shx mv build/types/* ./types && rm -rf ./types/testdata && shx rm -f ./types/*.spec.d.ts", - "format-types": "prettier --write --loglevel warn \"./types/**/*.d.ts\"", - "build": "shx rm -rf ./build && tsc && yarn move-types && yarn format-types", - "build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build", - "test-node": "node jasmine-testrunner.js", - "test-firefox": "yarn pack-web && karma start --single-run --browsers Firefox", - "test-chrome": "yarn pack-web && karma start --single-run --browsers ChromeHeadless", - "test": "yarn build-or-skip && yarn test-node", - "coverage": "nyc --reporter=text --reporter=lcov yarn test --quiet", - "pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js" - }, - "dependencies": { - "@cosmjs/cosmwasm": "^0.22.0", - "@cosmjs/launchpad": "^0.22.0" - } -} diff --git a/packages/demo-staking/src/index.spec.ts b/packages/demo-staking/src/index.spec.ts deleted file mode 100644 index 2e711ae6..00000000 --- a/packages/demo-staking/src/index.spec.ts +++ /dev/null @@ -1,146 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import { SigningCosmWasmClient } from "@cosmjs/cosmwasm"; -import { Coin, coins, makeCosmoshubPath, Secp256k1Wallet } from "@cosmjs/launchpad"; - -import { - BalanceResponse, - HandleMsg, - InitMsg, - InvestmentResponse, - QueryMsg, - TokenInfoResponse, -} from "./schema"; - -function pendingWithoutWasmd(): void { - if (!process.env.WASMD_ENABLED) { - return pending("Set WASMD_ENABLED to enable Cosmos node-based tests"); - } -} - -const httpUrl = "http://localhost:1317"; -const alice = { - mnemonic: "enlist hip relief stomach skate base shallow young switch frequent cry park", - address0: "cosmos14qemq0vw6y3gc3u3e0aty2e764u4gs5le3hada", -}; - -/** Code info staking.wasm */ -const codeId = 3; - -/** Instance parameters */ -const params = { - name: "Bounty", - symbol: "BOUNTY", - decimals: 3, - validator: "cosmosvaloper1e9zn2ueue2m0edjhmsgsf03yfcmeg7m7xh5xu5", - exitTax: "0.005", // 0.5 % - minWithdrawal: "700", -}; - -describe("Staking demo", () => { - it("works", async () => { - pendingWithoutWasmd(); - // The owner of the contract that will collect the tax - const ownerWallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); - const [{ address: ownerAddress }] = await ownerWallet.getAccounts(); - const ownerClient = new SigningCosmWasmClient(httpUrl, ownerAddress, ownerWallet); - - // a user of the contract - const userWallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic, makeCosmoshubPath(1)); - const [{ address: userAddress }] = await userWallet.getAccounts(); - const userClient = new SigningCosmWasmClient(httpUrl, userAddress, userWallet, { - exec: { - amount: coins(5000, "ucosm"), - gas: "300000", // 300k, needed for unbonding - }, - }); - - const initMsg: InitMsg = { - name: params.name, - symbol: params.symbol, - decimals: params.decimals, - validator: params.validator, - exit_tax: params.exitTax, - min_withdrawal: params.minWithdrawal, - }; - const { contractAddress } = await ownerClient.instantiate( - codeId, - initMsg, - `Staking derivative BOUNTY ${new Date()}`, - ); - - // Query token info (immutable) - { - const query: QueryMsg = { token_info: {} }; - const response: TokenInfoResponse = await ownerClient.queryContractSmart(contractAddress, query); - expect(response).toEqual({ - decimals: params.decimals, - name: params.name, - symbol: params.symbol, - }); - } - - // Query investment info (changes with bonding/unbonding) - { - const query: QueryMsg = { investment: {} }; - const response: InvestmentResponse = await ownerClient.queryContractSmart(contractAddress, query); - expect(response).toEqual({ - token_supply: "0", - staked_tokens: { denom: "ustake", amount: "0" }, - nominal_value: "1", - owner: ownerAddress, - exit_tax: params.exitTax, - validator: params.validator, - min_withdrawal: params.minWithdrawal, - }); - } - - const bondMsg: HandleMsg = { bond: {} }; - const amount: Coin = { - amount: "112233", - denom: "ustake", - }; - await userClient.execute(contractAddress, bondMsg, undefined, [amount]); - - // Investment info changed - { - const quer: QueryMsg = { investment: {} }; - const response: InvestmentResponse = await ownerClient.queryContractSmart(contractAddress, quer); - expect(response).toEqual({ - token_supply: "112233", - staked_tokens: { denom: "ustake", amount: "112233" }, - nominal_value: "1", - owner: ownerAddress, - exit_tax: params.exitTax, - validator: params.validator, - min_withdrawal: params.minWithdrawal, - }); - } - - // Get balance - { - const query: QueryMsg = { balance: { address: userAddress } }; - const response: BalanceResponse = await ownerClient.queryContractSmart(contractAddress, query); - expect(response).toEqual({ - balance: "112233", - }); - } - - const unbondMsg: HandleMsg = { unbond: { amount: "110000" } }; - // await ownerClient.execute(contractAddress, unbondMsg); - await userClient.execute(contractAddress, unbondMsg); - - // Get balance - { - const query: QueryMsg = { balance: { address: userAddress } }; - const response: BalanceResponse = await ownerClient.queryContractSmart(contractAddress, query); - expect(response).toEqual({ balance: "2233" }); - } - - // Check collected tax (0.5 % of 110000) - { - const query: QueryMsg = { balance: { address: ownerAddress } }; - const response: BalanceResponse = await ownerClient.queryContractSmart(contractAddress, query); - expect(response).toEqual({ balance: "550" }); - } - }); -}); diff --git a/packages/demo-staking/src/index.ts b/packages/demo-staking/src/index.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/src/schema.d.ts b/packages/demo-staking/src/schema.d.ts deleted file mode 100644 index 371ee2ff..00000000 --- a/packages/demo-staking/src/schema.d.ts +++ /dev/null @@ -1,210 +0,0 @@ -/* - * This file was generated with ❤️ by wasm.glass and is licensed - * for you under WTFPL OR 0BSD OR Unlicense OR MIT OR BSD-3-Clause. - * Note that different terms apply for the contract's source code and schema. - * Type generation powered by json-schema-to-typescript. - */ - -export interface BalanceResponse { - balance: string; - [k: string]: unknown; -} - -export interface ClaimsResponse { - claims: string; - [k: string]: unknown; -} - -export type HandleMsg = - | { - transfer: { - amount: string; - recipient: string; - [k: string]: unknown; - }; - [k: string]: unknown; - } - | { - bond: { - [k: string]: unknown; - }; - [k: string]: unknown; - } - | { - unbond: { - amount: string; - [k: string]: unknown; - }; - [k: string]: unknown; - } - | { - claim: { - [k: string]: unknown; - }; - [k: string]: unknown; - } - | { - reinvest: { - [k: string]: unknown; - }; - [k: string]: unknown; - } - | { - __bond_all_tokens: { - [k: string]: unknown; - }; - [k: string]: unknown; - }; - -export interface InitMsg { - /** - * decimal places of the derivative token (for UI) TODO: does this make sense? Do we need to normalize on this? We don't even know the decimals of the native token - */ - decimals: number; - /** - * this is how much the owner takes as a cut when someone unbonds TODO - */ - exit_tax: string; - /** - * This is the minimum amount we will pull out to reinvest, as well as a minumum that can be unbonded (to avoid needless staking tx) - */ - min_withdrawal: string; - /** - * name of the derivative token (FIXME: auto-generate?) - */ - name: string; - /** - * symbol / ticker of the derivative token - */ - symbol: string; - /** - * This is the validator that all tokens will be bonded to - */ - validator: string; - [k: string]: unknown; -} - -/** - * Investment info is fixed at initialization, and is used to control the function of the contract - */ -export interface InvestmentInfo { - /** - * this is the denomination we can stake (and only one we accept for payments) - */ - bond_denom: string; - /** - * this is how much the owner takes as a cut when someone unbonds - */ - exit_tax: string; - /** - * This is the minimum amount we will pull out to reinvest, as well as a minumum that can be unbonded (to avoid needless staking tx) - */ - min_withdrawal: string; - /** - * owner created the contract and takes a cut - */ - owner: string; - /** - * All tokens are bonded to this validator FIXME: humanize/canonicalize address doesn't work for validator addrresses - */ - validator: string; - [k: string]: unknown; -} - -export interface InvestmentResponse { - /** - * this is how much the owner takes as a cut when someone unbonds - */ - exit_tax: string; - /** - * This is the minimum amount we will pull out to reinvest, as well as a minumum that can be unbonded (to avoid needless staking tx) - */ - min_withdrawal: string; - /** - * A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 - * - * The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) - */ - nominal_value: string; - /** - * owner created the contract and takes a cut - */ - owner: string; - staked_tokens: { - amount: string; - denom: string; - [k: string]: unknown; - }; - token_supply: string; - /** - * All tokens are bonded to this validator - */ - validator: string; - [k: string]: unknown; -} - -export type QueryMsg = - | { - balance: { - address: string; - [k: string]: unknown; - }; - [k: string]: unknown; - } - | { - claims: { - address: string; - [k: string]: unknown; - }; - [k: string]: unknown; - } - | { - token_info: { - [k: string]: unknown; - }; - [k: string]: unknown; - } - | { - investment: { - [k: string]: unknown; - }; - [k: string]: unknown; - }; - -/** - * Supply is dynamic and tracks the current supply of staked and ERC20 tokens. - */ -export interface Supply { - /** - * bonded is how many native tokens exist bonded to the validator - */ - bonded: string; - /** - * claims is how many tokens need to be reserved paying back those who unbonded - */ - claims: string; - /** - * issued is how many derivative tokens this contract has issued - */ - issued: string; - [k: string]: unknown; -} - -/** - * TokenInfoResponse is info to display the derivative token in a UI - */ -export interface TokenInfoResponse { - /** - * decimal places of the derivative token (for UI) - */ - decimals: number; - /** - * name of the derivative token - */ - name: string; - /** - * symbol / ticker of the derivative token - */ - symbol: string; - [k: string]: unknown; -} diff --git a/packages/demo-staking/tsconfig.json b/packages/demo-staking/tsconfig.json deleted file mode 100644 index 167e8c02..00000000 --- a/packages/demo-staking/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "baseUrl": ".", - "outDir": "build", - "declarationDir": "build/types", - "rootDir": "src" - }, - "include": [ - "src/**/*" - ] -} diff --git a/packages/demo-staking/types/index.d.ts b/packages/demo-staking/types/index.d.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/demo-staking/webpack.web.config.js b/packages/demo-staking/webpack.web.config.js deleted file mode 100644 index 7373cace..00000000 --- a/packages/demo-staking/webpack.web.config.js +++ /dev/null @@ -1,19 +0,0 @@ -const glob = require("glob"); -const path = require("path"); -const webpack = require("webpack"); - -const target = "web"; -const distdir = path.join(__dirname, "dist", "web"); - -module.exports = [ - { - // bundle used for Karma tests - target: target, - entry: glob.sync("./build/**/*.spec.js"), - output: { - path: distdir, - filename: "tests.js", - }, - plugins: [new webpack.EnvironmentPlugin(["WASMD_ENABLED"])], - }, -]; From cf6dc3ec457bf897a7bb8e1aaa72af7a8f4bd959 Mon Sep 17 00:00:00 2001 From: willclarktech Date: Tue, 4 Aug 2020 17:25:11 +0200 Subject: [PATCH 2/4] scripts: Remove .gitignore from wasmd --- scripts/wasmd/.gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 scripts/wasmd/.gitignore diff --git a/scripts/wasmd/.gitignore b/scripts/wasmd/.gitignore deleted file mode 100644 index 3f8523cf..00000000 --- a/scripts/wasmd/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.gaiacli/keys/ -.gaiad/data/ From 43b1830f092cb438a45909c5ef402bb32834fb17 Mon Sep 17 00:00:00 2001 From: willclarktech Date: Tue, 4 Aug 2020 17:26:45 +0200 Subject: [PATCH 3/4] scripts: Remove staking from wasmd --- scripts/wasmd/contracts/checksums.sha256 | 1 - scripts/wasmd/contracts/staking.wasm | 3 -- scripts/wasmd/deploy_staking.js | 65 ------------------------ scripts/wasmd/init.sh | 1 - 4 files changed, 70 deletions(-) delete mode 100644 scripts/wasmd/contracts/staking.wasm delete mode 100755 scripts/wasmd/deploy_staking.js diff --git a/scripts/wasmd/contracts/checksums.sha256 b/scripts/wasmd/contracts/checksums.sha256 index 20fa2c37..1d16d387 100644 --- a/scripts/wasmd/contracts/checksums.sha256 +++ b/scripts/wasmd/contracts/checksums.sha256 @@ -1,3 +1,2 @@ 0f14abcc6fed08f2dd06896db974989db97dbcc6e8e30188b73fe5ab427c7785 cw-erc20.wasm ebc2b11e2afa50d5dcd4234840cd581e948a59d888bb8d651598bba3732cd8ee cw-nameservice.wasm -9430a98aa5bb765aa56f683290340e34e230822a4e356d566b54b9b5cf01ab30 staking.wasm diff --git a/scripts/wasmd/contracts/staking.wasm b/scripts/wasmd/contracts/staking.wasm deleted file mode 100644 index b7ed883e..00000000 --- a/scripts/wasmd/contracts/staking.wasm +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9430a98aa5bb765aa56f683290340e34e230822a4e356d566b54b9b5cf01ab30 -size 213411 diff --git a/scripts/wasmd/deploy_staking.js b/scripts/wasmd/deploy_staking.js deleted file mode 100755 index dad46c12..00000000 --- a/scripts/wasmd/deploy_staking.js +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env node - -/* eslint-disable @typescript-eslint/naming-convention */ -const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm"); -const { coins, Secp256k1Wallet } = require("@cosmjs/launchpad"); -const fs = require("fs"); - -const httpUrl = "http://localhost:1317"; -const alice = { - mnemonic: "enlist hip relief stomach skate base shallow young switch frequent cry park", - address0: "cosmos14qemq0vw6y3gc3u3e0aty2e764u4gs5le3hada", -}; - -const codeMeta = { - source: "", // not intended to be published - builder: "cosmwasm/rust-optimizer:0.8.0", -}; - -// To get the proper validator address, run the demo chain (./scripts/wasmd/start.sh), then run: -// curl http://localhost:1317/staking/validators | jq '.result[0].operator_address' -const bounty = { - label: "Bounty", - initMsg: { - name: "Bounty", - symbol: "BOUNTY", - decimals: 3, - validator: "cosmosvaloper1e9zn2ueue2m0edjhmsgsf03yfcmeg7m7xh5xu5", - exit_tax: "0.005", // 0.5 % - min_withdrawal: "7", - }, -}; - -const fees = { - upload: { - amount: coins(25000, "ucosm"), - gas: "1500000", // 1.5 million - }, -}; - -async function main() { - const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); - const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet, fees); - - const wasm = fs.readFileSync(__dirname + "/contracts/staking.wasm"); - const uploadReceipt = await client.upload(wasm, codeMeta, "Upload Staking code"); - console.info(`Upload succeeded. Receipt: ${JSON.stringify(uploadReceipt)}`); - - for (const { label, initMsg } of [bounty]) { - const { contractAddress } = await client.instantiate(uploadReceipt.codeId, initMsg, label, { - memo: `Create an staking instance "${label}"`, - }); - console.info(`Contract "${label}" instantiated at ${contractAddress}`); - } -} - -main().then( - () => { - console.info("Done deploying staking instances."); - process.exit(0); - }, - (error) => { - console.error(error); - process.exit(1); - }, -); diff --git a/scripts/wasmd/init.sh b/scripts/wasmd/init.sh index 48a2e687..26356a50 100755 --- a/scripts/wasmd/init.sh +++ b/scripts/wasmd/init.sh @@ -26,4 +26,3 @@ SCRIPT_DIR="$(realpath "$(dirname "$0")")" ) "$SCRIPT_DIR/deploy_erc20.js" "$SCRIPT_DIR/deploy_nameservice.js" -"$SCRIPT_DIR/deploy_staking.js" From ff21ad8e75a9f4502195c0fbf3ef4951db90e510 Mon Sep 17 00:00:00 2001 From: willclarktech Date: Tue, 4 Aug 2020 17:28:43 +0200 Subject: [PATCH 4/4] Update CHANGELOG for demo-staking removal --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 728ff249..c7d5a1a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - @cosmjs/cosmwasm: Rename `CosmWasmClient.postTx` method to `.broadcastTx`. - @cosmjs/cosmwasm: Rename `SigningCosmWasmClient.signAndPost` method to `.signAndBroadcast`. +- @cosmjs/demo-staking: Remove package and supporting scripts. - @cosmjs/launchpad: Rename `CosmosClient.postTx` method to `.broadcastTx`. - @cosmjs/launchpad: Rename `SigningCosmosClient.signAndPost` method to `.signAndBroadcast`.