diff --git a/CHANGELOG.md b/CHANGELOG.md index 2176d7ee..40a4fcad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ## Unreleased - TBD +## [9.2.2] + - [Wallet Provider: add "options" on tx sign return value](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/157) + ## [9.2.1] - [Fix / simplify some imports](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/148) - [Handle strings in binary codec](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/153) diff --git a/package-lock.json b/package-lock.json index 39753261..af7bfb4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@elrondnetwork/erdjs", - "version": "9.2.1", + "version": "9.2.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 993093c1..ee0663a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@elrondnetwork/erdjs", - "version": "9.2.1", + "version": "9.2.2", "description": "Smart Contracts interaction framework", "main": "out/index.js", "types": "out/index.d.js", diff --git a/src/dapp/walletProvider.ts b/src/dapp/walletProvider.ts index 4eda306e..eeba1b39 100644 --- a/src/dapp/walletProvider.ts +++ b/src/dapp/walletProvider.ts @@ -10,12 +10,12 @@ import { } from "./constants"; import { Transaction } from "../transaction"; import { SignableMessage } from "../signableMessage"; -import {ErrInvalidTxSignReturnValue, ErrNotImplemented} from "../errors"; -import {Signature} from "../signature"; +import { ErrInvalidTxSignReturnValue, ErrNotImplemented } from "../errors"; +import { Signature } from "../signature"; import { Nonce } from "../nonce"; import { Balance } from "../balance"; import { Address } from "../address"; -import { ChainID, GasLimit, GasPrice, TransactionVersion } from "../networkParams"; +import { ChainID, GasLimit, GasPrice, TransactionOptions, TransactionVersion } from "../networkParams"; import { TransactionPayload } from "../transactionPayload"; interface TransactionMessage { @@ -25,6 +25,7 @@ interface TransactionMessage { gasLimit?: number; data?: string; nonce?: number; + options?: number; } export class WalletProvider implements IDappProvider { @@ -81,7 +82,7 @@ export class WalletProvider implements IDappProvider { resolve(true); }, 10); }); - + return window.location.href; } @@ -187,6 +188,7 @@ export class WalletProvider implements IDappProvider { } static getTxSignReturnValue(urlParams: any): Transaction[] { + // "options" property is optional (it isn't always received from the Web Wallet) const expectedProps = ["nonce", "value", "receiver", "sender", "gasPrice", "gasLimit", "data", "chainID", "version", "signature"]; @@ -214,7 +216,10 @@ export class WalletProvider implements IDappProvider { data: new TransactionPayload(urlParams["data"][i]), chainID: new ChainID(urlParams["chainID"][i]), version: new TransactionVersion(parseInt(urlParams["version"][i])), - + // Handle the optional "options" property. + ...(urlParams["options"] && urlParams["options"][i] ? { + options: new TransactionOptions(parseInt(urlParams["options"][i])) + } : {}) }); tx.applySignature(new Signature(urlParams["signature"][i]), Address.fromString(urlParams["sender"][i])); transactions.push(tx);