UNPKG

@interchainjs/injective

Version:

<p align="center"> <img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"> </p>

22 lines (21 loc) 935 B
import { fromNumber, toPrefixedHex } from '@interchainjs/utils'; import { defaultPublicKeyConfig } from './defaults'; export function getAccountFromAuth(auth, pubKeyConfig = defaultPublicKeyConfig) { const publicKey = auth.getPublicKey(pubKeyConfig.isCompressed); const pubKeyHash = pubKeyConfig.hash(publicKey); return { algo: auth.algo, publicKey, cosmosAddress: pubKeyHash.toBech32('inj'), ethereumAddress: pubKeyHash.toPrefixedHex(), }; } export function updateDomain(defaultOptions, options) { return { name: options?.name ?? defaultOptions.name, version: options?.version ?? defaultOptions.version, chainId: toPrefixedHex(fromNumber(options?.ethereumChainId ?? defaultOptions.ethereumChainId), true), salt: options?.salt ?? defaultOptions.salt, verifyingContract: options?.verifyingContract ?? defaultOptions.verifyingContract, }; }