-
Notifications
You must be signed in to change notification settings - Fork 317
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
Add simulation support #931
Conversation
4ded93f
to
4d61793
Compare
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.
Very useful helper.
I like to not auto-set gas inside the signer, but let a caller easily get simulation estimates and set gas in the app
}), | ||
}; | ||
const memo = "Go go go"; | ||
const gasUsed = await client.simulate(alice.address0, [executeContractMsg], memo); |
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.
very cool!
Yeah, this is the next question. I think the flow is very inconvenient. I'm thinking about an "auto" option that does the simulation internally and use a constant multiplier but still allow a custom gas limit. I'll write an example that shows how the current diff can be used. |
10f45c9
to
27a4f1b
Compare
@ethanfrey could you have a look at |
27a4f1b
to
49278d1
Compare
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.
nice stuff
const memo = "With simulate"; | ||
const gasEstimation = await client.simulate(account.address, [sendMsg], memo); | ||
const fee = calculateFee(Math.round(gasEstimation * 1.3), gasPrice); | ||
const result = await client.sendTokens(account.address, recipient, amount, fee, memo); |
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.
Wow, this next to last argument can be:
- "auto"
- number -> multiplier after simulation
StdFee
-> caller fixed gas/fee
The top two using a gas price set in the constructor.
Is that correct?
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.
Exactly
@@ -367,7 +391,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { | |||
senderAddress: string, | |||
recipientAddress: string, | |||
amount: readonly Coin[], | |||
fee: StdFee, | |||
fee: StdFee | "auto" | number, |
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.
Okay, nice arg here... very flexible and I hope the caller uses TS
49278d1
to
b4aa877
Compare
Closes #828