@interchainjs/injective
Version:
<p align="center"> <img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"> </p>
26 lines (25 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountFromAuth = getAccountFromAuth;
exports.updateDomain = updateDomain;
const utils_1 = require("@interchainjs/utils");
const defaults_1 = require("./defaults");
function getAccountFromAuth(auth, pubKeyConfig = defaults_1.defaultPublicKeyConfig) {
const publicKey = auth.getPublicKey(pubKeyConfig.isCompressed);
const pubKeyHash = pubKeyConfig.hash(publicKey);
return {
algo: auth.algo,
publicKey,
cosmosAddress: pubKeyHash.toBech32('inj'),
ethereumAddress: pubKeyHash.toPrefixedHex(),
};
}
function updateDomain(defaultOptions, options) {
return {
name: options?.name ?? defaultOptions.name,
version: options?.version ?? defaultOptions.version,
chainId: (0, utils_1.toPrefixedHex)((0, utils_1.fromNumber)(options?.ethereumChainId ?? defaultOptions.ethereumChainId), true),
salt: options?.salt ?? defaultOptions.salt,
verifyingContract: options?.verifyingContract ?? defaultOptions.verifyingContract,
};
}