-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
chore(abstract-substrate): add abstract-substrate skeleton
- Loading branch information
Showing
15 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.idea | ||
public | ||
dist | ||
resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
.idea/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.nyc_output/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
printWidth: 120 | ||
singleQuote: true | ||
trailingComma: 'es5' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# BitGo abstract-substrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
102
modules/abstract-substrate/src/abstractSubstrateCoin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { SubstrateCoin } from './abstractSubstrateCoin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters