Skip to content

Commit

Permalink
Merge pull request #3686 from BitGo/BG-79064-injective-sdk-impl
Browse files Browse the repository at this point in the history
feat(sdk-coin-injective): injective sdk init along with testcases
  • Loading branch information
DinshawKothari authored Jun 23, 2023
2 parents c2a341a + 3cc02d4 commit e91d564
Show file tree
Hide file tree
Showing 42 changed files with 2,047 additions and 63 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-eos /var/modules/sdk-coin-eos/
RUN cd /var/modules/sdk-coin-eos && yarn link
COPY --from=builder /tmp/bitgo/modules/sdk-coin-ethw /var/modules/sdk-coin-ethw/
RUN cd /var/modules/sdk-coin-ethw && yarn link
COPY --from=builder /tmp/bitgo/modules/sdk-coin-injective /var/modules/sdk-coin-injective/
RUN cd /var/modules/sdk-coin-injective && yarn link
COPY --from=builder /tmp/bitgo/modules/sdk-coin-ltc /var/modules/sdk-coin-ltc/
RUN cd /var/modules/sdk-coin-ltc && yarn link
COPY --from=builder /tmp/bitgo/modules/sdk-coin-xlm /var/modules/sdk-coin-xlm/
Expand Down Expand Up @@ -206,16 +208,17 @@ RUN cd /var/bitgo-express && \
yarn link @bitgo/sdk-coin-doge && \
yarn link @bitgo/sdk-coin-eos && \
yarn link @bitgo/sdk-coin-ethw && \
yarn link @bitgo/sdk-coin-injective && \
yarn link @bitgo/sdk-coin-ltc && \
yarn link @bitgo/sdk-coin-xlm && \
yarn link @bitgo/sdk-coin-xrp && \
yarn link @bitgo/sdk-coin-zec
#LINK_END

#LABEL_START
LABEL created="Wed, 21 Jun 2023 04:11:17 GMT"
LABEL created="Thu, 22 Jun 2023 18:10:16 GMT"
LABEL version=9.29.0
LABEL git_hash=fced576cf32a20224ba25abd31efdfd4e8e04f94
LABEL git_hash=e8bf1cceea1bff0ee05a38b6f8bbe04c4c4b5588
#LABEL_END

USER node
Expand Down
1 change: 1 addition & 0 deletions modules/account-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@bitgo/sdk-coin-eth2": "^1.2.27",
"@bitgo/sdk-coin-hash": "^1.1.0",
"@bitgo/sdk-coin-hbar": "^1.3.27",
"@bitgo/sdk-coin-injective": "^1.1.2",
"@bitgo/sdk-coin-near": "^1.4.5",
"@bitgo/sdk-coin-osmo": "^1.3.2",
"@bitgo/sdk-coin-polygon": "^1.5.11",
Expand Down
5 changes: 5 additions & 0 deletions modules/account-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export { Hash };
import * as Sei from '@bitgo/sdk-coin-sei';
export { Sei };

import * as Injective from '@bitgo/sdk-coin-injective';
export { Injective };

import * as Sol from '@bitgo/sdk-coin-sol';
export { Sol };

Expand Down Expand Up @@ -150,6 +153,8 @@ const coinBuilderMap = {
thash: Hash.TransactionBuilderFactory,
sei: Sei.TransactionBuilderFactory,
tsei: Sei.TransactionBuilderFactory,
injective: Injective.TransactionBuilderFactory,
tinjective: Injective.TransactionBuilderFactory,
};

