client-aftermath-ts-sdk
Version:
Client Aftermath TypeScript SDK
96 lines • 5.43 kB
TypeScript
import { DisplayFieldsResponse, SuiObjectResponse } from "@mysten/sui/client";
import { AnyObjectType, Balance, ObjectId, Slippage, ModuleName, MoveErrorCode, SuiAddress, CoinType, CoinGeckoChain } from "../../types";
import { DynamicFieldsApiHelpers } from "../apiHelpers/dynamicFieldsApiHelpers";
import { EventsApiHelpers } from "../apiHelpers/eventsApiHelpers";
import { InspectionsApiHelpers } from "../apiHelpers/inspectionsApiHelpers";
import { ObjectsApiHelpers } from "../apiHelpers/objectsApiHelpers";
import { TransactionsApiHelpers } from "../apiHelpers/transactionsApiHelpers";
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
import { MoveErrors } from "../types/moveErrorsInterface";
import { Keypair } from "@mysten/sui/cryptography";
/**
* A utility class containing various helper functions for general use.
*/
export declare class Helpers {
static readonly dynamicFields: typeof DynamicFieldsApiHelpers;
static readonly events: typeof EventsApiHelpers;
static readonly inspections: typeof InspectionsApiHelpers;
static readonly objects: typeof ObjectsApiHelpers;
static readonly transactions: typeof TransactionsApiHelpers;
/**
* Removes leading zeroes from the hexadecimal representation of a given object type.
* @param type - The object type to strip leading zeroes from.
* @returns The object type with leading zeroes removed from its hexadecimal representation.
*/
static stripLeadingZeroesFromType: (type: AnyObjectType) => AnyObjectType;
/**
* Adds leading zeroes to a given `AnyObjectType` until it reaches a length of 64 characters.
* If the input type already has a length greater than 64, an error is thrown.
* @param type - The `AnyObjectType` to add leading zeroes to.
* @returns The modified `AnyObjectType` with leading zeroes added.
* @throws An error if the input type has a length greater than 64.
*/
static addLeadingZeroesToType: (type: AnyObjectType) => AnyObjectType;
static splitNonSuiCoinType: (coin: CoinType) => {
chain: Exclude<CoinGeckoChain, "sui">;
coinType: CoinType;
};
static isNumber: (str: string) => boolean;
static sum: (arr: number[]) => number;
static sumBigInt: (arr: bigint[]) => bigint;
static closeEnough: (a: number, b: number, tolerance: number) => boolean;
static closeEnoughBigInt: (a: bigint, b: bigint, tolerance: number) => boolean;
static veryCloseInt: (a: number, b: number, fixedOne: number) => boolean;
static blendedOperations: {
mulNNN: (a: number, b: number) => number;
mulNNB: (a: number, b: number) => bigint;
mulNBN: (a: number, b: bigint) => number;
mulNBB: (a: number, b: bigint) => bigint;
mulBBN: (a: bigint, b: bigint) => number;
mulBBB: (a: bigint, b: bigint) => bigint;
};
static maxBigInt: (...args: bigint[]) => bigint;
static minBigInt: (...args: bigint[]) => bigint;
static absBigInt: (num: bigint) => bigint;
static capitalizeOnlyFirstLetter: (str: string) => string;
static parseJsonWithBigint: (json: string, unsafeStringNumberConversion?: boolean) => any;
static deepCopy: <T>(target: T) => T;
static indexOfMax: (arr: any[]) => number;
static uniqueArray: <T>(arr: T[]) => T[];
static sleep: (ms: number) => Promise<unknown>;
static createUid: () => string;
static bifilter: <ArrayType>(array: ArrayType[], func: (item: ArrayType, index: number, arr: ArrayType[]) => boolean) => [trues: ArrayType[], falses: ArrayType[]];
static bifilterAsync: <ArrayType>(array: ArrayType[], func: (item: ArrayType, index: number, arr: ArrayType[]) => Promise<boolean>) => Promise<[trues: ArrayType[], falses: ArrayType[]]>;
static filterObject: <Value>(obj: Record<string, Value>, predicate: (key: string, value: Value) => boolean) => Record<string, Value>;
static applySlippageBigInt: (amount: Balance, slippage: Slippage) => bigint;
static applySlippage: (amount: number, slippage: Slippage) => number;
static zip<S1, S2>(firstCollection: Array<S1>, lastCollection: Array<S2>): Array<[S1, S2]>;
static removeCircularReferences<T>(obj: T, seen?: WeakSet<object>): T | undefined;
static isArrayOfStrings(value: unknown): value is string[];
static isValidType: (str: string) => boolean;
static isValidHex: (hexString: string) => boolean;
static getObjectType(data: SuiObjectResponse): ObjectId;
static getObjectId(data: SuiObjectResponse): ObjectId;
static getObjectFields(data: SuiObjectResponse): Record<string, any>;
static getObjectDisplay(data: SuiObjectResponse): DisplayFieldsResponse;
static addTxObject: (tx: Transaction, object: ObjectId | TransactionObjectArgument) => TransactionObjectArgument;
static isValidSuiAddress: (address: SuiAddress) => boolean;
static parseMoveErrorMessage(inputs: {
errorMessage: string;
}): {
errorCode: MoveErrorCode;
packageId: ObjectId;
module: ModuleName;
} | undefined;
static translateMoveErrorMessage(inputs: {
errorMessage: string;
moveErrors: MoveErrors;
}): {
errorCode: MoveErrorCode;
packageId: ObjectId;
module: ModuleName;
error: string;
} | undefined;
static keypairFromPrivateKey: (privateKey: string) => Keypair;
}
//# sourceMappingURL=helpers.d.ts.map