-
Notifications
You must be signed in to change notification settings - Fork 40
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
Remove ITransaction interface and update Transaction to follow specs #542
Remove ITransaction interface and update Transaction to follow specs #542
Conversation
const plainObject = { | ||
nonce: Number(transaction.nonce), | ||
value: transaction.value.toString(), | ||
receiver: transaction.receiver, | ||
sender: transaction.sender, | ||
receiver: transaction.receiver.bech32(), |
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.
The new method, toBech32()
?
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.
Also below / in other places.
gasPrice?: IGasPrice; | ||
gasLimit?: IGasLimit; | ||
chainID: IChainID; | ||
nonce?: 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.
Legacy functions from transferTransactionsFactory
(that use the now-removed gasEstimator
) should be dropped (in a next PR).
src/transactionOnNetwork.ts
Outdated
return { | ||
nonce: Number(transaction.nonce), | ||
value: transaction.value.toString(), | ||
receiver: transaction.receiver, | ||
sender: transaction.sender, | ||
receiver: transaction.receiver.bech32(), |
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.
Can use the "new" function (toBech32).
src/transactionComputer.ts
Outdated
senderUsername: this.toBase64OrUndefined(transaction.senderUsername), | ||
receiverUsername: this.toBase64OrUndefined(transaction.receiverUsername), | ||
gasPrice: Number(transaction.gasPrice), | ||
gasLimit: Number(transaction.gasLimit), | ||
data: this.toBase64OrUndefined(transaction.data), | ||
data: transaction.data.length > 0 ? Buffer.from(transaction.data).toString("base64") : undefined, |
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.
Can be changed back to use "toBase64OrUndefined"?
src/transaction.ts
Outdated
const hasGuardianSignature = this.guardianSignature.length > 0; | ||
return this.getOptions().isWithGuardian() && hasGuardian && hasGuardianSignature; | ||
const isGuardedSet = (this.options & TRANSACTION_OPTIONS_TX_GUARDED) == TRANSACTION_OPTIONS_TX_GUARDED; |
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.
Can we somehow use the transaction computer's hasOptionsSetFor...
?
src/transactionComputer.ts
Outdated
receiver: transaction.receiver.bech32(), | ||
sender: transaction.sender.bech32(), |
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.
use toBech32()
instead.
src/transactionOnNetwork.ts
Outdated
receiver: transaction.receiver.bech32(), | ||
sender: transaction.sender.bech32(), |
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.
use toBech32()
instead.
receiver: transaction.receiver.bech32(), | ||
sender: transaction.sender.bech32(), |
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.
could've used toBech32()
, but it's fine since this will be deleted.
const sender = Address.fromBech32("erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2"); | ||
const delegationContract = Address.fromBech32("erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqtllllls002zgc"); | ||
const sender = Address.newFromBech32("erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2"); | ||
const delegationContract = Address.newFromBech32( |
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 we should use the hex representation of built-in smart contract addresses.
@@ -334,29 +333,29 @@ export class DelegationTransactionsFactory { | |||
}).build(); | |||
} | |||
|
|||
createTransactionForWithdrawing(_sender: IAddress, _options: resources.ManageDelegationContractInput): Transaction { | |||
createTransactionForWithdrawing(_sender: Address, _options: resources.ManageDelegationContractInput): Transaction { |
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 don't remember why this method and the ones bellow are not implemented.
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.
they were not added when added the entrypoint and said will do a different pr for them
nonce: 91, | ||
value: TokenTransfer.egldFromAmount(10), | ||
nonce: 91n, | ||
value: TokenTransfer.egldFromAmount(10).amount, |
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.
we shoudn't use this method
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'll update in a different pr if that's ok
@@ -40,16 +39,16 @@ describe("test transaction", function () { | |||
let transactionOne = new Transaction({ | |||
sender: alice.address, | |||
receiver: bob.address, | |||
value: TokenTransfer.egldFromAmount(42), | |||
gasLimit: network.MinGasLimit, | |||
value: TokenTransfer.egldFromAmount(42).amount, |
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.
let's not use this method
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'll update in a different pr if that's ok
@@ -289,7 +289,7 @@ export class SmartContract implements ISmartContract { | |||
* @param nonce The owner nonce used for the deployment transaction | |||
*/ | |||
static computeAddress(owner: Address, nonce: INonce): Address { | |||
const deployer = Address.fromBech32(owner.bech32()); | |||
const deployer = Address.fromBech32(owner.toBech32()); |
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.
here it seems that we create an Address from an Address.
No description provided.