Skip to content

Commit

Permalink
feat: adds xrp support (#131)
Browse files Browse the repository at this point in the history
Co-authored-by: Tejasv Sharma <[email protected]>
  • Loading branch information
muzaffarbhat07 and TejasvOnly authored Oct 23, 2024
1 parent cc6bdb6 commit c4f154b
Show file tree
Hide file tree
Showing 58 changed files with 8,916 additions and 4,748 deletions.
6 changes: 6 additions & 0 deletions .changeset/twenty-vans-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@cypherock/sdk-app-xrp": major
"nodejs-test": patch
---

added xrp support
14 changes: 6 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ jobs:

steps:
- name: checkout code repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: "recursive"
submodules: 'recursive'

- name: Install pnpm
uses: pnpm/[email protected]
with:
version: next-8
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
Expand Down Expand Up @@ -68,8 +66,8 @@ jobs:
uses: changesets/action@v1
with:
version: pnpm ci:version
commit: "chore: update versions"
title: "chore: update versions"
commit: 'chore: update versions'
title: 'chore: update versions'
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 4 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ jobs:

steps:
- name: Checkout Commit
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: "recursive"
submodules: 'recursive'

- name: Install pnpm
uses: pnpm/[email protected]
with:
version: next-8
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
Expand Down
4 changes: 3 additions & 1 deletion apps/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@cypherock/sdk-app-near": "workspace:^",
"@cypherock/sdk-app-solana": "workspace:^",
"@cypherock/sdk-app-tron": "workspace:^",
"@cypherock/sdk-app-xrp": "workspace:^",
"@cypherock/sdk-core": "workspace:^",
"@cypherock/sdk-hw-hid": "workspace:^",
"@cypherock/sdk-hw-serialport": "workspace:^",
Expand All @@ -37,6 +38,7 @@
"ethers": "^6.7.0",
"near-api-js": "^2.1.4",
"tronweb": "^5.3.2",
"winston": "^3.11.0"
"winston": "^3.11.0",
"xrpl": "^4.0.0"
}
}
86 changes: 43 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
{
"name": "sdk",
"version": "0.0.0",
"private": true,
"workspaces": [
"apps/*",
"packages/*"
],
"scripts": {
"build": "turbo run build --no-daemon",
"prebuild": "turbo run prebuild --no-daemon",
"dev": "turbo run dev --parallel --no-daemon",
"lint": "turbo run lint --no-daemon",
"pretty": "turbo run pretty --no-daemon",
"lint:check": "turbo run lint:check --no-daemon",
"pretty:check": "turbo run pretty:check --no-daemon",
"test": "turbo run test --no-daemon",
"start:node": "turbo run start:node --no-daemon",
"start:browser": "turbo run start:browser --no-daemon",
"dev:browser": "turbo run dev:browser --no-daemon",
"pre-commit": "turbo run pre-commit --concurrency=1",
"prepare": "husky install",
"clean": "node scripts/clean.js && bash ./scripts/clean.sh",
"clean:force": "node scripts/clean.js -f && bash ./scripts/clean.sh",
"ci:publish": "pnpm publish -r --access public --no-git-checks --filter \"@cypherock/sdk-*\"",
"ci:version": "pnpm changeset version && pnpm i --no-frozen-lockfile",
"doc:serve": "mkdocs serve",
"doc:build": "mkdocs build"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.1",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@cypherock/eslint-config": "workspace:*",
"@cypherock/prettier-config": "workspace:*",
"husky": "^8.0.0",
"prettier": "^3.2.4",
"turbo": "latest"
},
"engines": {
"node": ">=18.0.0"
},
"packageManager": "[email protected]"
"name": "sdk",
"version": "0.0.0",
"private": true,
"workspaces": [
"apps/*",
"packages/*"
],
"scripts": {
"build": "turbo run build --no-daemon",
"prebuild": "turbo run prebuild --no-daemon",
"dev": "turbo run dev --parallel --no-daemon",
"lint": "turbo run lint --no-daemon",
"pretty": "turbo run pretty --no-daemon",
"lint:check": "turbo run lint:check --no-daemon",
"pretty:check": "turbo run pretty:check --no-daemon",
"test": "turbo run test --no-daemon",
"start:node": "turbo run start:node --no-daemon",
"start:browser": "turbo run start:browser --no-daemon",
"dev:browser": "turbo run dev:browser --no-daemon",
"pre-commit": "turbo run pre-commit --concurrency=1",
"prepare": "husky install",
"clean": "node scripts/clean.js && bash ./scripts/clean.sh",
"clean:force": "node scripts/clean.js -f && bash ./scripts/clean.sh",
"ci:publish": "pnpm publish -r --access public --no-git-checks --filter \"@cypherock/sdk-*\"",
"ci:version": "pnpm changeset version && pnpm i --no-frozen-lockfile",
"doc:serve": "mkdocs serve",
"doc:build": "mkdocs build"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.1",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@cypherock/eslint-config": "workspace:*",
"@cypherock/prettier-config": "workspace:*",
"husky": "^8.0.0",
"prettier": "^3.2.4",
"turbo": "^1.13.4"
},
"engines": {
"node": ">=18.0.0"
},
"packageManager": "[email protected]"
}
8 changes: 8 additions & 0 deletions packages/app-xrp/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
root: true,
extends: ['@cypherock/eslint-config'],
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json'],
},
};
7 changes: 7 additions & 0 deletions packages/app-xrp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.turbo
dist

