diff --git a/CODEOWNERS b/CODEOWNERS index 1ed00c2a3e..b66080fa1d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -47,6 +47,7 @@ /modules/abstract-cosmos/ @BitGo/ethalt-team /modules/sdk-coin-ada/ @BitGo/ethalt-team /modules/sdk-coin-algo/ @BitGo/ethalt-team +/modules/sdk-coin-apt/ @Bitgo/ethalt-team /modules/sdk-coin-arbeth/ @BitGo/ethalt-team /modules/sdk-coin-atom/ @BitGo/ethalt-team /modules/sdk-coin-avaxc/ @BitGo/ethalt-team diff --git a/Dockerfile b/Dockerfile index 3597de6c8f..56d921e1f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,6 +55,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-api /var/modules/sdk-api/ COPY --from=builder /tmp/bitgo/modules/unspents /var/modules/unspents/ COPY --from=builder /tmp/bitgo/modules/account-lib /var/modules/account-lib/ COPY --from=builder /tmp/bitgo/modules/sdk-coin-algo /var/modules/sdk-coin-algo/ +COPY --from=builder /tmp/bitgo/modules/sdk-coin-apt /var/modules/sdk-coin-apt/ 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/ @@ -126,6 +127,7 @@ cd /var/modules/sdk-api && yarn link && \ cd /var/modules/unspents && yarn link && \ cd /var/modules/account-lib && yarn link && \ cd /var/modules/sdk-coin-algo && yarn link && \ +cd /var/modules/sdk-coin-apt && yarn link && \ cd /var/modules/sdk-coin-arbeth && yarn link && \ cd /var/modules/abstract-eth && yarn link && \ cd /var/modules/sdk-coin-atom && yarn link && \ @@ -200,6 +202,7 @@ RUN cd /var/bitgo-express && \ yarn link @bitgo/unspents && \ yarn link @bitgo/account-lib && \ yarn link @bitgo/sdk-coin-algo && \ + yarn link @bitgo/sdk-coin-apt && \ yarn link @bitgo/sdk-coin-arbeth && \ yarn link @bitgo/abstract-eth && \ yarn link @bitgo/sdk-coin-atom && \ diff --git a/modules/bitgo/package.json b/modules/bitgo/package.json index f5a93ab64e..3d69b9a70d 100644 --- a/modules/bitgo/package.json +++ b/modules/bitgo/package.json @@ -51,6 +51,7 @@ "@bitgo/sdk-api": "^1.56.3", "@bitgo/sdk-coin-ada": "^4.3.4", "@bitgo/sdk-coin-algo": "^2.1.43", + "@bitgo/sdk-coin-apt": "^1.0.0", "@bitgo/sdk-coin-arbeth": "^21.0.37", "@bitgo/sdk-coin-atom": "^13.1.1", "@bitgo/sdk-coin-avaxc": "^5.1.6", diff --git a/modules/bitgo/src/v2/coinFactory.ts b/modules/bitgo/src/v2/coinFactory.ts index cc5344303a..b2b62cccfe 100644 --- a/modules/bitgo/src/v2/coinFactory.ts +++ b/modules/bitgo/src/v2/coinFactory.ts @@ -13,6 +13,7 @@ import { tokens } from '../config'; import { Ada, Algo, + Apt, Arbeth, ArbethToken, Atom, @@ -74,6 +75,7 @@ import { Ton, Tada, Talgo, + Tapt, Tarbeth, Tatom, TavaxC, @@ -140,6 +142,7 @@ import { function registerCoinConstructors(globalCoinFactory: CoinFactory): void { globalCoinFactory.register('ada', Ada.createInstance); globalCoinFactory.register('algo', Algo.createInstance); + globalCoinFactory.register('apt', Apt.createInstance); globalCoinFactory.register('arbeth', Arbeth.createInstance); globalCoinFactory.register('atom', Atom.createInstance); globalCoinFactory.register('avaxc', AvaxC.createInstance); @@ -191,6 +194,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void { globalCoinFactory.register('tia', Tia.createInstance); globalCoinFactory.register('ton', Ton.createInstance); globalCoinFactory.register('talgo', Talgo.createInstance); + globalCoinFactory.register('tapt', Tapt.createInstance); globalCoinFactory.register('tarbeth', Tarbeth.createInstance); globalCoinFactory.register('tada', Tada.createInstance); globalCoinFactory.register('tatom', Tatom.createInstance); diff --git a/modules/bitgo/src/v2/coins/index.ts b/modules/bitgo/src/v2/coins/index.ts index 23fe90dcb4..06ca4d441b 100644 --- a/modules/bitgo/src/v2/coins/index.ts +++ b/modules/bitgo/src/v2/coins/index.ts @@ -2,6 +2,7 @@ import { AbstractUtxoCoin } from '@bitgo/abstract-utxo'; import { AbstractLightningCoin } from '@bitgo/abstract-lightning'; import { Ada, Tada } from '@bitgo/sdk-coin-ada'; import { Algo, AlgoToken, Talgo } from '@bitgo/sdk-coin-algo'; +import { Apt, Tapt } from '@bitgo/sdk-coin-apt'; import { Arbeth, Tarbeth, ArbethToken } from '@bitgo/sdk-coin-arbeth'; import { Atom, Tatom } from '@bitgo/sdk-coin-atom'; import { AvaxC, AvaxCToken, TavaxC } from '@bitgo/sdk-coin-avaxc'; @@ -54,6 +55,7 @@ import { Zketh, Tzketh, ZkethToken } from '@bitgo/sdk-coin-zketh'; export { AbstractUtxoCoin }; export { AbstractLightningCoin }; export { Algo, AlgoToken, Talgo }; +export { Apt, Tapt }; export { Arbeth, Tarbeth, ArbethToken }; export { Ada, Tada }; export { Atom, Tatom }; diff --git a/modules/bitgo/test/browser/browser.spec.ts b/modules/bitgo/test/browser/browser.spec.ts index a74539120e..13d9d12175 100644 --- a/modules/bitgo/test/browser/browser.spec.ts +++ b/modules/bitgo/test/browser/browser.spec.ts @@ -33,6 +33,8 @@ describe('Coins', () => { XrpToken: 1, Rune: 1, Trune: 1, + Apt: 1, + Tapt: 1, }; Object.keys(BitGoJS.Coin) .filter((coinName) => !excludedKeys[coinName]) diff --git a/modules/bitgo/tsconfig.json b/modules/bitgo/tsconfig.json index cb41ab01da..91a780a291 100644 --- a/modules/bitgo/tsconfig.json +++ b/modules/bitgo/tsconfig.json @@ -44,6 +44,9 @@ { "path": "../sdk-coin-algo" }, + { + "path": "../sdk-coin-apt" + }, { "path": "../sdk-coin-arbeth" }, diff --git a/modules/sdk-coin-apt/.eslintignore b/modules/sdk-coin-apt/.eslintignore new file mode 100644 index 0000000000..1586a150fa --- /dev/null +++ b/modules/sdk-coin-apt/.eslintignore @@ -0,0 +1,4 @@ +node_modules +.idea +public +dist diff --git a/modules/sdk-coin-apt/.gitignore b/modules/sdk-coin-apt/.gitignore new file mode 100644 index 0000000000..67ccce4c64 --- /dev/null +++ b/modules/sdk-coin-apt/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +.idea/ +dist/ diff --git a/modules/sdk-coin-apt/.mocharc.yml b/modules/sdk-coin-apt/.mocharc.yml new file mode 100644 index 0000000000..95814796d1 --- /dev/null +++ b/modules/sdk-coin-apt/.mocharc.yml @@ -0,0 +1,8 @@ +require: 'ts-node/register' +timeout: '60000' +reporter: 'min' +reporter-option: + - 'cdn=true' + - 'json=false' +exit: true +spec: ['test/unit/**/*.ts'] diff --git a/modules/sdk-coin-apt/.npmignore b/modules/sdk-coin-apt/.npmignore new file mode 100644 index 0000000000..d5fb3a098c --- /dev/null +++ b/modules/sdk-coin-apt/.npmignore @@ -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 diff --git a/modules/sdk-coin-apt/.prettierignore b/modules/sdk-coin-apt/.prettierignore new file mode 100644 index 0000000000..3a11d6af29 --- /dev/null +++ b/modules/sdk-coin-apt/.prettierignore @@ -0,0 +1,2 @@ +.nyc_output/ +dist/ diff --git a/modules/sdk-coin-apt/.prettierrc.yml b/modules/sdk-coin-apt/.prettierrc.yml new file mode 100644 index 0000000000..7c3d8dd32a --- /dev/null +++ b/modules/sdk-coin-apt/.prettierrc.yml @@ -0,0 +1,3 @@ +printWidth: 120 +singleQuote: true +trailingComma: 'es5' diff --git a/modules/sdk-coin-apt/README.md b/modules/sdk-coin-apt/README.md new file mode 100644 index 0000000000..0bfe4304da --- /dev/null +++ b/modules/sdk-coin-apt/README.md @@ -0,0 +1,30 @@ +# BitGo sdk-coin-apt + +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-apt`. + +```shell +npm i @bitgo/sdk-api @bitgo/sdk-coin-apt +``` + +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 { Apt } from '@bitgo/sdk-coin-apt'; + +const sdk = new BitGoAPI(); + +sdk.register('apt', Apt.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. diff --git a/modules/sdk-coin-apt/package.json b/modules/sdk-coin-apt/package.json new file mode 100644 index 0000000000..f99a485192 --- /dev/null +++ b/modules/sdk-coin-apt/package.json @@ -0,0 +1,51 @@ +{ + "name": "@bitgo/sdk-coin-apt", + "version": "1.0.0", + "description": "BitGo SDK coin library for APT (Aptos) coin", + "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 ", + "license": "MIT", + "engines": { + "node": ">=16 <21" + }, + "repository": { + "type": "git", + "url": "https://github.com/BitGo/BitGoJS.git", + "directory": "modules/sdk-coin-apt" + }, + "lint-staged": { + "*.{js,ts}": [ + "yarn prettier --write", + "yarn eslint --fix" + ] + }, + "publishConfig": { + "access": "public" + }, + "nyc": { + "extension": [ + ".ts" + ] + }, + "dependencies": { + "@bitgo/sdk-core": "^28.13.1", + "@bitgo/statics": "^50.6.0", + "bignumber.js": "^9.1.2" + }, + "devDependencies": { + "@bitgo/sdk-api": "^1.56.3", + "@bitgo/sdk-test": "^8.0.50" + } +} diff --git a/modules/sdk-coin-apt/src/apt.ts b/modules/sdk-coin-apt/src/apt.ts new file mode 100644 index 0000000000..fa29ecddf5 --- /dev/null +++ b/modules/sdk-coin-apt/src/apt.ts @@ -0,0 +1,76 @@ +import { + BaseCoin, + BitGoBase, + KeyPair, + ParsedTransaction, + ParseTransactionOptions, + SignedTransaction, + SignTransactionOptions, + VerifyAddressOptions, + VerifyTransactionOptions, +} from '@bitgo/sdk-core'; +import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics'; + +export class Apt extends BaseCoin { + protected readonly _staticsCoin: Readonly; + protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly) { + super(bitgo); + + if (!staticsCoin) { + throw new Error('missing required constructor parameter staticsCoin'); + } + + this._staticsCoin = staticsCoin; + } + + static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly): BaseCoin { + return new Apt(bitgo, staticsCoin); + } + + /** + * Factor between the coin's base unit and its smallest subdivison + */ + public getBaseFactor(): number { + return 1e8; + } + + public getChain(): string { + return 'apt'; + } + + public getFamily(): string { + return 'apt'; + } + + public getFullName(): string { + return 'Aptos'; + } + + verifyTransaction(params: VerifyTransactionOptions): Promise { + throw new Error('Method not implemented.'); + } + + isWalletAddress(params: VerifyAddressOptions): Promise { + throw new Error('Method not implemented.'); + } + + parseTransaction(params: ParseTransactionOptions): Promise { + throw new Error('Method not implemented.'); + } + + generateKeyPair(seed?: Buffer): KeyPair { + throw new Error('Method not implemented.'); + } + + isValidPub(pub: string): boolean { + throw new Error('Method not implemented.'); + } + + isValidAddress(address: string): boolean { + throw new Error('Method not implemented.'); + } + + signTransaction(params: SignTransactionOptions): Promise { + throw new Error('Method not implemented.'); + } +} diff --git a/modules/sdk-coin-apt/src/index.ts b/modules/sdk-coin-apt/src/index.ts new file mode 100644 index 0000000000..dd32f56cfd --- /dev/null +++ b/modules/sdk-coin-apt/src/index.ts @@ -0,0 +1,4 @@ +export * from './lib'; +export * from './register'; +export * from './apt'; +export * from './tapt'; diff --git a/modules/sdk-coin-apt/src/lib/iface.ts b/modules/sdk-coin-apt/src/lib/iface.ts new file mode 100644 index 0000000000..546ef821e8 --- /dev/null +++ b/modules/sdk-coin-apt/src/lib/iface.ts @@ -0,0 +1,6 @@ +/** + * The transaction data returned from the toJson() function of a transaction + */ +export interface TxData { + id: string; +} diff --git a/modules/sdk-coin-apt/src/lib/index.ts b/modules/sdk-coin-apt/src/lib/index.ts new file mode 100644 index 0000000000..aa5217eaac --- /dev/null +++ b/modules/sdk-coin-apt/src/lib/index.ts @@ -0,0 +1,9 @@ +import * as Utils from './utils'; +import * as Interface from './iface'; + +export { KeyPair } from './keyPair'; +export { Transaction } from './transaction'; +export { TransactionBuilder } from './transactionBuilder'; +export { TransferBuilder } from './transferBuilder'; +export { TransactionBuilderFactory } from './transactionBuilderFactory'; +export { Interface, Utils }; diff --git a/modules/sdk-coin-apt/src/lib/keyPair.ts b/modules/sdk-coin-apt/src/lib/keyPair.ts new file mode 100644 index 0000000000..bb4449c74a --- /dev/null +++ b/modules/sdk-coin-apt/src/lib/keyPair.ts @@ -0,0 +1,23 @@ +import { DefaultKeys, Ed25519KeyPair } from '@bitgo/sdk-core'; + +export class KeyPair extends Ed25519KeyPair { + /** @inheritdoc */ + getKeys(): DefaultKeys { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + recordKeysFromPrivateKeyInProtocolFormat(prv: string): DefaultKeys { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + recordKeysFromPublicKeyInProtocolFormat(pub: string): DefaultKeys { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + getAddress(): string { + throw new Error('Method not implemented.'); + } +} diff --git a/modules/sdk-coin-apt/src/lib/transaction.ts b/modules/sdk-coin-apt/src/lib/transaction.ts new file mode 100644 index 0000000000..431c397b49 --- /dev/null +++ b/modules/sdk-coin-apt/src/lib/transaction.ts @@ -0,0 +1,16 @@ +import { BaseKey, BaseTransaction } from '@bitgo/sdk-core'; +import { TxData } from './iface'; + +export class Transaction extends BaseTransaction { + canSign(key: BaseKey): boolean { + return false; + } + + toBroadcastFormat(): string { + throw new Error('Method not implemented.'); + } + + toJson(): TxData { + throw new Error('Method not implemented.'); + } +} diff --git a/modules/sdk-coin-apt/src/lib/transactionBuilder.ts b/modules/sdk-coin-apt/src/lib/transactionBuilder.ts new file mode 100644 index 0000000000..04175935ff --- /dev/null +++ b/modules/sdk-coin-apt/src/lib/transactionBuilder.ts @@ -0,0 +1,99 @@ +import { + BaseAddress, + BaseKey, + BaseTransactionBuilder, + BuildTransactionError, + FeeOptions, + PublicKey as BasePublicKey, + Signature, + TransactionType, +} from '@bitgo/sdk-core'; +import { Transaction } from './transaction'; +import utils from './utils'; +import BigNumber from 'bignumber.js'; + +export abstract class TransactionBuilder extends BaseTransactionBuilder { + protected _transaction: Transaction; + private _signatures: Signature[] = []; + + // get and set region + /** + * The transaction type. + */ + protected abstract get transactionType(): TransactionType; + + /** @inheritdoc */ + protected get transaction(): Transaction { + return this._transaction; + } + + /** @inheritdoc */ + protected set transaction(transaction: Transaction) { + this._transaction = transaction; + } + + /** @inheritdoc */ + protected signImplementation(key: BaseKey): Transaction { + throw new Error('Method not implemented.'); + } + + /** @inheritDoc */ + addSignature(publicKey: BasePublicKey, signature: Buffer): void { + this._signatures.push({ publicKey, signature }); + } + + /** + * Sets the sender of this transaction. + * This account will be responsible for paying transaction fees. + * + * @param {string} senderAddress the account that is sending this transaction + * @returns {TransactionBuilder} This transaction builder + */ + sender(senderAddress: string): this { + throw new Error('Method not implemented.'); + } + + fee(feeOptions: FeeOptions): this { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + protected fromImplementation(rawTransaction: string): Transaction { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + protected async buildImplementation(): Promise { + throw new Error('Method not implemented.'); + } + + // region Validators + /** @inheritdoc */ + validateAddress(address: BaseAddress, addressFormat?: string): void { + if (!utils.isValidAddress(address.address)) { + throw new BuildTransactionError('Invalid address ' + address.address); + } + } + + /** @inheritdoc */ + validateKey(key: BaseKey): void { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + validateRawTransaction(rawTransaction: string): void { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + validateTransaction(transaction?: Transaction): void { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + validateValue(value: BigNumber): void { + if (value.isLessThan(0)) { + throw new BuildTransactionError('Value cannot be less than zero'); + } + } +} diff --git a/modules/sdk-coin-apt/src/lib/transactionBuilderFactory.ts b/modules/sdk-coin-apt/src/lib/transactionBuilderFactory.ts new file mode 100644 index 0000000000..b963ec4b4d --- /dev/null +++ b/modules/sdk-coin-apt/src/lib/transactionBuilderFactory.ts @@ -0,0 +1,20 @@ +import { BaseTransactionBuilderFactory } from '@bitgo/sdk-core'; +import { TransactionBuilder } from './transactionBuilder'; +import { TransferBuilder } from './transferBuilder'; + +export class TransactionBuilderFactory extends BaseTransactionBuilderFactory { + /** @inheritdoc */ + from(raw: string): TransactionBuilder { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + getTransferBuilder(): TransferBuilder { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + getWalletInitializationBuilder(): void { + throw new Error('Method not implemented.'); + } +} diff --git a/modules/sdk-coin-apt/src/lib/transferBuilder.ts b/modules/sdk-coin-apt/src/lib/transferBuilder.ts new file mode 100644 index 0000000000..b7ce748c92 --- /dev/null +++ b/modules/sdk-coin-apt/src/lib/transferBuilder.ts @@ -0,0 +1,13 @@ +import { TransactionBuilder } from './transactionBuilder'; +import { BaseCoin as CoinConfig } from '@bitgo/statics'; +import { TransactionType } from '@bitgo/sdk-core'; + +export class TransferBuilder extends TransactionBuilder { + constructor(_coinConfig: Readonly) { + super(_coinConfig); + } + + protected get transactionType(): TransactionType { + return TransactionType.Send; + } +} diff --git a/modules/sdk-coin-apt/src/lib/utils.ts b/modules/sdk-coin-apt/src/lib/utils.ts new file mode 100644 index 0000000000..b0cdef2405 --- /dev/null +++ b/modules/sdk-coin-apt/src/lib/utils.ts @@ -0,0 +1,37 @@ +import { BaseUtils } from '@bitgo/sdk-core'; + +export class Utils implements BaseUtils { + /** @inheritdoc */ + isValidAddress(address: string): boolean { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + isValidBlockId(hash: string): boolean { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + isValidPrivateKey(key: string): boolean { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + isValidPublicKey(key: string): boolean { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + isValidSignature(signature: string): boolean { + throw new Error('Method not implemented.'); + } + + /** @inheritdoc */ + isValidTransactionId(txId: string): boolean { + throw new Error('Method not implemented.'); + } +} + +const utils = new Utils(); + +export default utils; diff --git a/modules/sdk-coin-apt/src/register.ts b/modules/sdk-coin-apt/src/register.ts new file mode 100644 index 0000000000..8a9ab8e73e --- /dev/null +++ b/modules/sdk-coin-apt/src/register.ts @@ -0,0 +1,8 @@ +import { BitGoBase } from '@bitgo/sdk-core'; +import { Apt } from './apt'; +import { Tapt } from './tapt'; + +export const register = (sdk: BitGoBase): void => { + sdk.register('apt', Apt.createInstance); + sdk.register('tapt', Tapt.createInstance); +}; diff --git a/modules/sdk-coin-apt/src/tapt.ts b/modules/sdk-coin-apt/src/tapt.ts new file mode 100644 index 0000000000..491e92968f --- /dev/null +++ b/modules/sdk-coin-apt/src/tapt.ts @@ -0,0 +1,34 @@ +import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; +import { Apt } from './apt'; +import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics'; + +export class Tapt extends Apt { + protected readonly _staticsCoin: Readonly; + protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly) { + super(bitgo, staticsCoin); + + if (!staticsCoin) { + throw new Error('missing required constructor parameter staticsCoin'); + } + + this._staticsCoin = staticsCoin; + } + + static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly): BaseCoin { + return new Tapt(bitgo, staticsCoin); + } + + /** + * Identifier for the blockchain which supports this coin + */ + public getChain(): string { + return 'tapt'; + } + + /** + * Complete human-readable name of this coin + */ + public getFullName(): string { + return 'Testnet Aptos'; + } +} diff --git a/modules/sdk-coin-apt/test/integration/index.ts b/modules/sdk-coin-apt/test/integration/index.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modules/sdk-coin-apt/test/unit/apt.ts b/modules/sdk-coin-apt/test/unit/apt.ts new file mode 100644 index 0000000000..d81e6d9787 --- /dev/null +++ b/modules/sdk-coin-apt/test/unit/apt.ts @@ -0,0 +1,15 @@ +import 'should'; +import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test'; +import { BitGoAPI } from '@bitgo/sdk-api'; +import { Apt, Tapt } from '../../src'; + +describe('APT:', function () { + let bitgo: TestBitGoAPI; + + before(function () { + bitgo = TestBitGo.decorate(BitGoAPI, { env: 'mock' }); + bitgo.safeRegister('apt', Apt.createInstance); + bitgo.safeRegister('tapt', Tapt.createInstance); + bitgo.initializeTestVars(); + }); +}); diff --git a/modules/sdk-coin-apt/tsconfig.json b/modules/sdk-coin-apt/tsconfig.json new file mode 100644 index 0000000000..aa8f5a7e66 --- /dev/null +++ b/modules/sdk-coin-apt/tsconfig.json @@ -0,0 +1,26 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./", + "strictPropertyInitialization": false, + "esModuleInterop": true, + "typeRoots": ["../../types", "./node_modules/@types", "../../node_modules/@types"] + }, + "include": ["src/**/*", "test/**/*"], + "exclude": ["node_modules"], + "references": [ + { + "path": "../sdk-api" + }, + { + "path": "../sdk-core" + }, + { + "path": "../sdk-test" + }, + { + "path": "../statics" + } + ] +} diff --git a/tsconfig.packages.json b/tsconfig.packages.json index add1de9760..ea6a55d95c 100644 --- a/tsconfig.packages.json +++ b/tsconfig.packages.json @@ -40,6 +40,9 @@ { "path": "./modules/sdk-coin-algo" }, + { + "path": "./modules/sdk-coin-apt" + }, { "path": "./modules/sdk-coin-arbeth" }, diff --git a/yarn.lock b/yarn.lock index 6b90db3925..fc9ecc514b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6953,7 +6953,7 @@ bignumber.js@^4.0.0: resolved "https://registry.npmjs.org/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1" integrity sha512-eJzYkFYy9L4JzXsbymsFn3p54D+llV27oTQ+ziJG7WFRheJcNZilgVXMG0LoZtlQSKBsJdWtLFqOD0u+U0jZKA== -bignumber.js@^9.0.0, bignumber.js@^9.0.1, bignumber.js@^9.0.2, bignumber.js@^9.1.1: +bignumber.js@^9.0.0, bignumber.js@^9.0.1, bignumber.js@^9.0.2, bignumber.js@^9.1.1, bignumber.js@^9.1.2: version "9.1.2" resolved "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c" integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==