Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [7.0.1]
- [Bugfix for Safari - removed negative lookbehind regex #67](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/67)
- [Bugfix on WalletConnect signTransactions single Tx case #69](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/69)

## [7.0.0]
- [Contract wrapper](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/9)
Expand Down
22 changes: 17 additions & 5 deletions src/dapp/walletConnectProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,30 @@ export class WalletConnectProvider implements IDappProvider {

const address = await this.getAddress();
const params = transactions.map((transaction) => this.prepareWalletConnectMessage(transaction, address));
const signatures = await this.walletConnector.sendCustomRequest({
const signatures: { signature: string }[] | { signature: string } = await this.walletConnector.sendCustomRequest({
method: "erd_batch_sign",
params
});
if (!signatures || (transactions.length !== signatures.length)) {
if (!signatures) {
Logger.error("signTransactions: Wallet Connect could not sign the transactions");
throw new Error("Wallet Connect could not sign the transactions");
}
transactions.map((transaction, key: number) =>
transaction.applySignature(new Signature(signatures[key].signature), new Address(address))
);

if (Array.isArray(signatures)) {
if (transactions.length !== signatures.length) {
Logger.error("signTransactions: Wallet Connect could not sign the transactions. Invalid signatures.");
throw new Error("Wallet Connect could not sign the transactions. Invalid signatures.");
}

transactions.map((transaction, key: number) =>
transaction.applySignature(new Signature(signatures[key].signature), new Address(address))
);

return transactions;
}

transactions[0].applySignature(new Signature(signatures.signature), new Address(address));

return transactions;
}

Expand Down