# stryker temp files
.stryker-tmp
reports
src/proto
1 change: 1 addition & 0 deletions packages/app-xrp/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/proto/generated
1 change: 1 addition & 0 deletions packages/app-xrp/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@cypherock/prettier-config"
3 changes: 3 additions & 0 deletions packages/app-xrp/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

Documentation pending
22 changes: 22 additions & 0 deletions packages/app-xrp/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.test.ts',
'!src/**/__fixtures__/*',
'!src/proto/generated/**/*',
],
testTimeout: 500,
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: '.',
testPathIgnorePatterns: ['/node_modules/', '/__fixtures__/', '/dist/'],
testMatch: [
'**/tests/**/*.[jt]s?(x)',
'**/__tests__/**/*.[jt]s?(x)',
'!**/__mocks__/**/*.[jt]s?(x)',
'!**/__helpers__/**/*.[jt]s?(x)',
'!**/.stryker-tmp/**/*.[jt]s?(x)',
],
modulePathIgnorePatterns: ['<rootDir>/.stryker-tmp'],
};
21 changes: 21 additions & 0 deletions packages/app-xrp/jest.stryker.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.test.ts',
'!src/**/__fixtures__/*',
'!src/proto/generated/**/*',
],
testTimeout: 500,
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: '.',
testPathIgnorePatterns: ['/node_modules/', '/__fixtures__/', '/dist/'],
testMatch: [
'**/tests/**/*.[jt]s?(x)',
'**/__tests__/**/*.[jt]s?(x)',
'!**/__mocks__/**/*.[jt]s?(x)',
'!**/__helpers__/**/*.[jt]s?(x)',
],
modulePathIgnorePatterns: ['<rootDir>/.stryker-tmp'],
};
1 change: 1 addition & 0 deletions packages/app-xrp/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
site_name: '@cypherock/sdk-app-xrp'
54 changes: 54 additions & 0 deletions packages/app-xrp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@cypherock/sdk-app-xrp",
"version": "0.0.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"scripts": {
"lint": "eslint src/ tests/ --fix",
"lint:check": "eslint --ext .ts,tsx,js,jsx,js src/",
"pretty": "prettier --write 'src/**/*.ts' 'tests/**/*.ts'",
"pretty:check": "prettier --check 'src/**/*.ts' 'tests/**/*.ts'",
"prebuild": "bash ./scripts/prebuild.sh",
"build": "rimraf dist && tsc -p tsconfig.json",
"test": "cross-env LOG_LEVEL=error jest",
"test:mutation": "stryker run",
"pre-commit": "lint-staged"
},
"devDependencies": {
"@cypherock/eslint-config": "workspace:*",
"@cypherock/prettier-config": "workspace:^0.0.7",
"@cypherock/tsconfig": "workspace:*",
"@jest/globals": "^29.4.1",
"@stryker-mutator/core": "^6.4.1",
"@stryker-mutator/jest-runner": "^6.4.1",
"@stryker-mutator/typescript-checker": "^6.4.1",
"@types/jest": "^29.4.0",
"@types/node": "18.11.18",
"cross-env": "^7.0.3",
"eslint": "^7.32.0",
"jest": "^29.4.1",
"lint-staged": "^13.2.0",
"rimraf": "^4.1.2",
"ts-jest": "^29.0.5",
"ts-proto": "^1.139.0",
"typescript": "^4.5.2"
},
"dependencies": {
"@cypherock/sdk-core": "workspace:^0.0.25",
"@cypherock/sdk-interfaces": "workspace:^0.0.15",
"@cypherock/sdk-utils": "workspace:^0.0.18",
"long": "^5.2.1",
"protobufjs": "^7.2.2",
"xrpl": "^4.0.0"
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint --ext ts,tsx --quiet --fix --",
"prettier --write"
],
"*.{js,jsx,md,mdx,mjs,yml,yaml,css,json}": [
"prettier --write"
]
}
}
16 changes: 16 additions & 0 deletions packages/app-xrp/scripts/prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

