Skip to content

Commit

Permalink
Chihuahua metamask (#104)
Browse files Browse the repository at this point in the history
* metamask integration.

* snap installation fixes.
  • Loading branch information
SrikanthSoparla authored Jan 14, 2024
1 parent 16f067c commit 1bcccdf
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const metamaskInitialize = (cb) => {
},
});

if (!initialized) {
if (initialized && initialized.data && !initialized.data.initialized) {
// Initialize the Snap with default chains
window.ethereum.request({
method: 'wallet_invokeSnap',
Expand All @@ -177,9 +177,29 @@ const metamaskInitialize = (cb) => {
},
},
}).then((result) => {
window.ethereum.request({
method: 'wallet_invokeSnap',
params: {
snapId: 'npm:@cosmsnap/snap',
request: {
method: 'getChainAddress',
params: {
chain_id: chainId,
},
},
},
}).then((result) => {
if (result && result.data) {
cb(null, result && result.data);
}
}).catch((error) => {
cb((error && error.message) || error);
});
}).catch((error) => {
cb((error && error.message) || error);
});

return;
}

window.ethereum.request({
Expand Down

0 comments on commit 1bcccdf

Please sign in to comment.