/**
Expand Down
3 changes: 3 additions & 0 deletions modules/account-lib/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
{
"path": "../sdk-coin-hbar"
},
{
"path": "../sdk-coin-injective"
},
{
"path": "../sdk-coin-near"
},
Expand Down
1 change: 1 addition & 0 deletions modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@bitgo/sdk-coin-ethw": "^1.3.27",
"@bitgo/sdk-coin-hash": "^1.1.0",
"@bitgo/sdk-coin-hbar": "^1.3.27",
"@bitgo/sdk-coin-injective": "^1.1.2",
"@bitgo/sdk-coin-ltc": "^2.0.22",
"@bitgo/sdk-coin-near": "^1.4.5",
"@bitgo/sdk-coin-osmo": "^1.3.2",
Expand Down
4 changes: 4 additions & 0 deletions modules/bitgo/src/v2/coinFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
Gteth,
Hash,
Hbar,
Injective,
Ltc,
Ofc,
OfcToken,
Expand Down Expand Up @@ -81,6 +82,7 @@ import {
Thash,
Thbar,
Tia,
Tinjective,
Tltc,
Tosmo,
Tpolygon,
Expand Down Expand Up @@ -133,6 +135,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('hash', Hash.createInstance);
globalCoinFactory.register('hbar', Hbar.createInstance);
globalCoinFactory.register('ltc', Ltc.createInstance);
globalCoinFactory.register('injective', Injective.createInstance);
globalCoinFactory.register('near', Near.createInstance);
globalCoinFactory.register('ofc', Ofc.createInstance);
globalCoinFactory.register('osmo', Osmo.createInstance);
Expand Down Expand Up @@ -169,6 +172,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('tfiatusd', TfiatUsd.createInstance);
globalCoinFactory.register('thash', Thash.createInstance);
globalCoinFactory.register('thbar', Thbar.createInstance);
globalCoinFactory.register('tinjective', Tinjective.createInstance);
globalCoinFactory.register('tltc', Tltc.createInstance);
globalCoinFactory.register('tnear', TNear.createInstance);
globalCoinFactory.register('tosmo', Tosmo.createInstance);
Expand Down
95 changes: 49 additions & 46 deletions modules/bitgo/src/v2/coins/index.ts
Original file line number Diff line number Diff line change
@@ -1,82 +1,85 @@
import { AbstractUtxoCoin } from '@bitgo/abstract-utxo';
export { AbstractUtxoCoin };
import { Ada, Tada } from '@bitgo/sdk-coin-ada';
import { Algo, AlgoToken, Talgo } from '@bitgo/sdk-coin-algo';
import { Atom, Tatom } from '@bitgo/sdk-coin-atom';
import { AvaxC, AvaxCToken, TavaxC } from '@bitgo/sdk-coin-avaxc';
import { AvaxP, TavaxP } from '@bitgo/sdk-coin-avaxp';
import { Bch, Tbch } from '@bitgo/sdk-coin-bch';
import { Bcha, Tbcha } from '@bitgo/sdk-coin-bcha';
import { Bld, Tbld } from '@bitgo/sdk-coin-bld';
import { Bsc, BscToken, Tbsc } from '@bitgo/sdk-coin-bsc';
import { Bsv, Tbsv } from '@bitgo/sdk-coin-bsv';
import { Btc, Tbtc } from '@bitgo/sdk-coin-btc';
import { Btg } from '@bitgo/sdk-coin-btg';
import { Celo, CeloToken, Tcelo } from '@bitgo/sdk-coin-celo';
import { Cspr, Tcspr } from '@bitgo/sdk-coin-cspr';
import { Dash, Tdash } from '@bitgo/sdk-coin-dash';
import { Doge, Tdoge } from '@bitgo/sdk-coin-doge';
import { Dot, Tdot } from '@bitgo/sdk-coin-dot';
import { Eos, EosToken, Teos } from '@bitgo/sdk-coin-eos';
import { Etc, Tetc } from '@bitgo/sdk-coin-etc';
import { Erc20Token, Eth, Gteth, Teth } from '@bitgo/sdk-coin-eth';
import { Eth2, Teth2 } from '@bitgo/sdk-coin-eth2';
import { Ethw } from '@bitgo/sdk-coin-ethw';
import { Hash, Thash } from '@bitgo/sdk-coin-hash';
import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar';
import { Injective, Tinjective } from '@bitgo/sdk-coin-injective';
import { Ltc, Tltc } from '@bitgo/sdk-coin-ltc';
import { Osmo, Tosmo } from '@bitgo/sdk-coin-osmo';
import { Polygon, PolygonToken, Tpolygon } from '@bitgo/sdk-coin-polygon';
import { Rbtc, Trbtc } from '@bitgo/sdk-coin-rbtc';
import { Sei, Tsei } from '@bitgo/sdk-coin-sei';
import { Sol, Tsol } from '@bitgo/sdk-coin-sol';
import { Stx, Tstx } from '@bitgo/sdk-coin-stx';
import { Sui, Tsui } from '@bitgo/sdk-coin-sui';
import { Tia, Ttia } from '@bitgo/sdk-coin-tia';
import { Trx, Ttrx } from '@bitgo/sdk-coin-trx';
import { StellarToken, Txlm, Xlm } from '@bitgo/sdk-coin-xlm';
import { Txrp, Xrp } from '@bitgo/sdk-coin-xrp';
import { Txtz, Xtz } from '@bitgo/sdk-coin-xtz';
import { Tzec, Zec } from '@bitgo/sdk-coin-zec';
export { AbstractUtxoCoin };
export { Algo, AlgoToken, Talgo };
import { Ada, Tada } from '@bitgo/sdk-coin-ada';
export { Ada, Tada };
import { Atom, Tatom } from '@bitgo/sdk-coin-atom';
export { Atom, Tatom };
import { AvaxC, TavaxC, AvaxCToken } from '@bitgo/sdk-coin-avaxc';
export { AvaxC, TavaxC, AvaxCToken };
import { AvaxP, TavaxP } from '@bitgo/sdk-coin-avaxp';
export { AvaxC, AvaxCToken, TavaxC };
export { AvaxP, TavaxP };
import { Bch, Tbch } from '@bitgo/sdk-coin-bch';
export { Bch, Tbch };
import { Bsc, Tbsc, BscToken } from '@bitgo/sdk-coin-bsc';
export { Bsc, Tbsc, BscToken };
import { Bsv, Tbsv } from '@bitgo/sdk-coin-bsv';
export { Bsc, BscToken, Tbsc };
export { Bsv, Tbsv };
import { Btc, Tbtc } from '@bitgo/sdk-coin-btc';
export { Btc, Tbtc };
import { Btg } from '@bitgo/sdk-coin-btg';
export { Btg };
import { Celo, CeloToken, Tcelo } from '@bitgo/sdk-coin-celo';
export { Celo, CeloToken, Tcelo };
import { Cspr, Tcspr } from '@bitgo/sdk-coin-cspr';
export { Cspr, Tcspr };
import { Dash, Tdash } from '@bitgo/sdk-coin-dash';
export { Dash, Tdash };
import { Doge, Tdoge } from '@bitgo/sdk-coin-doge';
export { Doge, Tdoge };
import { Dot, Tdot } from '@bitgo/sdk-coin-dot';
export { Dot, Tdot };
import { Bcha, Tbcha } from '@bitgo/sdk-coin-bcha';
export { Bcha, Tbcha };
import { EosToken, Eos, Teos } from '@bitgo/sdk-coin-eos';
export { EosToken, Eos, Teos };
import { Erc20Token, Eth, Gteth, Teth } from '@bitgo/sdk-coin-eth';
export { Eos, EosToken, Teos };
export { Erc20Token, Eth, Gteth, Teth };
import { Eth2, Teth2 } from '@bitgo/sdk-coin-eth2';
export { Eth2, Teth2 };
import { Ethw } from '@bitgo/sdk-coin-ethw';
export { Ethw };
import { Etc, Tetc } from '@bitgo/sdk-coin-etc';
export { Etc, Tetc };
import { Hash, Thash } from '@bitgo/sdk-coin-hash';
export { Hash, Thash };
import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar';
export { Hbar, Thbar };
import { Ltc, Tltc } from '@bitgo/sdk-coin-ltc';
export { Ltc, Tltc };
import { Osmo, Tosmo } from '@bitgo/sdk-coin-osmo';
export { Osmo, Tosmo };
import { Polygon, Tpolygon, PolygonToken } from '@bitgo/sdk-coin-polygon';
export { Polygon, Tpolygon, PolygonToken };
import { Rbtc, Trbtc } from '@bitgo/sdk-coin-rbtc';
export { Polygon, PolygonToken, Tpolygon };
export { Rbtc, Trbtc };
import { Sol, Tsol } from '@bitgo/sdk-coin-sol';
export { Sol, Tsol };
import { Stx, Tstx } from '@bitgo/sdk-coin-stx';
export { Stx, Tstx };
import { Sui, Tsui } from '@bitgo/sdk-coin-sui';
export { Sui, Tsui };
import { Tia, Ttia } from '@bitgo/sdk-coin-tia';
export { Tia, Ttia };
import { Bld, Tbld } from '@bitgo/sdk-coin-bld';
export { Bld, Tbld };
import { Sei, Tsei } from '@bitgo/sdk-coin-sei';
export { Sei, Tsei };
import { Trx, Ttrx } from '@bitgo/sdk-coin-trx';
export { Injective, Tinjective };
export { Trx, Ttrx };
import { StellarToken, Txlm, Xlm } from '@bitgo/sdk-coin-xlm';
export { StellarToken, Txlm, Xlm };
import { Xrp, Txrp } from '@bitgo/sdk-coin-xrp';
export { Xrp, Txrp };
import { Xtz, Txtz } from '@bitgo/sdk-coin-xtz';
export { Xtz, Txtz };
import { Zec, Tzec } from '@bitgo/sdk-coin-zec';
export { Zec, Tzec };
export { Txrp, Xrp };
export { Txtz, Xtz };
export { Tzec, Zec };

import { coins } from '@bitgo/sdk-core';
const { Ofc, OfcToken, Susd, FiatUsd, FiatEur, FiatGBP, Tsusd, TfiatUsd, TfiatEur, TfiatGBP } = coins;
export { Ofc, OfcToken, Susd, FiatUsd, FiatEur, FiatGBP, Tsusd, TfiatUsd, TfiatEur, TfiatGBP };
export { FiatEur, FiatGBP, FiatUsd, Ofc, OfcToken, Susd, TfiatEur, TfiatGBP, TfiatUsd, Tsusd };

3 changes: 3 additions & 0 deletions modules/bitgo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
{
"path": "../sdk-coin-hbar"
},
{
"path": "../sdk-coin-injective"
},
{
"path": "../sdk-coin-ltc"
},
Expand Down
5 changes: 5 additions & 0 deletions modules/sdk-coin-injective/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.idea
public
dist

3 changes: 3 additions & 0 deletions modules/sdk-coin-injective/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.idea/
dist/
8 changes: 8 additions & 0 deletions modules/sdk-coin-injective/.mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require: 'ts-node/register'
timeout: '60000'
reporter: 'min'
reporter-option:
- 'cdn=true'
- 'json=false'
exit: true
spec: ['test/unit/**/*.ts']
14 changes: 14 additions & 0 deletions modules/sdk-coin-injective/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
!dist/
dist/test/
dist/tsconfig.tsbuildinfo
.idea/
.prettierrc.yml
tsconfig.json
src/
test/
scripts/
.nyc_output
CODEOWNERS
node_modules/
.prettierignore
.mocharc.js
2 changes: 2 additions & 0 deletions modules/sdk-coin-injective/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nyc_output/
dist/
3 changes: 3 additions & 0 deletions modules/sdk-coin-injective/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
printWidth: 120
singleQuote: true
trailingComma: 'es5'
30 changes: 30 additions & 0 deletions modules/sdk-coin-injective/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BitGo sdk-coin-injective

