@pushchain/core
Version:
Push Chain is a true universal L1 that is 100% EVM compatible. It allows developers to deploy once and make their apps instantly compatible with users from all other L1s (Ethereum, Solana, etc) with zero on-chain code change.
64 lines (63 loc) • 2.51 kB
TypeScript
import { CHAIN } from '../../constants/enums';
import { ExecutorAccountInfo, OriginAccountInfo, UniversalAccount } from '../universal.types';
/**
* Creates a `UniversalAccount` object from an address and chain options.
* Alternative to createUniversalAccount with a different parameter structure.
*
* @param {string} address - The account address.
* @param {Object} options - The configuration options.
* @param {CHAIN} options.chain - The chain the account is associated with.
* @returns {UniversalAccount} A normalized account object with chain and address.
*
* @example
* const universalAccount = toUniversal(
* '0x35B84d6848D16415177c64D64504663b998A6ab4',
* { chain: CHAIN.ETHEREUM_SEPOLIA }
* );
* // → { chain: CHAIN.ETHEREUM_SEPOLIA, address: '0x35B84d6848D16415177c64D64504663b998A6ab4' }
*/
export declare function toUniversal(address: string, options: {
chain: CHAIN;
}): UniversalAccount;
/**
* Converts an address and chain into a CAIP-10 style address string.
*
* Format: `namespace:chainId:address`
* Namespace is derived from the chain's VM type using VM_NAMESPACE.
*
* @param {string} address - The account address to convert.
* @param {Object} options - The configuration options.
* @param {CHAIN} options.chain - The chain the account is associated with.
* @returns {string} A CAIP-10 formatted string.
*
* @example
* Utils.account.toChainAgnostic('0xabc123...', {
* chain: CHAIN.ETHEREUM_SEPOLIA
* })
* // → 'eip155:11155111:0xabc123...'
*/
export declare function toChainAgnostic(address: string, options: {
chain: CHAIN;
}): string;
/**
* 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...' }
*/
export declare function fromChainAgnostic(caip: string): UniversalAccount;
export declare function convertOriginToExecutor(account: UniversalAccount, options?: {
onlyCompute?: boolean;
}): Promise<ExecutorAccountInfo>;
/**
* Convert Executor to Origin Account
*
* Given a UEA (executor) address on Push Chain, returns the mapped origin
* account and an existence flag.
*/
export declare function convertExecutorToOriginAccount(ueaAddress: `0x${string}`): Promise<OriginAccountInfo>;