From dc0ef7c6f012e3930afed7546fc1498c6fd4ea11 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 4 Aug 2020 14:02:49 +0200 Subject: [PATCH] Remove unnecessary smartQuery helper --- packages/cli/MASK.md | 20 ++++++++++---------- packages/cli/README.md | 8 ++++---- packages/cli/examples/helpers.ts | 5 ----- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/packages/cli/MASK.md b/packages/cli/MASK.md index 68cd6b73..8ab3ffa9 100644 --- a/packages/cli/MASK.md +++ b/packages/cli/MASK.md @@ -85,10 +85,10 @@ const ercs = await client.getContracts(ercId); const foo = ercs.filter((x) => x.label == "FOO").map((x) => x.address)[0]; // send some erc tokens to the mask as before -smartQuery(client, foo, { balance: { address: mask } }); +client.queryContractSmart(foo, { balance: { address: mask } }); const ercMsg = { transfer: { recipient: mask, amount: "800000" } }; client.execute(foo, ercMsg); -smartQuery(client, foo, { balance: { address: mask } }); +client.queryContractSmart(foo, { balance: { address: mask } }); ``` ## Usage @@ -117,8 +117,8 @@ client.getAccount(mask); And call the ERC20 contract from it: ```ts -smartQuery(client, foo, { balance: { address: rand } }); -smartQuery(client, foo, { balance: { address: mask } }); +client.queryContractSmart(foo, { balance: { address: rand } }); +client.queryContractSmart(foo, { balance: { address: mask } }); const callContract: HandleMsg = { reflectmsg: { @@ -128,8 +128,8 @@ const callContract: HandleMsg = { }, }; client.execute(mask, callContract); -smartQuery(client, foo, { balance: { address: rand } }); -smartQuery(client, foo, { balance: { address: mask } }); +client.queryContractSmart(foo, { balance: { address: rand } }); +client.queryContractSmart(foo, { balance: { address: mask } }); ``` ### Staking via OpaqueMsg @@ -241,17 +241,17 @@ aliceClient.getAccount(); // now, transfer ownership of the mask const query: QueryMsg = { owner: {} }; -smartQuery(client, mask, query); +client.queryContractSmart(mask, query); const transferMsg: HandleMsg = { changeowner: { owner: alice } }; client.execute(mask, transferMsg); -smartQuery(client, mask, query); +client.queryContractSmart(mask, query); ``` From now own, alice can control the mask, not me.... And she can extract the erc20 tokens or anything else the mask controls ```ts -smartQuery(client, foo, { balance: { address: alice } }); +client.queryContractSmart(foo, { balance: { address: alice } }); const withdraw: HandleMsg = { reflectmsg: { @@ -264,7 +264,7 @@ const withdraw: HandleMsg = { client.execute(mask, withdraw); // this will succeed (alice) aliceClient.execute(mask, withdraw); -smartQuery(client, foo, { balance: { address: alice } }); +client.queryContractSmart(foo, { balance: { address: alice } }); ``` Please explore the use-cases of the Mask. More than a production-ready contract diff --git a/packages/cli/README.md b/packages/cli/README.md index e406fd12..67fdef44 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -125,7 +125,7 @@ info; info.initMsg; // see your balance here -smartQuery(client, addr, { balance: { address } }); +client.queryContractSmart(addr, { balance: { address } }); ``` Instantiate and use ERC20 contract: @@ -153,17 +153,17 @@ const fooAddr2 = await client )[(fooAddr, fooAddr2)]; // now we have some cash -smartQuery(client, fooAddr, { balance: { address } }); +client.queryContractSmart(fooAddr, { balance: { address } }); const rcpt = await randomAddress("cosmos"); rcpt; -smartQuery(client, fooAddr, { balance: { address: rcpt } }); +client.queryContractSmart(fooAddr, { balance: { address: rcpt } }); const execMsg = { transfer: { recipient: rcpt, amount: "808" } }; const exec = await client.execute(fooAddr, execMsg); exec; exec.logs[0].events[0]; -smartQuery(client, fooAddr, { balance: { address: rcpt } }); +client.queryContractSmart(fooAddr, { balance: { address: rcpt } }); ``` Or just send tokens: diff --git a/packages/cli/examples/helpers.ts b/packages/cli/examples/helpers.ts index c249cf9f..7001abb3 100644 --- a/packages/cli/examples/helpers.ts +++ b/packages/cli/examples/helpers.ts @@ -59,11 +59,6 @@ const connect = async ( return { client, address }; }; -// smartQuery assumes the content is proper JSON data and parses before returning it -async function smartQuery(client: CosmWasmClient, addr: string, query: object): Promise { - return client.queryContractSmart(addr, query); -} - // loadOrCreateMnemonic will try to load a mnemonic from the file. // If missing, it will generate a random one and save to the file. //