SDK coins provide a modular approach to a monolithic architecture. This and all BitGoJS SDK coins allow developers to use only the coins needed for a given project.

## Installation

All coins are loaded traditionally through the `bitgo` package. If you are using coins individually, you will be accessing the coin via the `@bitgo/sdk-api` package.

In your project install both `@bitgo/sdk-api` and `@bitgo/sdk-coin-injective`.

```shell
npm i @bitgo/sdk-api @bitgo/sdk-coin-injective
```

Next, you will be able to initialize an instance of "bitgo" through `@bitgo/sdk-api` instead of `bitgo`.

```javascript
import { BitGoAPI } from '@bitgo/sdk-api';
import { Injective } from '@bitgo/sdk-coin-injective';

const sdk = new BitGoAPI();

sdk.register('injective', Injective.createInstance);
```

## Development

Most of the coin implementations are derived from `@bitgo/sdk-core`, `@bitgo/statics`, and coin specific packages. These implementations are used to interact with the BitGo API and BitGo platform services.

You will notice that the basic version of common class extensions have been provided to you and must be resolved before the package build will succeed. Upon initiation of a given SDK coin, you will need to verify that your coin has been included in the root `tsconfig.packages.json` and that the linting, formatting, and testing succeeds when run both within the coin and from the root of BitGoJS.
56 changes: 56 additions & 0 deletions modules/sdk-coin-injective/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@bitgo/sdk-coin-injective",
"version": "1.1.2",
"description": "BitGo SDK coin library for Injective",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
"build": "yarn tsc --build --incremental --verbose .",
"fmt": "prettier --write .",
"check-fmt": "prettier --check .",
"clean": "rm -r ./dist",
"lint": "eslint --quiet .",
"prepare": "npm run build",
"test": "npm run coverage",
"coverage": "nyc -- npm run unit-test",
"unit-test": "mocha"
},
"author": "BitGo SDK Team <[email protected]>",
"license": "MIT",
"engines": {
"node": ">=14 <17"
},
"repository": {
"type": "git",
"url": "https://github.com/BitGo/BitGoJS.git",
"directory": "modules/sdk-coin-injective"
},
"lint-staged": {
"*.{js,ts}": [
"yarn prettier --write",
"yarn eslint --fix"
]
},
"publishConfig": {
"access": "public"
},
"nyc": {
"extension": [
".ts"
]
},
"dependencies": {
"@bitgo/abstract-cosmos": "^1.3.0",
"@bitgo/sdk-core": "^8.10.0",
"@bitgo/statics": "^17.0.1",
"@cosmjs/amino": "^0.29.5",
"@cosmjs/encoding": "^0.29.5",
"@cosmjs/stargate": "^0.29.5",
"bignumber.js": "^9.1.1"
},
"devDependencies": {
"@bitgo/sdk-api": "^1.11.2",
"@bitgo/sdk-test": "^1.2.27",
"@types/lodash": "^4.14.183"
}
}
4 changes: 4 additions & 0 deletions modules/sdk-coin-injective/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './injective';
export * from './lib';
export * from './register';
export * from './tinjective';
Loading

0 comments on commit e91d564

Please sign in to comment.