diff --git a/Dockerfile b/Dockerfile index 7b2f52e001..38c34cc590 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,14 +21,6 @@ COPY --from=builder /tmp/bitgo/node_modules /var/node_modules/ COPY --from=builder /tmp/bitgo/modules/express /var/bitgo-express/ #COPY_START -COPY --from=builder /tmp/bitgo/modules/bitgo /var/modules/bitgo/ -RUN cd /var/modules/bitgo && yarn link -COPY --from=builder /tmp/bitgo/modules/abstract-eth /var/modules/abstract-eth/ -RUN cd /var/modules/abstract-eth && yarn link -COPY --from=builder /tmp/bitgo/modules/sdk-coin-eth /var/modules/sdk-coin-eth/ -RUN cd /var/modules/sdk-coin-eth && yarn link -COPY --from=builder /tmp/bitgo/modules/sdk-api /var/modules/sdk-api/ -RUN cd /var/modules/sdk-api && yarn link COPY --from=builder /tmp/bitgo/modules/sdk-core /var/modules/sdk-core/ RUN cd /var/modules/sdk-core && yarn link COPY --from=builder /tmp/bitgo/modules/bls-dkg /var/modules/bls-dkg/ @@ -41,6 +33,14 @@ COPY --from=builder /tmp/bitgo/modules/blake2b /var/modules/blake2b/ RUN cd /var/modules/blake2b && yarn link COPY --from=builder /tmp/bitgo/modules/blake2b-wasm /var/modules/blake2b-wasm/ RUN cd /var/modules/blake2b-wasm && yarn link +COPY --from=builder /tmp/bitgo/modules/bitgo /var/modules/bitgo/ +RUN cd /var/modules/bitgo && yarn link +COPY --from=builder /tmp/bitgo/modules/abstract-eth /var/modules/abstract-eth/ +RUN cd /var/modules/abstract-eth && yarn link +COPY --from=builder /tmp/bitgo/modules/sdk-coin-eth /var/modules/sdk-coin-eth/ +RUN cd /var/modules/sdk-coin-eth && yarn link +COPY --from=builder /tmp/bitgo/modules/sdk-api /var/modules/sdk-api/ +RUN cd /var/modules/sdk-api && yarn link COPY --from=builder /tmp/bitgo/modules/sjcl /var/modules/sjcl/ RUN cd /var/modules/sjcl && yarn link COPY --from=builder /tmp/bitgo/modules/unspents /var/modules/unspents/ @@ -65,10 +65,14 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-dot /var/modules/sdk-coin-dot/ RUN cd /var/modules/sdk-coin-dot && yarn link COPY --from=builder /tmp/bitgo/modules/sdk-coin-etc /var/modules/sdk-coin-etc/ RUN cd /var/modules/sdk-coin-etc && yarn link +COPY --from=builder /tmp/bitgo/modules/sdk-coin-eth2 /var/modules/sdk-coin-eth2/ +RUN cd /var/modules/sdk-coin-eth2 && yarn link COPY --from=builder /tmp/bitgo/modules/sdk-coin-hbar /var/modules/sdk-coin-hbar/ RUN cd /var/modules/sdk-coin-hbar && yarn link COPY --from=builder /tmp/bitgo/modules/sdk-coin-near /var/modules/sdk-coin-near/ RUN cd /var/modules/sdk-coin-near && yarn link +COPY --from=builder /tmp/bitgo/modules/sdk-coin-polygon /var/modules/sdk-coin-polygon/ +RUN cd /var/modules/sdk-coin-polygon && yarn link COPY --from=builder /tmp/bitgo/modules/sdk-coin-rbtc /var/modules/sdk-coin-rbtc/ RUN cd /var/modules/sdk-coin-rbtc && yarn link COPY --from=builder /tmp/bitgo/modules/sdk-coin-sol /var/modules/sdk-coin-sol/ @@ -109,16 +113,16 @@ RUN cd /var/modules/sdk-coin-zec && yarn link #LINK_START RUN cd /var/bitgo-express && \ - yarn link bitgo && \ - yarn link @bitgo/abstract-eth && \ - yarn link @bitgo/sdk-coin-eth && \ - yarn link @bitgo/sdk-api && \ yarn link @bitgo/sdk-core && \ yarn link @bitgo/bls-dkg && \ yarn link @bitgo/statics && \ yarn link @bitgo/utxo-lib && \ yarn link @bitgo/blake2b && \ yarn link @bitgo/blake2b-wasm && \ + yarn link bitgo && \ + yarn link @bitgo/abstract-eth && \ + yarn link @bitgo/sdk-coin-eth && \ + yarn link @bitgo/sdk-api && \ yarn link @bitgo/sjcl && \ yarn link @bitgo/unspents && \ yarn link @bitgo/abstract-utxo && \ @@ -131,8 +135,10 @@ RUN cd /var/bitgo-express && \ yarn link @bitgo/sdk-coin-cspr && \ yarn link @bitgo/sdk-coin-dot && \ yarn link @bitgo/sdk-coin-etc && \ + yarn link @bitgo/sdk-coin-eth2 && \ yarn link @bitgo/sdk-coin-hbar && \ yarn link @bitgo/sdk-coin-near && \ + yarn link @bitgo/sdk-coin-polygon && \ yarn link @bitgo/sdk-coin-rbtc && \ yarn link @bitgo/sdk-coin-sol && \ yarn link @bitgo/sdk-coin-stx && \ @@ -153,6 +159,12 @@ RUN cd /var/bitgo-express && \ yarn link @bitgo/sdk-coin-zec #LINK_END +#LABEL_START +LABEL created="Mon, 18 Jul 2022 20:03:36 GMT" +LABEL version=9.12.0 +LABEL git_hash=973a8b01131f5958dd5b588a17dc4346b148acb3 +#LABEL_END + USER node ENV NODE_ENV production ENV BITGO_BIND 0.0.0.0 diff --git a/modules/abstract-eth/CHANGELOG.md b/modules/abstract-eth/CHANGELOG.md index 178a22e562..a0e9245f1d 100644 --- a/modules/abstract-eth/CHANGELOG.md +++ b/modules/abstract-eth/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.23](https://github.com/BitGo/BitGoJS/compare/@bitgo/abstract-eth@1.0.1-rc.21...@bitgo/abstract-eth@1.0.1-rc.23) (2022-07-19) + +**Note:** Version bump only for package @bitgo/abstract-eth + + + + + +## [1.0.1-rc.22](https://github.com/BitGo/BitGoJS/compare/@bitgo/abstract-eth@1.0.1-rc.21...@bitgo/abstract-eth@1.0.1-rc.22) (2022-07-18) + +**Note:** Version bump only for package @bitgo/abstract-eth + + + + + ## [1.0.1-rc.21](https://github.com/BitGo/BitGoJS/compare/@bitgo/abstract-eth@1.0.1-rc.20...@bitgo/abstract-eth@1.0.1-rc.21) (2022-07-15) **Note:** Version bump only for package @bitgo/abstract-eth diff --git a/modules/abstract-eth/package.json b/modules/abstract-eth/package.json index 0b6eeb067b..1da3fdaf6a 100644 --- a/modules/abstract-eth/package.json +++ b/modules/abstract-eth/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/abstract-eth", - "version": "1.0.1-rc.21", + "version": "1.0.1-rc.23", "description": "BitGo SDK coin library for ETH base implementation", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -38,9 +38,9 @@ ] }, "dependencies": { - "@bitgo/sdk-coin-eth": "^1.1.0-rc.1", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-coin-eth": "^1.1.0-rc.3", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "bignumber.js": "^8.0.1", "bip32": "^2.0.6" } diff --git a/modules/abstract-utxo/CHANGELOG.md b/modules/abstract-utxo/CHANGELOG.md index 4df6326146..abd02ee11d 100644 --- a/modules/abstract-utxo/CHANGELOG.md +++ b/modules/abstract-utxo/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/abstract-utxo@1.1.0-rc.4...@bitgo/abstract-utxo@1.1.0-rc.6) (2022-07-19) + +**Note:** Version bump only for package @bitgo/abstract-utxo + + + + + +# [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/abstract-utxo@1.1.0-rc.4...@bitgo/abstract-utxo@1.1.0-rc.5) (2022-07-18) + +**Note:** Version bump only for package @bitgo/abstract-utxo + + + + + # [1.1.0-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/abstract-utxo@1.1.0-rc.3...@bitgo/abstract-utxo@1.1.0-rc.4) (2022-07-15) **Note:** Version bump only for package @bitgo/abstract-utxo diff --git a/modules/abstract-utxo/package.json b/modules/abstract-utxo/package.json index 61e3206b9e..ab8cf92860 100644 --- a/modules/abstract-utxo/package.json +++ b/modules/abstract-utxo/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/abstract-utxo", - "version": "1.1.0-rc.4", + "version": "1.1.0-rc.6", "description": "BitGo SDK coin library for UTXO base implementation", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -39,8 +39,8 @@ }, "dependencies": { "@bitgo/blockapis": "^1.0.1-rc.17", - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/unspents": "^0.8.0-rc.15", "@bitgo/utxo-lib": "^2.3.0-rc.11", "@types/bluebird": "^3.5.25", diff --git a/modules/account-lib/CHANGELOG.md b/modules/account-lib/CHANGELOG.md index 99961bf972..b0f3bfa810 100644 --- a/modules/account-lib/CHANGELOG.md +++ b/modules/account-lib/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.20.0-rc.38](https://github.com/BitGo/BitGoJS/compare/@bitgo/account-lib@2.20.0-rc.36...@bitgo/account-lib@2.20.0-rc.38) (2022-07-19) + +**Note:** Version bump only for package @bitgo/account-lib + + + + + +# [2.20.0-rc.37](https://github.com/BitGo/BitGoJS/compare/@bitgo/account-lib@2.20.0-rc.36...@bitgo/account-lib@2.20.0-rc.37) (2022-07-18) + +**Note:** Version bump only for package @bitgo/account-lib + + + + + # [2.20.0-rc.36](https://github.com/BitGo/BitGoJS/compare/@bitgo/account-lib@2.20.0-rc.35...@bitgo/account-lib@2.20.0-rc.36) (2022-07-15) **Note:** Version bump only for package @bitgo/account-lib diff --git a/modules/account-lib/package.json b/modules/account-lib/package.json index 1aa147b166..5660aa10bc 100644 --- a/modules/account-lib/package.json +++ b/modules/account-lib/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/account-lib", - "version": "2.20.0-rc.36", + "version": "2.20.0-rc.38", "description": "BitGo's account library functions", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -32,37 +32,27 @@ "@bitgo/bls": "^0.1.0", "@bitgo/bls-dkg": "^1.1.0-rc.1", "@bitgo/ethereumjs-utils-old": "npm:ethereumjs-util@5.2.0", - "@bitgo/sdk-coin-algo": "^1.1.0-rc.14", - "@bitgo/sdk-coin-avaxc": "^1.1.0-rc.1", - "@bitgo/sdk-coin-avaxp": "^2.0.0-rc.2", - "@bitgo/sdk-coin-celo": "^1.1.0-rc.1", - "@bitgo/sdk-coin-cspr": "^1.0.1-rc.15", - "@bitgo/sdk-coin-dot": "^1.0.1-rc.1", - "@bitgo/sdk-coin-etc": "^1.0.1-rc.3", - "@bitgo/sdk-coin-eth": "^1.1.0-rc.1", - "@bitgo/sdk-coin-hbar": "^1.0.1-rc.1", - "@bitgo/sdk-coin-near": "^1.0.1-rc.3", - "@bitgo/sdk-coin-rbtc": "^1.1.0-rc.1", - "@bitgo/sdk-coin-sol": "^1.0.1-rc.3", - "@bitgo/sdk-coin-stx": "^1.1.0-rc.4", - "@bitgo/sdk-coin-trx": "^1.0.1-rc.3", - "@bitgo/sdk-coin-xtz": "^1.1.0-rc.4", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", - "@ethereumjs/common": "^2.4.0", - "@hashgraph/sdk": "~2.3.0", - "@noble/secp256k1": "git+https://github.com/brandonblack/noble-secp256k1.git#856129c06436fb696bab7d827edad5effdffaee2", - "@polkadot/api": "7.15.1", - "@stablelib/hex": "^1.0.0", - "@stablelib/sha384": "^1.0.0", - "@substrate/txwrapper-core": "1.5.9", - "@substrate/txwrapper-polkadot": "1.5.9", - "@taquito/local-forging": "6.3.5-beta.0", - "@taquito/signer": "6.3.5-beta.0", - "@types/lodash": "^4.14.151", + "@bitgo/sdk-coin-algo": "^1.1.0-rc.16", + "@bitgo/sdk-coin-avaxc": "^1.1.0-rc.3", + "@bitgo/sdk-coin-avaxp": "^2.0.0-rc.4", + "@bitgo/sdk-coin-celo": "^1.1.0-rc.3", + "@bitgo/sdk-coin-cspr": "^1.0.1-rc.17", + "@bitgo/sdk-coin-dot": "^1.0.1-rc.3", + "@bitgo/sdk-coin-etc": "^1.0.1-rc.5", + "@bitgo/sdk-coin-eth": "^1.1.0-rc.3", + "@bitgo/sdk-coin-eth2": "^1.0.1-rc.0", + "@bitgo/sdk-coin-hbar": "^1.0.1-rc.3", + "@bitgo/sdk-coin-near": "^1.1.0-rc.1", + "@bitgo/sdk-coin-polygon": "^1.0.1-rc.0", + "@bitgo/sdk-coin-rbtc": "^1.1.0-rc.3", + "@bitgo/sdk-coin-sol": "^1.0.1-rc.5", + "@bitgo/sdk-coin-stx": "^1.1.0-rc.6", + "@bitgo/sdk-coin-trx": "^1.0.1-rc.5", + "@bitgo/sdk-coin-xtz": "^1.1.0-rc.6", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "bignumber.js": "^9.0.0", - "bs58": "^4.0.1", - "ethereumjs-abi": "^0.6.5" + "bs58": "^4.0.1" }, "devDependencies": { "@solana/web3.js": "1.31.0", diff --git a/modules/account-lib/src/coin/xrp/index.ts b/modules/account-lib/src/coin/xrp/index.ts deleted file mode 100644 index f6bc90256e..0000000000 --- a/modules/account-lib/src/coin/xrp/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as Utils from './utils'; - -export { KeyPair } from './keyPair'; -export { TransactionBuilderFactory } from './transactionBuilderFactory'; -export { Utils }; diff --git a/modules/account-lib/src/coin/xrp/keyPair.ts b/modules/account-lib/src/coin/xrp/keyPair.ts deleted file mode 100644 index 112bdc05bc..0000000000 --- a/modules/account-lib/src/coin/xrp/keyPair.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { KeyPairOptions, Secp256k1ExtendedKeyPair } from '@bitgo/sdk-core'; - -export class KeyPair extends Secp256k1ExtendedKeyPair { - /** - * Public constructor. By default, creates a key pair with a random master seed. - * - * @param { KeyPairOptions } source Either a master seed, a private key, or a public key - */ - constructor(source?: KeyPairOptions) { - super(source); - } -} diff --git a/modules/account-lib/src/coin/xrp/transaction.ts b/modules/account-lib/src/coin/xrp/transaction.ts deleted file mode 100644 index 14bd959ceb..0000000000 --- a/modules/account-lib/src/coin/xrp/transaction.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { BaseKey, BaseTransaction, NotImplementedError } from '@bitgo/sdk-core'; - -export class Transaction extends BaseTransaction { - /** @inheritdoc */ - canSign(key: BaseKey): boolean { - throw new NotImplementedError('canSign not implemented'); - } - - /** @inheritdoc */ - toBroadcastFormat(): string { - throw new NotImplementedError('toBroadcastFormat not implemented'); - } - - /** @inheritdoc */ - toJson(): any { - throw new NotImplementedError('toJson not implemented'); - } -} diff --git a/modules/account-lib/src/coin/xrp/transactionBuilder.ts b/modules/account-lib/src/coin/xrp/transactionBuilder.ts deleted file mode 100644 index 92b8f33369..0000000000 --- a/modules/account-lib/src/coin/xrp/transactionBuilder.ts +++ /dev/null @@ -1,55 +0,0 @@ -import BigNumber from 'bignumber.js'; -import { BaseCoin as CoinConfig } from '@bitgo/statics'; -import { BaseAddress, BaseKey, BaseTransactionBuilder, NotImplementedError } from '@bitgo/sdk-core'; -import { Transaction } from './transaction'; - -export abstract class TransactionBuilder extends BaseTransactionBuilder { - private _transaction: Transaction; - - constructor(_coinConfig: Readonly) { - super(_coinConfig); - } - - /** - * Initialize the transaction builder fields using the decoded transaction data - * - * @param {Transaction} tx the transaction data - */ - initBuilder(tx: Transaction): void { - throw new NotImplementedError('initBuilder not implemented'); - } - - // region Getters and Setters - /** @inheritdoc */ - protected get transaction(): Transaction { - return this._transaction; - } - // endregion - - // region Validators - /** @inheritdoc */ - validateAddress(address: BaseAddress, addressFormat?: string): void { - throw new NotImplementedError('validateAddress not implemented'); - } - - /** @inheritdoc */ - validateKey(key: BaseKey): void { - throw new NotImplementedError('validateKey not implemented'); - } - - /** @inheritdoc */ - validateRawTransaction(rawTransaction: any): void { - throw new NotImplementedError('validateRawTransaction not implemented'); - } - - /** @inheritdoc */ - validateTransaction(transaction?: Transaction): void { - throw new NotImplementedError('validateTransaction not implemented'); - } - - /** @inheritdoc */ - validateValue(value: BigNumber): void { - throw new NotImplementedError('validateValue not implemented'); - } - // endregion -} diff --git a/modules/account-lib/src/coin/xrp/transactionBuilderFactory.ts b/modules/account-lib/src/coin/xrp/transactionBuilderFactory.ts deleted file mode 100644 index 08302fb5d3..0000000000 --- a/modules/account-lib/src/coin/xrp/transactionBuilderFactory.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { BaseCoin as CoinConfig } from '@bitgo/statics'; -import { BaseTransactionBuilderFactory, NotImplementedError } from '@bitgo/sdk-core'; -import { TransferBuilder } from './transferBuilder'; -import { WalletInitializationBuilder } from './walletInitializationBuilder'; -import { TransactionBuilder } from './transactionBuilder'; -import { Transaction } from './transaction'; - -export class TransactionBuilderFactory extends BaseTransactionBuilderFactory { - constructor(_coinConfig: Readonly) { - super(_coinConfig); - } - - /** @inheritdoc */ - from(raw: Uint8Array | string): TransactionBuilder { - throw new NotImplementedError('from not implemented'); - } - - /** @inheritdoc */ - getWalletInitializationBuilder(tx?: Transaction): WalletInitializationBuilder { - return TransactionBuilderFactory.initializeBuilder(tx, new WalletInitializationBuilder(this._coinConfig)); - } - - /** @inheritdoc */ - getTransferBuilder(tx?: Transaction): TransferBuilder { - return TransactionBuilderFactory.initializeBuilder(tx, new TransferBuilder(this._coinConfig)); - } - - /** - * Initialize the builder with the given transaction - * - * @param {Transaction | undefined} tx - the transaction used to initialize the builder - * @param {TransactionBuilder} builder - the builder to be initialized - * @returns {TransactionBuilder} the builder initialized - */ - private static initializeBuilder(tx: Transaction | undefined, builder: T): T { - if (tx) { - builder.initBuilder(tx); - } - return builder; - } -} diff --git a/modules/account-lib/src/coin/xrp/transferBuilder.ts b/modules/account-lib/src/coin/xrp/transferBuilder.ts deleted file mode 100644 index 4625f31e93..0000000000 --- a/modules/account-lib/src/coin/xrp/transferBuilder.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { BaseCoin as CoinConfig } from '@bitgo/statics'; -import { BaseKey, NotImplementedError } from '@bitgo/sdk-core'; -import { TransactionBuilder } from './transactionBuilder'; -import { Transaction } from './transaction'; - -export class TransferBuilder extends TransactionBuilder { - constructor(_coinConfig: Readonly) { - super(_coinConfig); - } - - /** @inheritdoc */ - protected async buildImplementation(): Promise { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - protected fromImplementation(rawTransaction: any): Transaction { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - protected signImplementation(key: BaseKey): Transaction { - throw new NotImplementedError('method not implemented'); - } -} diff --git a/modules/account-lib/src/coin/xrp/utils.ts b/modules/account-lib/src/coin/xrp/utils.ts deleted file mode 100644 index f426d95a0f..0000000000 --- a/modules/account-lib/src/coin/xrp/utils.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { BaseUtils, NotImplementedError } from '@bitgo/sdk-core'; - -export class Utils implements BaseUtils { - /** @inheritdoc */ - isValidAddress(address: string): boolean { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - isValidBlockId(hash: string): boolean { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - isValidPrivateKey(key: string): boolean { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - isValidPublicKey(key: string): boolean { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - isValidSignature(signature: string): boolean { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - isValidTransactionId(txId: string): boolean { - throw new NotImplementedError('method not implemented'); - } -} diff --git a/modules/account-lib/src/coin/xrp/walletInitializationBuilder.ts b/modules/account-lib/src/coin/xrp/walletInitializationBuilder.ts deleted file mode 100644 index 5f755d513b..0000000000 --- a/modules/account-lib/src/coin/xrp/walletInitializationBuilder.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { BaseCoin as CoinConfig } from '@bitgo/statics'; -import { BaseKey, NotImplementedError } from '@bitgo/sdk-core'; -import { Transaction } from './transaction'; -import { TransactionBuilder } from './transactionBuilder'; - -export class WalletInitializationBuilder extends TransactionBuilder { - constructor(_coinConfig: Readonly) { - super(_coinConfig); - } - - /** @inheritdoc */ - protected async buildImplementation(): Promise { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - protected fromImplementation(rawTransaction: any): Transaction { - throw new NotImplementedError('method not implemented'); - } - - /** @inheritdoc */ - protected signImplementation(key: BaseKey): Transaction { - throw new NotImplementedError('method not implemented'); - } -} diff --git a/modules/account-lib/src/index.ts b/modules/account-lib/src/index.ts index 2239eab420..e9d25caeca 100644 --- a/modules/account-lib/src/index.ts +++ b/modules/account-lib/src/index.ts @@ -35,7 +35,7 @@ export { Xtz }; import * as Eth from '@bitgo/sdk-coin-eth'; export { Eth }; -import * as Eth2 from './coin/eth2'; +import * as Eth2 from '@bitgo/sdk-coin-eth2'; export { Eth2 }; import * as Etc from '@bitgo/sdk-coin-etc'; @@ -56,9 +56,6 @@ export { Hbar }; import { CsprLib as Cspr } from '@bitgo/sdk-coin-cspr'; export { Cspr }; -import * as Xrp from './coin/xrp'; -export { Xrp }; - import { StxLib as Stx } from '@bitgo/sdk-coin-stx'; export { Stx }; @@ -77,7 +74,7 @@ export { Dot }; import * as Near from '@bitgo/sdk-coin-near'; export { Near }; -import * as Polygon from './coin/polygon'; +import * as Polygon from '@bitgo/sdk-coin-polygon'; export { Polygon }; const coinBuilderMap = { @@ -102,8 +99,6 @@ const coinBuilderMap = { thbar: Hbar.TransactionBuilderFactory, cspr: Cspr.TransactionBuilderFactory, tcspr: Cspr.TransactionBuilderFactory, - xrp: Xrp.TransactionBuilderFactory, - txrp: Xrp.TransactionBuilderFactory, stx: Stx.TransactionBuilderFactory, tstx: Stx.TransactionBuilderFactory, algo: Algo.TransactionBuilderFactory, diff --git a/modules/account-lib/test/unit/keyPair/index.ts b/modules/account-lib/test/unit/keyPair/index.ts index 51e6adb286..9b4b9c4d1c 100644 --- a/modules/account-lib/test/unit/keyPair/index.ts +++ b/modules/account-lib/test/unit/keyPair/index.ts @@ -6,7 +6,7 @@ import { register } from '../../../src/keyPair'; import * as coinModules from '../../../src'; import { coins } from '@bitgo/statics'; import { KeyPair as EthKeyPair } from '@bitgo/sdk-coin-eth'; -import { KeyPair as Eth2KeyPair } from '../../../src/coin/eth2'; +import { KeyPair as Eth2KeyPair } from '@bitgo/sdk-coin-eth2'; import { Ed25519KeyPair } from '@bitgo/sdk-core'; describe('Key Pair Factory', () => { diff --git a/modules/account-lib/tsconfig.json b/modules/account-lib/tsconfig.json index df6018af9b..e5dcd2d61e 100644 --- a/modules/account-lib/tsconfig.json +++ b/modules/account-lib/tsconfig.json @@ -31,6 +31,9 @@ { "path": "../sdk-coin-eth" }, + { + "path": "../sdk-coin-eth2" + }, { "path": "../sdk-coin-dot" }, @@ -40,6 +43,9 @@ { "path": "../sdk-coin-near" }, + { + "path": "../sdk-coin-polygon" + }, { "path": "../sdk-coin-rbtc" }, diff --git a/modules/bitgo/CHANGELOG.md b/modules/bitgo/CHANGELOG.md index c3cb7f59d9..d745dbbf98 100644 --- a/modules/bitgo/CHANGELOG.md +++ b/modules/bitgo/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [14.2.0-rc.42](https://github.com/BitGo/BitGoJS/compare/bitgo@14.2.0-rc.40...bitgo@14.2.0-rc.42) (2022-07-19) + + +### Features + +* **sdk-coin-ada:** implement key pair and utils for ada sdk ([9a1aabb](https://github.com/BitGo/BitGoJS/commit/9a1aabb8a07b5787ab3fa645c29be1b940694892)) + + + + + +# [14.2.0-rc.41](https://github.com/BitGo/BitGoJS/compare/bitgo@14.2.0-rc.40...bitgo@14.2.0-rc.41) (2022-07-18) + +**Note:** Version bump only for package bitgo + + + + + # [14.2.0-rc.40](https://github.com/BitGo/BitGoJS/compare/bitgo@14.2.0-rc.39...bitgo@14.2.0-rc.40) (2022-07-15) **Note:** Version bump only for package bitgo diff --git a/modules/bitgo/package.json b/modules/bitgo/package.json index 84484e3551..4c25e8fbc0 100644 --- a/modules/bitgo/package.json +++ b/modules/bitgo/package.json @@ -1,6 +1,6 @@ { "name": "bitgo", - "version": "14.2.0-rc.40", + "version": "14.2.0-rc.42", "description": "BitGo JavaScript SDK", "main": "./dist/src/index.js", "types": "./dist/types/src/index.d.ts", @@ -45,42 +45,44 @@ "gen-docs": "typedoc" }, "dependencies": { - "@bitgo/abstract-eth": "^1.0.1-rc.21", - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/account-lib": "^2.20.0-rc.36", + "@bitgo/abstract-eth": "^1.0.1-rc.23", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/account-lib": "^2.20.0-rc.38", "@bitgo/blockapis": "^1.0.1-rc.17", - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-coin-ada": "^1.1.0-rc.5", - "@bitgo/sdk-coin-algo": "^1.1.0-rc.14", - "@bitgo/sdk-coin-avaxc": "^1.1.0-rc.1", - "@bitgo/sdk-coin-avaxp": "^2.0.0-rc.2", - "@bitgo/sdk-coin-bch": "^1.1.0-rc.5", - "@bitgo/sdk-coin-bcha": "^1.1.0-rc.5", - "@bitgo/sdk-coin-bsv": "^1.1.0-rc.5", - "@bitgo/sdk-coin-btc": "^1.0.1-rc.8", - "@bitgo/sdk-coin-btg": "^1.1.0-rc.5", - "@bitgo/sdk-coin-celo": "^1.1.0-rc.1", - "@bitgo/sdk-coin-cspr": "^1.0.1-rc.15", - "@bitgo/sdk-coin-dash": "^1.1.0-rc.6", - "@bitgo/sdk-coin-doge": "^1.0.1-rc.3", - "@bitgo/sdk-coin-dot": "^1.0.1-rc.1", - "@bitgo/sdk-coin-eos": "^1.0.1-rc.1", - "@bitgo/sdk-coin-etc": "^1.0.1-rc.3", - "@bitgo/sdk-coin-eth": "^1.1.0-rc.1", - "@bitgo/sdk-coin-hbar": "^1.0.1-rc.1", - "@bitgo/sdk-coin-ltc": "^1.1.0-rc.5", - "@bitgo/sdk-coin-near": "^1.0.1-rc.3", - "@bitgo/sdk-coin-rbtc": "^1.1.0-rc.1", - "@bitgo/sdk-coin-sol": "^1.0.1-rc.3", - "@bitgo/sdk-coin-stx": "^1.1.0-rc.4", - "@bitgo/sdk-coin-trx": "^1.0.1-rc.3", - "@bitgo/sdk-coin-xlm": "^1.0.1-rc.1", - "@bitgo/sdk-coin-xrp": "^1.1.0-rc.21", - "@bitgo/sdk-coin-xtz": "^1.1.0-rc.4", - "@bitgo/sdk-coin-zec": "^1.1.0-rc.7", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-coin-ada": "^1.1.0-rc.7", + "@bitgo/sdk-coin-algo": "^1.1.0-rc.16", + "@bitgo/sdk-coin-avaxc": "^1.1.0-rc.3", + "@bitgo/sdk-coin-avaxp": "^2.0.0-rc.4", + "@bitgo/sdk-coin-bch": "^1.1.0-rc.7", + "@bitgo/sdk-coin-bcha": "^1.1.0-rc.7", + "@bitgo/sdk-coin-bsv": "^1.1.0-rc.7", + "@bitgo/sdk-coin-btc": "^1.0.1-rc.10", + "@bitgo/sdk-coin-btg": "^1.1.0-rc.7", + "@bitgo/sdk-coin-celo": "^1.1.0-rc.3", + "@bitgo/sdk-coin-cspr": "^1.0.1-rc.17", + "@bitgo/sdk-coin-dash": "^1.1.0-rc.8", + "@bitgo/sdk-coin-doge": "^1.0.1-rc.5", + "@bitgo/sdk-coin-dot": "^1.0.1-rc.3", + "@bitgo/sdk-coin-eos": "^1.0.1-rc.3", + "@bitgo/sdk-coin-etc": "^1.0.1-rc.5", + "@bitgo/sdk-coin-eth": "^1.1.0-rc.3", + "@bitgo/sdk-coin-eth2": "^1.0.1-rc.0", + "@bitgo/sdk-coin-hbar": "^1.0.1-rc.3", + "@bitgo/sdk-coin-ltc": "^1.1.0-rc.7", + "@bitgo/sdk-coin-near": "^1.1.0-rc.1", + "@bitgo/sdk-coin-polygon": "^1.0.1-rc.0", + "@bitgo/sdk-coin-rbtc": "^1.1.0-rc.3", + "@bitgo/sdk-coin-sol": "^1.0.1-rc.5", + "@bitgo/sdk-coin-stx": "^1.1.0-rc.6", + "@bitgo/sdk-coin-trx": "^1.0.1-rc.5", + "@bitgo/sdk-coin-xlm": "^1.0.1-rc.3", + "@bitgo/sdk-coin-xrp": "^1.1.0-rc.23", + "@bitgo/sdk-coin-xtz": "^1.1.0-rc.6", + "@bitgo/sdk-coin-zec": "^1.1.0-rc.9", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/sjcl": "^1.0.1", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/statics": "^7.0.0-rc.4", "@bitgo/unspents": "^0.8.0-rc.15", "@bitgo/utxo-lib": "^2.3.0-rc.11", "@types/bluebird": "^3.5.25", @@ -107,7 +109,7 @@ "superagent": "^3.8.3" }, "devDependencies": { - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-test": "^1.0.1-rc.19", "@types/create-hmac": "^1.1.0", "@types/debug": "^4.1.4", "@types/jasmine": "^3.5.12", diff --git a/modules/bitgo/src/v2/coinFactory.ts b/modules/bitgo/src/v2/coinFactory.ts index d731646a6b..b6c5eb8501 100644 --- a/modules/bitgo/src/v2/coinFactory.ts +++ b/modules/bitgo/src/v2/coinFactory.ts @@ -5,7 +5,6 @@ import { CoinFactory } from '@bitgo/sdk-core'; import { AlgoToken } from '@bitgo/sdk-coin-algo'; import { Bcha, Tbcha } from '@bitgo/sdk-coin-bcha'; import { - Ada, Algo, AvaxC, AvaxCToken, @@ -40,7 +39,6 @@ import { StellarToken, Stx, Susd, - Tada, Talgo, TavaxC, TavaxP, @@ -83,7 +81,6 @@ import { SolToken } from '@bitgo/sdk-coin-sol'; import { HbarToken } from '@bitgo/sdk-coin-hbar'; function registerCoinConstructors(globalCoinFactory: CoinFactory): void { - globalCoinFactory.register('ada', Ada.createInstance); globalCoinFactory.register('algo', Algo.createInstance); globalCoinFactory.register('avaxc', AvaxC.createInstance); globalCoinFactory.register('avaxp', AvaxP.createInstance); @@ -114,7 +111,6 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void { globalCoinFactory.register('sol', Sol.createInstance); globalCoinFactory.register('stx', Stx.createInstance); globalCoinFactory.register('susd', Susd.createInstance); - globalCoinFactory.register('tada', Tada.createInstance); globalCoinFactory.register('talgo', Talgo.createInstance); globalCoinFactory.register('tavaxc', TavaxC.createInstance); globalCoinFactory.register('tavaxp', TavaxP.createInstance); diff --git a/modules/bitgo/src/v2/coins/index.ts b/modules/bitgo/src/v2/coins/index.ts index f3f3f84b60..ff8a411ceb 100644 --- a/modules/bitgo/src/v2/coins/index.ts +++ b/modules/bitgo/src/v2/coins/index.ts @@ -2,8 +2,6 @@ import { AbstractUtxoCoin } from '@bitgo/abstract-utxo'; export { AbstractUtxoCoin }; import { Algo, AlgoToken, Talgo } from '@bitgo/sdk-coin-algo'; export { Algo, AlgoToken, Talgo }; -import { Ada, Tada } from '@bitgo/sdk-coin-ada'; -export { Ada, Tada }; import { AvaxC, TavaxC, AvaxCToken } from '@bitgo/sdk-coin-avaxc'; export { AvaxC, TavaxC, AvaxCToken }; import { AvaxP, TavaxP } from '@bitgo/sdk-coin-avaxp'; @@ -30,12 +28,16 @@ import { EosToken, Eos, Teos } from '@bitgo/sdk-coin-eos'; export { EosToken, Eos, Teos }; import { Erc20Token, Eth, Gteth, Teth } from '@bitgo/sdk-coin-eth'; export { Erc20Token, Eth, Gteth, Teth }; +import { Eth2, Teth2 } from '@bitgo/sdk-coin-eth2'; +export { Eth2, Teth2 }; import { Etc, Tetc } from '@bitgo/sdk-coin-etc'; export { Etc, Tetc }; import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar'; export { Hbar, Thbar }; import { Ltc, Tltc } from '@bitgo/sdk-coin-ltc'; export { Ltc, Tltc }; +import { Polygon, Tpolygon } from '@bitgo/sdk-coin-polygon'; +export { Polygon, Tpolygon }; import { Rbtc, Trbtc } from '@bitgo/sdk-coin-rbtc'; export { Rbtc, Trbtc }; import { Sol, Tsol } from '@bitgo/sdk-coin-sol'; @@ -53,17 +55,6 @@ export { Xtz, Txtz }; import { Zec, Tzec } from '@bitgo/sdk-coin-zec'; export { Zec, Tzec }; -export { Eth2 } from './eth2'; -export { Ofc } from './ofc'; // TODO: SDKT-15: make abstract and remove from exported list -export { OfcToken } from './ofcToken'; -export { Susd } from './susd'; -export { FiatUsd } from './fiatusd'; -export { FiatEur } from './fiateur'; -export { FiatGBP } from './fiatgbp'; -export { Teth2 } from './teth2'; -export { Tsusd } from './tsusd'; -export { TfiatUsd } from './tfiatusd'; -export { TfiatEur } from './tfiateur'; -export { TfiatGBP } from './tfiatgbp'; -export { Polygon } from './polygon'; -export { Tpolygon } from './tpolygon'; +import { coins } from '@bitgo/sdk-core'; +const { Ofc, OfcToken, Susd, FiatUsd, FiatEur, FiatGBP, Tsusd, TfiatUsd, TfiatEur, TfiatGBP } = coins; +export { Ofc, OfcToken, Susd, FiatUsd, FiatEur, FiatGBP, Tsusd, TfiatUsd, TfiatEur, TfiatGBP }; diff --git a/modules/bitgo/tsconfig.json b/modules/bitgo/tsconfig.json index 01a9c6b705..82c3dea0dd 100644 --- a/modules/bitgo/tsconfig.json +++ b/modules/bitgo/tsconfig.json @@ -66,6 +66,9 @@ { "path": "../sdk-coin-doge" }, + { + "path": "../sdk-coin-dot" + }, { "path": "../sdk-coin-eos" }, @@ -76,7 +79,7 @@ "path": "../sdk-coin-eth" }, { - "path": "../sdk-coin-dot" + "path": "../sdk-coin-eth2" }, { "path": "../sdk-coin-hbar" @@ -87,6 +90,9 @@ { "path": "../sdk-coin-near" }, + { + "path": "../sdk-coin-polygon" + }, { "path": "../sdk-coin-rbtc" }, diff --git a/modules/express/CHANGELOG.md b/modules/express/CHANGELOG.md index fc666fb345..2f345ccb03 100644 --- a/modules/express/CHANGELOG.md +++ b/modules/express/CHANGELOG.md @@ -3,6 +3,26 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [9.12.4-rc.26](https://github.com/BitGo/BitGoJS/compare/@bitgo/express@9.12.4-rc.24...@bitgo/express@9.12.4-rc.26) (2022-07-19) + + +### Bug Fixes + +* **express:** allow account consolidations ([ede16e5](https://github.com/BitGo/BitGoJS/commit/ede16e57f5dac7319a02d10e084ae47972709591)) +* update bad dependency match ([5cc3255](https://github.com/BitGo/BitGoJS/commit/5cc3255aecba1ffb112da3ba10d8d36d2074b3e3)) + + + + + +## [9.12.4-rc.25](https://github.com/BitGo/BitGoJS/compare/@bitgo/express@9.12.4-rc.24...@bitgo/express@9.12.4-rc.25) (2022-07-18) + +**Note:** Version bump only for package @bitgo/express + + + + + ## [9.12.4-rc.24](https://github.com/BitGo/BitGoJS/compare/@bitgo/express@9.12.4-rc.23...@bitgo/express@9.12.4-rc.24) (2022-07-15) **Note:** Version bump only for package @bitgo/express diff --git a/modules/express/package.json b/modules/express/package.json index 726887830b..bab4b99ed4 100644 --- a/modules/express/package.json +++ b/modules/express/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/express", - "version": "9.12.4-rc.24", + "version": "9.12.4-rc.26", "private": true, "description": "Local signing server and proxy for the BitGo platform", "main": "./dist/src/index.js", @@ -38,8 +38,10 @@ "fmt": "yarn prettier --write '{src,test}/**/*.{ts,js,json}'" }, "dependencies": { + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "argparse": "^1.0.10", - "bitgo": "^14.2.0-rc.40", + "bitgo": "^14.2.0-rc.42", "bluebird": "^3.5.3", "body-parser": "^1.19.0", "connect-timeout": "^1.9.0", diff --git a/modules/express/src/clientRoutes.ts b/modules/express/src/clientRoutes.ts index 303c1db5cb..66b504441a 100755 --- a/modules/express/src/clientRoutes.ts +++ b/modules/express/src/clientRoutes.ts @@ -2,7 +2,6 @@ * @prettier */ import { UnsupportedCoinError } from '@bitgo/sdk-core'; -import { CoinFamily } from '@bitgo/statics'; import { BitGo, BitGoOptions, Coin, CustomSigningFunction, SignedTransaction } from 'bitgo'; import * as bodyParser from 'body-parser'; import * as debugLib from 'debug'; @@ -547,7 +546,7 @@ export async function handleV2ConsolidateAccount(req: express.Request) { throw new Error('consolidate address must be an array of addresses'); } - if (coin.getFamily() !== CoinFamily.ALGO && coin.getFamily() !== CoinFamily.XTZ) { + if (!coin.allowsAccountConsolidations()) { throw new Error('invalid coin selected'); } diff --git a/modules/express/test/unit/clientRoutes/consolidateAccount.ts b/modules/express/test/unit/clientRoutes/consolidateAccount.ts index 4a0fe77014..c3d95efa0d 100644 --- a/modules/express/test/unit/clientRoutes/consolidateAccount.ts +++ b/modules/express/test/unit/clientRoutes/consolidateAccount.ts @@ -1,4 +1,3 @@ -import { CoinFamily } from '@bitgo/statics'; import * as sinon from 'sinon'; import 'should-http'; @@ -12,8 +11,8 @@ import { handleV2ConsolidateAccount } from '../../../src/clientRoutes'; import { BitGo } from 'bitgo'; describe('Consolidate account', () => { - it('should fail if coin is not algo or tezos', async () => { - const coinStub = sinon.stub().returns({ getFamily: () => CoinFamily.BTC }); + it('should fail if coin does not allow consolidation', async () => { + const coinStub = sinon.stub().returns({ allowsAccountConsolidations: () => false }); const stubBitgo = sinon.createStubInstance(BitGo as any, { coin: coinStub }); const mockRequest = { @@ -31,29 +30,9 @@ describe('Consolidate account', () => { .should.be.rejectedWith('invalid coin selected'); }); - it('should pass if coin is algo', async () => { + it('should pass if coin allows consolidation', async () => { const result = { failure: [] }; - const { bitgoStub, consolidationStub } = createConsolidateMocks(result, CoinFamily.ALGO); - - const mockRequest = { - bitgo: bitgoStub, - params: { - coin: 'talgo', - id: '23423423423423', - }, - body: { - consolidateAddresses: ['someAddr'], - }, - }; - - await handleV2ConsolidateAccount(mockRequest as express.Request & typeof mockRequest) - .should.be.resolvedWith(result); - consolidationStub.should.be.calledOnceWith(mockRequest.body); - }); - - it('should pass if coin is xtz', async () => { - const result = { failure: [] }; - const { bitgoStub, consolidationStub } = createConsolidateMocks(result, CoinFamily.XTZ); + const { bitgoStub, consolidationStub } = createConsolidateMocks(result, true); const mockRequest = { bitgo: bitgoStub, @@ -89,11 +68,11 @@ describe('Consolidate account', () => { .should.be.rejectedWith('consolidate address must be an array of addresses'); }); - function createConsolidateMocks(res, coin = CoinFamily.ALGO) { + function createConsolidateMocks(res, allowsAccountConsolidations = false) { const consolidationStub = sinon.stub().returns(res); const walletStub = { sendAccountConsolidations: consolidationStub }; const coinStub = { - getFamily: () => coin, + allowsAccountConsolidations: () => allowsAccountConsolidations, wallets: () => ({ get: () => Promise.resolve(walletStub) }), }; return { @@ -105,7 +84,7 @@ describe('Consolidate account', () => { it('should return 400 when all transactions fail', async () => { const result = { success: [], failure: [0] }; const body = 'testbody'; - const { bitgoStub, consolidationStub } = createConsolidateMocks(result); + const { bitgoStub, consolidationStub } = createConsolidateMocks(result, true); const mockRequest = { bitgo: bitgoStub, params: { @@ -122,7 +101,7 @@ describe('Consolidate account', () => { it('should return 202 when some transactions fail', async () => { const result = { success: [0], failure: [0] }; const body = 'testbody'; - const { bitgoStub, consolidationStub } = createConsolidateMocks(result); + const { bitgoStub, consolidationStub } = createConsolidateMocks(result, true); const mockRequest = { bitgo: bitgoStub, params: { @@ -139,7 +118,7 @@ describe('Consolidate account', () => { it('should return 200 when all transactions succeed', async () => { const result = { failure: [] }; const body = 'testbody'; - const { bitgoStub, consolidationStub } = createConsolidateMocks(result); + const { bitgoStub, consolidationStub } = createConsolidateMocks(result, true); const mockRequest = { bitgo: bitgoStub, params: { diff --git a/modules/express/tsconfig.json b/modules/express/tsconfig.json index fe90ad1f24..7523bf8654 100644 --- a/modules/express/tsconfig.json +++ b/modules/express/tsconfig.json @@ -10,6 +10,12 @@ "references": [ { "path": "../bitgo" + }, + { + "path": "../sdk-core" + }, + { + "path": "../statics" } ] } diff --git a/modules/sdk-api/CHANGELOG.md b/modules/sdk-api/CHANGELOG.md index 057da9804d..591ed1af24 100644 --- a/modules/sdk-api/CHANGELOG.md +++ b/modules/sdk-api/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.33](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-api@1.1.0-rc.31...@bitgo/sdk-api@1.1.0-rc.33) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-api + + + + + +# [1.1.0-rc.32](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-api@1.1.0-rc.31...@bitgo/sdk-api@1.1.0-rc.32) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-api + + + + + # [1.1.0-rc.31](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-api@1.1.0-rc.30...@bitgo/sdk-api@1.1.0-rc.31) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-api diff --git a/modules/sdk-api/package.json b/modules/sdk-api/package.json index e9ef2662de..61bb44e817 100644 --- a/modules/sdk-api/package.json +++ b/modules/sdk-api/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-api", - "version": "1.1.0-rc.31", + "version": "1.1.0-rc.33", "description": "REST wrapper for BitGoJS", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -51,7 +51,7 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/sjcl": "^1.0.1", "@bitgo/unspents": "^0.8.0-rc.15", "@bitgo/utxo-lib": "^2.3.0-rc.11", diff --git a/modules/sdk-coin-ada/CHANGELOG.md b/modules/sdk-coin-ada/CHANGELOG.md index c4cd736b0e..4a82939108 100644 --- a/modules/sdk-coin-ada/CHANGELOG.md +++ b/modules/sdk-coin-ada/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@1.1.0-rc.5...@bitgo/sdk-coin-ada@1.1.0-rc.7) (2022-07-19) + + +### Features + +* **sdk-coin-ada:** implement key pair and utils for ada sdk ([9a1aabb](https://github.com/BitGo/BitGoJS/commit/9a1aabb8a07b5787ab3fa645c29be1b940694892)) + + + + + +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@1.1.0-rc.5...@bitgo/sdk-coin-ada@1.1.0-rc.6) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-ada + + + + + # [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@1.1.0-rc.4...@bitgo/sdk-coin-ada@1.1.0-rc.5) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-ada diff --git a/modules/sdk-coin-ada/package.json b/modules/sdk-coin-ada/package.json index ef46ce0ff9..996768a645 100644 --- a/modules/sdk-coin-ada/package.json +++ b/modules/sdk-coin-ada/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-ada", - "version": "1.1.0-rc.5", + "version": "1.1.0-rc.7", "description": "BitGo SDK coin library for Ada", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,11 +41,13 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", + "@emurgo/cardano-serialization-lib-browser": "^10.2.0", + "@emurgo/cardano-serialization-lib-nodejs": "^10.2.0", "bignumber.js": "^9.0.2" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31" + "@bitgo/sdk-api": "^1.1.0-rc.33" } } diff --git a/modules/sdk-coin-ada/src/keyPair.ts b/modules/sdk-coin-ada/src/keyPair.ts index 911c3549da..983c7987e2 100644 --- a/modules/sdk-coin-ada/src/keyPair.ts +++ b/modules/sdk-coin-ada/src/keyPair.ts @@ -1,4 +1,11 @@ -import { DefaultKeys, KeyPairOptions, Ed25519KeyPair, AddressFormat } from '@bitgo/sdk-core'; +import { DefaultKeys, KeyPairOptions, Ed25519KeyPair, toHex, AddressFormat } from '@bitgo/sdk-core'; +import { + PublicKey, + PrivateKey, + EnterpriseAddress, + NetworkInfo, + StakeCredential, +} from '@emurgo/cardano-serialization-lib-nodejs'; export class KeyPair extends Ed25519KeyPair { /** @@ -11,18 +18,42 @@ export class KeyPair extends Ed25519KeyPair { super(source); } - getAddress(format?: AddressFormat): string { - throw new Error('Method not implemented.'); + /** + * @returns { Address } + */ + getAddress(format): string { + const bytesFromHex = new Uint8Array(Buffer.from(this.keyPair.pub, 'hex')); + const pubKey = PublicKey.from_bytes(bytesFromHex); + let enterpriseAddress; + if (format === AddressFormat.testnet) { + enterpriseAddress = EnterpriseAddress.new( + NetworkInfo.testnet().network_id(), + StakeCredential.from_keyhash(pubKey.hash()) + ); + } else if (format === AddressFormat.mainnet) { + enterpriseAddress = EnterpriseAddress.new( + NetworkInfo.mainnet().network_id(), + StakeCredential.from_keyhash(pubKey.hash()) + ); + } + return enterpriseAddress.to_address().to_bech32(); } getKeys(): DefaultKeys { - throw new Error('Method not implemented.'); + const result: DefaultKeys = { pub: this.keyPair.pub }; + if (this.keyPair.prv) { + result.prv = this.keyPair.prv; + } + return result; } recordKeysFromPrivateKeyInProtocolFormat(prv: string): DefaultKeys { - throw new Error('Method not implemented.'); + const rawPrv = PrivateKey.from_bech32(prv).as_bytes(); + return new KeyPair({ prv: toHex(rawPrv) }).keyPair; } - recordKeysFromPublicKeyInProtocolFormat(prv: string): DefaultKeys { - throw new Error('Method not implemented.'); + + recordKeysFromPublicKeyInProtocolFormat(pub: string): DefaultKeys { + const rawPub = PublicKey.from_bech32(pub).as_bytes(); + return { pub: toHex(rawPub) }; } } diff --git a/modules/sdk-coin-ada/src/utils.ts b/modules/sdk-coin-ada/src/utils.ts index 2786428395..09b6936407 100644 --- a/modules/sdk-coin-ada/src/utils.ts +++ b/modules/sdk-coin-ada/src/utils.ts @@ -1,35 +1,68 @@ -import { BaseUtils, NotImplementedError } from '@bitgo/sdk-core'; +import { BaseUtils } from '@bitgo/sdk-core'; +import { Ed25519Signature, Address } from '@emurgo/cardano-serialization-lib-nodejs'; +import { KeyPair } from './keyPair'; export class Utils implements BaseUtils { - /** @inheritdoc */ + validateBlake2b(hash: string): boolean { + if (hash.length !== 64) { + return false; + } + return hash.match(/^[a-zA-Z0-9]+$/) !== null; + } + /** @inheritdoc */ isValidAddress(address: string): boolean { - throw new NotImplementedError('method not implemented'); + try { + Address.from_bech32(address); + return true; + } catch (err) { + return false; + } } /** @inheritdoc */ isValidBlockId(hash: string): boolean { - throw new NotImplementedError('method not implemented'); + return this.validateBlake2b(hash); } /** @inheritdoc */ isValidPrivateKey(key: string): boolean { - throw new NotImplementedError('method not implemented'); + // this will return true for both extended and non-extended ED25519 keys + return this.isValidKey(key); + } + + isValidKey(key: string): boolean { + try { + new KeyPair({ prv: key }); + return true; + } catch { + return false; + } } /** @inheritdoc */ - isValidPublicKey(key: string): boolean { - throw new NotImplementedError('method not implemented'); + isValidPublicKey(pubKey: string): boolean { + try { + new KeyPair({ pub: pubKey }); + return true; + } catch { + return false; + } } /** @inheritdoc */ isValidSignature(signature: string): boolean { - throw new NotImplementedError('method not implemented'); + try { + Ed25519Signature.from_hex(signature); + return true; + } catch (err) { + return false; + } } /** @inheritdoc */ isValidTransactionId(txId: string): boolean { - throw new NotImplementedError('method not implemented'); + return this.validateBlake2b(txId); } } diff --git a/modules/sdk-coin-ada/test/integration/index.ts b/modules/sdk-coin-ada/test/integration/index.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/sdk-coin-ada/test/resources/index.ts b/modules/sdk-coin-ada/test/resources/index.ts new file mode 100644 index 0000000000..1fa1d5d608 --- /dev/null +++ b/modules/sdk-coin-ada/test/resources/index.ts @@ -0,0 +1,79 @@ +export const address = { + address1: 'stake1vpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5egfu2p0u', + address2: + 'addr_test1qzpu9dmeztx7sfrl4qqtw3rvcewt822wn8mnatv8uc5yzdmvvz7nw9gmznn65g4ksrrfvyzhz52knc3mqxdyya47gz2q83wks3', + address3: + '37btjrVyb4KDXBNC4haBVPCrro8AQPHwvCMp3RFhhSVWwfFmZ6wwzSK6JK1hY6wHNmtrpTf1kdbva8TCneM2YsiXT7mrzT21EacHnPpz5YyUdj64na', + address4: 'addr_test1vr8rakm66rcfv4fcxqykg5lf0yv7lsyk9mvapx369jpvtcgfcuk7f', +}; + +export const blockHash = { + hash1: '24bf2cf83bc3b1819a4395ef4d9d3b60d687bfa53a9bf4c6c55acbf11e85ea03', + hash2: '59548738f2096318ab745e8252b62ac24fd9ab38379777513977a2315af21580', +}; + +export const signatures = { + signature1: + 'ed25519_sig14swpdlus75gyq6nsgagyq2dwwawzm463mddq2epmw98s4evq6cqc87sgzlfe2ks979kfuktwvqyveh38gl5f6mvxsl98tfpgksd6xzsrucym0', + signature2: + 'ed25519_sig1cqhp5j32e8tt8w7jqgpdcppuhqlwntuwk8duyj4lvjj4t687ws2t5ckzhfegfez6zls3kd4we3f48kwvwx03v8uktjuceuyg98crvqcy7jd5x', +}; + +export const txIds = { + hash1: 'e2d6ef426b378626599c5723f685a8ecf28940a1d54aa4afd63d7a31fb8c7d31', + hash2: '5f325bb8c4225db5faa8de6297f427f489c9d39572ded0451b89f565a7cbd347', + hash3: 'a19e177ba871af621a5c8bb429e756c2aa982ade9d4ae169c66f718284dd16cf', +}; + +export const privateKeys = { + prvKeyExtended: + 'ed25519e_sk13rv6afkern90kljwzqauj9p8s0qu4t29yjvm0u7q7exfq7yrp3xqyermevx7jg0xfjkg0sc5mdel0j46y8ym3fr6skygxxz7dm9zxygh5n244', + prvKey2: 'ed25519_sk1u79r9v3a4dccx9l9rn8d0wrrd49umyf5x5ft6txfc8lpc96syzaqjccnu6', + prvKey3WrongFormat: + 'ed25519e_sk1qr4lgrte8t43m6ky2cjdcnle583y54ex9j7z85fshenq86g92d8u6a40tgkpl702gqrqdgcdlxa7wzkgm74pqyspck7wclawgeu3yjslnu7nz3sdlszl1ad', + prvKey4: '00cebbe7db664726835a451e2cb8c1eba596369318b3e158656f54f76d747b7b', + prvKey5WrongFormat: '3560s-vl.1axfsjfjt6sa-q23-dssddddagag', +}; + +export const publicKeys = { + pubKey1: '9937fd481a9887463a67c39bad141ead730bffe7ed2cea31d7a02759bc197d00', + pubKey2: 'ba0fe12d67c2e111aaabc809f8a3ee3168522371ffca360a459e4043dd91eb08', + pubKey3: 'ed25519_pk1eame4ge0x5yrwpuqs5eyw89kfmjpgfkfh02xzdx6c2k9k2swcr5sjq4kzj', + pubKey4: 'sdfghjkiu87y6t5r4e3w2sdxcfghjui654', +}; + +export const enterpriseAccounts = { + account1: { + secretKey: 'ed25519_sk1amwk5s3l4fh6l86u8v2yxftldlg6mh9efdce5xy4wusl2kftr4aqlcy535', + publicKey: 'ed25519_pk1zy8mkv3k0d2d04qqv0xpme54x8y6yywqpjwhgddw5huvlh6m8gusds3l67', + hexPublic: '110fbb32367b54d7d40063cc1de69531c9a211c00c9d7435aea5f8cfdf5b3a39', + baseAddress: 'addr_test1vztvlmj9ht3phzcfml02zejan534rwpsm23z8rmakt9wkxcc82u67', + }, + + account2: { + secretKey: 'ed25519_sk1t5yluzh50txlj3xq4rvg0sfaksy0qyavne57k6zae2575qz438nstqw5uq', + publicKey: 'ed25519_pk138a2jey48a9a7ejrjxsq3td8vg7jz4urtnqmjcnqvcyet8d7jtjsey474x', + hexPublic: '89faa964953f4bdf664391a008ada7623d2157835cc1b962606609959dbe92e5', + baseAddress: 'addr_test1vpunqlch9k25zzzc76h7k8lra7wqx48qkmq0wtvd055um3sm4rler', + }, + + account3: { + secretKey: 'ed25519_sk1f44nvnxr8d37th07v44eumdtqkhlp29ddhtqv08n3alkhv2al2mqp2ak73', + publicKey: 'ed25519_pk1gczdpplaq4ams4t9zt6t508pkygc364ltgkz9gnp4vxjz4m52maqdqpas9', + baseAddress: 'addr_test1vq9arfq9pugs57apr3535z470ma2tvg8pnjy54q6s60muzscgmuj4', + }, + + account4: { + publicKeyHex: '9937fd481a9887463a67c39bad141ead730bffe7ed2cea31d7a02759bc197d00', + baseAddress: 'addr_test1vpyzy3pkh0qwgyhnzz93v65t92p2gzwpswcysh94ffx30qqxke78c', + }, + + seedAccount: { + seed: '', + secretKey: + 'xprv14zqmq4drmkvs76gxvqhg8dfdzcnf0hqer2ux0n2y8z09ulu5h4wegja87sygl77txhx7avkuefeq53ucq4m7e7wzx8n9wa603kk4hex3tvx0m2y3d2sjasnd7xh8tyy64mdksrv2v9xm8naf48xshtzlscwhqwcz', + publicKey: + 'xpub196u3a0yqdke428lwmmq9k0wfuxw0npq45fr7yy99umykds0dcv3azkcvlk5fz64p9mpxmudwwkgf4tkmdqxc5c2dk086n2wdpwk9lpswvqje8', + enterpriseAddress: 'addr_test1vr9exkzjnh6898pjg632qv7tnqs6h073dhjg3qq9jp9tcsg8d6n35', + }, +}; diff --git a/modules/sdk-coin-ada/test/unit/keyPair.ts b/modules/sdk-coin-ada/test/unit/keyPair.ts new file mode 100644 index 0000000000..cc5edaf62c --- /dev/null +++ b/modules/sdk-coin-ada/test/unit/keyPair.ts @@ -0,0 +1,111 @@ +import should from 'should'; +import { KeyPair } from '../../src/keyPair'; +import { enterpriseAccounts } from '../resources/'; +import { PrivateKey, PublicKey } from '@emurgo/cardano-serialization-lib-nodejs'; +import { AddressFormat, toHex } from '@bitgo/sdk-core'; + +describe('Ada Keypair', () => { + const defaultSeed = { seed: Buffer.alloc(32) }; + + describe('Keypair creation', () => { + it('initial state', () => { + const keyPair = new KeyPair(); + should.exists(keyPair.getKeys().prv); + should.exists(keyPair.getKeys().prv); + }); + + it('initialization from private key', () => { + let keyPair = new KeyPair({ + prv: enterpriseAccounts.account1.secretKey, + }); + + should.equal( + keyPair.getKeys().prv, + toHex(PrivateKey.from_bech32(enterpriseAccounts.account1.secretKey).as_bytes()) + ); + + should.equal(keyPair.getKeys().pub, enterpriseAccounts.account1.hexPublic); + + keyPair = new KeyPair({ + prv: enterpriseAccounts.account2.secretKey, + }); + + should.equal( + keyPair.getKeys().prv, + toHex(PrivateKey.from_bech32(enterpriseAccounts.account2.secretKey).as_bytes()) + ); + should.equal(keyPair.getKeys().pub, enterpriseAccounts.account2.hexPublic); + }); + + it('initialization from public key', () => { + let keyPair = new KeyPair({ pub: enterpriseAccounts.account1.publicKey }); + + should.equal( + keyPair.getKeys().pub, + toHex(PublicKey.from_bech32(enterpriseAccounts.account1.publicKey).as_bytes()) + ); + + keyPair = new KeyPair({ pub: enterpriseAccounts.account2.publicKey }); + should.equal(keyPair.getAddress(AddressFormat.testnet), enterpriseAccounts.account2.baseAddress); + + keyPair = new KeyPair({ pub: enterpriseAccounts.account4.publicKeyHex }); + should.equal(keyPair.getKeys().pub, enterpriseAccounts.account4.publicKeyHex); + }); + }); + + describe('KeyPair validation', () => { + it('should fail to create from an invalid seed', () => { + const seed = { seed: Buffer.alloc(8) }; // Seed should be 512 bits (64 bytes) + should.throws(() => new KeyPair(seed), 'bad seed size'); + }); + + it('should fail to create from an invalid public key', () => { + const source = { + pub: '01D63D', + }; + should.throws(() => new KeyPair(source), 'address seems to be malformed'); + }); + + it('should fail to create from an invalid private key', () => { + const source = { + prv: '82A34', + }; + should.throws(() => new KeyPair(source), 'Invalid base32 characters'); + }); + }); + + describe('getAddress', () => { + it('should get an address', () => { + let keyPair = new KeyPair({ prv: enterpriseAccounts.account1.secretKey }); + let address = keyPair.getAddress(AddressFormat.testnet); + address.should.equal(enterpriseAccounts.account1.baseAddress); + + keyPair = new KeyPair({ prv: enterpriseAccounts.account3.secretKey }); + address = keyPair.getAddress(AddressFormat.testnet); + address.should.equal(enterpriseAccounts.account3.baseAddress); + + keyPair = new KeyPair({ pub: enterpriseAccounts.account4.publicKeyHex }); + address = keyPair.getAddress(AddressFormat.testnet); + address.should.equal(enterpriseAccounts.account4.baseAddress); + }); + }); + + describe('getKeys', () => { + it('should get private and public keys in the protocol default format', () => { + const keyPair = new KeyPair(defaultSeed); + const { prv, pub } = keyPair.getKeys(); + + prv!.should.equal(prv); + pub.should.equal(pub); + const address = keyPair.getAddress(AddressFormat.testnet); + address.should.equal(enterpriseAccounts.seedAccount.enterpriseAddress); + }); + + it('should get private and public keys for a random seed', () => { + const keyPair = new KeyPair(); + const { prv, pub } = keyPair.getKeys(); + should.exist(prv); + should.exist(pub); + }); + }); +}); diff --git a/modules/sdk-coin-ada/test/unit/utils.ts b/modules/sdk-coin-ada/test/unit/utils.ts new file mode 100644 index 0000000000..6d0e7e5ecc --- /dev/null +++ b/modules/sdk-coin-ada/test/unit/utils.ts @@ -0,0 +1,69 @@ +import should from 'should'; +import { Utils } from '../../src/utils'; +import { toHex } from '@bitgo/sdk-core'; +import { Ed25519Signature } from '@emurgo/cardano-serialization-lib-nodejs'; +import { address, blockHash, signatures, txIds, privateKeys, publicKeys } from '../resources'; + +describe('utils', () => { + const utils = new Utils(); + + it('should validate addresses correctly', () => { + should.equal(utils.isValidAddress(address.address1), true); + should.equal(utils.isValidAddress(address.address2), true); + should.equal(utils.isValidAddress(address.address3), false); + should.equal(utils.isValidAddress(address.address4), true); + should.equal(utils.isValidAddress('dfjk35y'), false); + }); + + it('should validate block hash correctly', () => { + should.equal(utils.isValidBlockId(blockHash.hash1), true); + should.equal(utils.isValidBlockId(blockHash.hash2), true); + }); + + it('should validate invalid block hash correctly', () => { + should.equal(utils.isValidBlockId(''), false); + should.equal(utils.isValidBlockId('0xade35465gfvdcsxsz24300'), false); + should.equal(utils.isValidBlockId(blockHash.hash2 + 'ff'), false); + }); + + it('should validate public key correctly', () => { + should.equal(utils.isValidPublicKey(publicKeys.pubKey1), true); + should.equal(utils.isValidPublicKey(publicKeys.pubKey2), true); + should.equal(utils.isValidPublicKey(publicKeys.pubKey3), true); + should.equal(utils.isValidPublicKey(publicKeys.pubKey4), false); + }); + + it('should validate private key correctly', () => { + should.equal(utils.isValidPrivateKey(privateKeys.prvKeyExtended), true); + should.equal(utils.isValidPrivateKey(privateKeys.prvKey2), true); + should.equal(utils.isValidPrivateKey(privateKeys.prvKey3WrongFormat), false); + should.equal(utils.isValidPrivateKey(privateKeys.prvKey4), true); + should.equal(utils.isValidPrivateKey(privateKeys.prvKey5WrongFormat), false); + }); + + it('should validate signature correctly', () => { + should.equal(utils.isValidSignature(toHex(Ed25519Signature.from_bech32(signatures.signature1).to_bytes())), true); + should.equal(utils.isValidSignature(toHex(Ed25519Signature.from_bech32(signatures.signature2).to_bytes())), true); + }); + + it('should validate invalid signature correctly', () => { + should.equal(utils.isValidSignature(''), false); + should.equal(utils.isValidSignature('0x00'), false); + should.equal(utils.isValidSignature(privateKeys.prvKeyExtended), false); + should.equal(utils.isValidSignature(signatures.signature1.slice(2)), false); + should.equal(utils.isValidSignature(signatures.signature2 + 'ff'), false); + }); + + it('should validate transaction id correctly', () => { + should.equal(utils.isValidTransactionId(txIds.hash1), true); + should.equal(utils.isValidTransactionId(txIds.hash2), true); + should.equal(utils.isValidTransactionId(txIds.hash3), true); + }); + + it('should validate invalid transaction id correctly', () => { + should.equal(utils.isValidTransactionId(''), false); + should.equal(utils.isValidTransactionId(txIds.hash1.slice(3)), false); + should.equal(utils.isValidTransactionId(txIds.hash3 + '00'), false); + should.equal(utils.isValidTransactionId('dalij43ta0ga2dadda02'), false); + }); +}); diff --git a/modules/sdk-coin-algo/CHANGELOG.md b/modules/sdk-coin-algo/CHANGELOG.md index c6f25839ad..68d644287c 100644 --- a/modules/sdk-coin-algo/CHANGELOG.md +++ b/modules/sdk-coin-algo/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.16](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-algo@1.1.0-rc.14...@bitgo/sdk-coin-algo@1.1.0-rc.16) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-algo + + + + + +# [1.1.0-rc.15](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-algo@1.1.0-rc.14...@bitgo/sdk-coin-algo@1.1.0-rc.15) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-algo + + + + + # [1.1.0-rc.14](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-algo@1.1.0-rc.13...@bitgo/sdk-coin-algo@1.1.0-rc.14) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-algo diff --git a/modules/sdk-coin-algo/package.json b/modules/sdk-coin-algo/package.json index c77d2ac6d6..f178ece8f5 100644 --- a/modules/sdk-coin-algo/package.json +++ b/modules/sdk-coin-algo/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-algo", - "version": "1.1.0-rc.14", + "version": "1.1.0-rc.16", "description": "BitGo SDK coin library for Algorand", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,8 +41,8 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@bitgo/utxo-lib": "^2.3.0-rc.11", "@hashgraph/cryptography": "1.1.2", "@stablelib/hex": "^1.0.0", @@ -56,8 +56,8 @@ "tweetnacl": "^1.0.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "should": "^13.1.3", "sinon": "^7.5.0" } diff --git a/modules/sdk-coin-avaxc/CHANGELOG.md b/modules/sdk-coin-avaxc/CHANGELOG.md index d67d83e470..1030d1dc0d 100644 --- a/modules/sdk-coin-avaxc/CHANGELOG.md +++ b/modules/sdk-coin-avaxc/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-avaxc@1.1.0-rc.1...@bitgo/sdk-coin-avaxc@1.1.0-rc.3) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-avaxc + + + + + +# [1.1.0-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-avaxc@1.1.0-rc.1...@bitgo/sdk-coin-avaxc@1.1.0-rc.2) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-avaxc + + + + + # [1.1.0-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-avaxc@1.1.0-rc.0...@bitgo/sdk-coin-avaxc@1.1.0-rc.1) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-avaxc diff --git a/modules/sdk-coin-avaxc/package.json b/modules/sdk-coin-avaxc/package.json index 4a4737f4cd..68eb5d5264 100644 --- a/modules/sdk-coin-avaxc/package.json +++ b/modules/sdk-coin-avaxc/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-avaxc", - "version": "1.1.0-rc.1", + "version": "1.1.0-rc.3", "description": "BitGo SDK coin library for Avalanche c-chain", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,9 +41,9 @@ ] }, "dependencies": { - "@bitgo/sdk-coin-eth": "^1.1.0-rc.1", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-coin-eth": "^1.1.0-rc.3", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@ethereumjs/common": "^2.4.0", "bignumber.js": "^8.0.1", "bip32": "^2.0.6", @@ -54,7 +54,7 @@ "secp256k1": "^4.0.2" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-avaxp/CHANGELOG.md b/modules/sdk-coin-avaxp/CHANGELOG.md index 631aad12db..510e3516e4 100644 --- a/modules/sdk-coin-avaxp/CHANGELOG.md +++ b/modules/sdk-coin-avaxp/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-avaxp@2.0.0-rc.2...@bitgo/sdk-coin-avaxp@2.0.0-rc.4) (2022-07-19) + + +### Features + +* **sdk-coin-avaxp:** update stake validation check ([82ee448](https://github.com/BitGo/BitGoJS/commit/82ee4481094eaa60d5f3c97714eea10a6e69161b)) + + + + + +# [2.0.0-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-avaxp@2.0.0-rc.2...@bitgo/sdk-coin-avaxp@2.0.0-rc.3) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-avaxp + + + + + # [2.0.0-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-avaxp@2.0.0-rc.1...@bitgo/sdk-coin-avaxp@2.0.0-rc.2) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-avaxp diff --git a/modules/sdk-coin-avaxp/package.json b/modules/sdk-coin-avaxp/package.json index a739fc1d63..5d537d240f 100644 --- a/modules/sdk-coin-avaxp/package.json +++ b/modules/sdk-coin-avaxp/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-avaxp", - "version": "2.0.0-rc.2", + "version": "2.0.0-rc.4", "description": "BitGo's SDK coin library for avaxp coin", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -47,8 +47,8 @@ "@types/elliptic": "^6.4.12" }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "avalanche": "3.13.3", "bech32": "2.0.0", "bignumber.js": "^9.0.0", diff --git a/modules/sdk-coin-avaxp/src/lib/delegatorTxBuilder.ts b/modules/sdk-coin-avaxp/src/lib/delegatorTxBuilder.ts index e4ab2e0021..9afb14d587 100644 --- a/modules/sdk-coin-avaxp/src/lib/delegatorTxBuilder.ts +++ b/modules/sdk-coin-avaxp/src/lib/delegatorTxBuilder.ts @@ -56,8 +56,8 @@ export class DelegatorTxBuilder extends TransactionBuilder { } /** - * - * @param startTime + * start time of staking period + * @param value */ startTime(value: string | number): this { this._startTime = new BN(value); @@ -65,8 +65,8 @@ export class DelegatorTxBuilder extends TransactionBuilder { } /** - * - * @param endTime + * end time of staking period + * @param value */ endTime(value: string | number): this { this._endTime = new BN(value); @@ -124,6 +124,10 @@ export class DelegatorTxBuilder extends TransactionBuilder { * unix time stamp based off seconds */ validateStakeDuration(startTime: BN, endTime: BN): void { + const oneDayLater = new BN(Date.now()).add(new BN(86400)); + if (!startTime.gt(oneDayLater)) { + throw new BuildTransactionError('Start time needs to be one day greater than current time'); + } if (endTime < startTime) { throw new BuildTransactionError('End date cannot be less than start date'); } @@ -174,6 +178,7 @@ export class DelegatorTxBuilder extends TransactionBuilder { * @protected */ protected buildAvaxpTransaction(): void { + this.validateStakeDuration(this._startTime, this._endTime); const { inputs, outputs, credentials } = this.createInputOutput(); this.transaction.setTransaction( new Tx( diff --git a/modules/sdk-coin-avaxp/test/resources/avaxp.ts b/modules/sdk-coin-avaxp/test/resources/avaxp.ts index 4ddf9e946c..c4379fec25 100644 --- a/modules/sdk-coin-avaxp/test/resources/avaxp.ts +++ b/modules/sdk-coin-avaxp/test/resources/avaxp.ts @@ -55,10 +55,9 @@ export const INVALID_STAKE_AMOUNT = new BN(1999); export const INVALID_DELEGATION_FEE = 0; -export const START_TIME = new BN(0); -export const INVALID_START_TIME = new BN(1000000); -export const END_TIME = new BN(1209600); -export const INVALID_END_TIME = new BN(31556927); +export const START_TIME = new BN(Date.now()).add(new BN(90000)); +export const ONE_WEEK = new BN(604800); +export const TWO_YEAR = new BN(63072000); export const INVALID_SHORT_KEYPAIR_KEY = '82A34E'; diff --git a/modules/sdk-coin-avaxp/test/resources/errors.ts b/modules/sdk-coin-avaxp/test/resources/errors.ts index c439078c0e..bde49507fc 100644 --- a/modules/sdk-coin-avaxp/test/resources/errors.ts +++ b/modules/sdk-coin-avaxp/test/resources/errors.ts @@ -6,6 +6,8 @@ export const ERROR_EMPTY_RAW_TRANSACTION = 'Raw transaction is empty'; export const ERROR_RAW_PARSING = 'Raw transaction is not hex string'; +export const ERROR_STAKE_START_TIME_TOO_SHORT = 'Start time needs to be one day greater than current time'; + export const ERROR_STAKE_DURATION_SHORT_TIME = 'End date must be greater than or equal to two weeks'; export const ERROR_STAKE_DURATION_LONG_TIME = 'End date must be less than or equal to one year'; diff --git a/modules/sdk-coin-avaxp/test/unit/lib/validateTxBuilder.ts b/modules/sdk-coin-avaxp/test/unit/lib/validateTxBuilder.ts index c669f231c7..1b70ec3b4c 100644 --- a/modules/sdk-coin-avaxp/test/unit/lib/validateTxBuilder.ts +++ b/modules/sdk-coin-avaxp/test/unit/lib/validateTxBuilder.ts @@ -5,6 +5,7 @@ import * as testData from '../../resources/avaxp'; import * as errorMessage from '../../resources/errors'; import { TransactionBuilderFactory, DecodedUtxoObj } from '../../../src/lib'; import { coins } from '@bitgo/statics'; +import { BN } from 'avalanche'; describe('AvaxP Validate Tx Builder', () => { const factory = new TransactionBuilderFactory(coins.get('avaxp')); @@ -30,7 +31,7 @@ describe('AvaxP Validate Tx Builder', () => { it('should fail endTime less than 2 weeks', () => { assert.throws( () => { - txBuilder.validateStakeDuration(testData.INVALID_START_TIME, testData.END_TIME); + txBuilder.validateStakeDuration(testData.START_TIME, testData.START_TIME.add(testData.ONE_WEEK)); }, (e) => e.message === errorMessage.ERROR_STAKE_DURATION_SHORT_TIME ); @@ -38,11 +39,19 @@ describe('AvaxP Validate Tx Builder', () => { it('should fail endTime greater than 1 year', () => { assert.throws( () => { - txBuilder.validateStakeDuration(testData.START_TIME, testData.INVALID_END_TIME); + txBuilder.validateStakeDuration(testData.START_TIME, testData.START_TIME.add(testData.TWO_YEAR)); }, (e) => e.message === errorMessage.ERROR_STAKE_DURATION_LONG_TIME ); }); + it('should fail startTime too soon', () => { + assert.throws( + () => { + txBuilder.validateStakeDuration(new BN(Date.now()), testData.ONE_WEEK); + }, + (e) => e.message === errorMessage.ERROR_STAKE_START_TIME_TOO_SHORT + ); + }); it('should fail stake amount less than 2000', () => { assert.throws( () => { diff --git a/modules/sdk-coin-bch/CHANGELOG.md b/modules/sdk-coin-bch/CHANGELOG.md index 6aaa90f839..9e71890346 100644 --- a/modules/sdk-coin-bch/CHANGELOG.md +++ b/modules/sdk-coin-bch/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bch@1.1.0-rc.5...@bitgo/sdk-coin-bch@1.1.0-rc.7) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-bch + + + + + +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bch@1.1.0-rc.5...@bitgo/sdk-coin-bch@1.1.0-rc.6) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-bch + + + + + # [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bch@1.1.0-rc.4...@bitgo/sdk-coin-bch@1.1.0-rc.5) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-bch diff --git a/modules/sdk-coin-bch/package.json b/modules/sdk-coin-bch/package.json index e4e712bac6..285d0528ca 100644 --- a/modules/sdk-coin-bch/package.json +++ b/modules/sdk-coin-bch/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-bch", - "version": "1.1.0-rc.5", + "version": "1.1.0-rc.7", "description": "BitGo SDK coin library for Bitcoin Cash", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,12 +41,12 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-bcha/CHANGELOG.md b/modules/sdk-coin-bcha/CHANGELOG.md index d2a5c97586..16380274f2 100644 --- a/modules/sdk-coin-bcha/CHANGELOG.md +++ b/modules/sdk-coin-bcha/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bcha@1.1.0-rc.5...@bitgo/sdk-coin-bcha@1.1.0-rc.7) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-bcha + + + + + +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bcha@1.1.0-rc.5...@bitgo/sdk-coin-bcha@1.1.0-rc.6) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-bcha + + + + + # [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bcha@1.1.0-rc.4...@bitgo/sdk-coin-bcha@1.1.0-rc.5) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-bcha diff --git a/modules/sdk-coin-bcha/package.json b/modules/sdk-coin-bcha/package.json index 6525045ff6..dd12a9921d 100644 --- a/modules/sdk-coin-bcha/package.json +++ b/modules/sdk-coin-bcha/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-bcha", - "version": "1.1.0-rc.5", + "version": "1.1.0-rc.7", "description": "BitGo SDK coin library for Bitcoin abc", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,13 +41,13 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-coin-bch": "^1.1.0-rc.5", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-coin-bch": "^1.1.0-rc.7", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-bsv/CHANGELOG.md b/modules/sdk-coin-bsv/CHANGELOG.md index dcbc0938c9..3241ea8266 100644 --- a/modules/sdk-coin-bsv/CHANGELOG.md +++ b/modules/sdk-coin-bsv/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bsv@1.1.0-rc.5...@bitgo/sdk-coin-bsv@1.1.0-rc.7) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-bsv + + + + + +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bsv@1.1.0-rc.5...@bitgo/sdk-coin-bsv@1.1.0-rc.6) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-bsv + + + + + # [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-bsv@1.1.0-rc.4...@bitgo/sdk-coin-bsv@1.1.0-rc.5) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-bsv diff --git a/modules/sdk-coin-bsv/package.json b/modules/sdk-coin-bsv/package.json index ada61a0e3e..799022b29d 100644 --- a/modules/sdk-coin-bsv/package.json +++ b/modules/sdk-coin-bsv/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-bsv", - "version": "1.1.0-rc.5", + "version": "1.1.0-rc.7", "description": "BitGo SDK coin library for Bitcoin sv", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,13 +41,13 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-coin-bch": "^1.1.0-rc.5", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-coin-bch": "^1.1.0-rc.7", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-btc/CHANGELOG.md b/modules/sdk-coin-btc/CHANGELOG.md index f729644641..faac532ebf 100644 --- a/modules/sdk-coin-btc/CHANGELOG.md +++ b/modules/sdk-coin-btc/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.10](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-btc@1.0.1-rc.8...@bitgo/sdk-coin-btc@1.0.1-rc.10) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-btc + + + + + +## [1.0.1-rc.9](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-btc@1.0.1-rc.8...@bitgo/sdk-coin-btc@1.0.1-rc.9) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-btc + + + + + ## [1.0.1-rc.8](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-btc@1.0.1-rc.7...@bitgo/sdk-coin-btc@1.0.1-rc.8) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-btc diff --git a/modules/sdk-coin-btc/package.json b/modules/sdk-coin-btc/package.json index 561d63bec1..a6a55f98f6 100644 --- a/modules/sdk-coin-btc/package.json +++ b/modules/sdk-coin-btc/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-btc", - "version": "1.0.1-rc.8", + "version": "1.0.1-rc.10", "description": "BitGo SDK coin library for Bitcoin", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,13 +41,13 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "assert": "^2.0.0" } } diff --git a/modules/sdk-coin-btg/CHANGELOG.md b/modules/sdk-coin-btg/CHANGELOG.md index 6cdbb90b76..cf15fe7275 100644 --- a/modules/sdk-coin-btg/CHANGELOG.md +++ b/modules/sdk-coin-btg/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-btg@1.1.0-rc.5...@bitgo/sdk-coin-btg@1.1.0-rc.7) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-btg + + + + + +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-btg@1.1.0-rc.5...@bitgo/sdk-coin-btg@1.1.0-rc.6) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-btg + + + + + # [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-btg@1.1.0-rc.4...@bitgo/sdk-coin-btg@1.1.0-rc.5) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-btg diff --git a/modules/sdk-coin-btg/package.json b/modules/sdk-coin-btg/package.json index cf49ab064d..0c0ee4ad63 100644 --- a/modules/sdk-coin-btg/package.json +++ b/modules/sdk-coin-btg/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-btg", - "version": "1.1.0-rc.5", + "version": "1.1.0-rc.7", "description": "BitGo SDK coin library for Bitcoin Gold", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,12 +41,12 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-celo/CHANGELOG.md b/modules/sdk-coin-celo/CHANGELOG.md index e4cb799028..958ea20a4c 100644 --- a/modules/sdk-coin-celo/CHANGELOG.md +++ b/modules/sdk-coin-celo/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-celo@1.1.0-rc.1...@bitgo/sdk-coin-celo@1.1.0-rc.3) (2022-07-19) + + +### Bug Fixes + +* update bad dependency match ([5cc3255](https://github.com/BitGo/BitGoJS/commit/5cc3255aecba1ffb112da3ba10d8d36d2074b3e3)) + + + + + +# [1.1.0-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-celo@1.1.0-rc.1...@bitgo/sdk-coin-celo@1.1.0-rc.2) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-celo + + + + + # [1.1.0-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-celo@1.1.0-rc.0...@bitgo/sdk-coin-celo@1.1.0-rc.1) (2022-07-15) diff --git a/modules/sdk-coin-celo/package.json b/modules/sdk-coin-celo/package.json index 2ae94f701d..bc4969565f 100644 --- a/modules/sdk-coin-celo/package.json +++ b/modules/sdk-coin-celo/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-celo", - "version": "1.1.0-rc.1", + "version": "1.1.0-rc.3", "description": "BitGo SDK coin library for Celo", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,13 +41,14 @@ ] }, "dependencies": { - "@bitgo/abstract-eth": "^1.0.1-rc.21", + "@bitgo/abstract-eth": "^1.0.1-rc.23", "@bitgo/ethereumjs-utils-old": "npm:ethereumjs-util@5.2.0", - "@bitgo/sdk-coin-eth": "^1.1.0-rc.1", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-coin-eth": "^1.1.0-rc.3", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@celo/connect": "^2.0.0", "@celo/contractkit": "^2.0.0", + "@celo/wallet-base": "^2.0.0", "@celo/wallet-local": "^2.0.0", "@ethereumjs/common": "^2.4.0", "bignumber.js": "^9.0.0", @@ -56,7 +57,7 @@ "ethers": "^5.1.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-cspr/CHANGELOG.md b/modules/sdk-coin-cspr/CHANGELOG.md index 4a1103268e..201fe850cb 100644 --- a/modules/sdk-coin-cspr/CHANGELOG.md +++ b/modules/sdk-coin-cspr/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.17](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-cspr@1.0.1-rc.15...@bitgo/sdk-coin-cspr@1.0.1-rc.17) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-cspr + + + + + +## [1.0.1-rc.16](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-cspr@1.0.1-rc.15...@bitgo/sdk-coin-cspr@1.0.1-rc.16) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-cspr + + + + + ## [1.0.1-rc.15](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-cspr@1.0.1-rc.14...@bitgo/sdk-coin-cspr@1.0.1-rc.15) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-cspr diff --git a/modules/sdk-coin-cspr/package.json b/modules/sdk-coin-cspr/package.json index 39f45d5473..e896801638 100644 --- a/modules/sdk-coin-cspr/package.json +++ b/modules/sdk-coin-cspr/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-cspr", - "version": "1.0.1-rc.15", + "version": "1.0.1-rc.17", "description": "BitGo SDK coin library for Casper", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,8 +41,8 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@bitgo/utxo-lib": "^2.3.0-rc.11", "@ethersproject/bignumber": "^5.6.0", "@stablelib/hex": "^1.0.0", @@ -53,8 +53,8 @@ "secp256k1": "4.0.2" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "tweetnacl": "^1.0.3" } } diff --git a/modules/sdk-coin-dash/CHANGELOG.md b/modules/sdk-coin-dash/CHANGELOG.md index 5cc78027a7..e8e78d590e 100644 --- a/modules/sdk-coin-dash/CHANGELOG.md +++ b/modules/sdk-coin-dash/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.8](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-dash@1.1.0-rc.6...@bitgo/sdk-coin-dash@1.1.0-rc.8) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-dash + + + + + +# [1.1.0-rc.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-dash@1.1.0-rc.6...@bitgo/sdk-coin-dash@1.1.0-rc.7) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-dash + + + + + # [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-dash@1.1.0-rc.5...@bitgo/sdk-coin-dash@1.1.0-rc.6) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-dash diff --git a/modules/sdk-coin-dash/package.json b/modules/sdk-coin-dash/package.json index d590a0a069..120f100924 100644 --- a/modules/sdk-coin-dash/package.json +++ b/modules/sdk-coin-dash/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-dash", - "version": "1.1.0-rc.6", + "version": "1.1.0-rc.8", "description": "BitGo SDK coin library for Dash", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,12 +41,12 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-doge/CHANGELOG.md b/modules/sdk-coin-doge/CHANGELOG.md index 083dc55822..96ce649084 100644 --- a/modules/sdk-coin-doge/CHANGELOG.md +++ b/modules/sdk-coin-doge/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-doge@1.0.1-rc.3...@bitgo/sdk-coin-doge@1.0.1-rc.5) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-doge + + + + + +## [1.0.1-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-doge@1.0.1-rc.3...@bitgo/sdk-coin-doge@1.0.1-rc.4) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-doge + + + + + ## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-doge@1.0.1-rc.2...@bitgo/sdk-coin-doge@1.0.1-rc.3) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-doge diff --git a/modules/sdk-coin-doge/package.json b/modules/sdk-coin-doge/package.json index 0b19a1a42b..184f54020d 100644 --- a/modules/sdk-coin-doge/package.json +++ b/modules/sdk-coin-doge/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-doge", - "version": "1.0.1-rc.3", + "version": "1.0.1-rc.5", "description": "BitGo SDK coin library for Dogecoin", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,12 +41,12 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-dot/CHANGELOG.md b/modules/sdk-coin-dot/CHANGELOG.md index adfed6cb56..7f3ee9cf93 100644 --- a/modules/sdk-coin-dot/CHANGELOG.md +++ b/modules/sdk-coin-dot/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-dot@1.0.1-rc.1...@bitgo/sdk-coin-dot@1.0.1-rc.3) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-dot + + + + + +## [1.0.1-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-dot@1.0.1-rc.1...@bitgo/sdk-coin-dot@1.0.1-rc.2) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-dot + + + + + ## [1.0.1-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-dot@1.0.1-rc.0...@bitgo/sdk-coin-dot@1.0.1-rc.1) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-dot diff --git a/modules/sdk-coin-dot/package.json b/modules/sdk-coin-dot/package.json index bab0d7ac4f..9d20457682 100644 --- a/modules/sdk-coin-dot/package.json +++ b/modules/sdk-coin-dot/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-dot", - "version": "1.0.1-rc.1", + "version": "1.0.1-rc.3", "description": "BitGo SDK coin library for Polkadot", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,8 +41,8 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@polkadot/api": "7.15.1", "@polkadot/keyring": "^8.7.1", "@polkadot/types": "7.15.1", @@ -58,8 +58,8 @@ "tweetnacl": "^1.0.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "@types/lodash": "^4.14.151" } } diff --git a/modules/sdk-coin-eos/CHANGELOG.md b/modules/sdk-coin-eos/CHANGELOG.md index 5bbf3e0e00..ca300994ca 100644 --- a/modules/sdk-coin-eos/CHANGELOG.md +++ b/modules/sdk-coin-eos/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-eos@1.0.1-rc.1...@bitgo/sdk-coin-eos@1.0.1-rc.3) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-eos + + + + + +## [1.0.1-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-eos@1.0.1-rc.1...@bitgo/sdk-coin-eos@1.0.1-rc.2) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-eos + + + + + ## [1.0.1-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-eos@1.0.1-rc.0...@bitgo/sdk-coin-eos@1.0.1-rc.1) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-eos diff --git a/modules/sdk-coin-eos/package.json b/modules/sdk-coin-eos/package.json index e36675ba1f..4a084c01b3 100644 --- a/modules/sdk-coin-eos/package.json +++ b/modules/sdk-coin-eos/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-eos", - "version": "1.0.1-rc.1", + "version": "1.0.1-rc.3", "description": "BitGo SDK coin library for Eos", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,8 +41,8 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "bignumber.js": "^9.0.2", "bip32": "^2.0.6", "eosjs": "^21.0.2", @@ -51,8 +51,8 @@ "superagent": "^3.8.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "@types/lodash": "^4.14.121" } } diff --git a/modules/sdk-coin-etc/CHANGELOG.md b/modules/sdk-coin-etc/CHANGELOG.md index de6f5213c6..e631900565 100644 --- a/modules/sdk-coin-etc/CHANGELOG.md +++ b/modules/sdk-coin-etc/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-etc@1.0.1-rc.3...@bitgo/sdk-coin-etc@1.0.1-rc.5) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-etc + + + + + +## [1.0.1-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-etc@1.0.1-rc.3...@bitgo/sdk-coin-etc@1.0.1-rc.4) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-etc + + + + + ## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-etc@1.0.1-rc.2...@bitgo/sdk-coin-etc@1.0.1-rc.3) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-etc diff --git a/modules/sdk-coin-etc/package.json b/modules/sdk-coin-etc/package.json index d109fae1cb..8ac1f7bdc7 100644 --- a/modules/sdk-coin-etc/package.json +++ b/modules/sdk-coin-etc/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-etc", - "version": "1.0.1-rc.3", + "version": "1.0.1-rc.5", "description": "BitGo SDK coin library for Ethereum classic", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,15 +41,15 @@ ] }, "dependencies": { - "@bitgo/abstract-eth": "^1.0.1-rc.21", - "@bitgo/sdk-coin-eth": "^1.1.0-rc.1", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/abstract-eth": "^1.0.1-rc.23", + "@bitgo/sdk-coin-eth": "^1.1.0-rc.3", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@ethereumjs/common": "^2.4.0", "ethereumjs-abi": "^0.6.5" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-eth/CHANGELOG.md b/modules/sdk-coin-eth/CHANGELOG.md index 66d0d503b3..68a46401ef 100644 --- a/modules/sdk-coin-eth/CHANGELOG.md +++ b/modules/sdk-coin-eth/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-eth@1.1.0-rc.1...@bitgo/sdk-coin-eth@1.1.0-rc.3) (2022-07-19) + + +### Bug Fixes + +* **sdk-coin-eth:** modify buildAddressInitializationTransaction method ([3cc205f](https://github.com/BitGo/BitGoJS/commit/3cc205f6e216fa4245dcebefe584de708f4037b0)) + + + + + +# [1.1.0-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-eth@1.1.0-rc.1...@bitgo/sdk-coin-eth@1.1.0-rc.2) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-eth + + + + + # [1.1.0-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-eth@1.1.0-rc.0...@bitgo/sdk-coin-eth@1.1.0-rc.1) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-eth diff --git a/modules/sdk-coin-eth/package.json b/modules/sdk-coin-eth/package.json index 523983581f..5023e6346a 100644 --- a/modules/sdk-coin-eth/package.json +++ b/modules/sdk-coin-eth/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-eth", - "version": "1.1.0-rc.1", + "version": "1.1.0-rc.3", "description": "BitGo SDK coin library for Ethereum", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -42,8 +42,8 @@ }, "dependencies": { "@bitgo/ethereumjs-utils-old": "npm:ethereumjs-util@5.2.0", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@ethereumjs/common": "^2.4.0", "@ethereumjs/tx": "^3.3.0", "bignumber.js": "^9.0.0", @@ -59,8 +59,8 @@ "superagent": "^3.8.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "tweetnacl": "^1.0.3" } } diff --git a/modules/sdk-coin-eth/src/eth.ts b/modules/sdk-coin-eth/src/eth.ts index 952fc05bf1..b8ddbc4047 100644 --- a/modules/sdk-coin-eth/src/eth.ts +++ b/modules/sdk-coin-eth/src/eth.ts @@ -21,7 +21,6 @@ import { FeeEstimateOptions, getIsKrsRecovery, getIsUnsignedSweep, - HalfSignedAccountTransaction, InvalidAddressError, InvalidAddressVerificationObjectPropertyError, IWallet, @@ -38,6 +37,9 @@ import { VerifyAddressOptions as BaseVerifyAddressOptions, VerifyTransactionOptions, Wallet, + Recipient, + HalfSignedTransaction, + FullySignedTransaction, } from '@bitgo/sdk-core'; import { BaseCoin as StaticsBaseCoin, EthereumNetwork, ethGasConfigs } from '@bitgo/statics'; @@ -45,6 +47,8 @@ import type * as EthTxLib from '@ethereumjs/tx'; import type * as EthCommon from '@ethereumjs/common'; import { calculateForwarderV1Address, getProxyInitcode } from './lib'; +export { Recipient, HalfSignedTransaction, FullySignedTransaction }; + const debug = debugLib('bitgo:v2:eth'); export const optionalDeps = { @@ -118,12 +122,6 @@ interface HopPrebuild { gasPriceMax: number; } -export interface Recipient { - address: string; - amount: string; - data?: string; -} - interface EIP1559 { maxPriorityFeePerGas: number; maxFeePerGas: number; @@ -167,20 +165,6 @@ export interface SignTransactionOptions extends BaseSignTransactionOptions, Sign custodianTransactionId?: string; } -export interface HalfSignedTransaction extends HalfSignedAccountTransaction { - halfSigned: { - recipients: Recipient[]; - expireTime: number; - contractSequenceId: number; - sequenceId: number; - txHex?: never; - }; -} - -export interface FullySignedTransaction { - txHex: string; -} - export type SignedTransaction = HalfSignedTransaction | FullySignedTransaction; interface PrecreateBitGoOptions { diff --git a/modules/sdk-coin-eth/src/lib/transactionBuilder.ts b/modules/sdk-coin-eth/src/lib/transactionBuilder.ts index dd41713c8b..18b840d0f2 100644 --- a/modules/sdk-coin-eth/src/lib/transactionBuilder.ts +++ b/modules/sdk-coin-eth/src/lib/transactionBuilder.ts @@ -627,11 +627,13 @@ export class TransactionBuilder extends BaseTransactionBuilder { const addressInitData = getAddressInitializationData(this._forwarderVersion); const tx: TxData = this.buildBase(addressInitData); tx.to = this._contractAddress; + if (this._contractCounter) { - tx.deployedAddress = - this._forwarderVersion === 0 - ? calculateForwarderAddress(this._contractAddress, this._contractCounter) - : calculateForwarderV1Address(this._contractAddress, this._salt, this._initCode); + tx.deployedAddress = calculateForwarderAddress(this._contractAddress, this._contractCounter); + } + + if (this._salt && this._initCode) { + tx.deployedAddress = calculateForwarderV1Address(this._contractAddress, this._salt, this._initCode); } return tx; } diff --git a/modules/sdk-coin-eth2/.eslintignore b/modules/sdk-coin-eth2/.eslintignore new file mode 100644 index 0000000000..190f83e0df --- /dev/null +++ b/modules/sdk-coin-eth2/.eslintignore @@ -0,0 +1,5 @@ +node_modules +.idea +public +dist + diff --git a/modules/sdk-coin-eth2/.gitignore b/modules/sdk-coin-eth2/.gitignore new file mode 100644 index 0000000000..67ccce4c64 --- /dev/null +++ b/modules/sdk-coin-eth2/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +.idea/ +dist/ diff --git a/modules/sdk-coin-eth2/.mocharc.yml b/modules/sdk-coin-eth2/.mocharc.yml new file mode 100644 index 0000000000..95814796d1 --- /dev/null +++ b/modules/sdk-coin-eth2/.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-eth2/.npmignore b/modules/sdk-coin-eth2/.npmignore new file mode 100644 index 0000000000..d5fb3a098c --- /dev/null +++ b/modules/sdk-coin-eth2/.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-eth2/.prettierignore b/modules/sdk-coin-eth2/.prettierignore new file mode 100644 index 0000000000..3a11d6af29 --- /dev/null +++ b/modules/sdk-coin-eth2/.prettierignore @@ -0,0 +1,2 @@ +.nyc_output/ +dist/ diff --git a/modules/sdk-coin-eth2/.prettierrc.yml b/modules/sdk-coin-eth2/.prettierrc.yml new file mode 100644 index 0000000000..7c3d8dd32a --- /dev/null +++ b/modules/sdk-coin-eth2/.prettierrc.yml @@ -0,0 +1,3 @@ +printWidth: 120 +singleQuote: true +trailingComma: 'es5' diff --git a/modules/sdk-coin-eth2/CHANGELOG.md b/modules/sdk-coin-eth2/CHANGELOG.md new file mode 100644 index 0000000000..1cc8a0231c --- /dev/null +++ b/modules/sdk-coin-eth2/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## 1.0.1-rc.0 (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-eth2 diff --git a/modules/sdk-coin-eth2/README.md b/modules/sdk-coin-eth2/README.md new file mode 100644 index 0000000000..7dffd5d18b --- /dev/null +++ b/modules/sdk-coin-eth2/README.md @@ -0,0 +1,30 @@ +# BitGo sdk-coin-eth2 + +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-eth2`. + +```shell +npm i @bitgo/sdk-api @bitgo/sdk-coin-eth2 +``` + +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 { Eth2 } from '@bitgo/sdk-coin-eth2'; + +const sdk = new BitGoAPI(); + +sdk.register('eth2', Eth2.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-eth2/package.json b/modules/sdk-coin-eth2/package.json new file mode 100644 index 0000000000..cf3e7fc6b9 --- /dev/null +++ b/modules/sdk-coin-eth2/package.json @@ -0,0 +1,54 @@ +{ + "name": "@bitgo/sdk-coin-eth2", + "version": "1.0.1-rc.0", + "description": "BitGo SDK coin library for Eth2", + "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 .", + "precommit": "yarn lint-staged", + "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": ">=14 <17" + }, + "repository": { + "type": "git", + "url": "https://github.com/BitGo/BitGoJS.git", + "directory": "modules/sdk-coin-eth2" + }, + "lint-staged": { + "*.{js,ts}": [ + "yarn prettier --write", + "yarn eslint --fix" + ] + }, + "publishConfig": { + "access": "public" + }, + "nyc": { + "extension": [ + ".ts" + ] + }, + "dependencies": { + "@bitgo/sdk-core": "^1.1.0-rc.29", + "bignumber.js": "^8.0.1", + "ethereumjs-util": "7.1.5", + "lodash": "^4.17.14", + "superagent": "^3.8.3" + }, + "devDependencies": { + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" + } +} diff --git a/modules/bitgo/src/v2/coins/eth2.ts b/modules/sdk-coin-eth2/src/eth2.ts similarity index 94% rename from modules/bitgo/src/v2/coins/eth2.ts rename to modules/sdk-coin-eth2/src/eth2.ts index 55814e4f75..140b7fe690 100644 --- a/modules/bitgo/src/v2/coins/eth2.ts +++ b/modules/sdk-coin-eth2/src/eth2.ts @@ -4,7 +4,6 @@ import * as _ from 'lodash'; import * as ethUtil from 'ethereumjs-util'; import * as request from 'superagent'; -import { Eth2 as Eth2AccountLib } from '@bitgo/account-lib'; import BigNumber from 'bignumber.js'; import { @@ -22,6 +21,8 @@ import { VerifyTransactionOptions, } from '@bitgo/sdk-core'; +import { KeyPair as Eth2KeyPair } from './lib'; + interface Recipient { address: string; amount: string; @@ -170,7 +171,7 @@ export class Eth2 extends BaseCoin { * @returns {Boolean} is it valid? */ isValidPub(pub: string): boolean { - return Eth2AccountLib.KeyPair.isValidPub(pub); + return Eth2KeyPair.isValidPub(pub); } /** @@ -299,10 +300,10 @@ export class Eth2 extends BaseCoin { * @returns {Object} object with generated pub and prv */ generateKeyPair(seed?: Buffer): IBlsKeyPair { - let keyPair = new Eth2AccountLib.KeyPair(); - if (seed && Eth2AccountLib.KeyPair.isValidPrv(seed)) { + let keyPair = new Eth2KeyPair(); + if (seed && Eth2KeyPair.isValidPrv(seed)) { const seedStr = '0x' + Buffer.from(seed).toString('hex'); - keyPair = new Eth2AccountLib.KeyPair({ prv: seedStr }); + keyPair = new Eth2KeyPair({ prv: seedStr }); } else if (seed) { throw new Error('trying to generate keypair from invalid seed'); } @@ -333,10 +334,10 @@ export class Eth2 extends BaseCoin { * @param message */ async signMessage(key: { prv: string }, message: string): Promise { - const keyPair = new Eth2AccountLib.KeyPair({ prv: key.prv }); + const keyPair = new Eth2KeyPair({ prv: key.prv }); let messageToSign: Buffer = Buffer.from(message); - if (Eth2AccountLib.KeyPair.isValidPub(message)) { + if (Eth2KeyPair.isValidPub(message)) { // if we are doing a key signature, we should decode the message as a hex string // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore BG-34579: known compatibility issue with @types/ethereumjs-util @@ -348,8 +349,8 @@ export class Eth2 extends BaseCoin { } aggregateShares(shares: { pubShares: string[]; prvShares: string[] }): IBlsKeyPair { - const commonPub = Eth2AccountLib.KeyPair.aggregatePubkeys(shares.pubShares); - const prv = Eth2AccountLib.KeyPair.aggregatePrvkeys(shares.prvShares); + const commonPub = Eth2KeyPair.aggregatePubkeys(shares.pubShares); + const prv = Eth2KeyPair.aggregatePrvkeys(shares.prvShares); return { pub: commonPub, diff --git a/modules/sdk-coin-eth2/src/index.ts b/modules/sdk-coin-eth2/src/index.ts new file mode 100644 index 0000000000..827498ebdb --- /dev/null +++ b/modules/sdk-coin-eth2/src/index.ts @@ -0,0 +1,3 @@ +export * from './eth2'; +export * from './lib'; +export * from './teth2'; diff --git a/modules/account-lib/src/coin/eth2/index.ts b/modules/sdk-coin-eth2/src/lib/index.ts similarity index 100% rename from modules/account-lib/src/coin/eth2/index.ts rename to modules/sdk-coin-eth2/src/lib/index.ts diff --git a/modules/account-lib/src/coin/eth2/keyPair.ts b/modules/sdk-coin-eth2/src/lib/keyPair.ts similarity index 100% rename from modules/account-lib/src/coin/eth2/keyPair.ts rename to modules/sdk-coin-eth2/src/lib/keyPair.ts diff --git a/modules/bitgo/src/v2/coins/teth2.ts b/modules/sdk-coin-eth2/src/teth2.ts similarity index 84% rename from modules/bitgo/src/v2/coins/teth2.ts rename to modules/sdk-coin-eth2/src/teth2.ts index a2f45508e0..446833725b 100644 --- a/modules/bitgo/src/v2/coins/teth2.ts +++ b/modules/sdk-coin-eth2/src/teth2.ts @@ -2,6 +2,10 @@ import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; import { Eth2 } from './eth2'; export class Teth2 extends Eth2 { + constructor(bitgo: BitGoBase) { + super(bitgo); + } + static createInstance(bitgo: BitGoBase): BaseCoin { return new Teth2(bitgo); } diff --git a/modules/account-lib/test/resources/eth2/eth2.ts b/modules/sdk-coin-eth2/test/resources/eth2.ts similarity index 90% rename from modules/account-lib/test/resources/eth2/eth2.ts rename to modules/sdk-coin-eth2/test/resources/eth2.ts index 2329e27001..a10d0882d2 100644 --- a/modules/account-lib/test/resources/eth2/eth2.ts +++ b/modules/sdk-coin-eth2/test/resources/eth2.ts @@ -1,11 +1,11 @@ -import { KeyPair } from '@bitgo/sdk-coin-hbar'; +import { KeyPair } from '../../src'; // ACCOUNT_1 has public and private keys with prefix export const ACCOUNT_1 = { privateKey: '0x8fa1aa4aaa6c54aa2aacaafaaa23aCaa8fa1aa4aaa6c54aa2aacaafaaa23aCaa', publicKey: '0x8fa1aa4aaa6c54aa2aacaafaaa23aCaa8fa1aa4aaa6c54aa2aacaafaaa23aCaa', privateKeyBytes: Uint8Array.from( - Buffer.from('4fd90ae1b8f724a4902615c09145ae134617c325b98c6970dcf62ab9cc5e12f3', 'hex'), + Buffer.from('4fd90ae1b8f724a4902615c09145ae134617c325b98c6970dcf62ab9cc5e12f3', 'hex') ), }; diff --git a/modules/bitgo/test/v2/unit/coins/eth2.ts b/modules/sdk-coin-eth2/test/unit/eth2.ts similarity index 72% rename from modules/bitgo/test/v2/unit/coins/eth2.ts rename to modules/sdk-coin-eth2/test/unit/eth2.ts index 18a658ce25..db4ad48128 100644 --- a/modules/bitgo/test/v2/unit/coins/eth2.ts +++ b/modules/sdk-coin-eth2/test/unit/eth2.ts @@ -1,16 +1,17 @@ -import { Eth2 as Eth2AccountLib } from '@bitgo/account-lib'; import { bufferToHex } from 'ethereumjs-util'; -import { TestBitGo } from '@bitgo/sdk-test'; -import { BitGo } from '../../../../src/bitgo'; -import { Eth2, Teth2 } from '../../../../src/v2/coins'; +import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test'; +import { BitGoAPI } from '@bitgo/sdk-api'; +import { Eth2, KeyPair, Teth2 } from '../../src'; describe('Ethereum 2.0', function () { - let bitgo; + let bitgo: TestBitGoAPI; let basecoin; before(async function () { - bitgo = TestBitGo.decorate(BitGo, { env: 'mock' }); + bitgo = TestBitGo.decorate(BitGoAPI, { env: 'mock' }); + bitgo.safeRegister('eth2', Eth2.createInstance); + bitgo.safeRegister('teth2', Teth2.createInstance); bitgo.initializeTestVars(); basecoin = bitgo.coin('teth2'); }); @@ -36,11 +37,9 @@ describe('Ethereum 2.0', function () { }); it('should generate keypair from prv', function () { - const prv = Uint8Array.from( - Buffer.from('4fd90ae1b8f724a4902615c09145ae134617c325b98c6970dcf62ab9cc5e12f3', 'hex') - ); + const prv = Uint8Array.from(Buffer.from('4fd90ae1b8f724a4902615c09145ae134617c325b98c6970dcf62ab9cc5e12f3', 'hex')); const localBaseCoin = bitgo.coin('teth2'); - const keyPair = localBaseCoin.generateKeyPair(prv); + const keyPair = localBaseCoin.generateKeyPair(prv as any); keyPair.prv.should.equal('0x4fd90ae1b8f724a4902615c09145ae134617c325b98c6970dcf62ab9cc5e12f3'); }); @@ -48,19 +47,21 @@ describe('Ethereum 2.0', function () { // FIXME(BG-47812): this test is flaky // @ts-expect-error - no implicit this this.skip(); - const localBaseCoin = bitgo.coin('teth2'); + const localBaseCoin: Teth2 = bitgo.coin('teth2') as Teth2; const keyPair = localBaseCoin.generateKeyPair(); - keyPair.pub.length.should.equal(98); - keyPair.secretShares.every((secretShare) => secretShare.length.should.equal(66)); - (keyPair.pub.startsWith('0x')).should.be.true(); - keyPair.secretShares.every((secretShare) => (secretShare.startsWith('0x')).should.be.true()); - localBaseCoin.isValidPub(keyPair.pub).should.be.true(); + keyPair.pub?.length.should.equal(98); + keyPair.secretShares?.every((secretShare) => secretShare.length.should.equal(66)); + keyPair.pub?.startsWith('0x').should.be.true(); + keyPair.secretShares?.every((secretShare) => secretShare.startsWith('0x').should.be.true()); + localBaseCoin.isValidPub(keyPair.pub as string).should.be.true(); }); it('should reject keypair generation from an invalid prv', function () { const prv = Uint8Array.from(Buffer.from('', 'hex')); const localBaseCoin = bitgo.coin('teth2'); - (function () {localBaseCoin.generateKeyPair(prv);}).should.throw(); + (function () { + localBaseCoin.generateKeyPair(prv as any); + }.should.throw()); }); describe('Sign message:', () => { @@ -82,10 +83,13 @@ describe('Ethereum 2.0', function () { }); const walletSignatureBuffer = await basecoin.signMessage({ prv: walletKey.prv }, message); const walletSignature = bufferToHex(walletSignatureBuffer); - const signature = Eth2AccountLib.KeyPair.aggregateSignatures({ 1: BigInt(userSignature), 3: BigInt(walletSignature) }); + const signature = KeyPair.aggregateSignatures({ + 1: BigInt(userSignature), + 3: BigInt(walletSignature), + }); userKey.pub.should.equal(walletKey.pub); - (await Eth2AccountLib.KeyPair.verifySignature(userKey.pub, Buffer.from(message), signature)).should.be.true(); + (await KeyPair.verifySignature(userKey.pub, Buffer.from(message), signature)).should.be.true(); }); it('should fail to validate a string message with wrong public key', async function () { @@ -107,10 +111,13 @@ describe('Ethereum 2.0', function () { }); const walletSignatureBuffer = await basecoin.signMessage({ prv: walletKey.prv }, message); const walletSignature = bufferToHex(walletSignatureBuffer); - const signature = Eth2AccountLib.KeyPair.aggregateSignatures({ 1: BigInt(userSignature), 3: BigInt(walletSignature) }); + const signature = KeyPair.aggregateSignatures({ + 1: BigInt(userSignature), + 3: BigInt(walletSignature), + }); userKey.pub.should.equal(walletKey.pub); - (await Eth2AccountLib.KeyPair.verifySignature(userKey.pub, Buffer.from(message), signature)).should.be.false(); + (await KeyPair.verifySignature(userKey.pub, Buffer.from(message), signature)).should.be.false(); }); }); }); diff --git a/modules/account-lib/test/unit/coin/eth2/keyPair.ts b/modules/sdk-coin-eth2/test/unit/keyPair.ts similarity index 98% rename from modules/account-lib/test/unit/coin/eth2/keyPair.ts rename to modules/sdk-coin-eth2/test/unit/keyPair.ts index 1c005ea048..054f341d21 100644 --- a/modules/account-lib/test/unit/coin/eth2/keyPair.ts +++ b/modules/sdk-coin-eth2/test/unit/keyPair.ts @@ -1,7 +1,7 @@ import assert from 'assert'; import should from 'should'; -import { KeyPair } from '../../../../src/coin/eth2'; -import * as testData from '../../../resources/eth2/eth2'; +import { KeyPair } from '../../src'; +import * as testData from '../resources/eth2'; const pub = testData.ACCOUNT_1.publicKey; const prv = testData.ACCOUNT_1.privateKey; @@ -28,7 +28,7 @@ describe('Eth2 Key Pair', () => { new KeyPair({ secretShares: ['0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000002'], publicShare: pub, - }), + }) ); }); @@ -38,7 +38,7 @@ describe('Eth2 Key Pair', () => { new KeyPair({ secretShares: [prv], publicShare: '123', - }), + }) ); }); @@ -58,7 +58,7 @@ describe('Eth2 Key Pair', () => { new KeyPair({ threshold: 2, participants: 1, - }), + }) ); }); @@ -112,14 +112,14 @@ describe('Eth2 Key Pair', () => { it('from a public key', () => { assert.throws( () => new KeyPair().recordKeysFromPublicKey(pub), - (e) => e.message.includes(testData.errorMessageInvalidPublicKey), + (e) => e.message.includes(testData.errorMessageInvalidPublicKey) ); }); it('from a private key', () => { assert.throws( () => new KeyPair().recordKeysFromPrivateKey(prv), - (e) => e.message === testData.errorMessageInvalidPrivateKey, + (e) => e.message === testData.errorMessageInvalidPrivateKey ); }); }); diff --git a/modules/sdk-coin-eth2/tsconfig.json b/modules/sdk-coin-eth2/tsconfig.json new file mode 100644 index 0000000000..339ace24a2 --- /dev/null +++ b/modules/sdk-coin-eth2/tsconfig.json @@ -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/**/*", "test/**/*"], + "exclude": ["node_modules"], + "references": [ + { + "path": "../sdk-api" + }, + { + "path": "../sdk-core" + }, + { + "path": "../sdk-test" + } + ] +} diff --git a/modules/sdk-coin-hbar/CHANGELOG.md b/modules/sdk-coin-hbar/CHANGELOG.md index c5d8cf4a45..e8a5315cd8 100644 --- a/modules/sdk-coin-hbar/CHANGELOG.md +++ b/modules/sdk-coin-hbar/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-hbar@1.0.1-rc.1...@bitgo/sdk-coin-hbar@1.0.1-rc.3) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-hbar + + + + + +## [1.0.1-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-hbar@1.0.1-rc.1...@bitgo/sdk-coin-hbar@1.0.1-rc.2) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-hbar + + + + + ## [1.0.1-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-hbar@1.0.1-rc.0...@bitgo/sdk-coin-hbar@1.0.1-rc.1) (2022-07-15) diff --git a/modules/sdk-coin-hbar/package.json b/modules/sdk-coin-hbar/package.json index 4f6c9940e4..b62cd7fd87 100644 --- a/modules/sdk-coin-hbar/package.json +++ b/modules/sdk-coin-hbar/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-hbar", - "version": "1.0.1-rc.1", + "version": "1.0.1-rc.3", "description": "BitGo SDK coin library for Hbar", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,9 +41,9 @@ ] }, "dependencies": { - "@bitgo/sdk-coin-algo": "^1.1.0-rc.14", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-coin-algo": "^1.1.0-rc.16", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@hashgraph/proto": "2.0.1-beta.2", "@hashgraph/sdk": "~2.3.0", "@stablelib/sha384": "^1.0.0", @@ -55,7 +55,7 @@ "tweetnacl": "^1.0.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-ltc/CHANGELOG.md b/modules/sdk-coin-ltc/CHANGELOG.md index f651010c2a..11945c6c70 100644 --- a/modules/sdk-coin-ltc/CHANGELOG.md +++ b/modules/sdk-coin-ltc/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ltc@1.1.0-rc.5...@bitgo/sdk-coin-ltc@1.1.0-rc.7) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-ltc + + + + + +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ltc@1.1.0-rc.5...@bitgo/sdk-coin-ltc@1.1.0-rc.6) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-ltc + + + + + # [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ltc@1.1.0-rc.4...@bitgo/sdk-coin-ltc@1.1.0-rc.5) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-ltc diff --git a/modules/sdk-coin-ltc/package.json b/modules/sdk-coin-ltc/package.json index b675c75f59..30a249038b 100644 --- a/modules/sdk-coin-ltc/package.json +++ b/modules/sdk-coin-ltc/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-ltc", - "version": "1.1.0-rc.5", + "version": "1.1.0-rc.7", "description": "BitGo SDK coin library for Litecoin", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,12 +41,12 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-near/CHANGELOG.md b/modules/sdk-coin-near/CHANGELOG.md index d34780b95c..106ae80950 100644 --- a/modules/sdk-coin-near/CHANGELOG.md +++ b/modules/sdk-coin-near/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-near@1.0.1-rc.3...@bitgo/sdk-coin-near@1.1.0-rc.1) (2022-07-19) + + +### Features + +* **bitgo:** add near hot wallet recovery method ([9538c74](https://github.com/BitGo/BitGoJS/commit/9538c7430da93eba5680ee82b3ed017655074162)) + + + + + +# [1.1.0-rc.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-near@1.0.1-rc.3...@bitgo/sdk-coin-near@1.1.0-rc.0) (2022-07-18) + + +### Features + +* **bitgo:** add near hot wallet recovery method ([9538c74](https://github.com/BitGo/BitGoJS/commit/9538c7430da93eba5680ee82b3ed017655074162)) + + + + + ## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-near@1.0.1-rc.2...@bitgo/sdk-coin-near@1.0.1-rc.3) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-near diff --git a/modules/sdk-coin-near/package.json b/modules/sdk-coin-near/package.json index 7a37fdd756..d6019974c2 100644 --- a/modules/sdk-coin-near/package.json +++ b/modules/sdk-coin-near/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-near", - "version": "1.0.1-rc.3", + "version": "1.1.0-rc.1", "description": "BitGo SDK coin library for Near", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,8 +41,8 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@stablelib/hex": "^1.0.0", "bignumber.js": "^9.0.0", "bn.js": "^5.2.1", @@ -50,11 +50,12 @@ "js-sha256": "^0.9.0", "lodash": "^4.17.14", "near-api-js": "^0.44.2", + "superagent": "^3.8.3", "tweetnacl": "^1.0.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "@types/lodash": "^4.14.121" } } diff --git a/modules/sdk-coin-near/src/near.ts b/modules/sdk-coin-near/src/near.ts index 68d8104b32..4d49b51e83 100644 --- a/modules/sdk-coin-near/src/near.ts +++ b/modules/sdk-coin-near/src/near.ts @@ -19,7 +19,14 @@ import { TransactionExplanation, VerifyAddressOptions, VerifyTransactionOptions, + Ed25519BIP32, + Eddsa, + PublicKey, + Environments, + EDDSA, } from '@bitgo/sdk-core'; +import * as nearAPI from 'near-api-js'; +import * as request from 'superagent'; import { KeyPair as NearKeyPair, Transaction, TransactionBuilderFactory } from './lib'; import nearUtils from './lib/utils'; @@ -62,6 +69,50 @@ interface TransactionOutput { amount: string; } +interface RecoveryOptions { + userKey: string; // Box A + backupKey: string; // Box B + bitgoKey: string; // Box C + recoveryDestination: string; + krsProvider?: string; + walletPassphrase: string; +} + +interface NearTx { + serializedTx: string; +} + +interface NearTxBuilderParamsFromNode { + nonce: number; + blockHash: string; +} + +interface NearFeeConfig { + sendSir: number; + sendNotSir: number; + execution: number; +} + +interface ProtocolConfigOutput { + storageAmountPerByte: number; + transferCost: NearFeeConfig; + receiptConfig: NearFeeConfig; +} + +interface UserSigningMaterial { + uShare: EDDSA.UShare; + bitgoYShare: EDDSA.YShare; + backupYShare: EDDSA.YShare; + userYShare?: EDDSA.YShare; +} + +interface BackupSigningMaterial { + uShare: EDDSA.UShare; + bitgoYShare: EDDSA.YShare; + userYShare: EDDSA.YShare; + backupYShare?: EDDSA.YShare; +} + type TransactionInput = TransactionOutput; export interface NearParsedTransaction extends ParsedTransaction { @@ -78,7 +129,6 @@ export class Near extends BaseCoin { protected readonly _staticsCoin: Readonly; constructor(bitgo: BitGoBase, staticsCoin?: Readonly) { super(bitgo); - if (!staticsCoin) { throw new Error('missing required constructor parameter staticsCoin'); } @@ -86,6 +136,9 @@ export class Near extends BaseCoin { this._staticsCoin = staticsCoin; } + protected static initialized = false; + protected static MPC: Eddsa; + static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly): BaseCoin { return new Near(bitgo, staticsCoin); } @@ -268,13 +321,286 @@ export class Near extends BaseCoin { txHex: serializedTx, } as any; } + // TODO(BG-51092): Needs to be moved to a common place to re-use it for other coins + static async getInitializedMpcInstance(): Promise { + if (this.initialized) { + return this.MPC; + } + const hdTree = await Ed25519BIP32.initialize(); + this.MPC = await Eddsa.initialize(hdTree); + this.initialized = true; + return this.MPC; + } + + // TODO(BG-51092): Needs to be moved to a common place to re-use it for other coins + async getTSSSignature( + userSigningMaterial: UserSigningMaterial, + backupSigningMaterial: BackupSigningMaterial, + path = 'm/0', + transaction: Transaction + ): Promise { + const MPC = await Near.getInitializedMpcInstance(); + + const userCombine = MPC.keyCombine(userSigningMaterial.uShare, [ + userSigningMaterial.bitgoYShare, + userSigningMaterial.backupYShare, + ]); + const backupCombine = MPC.keyCombine(backupSigningMaterial.uShare, [ + backupSigningMaterial.bitgoYShare, + backupSigningMaterial.userYShare, + ]); + + const userSubkey = MPC.keyDerive( + userSigningMaterial.uShare, + [userSigningMaterial.bitgoYShare, userSigningMaterial.backupYShare], + path + ); + + const backupSubkey = MPC.keyCombine(backupSigningMaterial.uShare, [ + userSubkey.yShares[2], + backupSigningMaterial.bitgoYShare, + ]); + + const messageBuffer = transaction.signablePayload; + const userSignShare = MPC.signShare(messageBuffer, userSubkey.pShare, [userCombine.jShares[2]]); + const backupSignShare = MPC.signShare(messageBuffer, backupSubkey.pShare, [backupCombine.jShares[1]]); + const userSign = MPC.sign( + messageBuffer, + userSignShare.xShare, + [backupSignShare.rShares[1]], + [userSigningMaterial.bitgoYShare] + ); + const backupSign = MPC.sign( + messageBuffer, + backupSignShare.xShare, + [userSignShare.rShares[2]], + [backupSigningMaterial.bitgoYShare] + ); + const signature = MPC.signCombine([userSign, backupSign]); + const result = MPC.verify(messageBuffer, signature); + result.should.equal(true); + const rawSignature = Buffer.concat([Buffer.from(signature.R, 'hex'), Buffer.from(signature.sigma, 'hex')]); + return rawSignature; + } /** * Builds a funds recovery transaction without BitGo * @param params */ - async recover(params: any): Promise { - throw new MethodNotImplementedError('Near recovery not implemented'); + async recover(params: RecoveryOptions): Promise { + // TODO(BG-51092): This looks like a common part which can be extracted out too + /* ***************** START **************************************/ + if (_.isUndefined(params.userKey)) { + throw new Error('missing userKey'); + } + + if (_.isUndefined(params.backupKey)) { + throw new Error('missing backupKey'); + } + + if (_.isUndefined(params.bitgoKey)) { + throw new Error('missing backupKey'); + } + + if (_.isUndefined(params.walletPassphrase) && !params.userKey.startsWith('xpub')) { + throw new Error('missing wallet passphrase'); + } + + if (_.isUndefined(params.recoveryDestination) || !this.isValidAddress(params.recoveryDestination)) { + throw new Error('invalid recoveryDestination'); + } + + // Clean up whitespace from entered values + const userKey = params.userKey.replace(/\s/g, ''); + const backupKey = params.backupKey.replace(/\s/g, ''); + const bitgoKey = params.bitgoKey.replace(/\s/g, ''); + + // Decrypt private keys from KeyCard values + let userPrv; + if (!userKey.startsWith('xpub') && !userKey.startsWith('xprv')) { + try { + userPrv = this.bitgo.decrypt({ + input: userKey, + password: params.walletPassphrase, + }); + } catch (e) { + throw new Error(`Error decrypting user keychain: ${e.message}`); + } + } + /** TODO BG-52419 Implement Codec for parsing */ + const userSigningMaterial = JSON.parse(userPrv) as UserSigningMaterial; + + let backupPrv; + try { + backupPrv = this.bitgo.decrypt({ + input: backupKey, + password: params.walletPassphrase, + }); + } catch (e) { + throw new Error(`Error decrypting backup keychain: ${e.message}`); + } + const backupSigningMaterial = JSON.parse(backupPrv) as BackupSigningMaterial; + /* ********************** END ***********************************/ + + const MPC = await Near.getInitializedMpcInstance(); + const accountId = MPC.deriveUnhardened(bitgoKey, `m/0`).slice(0, 64); + const bs58EncodedPublicKey = nearAPI.utils.serialize.base_encode(new Uint8Array(Buffer.from(accountId, 'hex'))); + const { storageAmountPerByte, transferCost, receiptConfig } = await this.getProtocolConfig(); + const availableBalance = new BigNumber(await this.getAccountBalance(accountId, storageAmountPerByte)); + const { nonce, blockHash } = await this.getAccessKey({ accountId, bs58EncodedPublicKey }); + const gasPrice = await this.getGasPrice(blockHash); + const gasPriceFirstBlock = new BigNumber(gasPrice); + const gasPriceSecondBlock = gasPriceFirstBlock.multipliedBy(1.05); + const totalGasRequired = new BigNumber(transferCost.sendSir) + .plus(receiptConfig.sendSir) + .multipliedBy(gasPriceFirstBlock) + .plus(new BigNumber(transferCost.execution).plus(receiptConfig.execution).multipliedBy(gasPriceSecondBlock)); + // adding some padding to make sure the gas doesn't go below required gas by network + const totalGasWithPadding = totalGasRequired.multipliedBy(1.5); + const netAmount = availableBalance.minus(totalGasWithPadding).toFixed(); + const factory = new TransactionBuilderFactory(coins.get(this.getChain())); + const txBuilder = factory + .getTransferBuilder() + .sender(accountId, accountId) + .nonce(nonce) + .receiverId(params.recoveryDestination) + .recentBlockHash(blockHash) + .amount(netAmount); + const unsignedTransaction = (await txBuilder.build()) as Transaction; + + // add signature + const signatureHex = await this.getTSSSignature( + userSigningMaterial, + backupSigningMaterial, + 'm/0', + unsignedTransaction + ); + const publicKeyObj = { pub: accountId }; + txBuilder.addSignature(publicKeyObj as PublicKey, signatureHex); + const signedTransaction = await txBuilder.build(); + const serializedTx = signedTransaction.toBroadcastFormat(); + return { serializedTx: serializedTx }; + } + + /** + * Make a request to one of the public EOS nodes available + * @param params.payload + */ + protected async getDataFromNode(params: { payload?: Record }): Promise { + const nodeUrls = this.getPublicNodeUrls(); + for (const nodeUrl of nodeUrls) { + try { + return await request.post(nodeUrl).send(params.payload); + } catch (e) { + console.debug(e); + } + } + throw new Error(`Unable to call endpoint: '/' from nodes: ${_.join(nodeUrls, ', ')}`); + } + + protected async getAccessKey({ + accountId, + bs58EncodedPublicKey, + }: { + accountId: string; + bs58EncodedPublicKey: string; + }): Promise { + const response = await this.getDataFromNode({ + payload: { + jsonrpc: '2.0', + id: 'dontcare', + method: 'query', + params: { + request_type: 'view_access_key', + finality: 'final', + account_id: accountId, + public_key: bs58EncodedPublicKey, + }, + }, + }); + if (response.status !== 200) { + throw new Error('Account not found'); + } + const accessKey = response.body.result; + return { nonce: ++accessKey.nonce, blockHash: accessKey.block_hash }; + } + + protected async getAccountBalance(accountId: string, storageAmountPerByte: number): Promise { + const response = await this.getDataFromNode({ + payload: { + jsonrpc: '2.0', + id: 'dontcare', + method: 'query', + params: { + request_type: 'view_account', + finality: 'final', + account_id: accountId, + }, + }, + }); + if (response.status !== 200) { + throw new Error('Account not found'); + } + + const account = response.body.result; + const costPerByte = new BigNumber(storageAmountPerByte); + const stateStaked = new BigNumber(account.storage_usage).multipliedBy(costPerByte); + const staked = new BigNumber(account.locked); + const totalBalance = new BigNumber(account.amount).plus(staked); + const availableBalance = totalBalance.minus(BigNumber.max(staked, stateStaked)); + return availableBalance.toString(); + } + + protected async getProtocolConfig(): Promise { + const response = await this.getDataFromNode({ + payload: { + jsonrpc: '2.0', + id: 'dontcare', + method: 'EXPERIMENTAL_protocol_config', + params: { + finality: 'final', + }, + }, + }); + if (response.status !== 200) { + throw new Error('Account not found'); + } + + const config = response.body.result; + const storageAmountPerByte = config.runtime_config.storage_amount_per_byte; + const transferCostFromNetwork = config.runtime_config.transaction_costs.action_creation_config.transfer_cost; + const transferCost: NearFeeConfig = { + sendSir: transferCostFromNetwork.send_sir, + sendNotSir: transferCostFromNetwork.send_not_sir, + execution: transferCostFromNetwork.execution, + }; + + const receiptConfigFromNetwork = config.runtime_config.transaction_costs.action_receipt_creation_config; + const receiptConfig: NearFeeConfig = { + sendSir: receiptConfigFromNetwork.send_sir, + sendNotSir: receiptConfigFromNetwork.send_not_sir, + execution: receiptConfigFromNetwork.execution, + }; + return { storageAmountPerByte, transferCost, receiptConfig }; + } + + protected async getGasPrice(blockHash: string): Promise { + const response = await this.getDataFromNode({ + payload: { + jsonrpc: '2.0', + id: 'dontcare', + method: 'gas_price', + params: [blockHash], + }, + }); + if (response.status !== 200) { + throw new Error('Account not found'); + } + return response.body.result.gas_price; + } + + protected getPublicNodeUrls(): string[] { + return Environments[this.bitgo.getEnv()].nearNodeUrls; } async parseTransaction(params: NearParseTransactionOptions): Promise { diff --git a/modules/sdk-coin-near/test/fixtures/near.ts b/modules/sdk-coin-near/test/fixtures/near.ts index efe9eeebd9..b0cf76b186 100644 --- a/modules/sdk-coin-near/test/fixtures/near.ts +++ b/modules/sdk-coin-near/test/fixtures/near.ts @@ -68,3 +68,315 @@ export const rawTx = { }; export const validatorContractAddress = 'lavenderfive.pool.f863973.m0'; + +const getAccessKeyResponse = { + status: 200, + body: { + jsonrpc: '2.0', + result: { + block_hash: '844N9aWefd4TvJwdiBgXDVPz4W9z436kohTiXnp5y4fq', + block_height: 93510058, + nonce: 92548028000014, + permission: 'FullAccess', + }, + id: 'dontcare', + }, +}; + +const getAccountResponse = { + status: 200, + body: { + jsonrpc: '2.0', + result: { + amount: '197939394723504238400000001', + block_hash: '3wdCKZM5FUDXbNMGH91s3Qz6PgBrBk2ewRfvY2CkP2mv', + block_height: 93510153, + code_hash: '11111111111111111111111111111111', + locked: '0', + storage_paid_at: 0, + storage_usage: 182, + }, + id: 'dontcare', + }, +}; + +const getProtocolConfigResp = { + status: 200, + body: { + jsonrpc: '2.0', + result: { + avg_hidden_validator_seats_per_shard: [0, 0, 0, 0], + block_producer_kickout_threshold: 80, + chain_id: 'testnet', + chunk_producer_kickout_threshold: 90, + dynamic_resharding: false, + epoch_length: 43200, + fishermen_threshold: '340282366920938463463374607431768211455', + gas_limit: 1000000000000000, + gas_price_adjustment_rate: [1, 100], + genesis_height: 42376888, + genesis_time: '2020-07-31T03:39:42.911378Z', + max_gas_price: '10000000000000000000000', + max_inflation_rate: [1, 20], + min_gas_price: '5000', + minimum_stake_divisor: 10, + num_block_producer_seats: 200, + num_block_producer_seats_per_shard: [200, 200, 200, 200], + num_blocks_per_year: 31536000, + online_max_threshold: [99, 100], + online_min_threshold: [90, 100], + protocol_reward_rate: [1, 10], + protocol_treasury_account: 'near', + protocol_upgrade_stake_threshold: [4, 5], + protocol_version: 54, + runtime_config: { + account_creation_config: { + min_allowed_top_level_account_length: 32, + registrar_account_id: 'registrar', + }, + storage_amount_per_byte: '10000000000000000000', + transaction_costs: { + action_creation_config: { + add_key_cost: { + full_access_cost: { + execution: 101765125000, + send_not_sir: 101765125000, + send_sir: 101765125000, + }, + function_call_cost: { + execution: 102217625000, + send_not_sir: 102217625000, + send_sir: 102217625000, + }, + function_call_cost_per_byte: { + execution: 1925331, + send_not_sir: 1925331, + send_sir: 1925331, + }, + }, + create_account_cost: { + execution: 99607375000, + send_not_sir: 99607375000, + send_sir: 99607375000, + }, + delete_account_cost: { + execution: 147489000000, + send_not_sir: 147489000000, + send_sir: 147489000000, + }, + delete_key_cost: { + execution: 94946625000, + send_not_sir: 94946625000, + send_sir: 94946625000, + }, + deploy_contract_cost: { + execution: 184765750000, + send_not_sir: 184765750000, + send_sir: 184765750000, + }, + deploy_contract_cost_per_byte: { + execution: 64572944, + send_not_sir: 6812999, + send_sir: 6812999, + }, + function_call_cost: { + execution: 2319861500000, + send_not_sir: 2319861500000, + send_sir: 2319861500000, + }, + function_call_cost_per_byte: { + execution: 2235934, + send_not_sir: 2235934, + send_sir: 2235934, + }, + stake_cost: { + execution: 102217625000, + send_not_sir: 141715687500, + send_sir: 141715687500, + }, + transfer_cost: { + execution: 115123062500, + send_not_sir: 115123062500, + send_sir: 115123062500, + }, + }, + action_receipt_creation_config: { + execution: 108059500000, + send_not_sir: 108059500000, + send_sir: 108059500000, + }, + burnt_gas_reward: [3, 10], + data_receipt_creation_config: { + base_cost: { + execution: 36486732312, + send_not_sir: 36486732312, + send_sir: 36486732312, + }, + cost_per_byte: { + execution: 17212011, + send_not_sir: 17212011, + send_sir: 17212011, + }, + }, + pessimistic_gas_price_inflation_ratio: [103, 100], + storage_usage_config: { + num_bytes_account: 100, + num_extra_bytes_record: 40, + }, + }, + wasm_config: { + ext_costs: { + base: 264768111, + contract_loading_base: 35445963, + contract_loading_bytes: 216750, + ecrecover_base: 278821988457, + keccak256_base: 5879491275, + keccak256_byte: 21471105, + keccak512_base: 5811388236, + keccak512_byte: 36649701, + log_base: 3543313050, + log_byte: 13198791, + promise_and_base: 1465013400, + promise_and_per_promise: 5452176, + promise_return: 560152386, + read_cached_trie_node: 2280000000, + read_memory_base: 2609863200, + read_memory_byte: 3801333, + read_register_base: 2517165186, + read_register_byte: 98562, + ripemd160_base: 853675086, + ripemd160_block: 680107584, + sha256_base: 4540970250, + sha256_byte: 24117351, + storage_has_key_base: 54039896625, + storage_has_key_byte: 30790845, + storage_iter_create_from_byte: 0, + storage_iter_create_prefix_base: 0, + storage_iter_create_prefix_byte: 0, + storage_iter_create_range_base: 0, + storage_iter_create_to_byte: 0, + storage_iter_next_base: 0, + storage_iter_next_key_byte: 0, + storage_iter_next_value_byte: 0, + storage_read_base: 56356845750, + storage_read_key_byte: 30952533, + storage_read_value_byte: 5611005, + storage_remove_base: 53473030500, + storage_remove_key_byte: 38220384, + storage_remove_ret_value_byte: 11531556, + storage_write_base: 64196736000, + storage_write_evicted_byte: 32117307, + storage_write_key_byte: 70482867, + storage_write_value_byte: 31018539, + touching_trie_node: 16101955926, + utf16_decoding_base: 3543313050, + utf16_decoding_byte: 163577493, + utf8_decoding_base: 3111779061, + utf8_decoding_byte: 291580479, + validator_stake_base: 911834726400, + validator_total_stake_base: 911834726400, + write_memory_base: 2803794861, + write_memory_byte: 2723772, + write_register_base: 2865522486, + write_register_byte: 3801564, + }, + grow_mem_cost: 1, + limit_config: { + initial_memory_pages: 1024, + max_actions_per_receipt: 100, + max_arguments_length: 4194304, + max_contract_size: 4194304, + max_functions_number_per_contract: 10000, + max_gas_burnt: 300000000000000, + max_length_method_name: 256, + max_length_returned_data: 4194304, + max_length_storage_key: 2048, + max_length_storage_value: 4194304, + max_locals_per_contract: 1000000, + max_memory_pages: 2048, + max_number_bytes_method_names: 2000, + max_number_input_data_dependencies: 128, + max_number_logs: 100, + max_number_registers: 100, + max_promises_per_function_call_action: 1024, + max_register_size: 104857600, + max_stack_height: 16384, + max_total_log_length: 16384, + max_total_prepaid_gas: 300000000000000, + max_transaction_size: 4194304, + registers_memory_limit: 1073741824, + stack_limiter_version: 1, + wasmer2_stack_limit: 204800, + }, + regular_op_cost: 822756, + }, + }, + transaction_validity_period: 86400, + }, + id: 'dontcare', + }, +}; + +const getGasPriceResponse = { + status: 200, + body: { + jsonrpc: '2.0', + result: { + gas_price: '100000000', + }, + id: 'dontcare', + }, +}; + +export const NearResponses = { + getAccessKeyResponse, + getAccountResponse, + getGasPriceResponse, + getProtocolConfigResp, +} as const; + +export const keys = { + userKey: + '{"iv":"I8cx17GV2qZ9HKF5ITZS4g==","v":1,"iter":10000,"ks":256,"ts":64,"mode"\n' + + ':"ccm","adata":"","cipher":"aes","salt":"0k+79wgoUDU=","ct":"adpZXywRNHhLMI\n' + + 'IDae6KoQh6XmyNIslINE7aTd/9khp1/mu4uioKrJl0fAWC4+DdWWrEOiXKipX9yqvB5udWTDfaW\n' + + 'nM+ySG15MQ0Qrx0k1TqsDaYFFtQaNv64BV1nmOJrrT6gp5TRq3nxssgLnwdDJl8JvuSHplCxwKF\n' + + 'PynXTyZuVQ7mxMoruGnqHRrOf+9gS5xUySH/QKf1C8RpA0QZDlGcJS6i7bhAk894x694EYZu37q\n' + + 'V2mWs/oPtWMFAscFUNReSUcHu2rWV546/spJLog7d891Hq/Dq5aVxOYJkZmwLnFOc2Rz1qmz5s+\n' + + 'ExlXaDoGphVVYgq4Lhm6HQ4zKDCqo8oIPWGLCG437mTU1axmMPLNcDOEXqSfHLOhiOPgDS9YrYJ\n' + + 'EPAfiEfE3tR7SfqLMy9kwNmDM86EtPmoZcYEDHhz3oaVwT07+wwRH63cTGdPOlg8FusfBqFh8Ob\n' + + '2molhY6JdLeH1jc42rs0/GNWIH/kcm+LVAWqLRvax5nVCBMreKj1EfvsBADfUdXoIotRs1wqixO\n' + + 'D1p1PgRNJKBP4t7j2OXaij7FyKz6LU8dC6FcWvGAxkBeB5Lgo8GG/AaSMWwJY6eRTV8wBCsj9TL\n' + + 'M9+dhvZdQSvBGlstWgLLk1bPuAlNabOdnDmJa+IavKafaiP8LYCrfKaBZ2/ogC+aEvipEEOCk0J\n' + + 'h+A/PBcwl3Z+oPBzKNVvox0Cvp6rCUjuRVaH/TcoijASQ9DK0c8Kz2bc1BzAUJYGag1JngHsPbw\n' + + 'T41oifOVevJeVfl8Fe5M7UPGUyNm7Khu/l8pg25rO7n0MfIjgnyFVOZ/2aeZFy4ww/Ix1GLRLkS\n' + + '6VvlY2Bh6yhn0mFMIJPWZsUHVfbxuPpD2tPPufULiIXx/r/09HBlJp420GggTVIiMh9zXrek0vz\n' + + 'Mb/dfAnqX2msIF//R8LjsVBu9SRdDlqbJW3vviX1rw1XRT8Bpg5ieSWz8uVt7dzYzzsMwi8YwaA\n' + + 'FynwFHzi1aymP1gAyklubtcw8A="}', + backupKey: + '{"iv":"lbXgY5IYb9z3gwuYsD6oJA==","v":1,"iter":10000,"ks":256,"ts":64,"mode"\n' + + ':"ccm","adata":"","cipher":"aes","salt":"Wg9AcOhVCWQ=","ct":"YeJOJDQ6f/rc0D\n' + + 'nlsXyLYc6qhTITyEkZyFmt4X7TFMoG4otdVdx/wh+ieC/lssAgooqwyiW056QGFNCTIMbEI/zSm\n' + + 'rS362hQx9QK49Eadkc5pO2Qfm/EXlYAAi/hFe2q8tk4IU+CAowW7QcyJ5NMIb+J2ImqGKxgROC9\n' + + '4M4/ZxXTtbkalEVtwAF0Pyui8O0p+JHA/Q1D+9yPl3SfXu6D/GYV+RcmMtgae+wQYuIdx7fxGQk\n' + + 'EqMy9NfewKK/T+2SLpqYwED3C6OtMOM2URkPpU72KmRUzZllxk1/oLFVcHycLTd68qyfQr7QN2f\n' + + '8pKKvq7VdbLBS+VIcTbSFpO6WPJrEt/oUqQ8E3FLCQ7sAkZe6NNzyREJ5Ci/xCvnEAmeJz04kiR\n' + + 'qE4XGYpqObUhMHjfl80T2fxE66xdgCrbUfhPsQhmmJly8q1gFln3I6UJ+szXN4F0WAqx2SupHFy\n' + + '/JcGhyquq7b/+AXth3fFGdI3xL5x9ygMyCndUyk6bie8DWgtc6UW/a5Hz7FDNh7r2SujF0gHDut\n' + + 'yI7ff9qRfSTqf75YI3vkhqJp3O+LNiQpuTqpwPCTNl92FnAtcdEAw3V6QQXEe+rPlUeJbym1Qa/\n' + + 'cNHT0HGxd9/Yqd635CjhH2xUK4I2NyTaRvoNQh9PLUMVL/UqHRbL+AOTn7deVGRMBTf2GtfJcnV\n' + + 'cvtopuik+MlhceDu2SIwIgWbvXApV6drBnX8W7HPczcIi5O/IH2XawXIvSV6JsVxXeYY/KUsfih\n' + + '+RK4Qs5x8kZHyjl3vuFBEL4tWaKyc3A1zt375+3PUsDUMR+wyP3ANzXsgxpvzOVX/KFP709Mp0v\n' + + 'YJyctc/N1XD/RZ2xj6bha6ybsFUiNfT3v83+dKSMLUKzDe0IDqoC/XgYpo89z0zyFG4jpnVqUHz\n' + + 'hxrDtsDch1fFf/4B4xm8uGfDNcc0f5O+8eAzzmy/Kat79i9V1xCAE8gn7mAZILkzLnSbD1JyXaG\n' + + '5NK0trXhDQqFp7Gt6zYv6aG"}', + bitgoKey: + '8699d2e05d60a3f7ab733a74ccf707f3407494b60f4253616187f5262e20737519a1763de0b\n' + + 'cc4d165a7fa0e4dde67a1426ec4cc9fcd0820d749e6589dcfa08e', +}; + +export const accountInfo = { + accountId: 'f256196dae617aa348149c1e61e997272492668d517506d7a6e2392e06ea532c', + bs58EncodedPublicKey: 'HJyoxJMxRHnAp3oE73kuKnNYtvFEmp7UkQZNDFRokLVH', + blockHash: '844N9aWefd4TvJwdiBgXDVPz4W9z436kohTiXnp5y4fq', +}; diff --git a/modules/sdk-coin-near/test/unit/near.ts b/modules/sdk-coin-near/test/unit/near.ts index 960145abe8..3da1dbf3ea 100644 --- a/modules/sdk-coin-near/test/unit/near.ts +++ b/modules/sdk-coin-near/test/unit/near.ts @@ -2,7 +2,15 @@ import should = require('should'); import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test'; import { BitGoAPI } from '@bitgo/sdk-api'; import { randomBytes } from 'crypto'; -import { rawTx, accounts, validatorContractAddress, blockHash } from '../fixtures/near'; +import { + rawTx, + accounts, + validatorContractAddress, + blockHash, + NearResponses, + keys, + accountInfo, +} from '../fixtures/near'; import * as _ from 'lodash'; import * as sinon from 'sinon'; import { KeyPair, Near, TNear, Transaction } from '../../src'; @@ -654,4 +662,60 @@ describe('NEAR:', function () { }); }); }); + + describe('Recover Transactions:', () => { + it('should recover a txn for non-bitgo recoveries', async function () { + const sandBox = sinon.createSandbox(); + const callBack = sandBox.stub(Near.prototype, 'getDataFromNode' as keyof Near); + callBack + .withArgs({ + payload: { + jsonrpc: '2.0', + id: 'dontcare', + method: 'query', + params: { + request_type: 'view_access_key', + finality: 'final', + account_id: accountInfo.accountId, + public_key: accountInfo.bs58EncodedPublicKey, + }, + }, + }) + .resolves(NearResponses.getAccessKeyResponse); + callBack + .withArgs({ + payload: { + jsonrpc: '2.0', + id: 'dontcare', + method: 'query', + params: { + request_type: 'view_account', + finality: 'final', + account_id: accountInfo.accountId, + }, + }, + }) + .resolves(NearResponses.getAccountResponse); + callBack.withArgs().resolves(NearResponses.getProtocolConfigResp); + callBack + .withArgs({ + payload: { + jsonrpc: '2.0', + id: 'dontcare', + method: 'gas_price', + params: [accountInfo.blockHash], + }, + }) + .resolves(NearResponses.getGasPriceResponse); + const res = await basecoin.recover({ + userKey: keys.userKey, + backupKey: keys.backupKey, + bitgoKey: keys.bitgoKey, + recoveryDestination: 'abhay-near.testnet', + walletPassphrase: 'Ghghjkg!455544llll', + }); + res.should.not.be.empty(); + res.should.hasOwnProperty('serializedTx'); + }); + }); }); diff --git a/modules/sdk-coin-polygon/.eslintignore b/modules/sdk-coin-polygon/.eslintignore new file mode 100644 index 0000000000..190f83e0df --- /dev/null +++ b/modules/sdk-coin-polygon/.eslintignore @@ -0,0 +1,5 @@ +node_modules +.idea +public +dist + diff --git a/modules/sdk-coin-polygon/.gitignore b/modules/sdk-coin-polygon/.gitignore new file mode 100644 index 0000000000..67ccce4c64 --- /dev/null +++ b/modules/sdk-coin-polygon/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +.idea/ +dist/ diff --git a/modules/sdk-coin-polygon/.mocharc.yml b/modules/sdk-coin-polygon/.mocharc.yml new file mode 100644 index 0000000000..95814796d1 --- /dev/null +++ b/modules/sdk-coin-polygon/.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-polygon/.npmignore b/modules/sdk-coin-polygon/.npmignore new file mode 100644 index 0000000000..d5fb3a098c --- /dev/null +++ b/modules/sdk-coin-polygon/.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-polygon/.prettierignore b/modules/sdk-coin-polygon/.prettierignore new file mode 100644 index 0000000000..3a11d6af29 --- /dev/null +++ b/modules/sdk-coin-polygon/.prettierignore @@ -0,0 +1,2 @@ +.nyc_output/ +dist/ diff --git a/modules/sdk-coin-polygon/.prettierrc.yml b/modules/sdk-coin-polygon/.prettierrc.yml new file mode 100644 index 0000000000..7c3d8dd32a --- /dev/null +++ b/modules/sdk-coin-polygon/.prettierrc.yml @@ -0,0 +1,3 @@ +printWidth: 120 +singleQuote: true +trailingComma: 'es5' diff --git a/modules/sdk-coin-polygon/CHANGELOG.md b/modules/sdk-coin-polygon/CHANGELOG.md new file mode 100644 index 0000000000..6c65f2e46a --- /dev/null +++ b/modules/sdk-coin-polygon/CHANGELOG.md @@ -0,0 +1,11 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## 1.0.1-rc.0 (2022-07-19) + + +### Bug Fixes + +* update bad dependency match ([5cc3255](https://github.com/BitGo/BitGoJS/commit/5cc3255aecba1ffb112da3ba10d8d36d2074b3e3)) diff --git a/modules/sdk-coin-polygon/README.md b/modules/sdk-coin-polygon/README.md new file mode 100644 index 0000000000..bcb5ab1df5 --- /dev/null +++ b/modules/sdk-coin-polygon/README.md @@ -0,0 +1,30 @@ +# BitGo sdk-coin-polygon + +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-polygon`. + +```shell +npm i @bitgo/sdk-api @bitgo/sdk-coin-polygon +``` + +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 { Polygon } from '@bitgo/sdk-coin-polygon'; + +const sdk = new BitGoAPI(); + +sdk.register('polygon', Polygon.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-polygon/package.json b/modules/sdk-coin-polygon/package.json new file mode 100644 index 0000000000..91b9eb0d75 --- /dev/null +++ b/modules/sdk-coin-polygon/package.json @@ -0,0 +1,58 @@ +{ + "name": "@bitgo/sdk-coin-polygon", + "version": "1.0.1-rc.0", + "description": "BitGo SDK coin library for Polygon", + "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 .", + "precommit": "yarn lint-staged", + "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": ">=14 <17" + }, + "repository": { + "type": "git", + "url": "https://github.com/BitGo/BitGoJS.git", + "directory": "modules/sdk-coin-polygon" + }, + "lint-staged": { + "*.{js,ts}": [ + "yarn prettier --write", + "yarn eslint --fix" + ] + }, + "publishConfig": { + "access": "public" + }, + "nyc": { + "extension": [ + ".ts" + ] + }, + "dependencies": { + "@bitgo/abstract-eth": "^1.0.1-rc.23", + "@bitgo/sdk-coin-eth": "^1.1.0-rc.3", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", + "@ethereumjs/common": "^2.4.0", + "bignumber.js": "^9.0.0", + "ethereumjs-abi": "^0.6.5" + }, + "devDependencies": { + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", + "bip32": "^2.0.6", + "secp256k1": "^4.0.2" + } +} diff --git a/modules/sdk-coin-polygon/src/index.ts b/modules/sdk-coin-polygon/src/index.ts new file mode 100644 index 0000000000..f95b134f29 --- /dev/null +++ b/modules/sdk-coin-polygon/src/index.ts @@ -0,0 +1,3 @@ +export * from './lib'; +export * from './polygon'; +export * from './tpolygon'; diff --git a/modules/account-lib/src/coin/polygon/index.ts b/modules/sdk-coin-polygon/src/lib/index.ts similarity index 100% rename from modules/account-lib/src/coin/polygon/index.ts rename to modules/sdk-coin-polygon/src/lib/index.ts diff --git a/modules/account-lib/src/coin/polygon/resources.ts b/modules/sdk-coin-polygon/src/lib/resources.ts similarity index 97% rename from modules/account-lib/src/coin/polygon/resources.ts rename to modules/sdk-coin-polygon/src/lib/resources.ts index 6df17079e3..49a8f2c606 100644 --- a/modules/account-lib/src/coin/polygon/resources.ts +++ b/modules/sdk-coin-polygon/src/lib/resources.ts @@ -11,7 +11,7 @@ export const testnetCommon = EthereumCommon.forCustomChain( networkId: (coins.get('tpolygon').network as EthereumNetwork).chainId, chainId: (coins.get('tpolygon').network as EthereumNetwork).chainId, }, - 'london', + 'london' ); /** @@ -24,5 +24,5 @@ export const mainnetCommon = EthereumCommon.forCustomChain( networkId: (coins.get('polygon').network as EthereumNetwork).chainId, chainId: (coins.get('polygon').network as EthereumNetwork).chainId, }, - 'london', + 'london' ); diff --git a/modules/account-lib/src/coin/polygon/transactionBuilder.ts b/modules/sdk-coin-polygon/src/lib/transactionBuilder.ts similarity index 100% rename from modules/account-lib/src/coin/polygon/transactionBuilder.ts rename to modules/sdk-coin-polygon/src/lib/transactionBuilder.ts index 652f70b4b7..98e4db88d9 100644 --- a/modules/account-lib/src/coin/polygon/transactionBuilder.ts +++ b/modules/sdk-coin-polygon/src/lib/transactionBuilder.ts @@ -1,9 +1,9 @@ -import { BaseCoin as CoinConfig } from '@bitgo/statics'; -import EthereumAbi from 'ethereumjs-abi'; import { TransactionBuilder as EthTransactionBuilder } from '@bitgo/sdk-coin-eth'; import { BuildTransactionError, TransactionType } from '@bitgo/sdk-core'; -import { walletSimpleByteCode, walletSimpleConstructor } from './walletUtil'; +import { BaseCoin as CoinConfig } from '@bitgo/statics'; +import EthereumAbi from 'ethereumjs-abi'; import { getCommon } from './utils'; +import { walletSimpleByteCode, walletSimpleConstructor } from './walletUtil'; import { Transaction, TransferBuilder } from './'; export class TransactionBuilder extends EthTransactionBuilder { diff --git a/modules/account-lib/src/coin/polygon/transferBuilder.ts b/modules/sdk-coin-polygon/src/lib/transferBuilder.ts similarity index 100% rename from modules/account-lib/src/coin/polygon/transferBuilder.ts rename to modules/sdk-coin-polygon/src/lib/transferBuilder.ts diff --git a/modules/account-lib/src/coin/polygon/utils.ts b/modules/sdk-coin-polygon/src/lib/utils.ts similarity index 100% rename from modules/account-lib/src/coin/polygon/utils.ts rename to modules/sdk-coin-polygon/src/lib/utils.ts index 6084a1ee96..0ddaa2327f 100644 --- a/modules/account-lib/src/coin/polygon/utils.ts +++ b/modules/sdk-coin-polygon/src/lib/utils.ts @@ -1,7 +1,7 @@ -import { NetworkType } from '@bitgo/statics'; -import EthereumCommon from '@ethereumjs/common'; import { Utils, KeyPair, TxData } from '@bitgo/sdk-coin-eth'; import { InvalidTransactionError } from '@bitgo/sdk-core'; +import { NetworkType } from '@bitgo/statics'; +import EthereumCommon from '@ethereumjs/common'; import { testnetCommon, mainnetCommon } from './resources'; /** diff --git a/modules/account-lib/src/coin/polygon/walletUtil.ts b/modules/sdk-coin-polygon/src/lib/walletUtil.ts similarity index 100% rename from modules/account-lib/src/coin/polygon/walletUtil.ts rename to modules/sdk-coin-polygon/src/lib/walletUtil.ts diff --git a/modules/bitgo/src/v2/coins/polygon.ts b/modules/sdk-coin-polygon/src/polygon.ts similarity index 92% rename from modules/bitgo/src/v2/coins/polygon.ts rename to modules/sdk-coin-polygon/src/polygon.ts index 130e1c166c..13b0ebf694 100644 --- a/modules/bitgo/src/v2/coins/polygon.ts +++ b/modules/sdk-coin-polygon/src/polygon.ts @@ -1,12 +1,12 @@ /** * @prettier */ -import { BaseCoin, BitGoBase, TransactionExplanation } from '@bitgo/sdk-core'; -import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics'; +import { ExplainTransactionOptions } from '@bitgo/abstract-eth'; import { Eth, Recipient, GetSendMethodArgsOptions, SendMethodArgs, optionalDeps } from '@bitgo/sdk-coin-eth'; -import { getBuilder, Polygon as PolygonAccountLib } from '@bitgo/account-lib'; +import { BaseCoin, BitGoBase, TransactionExplanation } from '@bitgo/sdk-core'; +import { BaseCoin as StaticsBaseCoin, coins } from '@bitgo/statics'; import BigNumber from 'bignumber.js'; -import { ExplainTransactionOptions } from '@bitgo/abstract-eth'; +import { KeyPair, TransactionBuilder } from './lib'; export class Polygon extends Eth { protected readonly _staticsCoin: Readonly; @@ -47,7 +47,7 @@ export class Polygon extends Eth { isValidPub(pub: string): boolean { let valid = true; try { - new PolygonAccountLib.KeyPair({ pub }); + new KeyPair({ pub }); } catch (e) { valid = false; } @@ -89,8 +89,8 @@ export class Polygon extends Eth { * Create a new transaction builder for the current chain * @return a new transaction builder */ - protected getTransactionBuilder(): PolygonAccountLib.TransactionBuilder { - return getBuilder(this.getBaseChain()) as PolygonAccountLib.TransactionBuilder; + protected getTransactionBuilder(): TransactionBuilder { + return new TransactionBuilder(coins.get(this.getBaseChain())); } /** diff --git a/modules/bitgo/src/v2/coins/tpolygon.ts b/modules/sdk-coin-polygon/src/tpolygon.ts similarity index 100% rename from modules/bitgo/src/v2/coins/tpolygon.ts rename to modules/sdk-coin-polygon/src/tpolygon.ts diff --git a/modules/sdk-coin-polygon/test/getBuilder.ts b/modules/sdk-coin-polygon/test/getBuilder.ts new file mode 100644 index 0000000000..5077f98885 --- /dev/null +++ b/modules/sdk-coin-polygon/test/getBuilder.ts @@ -0,0 +1,7 @@ +import { BaseBuilder } from '@bitgo/sdk-core'; +import { coins } from '@bitgo/statics'; +import { TransactionBuilder } from '../src'; + +export function getBuilder(coinName: string): BaseBuilder { + return new TransactionBuilder(coins.get(coinName)); +} diff --git a/modules/account-lib/test/resources/polygon/polygon.ts b/modules/sdk-coin-polygon/test/resources.ts similarity index 99% rename from modules/account-lib/test/resources/polygon/polygon.ts rename to modules/sdk-coin-polygon/test/resources.ts index fbe673d8a7..2211b2e433 100644 --- a/modules/account-lib/test/resources/polygon/polygon.ts +++ b/modules/sdk-coin-polygon/test/resources.ts @@ -1,5 +1,4 @@ -import { KeyPair } from '../../../src/coin/polygon'; -import { ETHTransactionType, LegacyTxData } from '@bitgo/sdk-coin-eth'; +import { ETHTransactionType, KeyPair, LegacyTxData } from '@bitgo/sdk-coin-eth'; export const ENCODED_TRANSACTION = '0xf91661010a822ee09419645032c7f1533395d44a629462e751084d3e4c8204d2b915fb60606040526000600160006101000a81548160ff021916908315150217905550341561002a57600080fd5b60405161155b38038061155b833981016040528080518201919050506003815114151561005657600080fd5b806000908051906020019061006c929190610073565b5050610140565b8280548282559060005260206000209081019282156100ec579160200282015b828111156100eb5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610093565b5b5090506100f991906100fd565b5090565b61013d91905b8082111561013957600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101610103565b5090565b90565b61140c8061014f6000396000f300606060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630dcd7a6c146101335780632079fb9a146101e95780632da034091461024c57806339125215146102a45780637df73e271461037e578063a0b7967b146103cf578063a68a76cc146103f8578063abe3219c1461044d578063fc0f392d1461047a575b6000341115610131577f6e89d517057028190560dd200cf6bf792842861353d1173761dfa362e1c133f03334600036604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001828103825284848281815260200192508082843782019150509550505050505060405180910390a15b005b341561013e57600080fd5b6101e7600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061048f565b005b34156101f457600080fd5b61020a6004808035906020019091905050610668565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561025757600080fd5b6102a2600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506106a7565b005b34156102af57600080fd5b61037c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610773565b005b341561038957600080fd5b6103b5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a72565b604051808215151515815260200191505060405180910390f35b34156103da57600080fd5b6103e2610b16565b6040518082815260200191505060405180910390f35b341561040357600080fd5b61040b610b70565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561045857600080fd5b610460610b95565b604051808215151515815260200191505060405180910390f35b341561048557600080fd5b61048d610ba8565b005b60008061049b33610a72565b15156104a657600080fd5b878787878760405180807f45524332300000000000000000000000000000000000000000000000000000008152506005018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140183815260200182815260200195505050505050604051809103902091506105898883858888610c3b565b508590508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb89896000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561063857600080fd5b6102c65a03f1151561064957600080fd5b50505060405180519050151561065e57600080fd5b5050505050505050565b60008181548110151561067757fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006106b233610a72565b15156106bd57600080fd5b8290508073ffffffffffffffffffffffffffffffffffffffff16633ef13367836040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b151561075a57600080fd5b6102c65a03f1151561076b57600080fd5b505050505050565b60008061077f33610a72565b151561078a57600080fd5b878787878760405180807f45544845520000000000000000000000000000000000000000000000000000008152506005018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140185815260200184805190602001908083835b602083101515610833578051825260208201915060208101905060208303925061080e565b6001836020036101000a038019825116818451168082178552505050505050905001838152602001828152602001955050505050506040518091039020915061087f8883858888610c3b565b90508773ffffffffffffffffffffffffffffffffffffffff16878760405180828051906020019080838360005b838110156108c75780820151818401526020810190506108ac565b50505050905090810190601f1680156108f45780820380516001836020036101000a031916815260200191505b5091505060006040518083038185876187965a03f192505050151561091857600080fd5b7f59bed9ab5d78073465dd642a9e3e76dfdb7d53bcae9d09df7d0b8f5234d5a8063382848b8b8b604051808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185600019166000191681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610a29578082015181840152602081019050610a0e565b50505050905090810190601f168015610a565780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390a15050505050505050565b600080600090505b600080549050811015610b0b578273ffffffffffffffffffffffffffffffffffffffff16600082815481101515610aad57fe5b906000526020600020900160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610afe5760019150610b10565b8080600101915050610a7a565b600091505b50919050565b6000806000809150600090505b600a811015610b655781600282600a81101515610b3c57fe5b01541115610b5857600281600a81101515610b5357fe5b015491505b8080600101915050610b23565b600182019250505090565b6000610b7a610e90565b604051809103906000f0801515610b9057600080fd5b905090565b600160009054906101000a900460ff1681565b610bb133610a72565b1515610bbc57600080fd5b60018060006101000a81548160ff0219169083151502179055507f0909e8f76a4fd3e970f2eaef56c0ee6dfaf8b87c5b8d3f56ffce78e825a9115733604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b600080610c488686610ce6565b9050600160009054906101000a900460ff168015610c6c5750610c6a87610a72565b155b15610c7657600080fd5b42841015610c8357600080fd5b610c8c83610db9565b610c9581610a72565b1515610ca057600080fd5b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610cd957600080fd5b8091505095945050505050565b60008060008060418551141515610cfc57600080fd5b602085015192506040850151915060ff6041860151169050601b8160ff161015610d2757601b810190505b600186828585604051600081526020016040526000604051602001526040518085600019166000191681526020018460ff1660ff16815260200183600019166000191681526020018260001916600019168152602001945050505050602060405160208103908084039060008661646e5a03f11515610da557600080fd5b505060206040510351935050505092915050565b600080610dc533610a72565b1515610dd057600080fd5b60009150600090505b600a811015610e385782600282600a81101515610df257fe5b01541415610dff57600080fd5b600282600a81101515610e0e57fe5b0154600282600a81101515610e1f57fe5b01541015610e2b578091505b8080600101915050610dd9565b600282600a81101515610e4757fe5b0154831015610e5557600080fd5b612710600283600a81101515610e6757fe5b015401831115610e7657600080fd5b82600283600a81101515610e8657fe5b0181905550505050565b60405161054080610ea18339019056006060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506104e28061005e6000396000f300606060405260043610610056576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062821de3146101475780633ef133671461019c5780636b9f96ea146101d5575b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015156100b757600080fd5b7f69b31548dea9b3b707b4dff357d326e3e9348b24e7a6080a218a6edeeec48f9b3334600036604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001828103825284848281815260200192508082843782019150509550505050505060405180910390a1005b341561015257600080fd5b61015a6101ea565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101a757600080fd5b6101d3600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061020f565b005b34156101e057600080fd5b6101e861043c565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561026f57600080fd5b8392503091508273ffffffffffffffffffffffffffffffffffffffff166370a08231836000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561031857600080fd5b6102c65a03f1151561032957600080fd5b505050604051805190509050600081141561034357610436565b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561040f57600080fd5b6102c65a03f1151561042057600080fd5b50505060405180519050151561043557600080fd5b5b50505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f1935050505015156104b457600080fd5b5600a165627a7a72305820088cce905e424bfe474510efe41761893e9e34b54b885b8fee546d8be88aee3c0029a165627a7a72305820827adc3ef3a179757bc33003e41070fbbfcdfc5db31275af3cb0395155cd3bbb0029000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000008775ed5a9f67f90a017afb46980bfdae423dd41c00000000000000000000000042ff8ce0f79b69993893cef89412a4c48b7d29af0000000000000000000000007ae2ccba98e20daa6f6271cdf97a79c0274856f783027125a07c070f56759fb8f0f955768185c43d359bb7f954e6b4b74fc5913e4ca4a66163a06526510d623653d4e29e3a4d896ecf46d0fc67a52ab0e04f41ec9f7b6f0c4522'; diff --git a/modules/bitgo/test/v2/unit/coins/polygon.ts b/modules/sdk-coin-polygon/test/unit/polygon.ts similarity index 74% rename from modules/bitgo/test/v2/unit/coins/polygon.ts rename to modules/sdk-coin-polygon/test/unit/polygon.ts index f0ac55d3c2..17253c6f9b 100644 --- a/modules/bitgo/test/v2/unit/coins/polygon.ts +++ b/modules/sdk-coin-polygon/test/unit/polygon.ts @@ -1,53 +1,57 @@ -import { TestBitGo } from '@bitgo/sdk-test'; -import { BitGo } from '../../../../src/bitgo'; -import { Polygon } from '../../../../src/v2/coins/polygon'; -import { Tpolygon } from '../../../../src/v2/coins/tpolygon'; -import { getBuilder, Polygon as PolygonAccountLib } from '@bitgo/account-lib'; -import * as secp256k1 from 'secp256k1'; +import { BitGoAPI } from '@bitgo/sdk-api'; +import { common, TransactionType, Wallet } from '@bitgo/sdk-core'; +import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test'; import * as bip32 from 'bip32'; import * as nock from 'nock'; - +import * as secp256k1 from 'secp256k1'; import * as should from 'should'; -import { common, TransactionType, Wallet } from '@bitgo/sdk-core'; +import { Polygon, Tpolygon, TransactionBuilder, TransferBuilder } from '../../src'; +import { getBuilder } from '../getBuilder'; nock.enableNetConnect(); describe('Polygon', function () { - let bitgo; - let tpolygonCoin; + let bitgo: TestBitGoAPI; + let basecoin; let hopTxBitgoSignature; const address1 = '0x174cfd823af8ce27ed0afee3fcf3c3ba259116be'; const address2 = '0x7e85bdc27c050e3905ebf4b8e634d9ad6edd0de6'; const hopContractAddress = '0x47ce7cc86efefef19f8fb516b11735d183da8635'; const hopDestinationAddress = '0x9c7e8ce6825bD48278B3Ab59228EE26f8BE7925b'; - const hopTx = '0xf86b808504a817c8ff8252ff949c7e8ce6825bd48278b3ab59228ee26f8be7925b87038d7ea4c68000801ca011bc22c664570133dfca4f08a0b8d02339cf467046d6a4152f04f368d0eaf99ea01d6dc5cf0c897c8d4c3e1df53d0d042784c424536a4cc5b802552b7d64fee8b5'; + const hopTx = + '0xf86b808504a817c8ff8252ff949c7e8ce6825bd48278b3ab59228ee26f8be7925b87038d7ea4c68000801ca011bc22c664570133dfca4f08a0b8d02339cf467046d6a4152f04f368d0eaf99ea01d6dc5cf0c897c8d4c3e1df53d0d042784c424536a4cc5b802552b7d64fee8b5'; const hopTxid = '0x4af65143bc77da2b50f35b3d13cacb4db18f026bf84bc0743550bc57b9b53351'; - const userReqSig = '0x404db307f6147f0d8cd338c34c13906ef46a6faa7e0e119d5194ef05aec16e6f3d710f9b7901460f97e924066b62efd74443bd34402c6d40b49c203a559ff2c8'; + const userReqSig = + '0x404db307f6147f0d8cd338c34c13906ef46a6faa7e0e119d5194ef05aec16e6f3d710f9b7901460f97e924066b62efd74443bd34402c6d40b49c203a559ff2c8'; before(function () { - const bitgoKeyXprv = 'xprv9s21ZrQH143K3tpWBHWe31sLoXNRQ9AvRYJgitkKxQ4ATFQMwvr7hHNqYRUnS7PsjzB7aK1VxqHLuNQjj1sckJ2Jwo2qxmsvejwECSpFMfC'; + const bitgoKeyXprv = + 'xprv9s21ZrQH143K3tpWBHWe31sLoXNRQ9AvRYJgitkKxQ4ATFQMwvr7hHNqYRUnS7PsjzB7aK1VxqHLuNQjj1sckJ2Jwo2qxmsvejwECSpFMfC'; const bitgoKey = bip32.fromBase58(bitgoKeyXprv); if (!bitgoKey.privateKey) { throw new Error('no privateKey'); } const bitgoXpub = bitgoKey.neutered().toBase58(); - hopTxBitgoSignature = '0xaa' + Buffer.from(secp256k1.ecdsaSign(Buffer.from(hopTxid.slice(2), 'hex'), bitgoKey.privateKey).signature).toString('hex'); + hopTxBitgoSignature = + '0xaa' + + Buffer.from(secp256k1.ecdsaSign(Buffer.from(hopTxid.slice(2), 'hex'), bitgoKey.privateKey).signature).toString( + 'hex' + ); const env = 'test'; - bitgo = TestBitGo.decorate(BitGo, { env }); + bitgo = TestBitGo.decorate(BitGoAPI, { env }); common.Environments[env].hsmXpub = bitgoXpub; + bitgo.safeRegister('polygon', Polygon.createInstance); + bitgo.safeRegister('tpolygon', Tpolygon.createInstance); bitgo.initializeTestVars(); + basecoin = bitgo.coin('tpolygon'); }); after(function () { nock.cleanAll(); }); - beforeEach(() => { - tpolygonCoin = bitgo.coin('tpolygon') as Tpolygon; - }); - /** * Build an unsigned account-lib multi-signature send transactino * @param destination The destination address of the transaction @@ -69,7 +73,7 @@ describe('Polygon', function () { gasPrice = '10000', gasLimit = '20000', }) { - const txBuilder: PolygonAccountLib.TransactionBuilder = getBuilder('tpolygon') as PolygonAccountLib.TransactionBuilder; + const txBuilder: TransactionBuilder = getBuilder('tpolygon') as TransactionBuilder; txBuilder.type(TransactionType.Send); txBuilder.fee({ fee: gasPrice, @@ -77,7 +81,7 @@ describe('Polygon', function () { }); txBuilder.counter(nonce); txBuilder.contract(contractAddress); - const transferBuilder = txBuilder.transfer() as PolygonAccountLib.TransferBuilder; + const transferBuilder = txBuilder.transfer() as TransferBuilder; transferBuilder .coin('tpolygon') @@ -89,9 +93,7 @@ describe('Polygon', function () { return await txBuilder.build(); }; - describe('Instantiate', () => { - it('should instantiate the coin', function () { let localBasecoin = bitgo.coin('tpolygon'); localBasecoin.should.be.an.instanceof(Tpolygon); @@ -99,17 +101,15 @@ describe('Polygon', function () { localBasecoin = bitgo.coin('polygon'); localBasecoin.should.be.an.instanceof(Polygon); }); - }); describe('Explain transaction:', () => { - it('should fail if the options object is missing parameters', async function () { const explainParams = { feeInfo: { fee: 1 }, txHex: null, }; - await tpolygonCoin.explainTransaction(explainParams).should.be.rejectedWith('missing explain tx parameters'); + await basecoin.explainTransaction(explainParams).should.be.rejectedWith('missing explain tx parameters'); }); it('explain a transfer transaction', async function () { @@ -127,14 +127,12 @@ describe('Polygon', function () { }, feeInfo: { fee: 1 }, }; - const explanation = await tpolygonCoin.explainTransaction(explainParams); + const explanation = await basecoin.explainTransaction(explainParams); should.exist(explanation.id); }); - }); describe('Sign Transaction', () => { - const account_1 = { address: '0x8Ce59c2d1702844F8EdED451AA103961bC37B4e8', owner_1: '4ee089aceabf3ddbf748db79b1066c33b7d3ea1ab3eb7e325121bba2bff2f5ca', @@ -150,15 +148,15 @@ describe('Polygon', function () { }; it('should sign an unsigned test tx', async function () { - const coin = bitgo.coin('tpolygon'); - - const halfSignedTransaction = await coin.signTransaction({ + const halfSignedTransaction = await basecoin.signTransaction({ txPrebuild: { isBatch: false, - recipients: [{ - amount: '1', - address: account_1.address, - }], + recipients: [ + { + amount: '1', + address: account_1.address, + }, + ], expireTime: 1627949214, contractSequenceId: 1, gasLimit: 7000000, @@ -172,21 +170,23 @@ describe('Polygon', function () { }); halfSignedTransaction.halfSigned.recipients.length.should.equals(1); - halfSignedTransaction.halfSigned.recipients[0].address.toLowerCase().should.equals(account_1.address.toLowerCase()); + halfSignedTransaction.halfSigned.recipients[0].address + .toLowerCase() + .should.equals(account_1.address.toLowerCase()); halfSignedTransaction.halfSigned.recipients[0].amount.toLowerCase().should.equals('1'); }); it('should sign a transaction with EIP1559 fee params', async function () { - const coin = bitgo.coin('tpolygon'); - - const halfSignedTransaction = await coin.signTransaction({ + const halfSignedTransaction = await basecoin.signTransaction({ txPrebuild: { eip1559: { maxPriorityFeePerGas: 10, maxFeePerGas: 10 }, isBatch: false, - recipients: [{ - amount: '1', - address: account_1.address, - }], + recipients: [ + { + amount: '1', + address: account_1.address, + }, + ], expireTime: 1627949214, contractSequenceId: 12, gasLimit: undefined, @@ -200,20 +200,19 @@ describe('Polygon', function () { }); halfSignedTransaction.halfSigned.recipients.length.should.equals(1); - halfSignedTransaction.halfSigned.recipients[0].address.toLowerCase().should.equals(account_1.address.toLowerCase()); + halfSignedTransaction.halfSigned.recipients[0].address + .toLowerCase() + .should.equals(account_1.address.toLowerCase()); halfSignedTransaction.halfSigned.recipients[0].amount.toLowerCase().should.equals('1'); halfSignedTransaction.halfSigned.eip1559.maxPriorityFeePerGas.should.equal(10); halfSignedTransaction.halfSigned.eip1559.maxFeePerGas.should.equal(10); }); - }); describe('Transaction Verification', function () { - it('should verify a normal txPrebuild from the bitgo server that matches the client txParams', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = { recipients: [{ amount: '1000000000000', address: address1 }], @@ -234,13 +233,12 @@ describe('Polygon', function () { const verification = {}; - const isTransactionVerified = await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }); + const isTransactionVerified = await basecoin.verifyTransaction({ txParams, txPrebuild, wallet, verification }); isTransactionVerified.should.equal(true); }); it('should verify a hop txPrebuild from the bitgo server that matches the client txParams', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = { recipients: [{ amount: 1000000000000000, address: hopDestinationAddress }], @@ -275,13 +273,12 @@ describe('Polygon', function () { const verification = {}; - const isTransactionVerified = await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }); + const isTransactionVerified = await basecoin.verifyTransaction({ txParams, txPrebuild, wallet, verification }); isTransactionVerified.should.equal(true); }); it('should reject when client txParams are missing', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = null; @@ -298,16 +295,19 @@ describe('Polygon', function () { const verification = {}; - await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }) + await basecoin + .verifyTransaction({ txParams, txPrebuild, wallet, verification }) .should.be.rejectedWith('missing params'); }); it('should reject txPrebuild that is both batch and hop', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = { - recipients: [{ amount: '1000000000000', address: address1 }, { amount: '2500000000000', address: address2 }], + recipients: [ + { amount: '1000000000000', address: address1 }, + { amount: '2500000000000', address: address2 }, + ], wallet: wallet, walletPassphrase: 'fakeWalletPassphrase', hop: true, @@ -339,22 +339,28 @@ describe('Polygon', function () { const verification = {}; - await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }) + await basecoin + .verifyTransaction({ txParams, txPrebuild, wallet, verification }) .should.be.rejectedWith('tx cannot be both a batch and hop transaction'); }); it('should reject a txPrebuild with more than one recipient', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = { - recipients: [{ amount: '1000000000000', address: address1 }, { amount: '2500000000000', address: address2 }], + recipients: [ + { amount: '1000000000000', address: address1 }, + { amount: '2500000000000', address: address2 }, + ], wallet: wallet, walletPassphrase: 'fakeWalletPassphrase', }; const txPrebuild = { - recipients: [{ amount: '1000000000000', address: address1 }, { amount: '2500000000000', address: address2 }], + recipients: [ + { amount: '1000000000000', address: address1 }, + { amount: '2500000000000', address: address2 }, + ], nextContractSequenceId: 0, gasPrice: 20000000000, gasLimit: 500000, @@ -366,13 +372,13 @@ describe('Polygon', function () { const verification = {}; - await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }) + await basecoin + .verifyTransaction({ txParams, txPrebuild, wallet, verification }) .should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found'); }); it('should reject a hop txPrebuild that does not send to its hop address', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = { recipients: [{ amount: '1000000000000000', address: hopDestinationAddress }], @@ -407,13 +413,13 @@ describe('Polygon', function () { const verification = {}; - await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }) + await basecoin + .verifyTransaction({ txParams, txPrebuild, wallet, verification }) .should.be.rejectedWith('recipient address of txPrebuild does not match hop address'); }); it('should reject a normal txPrebuild from the bitgo server with the wrong amount', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = { recipients: [{ amount: '1000000000000', address: address1 }], @@ -434,13 +440,15 @@ describe('Polygon', function () { const verification = {}; - await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }) - .should.be.rejectedWith('normal transaction amount in txPrebuild received from BitGo servers does not match txParams supplied by client'); + await basecoin + .verifyTransaction({ txParams, txPrebuild, wallet, verification }) + .should.be.rejectedWith( + 'normal transaction amount in txPrebuild received from BitGo servers does not match txParams supplied by client' + ); }); it('should reject a normal txPrebuild from the bitgo server with the wrong recipient', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = { recipients: [{ amount: '1000000000000', address: address1 }], @@ -461,13 +469,15 @@ describe('Polygon', function () { const verification = {}; - await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }) - .should.be.rejectedWith('destination address in normal txPrebuild does not match that in txParams supplied by client'); + await basecoin + .verifyTransaction({ txParams, txPrebuild, wallet, verification }) + .should.be.rejectedWith( + 'destination address in normal txPrebuild does not match that in txParams supplied by client' + ); }); it('should reject a txPrebuild from the bitgo server with the wrong coin', async function () { - const coin = bitgo.coin('tpolygon'); - const wallet = new Wallet(bitgo, coin, {}); + const wallet = new Wallet(bitgo, basecoin, {}); const txParams = { recipients: [{ amount: '1000000000000', address: address1 }], @@ -488,10 +498,9 @@ describe('Polygon', function () { const verification = {}; - await coin.verifyTransaction({ txParams, txPrebuild, wallet, verification }) + await basecoin + .verifyTransaction({ txParams, txPrebuild, wallet, verification }) .should.be.rejectedWith('coin in txPrebuild did not match that in txParams supplied by client'); }); - }); - }); diff --git a/modules/account-lib/test/unit/coin/polygon/transaction.ts b/modules/sdk-coin-polygon/test/unit/transaction.ts similarity index 89% rename from modules/account-lib/test/unit/coin/polygon/transaction.ts rename to modules/sdk-coin-polygon/test/unit/transaction.ts index 6e0f7af286..667d5c3ac2 100644 --- a/modules/account-lib/test/unit/coin/polygon/transaction.ts +++ b/modules/sdk-coin-polygon/test/unit/transaction.ts @@ -1,8 +1,8 @@ import should from 'should'; import { coins } from '@bitgo/statics'; -import { Transaction } from '../../../../src/coin/polygon'; -import * as testData from '../../../resources/polygon/polygon'; -import { getCommon } from '../../../../src/coin/polygon/utils'; +import { Transaction } from '../../src'; +import { getCommon } from '../../src/lib/utils'; +import * as testData from '../resources'; describe('Polygon Transaction', () => { const coinConfig = coins.get('tpolygon'); diff --git a/modules/account-lib/test/unit/coin/polygon/transactionBuilder/walletInitialization.ts b/modules/sdk-coin-polygon/test/unit/transactionBuilder/walletInitialization.ts similarity index 88% rename from modules/account-lib/test/unit/coin/polygon/transactionBuilder/walletInitialization.ts rename to modules/sdk-coin-polygon/test/unit/transactionBuilder/walletInitialization.ts index 4bbc49ee85..c50e5f0ae3 100644 --- a/modules/account-lib/test/unit/coin/polygon/transactionBuilder/walletInitialization.ts +++ b/modules/sdk-coin-polygon/test/unit/transactionBuilder/walletInitialization.ts @@ -1,12 +1,13 @@ import should from 'should'; import { TransactionType } from '@bitgo/sdk-core'; -import { getBuilder, Polygon } from '../../../../../src'; -import * as testData from '../../../../resources/polygon/polygon'; +import { TransactionBuilder } from '../../../src'; +import * as testData from '../../resources'; +import { coins } from '@bitgo/statics'; describe('Polygon wallet initialization', function () { - let txBuilder: Polygon.TransactionBuilder; + let txBuilder: TransactionBuilder; const initTxBuilder = (): void => { - txBuilder = getBuilder('tpolygon') as Polygon.TransactionBuilder; + txBuilder = new TransactionBuilder(coins.get('tpolygon')); txBuilder.fee({ fee: '10000000000', gasLimit: '6800000', @@ -35,7 +36,7 @@ describe('Polygon wallet initialization', function () { }); it('a signed init transaction from serialized', async () => { - const newTxBuilder = getBuilder('tpolygon') as Polygon.TransactionBuilder; + const newTxBuilder = new TransactionBuilder(coins.get('tpolygon')); newTxBuilder.from(testData.TX_BROADCAST); const newTx = await newTxBuilder.build(); should.equal(newTx.toBroadcastFormat(), testData.TX_BROADCAST); @@ -72,7 +73,7 @@ describe('Polygon wallet initialization', function () { const tx = await txBuilder.build(); const serialized = tx.toBroadcastFormat(); - const newTxBuilder = getBuilder('tpolygon') as Polygon.TransactionBuilder; + const newTxBuilder = new TransactionBuilder(coins.get('tpolygon')); newTxBuilder.from(serialized); const newTx = await newTxBuilder.build(); should.equal(newTx.toBroadcastFormat(), serialized); @@ -86,7 +87,7 @@ describe('Polygon wallet initialization', function () { const tx = await txBuilder.build(); const serialized = tx.toBroadcastFormat(); - const newTxBuilder = getBuilder('tpolygon') as Polygon.TransactionBuilder; + const newTxBuilder = new TransactionBuilder(coins.get('tpolygon')); newTxBuilder.from(serialized); const newTx = await newTxBuilder.build(); should.equal(newTx.toBroadcastFormat(), serialized); diff --git a/modules/sdk-coin-polygon/tsconfig.json b/modules/sdk-coin-polygon/tsconfig.json new file mode 100644 index 0000000000..2862c10c0e --- /dev/null +++ b/modules/sdk-coin-polygon/tsconfig.json @@ -0,0 +1,32 @@ +{ + "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": "../abstract-eth" + }, + { + "path": "../sdk-api" + }, + { + "path": "../sdk-coin-eth" + }, + { + "path": "../sdk-core" + }, + { + "path": "../statics" + }, + { + "path": "../sdk-test" + } + ] +} diff --git a/modules/sdk-coin-rbtc/CHANGELOG.md b/modules/sdk-coin-rbtc/CHANGELOG.md index 48bd0365b6..9d6181c750 100644 --- a/modules/sdk-coin-rbtc/CHANGELOG.md +++ b/modules/sdk-coin-rbtc/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-rbtc@1.1.0-rc.1...@bitgo/sdk-coin-rbtc@1.1.0-rc.3) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-rbtc + + + + + +# [1.1.0-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-rbtc@1.1.0-rc.1...@bitgo/sdk-coin-rbtc@1.1.0-rc.2) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-rbtc + + + + + # [1.1.0-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-rbtc@1.1.0-rc.0...@bitgo/sdk-coin-rbtc@1.1.0-rc.1) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-rbtc diff --git a/modules/sdk-coin-rbtc/package.json b/modules/sdk-coin-rbtc/package.json index da04b8d99c..5df69f0361 100644 --- a/modules/sdk-coin-rbtc/package.json +++ b/modules/sdk-coin-rbtc/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-rbtc", - "version": "1.1.0-rc.1", + "version": "1.1.0-rc.3", "description": "BitGo SDK coin library for Rootstock rsk", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,15 +41,15 @@ ] }, "dependencies": { - "@bitgo/abstract-eth": "^1.0.1-rc.21", - "@bitgo/sdk-coin-eth": "^1.1.0-rc.1", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/abstract-eth": "^1.0.1-rc.23", + "@bitgo/sdk-coin-eth": "^1.1.0-rc.3", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@ethereumjs/common": "^2.4.0", "ethereumjs-abi": "^0.6.5" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-sol/CHANGELOG.md b/modules/sdk-coin-sol/CHANGELOG.md index 0b1d116c66..915bf88475 100644 --- a/modules/sdk-coin-sol/CHANGELOG.md +++ b/modules/sdk-coin-sol/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-sol@1.0.1-rc.3...@bitgo/sdk-coin-sol@1.0.1-rc.5) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-sol + + + + + +## [1.0.1-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-sol@1.0.1-rc.3...@bitgo/sdk-coin-sol@1.0.1-rc.4) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-sol + + + + + ## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-sol@1.0.1-rc.2...@bitgo/sdk-coin-sol@1.0.1-rc.3) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-sol diff --git a/modules/sdk-coin-sol/package.json b/modules/sdk-coin-sol/package.json index 9860a4a4ec..6bca95f3b1 100644 --- a/modules/sdk-coin-sol/package.json +++ b/modules/sdk-coin-sol/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-sol", - "version": "1.0.1-rc.3", + "version": "1.0.1-rc.5", "description": "BitGo SDK coin library for Sol", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,8 +41,8 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@solana/spl-token": "0.1.8", "@solana/web3.js": "1.31.0", "bignumber.js": "^9.0.0", @@ -51,8 +51,8 @@ "tweetnacl": "^1.0.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "@types/lodash": "^4.14.121" } } diff --git a/modules/sdk-coin-stx/CHANGELOG.md b/modules/sdk-coin-stx/CHANGELOG.md index fc5af8bd19..79979f127f 100644 --- a/modules/sdk-coin-stx/CHANGELOG.md +++ b/modules/sdk-coin-stx/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-stx@1.1.0-rc.4...@bitgo/sdk-coin-stx@1.1.0-rc.6) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-stx + + + + + +# [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-stx@1.1.0-rc.4...@bitgo/sdk-coin-stx@1.1.0-rc.5) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-stx + + + + + # [1.1.0-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-stx@1.1.0-rc.3...@bitgo/sdk-coin-stx@1.1.0-rc.4) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-stx diff --git a/modules/sdk-coin-stx/package.json b/modules/sdk-coin-stx/package.json index e83d5add4c..487dce528f 100644 --- a/modules/sdk-coin-stx/package.json +++ b/modules/sdk-coin-stx/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-stx", - "version": "1.1.0-rc.4", + "version": "1.1.0-rc.6", "description": "BitGo SDK coin library for Stacks", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -42,8 +42,8 @@ }, "dependencies": { "@bitgo/ethereumjs-utils-old": "npm:ethereumjs-util@5.2.0", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@stacks/network": "^4.3.0", "@stacks/transactions": "2.0.1", "bignumber.js": "^9.0.0", @@ -55,8 +55,8 @@ "lodash": "^4.17.15" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19", "@types/elliptic": "^6.4.12" } } diff --git a/modules/sdk-coin-trx/CHANGELOG.md b/modules/sdk-coin-trx/CHANGELOG.md index 98e9252355..9e1c0d63e2 100644 --- a/modules/sdk-coin-trx/CHANGELOG.md +++ b/modules/sdk-coin-trx/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-trx@1.0.1-rc.3...@bitgo/sdk-coin-trx@1.0.1-rc.5) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-trx + + + + + +## [1.0.1-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-trx@1.0.1-rc.3...@bitgo/sdk-coin-trx@1.0.1-rc.4) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-trx + + + + + ## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-trx@1.0.1-rc.2...@bitgo/sdk-coin-trx@1.0.1-rc.3) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-trx diff --git a/modules/sdk-coin-trx/package.json b/modules/sdk-coin-trx/package.json index 533343097b..8f04f9512c 100644 --- a/modules/sdk-coin-trx/package.json +++ b/modules/sdk-coin-trx/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-trx", - "version": "1.0.1-rc.3", + "version": "1.0.1-rc.5", "description": "BitGo SDK coin library for Tron", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -47,8 +47,8 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@bitgo/utxo-lib": "^2.3.0-rc.11", "@stablelib/hex": "^1.0.0", "bignumber.js": "^9.0.0", @@ -60,7 +60,7 @@ "tronweb": "^3.2.6" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-xlm/CHANGELOG.md b/modules/sdk-coin-xlm/CHANGELOG.md index d21af820e2..fd0e475f72 100644 --- a/modules/sdk-coin-xlm/CHANGELOG.md +++ b/modules/sdk-coin-xlm/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xlm@1.0.1-rc.1...@bitgo/sdk-coin-xlm@1.0.1-rc.3) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-xlm + + + + + +## [1.0.1-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xlm@1.0.1-rc.1...@bitgo/sdk-coin-xlm@1.0.1-rc.2) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-xlm + + + + + ## [1.0.1-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xlm@1.0.1-rc.0...@bitgo/sdk-coin-xlm@1.0.1-rc.1) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-xlm diff --git a/modules/sdk-coin-xlm/package.json b/modules/sdk-coin-xlm/package.json index fecb13ca0d..ffe4c5a14b 100644 --- a/modules/sdk-coin-xlm/package.json +++ b/modules/sdk-coin-xlm/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-xlm", - "version": "1.0.1-rc.1", + "version": "1.0.1-rc.3", "description": "BitGo SDK coin library for Xlm", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,8 +41,8 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@bitgo/utxo-lib": "^2.3.0-rc.11", "bignumber.js": "^8.0.1", "lodash": "^4.17.14", @@ -50,7 +50,7 @@ "superagent": "^3.8.3" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-xrp/CHANGELOG.md b/modules/sdk-coin-xrp/CHANGELOG.md index 25505458d6..ae35da3f0f 100644 --- a/modules/sdk-coin-xrp/CHANGELOG.md +++ b/modules/sdk-coin-xrp/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.23](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xrp@1.1.0-rc.21...@bitgo/sdk-coin-xrp@1.1.0-rc.23) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-xrp + + + + + +# [1.1.0-rc.22](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xrp@1.1.0-rc.21...@bitgo/sdk-coin-xrp@1.1.0-rc.22) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-xrp + + + + + # [1.1.0-rc.21](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xrp@1.1.0-rc.20...@bitgo/sdk-coin-xrp@1.1.0-rc.21) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-xrp diff --git a/modules/sdk-coin-xrp/package.json b/modules/sdk-coin-xrp/package.json index 3858eef1e0..2140703b39 100644 --- a/modules/sdk-coin-xrp/package.json +++ b/modules/sdk-coin-xrp/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-xrp", - "version": "1.1.0-rc.21", + "version": "1.1.0-rc.23", "description": "BitGo SDK coin library for Ripple", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,9 +41,11 @@ ] }, "dependencies": { - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-eth": "^1.0.1-rc.23", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@bitgo/utxo-lib": "^2.3.0-rc.11", - "bignumber.js": "^8.0.1", + "bignumber.js": "^9.0.0", "bip32": "^2.0.6", "lodash": "^4.17.14", "ripple-address-codec": "~4.1.3", @@ -52,6 +54,6 @@ "ripple-lib": "~1.4.1" }, "devDependencies": { - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-xtz/CHANGELOG.md b/modules/sdk-coin-xtz/CHANGELOG.md index f58abd6f0b..5fc9a6be4c 100644 --- a/modules/sdk-coin-xtz/CHANGELOG.md +++ b/modules/sdk-coin-xtz/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xtz@1.1.0-rc.4...@bitgo/sdk-coin-xtz@1.1.0-rc.6) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-xtz + + + + + +# [1.1.0-rc.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xtz@1.1.0-rc.4...@bitgo/sdk-coin-xtz@1.1.0-rc.5) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-xtz + + + + + # [1.1.0-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-xtz@1.1.0-rc.3...@bitgo/sdk-coin-xtz@1.1.0-rc.4) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-xtz diff --git a/modules/sdk-coin-xtz/package.json b/modules/sdk-coin-xtz/package.json index 69150e5990..10e26ce202 100644 --- a/modules/sdk-coin-xtz/package.json +++ b/modules/sdk-coin-xtz/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-xtz", - "version": "1.1.0-rc.4", + "version": "1.1.0-rc.6", "description": "BitGo SDK coin library for Tezos", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -42,8 +42,8 @@ }, "dependencies": { "@bitgo/blake2b": "^3.0.3-rc.0", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "@taquito/local-forging": "6.3.5-beta.0", "@taquito/signer": "6.3.5-beta.0", "bignumber.js": "^9.0.0", @@ -55,7 +55,7 @@ "lodash": "^4.17.15" }, "devDependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-coin-zec/CHANGELOG.md b/modules/sdk-coin-zec/CHANGELOG.md index 756242a645..589ec06c65 100644 --- a/modules/sdk-coin-zec/CHANGELOG.md +++ b/modules/sdk-coin-zec/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.9](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-zec@1.1.0-rc.7...@bitgo/sdk-coin-zec@1.1.0-rc.9) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-coin-zec + + + + + +# [1.1.0-rc.8](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-zec@1.1.0-rc.7...@bitgo/sdk-coin-zec@1.1.0-rc.8) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-coin-zec + + + + + # [1.1.0-rc.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-zec@1.1.0-rc.6...@bitgo/sdk-coin-zec@1.1.0-rc.7) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-coin-zec diff --git a/modules/sdk-coin-zec/package.json b/modules/sdk-coin-zec/package.json index 5d0420408e..16a6e520fa 100644 --- a/modules/sdk-coin-zec/package.json +++ b/modules/sdk-coin-zec/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-coin-zec", - "version": "1.1.0-rc.7", + "version": "1.1.0-rc.9", "description": "BitGo SDK coin library for Zcash", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -41,11 +41,11 @@ ] }, "dependencies": { - "@bitgo/abstract-utxo": "^1.1.0-rc.4", - "@bitgo/sdk-core": "^1.1.0-rc.27", + "@bitgo/abstract-utxo": "^1.1.0-rc.6", + "@bitgo/sdk-core": "^1.1.0-rc.29", "@bitgo/utxo-lib": "^2.3.0-rc.11" }, "devDependencies": { - "@bitgo/sdk-test": "^1.0.1-rc.17" + "@bitgo/sdk-test": "^1.0.1-rc.19" } } diff --git a/modules/sdk-core/CHANGELOG.md b/modules/sdk-core/CHANGELOG.md index ebed511fa3..30d5eeca91 100644 --- a/modules/sdk-core/CHANGELOG.md +++ b/modules/sdk-core/CHANGELOG.md @@ -3,6 +3,30 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.29](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-core@1.1.0-rc.27...@bitgo/sdk-core@1.1.0-rc.29) (2022-07-19) + + +### Bug Fixes + +* **bitgo:** add token to whitelistedParams in eddsa prebuildTxWithIntent BG-52482 ([09c19e9](https://github.com/BitGo/BitGoJS/commit/09c19e950549f6777ee17919514cfb9a1039e73c)) + + +### Features + +* **sdk-coin-ada:** implement key pair and utils for ada sdk ([9a1aabb](https://github.com/BitGo/BitGoJS/commit/9a1aabb8a07b5787ab3fa645c29be1b940694892)) + + + + + +# [1.1.0-rc.28](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-core@1.1.0-rc.27...@bitgo/sdk-core@1.1.0-rc.28) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-core + + + + + # [1.1.0-rc.27](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-core@1.1.0-rc.26...@bitgo/sdk-core@1.1.0-rc.27) (2022-07-15) diff --git a/modules/sdk-core/package.json b/modules/sdk-core/package.json index e3346c4103..772b97146f 100644 --- a/modules/sdk-core/package.json +++ b/modules/sdk-core/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-core", - "version": "1.1.0-rc.27", + "version": "1.1.0-rc.29", "description": "core library functions for BitGoJS", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -36,7 +36,7 @@ }, "dependencies": { "@bitgo/bls-dkg": "^1.1.0-rc.1", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/statics": "^7.0.0-rc.4", "@bitgo/utxo-lib": "^2.3.0-rc.11", "@noble/secp256k1": "1.6.0", "@stablelib/hex": "^1.0.0", diff --git a/modules/sdk-core/src/account-lib/baseCoin/enum.ts b/modules/sdk-core/src/account-lib/baseCoin/enum.ts index e13c218533..ef1364b189 100644 --- a/modules/sdk-core/src/account-lib/baseCoin/enum.ts +++ b/modules/sdk-core/src/account-lib/baseCoin/enum.ts @@ -53,6 +53,8 @@ export enum TransactionType { export enum AddressFormat { hex = 'hex', base58 = 'base58', + mainnet = 'mainnet', + testnet = 'testnet', } // TODO(): create union type of all address formats enums diff --git a/modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts b/modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts index 3cba3dd40b..a7382fda27 100644 --- a/modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts +++ b/modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts @@ -262,6 +262,16 @@ export interface HalfSignedAccountTransaction { }; } +export interface HalfSignedTransaction extends HalfSignedAccountTransaction { + halfSigned: { + recipients: Recipient[]; + expireTime: number; + contractSequenceId: number; + sequenceId: number; + txHex?: never; + }; +} + export interface SignedTransactionRequest { txRequestId: string; } diff --git a/modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsa.ts b/modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsa.ts index 9beeaefa01..c3478e84c5 100644 --- a/modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsa.ts +++ b/modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsa.ts @@ -355,6 +355,7 @@ export class EddsaUtils extends baseTSSUtils { recipients: intentRecipients, memo: params.memo?.value, nonce: params.nonce, + token: params.tokenName, }, apiVersion: apiVersion, preview, diff --git a/modules/bitgo/src/v2/coins/fiateur.ts b/modules/sdk-core/src/coins/fiateur.ts similarity index 98% rename from modules/bitgo/src/v2/coins/fiateur.ts rename to modules/sdk-core/src/coins/fiateur.ts index dca9d09413..ebb6aa7f09 100644 --- a/modules/bitgo/src/v2/coins/fiateur.ts +++ b/modules/sdk-core/src/coins/fiateur.ts @@ -12,7 +12,7 @@ import { SignTransactionOptions, VerifyAddressOptions, VerifyTransactionOptions, -} from '@bitgo/sdk-core'; +} from '../'; export class FiatEur extends BaseCoin { static createInstance(bitgo: BitGoBase): BaseCoin { diff --git a/modules/bitgo/src/v2/coins/fiatgbp.ts b/modules/sdk-core/src/coins/fiatgbp.ts similarity index 98% rename from modules/bitgo/src/v2/coins/fiatgbp.ts rename to modules/sdk-core/src/coins/fiatgbp.ts index 16a218edfb..9e304163cd 100644 --- a/modules/bitgo/src/v2/coins/fiatgbp.ts +++ b/modules/sdk-core/src/coins/fiatgbp.ts @@ -12,7 +12,7 @@ import { SignTransactionOptions, VerifyAddressOptions, VerifyTransactionOptions, -} from '@bitgo/sdk-core'; +} from '../'; export class FiatGBP extends BaseCoin { static createInstance(bitgo: BitGoBase): BaseCoin { diff --git a/modules/bitgo/src/v2/coins/fiatusd.ts b/modules/sdk-core/src/coins/fiatusd.ts similarity index 98% rename from modules/bitgo/src/v2/coins/fiatusd.ts rename to modules/sdk-core/src/coins/fiatusd.ts index 32dbe61bf5..655dccf108 100644 --- a/modules/bitgo/src/v2/coins/fiatusd.ts +++ b/modules/sdk-core/src/coins/fiatusd.ts @@ -12,7 +12,7 @@ import { SignTransactionOptions, VerifyAddressOptions, VerifyTransactionOptions, -} from '@bitgo/sdk-core'; +} from '../'; export class FiatUsd extends BaseCoin { static createInstance(bitgo: BitGoBase): BaseCoin { diff --git a/modules/sdk-core/src/coins/index.ts b/modules/sdk-core/src/coins/index.ts new file mode 100644 index 0000000000..3a80bb6f05 --- /dev/null +++ b/modules/sdk-core/src/coins/index.ts @@ -0,0 +1,10 @@ +export * from './fiateur'; +export * from './tfiateur'; +export * from './fiatgbp'; +export * from './tfiatgbp'; +export * from './fiatusd'; +export * from './tfiatusd'; +export * from './ofc'; +export * from './ofcToken'; +export * from './susd'; +export * from './tsusd'; diff --git a/modules/bitgo/src/v2/coins/ofc.ts b/modules/sdk-core/src/coins/ofc.ts similarity index 98% rename from modules/bitgo/src/v2/coins/ofc.ts rename to modules/sdk-core/src/coins/ofc.ts index eaa8d848e7..857bde563c 100644 --- a/modules/bitgo/src/v2/coins/ofc.ts +++ b/modules/sdk-core/src/coins/ofc.ts @@ -14,7 +14,7 @@ import { SignTransactionOptions, VerifyAddressOptions, VerifyTransactionOptions, -} from '@bitgo/sdk-core'; +} from '../'; export class Ofc extends BaseCoin { static createInstance(bitgo: BitGoBase): BaseCoin { diff --git a/modules/bitgo/src/v2/coins/ofcToken.ts b/modules/sdk-core/src/coins/ofcToken.ts similarity index 93% rename from modules/bitgo/src/v2/coins/ofcToken.ts rename to modules/sdk-core/src/coins/ofcToken.ts index 6dd8d90dc2..84ffbb4406 100644 --- a/modules/bitgo/src/v2/coins/ofcToken.ts +++ b/modules/sdk-core/src/coins/ofcToken.ts @@ -1,11 +1,15 @@ /** * @prettier */ +import { OfcTokenConfig } from '@bitgo/statics'; import { isString } from 'lodash'; +import { + BitGoBase, + CoinConstructor, + SignTransactionOptions as BaseSignTransactionOptions, + SignedTransaction, +} from '../'; import { Ofc } from './ofc'; -import { BitGoBase, CoinConstructor, SignTransactionOptions as BaseSignTransactionOptions } from '@bitgo/sdk-core'; -import { SignedTransaction } from '@bitgo/sdk-coin-eth'; -import { OfcTokenConfig } from '@bitgo/statics'; export interface SignTransactionOptions extends BaseSignTransactionOptions { txPrebuild: { diff --git a/modules/bitgo/src/v2/coins/susd.ts b/modules/sdk-core/src/coins/susd.ts similarity index 98% rename from modules/bitgo/src/v2/coins/susd.ts rename to modules/sdk-core/src/coins/susd.ts index 3f073967a0..80ea10d177 100644 --- a/modules/bitgo/src/v2/coins/susd.ts +++ b/modules/sdk-core/src/coins/susd.ts @@ -12,7 +12,7 @@ import { SignTransactionOptions, VerifyAddressOptions, VerifyTransactionOptions, -} from '@bitgo/sdk-core'; +} from '../'; export class Susd extends BaseCoin { static createInstance(bitgo: BitGoBase): BaseCoin { diff --git a/modules/bitgo/src/v2/coins/tfiateur.ts b/modules/sdk-core/src/coins/tfiateur.ts similarity index 84% rename from modules/bitgo/src/v2/coins/tfiateur.ts rename to modules/sdk-core/src/coins/tfiateur.ts index 668430c29b..5d4533a1a5 100644 --- a/modules/bitgo/src/v2/coins/tfiateur.ts +++ b/modules/sdk-core/src/coins/tfiateur.ts @@ -1,7 +1,7 @@ /** * @prettier */ -import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; +import { BaseCoin, BitGoBase } from '../'; import { FiatEur } from './fiateur'; export class TfiatEur extends FiatEur { diff --git a/modules/bitgo/src/v2/coins/tfiatgbp.ts b/modules/sdk-core/src/coins/tfiatgbp.ts similarity index 84% rename from modules/bitgo/src/v2/coins/tfiatgbp.ts rename to modules/sdk-core/src/coins/tfiatgbp.ts index 3172098959..b38a131b3e 100644 --- a/modules/bitgo/src/v2/coins/tfiatgbp.ts +++ b/modules/sdk-core/src/coins/tfiatgbp.ts @@ -1,7 +1,7 @@ /** * @prettier */ -import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; +import { BaseCoin, BitGoBase } from '../'; import { FiatGBP } from './fiatgbp'; export class TfiatGBP extends FiatGBP { diff --git a/modules/bitgo/src/v2/coins/tfiatusd.ts b/modules/sdk-core/src/coins/tfiatusd.ts similarity index 84% rename from modules/bitgo/src/v2/coins/tfiatusd.ts rename to modules/sdk-core/src/coins/tfiatusd.ts index 2755d33b5e..3ce1bd1088 100644 --- a/modules/bitgo/src/v2/coins/tfiatusd.ts +++ b/modules/sdk-core/src/coins/tfiatusd.ts @@ -1,7 +1,7 @@ /** * @prettier */ -import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; +import { BaseCoin, BitGoBase } from '../'; import { FiatUsd } from './fiatusd'; export class TfiatUsd extends FiatUsd { diff --git a/modules/bitgo/src/v2/coins/tsusd.ts b/modules/sdk-core/src/coins/tsusd.ts similarity index 83% rename from modules/bitgo/src/v2/coins/tsusd.ts rename to modules/sdk-core/src/coins/tsusd.ts index 4f94926656..a2331e5c92 100644 --- a/modules/bitgo/src/v2/coins/tsusd.ts +++ b/modules/sdk-core/src/coins/tsusd.ts @@ -1,7 +1,7 @@ /** * @prettier */ -import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; +import { BaseCoin, BitGoBase } from '../'; import { Susd } from './susd'; export class Tsusd extends Susd { diff --git a/modules/sdk-core/src/index.ts b/modules/sdk-core/src/index.ts index b1c2b48e5b..3012e5fd63 100644 --- a/modules/sdk-core/src/index.ts +++ b/modules/sdk-core/src/index.ts @@ -3,5 +3,6 @@ export * as accountLib from './account-lib'; export * from './api'; export * from './bitgo'; export * from './bitgojsError'; +export * as coins from './coins'; import * as common from './common'; export { common }; diff --git a/modules/sdk-test/CHANGELOG.md b/modules/sdk-test/CHANGELOG.md index a8ba805c0a..e61bf2e26d 100644 --- a/modules/sdk-test/CHANGELOG.md +++ b/modules/sdk-test/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1-rc.19](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-test@1.0.1-rc.17...@bitgo/sdk-test@1.0.1-rc.19) (2022-07-19) + +**Note:** Version bump only for package @bitgo/sdk-test + + + + + +## [1.0.1-rc.18](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-test@1.0.1-rc.17...@bitgo/sdk-test@1.0.1-rc.18) (2022-07-18) + +**Note:** Version bump only for package @bitgo/sdk-test + + + + + ## [1.0.1-rc.17](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-test@1.0.1-rc.16...@bitgo/sdk-test@1.0.1-rc.17) (2022-07-15) **Note:** Version bump only for package @bitgo/sdk-test diff --git a/modules/sdk-test/package.json b/modules/sdk-test/package.json index 52fc8bba47..0f8e102a98 100644 --- a/modules/sdk-test/package.json +++ b/modules/sdk-test/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/sdk-test", - "version": "1.0.1-rc.17", + "version": "1.0.1-rc.19", "private": "true", "description": "coin test libary for BitGoJS", "main": "./dist/src/index.js", @@ -28,9 +28,9 @@ ] }, "dependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-core": "^1.1.0-rc.27", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-core": "^1.1.0-rc.29", + "@bitgo/statics": "^7.0.0-rc.4", "bignumber.js": "^8.0.1", "lodash": "^4.17.14", "should-http": "^0.1.1" diff --git a/modules/statics/CHANGELOG.md b/modules/statics/CHANGELOG.md index 912f562b42..18c9a1246b 100644 --- a/modules/statics/CHANGELOG.md +++ b/modules/statics/CHANGELOG.md @@ -3,6 +3,29 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [7.0.0-rc.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/statics@7.0.0-rc.2...@bitgo/statics@7.0.0-rc.4) (2022-07-19) + + +### Features + +* **statics:** add toekn MWT ([1bd223d](https://github.com/BitGo/BitGoJS/commit/1bd223d4e0bf24544c57b8f7023a46135f46a632)) +* **statics:** remove 'kind' parameter from FIAT factory and FiatCoin class ([ace31ac](https://github.com/BitGo/BitGoJS/commit/ace31acbb43e1e1f04798f398af28ca8e8aadfc6)) + + + + + +# [7.0.0-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/statics@7.0.0-rc.2...@bitgo/statics@7.0.0-rc.3) (2022-07-18) + + +### Features + +* **statics:** add toekn MWT ([1bd223d](https://github.com/BitGo/BitGoJS/commit/1bd223d4e0bf24544c57b8f7023a46135f46a632)) + + + + + # [7.0.0-rc.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/statics@7.0.0-rc.0...@bitgo/statics@7.0.0-rc.2) (2022-07-15) diff --git a/modules/statics/package.json b/modules/statics/package.json index 8fad03122a..c9367b6a42 100644 --- a/modules/statics/package.json +++ b/modules/statics/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/statics", - "version": "7.0.0-rc.2", + "version": "7.0.0-rc.4", "description": "dependency-free static configuration for the bitgo platform", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", diff --git a/modules/statics/src/account.ts b/modules/statics/src/account.ts index 4c3e371f8f..d8b93d6f40 100644 --- a/modules/statics/src/account.ts +++ b/modules/statics/src/account.ts @@ -84,7 +84,6 @@ export interface SolCoinConstructorOptions extends AccountConstructorOptions { type FiatCoinName = `fiat${string}` | `tfiat${string}`; export interface FiatCoinConstructorOptions extends AccountConstructorOptions { name: FiatCoinName; - kind: CoinKind; } export interface ContractAddress extends String { @@ -321,7 +320,7 @@ export class FiatCoin extends BaseCoin { public readonly network: BaseNetwork; constructor(options: FiatCoinConstructorOptions) { - super(options); + super({ ...options, kind: CoinKind.FIAT }); this.network = options.network; } @@ -1247,7 +1246,6 @@ export function tavaxErc20( * @param prefix? Optional coin prefix. Defaults to empty string * @param suffix? Optional coin suffix. Defaults to coin name. * @param isToken? Whether or not this coin is a token of another coin - * @param kind? Differentiates coins which represent fiat assets from those which represent crypto assets */ export function fiat( name: FiatCoinName, @@ -1259,8 +1257,7 @@ export function fiat( primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1, prefix = '', suffix: string = name.toUpperCase(), - isToken = false, - kind: CoinKind = CoinKind.FIAT + isToken = false ) { return Object.freeze( new FiatCoin({ @@ -1274,7 +1271,6 @@ export function fiat( isToken, asset, primaryKeyCurve, - kind, }) ); } diff --git a/modules/statics/src/base.ts b/modules/statics/src/base.ts index f8b46ae95e..b26e3ee64c 100644 --- a/modules/statics/src/base.ts +++ b/modules/statics/src/base.ts @@ -513,6 +513,7 @@ export enum UnderlyingAsset { MUSD = 'musd', MVL = 'mvl', MVI = 'mvi', + MWT = 'mwt', NAS = 'nas', NCT = 'nct', NDX = 'ndx', diff --git a/modules/statics/src/coins.ts b/modules/statics/src/coins.ts index c49fce73cf..cc3222b59c 100644 --- a/modules/statics/src/coins.ts +++ b/modules/statics/src/coins.ts @@ -559,6 +559,7 @@ export const coins = CoinMap.fromCoins([ erc20('musd', 'mStable USD', 18, '0xe2f2a5c287993345a840db3b0845fbc70f5935a5', UnderlyingAsset.MUSD), erc20('mvl', 'Mass Vehicle Ledger', 18, '0xa849eaae994fb86afa73382e9bd88c2b6b18dc71', UnderlyingAsset.MVL), erc20('mvi', 'Metaverse Index', 18, '0x72e364f2abdc788b7e918bc238b21f109cd634d7', UnderlyingAsset.MVI), + erc20('mwt', 'Mountain Wolf Token', 18, '0x1bd936a1d180b5afc640ea9b2274156af0b7533b', UnderlyingAsset.MWT), erc20('nas', 'Nebulas', 18, '0x5d65d971895edc438f465c17db6992698a52318d', UnderlyingAsset.NAS), erc20('nct', 'Polyswarm', 18, '0x9e46a38f5daabe8683e10793b06749eef7d733d1', UnderlyingAsset.NCT), erc20('ndx', 'Indexed Finance', 18, '0x86772b1409b61c639eaac9ba0acfbb6e238e5f83', UnderlyingAsset.NDX), diff --git a/modules/utxo-bin/CHANGELOG.md b/modules/utxo-bin/CHANGELOG.md index 9c2073ee9e..c61535d500 100644 --- a/modules/utxo-bin/CHANGELOG.md +++ b/modules/utxo-bin/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.0.0-rc.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/utxo-bin@2.0.0-rc.0...@bitgo/utxo-bin@2.0.0-rc.3) (2022-07-19) + +**Note:** Version bump only for package @bitgo/utxo-bin + + + + + +# [2.0.0-rc.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/utxo-bin@2.0.0-rc.0...@bitgo/utxo-bin@2.0.0-rc.1) (2022-07-18) + +**Note:** Version bump only for package @bitgo/utxo-bin + + + + + # [2.0.0-rc.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/utxo-bin@1.0.2-rc.27...@bitgo/utxo-bin@2.0.0-rc.0) (2022-07-15) diff --git a/modules/utxo-bin/package.json b/modules/utxo-bin/package.json index be7dd563a0..53e92317e4 100644 --- a/modules/utxo-bin/package.json +++ b/modules/utxo-bin/package.json @@ -1,7 +1,7 @@ { "name": "@bitgo/utxo-bin", "description": "Command-line utility for BitGo UTXO transactions", - "version": "2.0.0-rc.0", + "version": "2.0.0-rc.3", "files": [ "dist/**/*" ], @@ -27,7 +27,7 @@ "bin": "./dist/bin/index.js", "dependencies": { "@bitgo/blockapis": "^1.0.1-rc.17", - "@bitgo/statics": "^7.0.0-rc.2", + "@bitgo/statics": "^7.0.0-rc.4", "@bitgo/utxo-lib": "^2.3.0-rc.11", "archy": "^1.0.0", "chalk": "4", diff --git a/modules/web-demo/CHANGELOG.md b/modules/web-demo/CHANGELOG.md index 4bc42cb0ca..02d023c016 100644 --- a/modules/web-demo/CHANGELOG.md +++ b/modules/web-demo/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0-rc.25](https://github.com/BitGo/BitGoJS/compare/@bitgo/web-demo@1.1.0-rc.23...@bitgo/web-demo@1.1.0-rc.25) (2022-07-19) + +**Note:** Version bump only for package @bitgo/web-demo + + + + + +# [1.1.0-rc.24](https://github.com/BitGo/BitGoJS/compare/@bitgo/web-demo@1.1.0-rc.23...@bitgo/web-demo@1.1.0-rc.24) (2022-07-18) + +**Note:** Version bump only for package @bitgo/web-demo + + + + + # [1.1.0-rc.23](https://github.com/BitGo/BitGoJS/compare/@bitgo/web-demo@1.1.0-rc.22...@bitgo/web-demo@1.1.0-rc.23) (2022-07-15) **Note:** Version bump only for package @bitgo/web-demo diff --git a/modules/web-demo/package.json b/modules/web-demo/package.json index f963490549..3f3dc3ad71 100644 --- a/modules/web-demo/package.json +++ b/modules/web-demo/package.json @@ -1,6 +1,6 @@ { "name": "@bitgo/web-demo", - "version": "1.1.0-rc.23", + "version": "1.1.0-rc.25", "description": "BitGoJS Web demo package", "repository": { "type": "git", @@ -24,9 +24,9 @@ "precommit": "yarn lint-staged" }, "dependencies": { - "@bitgo/sdk-api": "^1.1.0-rc.31", - "@bitgo/sdk-coin-xrp": "^1.1.0-rc.21", - "bitgo": "^14.2.0-rc.40", + "@bitgo/sdk-api": "^1.1.0-rc.33", + "@bitgo/sdk-coin-xrp": "^1.1.0-rc.23", + "bitgo": "^14.2.0-rc.42", "lodash": "^4.17.15", "react": "^17.0.2", "react-dom": "^17.0.2", diff --git a/scripts/check-package-dependencies.ts b/scripts/check-package-dependencies.ts index c74d9ca72f..d16557c93c 100644 --- a/scripts/check-package-dependencies.ts +++ b/scripts/check-package-dependencies.ts @@ -11,9 +11,10 @@ const options = { 'dist', 'example', 'test', + 'examples', ], ignoreMatches: [ - '@*/**', + '@components/**', 'assert', 'blake2b', 'express-serve-static-core', diff --git a/scripts/update-dockerfile.ts b/scripts/update-dockerfile.ts index e4f800c305..b905cf1b8e 100644 --- a/scripts/update-dockerfile.ts +++ b/scripts/update-dockerfile.ts @@ -10,11 +10,11 @@ type ManagedModule = { /** * Create a function which can run lerna commands - * @param lernaPath {string} path to lerna binary + * @param {String} lernaPath - path to lerna binary * @returns {function(string, string[], Object.): Promise} */ -function getLernaRunner(lernaPath) { - return async (command, args = [], options = {}) => { +function getLernaRunner(lernaPath: string) { + return async (command: string, args: string[] = [], options = {}) => { const { stdout } = await execa( lernaPath, [command, ...args], @@ -36,7 +36,7 @@ const walkDependencies = (packageName: string, setDeps: Set, grap /** * Get information on the modules in this repo that are managed by lerna. - * @param lerna {function} + * @param {Function} lerna * @returns {Promise<{path: *, name: *, deps: *, version: *}[]>} */ async function updateDockerFile(lerna) { @@ -56,10 +56,16 @@ async function updateDockerFile(lerna) { const linkers = Array.from(setDeps).map((dep) => ` yarn link ${dep.name}`).join(' && \\\n'); const linkContent = `RUN cd /var/bitgo-express && \\\n${linkers}\n`; + + // add metadata about the build to docker labels + let labelContent = `LABEL created="${new Date().toUTCString()}"\n`; // add created timestamp; + labelContent += `LABEL version=${require('../modules/express/package.json').version}\n`; // set current image version from express + labelContent += `LABEL git_hash=${require('child_process').execSync(`git rev-parse HEAD`).toString().trim()}\n`; // set to latest git HEAD hash + dockerContents = dockerContents .replace(/#COPY_START((.|\n)*)#COPY_END/, `#COPY_START\n${copyContent}#COPY_END`) - .replace(/#LINK_START((.|\n)*)#LINK_END/, `#LINK_START\n${linkContent}#LINK_END`); - + .replace(/#LINK_START((.|\n)*)#LINK_END/, `#LINK_START\n${linkContent}#LINK_END`) + .replace(/#LABEL_START((.|\n)*)#LABEL_END/, `#LABEL_START\n${labelContent}#LABEL_END`); fs.writeFileSync('Dockerfile', dockerContents); } diff --git a/tsconfig.packages.json b/tsconfig.packages.json index 6c05d28b78..fbe294fc77 100644 --- a/tsconfig.packages.json +++ b/tsconfig.packages.json @@ -61,6 +61,9 @@ { "path": "./modules/sdk-coin-doge" }, + { + "path": "./modules/sdk-coin-dot" + }, { "path": "./modules/sdk-coin-eos" }, @@ -71,7 +74,7 @@ "path": "./modules/sdk-coin-eth" }, { - "path": "./modules/sdk-coin-dot" + "path": "./modules/sdk-coin-eth2" }, { "path": "./modules/sdk-coin-hbar" @@ -82,6 +85,9 @@ { "path": "./modules/sdk-coin-near" }, + { + "path": "./modules/sdk-coin-polygon" + }, { "path": "./modules/sdk-coin-rbtc" }, diff --git a/yarn.lock b/yarn.lock index eb9aed5f45..e75f207a32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1069,7 +1069,7 @@ web3-eth-abi "1.3.6" web3-utils "1.3.6" -"@celo/wallet-base@2.0.0": +"@celo/wallet-base@2.0.0", "@celo/wallet-base@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@celo/wallet-base/-/wallet-base-2.0.0.tgz#c3926af9fe618792eadb5e89b594cafcd7e8f158" integrity sha512-P/w1sd+VVqzCxOHzS9jUBSKfke/49GuaaNhsxD8xFX3Rr2/ryGE3ZgzoS3LQbQx2X3WqwRUGhelt7fGgTguBJg== @@ -1420,6 +1420,16 @@ resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed" integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg== +"@emurgo/cardano-serialization-lib-browser@^10.2.0": + version "10.2.0" + resolved "https://registry.yarnpkg.com/@emurgo/cardano-serialization-lib-browser/-/cardano-serialization-lib-browser-10.2.0.tgz#5eb1d1b579072598e4911e5d8ae23f63e22e7b28" + integrity sha512-b4RrWtC5y8+bjKp9sFo8IWXg+xIatXoUq4YcqFDReDN6dpHRjLlOJv7h9Da6VA5GXvLQy6vOFuieAZJFGng9FQ== + +"@emurgo/cardano-serialization-lib-nodejs@^10.2.0": + version "10.2.0" + resolved "https://registry.yarnpkg.com/@emurgo/cardano-serialization-lib-nodejs/-/cardano-serialization-lib-nodejs-10.2.0.tgz#e76ee34fca434b5b0c95cf33ef61548d6845f79e" + integrity sha512-rRWBQcbQlMj4GS7gt6toxRzY9cjMfFBWYKWrfH+eEqUXSO+3blKKA3T/yra3khxU/8+EAY1T94uoUDvjkrpTzg== + "@es-joy/jsdoccomment@^0.4.4": version "0.4.4" resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.4.4.tgz#8a25154156edbfc29e310943ebb17ee29122c9df" @@ -2713,7 +2723,7 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.0.0.tgz#d5e38bfbdaba174805a4e649f13be9a9ed3351ae" integrity sha512-DZVbtY62kc3kkBtMHqwCOfXrT/hnoORy5BJ4+HU1IR59X0KWAOqsfzQPcUl/lQLlG7qXbe/fZ3r/emxtAl+sqg== -"@noble/secp256k1@1.5.5", "@noble/secp256k1@git+https://github.com/brandonblack/noble-secp256k1.git#856129c06436fb696bab7d827edad5effdffaee2": +"@noble/secp256k1@1.5.5": version "1.5.5" resolved "git+https://github.com/brandonblack/noble-secp256k1.git#856129c06436fb696bab7d827edad5effdffaee2"