Skip to content

Commit

Permalink
chore: abstract cosmostation wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Oct 18, 2024
1 parent 673b3bf commit 3605f8e
Show file tree
Hide file tree
Showing 14 changed files with 8,195 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/wallets/wallet-cosmos/src/strategy/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
import type { DirectSignResponse } from '@cosmjs/proto-signing'
import { CosmosWallet } from './../wallet'

const cosmosWallets = [Wallet.Leap, Wallet.Ninji, Wallet.Keplr]

export class CosmosWalletStrategy
extends BaseConcreteStrategy
implements ConcreteWalletStrategy
Expand All @@ -46,6 +48,12 @@ export class CosmosWalletStrategy
) {
super(args)

if (!cosmosWallets.includes(args.wallet)) {
throw new CosmosWalletException(
new Error(`Cosmos Wallet for ${args.wallet} is not supported.`),
)
}

this.wallet = args.wallet
this.chainId = args.chainId || CosmosChainId.Injective
this.cosmosWallet = new CosmosWallet(args.chainId, args.wallet)
Expand Down
60 changes: 60 additions & 0 deletions packages/wallets/wallet-cosmostation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 🌟 Injective Protocol - Magic Wallet Strategy

<!-- TODO -->

[![downloads](https://img.shields.io/npm/dm/@injectivelabs/wallet-ts.svg)](https://www.npmjs.com/package/@injectivelabs/wallet-ts)
[![npm-version](https://img.shields.io/npm/v/@injectivelabs/wallet-ts.svg)](https://www.npmjs.com/package/@injectivelabs/wallet-ts)
[![license](https://img.shields.io/npm/l/express.svg)]()

_Package to use Magic Wallets on Injective via the wallet strategy._

---

## 📚 Installation

```bash
yarn add @injectivelabs/wallet-magic
```

---

## 📖 Documentation

<!-- TODO -->

Read more and find example usages on our [WalletStrategy Docs](https://docs.ts.injective.network/wallet/wallet-wallet-strategy)

---

## 📜 Contribution

**Contribution guides and practices will be available once there is a stable foundation of the whole package set within the `injective-ts` repo.**

---

## ⛑ Support

Reach out to us at one of the following places!

- Website at <a href="https://injective.com" target="_blank">`injective.com`</a>
- Twitter at <a href="https://twitter.com/Injective_" target="_blank">`@Injective`</a>
- Discord at <a href="https://discord.com/invite/NK4qdbv" target="_blank">`Discord`</a>
- Telegram at <a href="https://t.me/joininjective" target="_blank">`Telegram`</a>

---

## 🔓 License

Copyright © 2021 - 2022 Injective Labs Inc. (https://injectivelabs.org/)

<a href="https://iili.io/mNneZN.md.png"><img src="https://iili.io/mNneZN.md.png" style="width: 300px; max-width: 100%; height: auto" />

Originally released by Injective Labs Inc. under: <br />
Apache License <br />
Version 2.0, January 2004 <br />
http://www.apache.org/licenses/

<p>&nbsp;</p>
<div align="center">
<sub><em>Powering the future of decentralized finance.</em></sub>
</div>
56 changes: 56 additions & 0 deletions packages/wallets/wallet-cosmostation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@injectivelabs/wallet-cosmostation",
"description": "Cosmostation strategy for use with @injectivelabs/wallet-core.",
"version": "0.0.1",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
"email": "[email protected]"
},
"license": "Apache-2.0",
"types": "dist/cjs/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"files": [
"dist"
],
"_moduleAliases": {
"~wallet-cosmostation": "dist"
},
"scripts": {
"postinstall": "link-module-alias",
"build:cjs": "BUILD_MODE=cjs tsc --build tsconfig.build.json",
"build:esm": "BUILD_MODE=esm tsc --build tsconfig.build.esm.json",
"build": "yarn build:esm && yarn build:cjs && yarn build:post && link-module-alias",
"build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && yarn build:post && link-module-alias",
"build:post": "shx cp ../../../etc/stub/package.json.stub dist/cjs/package.json && shx cp ../../../etc/stub/package.esm.json.stub dist/esm/package.json",
"clean": "tsc --build tsconfig.build.json --clean && tsc --build tsconfig.build.esm.json --clean && shx rm -rf coverage *.log junit.xml dist && jest --clearCache && shx mkdir -p dist",
"test": "jest",
"test:watch": "jest --watch",
"test:ci": "jest --coverage --ci --reporters='jest-junit'",
"coverage": "jest --coverage",
"coverage:show": "live-server coverage",
"dev": "ts-node -r tsconfig-paths/register src/index.ts",
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.14.14",
"@injectivelabs/sdk-ts": "^1.14.15-beta.9",
"@injectivelabs/ts-types": "^1.14.14",
"@injectivelabs/utils": "^1.14.14",
"@injectivelabs/wallet-base": "^0.0.1",
"@cosmjs/proto-signing": "^0.32.3",
"@walletconnect/ethereum-provider": "^2.12.2",
"@cosmostation/extension-client": "^0.1.15"
},
"gitHead": "35bd09035587be3fd170cc48b5c13f231e699a79",
"typedoc": {
"entryPoint": "./src/index.ts",
"readmeFile": "./README.md",
"displayName": "wallet-cosmostation API Documentation"
},
"resolutions": {
"**/libsodium": "npm:@bangjelkoski/noop",
"**/libsodium-wrappers": "npm:@bangjelkoski/noop"
}
}
1 change: 1 addition & 0 deletions packages/wallets/wallet-cosmostation/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Cosmostation as CosmostationWalletStrategy } from './strategy/strategy'
Loading

0 comments on commit 3605f8e

Please sign in to comment.