Skip to content
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

Merged
merged 9 commits into from
Dec 12, 2024

Conversation

danielailie
Copy link
Contributor

No description provided.

@danielailie danielailie self-assigned this Dec 10, 2024
const plainObject = {
nonce: Number(transaction.nonce),
value: transaction.value.toString(),
receiver: transaction.receiver,
sender: transaction.sender,
receiver: transaction.receiver.bech32(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new method, toBech32()?

Copy link
Contributor

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;
Copy link
Contributor

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).

return {
nonce: Number(transaction.nonce),
value: transaction.value.toString(),
receiver: transaction.receiver,
sender: transaction.sender,
receiver: transaction.receiver.bech32(),
Copy link
Contributor

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).

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,
Copy link
Contributor

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"?

const hasGuardianSignature = this.guardianSignature.length > 0;
return this.getOptions().isWithGuardian() && hasGuardian && hasGuardianSignature;
const isGuardedSet = (this.options & TRANSACTION_OPTIONS_TX_GUARDED) == TRANSACTION_OPTIONS_TX_GUARDED;
Copy link
Contributor

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...?

Comment on lines 108 to 109
receiver: transaction.receiver.bech32(),
sender: transaction.sender.bech32(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use toBech32() instead.

Comment on lines 11 to 12
receiver: transaction.receiver.bech32(),
sender: transaction.sender.bech32(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use toBech32() instead.

Comment on lines 10 to 11
receiver: transaction.receiver.bech32(),
sender: transaction.sender.bech32(),
Copy link
Contributor

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(
Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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());
Copy link
Contributor

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.

@danielailie danielailie merged commit 372cd24 into feat/next Dec 12, 2024
4 checks passed
@danielailie danielailie deleted the TOOL-390-update-transaction-to-follow-specs branch December 12, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants