Skip to content

Commit

Permalink
incorporate ripple-lib-server repo
Browse files Browse the repository at this point in the history
  • Loading branch information
hiromaily committed Feb 6, 2022
1 parent 456630b commit 6043370
Show file tree
Hide file tree
Showing 34 changed files with 12,349 additions and 0 deletions.
20 changes: 20 additions & 0 deletions web/ripple-lib-server/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
trim_trailing_whitespace = true

[Makefile]
indent_size = 4
indent_style = tab

[*.{md,markdown}]
insert_final_newline = false
trim_trailing_whitespace = false

[*.json]
insert_final_newline = false
1 change: 1 addition & 0 deletions web/ripple-lib-server/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/**/*.js
21 changes: 21 additions & 0 deletions web/ripple-lib-server/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"env": {
"browser": false,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "jest"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"prettier"
],
"rules": {}
}
2 changes: 2 additions & 0 deletions web/ripple-lib-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
12 changes: 12 additions & 0 deletions web/ripple-lib-server/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"singleQuote": true,
"trailingComma": "all",
"overrides": [
{
"files": "*.ts",
"options": {
"parser": "typescript"
}
}
]
}
21 changes: 21 additions & 0 deletions web/ripple-lib-server/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 HirokiYasui

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 18 additions & 0 deletions web/ripple-lib-server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

.PHONY: setup
setup-mac:
brew install protobuf
brew tap ktr0731/evans
brew install evans

.PHONY: protoc-ts
protoc-ts:
./scripts/protoc-ts.sh

.PHONY: update-dependencies
update-dependencies:
yarn yarn-upgrade-all

