Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(abstract-substrate): add abstract-substrate skeleton #5354

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

# All other coins
/modules/abstract-cosmos/ @BitGo/ethalt-team
/modules/abstract-substrate/ @BitGo/ethalt-team
/modules/sdk-coin-ada/ @BitGo/ethalt-team
/modules/sdk-coin-algo/ @BitGo/ethalt-team
/modules/sdk-coin-apt/ @Bitgo/ethalt-team
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-arbeth /var/modules/sdk-coin-arb
COPY --from=builder /tmp/bitgo/modules/abstract-eth /var/modules/abstract-eth/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-atom /var/modules/sdk-coin-atom/
COPY --from=builder /tmp/bitgo/modules/abstract-cosmos /var/modules/abstract-cosmos/
COPY --from=builder /tmp/bitgo/modules/abstract-substrate /var/modules/abstract-substrate/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-avaxc /var/modules/sdk-coin-avaxc/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-avaxp /var/modules/sdk-coin-avaxp/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-eth /var/modules/sdk-coin-eth/
Expand Down Expand Up @@ -136,6 +137,7 @@ cd /var/modules/sdk-coin-arbeth && yarn link && \
cd /var/modules/abstract-eth && yarn link && \
cd /var/modules/sdk-coin-atom && yarn link && \
cd /var/modules/abstract-cosmos && yarn link && \
cd /var/modules/abstract-substrate && yarn link && \
cd /var/modules/sdk-coin-avaxc && yarn link && \
cd /var/modules/sdk-coin-avaxp && yarn link && \
cd /var/modules/sdk-coin-eth && yarn link && \
Expand Down Expand Up @@ -214,6 +216,7 @@ RUN cd /var/bitgo-express && \
yarn link @bitgo/abstract-eth && \
yarn link @bitgo/sdk-coin-atom && \
yarn link @bitgo/abstract-cosmos && \
yarn link @bitgo/abstract-substrate && \
yarn link @bitgo/sdk-coin-avaxc && \
yarn link @bitgo/sdk-coin-avaxp && \
yarn link @bitgo/sdk-coin-eth && \
Expand Down
5 changes: 5 additions & 0 deletions modules/abstract-substrate/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.idea
public
dist
resources
3 changes: 3 additions & 0 deletions modules/abstract-substrate/.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/abstract-substrate/.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']
12 changes: 12 additions & 0 deletions modules/abstract-substrate/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
!dist/
.idea/
.prettierrc.yml
tsconfig.json
src/
test/
scripts/
.nyc_output
CODEOWNERS
node_modules/
.prettierignore
.mocharc.js
2 changes: 2 additions & 0 deletions modules/abstract-substrate/.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/abstract-substrate/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
printWidth: 120
singleQuote: true
trailingComma: 'es5'
Empty file.
1 change: 1 addition & 0 deletions modules/abstract-substrate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# BitGo abstract-substrate
44 changes: 44 additions & 0 deletions modules/abstract-substrate/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@bitgo/abstract-substrate",
"version": "1.0.0",
"description": "BitGo SDK coin library for Substrate base implementation",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
"build": "npm run prepare",
"build-ts": "yarn tsc --build --incremental --verbose .",
"fmt": "prettier --write .",
"check-fmt": "prettier --check .",
"clean": "rm -r ./dist",
"lint": "eslint --quiet .",
"prepare": "npm run build-ts"
},
"author": "BitGo SDK Team <[email protected]>",
"license": "MIT",
"engines": {
"node": ">=18 <21"
},
"repository": {
"type": "git",
"url": "https://github.com/BitGo/BitGoJS.git",
"directory": "modules/abstract-substrate"
},
"lint-staged": {
"*.{js,ts}": [
"yarn prettier --write",
"yarn eslint --fix"
]
},
"publishConfig": {
"access": "public"
},
"nyc": {
"extension": [
".ts"
]
},
"dependencies": {
"@bitgo/sdk-core": "^28.18.0",
"@bitgo/statics": "^50.17.0"
}
}
102 changes: 102 additions & 0 deletions modules/abstract-substrate/src/abstractSubstrateCoin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import {
BaseCoin,
BitGoBase,
KeyPair,
MPCAlgorithm,
ParsedTransaction,
ParseTransactionOptions,
SignedTransaction,
SignTransactionOptions,
VerifyAddressOptions,
VerifyTransactionOptions,
} from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin, CoinFamily } from '@bitgo/statics';

export class SubstrateCoin extends BaseCoin {
protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;
protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>) {
super(bitgo);

if (!staticsCoin) {
throw new Error('missing required constructor parameter staticsCoin');
}

this._staticsCoin = staticsCoin;
}

static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
return new SubstrateCoin(bitgo, staticsCoin);
}

/**
* Creates an instance of TransactionBuilderFactory for the coin specific sdk
*/
getBuilder(): any {
throw new Error('Method not implemented.');
}

/** @inheritDoc **/
getBaseFactor(): string | number {
throw new Error('Method not implemented');
}

/** @inheritDoc **/
getChain(): string {
return this._staticsCoin.name;
}

/** @inheritDoc **/
getFamily(): CoinFamily {
return this._staticsCoin.family;
}

/** @inheritDoc **/
getFullName(): string {
return this._staticsCoin.fullName;
}

/** @inheritDoc */
supportsTss(): boolean {
return true;
}

/** @inheritDoc **/
getMPCAlgorithm(): MPCAlgorithm {
return 'eddsa';
}

/** @inheritDoc **/
generateKeyPair(seed?: Buffer): KeyPair {
throw new Error('Method not implemented');
}

/** @inheritDoc **/
isValidPub(pub: string): boolean {
throw new Error('Method not implemented');
}

/** @inheritDoc **/
isWalletAddress(params: VerifyAddressOptions): Promise<boolean> {
throw new Error('Method not implemented');
}

/** @inheritDoc **/
parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
throw new Error('Method not implemented');
}

/** @inheritDoc **/
verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
throw new Error('Method not implemented');
}

/** @inheritDoc **/
isValidAddress(address: string): boolean {
throw new Error('Method not implemented.');
}

/** @inheritDoc **/
signTransaction(params: SignTransactionOptions): Promise<SignedTransaction> {
throw new Error('Method not implemented.');
}
}
1 change: 1 addition & 0 deletions modules/abstract-substrate/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SubstrateCoin } from './abstractSubstrateCoin';
23 changes: 23 additions & 0 deletions modules/abstract-substrate/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./",
"strictPropertyInitialization": false,
"esModuleInterop": true,
"typeRoots": ["../../types", "./node_modules/@types", "../../node_modules/@types"]
},
"include": ["src/**/*", "resources/**/*"],
"exclude": ["node_modules"],
"references": [
{
"path": "../sdk-core"
},
{
"path": "../statics"
},
{
"path": "../utxo-lib"
}
]
}
3 changes: 3 additions & 0 deletions tsconfig.packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{
"path": "./modules/abstract-cosmos"
},
{
"path": "./modules/abstract-substrate"
},
{
"path": "./modules/abstract-eth"
},
Expand Down
Loading