Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-bsv /var/modules/sdk-coin-bsv/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-btc /var/modules/sdk-coin-btc/
COPY --from=builder /tmp/bitgo/modules/utxo-ord /var/modules/utxo-ord/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-btg /var/modules/sdk-coin-btg/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-canton /var/modules/sdk-coin-canton/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-dash /var/modules/sdk-coin-dash/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-doge /var/modules/sdk-coin-doge/
COPY --from=builder /tmp/bitgo/modules/sdk-coin-eos /var/modules/sdk-coin-eos/
Expand Down Expand Up @@ -219,6 +220,7 @@ cd /var/modules/sdk-coin-bsv && yarn link && \
cd /var/modules/sdk-coin-btc && yarn link && \
cd /var/modules/utxo-ord && yarn link && \
cd /var/modules/sdk-coin-btg && yarn link && \
cd /var/modules/sdk-coin-canton && yarn link && \
cd /var/modules/sdk-coin-dash && yarn link && \
cd /var/modules/sdk-coin-doge && yarn link && \
cd /var/modules/sdk-coin-eos && yarn link && \
Expand Down Expand Up @@ -318,6 +320,7 @@ RUN cd /var/bitgo-express && \
yarn link @bitgo/sdk-coin-btc && \
yarn link @bitgo/utxo-ord && \
yarn link @bitgo/sdk-coin-btg && \
yarn link @bitgo/sdk-coin-canton && \
yarn link @bitgo/sdk-coin-dash && \
yarn link @bitgo/sdk-coin-doge && \
yarn link @bitgo/sdk-coin-eos && \
Expand Down
1 change: 1 addition & 0 deletions modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@bitgo/sdk-coin-bsv": "^2.4.2",
"@bitgo/sdk-coin-btc": "^2.9.1",
"@bitgo/sdk-coin-btg": "^2.4.2",
"@bitgo/sdk-coin-canton": "^1.0.0",
"@bitgo/sdk-coin-celo": "^5.3.2",
"@bitgo/sdk-coin-coredao": "^2.6.2",
"@bitgo/sdk-coin-coreum": "^21.5.2",
Expand Down
7 changes: 7 additions & 0 deletions modules/bitgo/src/v2/coinFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
Bsv,
Btc,
Btg,
Canton,
Celo,
CeloToken,
Coredao,
Expand Down Expand Up @@ -149,6 +150,7 @@ import {
Tbtcsig,
Tbtc4,
Tbtcbgsig,
Tcanton,
Tcelo,
Tcoredao,
Tcoreum,
Expand Down Expand Up @@ -241,6 +243,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin
coinFactory.register('bsv', Bsv.createInstance);
coinFactory.register('btc', Btc.createInstance);
coinFactory.register('btg', Btg.createInstance);
coinFactory.register('canton', Canton.createInstance);
coinFactory.register('celo', Celo.createInstance);
coinFactory.register('coredao', Coredao.createInstance);
coinFactory.register('coreum', Coreum.createInstance);
Expand Down Expand Up @@ -605,6 +608,8 @@ export function getCoinConstructor(coinName: string): CoinConstructor | undefine
return Btc.createInstance;
case 'btg':
return Btg.createInstance;
case 'canton':
return Canton.createInstance;
case 'celo':
return Celo.createInstance;
case 'coredao':
Expand Down Expand Up @@ -747,6 +752,8 @@ export function getCoinConstructor(coinName: string): CoinConstructor | undefine
return Tbtc4.createInstance;
case 'tbtcbgsig':
return Tbtcbgsig.createInstance;
case 'tcanton':
return Tcanton.createInstance;
case 'tcelo':
return Tcelo.createInstance;
case 'tcoredao':
Expand Down
2 changes: 2 additions & 0 deletions modules/bitgo/src/v2/coins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Bsc, BscToken, Tbsc } from '@bitgo/sdk-coin-bsc';
import { Bsv, Tbsv } from '@bitgo/sdk-coin-bsv';
import { Btc, Tbtc, Tbtcsig, Tbtc4, Tbtcbgsig } from '@bitgo/sdk-coin-btc';
import { Btg } from '@bitgo/sdk-coin-btg';
import { Canton, Tcanton } from '@bitgo/sdk-coin-canton';
import { Celo, CeloToken, Tcelo } from '@bitgo/sdk-coin-celo';
import { Coredao, Tcoredao, CoredaoToken } from '@bitgo/sdk-coin-coredao';
import { Coreum, Tcoreum } from '@bitgo/sdk-coin-coreum';
Expand Down Expand Up @@ -91,6 +92,7 @@ export { Bsc, BscToken, Tbsc };
export { Bsv, Tbsv };
export { Btc, Tbtc, Tbtcsig, Tbtc4, Tbtcbgsig };
export { Btg };
export { Canton, Tcanton };
export { Celo, CeloToken, Tcelo };
export { Coredao, Tcoredao, CoredaoToken };
export { Coreum, Tcoreum };
Expand Down
2 changes: 2 additions & 0 deletions modules/bitgo/test/browser/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ describe('Coins', () => {
HashToken: 1,
FlrToken: 1,
JettonToken: 1,
Canton: 1,
Tcanton: 1,
};
Object.keys(BitGoJS.Coin)
.filter((coinName) => !excludedKeys[coinName])
Expand Down
3 changes: 3 additions & 0 deletions modules/bitgo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
{
"path": "../sdk-coin-btg"
},
{
"path": "../sdk-coin-canton"
},
{
"path": "../sdk-coin-celo"
},
Expand Down
5 changes: 5 additions & 0 deletions modules/sdk-coin-canton/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.idea
public
dist

3 changes: 3 additions & 0 deletions modules/sdk-coin-canton/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.idea/
dist/
8 changes: 8 additions & 0 deletions modules/sdk-coin-canton/.mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require: 'tsx'
timeout: '60000'
reporter: 'min'
reporter-option:
- 'cdn=true'
- 'json=false'
exit: true
spec: ['test/unit/**/*.ts']
14 changes: 14 additions & 0 deletions modules/sdk-coin-canton/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
!dist/
dist/test/
dist/tsconfig.tsbuildinfo
.idea/
.prettierrc.yml
tsconfig.json
src/
test/
scripts/
.nyc_output
CODEOWNERS
node_modules/
.prettierignore
.mocharc.js
2 changes: 2 additions & 0 deletions modules/sdk-coin-canton/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nyc_output/
dist/
3 changes: 3 additions & 0 deletions modules/sdk-coin-canton/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
printWidth: 120
singleQuote: true
trailingComma: 'es5'
30 changes: 30 additions & 0 deletions modules/sdk-coin-canton/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BitGo sdk-coin-canton

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-canton`.

```shell
npm i @bitgo/sdk-api @bitgo/sdk-coin-canton
```

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 { Canton } from '@bitgo/sdk-coin-canton';

const sdk = new BitGoAPI();

sdk.register('canton', Canton.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.
52 changes: 52 additions & 0 deletions modules/sdk-coin-canton/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@bitgo/sdk-coin-canton",
"version": "1.0.0",
"description": "BitGo SDK coin library for Canton",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
"build": "yarn tsc --build --incremental --verbose .",
"fmt": "prettier --write .",
"check-fmt": "prettier --check .",
"clean": "rm -r ./dist",
"lint": "eslint --quiet .",
"prepare": "npm run build",
"test": "npm run coverage",
"coverage": "nyc -- npm run unit-test",
"unit-test": "mocha"
},
"author": "BitGo SDK Team <sdkteam@bitgo.com>",
"license": "MIT",
"engines": {
"node": ">=20 <23"
},
"repository": {
"type": "git",
"url": "https://github.com/BitGo/BitGoJS.git",
"directory": "modules/sdk-coin-canton"
},
"lint-staged": {
"*.{js,ts}": [
"yarn prettier --write",
"yarn eslint --fix"
]
},
"publishConfig": {
"access": "public"
},
"nyc": {
"extension": [
".ts"
]
},
"dependencies": {
"@bitgo/sdk-core": "^36.10.1",
"@bitgo/statics": "^58.2.0",
"bignumber.js": "^9.1.1"
},
"devDependencies": {
"@bitgo/sdk-api": "^1.69.2",
"@bitgo/sdk-lib-mpc": "^10.7.0",
"@bitgo/sdk-test": "^9.1.2"
}
}
112 changes: 112 additions & 0 deletions modules/sdk-coin-canton/src/canton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import {
AuditDecryptedKeyParams,
BaseCoin,
BitGoBase,
KeyPair,
MPCAlgorithm,
MultisigType,
multisigTypes,
ParsedTransaction,
ParseTransactionOptions,
SignedTransaction,
SignTransactionOptions,
VerifyAddressOptions,
VerifyTransactionOptions,
} from '@bitgo/sdk-core';
import { auditEddsaPrivateKey } from '@bitgo/sdk-lib-mpc';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';

export class Canton extends BaseCoin {
protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;

protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>) {
super(bitgo);

if (!staticsCoin) {
throw new Error('missing required constructor parameter staticsCoin');
}

this._staticsCoin = staticsCoin;
}

static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
return new Canton(bitgo, staticsCoin);
}

/** @inheritDoc */
public getBaseFactor(): number {
return 1e10;
}

/** @inheritDoc */
public getChain(): string {
return 'canton';
}

/** @inheritDoc */
public getFamily(): string {
return 'canton';
}

/** @inheritDoc */
public getFullName(): string {
return 'Canton';
}

/** @inheritDoc */
supportsTss(): boolean {
return true;
}

/** inherited doc */
getDefaultMultisigType(): MultisigType {
return multisigTypes.tss;
}

getMPCAlgorithm(): MPCAlgorithm {
return 'eddsa';
}

/** @inheritDoc */
verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
throw new Error('Method not implemented.');
}

/** @inheritDoc */
isWalletAddress(params: VerifyAddressOptions): Promise<boolean> {
throw new Error('Method not implemented.');
}

/** @inheritDoc */
parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
throw new Error('Method not implemented.');
}

/** @inheritDoc */
generateKeyPair(seed?: Buffer): KeyPair {
throw new Error('Method not implemented.');
}

/** @inheritDoc */
isValidPub(pub: string): boolean {
throw new Error('Method not implemented.');
}

/** @inheritDoc */
isValidAddress(address: string): boolean {
throw new Error('Method not implemented.');
}

/** @inheritDoc */
signTransaction(params: SignTransactionOptions): Promise<SignedTransaction> {
throw new Error('Method not implemented.');
}

/** @inheritDoc */
auditDecryptedKey({ multiSigType, prv, publicKey }: AuditDecryptedKeyParams): void {
if (multiSigType !== 'tss') {
throw new Error('Unsupported multiSigType');
}
auditEddsaPrivateKey(prv, publicKey ?? '');
}
}
3 changes: 3 additions & 0 deletions modules/sdk-coin-canton/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './lib';
export * from './canton';
export * from './tcanton';
6 changes: 6 additions & 0 deletions modules/sdk-coin-canton/src/lib/iface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* The transaction data returned from the toJson() function of a transaction
*/
export interface TxData {
id: string;
}
9 changes: 9 additions & 0 deletions modules/sdk-coin-canton/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as Utils from './utils';
import * as Interface from './iface';

export { KeyPair } from './keyPair';
export { Transaction } from './transaction';
export { TransactionBuilder } from './transactionBuilder';
export { TransactionBuilderFactory } from './transactionBuilderFactory';

export { Utils, Interface };
23 changes: 23 additions & 0 deletions modules/sdk-coin-canton/src/lib/keyPair.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { DefaultKeys, Ed25519KeyPair } from '@bitgo/sdk-core';

export class KeyPair extends Ed25519KeyPair {
/** @inheritdoc */
getKeys(): DefaultKeys {
throw new Error('Method not implemented.');
}

/** @inheritdoc */
recordKeysFromPrivateKeyInProtocolFormat(prv: string): DefaultKeys {
throw new Error('Method not implemented.');
}

/** @inheritdoc */
recordKeysFromPublicKeyInProtocolFormat(pub: string): DefaultKeys {
throw new Error('Method not implemented.');
}

/** @inheritdoc */
getAddress(): string {
throw new Error('Method not implemented.');
}
}
Loading