.PHONY: run
run:
yarn run dev
12 changes: 12 additions & 0 deletions web/ripple-lib-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ripple-lib-server
This is gRPC server for calling Ripple API by ripple-lib library.
However, the alternative way is to use [XRP API Server](https://xrpl.org/xrp-api.html).

- proto file [ripple-lib-proto](https://github.com/hiromaily/ripple-lib-proto)
- gRPC client [go-crypto-wallet](https://github.com/hiromaily/go-crypto-wallet)

## ripple-lib
- [ripple-lib](https://github.com/ripple/ripple-lib)
- [Applications using ripple-lib (RippleAPI)](https://github.com/ripple/ripple-lib/blob/develop/APPLICATIONS.md)
- [Get Started with RippleAPI for JavaScript](https://xrpl.org/get-started-with-rippleapi-for-javascript.html)
- [RippleAPI Reference](https://xrpl.org/ja/rippleapi-reference.html)
20 changes: 20 additions & 0 deletions web/ripple-lib-server/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
testEnvironment: 'node',
transform: {
"^.+\\.tsx?$": "ts-jest"
},
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx",
"json",
"node",
],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(ts|js)x?$',
coverageDirectory: 'coverage',
collectCoverageFrom: [
'src/**/*.{ts,tsx,js,jsx}',
'!src/**/*.d.ts',
],
};
42 changes: 42 additions & 0 deletions web/ripple-lib-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "ripple-lib-server",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "yarn ts-node src/server.ts",
"dev:watch": "ts-node-dev --respawn src/server.ts",
"lint": "eslint . --ext .ts,.tsx --fix",
"test": "jest --coverage",
"test:watch": "jest --watch"
},
"author": "HirokiYasui <[email protected]>",
"license": "MIT",
"devDependencies": {
"@types/dotenv": "^8.2.0",
"@types/google-protobuf": "^3.15.5",
"@types/jest": "^27.0.3",
"@types/node": "^17.0.5",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^25.3.2",
"grpc-tools": "^1.11.2",
"grpc_tools_node_protoc_ts": "^5.3.2",
"jest": "^27.4.5",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"ts-jest": "^27.1.2",
"ts-node": "^10.4.0",
"ts-node-dev": "^1.1.8",
"tsutils": "^3.21.0",
"typescript": "^4.5.4",
"yarn-upgrade-all": "^0.5.4"
},
"dependencies": {
"dotenv": "^10.0.0",
"google-protobuf": "^3.19.1",
"grpc": "^1.24.11",
"ripple-lib": "^1.10.0"
}
}
33 changes: 33 additions & 0 deletions web/ripple-lib-server/scripts/protoc-ts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# https://caddi.tech/archives/455

PLUGIN_TS=./node_modules/.bin/protoc-gen-ts
PLUGIN_GRPC=./node_modules/.bin/grpc_tools_node_protoc_plugin
DIST_DIR=./src/pb
PROTO_PATH=../../data/proto

rm -rf ${DIST_DIR}
mkdir ${DIST_DIR}

protoc \
--js_out=import_style=commonjs,binary:"${DIST_DIR}"/ \
--ts_out=import_style=commonjs,binary:"${DIST_DIR}"/ \
--grpc_out="${DIST_DIR}"/ \
--plugin=protoc-gen-grpc="${PLUGIN_GRPC}" \
--plugin=protoc-gen-ts="${PLUGIN_TS}" \
--proto_path=${PROTO_PATH}/rippleapi \
--proto_path=${PROTO_PATH}/third_party \
${PROTO_PATH}/rippleapi/*.proto \
${PROTO_PATH}/third_party/gogo/protobuf/gogoproto/*.proto


# "`yarn bin`"/grpc_tools_node_protoc \
# --plugin=protoc-gen-grpc="`yarn bin`"/grpc_tools_node_protoc_plugin \
# --js_out=import_style=commonjs,binary:./generated \
# --grpc_out=./generated \
# -I./ ./proto/proto/rippleapi/rippleapi.proto

# "`yarn bin`"/grpc_tools_node_protoc \
# --plugin=protoc-gen-ts="`yarn bin`"/protoc-gen-ts \
# --ts_out=./generated \
# -I./ ./proto/proto/rippleapi/rippleapi.proto
41 changes: 41 additions & 0 deletions web/ripple-lib-server/src/pb/account_grpc_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// package: rippleapi.account
// file: account.proto

/* tslint:disable */
/* eslint-disable */

import * as grpc from "grpc";
import * as account_pb from "./account_pb";

interface IRippleAccountAPIService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
getAccountInfo: IRippleAccountAPIService_IGetAccountInfo;
}

interface IRippleAccountAPIService_IGetAccountInfo extends grpc.MethodDefinition<account_pb.RequestGetAccountInfo, account_pb.ResponseGetAccountInfo> {
path: "/rippleapi.account.RippleAccountAPI/GetAccountInfo";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<account_pb.RequestGetAccountInfo>;
requestDeserialize: grpc.deserialize<account_pb.RequestGetAccountInfo>;
responseSerialize: grpc.serialize<account_pb.ResponseGetAccountInfo>;
responseDeserialize: grpc.deserialize<account_pb.ResponseGetAccountInfo>;
}

export const RippleAccountAPIService: IRippleAccountAPIService;

export interface IRippleAccountAPIServer {
getAccountInfo: grpc.handleUnaryCall<account_pb.RequestGetAccountInfo, account_pb.ResponseGetAccountInfo>;
}

export interface IRippleAccountAPIClient {
getAccountInfo(request: account_pb.RequestGetAccountInfo, callback: (error: grpc.ServiceError | null, response: account_pb.ResponseGetAccountInfo) => void): grpc.ClientUnaryCall;
getAccountInfo(request: account_pb.RequestGetAccountInfo, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: account_pb.ResponseGetAccountInfo) => void): grpc.ClientUnaryCall;
getAccountInfo(request: account_pb.RequestGetAccountInfo, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: account_pb.ResponseGetAccountInfo) => void): grpc.ClientUnaryCall;
}

export class RippleAccountAPIClient extends grpc.Client implements IRippleAccountAPIClient {
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
public getAccountInfo(request: account_pb.RequestGetAccountInfo, callback: (error: grpc.ServiceError | null, response: account_pb.ResponseGetAccountInfo) => void): grpc.ClientUnaryCall;
public getAccountInfo(request: account_pb.RequestGetAccountInfo, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: account_pb.ResponseGetAccountInfo) => void): grpc.ClientUnaryCall;
public getAccountInfo(request: account_pb.RequestGetAccountInfo, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: account_pb.ResponseGetAccountInfo) => void): grpc.ClientUnaryCall;
}
46 changes: 46 additions & 0 deletions web/ripple-lib-server/src/pb/account_grpc_pb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// GENERATED CODE -- DO NOT EDIT!

