FCT Utils

Utility functions of the FCT

import { BatchMultiSigCall } from "@kirobo/fct-core"

const FCT = new BatchMultiSigCall();
const utils = FCT.utils

Functions

getAllRequiredApprovals

Promise function - Returns an array of required approvals for each call in the FCT.

const requiredApprovals = await FCT.utils.getAllRequiredApprovals()

Returns

IRequiredApproval[]

getCalldataForActuator

Retrieve the encoded calldata for the actuator to execute the FCT.

const calldata = FCT.utils.getCalldataForActuator({
    signatures,
    purgedFCT,
    investor,
    activator
})

Method Arguments

NameTypeDescription

signatures

SignatureLike

Signatures of the FCT

purgedFCT

string

Hash of FCT that is purged

investor

string

Address of investor

activator

string

Address of activator

Returns

string - Encoded calldata for FCT_BatchMultiSigCall function batchMultiSigCall

getAuthenticatorSignature

Get the authenticator's signature for the FCT.

The authenticator's signature must always be at signatures[0].

Otherwise, the execution of the FCT will fail with an error FCT:E data mismatch

const call = FCT.utils.getAuthenticatorSignature();

Method Arguments

No arguments

Returns

SignatureLike

recoverAddress

Recover the address from a signature that was used to sign the FCT.

const address = FCT.utils.recoverAddress(signature);

Method Arguments

NameTypeDescription

signature

SignatureLike

Signature of the FCT

Returns

string

getOptions

Parses FCT's sessionId and returns an object of FCT options.

const options = FCT.utils.getOptions();

Returns

{
    valid_from: string, 
    expires_at: string, 
    gas_price_limit: string, 
    blockable: boolean, 
    purgeable: boolean, 
    builder: string, 
    recurrency: {
        accumetable: boolean, 
        chillTime: string, 
        maxRepeats: string
    }, 
    authEnabled: boolean
}

getMessageHash

Retrieve the message hash of the FCT.

const messageHash = FCT.utils.getMessageHash();

Method Arguments

No arguments

Returns

string

isValid

Check if the FCT is valid. If the FCT is invalid, an error will be thrown with a reason.

const isValid = FCT.utils.isValid();

Method Arguments

No arguments

Returns

boolean | Error

getSigners

Retrieve all signer addresses from the FCT.

const signers = FCT.utils.getSigners();

Method Arguments

No arguments

Returns

string[]

getAllPaths

Retrieve all possible run paths for the execution of the FCT.

const paths = FCT.utils.getAllPaths();

Method Arguments

No arguments

Returns

Returns an array of paths, where each path is represented as a string[] of call indexes.

string[][]

getPaymentPerPayer

Calculates the largest and smallest possible payments for every payer in the FCT.

const payments = FCT.utils.getPaymentPerPayer({
    signatures,
    gasPrice,
    ethPriceInKIRO,
    penalty,
    fees,
});

Method Arguments

All variables are optional except kiroPriceInETH

NameTypeDescription

signatures

SignatureLike[]

Signatures for FCT

gasPrice

number

Intented FCT execution gas price. Note - if the provided gas price is higher than maxGasPrice, function will use maxGasPrice instead

maxGasPrice

number | string | bigint

Default - maxGasPrice set in FCTs options. The max gas price that the FCT can be executed on

kiroPriceInETH

string

penalty

number

Penalty if payment is in ETH instead of KIRO. Format in wei. Example - penalty 4 is "40000"

fees

{

baseFeeBPS?: number; bonusFeeBPS?: number;

};

Fees of the FCT execution. By default: - baseFeeBPS: 1000, - bonusFeeBPS: 5000

Returns

{
    payer: string;
    largestPayment: {
        gas: string;
        amount: string;
        amountInETH: string;
    };
    smallestPayment: {
        gas: string;
        amount: string;
        amountInETH: string;
    };
}[]

Last updated