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

Update DAppSigner.ts #170

Merged
merged 8 commits into from
Jul 19, 2024
Merged

Update DAppSigner.ts #170

merged 8 commits into from
Jul 19, 2024

Conversation

teacoat
Copy link
Contributor

@teacoat teacoat commented Jun 10, 2024

When working with HSuite they were encountering issues with signing transactions, this is the change we applied to hashconnect in order to fix the issue. When signing a transaction multiple times (multisig), you want to preserve the node id.

May resolve this: #124

When working with HSuite they were encountering issues with signing transactions, this is the change we applied to hashconnect in order to fix the issue.

Signed-off-by: Tyler Cote <[email protected]>
@teacoat teacoat requested a review from a team as a code owner June 10, 2024 15:40
@teacoat teacoat requested a review from web3-nomad June 10, 2024 15:40
Copy link

github-actions bot commented Jun 10, 2024

Coverage report

St.
Category Percentage Covered / Total
🔴 Statements
45.26% (-0.24% 🔻)
258/570
🔴 Branches
25.14% (-0.59% 🔻)
44/175
🔴 Functions 27.34% 38/139
🔴 Lines
45.4% (-0.26% 🔻)
242/533
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / DAppSigner.ts
47.5% (-1.85% 🔻)
13.64% (-1.36% 🔻)
37.5%
47.37% (-1.95% 🔻)

Test suite run success

25 tests passing in 2 suites.

Report generated by 🧪jest coverage report action from 17cad0d

@teacoat
Copy link
Contributor Author

teacoat commented Jun 10, 2024

It is possible the entire signing function here is wrong, I will do some more testing on this as its quite different to what we are doing in hashconnect

@franfernandez20
Copy link
Contributor

Maybe we can use an approach similar to this function: keep setting the nodes if the transaction does not have any set, and use the node from the transaction if it does.

/**
 * Sets default consensus nodes that a transaction will be submitted to. Node Account ID(s)
 * must be set before a transaction can be frozen. If they have already been set, this
 * function will not modify the transaction.
 * @param transaction - any instance of a class that extends `Transaction`
 *
 * @see {@link https://docs.hedera.com/hedera/networks/testnet/testnet-nodes | Full list of Testnet-nodes}
 * @see {@link https://docs.hedera.com/hedera/networks/mainnet/mainnet-nodes | Full list of Mainnet-nodes}
 */
export function setDefaultNodeAccountIds<T extends Transaction>(transaction: T): void {
  const isNodeAccountIdNotSet =
    !transaction.nodeAccountIds || transaction.nodeAccountIds.length === 0

  if (!transaction.isFrozen() && isNodeAccountIdNotSet)
    transaction.setNodeAccountIds([new AccountId(3), new AccountId(4), new AccountId(5)])
}

@tomachianura
Copy link

thanks guys,trule appreciated!

@tmctl tmctl requested a review from a team as a code owner July 1, 2024 17:12
Copy link
Contributor

@gregscullard gregscullard left a comment

Choose a reason for hiding this comment

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

LGTM

@franfernandez20 franfernandez20 self-requested a review July 8, 2024 15:43
@tmctl
Copy link
Contributor

tmctl commented Jul 15, 2024

@franfernandez20 this changes the original suggested change approved by @gregscullard here: d47e8a7

It might be helpful in the future to do a PR into another branch that has an open PR so that we can better see the diff.

I've added some notes here - https://github.com/hashgraph/hedera-wallet-connect/pull/213/files

Fran's updates effectively check to see if the transaction has nodeAccountIds and then uses the first one, otherwise uses the internal function to get a random node account id. This logic makes sense to me.

@tmctl
Copy link
Contributor

tmctl commented Jul 15, 2024

github action annotations might make it harder to read the diff in this PR, if you press a on the files changed page, it is a quick way to toggle the annotations.

Copy link
Contributor

@hgraphql hgraphql left a comment

Choose a reason for hiding this comment

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

LGTM

@tmctl tmctl requested review from a team as code owners July 19, 2024 00:52
Signed-off-by: Tyler McDonald <[email protected]>
@tmctl tmctl merged commit 96c54a3 into main Jul 19, 2024
10 checks passed
@tmctl tmctl deleted the signing-fix branch July 19, 2024 00:59
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.

6 participants