IERC20PaymentClientBase_v1.sol

Git Source

Author: Inverter Network

Enables modules within the Inverter Network to create and manage payment orders that can be processed by authorized payment processors, ensuring efficient and secure transactions. Refer to the implementations contract for more details.

STRUCTURING OF THE FLAGS AND DATA FIELDS The PaymentOrder struct implements a flag system to manage the information payloads received by the payment processor. It is comprised of a bytes32 value that indicates the number of flags that are active, and a bytes32[] value that stores the corresponding values. For example: If the value of 'flags' is '0000 [...] 0000 1011', then that order stores values for the paramters 0, 1 and 3 of the master list. The byte code for simple flag setups might also be represented by hexadecimal values like 0xB, which has the same value as the bit combination above. If a module wants to set flags, it can use bit shifts, in this case 1 << 0, 1 << 1 and 1 << 3. Afterwards, to be correct, the following data variable should contain 3 elements of the type specified in the master list, each stored as bytes32 value.

Functions

paymentOrders

Returns the list of outstanding payment orders.

function paymentOrders() external view returns (PaymentOrder[] memory);

Returns

Name
Type
Description

<none>

PaymentOrder[]

list of payment orders.

outstandingTokenAmount

Returns the total outstanding token payment amount.

function outstandingTokenAmount(address token_)
    external
    view
    returns (uint total_);

Parameters

Name
Type
Description

token_

address

The token in which to pay.

Returns

Name
Type
Description

total_

uint256

amount of token to pay.

collectPaymentOrders

Collects outstanding payment orders.

Marks the orders as completed for the client.

function collectPaymentOrders()
    external
    returns (
        PaymentOrder[] memory paymentOrders_,
        address[] memory tokens_,
        uint[] memory totalAmounts_
    );

Returns

Name
Type
Description

paymentOrders_

PaymentOrder[]

list of payment orders.

tokens_

address[]

list of token addresses.

totalAmounts_

uint256[]

list of amounts.

amountPaid

Notifies the PaymentClient, that tokens have been paid out accordingly.

Payment Client will reduce the total amount of tokens it will stock up by the given amount.

This has to be called by a paymentProcessor.

function amountPaid(address token_, uint amount_) external;

Parameters

Name
Type
Description

token_

address

The token in which the payment was made.

amount_

uint256

amount of tokens that have been paid out.

getFlags

Returns the flags used when creating payment orders in this client.

function getFlags() external view returns (bytes32 flags_);

Returns

Name
Type
Description

flags_

bytes32

The flags this client will use.

getFlagCount

Returns the number of flags this client uses for PaymentOrders.

function getFlagCount() external view returns (uint8 flagCount_);

Returns

Name
Type
Description

flagCount_

uint8

The number of flags.

Events

PaymentOrderAdded

Added a payment order.

event PaymentOrderAdded(
    address indexed recipient,
    address indexed token,
    uint amount,
    uint originChainId,
    uint targetChainId,
    bytes32 flags,
    bytes32[] data
);

Parameters

Name
Type
Description

recipient

address

The address that will receive the payment.

token

address

The token in which to pay.

amount

uint256

The amount of tokens the payment consists of.

originChainId

uint256

The id of the origin chain.

targetChainId

uint256

The id of the target chain.

flags

bytes32

Flags that indicate additional data used by the payment order.

data

bytes32[]

Array of additional data regarding the payment order.

FlagsSet

Emitted when the flags are set.

event FlagsSet(uint8 flagCount, bytes32 newFlags);

Parameters

Name
Type
Description

flagCount

uint8

The number of flags set.

newFlags

bytes32

The newly set flags.

Errors

Module__ERC20PaymentClientBase__CallerNotAuthorized

Function is only callable by authorized address.

error Module__ERC20PaymentClientBase__CallerNotAuthorized();

Module__ERC20PaymentClientBase__TokenTransferFailed

ERC20 token transfer failed.

error Module__ERC20PaymentClientBase__TokenTransferFailed();

Module__ERC20PaymentClientBase__InsufficientFunds

Insufficient funds to fulfill the payment.

error Module__ERC20PaymentClientBase__InsufficientFunds(address token);

Parameters

Name
Type
Description

token

address

The token in which the payment was made.

Module__ERC20PaymentClientBase__InvalidRecipient

Given recipient invalid.

error Module__ERC20PaymentClientBase__InvalidRecipient();

Module__ERC20PaymentClientBase__InvalidToken

Given token invalid.

error Module__ERC20PaymentClientBase__InvalidToken();

Module__ERC20PaymentClientBase__InvalidAmount

Given amount invalid.

error Module__ERC20PaymentClientBase__InvalidAmount();

Module__ERC20PaymentClientBase__InvalidPaymentOrder

Given paymentOrder is invalid.

error Module__ERC20PaymentClientBase__InvalidPaymentOrder();

Module__ERC20PaymentClientBase__MismatchBetweenFlagCountAndArrayLength

Given mismatch between flag count and supplied array length.

error Module__ERC20PaymentClientBase__MismatchBetweenFlagCountAndArrayLength(
    uint8 flagCount, uint arrayLength
);

Module__ERC20PaymentClientBase_v1__FlagAmountTooHigh

Given number of flags exceeds the limit.

error Module__ERC20PaymentClientBase_v1__FlagAmountTooHigh();

Structs

PaymentOrder

Struct used to store information about a payment order.

struct PaymentOrder {
    address recipient;
    address paymentToken;
    uint amount;
    uint originChainId;
    uint targetChainId;
    bytes32 flags;
    bytes32[] data;
}

Properties

Name
Type
Description

recipient

address

The recipient of the payment.

paymentToken

address

The token in which to pay. Assumed to always be on the local chain.

amount

uint256

The amount of tokens to pay.

originChainId

uint256

The id of the origin chain.

targetChainId

uint256

The id of the target chain.

flags

bytes32

Flags that indicate which information the data array contains.

data

bytes32[]

Array of additional data regarding the payment order.

Last updated