Skip to content

Commit

Permalink
feat: support metamask wallet on injective network (#31)
Browse files Browse the repository at this point in the history
Only works for extension; wallet connect is not implemented yet
  • Loading branch information
AaronCQL authored Dec 27, 2023
1 parent a41cfa8 commit 86dd77f
Show file tree
Hide file tree
Showing 21 changed files with 713 additions and 10 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## `v0.0.47`

### Features

- Added `MetamaskInjective` wallet to execute txs via MetaMask extension on Injective network (*does not support wallet connect yet*)

### Improvements

- Added `extensionOptions` to `Tx.toSignedProto`

## `v0.0.46`

### Fixes
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ pnpm build

### Publishing

To bump the package version prior to publishing, run:

```sh
# To bump the patch number (most publishes should use this)
pnpm version patch --no-git-tag-version

# To bump the prerelease number (if and only if a RC version is required)
pnpm version prerelease --no-git-tag-version --preid=rc
```

To publish the package to NPM, run:

```sh
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,18 @@ This directory contains various APIs, data, and types needed for wallet interact

### `cosmes/wallet`

This directory is a [Cosmos Kit](https://cosmoskit.com) alternative to manage various wallets (Keplr, Station, Cosmostation, Leap, etc.) across various different Cosmos SDK based blockchains. See [`examples/solid-vite`](./examples/solid-vite) for a working example.
This directory is a [Cosmos Kit](https://cosmoskit.com) alternative to interact with wallets across all Cosmos SDK based blockchains. See [`examples/solid-vite`](./examples/solid-vite) for a working example.

**Wallets supported**:

- [Station](https://docs.terra.money/learn/station/)
- [Keplr](https://www.keplr.app/)
- [Leap](https://www.leapwallet.io/)
- [Cosmostation](https://wallet.cosmostation.io/)
- [MetaMask](https://metamask.io/) (for Injective only)

**Features**:

- Supports Station, Keplr, Leap, and Cosmostation wallets
- Supports both browser extension (desktop) and WalletConnect (mobile)
- Unified interface for connecting, signing, broadcasting, and event handling
- Signing of arbitrary messages (for wallets that support it)
Expand Down
7 changes: 6 additions & 1 deletion examples/solid-vite/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CosmostationController,
KeplrController,
LeapController,
MetamaskInjectiveController,
StationController,
UnsignedTx,
WalletController,
Expand Down Expand Up @@ -34,6 +35,7 @@ const WALLETS: Record<WalletName, string> = {
[WalletName.COSMOSTATION]: "Cosmostation",
[WalletName.STATION]: "Terra Station",
[WalletName.LEAP]: "Leap",
[WalletName.METAMASK_INJECTIVE]: "MetaMask",
};
const TYPES: Record<WalletType, string> = {
[WalletType.EXTENSION]: "Extension",
Expand All @@ -44,6 +46,7 @@ const CONTROLLERS: Record<string, WalletController> = {
[WalletName.KEPLR]: new KeplrController(WC_PROJECT_ID),
[WalletName.LEAP]: new LeapController(WC_PROJECT_ID),
[WalletName.COSMOSTATION]: new CosmostationController(WC_PROJECT_ID),
[WalletName.METAMASK_INJECTIVE]: new MetamaskInjectiveController(),
};

function getRpc(chain: string): string {
Expand Down Expand Up @@ -116,7 +119,9 @@ function getDenom(chain: string): string {

const App: Component = () => {
const [chain, setChain] = createSignal<string>("injective-1");
const [wallet, setWallet] = createSignal<WalletName>(WalletName.KEPLR);
const [wallet, setWallet] = createSignal<WalletName>(
WalletName.METAMASK_INJECTIVE
);
const [wallets, setWallets] = createStore<Record<string, ConnectedWallet>>(
{}
);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cosmes",
"version": "0.0.46",
"version": "0.0.47",
"private": false,
"packageManager": "pnpm@8.3.0",
"sideEffects": false,
Expand Down Expand Up @@ -45,6 +45,7 @@
"@bufbuild/protoc-gen-es": "^1.2.0",
"@bufbuild/protoplugin": "^1.2.0",
"@keplr-wallet/types": "^0.11.62",
"@metamask/providers": "^14.0.2",
"@noble/hashes": "^1.3.2",
"@noble/secp256k1": "^2.0.0",
"@scure/base": "^1.1.3",
Expand Down
Loading

0 comments on commit 86dd77f

Please sign in to comment.