Skip to content
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

Merged
merged 40 commits into from
Oct 13, 2023
Merged

Conversation

Leechael
Copy link
Contributor

@Leechael Leechael commented Sep 15, 2023

Depends on #1378 & #1385.

  • InkCommand can switch to plain mode, which allows encryption to be turned off for debugging purposes.
  • An error is thrown when a PrpcError is detected.
  • Decode for MessageOutput.
  • Auto-deposit.

Also the improvement suggestion from @kingsleydon : PinkContractSubmittableResult.waitFinalized support optional predicate function.

@Leechael Leechael force-pushed the post-dd-hackathon-improvement branch from 7cc417d to 5f135f4 Compare September 15, 2023 07:48
@Leechael Leechael force-pushed the post-dd-hackathon-improvement branch from 5f135f4 to 2554055 Compare September 15, 2023 08:17
@Leechael Leechael force-pushed the post-dd-hackathon-improvement branch 2 times, most recently from e597148 to be739ba Compare September 16, 2023 00:52
Comment on lines +98 to +100
async waitFinalized(
predicate?: () => Promise<boolean>,
options?: { timeout?: number; blocks?: number }
): Promise<void> {
Copy link
Contributor Author

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[]) {
Copy link
Contributor Author

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()

Copy link
Contributor Author

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()

@Leechael Leechael marked this pull request as ready for review September 17, 2023 19:07
])

const msg = this.abi.findConstructor(constructorOrId).toU8a(args)
const storageDepositRequired = depositPerByte.mul(new BN(msg.length * 2.2))
Copy link
Collaborator

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?

Copy link
Contributor

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?

Copy link
Collaborator

@kvinwang kvinwang Sep 27, 2023

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.

Copy link
Contributor Author

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.

@Leechael Leechael force-pushed the post-dd-hackathon-improvement branch from 8bf1d61 to 83b8aca Compare October 8, 2023 17:26
@Leechael Leechael requested a review from kvinwang October 11, 2023 14:13
@Leechael Leechael force-pushed the post-dd-hackathon-improvement branch from b4962c0 to 4e82f9c Compare October 13, 2023 09:07
@Leechael Leechael merged commit 3f7ace6 into master Oct 13, 2023
9 checks passed
@Leechael Leechael deleted the post-dd-hackathon-improvement branch October 13, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants