-
Notifications
You must be signed in to change notification settings - Fork 299
feat(sdk-coin-canton): added new coin, canton skeleton #7114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,9 @@ | |
{ | ||
"path": "../sdk-coin-btg" | ||
}, | ||
{ | ||
"path": "../sdk-coin-canton" | ||
}, | ||
{ | ||
"path": "../sdk-coin-celo" | ||
}, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.idea | ||
public | ||
dist | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
.idea/ | ||
dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require: 'tsx' | ||
timeout: '60000' | ||
reporter: 'min' | ||
reporter-option: | ||
- 'cdn=true' | ||
- 'json=false' | ||
exit: true | ||
spec: ['test/unit/**/*.ts'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
!dist/ | ||
dist/test/ | ||
dist/tsconfig.tsbuildinfo | ||
.idea/ | ||
.prettierrc.yml | ||
tsconfig.json | ||
src/ | ||
test/ | ||
scripts/ | ||
.nyc_output | ||
CODEOWNERS | ||
node_modules/ | ||
.prettierignore | ||
.mocharc.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.nyc_output/ | ||
dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
printWidth: 120 | ||
singleQuote: true | ||
trailingComma: 'es5' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# BitGo sdk-coin-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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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'; | ||
} | ||
|
||
ravibitgo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** @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') { | ||
ravibitgo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throw new Error('Unsupported multiSigType'); | ||
} | ||
auditEddsaPrivateKey(prv, publicKey ?? ''); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './lib'; | ||
export * from './canton'; | ||
export * from './tcanton'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* The transaction data returned from the toJson() function of a transaction | ||
*/ | ||
export interface TxData { | ||
id: string; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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.'); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.