Skip to content

Commit

Permalink
feat(sdk-coin-rune): added rune sdk and statics
Browse files Browse the repository at this point in the history
  • Loading branch information
at31416 committed Oct 21, 2024
1 parent db35f38 commit 4a7d37d
Show file tree
Hide file tree
Showing 45 changed files with 5,647 additions and 5 deletions.
1 change: 1 addition & 0 deletions modules/abstract-cosmos/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export const withdrawDelegatorRewardMsgTypeUrl = '/cosmos.distribution.v1beta1.M
export const executeContractMsgTypeUrl = '/cosmwasm.wasm.v1.MsgExecuteContract';
export const UNAVAILABLE_TEXT = 'UNAVAILABLE';
export const ROOT_PATH = 'm/0';
export const sendMsgType = '/types.MsgSend'; // thorchain uses this custom message type
4 changes: 3 additions & 1 deletion modules/abstract-cosmos/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
import { CosmosKeyPair as KeyPair } from './keyPair';

export class CosmosUtils implements BaseUtils {
private registry;
protected registry;

constructor() {
this.registry = new Registry([...defaultRegistryTypes]);
Expand Down Expand Up @@ -340,6 +340,8 @@ export class CosmosUtils implements BaseUtils {
switch (typeUrl) {
case constants.sendMsgTypeUrl:
return TransactionType.Send;
case constants.sendMsgType:
return TransactionType.Send;
case constants.delegateMsgTypeUrl:
return TransactionType.StakingActivate;
case constants.undelegateMsgTypeUrl:
Expand Down
1 change: 1 addition & 0 deletions modules/account-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@bitgo/sdk-coin-osmo": "^3.0.10",
"@bitgo/sdk-coin-polygon": "^21.0.10",
"@bitgo/sdk-coin-rbtc": "^2.0.41",
"@bitgo/sdk-coin-rune": "^1.0.0",
"@bitgo/sdk-coin-sei": "^3.0.10",
"@bitgo/sdk-coin-sol": "^4.6.0",
"@bitgo/sdk-coin-stx": "^3.2.26",
Expand Down
5 changes: 5 additions & 0 deletions modules/account-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export { Zeta };
import * as Coreum from '@bitgo/sdk-coin-coreum';
export { Coreum };

import * as Rune from '@bitgo/sdk-coin-rune';
export { Rune };

import * as Sol from '@bitgo/sdk-coin-sol';
export { Sol };

Expand Down Expand Up @@ -196,6 +199,8 @@ const coinBuilderMap = {
tzketh: zkEth.TransactionBuilder,
bera: Bera.TransactionBuilder,
tbera: Bera.TransactionBuilder,
rune: Rune.TransactionBuilderFactory,
trune: Rune.TransactionBuilderFactory,
};

/**
Expand Down
1 change: 1 addition & 0 deletions modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"@bitgo/sdk-coin-osmo": "^3.0.10",
"@bitgo/sdk-coin-polygon": "^21.0.10",
"@bitgo/sdk-coin-rbtc": "^2.0.41",
"@bitgo/sdk-coin-rune": "^1.0.0",
"@bitgo/sdk-coin-sei": "^3.0.10",
"@bitgo/sdk-coin-sol": "^4.6.0",
"@bitgo/sdk-coin-stx": "^3.2.26",
Expand Down
4 changes: 4 additions & 0 deletions modules/bitgo/src/v2/coinFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
Polygon,
PolygonToken,
Rbtc,
Rune,
Sei,
Sol,
StellarToken,
Expand Down Expand Up @@ -110,6 +111,7 @@ import {
Topeth,
Tpolygon,
Trbtc,
Trune,
Trx,
Tsei,
Tsol,
Expand Down Expand Up @@ -180,6 +182,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('osmo', Osmo.createInstance);
globalCoinFactory.register('polygon', Polygon.createInstance);
globalCoinFactory.register('rbtc', Rbtc.createInstance);
globalCoinFactory.register('rune', Rune.createInstance);
globalCoinFactory.register('sei', Sei.createInstance);
globalCoinFactory.register('sol', Sol.createInstance);
globalCoinFactory.register('stx', Stx.createInstance);
Expand Down Expand Up @@ -227,6 +230,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('tosmo', Tosmo.createInstance);
globalCoinFactory.register('tpolygon', Tpolygon.createInstance);
globalCoinFactory.register('trbtc', Trbtc.createInstance);
globalCoinFactory.register('trune', Trune.createInstance);
globalCoinFactory.register('trx', Trx.createInstance);
globalCoinFactory.register('tsei', Tsei.createInstance);
globalCoinFactory.register('tsol', Tsol.createInstance);
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 @@ -36,6 +36,7 @@ import { Opeth, Topeth, OpethToken } from '@bitgo/sdk-coin-opeth';
import { Osmo, Tosmo } from '@bitgo/sdk-coin-osmo';
import { Polygon, PolygonToken, Tpolygon } from '@bitgo/sdk-coin-polygon';
import { Rbtc, Trbtc } from '@bitgo/sdk-coin-rbtc';
import { Rune, Trune } from '@bitgo/sdk-coin-rune';
import { Sei, Tsei } from '@bitgo/sdk-coin-sei';
import { Sol, Tsol } from '@bitgo/sdk-coin-sol';
import { Stx, Tstx } from '@bitgo/sdk-coin-stx';
Expand Down Expand Up @@ -85,6 +86,7 @@ export { Opeth, Topeth, OpethToken };
export { Osmo, Tosmo };
export { Polygon, PolygonToken, Tpolygon };
export { Rbtc, Trbtc };
export { Rune, Trune };
export { Sol, Tsol };
export { Stx, Tstx };
export { Sui, Tsui, SuiToken };
Expand Down
1 change: 1 addition & 0 deletions modules/bitgo/test/v2/unit/keychains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('V2 Keychains', function () {
n.asset !== UnderlyingAsset.ARBETH && // TODO(WIN-692): remove this once coin-specific module for arbeth is added
n.asset !== UnderlyingAsset.OPETH && // TODO(WIN-692): remove this once coin-specific module for opeth is added
n.asset !== UnderlyingAsset.ZKETH && // TODO(WIN-1427): remove this once coin-specific module for zketh is added
n.asset !== UnderlyingAsset.RUNE &&
coinFamilyValues.includes(n.name)
);

Expand Down
7 changes: 5 additions & 2 deletions modules/bitgo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@
"path": "../sdk-coin-eth2"
},
{
"path": "../sdk-coin-ethw"
"path": "../sdk-coin-ethlike"
},
{
"path": "../sdk-coin-ethlike"
"path": "../sdk-coin-ethw"
},
{
"path": "../sdk-coin-hash"
Expand Down Expand Up @@ -149,6 +149,9 @@
{
"path": "../sdk-coin-rbtc"
},
{
"path": "../sdk-coin-rune"
},
{
"path": "../sdk-coin-sei"
},
Expand Down
5 changes: 5 additions & 0 deletions modules/sdk-coin-rune/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.idea
public
dist
resources
3 changes: 3 additions & 0 deletions modules/sdk-coin-rune/.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-rune/.mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require: 'ts-node/register'
timeout: '60000'
reporter: 'min'
reporter-option:
- 'cdn=true'
- 'json=false'
exit: true
spec: ['test/unit/**/*.ts']
14 changes: 14 additions & 0 deletions modules/sdk-coin-rune/.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-rune/.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-rune/.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-rune/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BitGo sdk-coin-rune

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

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

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

const sdk = new BitGoAPI();

sdk.register('rune', Rune.createInstance);
```

## Development

Most of the coin implementations are derived from `@bitgo/sdk-core`, `@bitgo/statics`, and coin specific packages. These implementations are used to interact with the BitGo API and BitGo platform services.

You will notice that the basic version of common class extensions have been provided to you and must be resolved before the package build will succeed. Upon initiation of a given SDK coin, you will need to verify that your coin has been included in the root `tsconfig.packages.json` and that the linting, formatting, and testing succeeds when run both within the coin and from the root of BitGoJS.
51 changes: 51 additions & 0 deletions modules/sdk-coin-rune/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@bitgo/sdk-coin-rune",
"version": "1.0.0",
"description": "BitGo SDK coin library for Rune",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
"build": "npm run prepare",
"build-ts": "yarn tsc --build --incremental --verbose .",
"fmt": "prettier --write .",
"check-fmt": "prettier --check .",
"clean": "rm -r ./dist",
"lint": "eslint --quiet .",
"prepare": "npm run build-ts && shx cp -r ./resources ./dist",
"test": "npm run coverage",
"coverage": "nyc -- npm run unit-test",
"unit-test": "mocha"
},
"author": "BitGo SDK Team <[email protected]>",
"license": "MIT",
"engines": {
"node": ">=18 <21"
},
"repository": {
"type": "git",
"url": "https://github.com/BitGo/BitGoJS.git",
"directory": "modules/sdk-coin-rune"
},
"lint-staged": {
"*.{js,ts}": [
"yarn prettier --write",
"yarn eslint --fix"
]
},
"publishConfig": {
"access": "public"
},
"nyc": {
"extension": [
".ts"
]
},
"dependencies": {
"@bitgo/sdk-core": "^28.10.0",
"bech32-buffer": "^0.2.1"
},
"devDependencies": {
"@bitgo/sdk-api": "^1.55.2",
"@bitgo/sdk-test": "^8.0.46"
}
}
Loading

0 comments on commit 4a7d37d

Please sign in to comment.