Skip to content

Commit

Permalink
chore(SuggestChain): allow partial io options
Browse files Browse the repository at this point in the history
 - refactor keplr access
  • Loading branch information
dckc committed Jul 14, 2022
1 parent 92d980d commit 175f809
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/wallet/ui/src/util/SuggestChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ const makeChainInfo = (networkConfig, rpcAddr, chainId, caption) => {

export async function suggestChain(
networkConfig,
caption = undefined,
io = {
fetch,
window,
SigningStargateClient,
random: Math.random,
},
/** @type {string} */ caption = undefined,
io = {},
) {
const { fetch, window, SigningStargateClient: SigningClient, random } = io;
const {
fetch = globalThis.fetch,
keplr = window.keplr,
SigningClient = SigningStargateClient,
random = Math.random,
} = io;

const res = await fetch(networkConfig);
if (!res.ok) {
Expand All @@ -77,10 +77,10 @@ export async function suggestChain(
const rpcAddr = rpcAddrs[Math.floor(random() * rpcAddrs.length)];

const chainInfo = makeChainInfo(networkConfig, rpcAddr, chainId, caption);
await window.keplr.experimentalSuggestChain(chainInfo);
await window.keplr.enable(chainId);
await keplr.experimentalSuggestChain(chainInfo);
await keplr.enable(chainId);

const offlineSigner = window.getOfflineSigner(chainId);
const offlineSigner = keplr.getOfflineSigner(chainId);
const cosmJS = await SigningClient.connectWithSigner(
chainInfo.rpc,
offlineSigner,
Expand Down

0 comments on commit 175f809

Please sign in to comment.