Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

add options field to tx #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion package-lock.json

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

12 changes: 9 additions & 3 deletions src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Transaction {
gasLimit = '',
data = '',
chainID='',
version = 0
version = 0,
options = 0
}) {
Transaction.validateAddresses([from, to]);
this.nonce = nonce;
Expand All @@ -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 = '';
Expand Down Expand Up @@ -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);
Expand All @@ -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,
}
}
Expand Down
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down