Skip to content

Commit

Permalink
feat(sdk-coin-islm): add Islamic Coin
Browse files Browse the repository at this point in the history
Ticket: WIN-490
  • Loading branch information
hitansh-madan committed Oct 11, 2023
1 parent e257093 commit 456cb30
Show file tree
Hide file tree
Showing 42 changed files with 2,445 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-eth2 /var/modules/sdk-coin-eth2/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-hash /var/modules/sdk-coin-hash/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-hbar /var/modules/sdk-coin-hbar/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-injective /var/modules/sdk-coin-injective/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-islm /var/modules/sdk-coin-islm/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-near /var/modules/sdk-coin-near/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-osmo /var/modules/sdk-coin-osmo/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-polygon /var/modules/sdk-coin-polygon/
Expand Down Expand Up @@ -131,6 +132,7 @@ cd /var/modules/sdk-coin-eth2 && yarn link && \
cd /var/modules/sdk-coin-hash && yarn link && \
cd /var/modules/sdk-coin-hbar && yarn link && \
cd /var/modules/sdk-coin-injective && yarn link && \
cd /var/modules/sdk-coin-islm && yarn link && \
cd /var/modules/sdk-coin-near && yarn link && \
cd /var/modules/sdk-coin-osmo && yarn link && \
cd /var/modules/sdk-coin-polygon && yarn link && \
Expand Down Expand Up @@ -195,6 +197,7 @@ RUN cd /var/bitgo-express && \
yarn link @bitgo/sdk-coin-hash && \
yarn link @bitgo/sdk-coin-hbar && \
yarn link @bitgo/sdk-coin-injective && \
yarn link @bitgo/sdk-coin-islm && \
yarn link @bitgo/sdk-coin-near && \
yarn link @bitgo/sdk-coin-osmo && \
yarn link @bitgo/sdk-coin-polygon && \
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 @@ -43,6 +43,7 @@
"@bitgo/sdk-coin-hash": "^1.4.11",
"@bitgo/sdk-coin-hbar": "^1.5.11",
"@bitgo/sdk-coin-injective": "^1.4.11",
"@bitgo/sdk-coin-islm": "^1.0.0",
"@bitgo/sdk-coin-near": "^1.6.11",
"@bitgo/sdk-coin-osmo": "^1.6.11",
"@bitgo/sdk-coin-polygon": "^1.8.0",
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 @@ -86,6 +86,9 @@ export { Sei };
import * as Injective from '@bitgo/sdk-coin-injective';
export { Injective };

import * as Islm from '@bitgo/sdk-coin-islm';
export { Islm };

import * as Zeta from '@bitgo/sdk-coin-zeta';
export { Zeta };

