-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk-coin-oas): add oas sdk skeleton
Ticket: WIN-3696
- Loading branch information
Showing
27 changed files
with
384 additions
and
2 deletions.
There are no files selected for viewing
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
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 | ||
|
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,14 @@ | ||
!dist/ | ||
dist/test/ | ||
dist/tsconfig.tsbuildinfo | ||
.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' |
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,30 @@ | ||
# BitGo sdk-coin-coredao | ||
|
||
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-coredao`. | ||
|
||
```shell | ||
npm i @bitgo/sdk-api @bitgo/sdk-coin-coredao | ||
``` | ||
|
||
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 { Coredao } from '@bitgo/sdk-coin-coredao'; | ||
|
||
const sdk = new BitGoAPI(); | ||
|
||
sdk.register('coredao', Coredao.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. |
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,51 @@ | ||
{ | ||
"name": "@bitgo/sdk-coin-coredao", | ||
"version": "1.0.0", | ||
"description": "BitGo SDK coin library for Coredao", | ||
"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": ">=18 <21" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/BitGo/BitGoJS.git", | ||
"directory": "modules/sdk-coin-coredao" | ||
}, | ||
"lint-staged": { | ||
"*.{js,ts}": [ | ||
"yarn prettier --write", | ||
"yarn eslint --fix" | ||
] | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"nyc": { | ||
"extension": [ | ||
".ts" | ||
] | ||
}, | ||
"dependencies": { | ||
"@bitgo/abstract-eth": "^22.2.4", | ||
"@bitgo/sdk-core": "^28.12.0", | ||
"@bitgo/statics": "^50.5.0" | ||
}, | ||
"devDependencies": { | ||
"@bitgo/sdk-api": "^1.56.1", | ||
"@bitgo/sdk-test": "^8.0.48" | ||
} | ||
} |
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 @@ | ||
import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; | ||
import { BaseCoin as StaticsBaseCoin, CoinFamily } from '@bitgo/statics'; | ||
import { AbstractEthLikeCoin } from '@bitgo/abstract-eth'; | ||
|
||
export class Coredao extends AbstractEthLikeCoin { | ||
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 Coredao(bitgo, staticsCoin); | ||
} | ||
|
||
getBaseFactor(): number { | ||
return Math.pow(10, this._staticsCoin.decimalPlaces); | ||
} | ||
|
||
getChain() { | ||
return this._staticsCoin.name; | ||
} | ||
|
||
/** | ||
* Get the base chain that the coin exists on. | ||
*/ | ||
getBaseChain() { | ||
return this.getChain(); | ||
} | ||
|
||
getFamily(): CoinFamily { | ||
return this._staticsCoin.family; | ||
} | ||
|
||
getFullName() { | ||
return this._staticsCoin.fullName; | ||
} | ||
} |
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 @@ | ||
export * from './lib'; | ||
export * from './coredao'; | ||
export * from './tcoredao'; |
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 @@ | ||
import { BaseAddress } from '@bitgo/sdk-core'; | ||
|
||
export class Address implements BaseAddress {} |
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 @@ | ||
export enum ContractType {} | ||
|
||
export enum PermissionType {} |
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,10 @@ | ||
// import * as Utils from './utils'; | ||
// import * as Interface from './iface'; | ||
|
||
export { Address } from './address'; | ||
export { KeyPair } from './keyPair'; | ||
export { Transaction } from './transaction'; | ||
export { TransactionBuilder } from './transactionBuilder'; | ||
export { TransactionBuilderFactory } from './transactionBuilderFactory'; | ||
|
||
// export { Utils, Interface }; |
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,42 @@ | ||
import { | ||
AddressFormat, | ||
BaseKeyPair, | ||
BlsKeyPair, | ||
DefaultKeys, | ||
Ed25519KeyPair, | ||
Secp256k1ExtendedKeyPair, | ||
} from '@bitgo/sdk-core'; | ||
|
||
export class KeyPair implements BaseKeyPair { | ||
recordKeysFromPrivateKey(prv: string): void { | ||
throw new Error('Method not implemented.'); | ||
} | ||
recordKeysFromPublicKey(pub: string): void { | ||
throw new Error('Method not implemented.'); | ||
} | ||
getKeys() { | ||
throw new Error('Method not implemented.'); | ||
} | ||
getAddress(format?: AddressFormat): string { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} | ||
|
||
export class KeyPair1 extends BlsKeyPair {} | ||
|
||
export class KeyPair2 extends Ed25519KeyPair { | ||
recordKeysFromPrivateKeyInProtocolFormat(prv: string): DefaultKeys { | ||
throw new Error('Method not implemented.'); | ||
} | ||
recordKeysFromPublicKeyInProtocolFormat(pub: string): DefaultKeys { | ||
throw new Error('Method not implemented.'); | ||
} | ||
getAddress(format?: AddressFormat): string { | ||
throw new Error('Method not implemented.'); | ||
} | ||
getKeys() { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} | ||
|
||
export class KeyPair3 extends Secp256k1ExtendedKeyPair {} |
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,13 @@ | ||
import { BaseKey, BaseTransaction } from '@bitgo/sdk-core'; | ||
|
||
export class Transaction extends BaseTransaction { | ||
canSign(key: BaseKey): boolean { | ||
throw new Error('Method not implemented.'); | ||
} | ||
toJson() { | ||
throw new Error('Method not implemented.'); | ||
} | ||
toBroadcastFormat() { | ||
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,35 @@ | ||
import { BaseAddress, BaseKey, BaseTransaction, BaseTransactionBuilder } from '@bitgo/sdk-core'; | ||
import BigNumber from 'bignumber.js'; | ||
|
||
export class TransactionBuilder extends BaseTransactionBuilder { | ||
protected fromImplementation(rawTransaction: any): BaseTransaction { | ||
throw new Error('Method not implemented.'); | ||
} | ||
protected signImplementation(key: BaseKey): BaseTransaction { | ||
throw new Error('Method not implemented.'); | ||
} | ||
protected buildImplementation(): Promise<BaseTransaction> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
validateKey(key: BaseKey): void { | ||
throw new Error('Method not implemented.'); | ||
} | ||
validateAddress(address: BaseAddress, addressFormat?: string): void { | ||
throw new Error('Method not implemented.'); | ||
} | ||
validateValue(value: BigNumber): void { | ||
throw new Error('Method not implemented.'); | ||
} | ||
validateRawTransaction(rawTransaction: any): void { | ||
throw new Error('Method not implemented.'); | ||
} | ||
validateTransaction(transaction?: BaseTransaction): void { | ||
throw new Error('Method not implemented.'); | ||
} | ||
protected get transaction(): BaseTransaction { | ||
throw new Error('Method not implemented.'); | ||
} | ||
protected set transaction(transaction: BaseTransaction) { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
modules/sdk-coin-coredao/src/lib/transactionBuilderFactory.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,13 @@ | ||
import { BaseTransactionBuilderFactory } from '@bitgo/sdk-core'; | ||
|
||
export class TransactionBuilderFactory extends BaseTransactionBuilderFactory { | ||
public getWalletInitializationBuilder() { | ||
throw new Error('Method not implemented.'); | ||
} | ||
public getTransferBuilder() { | ||
throw new Error('Method not implemented.'); | ||
} | ||
public from(raw: string | Uint8Array) { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} |
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,18 @@ | ||
/** | ||
* Testnet Coredao | ||
* | ||
* @format | ||
*/ | ||
import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; | ||
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics'; | ||
import { Coredao } from './coredao'; | ||
|
||
export class Tcoredao extends Coredao { | ||
protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>) { | ||
super(bitgo, staticsCoin); | ||
} | ||
|
||
static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin { | ||
return new Tcoredao(bitgo, staticsCoin); | ||
} | ||
} |
Empty file.
Oops, something went wrong.