Skip to content

Commit

Permalink
Merge pull request #537 from multiversx/TOOL-365-add-transfers-contro…
Browse files Browse the repository at this point in the history
…ller

Add transfers controller
  • Loading branch information
danielailie authored Nov 18, 2024
2 parents 49d3204 + a344eae commit 0bdc506
Show file tree
Hide file tree
Showing 31 changed files with 154 additions and 235 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ name: Build and Test

on:
pull_request:
branches: [ main, development, feat/*, release/* ]
workflow_dispatch:

jobs:
Expand Down
2 changes: 1 addition & 1 deletion src/abi/interaction.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ContractController } from "../testutils/contractController";
import { createLocalnetProvider } from "../testutils/networkProviders";
import { Transaction } from "../transaction";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { TransactionWatcher } from "../transactionWatcher";
import { Interaction } from "./interaction";
import { ResultsParser } from "./resultsParser";
Expand Down
2 changes: 1 addition & 1 deletion src/abi/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IAddress, IChainID, IGasLimit, IGasPrice, INonce, ITokenTransfer, ITran
import { SmartContractTransactionsFactory } from "../smartContracts";
import { TokenTransfer } from "../tokens";
import { Transaction } from "../transaction";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { ContractFunction } from "./function";
import { InteractionChecker } from "./interactionChecker";
import { CallArguments } from "./interface";
Expand Down
2 changes: 1 addition & 1 deletion src/abi/smartContract.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { prepareDeployment } from "../testutils";
import { createLocalnetProvider } from "../testutils/networkProviders";
import { loadTestWallets, TestWallet } from "../testutils/wallets";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { TransactionWatcher } from "../transactionWatcher";
import { decodeUnsignedNumber } from "./codec";
import { ContractFunction } from "./function";
Expand Down
2 changes: 1 addition & 1 deletion src/abi/smartContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TRANSACTION_MIN_GAS_PRICE } from "../constants";
import { ErrContractHasNoAddress } from "../errors";
import { INonce } from "../interface";
import { Transaction } from "../transaction";
import { TransactionsFactoryConfig } from "../transactionsFactories/transactionsFactoryConfig";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { guardValueIsSet } from "../utils";
import { SmartContractTransactionsFactory } from "./../smartContracts/smartContractTransactionsFactory";
import { CodeMetadata } from "./codeMetadata";
Expand Down
2 changes: 1 addition & 1 deletion src/abi/smartContractResults.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SmartContractTransactionsFactory } from "../smartContracts";
import { loadTestWallets, prepareDeployment, TestWallet } from "../testutils";
import { createLocalnetProvider } from "../testutils/networkProviders";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories/transactionsFactoryConfig";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { TransactionWatcher } from "../transactionWatcher";
import { ContractFunction } from "./function";
import { ResultsParser } from "./resultsParser";
Expand Down
2 changes: 1 addition & 1 deletion src/accountManagement/accountController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IAccount } from "../accounts/interfaces";
import { Transaction } from "../transaction";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { AccountTransactionsFactory } from "./accountTransactionsFactory";
import { SaveKeyValueInput, SetGuardianInput } from "./resources";

Expand Down
2 changes: 1 addition & 1 deletion src/accountManagement/accountTransactionsFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from "chai";
import { Address } from "../address";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { AccountTransactionsFactory } from "./accountTransactionsFactory";

describe("test account transactions factory", function () {
Expand Down
2 changes: 1 addition & 1 deletion src/accountManagement/accountTransactionsFactory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address } from "../address";
import { IAddress } from "../interface";
import { Transaction } from "../transaction";
import { TransactionBuilder } from "../transactionsFactories/transactionBuilder";
import { TransactionBuilder } from "../transactionBuilder";
import { SaveKeyValueInput, SetGuardianInput } from "./resources";

interface IConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/delegation/delegationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ITransactionOnNetwork } from "../interfaceOfNetwork";
import { INetworkProvider } from "../networkProviders/interface";
import { Transaction } from "../transaction";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { TransactionWatcher } from "../transactionWatcher";
import { DelegationTransactionsFactory } from "./delegationTransactionsFactory";
import { DelegationTransactionsOutcomeParser } from "./delegationTransactionsOutcomeParser";
Expand Down
2 changes: 1 addition & 1 deletion src/delegation/delegationTransactionsFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from "chai";
import { Address } from "../address";
import { DELEGATION_MANAGER_SC_ADDRESS_HEX } from "../constants";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { ValidatorPublicKey } from "../wallet";
import { DelegationTransactionsFactory } from "./delegationTransactionsFactory";

Expand Down
2 changes: 1 addition & 1 deletion src/delegation/delegationTransactionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DELEGATION_MANAGER_SC_ADDRESS_HEX } from "../constants";
import { Err } from "../errors";
import { IAddress } from "../interface";
import { Transaction } from "../transaction";
import { TransactionBuilder } from "../transactionsFactories/transactionBuilder";
import { TransactionBuilder } from "../transactionBuilder";
import * as resources from "./resources";

interface IConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export * from "./tokens";
export * from "./transaction";
export * from "./transactionComputer";
export * from "./transactionPayload";
export * from "./transactionsFactories";
export * from "./transactionsOutcomeParsers";
export * from "./transactionWatcher";
export * from "./transfers";
export * from "./utils";
export * from "./wallet";
2 changes: 1 addition & 1 deletion src/relayed/relayedController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IAccount } from "../accounts/interfaces";
import { Transaction } from "../transaction";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { RelayedTransactionsFactory } from "./relayedTransactionsFactory";
import { RelayedV1TransactionInput, RelayedV2TransactionInput } from "./resources";

Expand Down
2 changes: 1 addition & 1 deletion src/relayed/relayedTransactionsFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assert } from "chai";
import { TestWallet, loadTestWallets } from "../testutils";
import { Transaction } from "../transaction";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories/transactionsFactoryConfig";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { RelayedTransactionsFactory } from "./relayedTransactionsFactory";

describe("test relayed transactions factory", function () {
Expand Down
2 changes: 1 addition & 1 deletion src/smartContracts/smartContractController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { INetworkProvider } from "../networkProviders/interface";
import { SmartContractQueriesController } from "../smartContractQueriesController";
import { Transaction } from "../transaction";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { SmartContractTransactionsOutcomeParser } from "../transactionsOutcomeParsers";
import { TransactionWatcher } from "../transactionWatcher";
import * as resources from "./resources";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Address } from "../address";
import { Err } from "../errors";
import { loadAbiRegistry, loadContractCode } from "../testutils/utils";
import { Token, TokenTransfer } from "../tokens";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { SmartContractTransactionsFactory } from "./smartContractTransactionsFactory";

describe("test smart contract transactions factory", function () {
Expand Down
4 changes: 2 additions & 2 deletions src/smartContracts/smartContractTransactionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { CONTRACT_DEPLOY_ADDRESS_HEX, VM_TYPE_WASM_VM } from "../constants";
import { Err } from "../errors";
import { Logger } from "../logger";
import { TokenComputer, TokenTransfer } from "../tokens";
import { TokenTransfersDataBuilder } from "../tokenTransfersDataBuilder";
import { Transaction } from "../transaction";
import { TokenTransfersDataBuilder } from "../transactionsFactories/tokenTransfersDataBuilder";
import { TransactionBuilder } from "../transactionsFactories/transactionBuilder";
import { TransactionBuilder } from "../transactionBuilder";
import { byteArrayToHex, utf8ToHex } from "../utils.codec";
import * as resources from "./resources";

Expand Down
2 changes: 1 addition & 1 deletion src/tokenManagement/tokenManagementController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { INetworkProvider } from "../networkProviders/interface";
import { IESDTIssueOutcome } from "../tokenOperations";
import { Transaction } from "../transaction";
import { TransactionComputer } from "../transactionComputer";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { TokenManagementTransactionsOutcomeParser } from "../transactionsOutcomeParsers";
import { TransactionWatcher } from "../transactionWatcher";
import * as resources from "./resources";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assert } from "chai";
import { Address } from "../address";
import { ESDT_CONTRACT_ADDRESS_HEX } from "../constants";
import { loadTestWallets, TestWallet } from "../testutils";
import { TransactionsFactoryConfig } from "../transactionsFactories";
import { TransactionsFactoryConfig } from "../transactionsFactoryConfig";
import { TokenManagementTransactionsFactory } from "./tokenManagementTransactionsFactory";

describe("test token management transactions factory", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/tokenManagement/tokenManagementTransactionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ErrBadUsage } from "../errors";
import { IAddress } from "../interface";
import { Logger } from "../logger";
import { Transaction } from "../transaction";
import { TransactionBuilder } from "../transactionsFactories/transactionBuilder";
import { TransactionBuilder } from "../transactionBuilder";
import * as resources from "./resources";

interface IConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AddressValue, ArgSerializer, BigUIntValue, TokenIdentifierValue, TypedValue, U32Value } from "../abi";
import { IAddress } from "../interface";
import { TokenComputer, TokenTransfer } from "../tokens";
import { AddressValue, ArgSerializer, BigUIntValue, TokenIdentifierValue, TypedValue, U32Value } from "./abi";
import { IAddress } from "./interface";
import { TokenComputer, TokenTransfer } from "./tokens";

export class TokenTransfersDataBuilder {
private tokenComputer: TokenComputer;
Expand Down
7 changes: 3 additions & 4 deletions src/transaction.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { TokenTransfer } from "./tokens";
import { Transaction } from "./transaction";
import { TransactionComputer } from "./transactionComputer";
import { TransactionPayload } from "./transactionPayload";
import { TransactionsFactoryConfig } from "./transactionsFactoryConfig";
import { TransactionWatcher } from "./transactionWatcher";
import { TransactionsFactoryConfig } from "./transactionsFactories/transactionsFactoryConfig";
import { TransferTransactionsFactory } from "./transactionsFactories/transferTransactionsFactory";
import { TransferTransactionsFactory } from "./transfers/transferTransactionsFactory";

describe("test transaction", function () {
let alice: TestWallet, bob: TestWallet;
Expand Down Expand Up @@ -156,8 +156,7 @@ describe("test transaction", function () {
await bob.sync(provider);
const initialBalanceOfBob = new BigNumber(bob.account.balance.toString());

const transaction = factory.createTransactionForNativeTokenTransfer({
sender: alice.address,
const transaction = factory.createTransactionForNativeTokenTransfer(alice.address, {
receiver: bob.address,
nativeAmount: 42000000000000000000n,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ARGUMENTS_SEPARATOR } from "../constants";
import { IAddress, ITransactionPayload } from "../interface";
import { Transaction } from "../transaction";
import { TransactionPayload } from "../transactionPayload";
import { ARGUMENTS_SEPARATOR } from "./constants";
import { IAddress, ITransactionPayload } from "./interface";
import { Transaction } from "./transaction";
import { TransactionPayload } from "./transactionPayload";

interface Config {
chainID: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LibraryConfig } from "../config";
import { LibraryConfig } from "./config";

export class TransactionsFactoryConfig {
chainID: string;
Expand Down
128 changes: 0 additions & 128 deletions src/transferTransactionsFactory.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./transactionsFactoryConfig";
export * from "./transfersControllers";
export * from "./transferTransactionsFactory";
20 changes: 20 additions & 0 deletions src/transfers/resources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Address } from "../address";
import { TokenTransfer } from "../tokens";

export type NativeTokenTransferInput = {
receiver: Address;
nativeAmount?: bigint;
data?: Uint8Array;
};

export type CustomTokenTransferInput = {
receiver: Address;
tokenTransfers: TokenTransfer[];
};

export type CreateTransferTransactionInput = {
receiver: Address;
nativeAmount?: bigint;
tokenTransfers?: TokenTransfer[];
data?: Uint8Array;
};
Loading

0 comments on commit 0bdc506

Please sign in to comment.