Got guide working

This commit is contained in:
Ethan Frey 2020-02-10 15:58:30 +01:00
parent 0544836a60
commit b047658af3
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/camelcase */
import {
logs,
logs
} from "@cosmwasm/sdk";
const defaultHttpUrl = "http://localhost:1317";
@ -26,9 +26,9 @@ const networkId = "testing";
// helper functions
async function instantiateContract(initClient: RestClient, initPen: Secp256k1Pen, codeId: number, msg: object, transferAmount?: types.Coin[]): Promise<string> {
const instantiateContract = async (initClient: RestClient, initPen: Secp256k1Pen, codeId: number, msg: object, transferAmount?: types.Coin[]): Promise<string> => {
const memo = "Create an ERC20 instance";
const sender = encodeAddress({ "type": "tendermint/Secp256k1PubKey", "value": toBase64(initPen.pubkey)}, "cosmos");
const sender = encodeAddress({ "type": types.pubkeyType.secp256k1, "value": toBase64(initPen.pubkey)}, "cosmos");
const instantiateContractMsg = {
type: "wasm/instantiate",
value: {
@ -57,7 +57,7 @@ async function instantiateContract(initClient: RestClient, initPen: Secp256k1Pen
}
// helper functions
async function executeContract(execClient: RestClient, execPen: Secp256k1Pen, contractAddr: string, msg: object, transferAmount?: types.Coin[]): Promise<readonly logs.Log[]> {
const executeContract = async (execClient: RestClient, execPen: Secp256k1Pen, contractAddr: string, msg: object, transferAmount?: types.Coin[]): Promise<readonly logs.Log[]> => {
const memo = "Create an ERC20 instance";
const sender = encodeAddress({ "type": "tendermint/Secp256k1PubKey", "value": toBase64(execPen.pubkey)}, "cosmos");
const instantiateContractMsg = {

View File

@ -29,4 +29,11 @@ info.init_msg
client.queryContractSmart(addr, { balance: { address: faucetAddress } })
// make a new contract
const initMsg = { name: "Foo Coin", symbol: "FOO", decimals: 2, initial_balances: [{address: faucetAddress, amount: "123456789"}]}
const foo = await instantiateContract(client, pen, 1, initMsg);
client.queryContractSmart(foo, { balance: { address: faucetAddress } })
// TODO: unused account
// TODO: execute and send tokens
```