From 18169bfdddd78e3e1706c170c424970be28ba198 Mon Sep 17 00:00:00 2001 From: bogdan-rosianu Date: Thu, 18 Feb 2021 16:44:17 +0200 Subject: [PATCH] add options field to tx --- package-lock.json | 2 +- src/transaction.js | 12 +++++++++--- test.js | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 61e012d..3c8f56c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@elrondnetwork/elrond-core-js", - "version": "1.28.0", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/transaction.js b/src/transaction.js index 8a7d44a..b0eb3a4 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -15,7 +15,8 @@ class Transaction { gasLimit = '', data = '', chainID='', - version = 0 + version = 0, + options = 0 }) { Transaction.validateAddresses([from, to]); this.nonce = nonce; @@ -28,7 +29,8 @@ class Transaction { this.gasLimit = gasLimit; this.data = data; this.chainID = chainID; - this.version = version + this.version = version; + this.options = options; // Set an empty signature for start this.signature = ''; @@ -66,7 +68,10 @@ class Transaction { mainTx.chainID = this.chainID; } if ( this.version ) { - mainTx.version = this.version + mainTx.version = this.version; + } + if ( this.options ) { + mainTx.options = this.options; } let mainTxJSON = JSON.stringify(mainTx); @@ -86,6 +91,7 @@ class Transaction { data: Buffer.from(this.data).toString('base64'), chainID: this.chainID, version: this.version, + options: this.options, signature: this.signature, } } diff --git a/test.js b/test.js index 7e0b9c6..72ee52b 100644 --- a/test.js +++ b/test.js @@ -48,6 +48,7 @@ const myNewTx2 = new transaction({ data: "!!!!!", chainID: "test chainID", version: 999, + options: 1, }); const txBeforeSigning2 = myNewTx2.prepareForSigning(); console.log('tx before signing: \n', txBeforeSigning2.toString());