Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ window.onload = async () => {
if (window.keplr.experimentalSuggestChain) {
try {
// Keplr v0.6.4 introduces an experimental feature that supports the feature to suggests the chain from a webpage.
// cosmoshub-3 is integrated to Keplr so the code should return without errors.
// The code below is not needed for cosmoshub-3, but may be helpful if you’re adding a custom chain.
// cosmoshub-4 is integrated to Keplr so the code should return without errors.
// The code below is not needed for cosmoshub-4, but may be helpful if you’re adding a custom chain.
// If the user approves, the chain will be added to the user's Keplr extension.
// If the user rejects it or the suggested chain information doesn't include the required fields, it will throw an error.
// If the same chain id is already registered, it will resolve and not require the user interactions.
await window.keplr.experimentalSuggestChain({
// Chain-id of the Cosmos SDK chain.
chainId: "cosmoshub-3",
chainId: "cosmoshub-4",
// The name of the chain to be displayed to the user.
chainName: "Cosmos",
// RPC endpoint of the chain.
rpc: "https://node-cosmoshub-3.keplr.app/rpc",
rpc: "https://node-cosmoshub-4.keplr.app/rpc",
// REST endpoint of the chain.
rest: "https://node-cosmoshub-3.keplr.app/rest",
rest: "https://node-cosmoshub-4.keplr.app/rest",
// Staking coin information
stakeCurrency: {
// Coin denomination to be displayed to the user.
Expand Down Expand Up @@ -112,7 +112,7 @@ window.onload = async () => {
}
}

const chainId = "cosmoshub-3";
const chainId = "cosmoshub-4";

// You should request Keplr to enable the wallet.
// This method will ask the user whether or not to allow access if they haven't visited this website.
Expand All @@ -130,7 +130,7 @@ window.onload = async () => {

// Initialize the gaia api with the offline signer that is injected by Keplr extension.
const cosmJS = new SigningCosmosClient(
"https://node-cosmoshub-3.keplr.app/rest",
"https://node-cosmoshub-4.keplr.app/rest",
accounts[0].address,
offlineSigner,
);
Expand All @@ -153,15 +153,15 @@ document.sendForm.onsubmit = () => {

(async () => {
// See above.
const chainId = "cosmoshub-3";
const chainId = "cosmoshub-4";
await window.keplr.enable(chainId);
const offlineSigner = window.getOfflineSigner(chainId);

const accounts = await offlineSigner.getAccounts();

// Initialize the gaia api with the offline signer that is injected by Keplr extension.
const cosmJS = new SigningCosmosClient(
"https://node-cosmoshub-3.keplr.app/rest",
"https://node-cosmoshub-4.keplr.app/rest",
accounts[0].address,
offlineSigner
);
Expand Down