Remove unnecessary smartQuery helper

This commit is contained in:
Simon Warta 2020-08-04 14:02:49 +02:00
parent 3b5896d151
commit dc0ef7c6f0
3 changed files with 14 additions and 19 deletions

View File

@ -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

View File

@ -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:

View File

@ -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<any> {
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.
//