Skip to content

Commit efb3ff2

Browse files
committed
feat(sdk-coin-vet): add sdk skeleton for vet
Ticket: COIN-3934
1 parent 1910925 commit efb3ff2

26 files changed

+843
-2
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
/modules/sdk-coin-tao/ @BitGo/ethalt-team
8585
/modules/sdk-coin-ton/ @BitGo/ethalt-team
8686
/modules/sdk-coin-trx/ @BitGo/ethalt-team
87+
/modules/sdk-coin-vet/ @Bitgo/ethalt-team
8788
/modules/sdk-coin-wemix/ @BitGo/ethalt-team
8889
/modules/sdk-coin-world/ @BitGo/ethalt-team
8990
/modules/sdk-coin-xdc/ @BitGo/ethalt-team

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-ltc /var/modules/sdk-coin-ltc/
129129
COPY --from=builder /tmp/bitgo/modules/sdk-coin-polyx /var/modules/sdk-coin-polyx/
130130
COPY --from=builder /tmp/bitgo/modules/sdk-coin-xlm /var/modules/sdk-coin-xlm/
131131
COPY --from=builder /tmp/bitgo/modules/sdk-coin-zec /var/modules/sdk-coin-zec/
132+
COPY --from=builder /tmp/bitgo/modules/sdk-coin-vet /var/modules/sdk-coin-vet/
132133

133134
RUN cd /var/modules/abstract-lightning && yarn link && \
134135
cd /var/modules/sdk-core && yarn link && \
@@ -220,7 +221,8 @@ cd /var/modules/sdk-coin-lnbtc && yarn link && \
220221
cd /var/modules/sdk-coin-ltc && yarn link && \
221222
cd /var/modules/sdk-coin-polyx && yarn link && \
222223
cd /var/modules/sdk-coin-xlm && yarn link && \
223-
cd /var/modules/sdk-coin-zec && yarn link
224+
cd /var/modules/sdk-coin-zec && yarn link && \
225+
cd /var/modules/sdk-coin-vet && yarn link
224226
#COPY_END
225227

226228
#LINK_START
@@ -315,7 +317,8 @@ RUN cd /var/bitgo-express && \
315317
yarn link @bitgo/sdk-coin-ltc && \
316318
yarn link @bitgo/sdk-coin-polyx && \
317319
yarn link @bitgo/sdk-coin-xlm && \
318-
yarn link @bitgo/sdk-coin-zec
320+
yarn link @bitgo/sdk-coin-zec && \
321+
yarn link @bitgo/sdk-coin-vet
319322
#LINK_END
320323

321324
#LABEL_START

modules/bitgo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"@bitgo/sdk-coin-tia": "^3.0.48",
110110
"@bitgo/sdk-coin-ton": "^3.5.2",
111111
"@bitgo/sdk-coin-trx": "^3.0.1",
112+
"@bitgo/sdk-coin-vet": "^1.3.0",
112113
"@bitgo/sdk-coin-wemix": "^1.2.3",
113114
"@bitgo/sdk-coin-world": "^1.1.2",
114115
"@bitgo/sdk-coin-xdc": "^1.2.3",

