@moonbeam-network/xcm-utils
Version:
Moonbeam XCM utilities
46 lines (38 loc) • 1.96 kB
TypeScript
import { RoundingMode } from 'big.js';
import { ApiPromise } from '@polkadot/api';
declare function isHexString(asset: unknown): boolean;
declare function isEthAddress(address: string): boolean;
declare function formatAssetIdToERC20(id: string): string;
declare function convertAddressTo32Bytes(address: string): string;
declare function toDecimal(number: bigint | number | string, decimals: number, maxDecimal?: number, roundType?: RoundingMode): string;
declare function toBigInt(amount: bigint | string | number, decimals: number): bigint;
declare function convertDecimals(number: string | bigint, decimals: number, targetDecimals: number): bigint;
declare function hasDecimalOverflow(fl: number | string, maxDecimal: number): boolean;
/**
* reference: https://github.com/Moonsong-Labs/xcm-tools/blob/main/scripts/calculate-sovereign-account.ts
*/
declare function getSovereignAccountAddresses(paraId: number): {
generic: string;
moonbeam: string;
relay: string;
};
/**
* reference: https://github.com/Moonsong-Labs/xcm-tools/blob/main/scripts/calculate-multilocation-derivative-account.ts
*/
declare function getMultilocationDerivedAddresses({ paraId, address, isParents, }: {
paraId?: number;
address: string;
isParents?: boolean;
}): {
address20: `0x${string}`;
address32: `0x${string}`;
};
declare enum MRLTypes {
XcmVersionedMultiLocation = "XcmVersionedMultiLocation",
XcmVersionedLocation = "XcmVersionedLocation",
XcmRoutingUserAction = "XcmRoutingUserAction",
VersionedUserAction = "VersionedUserAction"
}
declare function getPolkadotApi(ws: string | string[]): Promise<ApiPromise>;
declare function getPolkadotAppsUrl(ws: string): string;
export { MRLTypes, convertAddressTo32Bytes, convertDecimals, formatAssetIdToERC20, getMultilocationDerivedAddresses, getPolkadotApi, getPolkadotAppsUrl, getSovereignAccountAddresses, hasDecimalOverflow, isEthAddress, isHexString, toBigInt, toDecimal };