Skip to main content

Namespace: helpers

Enumerations

Variables

BUYER

Const BUYER: "buyer"

Defined in

helpers/constants.ts:22


SELLER

Const SELLER: "seller"

Defined in

helpers/constants.ts:23


WHO_BUYER

Const WHO_BUYER: 1

Defined in

helpers/constants.ts:10


WHO_MARKETPLACE

Const WHO_MARKETPLACE: 3

Defined in

helpers/constants.ts:12


WHO_PROTOCOL

Const WHO_PROTOCOL: 0

Defined in

helpers/constants.ts:9


WHO_SELLER

Const WHO_SELLER: 2

Defined in

helpers/constants.ts:11


ZERO_FEE_VALUE

Const ZERO_FEE_VALUE: 0

Defined in

helpers/constants.ts:1

Functions

addressWithYou

addressWithYou(address, walletAddress, nonEnsAddress?): string

Parameters

NameType
addressstring
walletAddressstring
nonEnsAddress?string

Returns

string

Defined in

helpers/addressFormat.ts:24


bipsToPercentage

bipsToPercentage(values): number[]

convert bips to percentage dividing (/) the value by 100

Parameters

NameType
valuesnumber[] | bigint[]

Returns

number[]

Defined in

helpers/bipsToPercentage.ts:5


calculateSplit

calculateSplit(group, walletUserAddress): bigint

Parameters

NameType
groupIGetEscrowData[]
walletUserAddressstring

Returns

bigint

Defined in

helpers/calculateSplit.ts:55


countdownChallengePeriod

countdownChallengePeriod(end): string

Parameters

NameType
endDate

Returns

string

Defined in

helpers/countdownChallengePeriod.ts:1


displayChallengePeriod

displayChallengePeriod(challengePeriod, useLongFormat?): string

Parameters

NameType
challengePeriodnumber
useLongFormat?boolean

Returns

string

Defined in

helpers/displayChallengePeriod.ts:34


formatAmount

formatAmount(amount, precision): string

Parameters

NameType
amountbigint
precisionnumber | bigint

Returns

string

Defined in

helpers/formatAmount.ts:3


formatAmountToUSD

formatAmountToUSD(amount, exchangeValue): string

Parameters

NameType
amountstring | number | bigint
exchangeValuenumber

Returns

string

Defined in

helpers/formatAmountToUSD.ts:3


getExchangeRates

getExchangeRates(chainId, tokensAddresses): Promise<IResult>

Parameters

NameType
chainIdnumber
tokensAddressesstring[]

Returns

Promise<IResult>

Defined in

helpers/getExchangeRates.ts:61


getSplitFromLoggedUser

getSplitFromLoggedUser(«destructured», walletUserAddress): bigint

Parameters

NameType
«destructured»IGetEscrowData
walletUserAddressstring

Returns

bigint

Defined in

helpers/calculateSplit.ts:6


groupBy

groupBy<T, K>(array, getKey): Record<K, T[]>

Type parameters

NameType
TT
Kextends string | number | symbol

Parameters

NameType
arrayT[]
getKey(item: T) => K

Returns

Record<K, T[]>

Defined in

helpers/groupBy.ts:1


isSameAddress

isSameAddress(address1, address2): boolean

isSameAddress function compares two addresses, if equal returns true otherwise false.

Always use this function to compare addresses, and avoid to call toLowerCase() directly

Parameters

NameType
address1string
address2string

Returns

boolean

Defined in

helpers/isSameAddress.ts:8


isValidAddress

isValidAddress(address): boolean

Parameters

NameType
addressstring

Returns

boolean

Defined in

helpers/isValidAddress.ts:3


nullOrValue

nullOrValue(value): any

Parameters

NameType
valueany

Returns

any

Defined in

helpers/nullOrValue.ts:3


parseAmount

parseAmount(amount, precision): bigint

Parameters

NameType
amountstring
precisionnumber | bigint

Returns

bigint

Defined in

helpers/formatAmount.ts:14


percentageToBips

percentageToBips(values): number[]

convert percetage to bips multplying (*) the value by 100

Parameters

NameType
valuesnumber[]

Returns

number[]

Defined in

helpers/percentageToBips.ts:5


reduceAddress

reduceAddress(address, ensAddress?): string

Parameters

NameType
addressstring
ensAddress?string

Returns

string

Defined in

helpers/addressFormat.ts:4


roundPercentage

roundPercentage(amount): number

Round a percentage to max 2 decimals. If amount > 100, returns 100 If amount < 0, returns 0

Parameters

NameType
amountnumber

Returns

number

Defined in

helpers/roundPercentage.ts:6


tag

tag<tag>(tagHtmlName): HTMLElementTagNameMap[tag]

Helper to create tags html in declarative way

Type parameters

NameType
tagextends keyof HTMLElementTagNameMap

Parameters

NameType
tagHtmlNametag

Returns

HTMLElementTagNameMap[tag]

HTMLElementTagNameMap by tag name

Defined in

helpers/tag.ts:5


toDate

toDate(seconds): Date

convert to date getting the BigInt timestamp without milliseconds and converting it to date with milliseconds

Every timestamp that come from the blockchain should be passed by this function The blockchain provide the timestamp without the milleseconds.

So the fields: challenge_period_start, challenge_period_end, paid_at, release_at, ...etc_at, should use this function to parse the seconds in valid date.

Parameters

NameType
secondsnumber | bigint

Returns

Date

Defined in

helpers/toDate.ts:13


validateAddresses

validateAddresses(address): boolean

Parameters

NameType
addressValidAddrsProps

Returns

boolean

Defined in

helpers/validateAddresses.ts:40


validateParameters

validateParameters(data): Promise<validAddrsToken>

Parameters

NameType
dataIValidateProps

Returns

Promise<validAddrsToken>

Defined in

helpers/validateParameters.ts:16