modules/bitgo/src/v2/coinFactory.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,15 @@ import {
161161
Ttia,
162162
Tton,
163163
Ttrx,
164+
Tvet,
164165
Txlm,
165166
Txdc,
166167
Txrp,
167168
Txtz,
168169
Tzec,
169170
Tzeta,
170171
Tzketh,
172+
Vet,
171173
Wemix,
172174
World,
173175
Xdc,
@@ -318,6 +320,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin
318320
coinFactory.register('ttia', Ttia.createInstance);
319321
coinFactory.register('tton', Tton.createInstance);
320322
coinFactory.register('ttrx', Ttrx.createInstance);
323+
coinFactory.register('tvet', Tvet.createInstance);
321324
coinFactory.register('txdc', Txdc.createInstance);
322325
coinFactory.register('txlm', Txlm.createInstance);
323326
coinFactory.register('txrp', Txrp.createInstance);
@@ -327,6 +330,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin
327330
coinFactory.register('tzketh', Tzketh.createInstance);
328331
coinFactory.register('twemix', Twemix.createInstance);
329332
coinFactory.register('tworld', Tworld.createInstance);
333+
coinFactory.register('vet', Vet.createInstance);
330334
coinFactory.register('xdc', Xdc.createInstance);
331335
coinFactory.register('xlm', Xlm.createInstance);
332336
coinFactory.register('xrp', Xrp.createInstance);

modules/bitgo/src/v2/coins/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { Tia, Ttia } from '@bitgo/sdk-coin-tia';
6060
import { Ton, Tton } from '@bitgo/sdk-coin-ton';
6161
import { Trx, Ttrx } from '@bitgo/sdk-coin-trx';
6262
import { StellarToken, Txlm, Xlm } from '@bitgo/sdk-coin-xlm';
63+
import { Vet, Tvet } from '@bitgo/sdk-coin-vet';
6364
import { Wemix, Twemix } from '@bitgo/sdk-coin-wemix';
6465
import { World, Tworld } from '@bitgo/sdk-coin-world';
6566
import { Xdc, Txdc } from '@bitgo/sdk-coin-xdc';
@@ -130,6 +131,7 @@ export { Sei, Tsei };
130131
export { Injective, Tinjective };
131132
export { Islm, Tislm };
132133
export { Trx, Ttrx };
134+
export { Vet, Tvet };
133135
export { Xdc, Txdc };
134136
export { StellarToken, Txlm, Xlm };
135137
export { Txrp, Xrp, XrpToken };

modules/bitgo/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@
230230
{
231231
"path": "../sdk-coin-trx"
232232
},
233+
{
234+
"path": "../sdk-coin-vet"
235+
},
233236
{
234237
"path": "../sdk-coin-wemix"
235238
},

modules/sdk-coin-vet/.eslintignore

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+

modules/sdk-coin-vet/.gitignore

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/

modules/sdk-coin-vet/.mocharc.yml

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: '10000'
3+
reporter: 'min'
4+
reporter-option:
5+
- 'cdn=true'
6+
- 'json=false'
7+
exit: true
8+
spec: ['test/unit/**/*.ts']

modules/sdk-coin-vet/.npmignore

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

modules/sdk-coin-vet/.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.nyc_output/
2+
dist/

modules/sdk-coin-vet/.prettierrc.yml

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-vet/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# BitGo sdk-coin-vet
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-vet`.
10+
11+
```shell
12+
npm i @bitgo/sdk-api @bitgo/sdk-coin-vet
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 { Vet } from '@bitgo/sdk-coin-vet';
20+
21+
const sdk = new BitGoAPI();
22+
23+
sdk.register('vet', Vet.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.

modules/sdk-coin-vet/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@bitgo/sdk-coin-vet",
3+
"version": "1.3.0",
4+
"description": "BitGo SDK coin library for VeChain",
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-vet"
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-cosmos": "^11.7.3",
44+
"@bitgo/sdk-core": "^33.2.0",
45+
"@bitgo/statics": "^52.2.0"
46+
},
47+
"devDependencies": {
48+
"@bitgo/sdk-api": "^1.62.3",
49+
"@bitgo/sdk-test": "^8.0.84"
50+
}
51+
}

modules/sdk-coin-vet/src/index.ts

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 './vet';
3+
export * from './tvet';
4+
export * from './register';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const DEFAULT_GAS_UNIT_PRICE = 100;

modules/sdk-coin-vet/src/lib/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as Constants from './constants';
2+
import * as Utils from './utils';
3+
4+
export { Constants, Utils };

modules/sdk-coin-vet/src/lib/utils.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { BaseUtils } from '@bitgo/sdk-core';
2+
3+
export class Utils implements BaseUtils {
4+
isValidAddress(address: string): boolean {
5+
throw new Error('Method not implemented');
6+
}
7+
8+
isValidBlockId(hash: string): boolean {
9+
throw new Error('Method not implemented');
10+
}
11+
12+
isValidPrivateKey(key: string): boolean {
13+
throw new Error('Method not implemented');
14+
}
15+
16+
isValidPublicKey(key: string): boolean {
17+
throw new Error('Method not implemented');
18+
}
19+
20+
isValidSignature(signature: string): boolean {
21+
throw new Error('Method not implemented');
22+
}
23+
24+
isValidTransactionId(txId: string): boolean {
25+
throw new Error('Method not implemented');
26+
}
27+
}
28+
29+
const utils = new Utils();
30+
31+
export default utils;

modules/sdk-coin-vet/src/register.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { BitGoBase } from '@bitgo/sdk-core';
2+
import { Vet } from './vet';
3+
import { Tvet } from './tvet';
4+
5+
export const register = (sdk: BitGoBase): void => {
6+
sdk.register('vet', Vet.createInstance);
7+
sdk.register('tvet', Tvet.createInstance);
8+
};

modules/sdk-coin-vet/src/tvet.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Testnet Vechain
3+
*/
4+
import { BaseCoin, BitGoBase } from '@bitgo/sdk-core';
5+
import { Vet } from './vet';
6+
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
7+
8+
export class Tvet extends Vet {
9+
protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;
10+
protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>) {
11+
super(bitgo, staticsCoin);
12+
13+
if (!staticsCoin) {
14+
throw new Error('missing required constructor parameter staticsCoin');
15+
}
16+
17+
this._staticsCoin = staticsCoin;
18+
}
19+
20+
static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
21+
return new Tvet(bitgo, staticsCoin);
22+
}
23+
24+
/**
25+
* Identifier for the blockchain which supports this coin
26+
*/
27+
public getChain(): string {
28+
return 'tvet';
29+
}
30+
31+
/**
32+
* Complete human-readable name of this coin
33+
*/
34+
public getFullName(): string {
35+
return 'Testnet VeChain';
36+
}
37+
}

0 commit comments

Comments
 (0)