Skip to content

Commit 257da8f

Browse files
committed
feat: add xrp coin
Ticket: BG-0
1 parent a8e7402 commit 257da8f

30 files changed

Lines changed: 2324 additions & 0 deletions

modules/sdk-coin-xpr/.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules

modules/sdk-coin-xpr/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist
2+
/node_modules
3+
/.nyc_output

modules/sdk-coin-xpr/.mocharc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require:
2+
- ts-node/register
3+
- source-map-support/register
4+
spec: 'test/unit/**/*.ts'
5+
timeout: 10000
6+
reporter: min

modules/sdk-coin-xpr/.npmignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**/*.ts
2+
!**/*.d.ts
3+
src
4+
test
5+
tsconfig.json
6+
tslint.json
7+
.gitignore
8+
.eslintignore
9+
.mocharc.yml
10+
.prettierignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
printWidth: 120
2+
singleQuote: true
3+
trailingComma: es5

modules/sdk-coin-xpr/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# BitGo sdk-coin-xpr
2+
3+
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.
4+
5+
## Installation
6+
7+
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.
8+
9+
In your project install both `@bitgo/sdk-api` and `@bitgo/sdk-coin-xpr`.
10+
11+
```shell
12+
npm i @bitgo/sdk-api @bitgo/sdk-coin-xpr
13+
```
14+
15+
Next, you will be able to initialize an instance of "bitgo" through `@bitgo/sdk-api` instead of `bitgo`.
16+
17+
```javascript
18+
import { BitGoAPI } from '@bitgo/sdk-api';
19+
import { Xpr } from '@bitgo/sdk-coin-xpr';
20+
21+
const sdk = new BitGoAPI();
22+
23+
sdk.register('xpr', Xpr.createInstance);
24+
```
25+
26+
## Development
27+
28+
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.
29+
30+
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.

modules/sdk-coin-xpr/package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "@bitgo/sdk-coin-xpr",
3+
"version": "1.0.0",
4+
"description": "BitGo SDK coin library for Proton (XPR Network)",
5+
"main": "./dist/src/index.js",
6+
"types": "./dist/src/index.d.ts",
7+
"scripts": {
8+
"build": "yarn tsc --build --incremental --verbose .",
9+
"fmt": "prettier --write .",
10+
"check-fmt": "prettier --check '**/*.{ts,js,json}'",
11+
"clean": "rm -r ./dist",
12+
"lint": "eslint --quiet .",
13+
"prepare": "npm run build",
14+
"test": "npm run coverage",
15+
"coverage": "nyc -- npm run unit-test",
16+
"unit-test": "mocha"
17+
},
18+
"author": "BitGo SDK Team <sdkteam@bitgo.com>",
19+
"license": "MIT",
20+
"engines": {
21+
"node": ">=20 <23"
22+
},
23+
"repository": {
24+
"type": "git",
25+
"url": "https://github.com/BitGo/BitGoJS.git",
26+
"directory": "modules/sdk-coin-xpr"
27+
},
28+
"lint-staged": {
29+
"*.{js,ts}": [
30+
"yarn prettier --write",
31+
"yarn eslint --fix"
32+
]
33+
},
34+
"publishConfig": {
35+
"access": "public"
36+
},
37+
"nyc": {
38+
"extension": [
39+
".ts"
40+
]
41+
},
42+
"dependencies": {
43+
"@bitgo/sdk-core": "^36.29.0",
44+
"@bitgo/secp256k1": "^1.9.0",
45+
"@bitgo/statics": "^58.23.0",
46+
"bignumber.js": "^9.1.1",
47+
"eosjs": "^21.0.2",
48+
"eosjs-ecc": "^4.0.4",
49+
"lodash": "^4.17.14",
50+
"superagent": "^9.0.1"
51+
},
52+
"devDependencies": {
53+
"@bitgo/sdk-api": "^1.73.3",
54+
"@bitgo/sdk-test": "^9.1.24",
55+
"@types/lodash": "^4.14.121"
56+
},
57+
"files": [
58+
"dist"
59+
]
60+
}

modules/sdk-coin-xpr/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './lib';
2+
export * from './xpr';
3+
export * from './txpr';
4+
export * from './register';
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Constants for Proton (XPR Network)
3+
*/
4+
5+
export const MAINNET_COIN = 'xpr';
6+
export const TESTNET_COIN = 'txpr';
7+
8+
// Proton mainnet chain ID
9+
export const MAINNET_CHAIN_ID = '384da888112027f0321850a169f737c33e53b388aad48b5adace4bab97f437e0';
10+
// Proton testnet chain ID
11+
export const TESTNET_CHAIN_ID = '71ee83bcf52142d61019d95f9cc5427ba6a0d7ff8accd9e2088ae2abeaf3d3dd';
12+
13+
// Proton address constraints (same as EOS: up to 12 characters, only a-z and 1-5)
14+
export const ADDRESS_LENGTH = 12;
15+
export const VALID_ADDRESS_CHARS = '12345abcdefghijklmnopqrstuvwxyz'.split('');
16+
// Proton addresses: up to 12 characters, only a-z, 1-5, and . (dot)
17+
export const VALID_ADDRESS_REGEX = /^[a-z1-5.]{1,12}$/;
18+
// EOS-style public key format: PUB_K1_xxx or EOS_xxx (legacy)
19+
export const VALID_PUBLIC_KEY_REGEX = /^(PUB_K1_[A-Za-z0-9]+|EOS[A-Za-z0-9]+)$/;
20+
21+
// Transaction expiry - 8 hours in seconds (same as EOS)
22+
export const TX_EXPIRY_SECONDS = 28800;
23+
24+
// Token contract for XPR native token transfers
25+
export const TOKEN_CONTRACT = 'eosio.token';
26+
export const TOKEN_SYMBOL = 'XPR';
27+
export const TOKEN_PRECISION = 4;
28+
29+
// System contract
30+
export const SYSTEM_CONTRACT = 'eosio';

0 commit comments

Comments
 (0)