'use strict';
var grpc = require('grpc');
var account_pb = require('./account_pb.js');

function serialize_rippleapi_account_RequestGetAccountInfo(arg) {
if (!(arg instanceof account_pb.RequestGetAccountInfo)) {
throw new Error('Expected argument of type rippleapi.account.RequestGetAccountInfo');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_rippleapi_account_RequestGetAccountInfo(buffer_arg) {
return account_pb.RequestGetAccountInfo.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_rippleapi_account_ResponseGetAccountInfo(arg) {
if (!(arg instanceof account_pb.ResponseGetAccountInfo)) {
throw new Error('Expected argument of type rippleapi.account.ResponseGetAccountInfo');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_rippleapi_account_ResponseGetAccountInfo(buffer_arg) {
return account_pb.ResponseGetAccountInfo.deserializeBinary(new Uint8Array(buffer_arg));
}


// RippleAccountAPI
var RippleAccountAPIService = exports.RippleAccountAPIService = {
// https://xrpl.org/rippleapi-reference.html#getaccountinfo
getAccountInfo: {
path: '/rippleapi.account.RippleAccountAPI/GetAccountInfo',
requestStream: false,
responseStream: false,
requestType: account_pb.RequestGetAccountInfo,
responseType: account_pb.ResponseGetAccountInfo,
requestSerialize: serialize_rippleapi_account_RequestGetAccountInfo,
requestDeserialize: deserialize_rippleapi_account_RequestGetAccountInfo,
responseSerialize: serialize_rippleapi_account_ResponseGetAccountInfo,
responseDeserialize: deserialize_rippleapi_account_ResponseGetAccountInfo,
},
};

exports.RippleAccountAPIClient = grpc.makeGenericClientConstructor(RippleAccountAPIService);
59 changes: 59 additions & 0 deletions web/ripple-lib-server/src/pb/account_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// package: rippleapi.account
// file: account.proto

/* tslint:disable */
/* eslint-disable */

import * as jspb from "google-protobuf";

export class RequestGetAccountInfo extends jspb.Message {
getAddress(): string;
setAddress(value: string): RequestGetAccountInfo;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): RequestGetAccountInfo.AsObject;
static toObject(includeInstance: boolean, msg: RequestGetAccountInfo): RequestGetAccountInfo.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: RequestGetAccountInfo, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): RequestGetAccountInfo;
static deserializeBinaryFromReader(message: RequestGetAccountInfo, reader: jspb.BinaryReader): RequestGetAccountInfo;
}

export namespace RequestGetAccountInfo {
export type AsObject = {
address: string,
}
}

export class ResponseGetAccountInfo extends jspb.Message {
getSequence(): number;
setSequence(value: number): ResponseGetAccountInfo;
getXrpbalance(): string;
setXrpbalance(value: string): ResponseGetAccountInfo;
getOwnercount(): number;
setOwnercount(value: number): ResponseGetAccountInfo;
getPreviousaffectingtransactionid(): string;
setPreviousaffectingtransactionid(value: string): ResponseGetAccountInfo;
getPreviousaffectingtransactionledgerversion(): number;
setPreviousaffectingtransactionledgerversion(value: number): ResponseGetAccountInfo;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ResponseGetAccountInfo.AsObject;
static toObject(includeInstance: boolean, msg: ResponseGetAccountInfo): ResponseGetAccountInfo.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ResponseGetAccountInfo, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ResponseGetAccountInfo;
static deserializeBinaryFromReader(message: ResponseGetAccountInfo, reader: jspb.BinaryReader): ResponseGetAccountInfo;
}

export namespace ResponseGetAccountInfo {
export type AsObject = {
sequence: number,
xrpbalance: string,
ownercount: number,
previousaffectingtransactionid: string,
previousaffectingtransactionledgerversion: number,
}
}
Loading

0 comments on commit 6043370

Please sign in to comment.