Skip to content

Commit

Permalink
chore(sdk-coin-tao): add sdk skeleton
Browse files Browse the repository at this point in the history
TICKET: WIN-4293
  • Loading branch information
nvrakesh06 committed Jan 10, 2025
1 parent c5cfd9b commit d618991
Show file tree
Hide file tree
Showing 33 changed files with 520 additions and 2 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
/modules/sdk-coin-sol/ @BitGo/ethalt-team
/modules/sdk-coin-stx/ @BitGo/ethalt-team
/modules/sdk-coin-sui/ @BitGo/ethalt-team
/modules/sdk-coin-tao/ @BitGo/ethalt-team
/modules/sdk-coin-ton/ @BitGo/ethalt-team
/modules/sdk-coin-trx/ @BitGo/ethalt-team
/modules/sdk-coin-xlm/ @BitGo/ethalt-team
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-sei /var/modules/sdk-coin-sei/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-sol /var/modules/sdk-coin-sol/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-stx /var/modules/sdk-coin-stx/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-sui /var/modules/sdk-coin-sui/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-tao /var/modules/sdk-coin-tao/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-tia /var/modules/sdk-coin-tia/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-ton /var/modules/sdk-coin-ton/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-trx /var/modules/sdk-coin-trx/
Expand Down Expand Up @@ -166,6 +167,7 @@ cd /var/modules/sdk-coin-sei && yarn link && \
cd /var/modules/sdk-coin-sol && yarn link && \
cd /var/modules/sdk-coin-stx && yarn link && \
cd /var/modules/sdk-coin-sui && yarn link && \
cd /var/modules/sdk-coin-tao && yarn link && \
cd /var/modules/sdk-coin-tia && yarn link && \
cd /var/modules/sdk-coin-ton && yarn link && \
cd /var/modules/sdk-coin-trx && yarn link && \
Expand Down Expand Up @@ -245,6 +247,7 @@ RUN cd /var/bitgo-express && \
yarn link @bitgo/sdk-coin-sol && \
yarn link @bitgo/sdk-coin-stx && \
yarn link @bitgo/sdk-coin-sui && \
yarn link @bitgo/sdk-coin-tao && \
yarn link @bitgo/sdk-coin-tia && \
yarn link @bitgo/sdk-coin-ton && \
yarn link @bitgo/sdk-coin-trx && \
Expand Down
4 changes: 2 additions & 2 deletions modules/abstract-substrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
"dependencies": {
"@bitgo/sdk-core": "^28.18.0",
"@bitgo/statics": "^50.17.0"
"@bitgo/sdk-core": "^28.19.0",
"@bitgo/statics": "^50.18.0"
}
}
1 change: 1 addition & 0 deletions modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"@bitgo/sdk-coin-sol": "^4.7.15",
"@bitgo/sdk-coin-stx": "^3.3.15",
"@bitgo/sdk-coin-sui": "^5.8.17",
"@bitgo/sdk-coin-tao": "^1.0.0",
"@bitgo/sdk-coin-tia": "^3.0.27",
"@bitgo/sdk-coin-ton": "^3.4.15",
"@bitgo/sdk-coin-trx": "^2.0.58",
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 @@ -74,6 +74,7 @@ import {
Sui,
SuiToken,
Susd,
Tao,
Ton,
Tada,
Talgo,
Expand Down Expand Up @@ -124,6 +125,7 @@ import {
Tstx,
Tsui,
Tsusd,
Ttao,
Ttia,
Tton,
Ttrx,
Expand Down Expand Up @@ -197,6 +199,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('stx', Stx.createInstance);
globalCoinFactory.register('sui', Sui.createInstance);
globalCoinFactory.register('susd', Susd.createInstance);
globalCoinFactory.register('tao', Tao.createInstance);
globalCoinFactory.register('tia', Tia.createInstance);
globalCoinFactory.register('ton', Ton.createInstance);
globalCoinFactory.register('talgo', Talgo.createInstance);
Expand Down Expand Up @@ -249,6 +252,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('tstx', Tstx.createInstance);
globalCoinFactory.register('tsui', Tsui.createInstance);
globalCoinFactory.register('tsusd', Tsusd.createInstance);
globalCoinFactory.register('ttao', Ttao.createInstance);
globalCoinFactory.register('ttia', Ttia.createInstance);
globalCoinFactory.register('tton', Tton.createInstance);
globalCoinFactory.register('ttrx', Ttrx.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 @@ -44,6 +44,7 @@ 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, SuiToken } from '@bitgo/sdk-coin-sui';
import { Tao, Ttao } from '@bitgo/sdk-coin-tao';
import { Tia, Ttia } from '@bitgo/sdk-coin-tia';
import { Ton, Tton } from '@bitgo/sdk-coin-ton';
import { Trx, Ttrx } from '@bitgo/sdk-coin-trx';
Expand Down Expand Up @@ -96,6 +97,7 @@ export { Rune, Trune };
export { Sol, Tsol };
export { Stx, Tstx };
export { Sui, Tsui, SuiToken };
export { Tao, Ttao };
export { Tia, Ttia };
export { Ton, Tton };
export { Bld, Tbld };
Expand Down
2 changes: 2 additions & 0 deletions modules/bitgo/test/browser/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe('Coins', () => {
XrpToken: 1,
Rune: 1,
Trune: 1,
Tao: 1,
Ttao: 1,
};
Object.keys(BitGoJS.Coin)
.filter((coinName) => !excludedKeys[coinName])
Expand Down
3 changes: 3 additions & 0 deletions modules/bitgo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
{
"path": "../sdk-coin-sui"
},
{
"path": "../sdk-coin-tao"
},
{
"path": "../sdk-coin-tia"
},
Expand Down
4 changes: 4 additions & 0 deletions modules/sdk-coin-tao/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.idea
public
dist
3 changes: 3 additions & 0 deletions modules/sdk-coin-tao/.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-tao/.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-tao/.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-tao/.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-tao/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
printWidth: 120
singleQuote: true
trailingComma: 'es5'
Empty file.
30 changes: 30 additions & 0 deletions modules/sdk-coin-tao/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BitGo sdk-coin-tao

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

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

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

const sdk = new BitGoAPI();

sdk.register('apt', Apt.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.
52 changes: 52 additions & 0 deletions modules/sdk-coin-tao/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@bitgo/sdk-coin-tao",
"version": "1.0.0",
"description": "BitGo SDK coin library for TAO (Bittensor) coin",
"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 <21"
},
"repository": {
"type": "git",
"url": "https://github.com/BitGo/BitGoJS.git",
"directory": "modules/sdk-coin-tao"
},
"lint-staged": {
"*.{js,ts}": [
"yarn prettier --write",
"yarn eslint --fix"
]
},
"publishConfig": {
"access": "public"
},
"nyc": {
"extension": [
".ts"
]
},
"dependencies": {
"@bitgo/abstract-substrate": "^1.0.0",
"@bitgo/sdk-core": "^28.19.0",
"@bitgo/statics": "^50.18.0",
"bignumber.js": "^9.1.2"
},
"devDependencies": {
"@bitgo/sdk-api": "^1.58.0",
"@bitgo/sdk-test": "^8.0.63"
}
}
4 changes: 4 additions & 0 deletions modules/sdk-coin-tao/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './lib';
export * from './register';
export * from './tao';
export * from './ttao';
6 changes: 6 additions & 0 deletions modules/sdk-coin-tao/src/lib/iface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* The transaction data returned from the toJson() function of a transaction
*/
export interface TxData {
id: string;
}
9 changes: 9 additions & 0 deletions modules/sdk-coin-tao/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as Utils from './utils';
import * as Interface from './iface';

export { KeyPair } from './keyPair';
export { Transaction } from './transaction';
export { TransactionBuilder } from './transactionBuilder';
export { TransferBuilder } from './transferBuilder';
export { TransactionBuilderFactory } from './transactionBuilderFactory';
export { Interface, Utils };
23 changes: 23 additions & 0 deletions modules/sdk-coin-tao/src/lib/keyPair.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { DefaultKeys, Ed25519KeyPair } from '@bitgo/sdk-core';

export class KeyPair extends Ed25519KeyPair {
/** @inheritdoc */
getKeys(): DefaultKeys {
throw new Error('Method not implemented.');
}

/** @inheritdoc */
recordKeysFromPrivateKeyInProtocolFormat(prv: string): DefaultKeys {
throw new Error('Method not implemented.');
}

/** @inheritdoc */
recordKeysFromPublicKeyInProtocolFormat(pub: string): DefaultKeys {
throw new Error('Method not implemented.');
}

/** @inheritdoc */
getAddress(): string {
throw new Error('Method not implemented.');
}
}
16 changes: 16 additions & 0 deletions modules/sdk-coin-tao/src/lib/transaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BaseKey, BaseTransaction } from '@bitgo/sdk-core';
import { TxData } from './iface';

export class Transaction extends BaseTransaction {
canSign(key: BaseKey): boolean {
return false;
}

toBroadcastFormat(): string {
throw new Error('Method not implemented.');
}

toJson(): TxData {
throw new Error('Method not implemented.');
}
}
Loading

0 comments on commit d618991

Please sign in to comment.