Expand Down Expand Up @@ -163,6 +166,8 @@ const coinBuilderMap = {
tinjective: Injective.TransactionBuilderFactory,
zeta: Zeta.TransactionBuilderFactory,
tzeta: Zeta.TransactionBuilderFactory,
islm: Islm.TransactionBuilderFactory,
tislm: Islm.TransactionBuilderFactory,
core: Core.TransactionBuilderFactory,
tcore: Core.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 @@ -55,6 +55,9 @@
{
"path": "../sdk-coin-injective"
},
{
"path": "../sdk-coin-islm"
},
{
"path": "../sdk-coin-near"
},
Expand Down
3 changes: 2 additions & 1 deletion modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@bitgo/sdk-coin-btc": "^1.7.11",
"@bitgo/sdk-coin-btg": "^1.5.11",
"@bitgo/sdk-coin-celo": "^1.5.11",
"@bitgo/sdk-coin-core": "^1.0.0",
"@bitgo/sdk-coin-cspr": "^1.5.0",
"@bitgo/sdk-coin-dash": "^1.5.11",
"@bitgo/sdk-coin-doge": "^1.12.11",
Expand All @@ -73,7 +74,7 @@
"@bitgo/sdk-coin-hash": "^1.4.11",
"@bitgo/sdk-coin-hbar": "^1.5.11",
"@bitgo/sdk-coin-injective": "^1.4.11",
"@bitgo/sdk-coin-core": "^1.0.0",
"@bitgo/sdk-coin-islm": "^1.0.0",
"@bitgo/sdk-coin-ltc": "^2.2.11",
"@bitgo/sdk-coin-near": "^1.6.11",
"@bitgo/sdk-coin-osmo": "^1.6.11",
Expand Down
6 changes: 5 additions & 1 deletion modules/bitgo/src/v2/coinFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
Hash,
Hbar,
Injective,
Islm,
Ltc,
Ofc,
OfcToken,
Expand All @@ -70,6 +71,7 @@ import {
Tbsv,
Tbtc,
Tcelo,
Tcore,
Tcspr,
Tdash,
Tdoge,
Expand All @@ -85,7 +87,7 @@ import {
Thbar,
Tia,
Tinjective,
Tcore,
Tislm,
Tltc,
Tosmo,
Tpolygon,
Expand Down Expand Up @@ -143,6 +145,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('hbar', Hbar.createInstance);
globalCoinFactory.register('ltc', Ltc.createInstance);
globalCoinFactory.register('injective', Injective.createInstance);
globalCoinFactory.register('islm', Islm.createInstance);
globalCoinFactory.register('near', Near.createInstance);
globalCoinFactory.register('ofc', Ofc.createInstance);
globalCoinFactory.register('osmo', Osmo.createInstance);
Expand Down Expand Up @@ -182,6 +185,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('thash', Thash.createInstance);
globalCoinFactory.register('thbar', Thbar.createInstance);
globalCoinFactory.register('tinjective', Tinjective.createInstance);
globalCoinFactory.register('tislm', Tislm.createInstance);
globalCoinFactory.register('tltc', Tltc.createInstance);
globalCoinFactory.register('tnear', TNear.createInstance);
globalCoinFactory.register('tosmo', Tosmo.createInstance);
Expand Down
2 changes: 2 additions & 0 deletions modules/bitgo/src/v2/coins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ 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 { Islm, Tislm } from '@bitgo/sdk-coin-islm';
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';
Expand Down Expand Up @@ -78,6 +79,7 @@ export { Ton, Tton };
export { Bld, Tbld };
export { Sei, Tsei };
export { Injective, Tinjective };
export { Islm, Tislm };
export { Trx, Ttrx };
export { StellarToken, Txlm, Xlm };
export { Txrp, Xrp };
Expand Down
3 changes: 3 additions & 0 deletions modules/bitgo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
{
"path": "../sdk-coin-injective"
},
{
"path": "../sdk-coin-islm"
},
{
"path": "../sdk-coin-ltc"
},
Expand Down
5 changes: 5 additions & 0 deletions modules/sdk-coin-islm/.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-islm/.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-islm/.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-islm/.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-islm/.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-islm/.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-islm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BitGo sdk-coin-islm

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-islm`.

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

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 { Islm } from '@bitgo/sdk-coin-islm';

const sdk = new BitGoAPI();

sdk.register('islm', Islm.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.
60 changes: 60 additions & 0 deletions modules/sdk-coin-islm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "@bitgo/sdk-coin-islm",
"version": "1.0.0",
"description": "BitGo SDK coin library for Islm",
"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": ">=16 <19"
},
"repository": {
"type": "git",
"url": "https://github.com/BitGo/BitGoJS.git",
"directory": "modules/sdk-coin-islm"
},
"lint-staged": {
"*.{js,ts}": [
"yarn prettier --write",
"yarn eslint --fix"
]
},
"publishConfig": {
"access": "public"
},
"nyc": {
"extension": [
".ts"
]
},
"dependencies": {
"@bitgo/abstract-cosmos": "^1.6.11",
"@bitgo/sdk-core": "^8.24.0",
"@bitgo/statics": "^27.0.0",
"@cosmjs/amino": "^0.29.5",
"@cosmjs/encoding": "^0.29.5",
"@cosmjs/proto-signing": "^0.29.5",
"@cosmjs/stargate": "^0.29.5",
"bignumber.js": "^9.1.1",
"cosmjs-types": "^0.6.1",
"ethers": "^5.7.2",
"keccak": "3.0.3",
"protobufjs": "^7.2.4"
},
"devDependencies": {
"@bitgo/sdk-api": "^1.22.0",
"@bitgo/sdk-test": "^1.2.41"
}
}
15 changes: 15 additions & 0 deletions modules/sdk-coin-islm/resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Resources

This directory contains external logic required to handle signing/validation/address derivation for
a specific coin.

Typically, this manifests as a smaller snippet of code from a larger codebase, of which, this
library only requires a small portion of.

---

## ISLM Resources

Haqq Network (Islamic Coin) doesn't utilize the cosmos default `secp256k1` PubKey type & utilizes as different PubKey type `ethSecp256k1` exposed by ethermint. The protobuf files for `ethSecp256k1` are defined here : https://github.com/evmos/ethermint/blob/main/proto/ethermint/crypto/v1/ethsecp256k1/keys.proto

This directory contains the generated TypeScript types required, and also contains the `.proto` files used to generate them.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";
package ethermint.crypto.v1.ethsecp256k1;

import "gogoproto/gogo.proto";

option go_package = "github.com/evmos/ethermint/crypto/ethsecp256k1";

// PubKey defines a type alias for an ecdsa.PublicKey that implements
// Tendermint's PubKey interface. It represents the 33-byte compressed public
// key format.
message PubKey {
option (gogoproto.goproto_stringer) = false;

// key is the public key in byte form
bytes key = 1;
}

// PrivKey defines a type alias for an ecdsa.PrivateKey that implements
// Tendermint's PrivateKey interface.
message PrivKey {
// key is the private key in byte form
bytes key = 1;
}
Loading

0 comments on commit 456cb30

Please sign in to comment.