-
Notifications
You must be signed in to change notification settings - Fork 151
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
Post DeveloperDAO Hackathon Improvements #1386
Conversation
7cc417d
to
5f135f4
Compare
5f135f4
to
2554055
Compare
e597148
to
be739ba
Compare
async waitFinalized( | ||
predicate?: () => Promise<boolean>, | ||
options?: { timeout?: number; blocks?: number } | ||
): Promise<void> { |
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 update is base on the feedback from @kingsleydon . Now we can send contract transaction and wait for it finalize like this:
const { output: counts } = await contractPromise.query.totalBadge<u8>(cert.address, { cert })
const tx = await signAndSend(contractPromise.tx.newBadge(txOptions, 'New badge 01'), pair)
await tx.waitFinalized(async () => {
return contractPromise.query.totalBadge<u8>(cert, address, { cert }) > counts
})
const seed = hexToU8a(hexAddPrefix(randomHex(32))) | ||
const pair = sr25519KeypairFromSeed(seed) | ||
const [sk, pk] = [pair.slice(0, 64), pair.slice(64)] | ||
public async send(messageOrId: string, options: PinkContractSendOptions, ...args: unknown[]) { |
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.
The #inkCommand
function is synchronous, so we cannot include the autoDeposit
function inside it because the estimating process is asynchronous. We added a new function call send
here, it include the autoDepost
:
const result = await contract.send('newBadge', { pair, autoDeposit: true }, name)
await result.waitFinalized()
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.
Updated:
const result = await contract.send.newBadge({ pair }, name)
// Or
const result = await contract.send.newBadge({ address, signer }, name)
// wait block finalize
await result.waitFinalized()
]) | ||
|
||
const msg = this.abi.findConstructor(constructorOrId).toU8a(args) | ||
const storageDepositRequired = depositPerByte.mul(new BN(msg.length * 2.2)) |
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.
But the storage deposit is not related to the size of args?
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.
What's the proper way to estimate the storage deposit for contract upload and instantiate?
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.
What's the proper way to estimate the storage deposit for contract upload and instantiate?
They are two steps, so it should be estimated_deposit_for_code_storage + estimated_deposit_for_instantiation
where:
estimated_deposit_for_code_storage = code_size * 2.2 * price;
estimated_deposit_for_instantiation = storage_deposit_limit if charges or 0. where storage_deposit_limit is estimated using the rpc.
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.
But the storage deposit is not related to the size of args?
For example, when instantiating ActionOffchainRollup with JS code, it incurs a high storage deposit fee and requires consideration of the size of args.
… plain type CommandPayload
…ze of PinkContractSubmittableResult
… for auto-deposit
8bf1d61
to
83b8aca
Compare
…aitFinalized so we can false faster with the concrete error
…rx, throws error if so
b4962c0
to
4e82f9c
Compare
Depends on #1378 & #1385.
Also the improvement suggestion from @kingsleydon :
PinkContractSubmittableResult.waitFinalized
support optional predicate function.