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

FCL Feature: Calculate the transaction hash #840

Merged
merged 6 commits into from
Oct 13, 2021
Merged

Conversation

avcdsld
Copy link
Contributor

@avcdsld avcdsld commented Oct 8, 2021

Closes:

Description

(Partial copy from FLIP Fest issue 24)

Right now, there's no way to get the transaction hash before it's sent to the blockchain. Pre-calculating the transaction hash will allow for error recovery if there are any network connection issues during the submission of the transaction.

Features

  • Middleware that is executed before a transaction is sent, and can be passed an asynchronous function that receives the voucher.
  • Function to calculate txId from voucher
  • Sample code and explanation in readme

Other

  • This is features addition to @onflow/sdk. After the @onflow/sdk version is upgraded, the following changes to fcl will make it available to fcl. This is a very trivial change.

    packages/fcl/src/fcl.js

    export {voucherToTxId} from "@onflow/sdk"
    export {preSendCheck} from "@onflow/sdk"
    

@gregsantos
Copy link
Contributor

Thanks for your contribution @avcdsld! This is looking quite solid overall. 👏
We will have a chance to run, test, and review soon and should have any feedback to you early next week.

@@ -54,3 +55,8 @@ export const createSignableVoucher = ix => {
envelopeSigs: buildOutsideSigners(),
}
}

export const voucherToTxId = voucher => {
// ref. https://github.com/onflow/flow-go-sdk/blob/d794a2/transaction.go#L119
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Removed👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @avcdsld We're just aligning internally about any last requests before merge but consider this milestone submission approved!

@gregsantos gregsantos merged commit 387527c into onflow:master Oct 13, 2021
@orodio
Copy link
Contributor

orodio commented Oct 13, 2021

Thanks so much for this @avcdsld and continuing to be an amazing member of the Flow community.

@JeffreyDoyle
Copy link
Member

Thank you @avcdsld ! This is an excellent addition to FCL 😄

@gregsantos
Copy link
Contributor

Merged into master @avcdsld 🚀 Thank you for your contribution and support!

@chasefleming
Copy link
Member

Thanks @avcdsld ! Great contribution.

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.

5 participants