Skip to content

Commit

Permalink
Update DAppSigner.ts (#170)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Cote <tyler8cote@gmail.com>
Signed-off-by: Fran Fernandez <fran@kabila.app>
Signed-off-by: Tyler McDonald <tyler@hgraph.io>
Co-authored-by: Tyler McDonald <tyler@hgraph.io>
Co-authored-by: Tyler <tyler+hgraphql@hgraph.io>
Co-authored-by: Fran Fernández <franfernandez20@gmail.com>
  • Loading branch information
4 people authored Jul 19, 2024
1 parent a3f86bf commit 96c54a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/hedera-wallet-connect",
"version": "1.3.0",
"version": "1.3.1",
"description": "A library to facilitate integrating Hedera with WalletConnect",
"repository": {
"type": "git",
Expand Down
14 changes: 13 additions & 1 deletion src/lib/dapp/DAppSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,22 @@ export class DAppSigner implements Signer {
.setTransactionId(TransactionId.generate(this.getAccountId()))
}

/**
* Prepares a transaction object for signing using a single node account id.
* If the transaction object does not already have a node account id,
* generate a random node account id using the Hedera SDK client
*
* @param transaction - Any instance of a class that extends `Transaction`
* @returns transaction - `Transaction` object with signature
*/
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
let nodeAccountId: AccountId
if (!transaction.nodeAccountIds || transaction.nodeAccountIds.length === 0)
nodeAccountId = this._getRandomNodes(1)[0]
else nodeAccountId = transaction.nodeAccountIds[0]
const transactionBody: proto.TransactionBody = transactionToTransactionBody(
transaction,
this._getRandomNodes(1)[0],
nodeAccountId,
)
const transactionBodyBase64 = transactionBodyToBase64String(transactionBody)

Expand Down

0 comments on commit 96c54a3

Please sign in to comment.