Skip to content

Commit ae706a0

Browse files
committed
feat(sdk-coin-coredao): add coredao sdk skeleton
Ticket: WIN-3696
1 parent c5a1da8 commit ae706a0

File tree

24 files changed

+512
-0
lines changed

24 files changed

+512
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.idea
3+
public
4+
dist
5+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.idea/
3+
dist/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require: 'ts-node/register'
2+
timeout: '120000'
3+
reporter: 'min'
4+
reporter-option:
5+
- 'cdn=true'
6+
- 'json=false'
7+
exit: true
8+
spec: ['test/unit/**/*.ts']
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!dist/
2+
dist/test/
3+
dist/tsconfig.tsbuildinfo
4+
.idea/
5+
.prettierrc.yml
6+
tsconfig.json
7+
src/
8+
test/
9+
scripts/
10+
.nyc_output
11+
CODEOWNERS
12+
node_modules/
13+
.prettierignore
14+
.mocharc.js
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.nyc_output/
2+
dist/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
printWidth: 120
2+
singleQuote: true
3+
trailingComma: 'es5'

modules/sdk-coin-coredao/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# BitGo sdk-coin-coredao
2+
3+
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.
4+
5+
## Installation
6+
7+
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.
8+
9+
In your project install both `@bitgo/sdk-api` and `@bitgo/sdk-coin-coredao`.
10+
11+
```shell
12+
npm i @bitgo/sdk-api @bitgo/sdk-coin-coredao
13+
```
14+
15+
Next, you will be able to initialize an instance of "bitgo" through `@bitgo/sdk-api` instead of `bitgo`.
16+
17+
```javascript
18+
import { BitGoAPI } from '@bitgo/sdk-api';
19+
import { Coredao } from '@bitgo/sdk-coin-coredao';
20+
21+
const sdk = new BitGoAPI();
22+
23+
sdk.register('coredao', Coredao.createInstance);
24+
```
25+
26+
## Development
27+
28+
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.
29+
30+
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.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "@bitgo/sdk-coin-coredao",
3+
"version": "1.0.0",
4+
"description": "BitGo SDK coin library for Coredao",
5+
"main": "./dist/src/index.js",
6+
"types": "./dist/src/index.d.ts",
7+
"scripts": {
8+
"build": "yarn tsc --build --incremental --verbose .",
9+
"fmt": "prettier --write .",
10+
"check-fmt": "prettier --check .",
11+
"clean": "rm -r ./dist",
12+
"lint": "eslint --quiet .",
13+
"prepare": "npm run build",
14+
"test": "npm run coverage",
15+
"coverage": "nyc -- npm run unit-test",
16+
"unit-test": "mocha"
17+
},
18+
"author": "BitGo SDK Team <[email protected]>",
19+
"license": "MIT",
20+
"engines": {
21+
"node": ">=18 <21"
22+
},
23+
"repository": {
24+
"type": "git",
25+
"url": "https://github.com/BitGo/BitGoJS.git",
26+
"directory": "modules/sdk-coin-coredao"
27+
},
28+
"lint-staged": {
29+
"*.{js,ts}": [
30+
"yarn prettier --write",
31+
"yarn eslint --fix"
32+
]
33+
},
34+
"publishConfig": {
35+
"access": "public"
36+
},
37+
"nyc": {
38+
"extension": [
39+
".ts"
40+
]
41+
},
42+
"dependencies": {
43+
"@bitgo/abstract-eth": "^22.3.1",
44+
"@bitgo/sdk-core": "^28.13.1",
45+
"@bitgo/statics": "^50.6.0",
46+
"@ethereumjs/common": "^2.6.5"
47+
},
48+
"devDependencies": {
49+
"@bitgo/sdk-api": "^1.56.3",
50+
"@bitgo/sdk-test": "^8.0.50"
51+
}
52+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { BaseCoin, BitGoBase, common, MPCAlgorithm } from '@bitgo/sdk-core';
2+
import { BaseCoin as StaticsBaseCoin, coins } from '@bitgo/statics';
3+
import { AbstractEthLikeNewCoins, recoveryBlockchainExplorerQuery } from '@bitgo/abstract-eth';
4+
import { TransactionBuilder } from './lib';
5+
6+
export class Coredao extends AbstractEthLikeNewCoins {
7+
protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>) {
8+
super(bitgo, staticsCoin);
9+
}
10+
11+
static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
12+
return new Coredao(bitgo, staticsCoin);
13+
}
14+
15+
protected getTransactionBuilder(): TransactionBuilder {
16+
return new TransactionBuilder(coins.get(this.getBaseChain()));
17+
}
18+
19+
/** @inheritDoc */
20+
allowsAccountConsolidations(): boolean {
21+
return true;
22+
}
23+
24+
/** @inheritDoc */
25+
supportsTss(): boolean {
26+
return true;
27+
}
28+
29+
/** @inheritDoc */
30+
getMPCAlgorithm(): MPCAlgorithm {
31+
return 'ecdsa';
32+
}
33+
34+
async recoveryBlockchainExplorerQuery(query: Record<string, string>): Promise<Record<string, unknown>> {
35+
const apiToken = common.Environments[this.bitgo.getEnv()].coredaoExplorerApiToken;
36+
const explorerUrl = common.Environments[this.bitgo.getEnv()].coredaoExplorerBaseUrl;
37+
return await recoveryBlockchainExplorerQuery(query, explorerUrl as string, apiToken);
38+
}
39+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './lib';
2+
export * from './coredao';
3+
export * from './tcoredao';
4+
export * from './register';

0 commit comments

Comments
 (0)