rm -rf ./src/proto/generated/*.ts || true
rm -rf ./src/proto/generated/xrp || true

mkdir -p src/proto/generated

if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
protoc --plugin=protoc-gen-ts_proto=$(pwd)/node_modules/.bin/protoc-gen-ts_proto.cmd --ts_proto_out=./src/proto/generated ../../submodules/common/proto/xrp/*.proto ../../submodules/common/proto/common.proto -I../../submodules/common/proto --ts_proto_opt=forceLong=string --ts_proto_opt=esModuleInterop=true
else
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/proto/generated ../../submodules/common/proto/xrp/*.proto ../../submodules/common/proto/common.proto -I../../submodules/common/proto --ts_proto_opt=forceLong=string --ts_proto_opt=esModuleInterop=true
fi

node ../../scripts/extractTypes/index.js ./src/proto/generated ./src/proto/generated/types.ts
60 changes: 60 additions & 0 deletions packages/app-xrp/src/__mocks__/sdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { ISDK } from '@cypherock/sdk-core';
import { DeviceState } from '@cypherock/sdk-interfaces';
import { jest } from '@jest/globals';

let sequenceNumber = 0;

export const getStatus = jest.fn<ISDK['getStatus']>();
export const sendAbort = jest.fn<ISDK['sendAbort']>();
export const getResult = jest.fn<ISDK['getResult']>();
export const sendQuery = jest.fn<ISDK['sendQuery']>();

export const configureAppletId = jest.fn<ISDK['configureAppletId']>();
export const checkAppCompatibility = jest.fn<ISDK['checkAppCompatibility']>();

export const waitForResult = jest.fn<ISDK['waitForResult']>();
export const getSequenceNumber = jest.fn<ISDK['getSequenceNumber']>(
async () => sequenceNumber,
);
export const getNewSequenceNumber = jest.fn<ISDK['getNewSequenceNumber']>(
async () => {
sequenceNumber += 1;
return sequenceNumber;
},
);

export const runOperation = jest.fn<ISDK['runOperation']>(func => func());

export const destroy = jest.fn<ISDK['destroy']>();
export const getDeviceState = jest.fn<ISDK['getDeviceState']>(
async () => DeviceState.MAIN,
);

export const create = jest.fn(async () =>
Promise.resolve({
configureAppletId,
checkAppCompatibility,
sendAbort,
getResult,
getStatus,
sendQuery,
waitForResult,
getSequenceNumber,
getNewSequenceNumber,
runOperation,
destroy,
getDeviceState,
}),
);

jest.mock('@cypherock/sdk-core', () => {
const originalModule: any = jest.requireActual('@cypherock/sdk-core');

return {
__esModule: true,
...originalModule,
SDK: {
create,
},
};
});
Loading

0 comments on commit c4f154b

Please sign in to comment.