From ff46dee84750f6a59166d52bbd768b6a9cc3de64 Mon Sep 17 00:00:00 2001 From: bragaz Date: Wed, 11 Nov 2020 11:49:01 +0100 Subject: [PATCH] fixed helper functions --- helpers.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/helpers.ts b/helpers.ts index 6d70050..03b29bd 100644 --- a/helpers.ts +++ b/helpers.ts @@ -188,7 +188,7 @@ interface BonsaiContract { use: (contractAddress: string) => BonsaiInstance } -const bonsaiCW = (client: SigningCosmWasmClient) : BonsaiContract => { +const bonsaiCW = (client: SigningCosmWasmClient, metaSource: string, builderSource: string, contractSource: string) : BonsaiContract => { const use = (contractAddress: string): BonsaiInstance => { const getBonsais = async (): Promise => { return await client.queryContractSmart(contractAddress, {get_bonsais: {}}); @@ -243,13 +243,12 @@ const bonsaiCW = (client: SigningCosmWasmClient) : BonsaiContract => { return r.data } - const upload = async (metaSource: string, builderSource: string, contractSource: string): Promise => { + const upload = async (): Promise => { const meta = { source: metaSource, builder: builderSource }; - const sourceUrl = contractSource; - const wasm = await downloadWasm(sourceUrl); + const wasm = await downloadWasm(contractSource); const result = await client.upload(wasm, meta); return result.codeId; } @@ -266,8 +265,10 @@ const bonsaiCW = (client: SigningCosmWasmClient) : BonsaiContract => { // Example: // const client = await useOptions(coralnetOptions).setup("12345678"); // const { address } = await client.getAccount() -// const factory = bonsaiCW(client) -// +// const metaSourcePath = "https://github.com/bragaz/wasm-test-contract/tree/v0.1.2" +// const optimizerPath = "cosmwasm/rust-optimizer:0.10.4" +// const sourceUrl = "https://github.com/bragaz/wasm-test-contract/releases/download/v0.1.2/my_first_contract.wasm" +// const factory = bonsaiCW(client, metaSourcePath, optimizerPath, sourceUrl) // const codeId = await factory.upload(); // const contract = await factory.instantiate(codeId, {number: 5, price: {denom: "ushell", amount: "1"}}, "Bonsai") // contract.contractAddress -> 'coral1267wq2zk22kt5juypdczw3k4wxhc4z47mug9fd'