-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaced BigNumber with BigInt #384
Conversation
@@ -59,13 +59,13 @@ export type ITokenPayment = ITokenTransfer; | |||
export interface ITransactionNext { | |||
sender: string; | |||
receiver: string; | |||
gasLimit: BigNumber.Value; | |||
gasLimit: bigint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -130,7 +130,7 @@ export class SmartContract implements ISmartContract { | |||
const nextTx = scNextTransactionFactory.createTransactionForDeploy({ | |||
sender: deployer, | |||
bytecode: bytecode, | |||
gasLimit: gasLimit.valueOf(), | |||
gasLimit: BigInt(gasLimit.valueOf()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upcasting, because before we had gasLimit
as number. This is fine (it's the only good option) 👍
@@ -32,8 +32,8 @@ describe("test transaction construction", async () => { | |||
const transaction = Transaction.fromTransactionNext(nextTransaction); | |||
assert.deepEqual(transaction.getSender(), Address.fromBech32(plainTransactionNextObject.sender)); | |||
assert.deepEqual(transaction.getReceiver(), Address.fromBech32(plainTransactionNextObject.receiver)); | |||
assert.equal(transaction.getGasLimit().valueOf(), plainTransactionNextObject.gasLimit); | |||
assert.equal(transaction.getValue().toString(), plainTransactionNextObject.value); | |||
assert.equal(transaction.getGasLimit().valueOf().toFixed(0), plainTransactionNextObject.gasLimit.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why does this work, since transaction.getGasLimit().valueOf()
returns a number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toString()
works fine as well.
src/transaction.ts
Outdated
@@ -428,9 +428,9 @@ export class Transaction { | |||
const tx = new Transaction({ | |||
sender: Address.fromBech32(transaction.sender), | |||
receiver: Address.fromBech32(transaction.receiver), | |||
gasLimit: new BigNumber(transaction.gasLimit).toNumber(), | |||
gasLimit: new BigNumber(transaction.gasLimit.toString()).toNumber(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here we should do as follows:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
chainID: transaction.chainID, | ||
value: new BigNumber(transaction.value).toFixed(0), | ||
value: new BigNumber(transaction.value.toString()).toFixed(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is OK.
bigIntToHex(new BigNumber(options.tokenNonce.toString())), | ||
bigIntToHex(new BigNumber(options.quantityToBurn.toString())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use numberToPaddedHex
(which handles bigint
). If necessary, maybe handle 0 differently in numberToPaddedHex
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with numberToPaddedHex
.
@@ -49,7 +49,7 @@ describe("test token management transactions factory", () => { | |||
assert.deepEqual( | |||
next.data, | |||
Buffer.from( | |||
"issue@4652414e4b@4652414e4b@64@@63616e467265657a65@74727565@63616e57697065@74727565@63616e5061757365@74727565@63616e4368616e67654f776e6572@74727565@63616e55706772616465@66616c7365@63616e4164645370656369616c526f6c6573@66616c7365", | |||
"issue@4652414e4b@4652414e4b@64@00@63616e467265657a65@74727565@63616e57697065@74727565@63616e5061757365@74727565@63616e4368616e67654f776e6572@74727565@63616e55706772616465@66616c7365@63616e4164645370656369616c526f6c6573@66616c7365", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fine 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed on testnet 👍
src/transaction.ts
Outdated
new BigNumber(networkConfig.GasPriceModifier) | ||
); | ||
const processingFee = diff.multipliedBy(modifiedGasPrice); | ||
const diff = transaction.gasLimit- moveBalanceGas; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transaction.gasLimit- moveBalanceGas;
=>
transaction.gasLimit - moveBalanceGas;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -49,7 +49,7 @@ describe("test token management transactions factory", () => { | |||
assert.deepEqual( | |||
next.data, | |||
Buffer.from( | |||
"issue@4652414e4b@4652414e4b@64@@63616e467265657a65@74727565@63616e57697065@74727565@63616e5061757365@74727565@63616e4368616e67654f776e6572@74727565@63616e55706772616465@66616c7365@63616e4164645370656369616c526f6c6573@66616c7365", | |||
"issue@4652414e4b@4652414e4b@64@00@63616e467265657a65@74727565@63616e57697065@74727565@63616e5061757365@74727565@63616e4368616e67654f776e6572@74727565@63616e55706772616465@66616c7365@63616e4164645370656369616c526f6c6573@66616c7365", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed on testnet 👍
For the new v13 release, the functionality added will use
bigint
instead ofBigNumber
.