-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cw20-base: upgrade helper.ts to cosmjs 0.25 #248
Conversation
contracts/cw20-base/helpers.ts
Outdated
const keyfile = filename || options.defaultKeyFile; | ||
const wallet = await loadOrCreateWallet(hackatomOptions, keyfile, password); | ||
const client = await connect(wallet, hackatomOptions); | ||
const account = (await wallet.getAccounts())[0].address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better call this address
contracts/cw20-base/helpers.ts
Outdated
|
||
// ensure we have some tokens | ||
if (options.faucetUrl) { | ||
const account = await client.getAccount(); | ||
if (!account) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is always false now, because account
is always a non-empty address. I.e. you never get tokens
|
||
// ensure we have some tokens | ||
if (options.faucetUrl) { | ||
const account = await client.getAccount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tells you whether or not the account exists on chain. You probably want to keep it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking if the account is empty (if they had tokens earlier but spent them all) is a fair enough check.
It's on the client side, so being stricter doesn't add security
contracts/cw20-base/helpers.ts
Outdated
const use = (contractAddress: string): CW20Instance => { | ||
const balance = async (account?: string): Promise<string> => { | ||
const address = account || client.senderAddress; | ||
const result = await client.queryContractSmart(contractAddress, {balance: { address }}); | ||
const address = account || (await cw20Client.wallet.getAccounts())[0].address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You stored it here:
const address = account || (await cw20Client.wallet.getAccounts())[0].address; | |
const address = account || cw20Client.sender; |
a06539f
to
8ab10fc
Compare
An external contributor fixed helper.ts and sent to me. This version works now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks
* Usage: npx @cosmjs/cli@^0.23 --init https://raw.githubusercontent.com/CosmWasm/cosmwasm-plus/master/contracts/cw20-base/helpers.ts | ||
* | ||
* | ||
* Usage: npx @cosmjs/cli@^0.25 --init https://raw.githubusercontent.com/CosmWasm/cosmwasm-plus/master/contracts/cw20-base/helpers.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
// ensure we have some tokens | ||
if (options.faucetUrl) { | ||
const account = await client.getAccount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking if the account is empty (if they had tokens earlier but spent them all) is a fair enough check.
It's on the client side, so being stricter doesn't add security
WIP