@pushchain/core
Version:
## Overview
72 lines (71 loc) • 2.96 kB
TypeScript
import { convertOriginToExecutor, fromChainAgnostic, convertExecutorToOriginAccount, toChainAgnostic, toUniversal } from './universal/account';
import { construct, toUniversal as toUniversalSigner, toUniversalFromKeypair } from './universal/signer';
/**
* @dev - THESE UTILS ARE EXPORTED TO SDK CONSUMER
* @dev - Make sure each exported fn has good comments to help out sdk consumer
*/
/**
* Utility class for handling CAIP-10 chain-agnostic address formatting
* and universal account conversions.
*/
export declare class Utils {
static account: {
toChainAgnostic: typeof toChainAgnostic;
toUniversal: typeof toUniversal;
/**
* Converts a CAIP-10 formatted string into a UniversalAccount.
*
* @param {string} caip - A CAIP-10 address string (e.g., 'eip155:1:0xabc...').
* @returns {UniversalAccount} The resolved account.
* @throws {Error} If the CAIP string is invalid or unsupported.
*
* @example
* Utils.account.fromChainAgnostic('eip155:11155111:0xabc...')
* // → { chain: CHAIN.ETHEREUM_SEPOLIA, address: '0xabc...' }
*/
fromChainAgnostic: typeof fromChainAgnostic;
convertOriginToExecutor: typeof convertOriginToExecutor;
convertExecutorToOriginAccount: typeof convertExecutorToOriginAccount;
};
static signer: {
/**
* Converts various signer types (viem, ethers v6, Solana) into a UniversalSigner.
*/
toUniversalFromKeypair: typeof toUniversalFromKeypair;
/**
* Constructs a UniversalSignerSkeleton from raw signing functions.
*/
construct: typeof construct;
/**
* Converts a UniversalSignerSkeleton to a UniversalSigner.
*/
toUniversal: typeof toUniversalSigner;
};
static helpers: {
getChainName: (chainNamespace: string) => string;
encodeTxData({ abi, functionName, args, }: {
abi: any[];
functionName: string;
args?: any[];
}): `0x${string}`;
/**
* Multiplies a string representation of a number by a given exponent of base 10 (10^exponent).
*
* This is commonly used for converting human-readable token amounts to their on-chain representation.
* For example, converting "1.5" ETH to wei (18 decimals) would be parseUnits("1.5", 18).
*
* @param {string} value - The string representation of the number to multiply.
* @param {number} exponent - The exponent (number of decimal places).
* @returns {bigint} The result as a bigint.
*
* @example
* Utils.helpers.parseUnits('420', 9)
* // → 420000000000n
*
* @example
* Utils.helpers.parseUnits('1.5', 18)
* // → 1500000000000000000n
*/
parseUnits(value: string, exponent: number): bigint;
};
}