Skip to content

Commit

Permalink
feat(sdk-coin-oas): add oas sdk skeleton
Browse files Browse the repository at this point in the history
Ticket: WIN-3696
  • Loading branch information
adarsh312 committed Nov 8, 2024
1 parent 86bc4ba commit d0a57b1
Show file tree
Hide file tree
Showing 27 changed files with 384 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-algo /var/modules/sdk-coin-algo/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-arbeth /var/modules/sdk-coin-arbeth/
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/sdk-coin-arbeth /var/modules/sdk-coin-coredao/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-coredao /var/modules/sdk-coin-coredao/
COPY --from=builder /tmp/bitgo/modules/abstract-cosmos /var/modules/abstract-cosmos/
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/
Expand All @@ -77,7 +77,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-hbar /var/modules/sdk-coin-hbar/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-injective /var/modules/sdk-coin-injective/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-islm /var/modules/sdk-coin-islm/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-near /var/modules/sdk-coin-near/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-arbeth /var/modules/sdk-coin-oas/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-oas /var/modules/sdk-coin-oas/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-opeth /var/modules/sdk-coin-opeth/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-osmo /var/modules/sdk-coin-osmo/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-polygon /var/modules/sdk-coin-polygon/
Expand Down
1 change: 1 addition & 0 deletions modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@bitgo/sdk-coin-btc": "^2.3.4",
"@bitgo/sdk-coin-btg": "^2.0.43",
"@bitgo/sdk-coin-celo": "^3.0.35",
"@bitgo/sdk-coin-coredao": "^1.0.0",
"@bitgo/sdk-coin-coreum": "^21.0.12",
"@bitgo/sdk-coin-cspr": "^2.0.43",
"@bitgo/sdk-coin-dash": "^2.0.43",
Expand Down
3 changes: 3 additions & 0 deletions modules/bitgo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
{
"path": "../sdk-coin-celo"
},
{
"path": "../sdk-coin-coredao"
},
{
"path": "../sdk-coin-coreum"
},
Expand Down
5 changes: 5 additions & 0 deletions modules/sdk-coin-coredao/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.idea
public
dist

3 changes: 3 additions & 0 deletions modules/sdk-coin-coredao/.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/sdk-coin-coredao/.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']
14 changes: 14 additions & 0 deletions modules/sdk-coin-coredao/.npmignore
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
2 changes: 2 additions & 0 deletions modules/sdk-coin-coredao/.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/sdk-coin-coredao/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
printWidth: 120
singleQuote: true
trailingComma: 'es5'
30 changes: 30 additions & 0 deletions modules/sdk-coin-coredao/README.md
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.
51 changes: 51 additions & 0 deletions modules/sdk-coin-coredao/package.json
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"
}
}
44 changes: 44 additions & 0 deletions modules/sdk-coin-coredao/src/coredao.ts
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;
}
}
3 changes: 3 additions & 0 deletions modules/sdk-coin-coredao/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './lib';
export * from './coredao';
export * from './tcoredao';
3 changes: 3 additions & 0 deletions modules/sdk-coin-coredao/src/lib/address.ts
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 {}
3 changes: 3 additions & 0 deletions modules/sdk-coin-coredao/src/lib/enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum ContractType {}

export enum PermissionType {}
Empty file.
10 changes: 10 additions & 0 deletions modules/sdk-coin-coredao/src/lib/index.ts
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 };
42 changes: 42 additions & 0 deletions modules/sdk-coin-coredao/src/lib/keyPair.ts
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 {}
13 changes: 13 additions & 0 deletions modules/sdk-coin-coredao/src/lib/transaction.ts
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.');
}
}
35 changes: 35 additions & 0 deletions modules/sdk-coin-coredao/src/lib/transactionBuilder.ts
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 modules/sdk-coin-coredao/src/lib/transactionBuilderFactory.ts
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.
18 changes: 18 additions & 0 deletions modules/sdk-coin-coredao/src/tcoredao.ts
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.
Loading

0 comments on commit d0a57b1

Please sign in to comment.