UNPKG

@tedcryptoorg/cosmos-signer

Version:

Cosmos Signer - A library for signing transactions for Cosmos SDK chains

50 lines (49 loc) 1.76 kB
import BaseWallet from "./BaseWallet"; export class CosmostationWallet extends BaseWallet { cosmostationProvider; name = 'cosmostation'; label = 'Cosmostation Wallet'; keychangeEvent = 'cosmostation_keystorechange'; authzAminoLiftedValueSupport = false; constructor(keplrProvider, cosmostationProvider) { super(keplrProvider); this.cosmostationProvider = cosmostationProvider; } async getSigner(network) { if (this.signer === null) { const { chainId } = network; if (this.isLedger()) { this.signer = await this.provider.getOfflineSignerOnlyAmino(chainId); } else { this.signer = await this.provider.getOfflineSigner(chainId); } } return this.signer; } async suggestChain(network) { return await this.cosmostationProvider.request({ method: 'cos_addChain', params: this.suggestChainData(network) }); } suggestChainData(network) { return { chainId: network.chainId, chainName: network.prettyName, addressPrefix: network.prefix, baseDenom: network.denom, displayDenom: network.symbol, restURL: network.restUrl, coinType: `${network.slip44}`, decimals: network.decimals, gasRate: { average: `${network.gasPriceStep.high}`, low: `${network.gasPriceStep.average}`, tiny: `${network.gasPriceStep.low}` }, ...((network.data.keplrFeatures?.includes('eth-address-gen') ?? network.slip44 === 60) ? { type: 'ETHERMINT' } : {}) }; } }