Skip to content
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

Merge the Soroban RPC client into this library #860

Merged
merged 30 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
41bff1f
Move Horizon SDK into subfolders
Shaptic Jul 18, 2023
689f716
Move types also
Shaptic Jul 18, 2023
13a2f7d
WIP merge
Shaptic Aug 4, 2023
ffeed24
Upgrade all dependencies to their latest versions
Shaptic Sep 6, 2023
59b841c
Drop redundancies, tests pass!
Shaptic Sep 7, 2023
820c9ba
Move over latest soroban-client source code
Shaptic Sep 14, 2023
5b2c403
Trying to update Soroban tests to pass
Shaptic Sep 14, 2023
455fab8
More moving, formatting pass
Shaptic Sep 15, 2023
4a6cdc6
Merge branch 'master' into soroban-merge
Shaptic Sep 15, 2023
9cb919d
Holy crap, node tests pass???
Shaptic Sep 15, 2023
aa9f9d6
Fixup browser tests, too, LFGGGG
Shaptic Sep 15, 2023
90df6de
Prettier
Shaptic Sep 15, 2023
df2526d
Prettier: smaller diff
Shaptic Sep 15, 2023
5d8019a
Prettier fixup for easier merge?
Shaptic Sep 22, 2023
4181b0a
Merge branch 'master' into soroban-merge
Shaptic Sep 22, 2023
4fc2934
Drop Node 20 tests
Shaptic Sep 22, 2023
21bd09f
Minimize formatting changes
Shaptic Sep 22, 2023
fdfe795
:cmonBruh:
Shaptic Sep 22, 2023
7b34b1d
Move namespaces around to isolate srpc and hz
Shaptic Oct 11, 2023
bc5ff0f
Final testing fixups
Shaptic Oct 12, 2023
4412f7d
Merge branch 'master' into soroban-merge
Shaptic Oct 12, 2023
b4ffa9c
Merge fixup
Shaptic Oct 12, 2023
0b08af8
Upgrade soroban library + tests from v1.0.0-beta.3
Shaptic Oct 13, 2023
1ab6696
Fixup and revert unneeded changes
Shaptic Oct 13, 2023
4947082
Moving/Renaming Sep10 stuff around a bit
Shaptic Oct 13, 2023
3212204
Move friendbot API into a separate module
Shaptic Oct 16, 2023
9efd446
Reset changelog find/replace and add entry
Shaptic Oct 23, 2023
879e3a4
Buncha SEP-related module/file renames
Shaptic Oct 23, 2023
e455ac3
Finish moving and renaming, add friendbot export
Shaptic Oct 23, 2023
63e62ed
Merge branch 'master' into soroban-merge
Shaptic Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 36 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stellar-sdk",
"version": "11.0.0-beta.1",
"version": "11.0.0-beta.2",
"description": "A library for working with the Stellar Horizon server.",
"keywords": [
"stellar"
Expand All @@ -17,7 +17,7 @@
"author": "Stellar Development Foundation <[email protected]>",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"browser": "./dist/stellar-sdk.js",
"browser": "./dist/stellar-sdk.min.js",
"files": [
"/types",
"/lib",
Expand All @@ -28,18 +28,19 @@
"build:prod": "cross-env NODE_ENV=production yarn _build",
"build:node": "yarn _babel && yarn build:ts",
"build:ts": "tsc -p ./config/tsconfig.json",
"build:test": "tsc -p ./test/tsconfig.json",
"build:browser": "webpack -c config/webpack.config.browser.js",
"build:docs": "cross-env NODE_ENV=docs yarn _babel",
"clean": "rm -rf lib/ dist/ coverage/ .nyc_output/ jsdoc/",
"docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json --verbose",
"test": "yarn test:node && yarn test:integration && yarn test:browser",
"test": "yarn build:test && yarn test:node && yarn test:integration && yarn test:browser",
"test:node": "yarn _nyc mocha --recursive 'test/unit/**/*.js'",
"test:integration": "yarn _nyc mocha --recursive 'test/integration/**/*.js'",
"test:browser": "karma start config/karma.conf.js",
"fmt": "yarn eslint -c .eslintrc.js src/ --fix && yarn _prettier",
"preversion": "yarn clean && yarn fmt && yarn build:prod && yarn test",
"prepare": "yarn build:prod",
"_build": "yarn build:node && yarn build:browser",
"_build": "yarn build:node && yarn build:test && yarn build:browser",
"_babel": "babel --extensions '.ts' --out-dir lib/ src/",
"_nyc": "nyc --nycrc-path config/.nycrc",
"_prettier": "prettier --ignore-path config/.prettierignore --write './**/*.js'"
Expand All @@ -51,8 +52,7 @@
},
"lint-staged": {
"**/*.{js,json,ts}": [
"yarn fmt",
"yarn lint"
"yarn fmt"
]
},
"mocha": {
Expand All @@ -66,7 +66,7 @@
],
"sort": true,
"recursive": true,
"timeout": 60000
"timeout": 30000
},
"nyc": {
"instrument": false,
Expand All @@ -76,38 +76,41 @@
]
},
"devDependencies": {
"@babel/cli": "^7.22.6",
"@babel/core": "^7.22.8",
"@babel/eslint-parser": "^7.22.7",
"@babel/eslint-plugin": "^7.19.1",
"@babel/preset-env": "^7.22.7",
"@babel/preset-typescript": "^7.21.4",
"@babel/register": "^7.21.0",
"@definitelytyped/dtslint": "^0.0.163",
"@babel/cli": "^7.22.15",
"@babel/core": "^7.22.19",
"@babel/eslint-parser": "^7.22.15",
"@babel/eslint-plugin": "^7.22.10",
"@babel/preset-env": "^7.22.15",
"@babel/preset-typescript": "^7.22.15",
"@babel/register": "^7.22.15",
"@definitelytyped/dtslint": "^0.0.178",
"@istanbuljs/nyc-config-babel": "3.0.0",
"@stellar/tsconfig": "^1.0.2",
"@types/chai": "^4.3.6",
"@types/detect-node": "^2.0.0",
"@types/eventsource": "^1.1.2",
"@types/lodash": "^4.14.192",
"@types/node": "^20.4.1",
"@types/lodash": "^4.14.198",
"@types/mocha": "^10.0.1",
"@types/node": "^20.6.0",
"@types/randombytes": "^2.0.0",
"@types/urijs": "^1.19.6",
"@typescript-eslint/parser": "^5.59.7",
"axios-mock-adapter": "^1.21.5",
"@types/sinon": "^10.0.16",
"@types/urijs": "^1.19.20",
"@typescript-eslint/parser": "^6.7.0",
"axios-mock-adapter": "^1.22.0",
"babel-loader": "^9.1.3",
"babel-plugin-istanbul": "^6.1.1",
"buffer": "^6.0.3",
"chai": "^4.3.7",
"chai": "^4.3.8",
"chai-as-promised": "^7.1.1",
"chai-http": "^4.3.0",
"cross-env": "^7.0.3",
"eslint": "^8.44.0",
"eslint": "^8.49.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.25.2",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-import": "^0.0.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-webpack-plugin": "^4.0.1",
"ghooks": "^2.0.4",
"husky": "^8.0.3",
Expand All @@ -120,30 +123,30 @@
"karma-mocha": "^2.0.0",
"karma-sinon-chai": "^2.0.2",
"karma-webpack": "^5.0.0",
"lint-staged": "^13.2.3",
"lint-staged": "^14.0.1",
"lodash": "^4.17.21",
"minami": "^1.1.1",
"mocha": "^10.2.0",
"node-polyfill-webpack-plugin": "^2.0.1",
"nyc": "^15.1.0",
"prettier": "^2.8.7",
"prettier": "^3.0.3",
"randombytes": "^2.1.0",
"sinon": "^15.2.0",
"sinon": "^16.0.0",
"sinon-chai": "^3.7.0",
"taffydb": "^2.7.3",
"terser-webpack-plugin": "^5.3.9",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"utility-types": "^3.7.0",
"webpack": "^5.88.1",
"webpack": "^5.88.2",
"webpack-cli": "^5.0.1"
},
"dependencies": {
"axios": "^1.4.0",
"bignumber.js": "^9.1.1",
"axios": "^1.5.0",
"bignumber.js": "^9.1.2",
"eventsource": "^2.0.2",
"randombytes": "^2.1.0",
"stellar-base": "^9.0.0",
"stellar-base": "10.0.0-beta.1",
"toml": "^3.0.0",
"urijs": "^1.19.1"
}
Expand Down
2 changes: 1 addition & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Horizon } from "./horizon_api";
import { Horizon } from "./horizon/horizon_api";

// For ES5 compatibility (https://stackoverflow.com/a/55066280).
/* tslint:disable:variable-name max-classes-per-file */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import axios from "axios";
import { StrKey } from "stellar-base";
import URI from "urijs";

import { Config } from "./config";
import { BadResponseError } from "./errors";
import { Config } from "../config";
import { BadResponseError } from "../errors";
import { StellarTomlResolver } from "./stellar_toml_resolver";

// FEDERATION_RESPONSE_MAX_SIZE is the maximum size of response from a federation server
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from "axios";
import { Networks } from "stellar-base";
import toml from "toml";
import { Config } from "./config";
import { Networks } from "stellar-base";

import { Config } from "../config";

// STELLAR_TOML_MAX_SIZE is the maximum size of stellar.toml file
export const STELLAR_TOML_MAX_SIZE = 100 * 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ export class AccountCallBuilder extends CallBuilder<
this.url.setQuery("liquidity_pool", id);
return this;
}
}
}
File renamed without changes.
File renamed without changes.
10 changes: 4 additions & 6 deletions src/call_builder.ts → src/horizon/call_builder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import URI from "urijs";
import URITemplate from "urijs/src/URITemplate";

import { BadRequestError, NetworkError, NotFoundError } from "./errors";
import { BadRequestError, NetworkError, NotFoundError } from "../errors";

import { Horizon } from "./horizon_api";
import HorizonAxiosClient from "./horizon_axios_client";
import { HorizonAxiosClient, version } from "./horizon_axios_client";
import { ServerApi } from "./server_api";

/* tslint:disable-next-line:no-var-requires */
const version = require("../package.json").version;

// Resources which can be included in the Horizon response via the `join`
// query-param.
const JOINABLE = ["transaction"];
Expand Down Expand Up @@ -404,4 +402,4 @@ export class CallBuilder<
return Promise.reject(new Error(error.message));
}
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios, { AxiosResponse } from "axios";
import URI from "urijs";

/* tslint:disable-next-line:no-var-requires */
const version = require("../package.json").version;
export const version = require("../../package.json").version;

export interface ServerTime {
serverTime: number;
Expand All @@ -23,7 +23,7 @@ export interface ServerTime {
*/
export const SERVER_TIME_MAP: Record<string, ServerTime> = {};

const HorizonAxiosClient = axios.create({
export const HorizonAxiosClient = axios.create({
headers: {
"X-Client-Name": "js-stellar-sdk",
"X-Client-Version": version,
Expand Down
9 changes: 9 additions & 0 deletions src/horizon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { AccountCallBuilder as ACB } from './account_call_builder'
import { AccountResponse as AR } from './account_response'

export namespace Horizon {
export type AccountCallBuilder = ACB;
export type AccountResponse = AR;
}

export default Horizon;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/server.ts → src/horizon/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {
import URI from "urijs";

import { CallBuilder } from "./call_builder";
import { Config } from "./config";
import { Config } from "../config";
import {
AccountRequiresMemoError,
BadResponseError,
NotFoundError,
} from "./errors";
} from "../errors";

import { AccountCallBuilder } from "./account_call_builder";
import { AccountResponse } from "./account_response";
Expand Down
2 changes: 1 addition & 1 deletion src/server_api.ts → src/horizon/server_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,4 @@ export namespace ServerApi {
destination_asset_code: string;
destination_asset_issuer: string;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* tslint:disable: variable-name */
import { Asset } from "stellar-base";
import { CallBuilder } from "./call_builder";
import { BadRequestError } from "./errors";
import { BadRequestError } from "../errors";
import { Horizon } from "./horizon_api";
import { ServerApi } from "./server_api";

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 21 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
// tslint:disable-next-line: no-reference
/// <reference path="../types/dom-monkeypatch.d.ts" />

/* tslint:disable:no-var-requires */
const version = require("../package.json").version;

// Expose all types
export * from "./horizon_api";
export * from "./server_api";
export * from './horizon';
export * from './soroban/soroban_rpc';

// stellar-sdk classes to expose
export * from "./account_response";
export * from "./errors";
export { Config } from "./config";
export { Server } from "./server";
export * from './errors';
export { Config } from './config';
export {
FederationServer,
FEDERATION_RESPONSE_MAX_SIZE
} from "./federation_server";
} from './federation/federation_server';
export {
StellarTomlResolver,
STELLAR_TOML_MAX_SIZE
} from "./stellar_toml_resolver";
} from './federation/stellar_toml_resolver';

export {
Shaptic marked this conversation as resolved.
Show resolved Hide resolved
default as HorizonAxiosClient,
SERVER_TIME_MAP,
getCurrentServerTime
} from "./horizon_axios_client";
export * from "./utils";
getCurrentServerTime,
version
} from './horizon/horizon_axios_client';

// expose classes and functions from stellar-base
export * from "stellar-base";
export { Server as HorizonServer } from './horizon/server';

Shaptic marked this conversation as resolved.
Show resolved Hide resolved
export * from './utils';

export { version };
// soroban-client classes to expose
export { SorobanServer, AxiosClient as SorobanAxiosClient } from './soroban';

export * from './soroban/transaction';
export { ContractSpec } from './soroban/contract_spec';

// expose classes and functions from stellar-base
export * from 'stellar-base';

export default module.exports;
42 changes: 42 additions & 0 deletions src/soroban/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
env: {
es6: true,
},
parser: "@babel/eslint-parser",
extends: ["airbnb-base", "prettier"],
plugins: ["prettier", "prefer-import"],
rules: {
// OFF
"import/prefer-default-export": 0,
"node/no-unsupported-features/es-syntax": 0,
"node/no-unsupported-features/es-builtins": 0,
camelcase: 0,
"class-methods-use-this": 0,
"linebreak-style": 0,
"new-cap": 0,
"no-param-reassign": 0,
"no-underscore-dangle": 0,
"no-use-before-define": 0,
"prefer-destructuring": 0,
"lines-between-class-members": 0,

// WARN
"prefer-import/prefer-import-over-require": [1],
"no-console": ["warn", { allow: ["assert"] }],
"no-debugger": 1,
"no-unused-vars": 1,
"arrow-body-style": 1,
"valid-jsdoc": [
1,
{
requireReturnDescription: false,
},
],
"prefer-const": 1,
"object-shorthand": 1,
"require-await": 1,

// ERROR
"no-unused-expressions": [2, { allowTaggedTemplates: true }],
},
};
12 changes: 12 additions & 0 deletions src/soroban/axios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import axios from "axios";

/* tslint:disable-next-line:no-var-requires */
export const version = require("../../package.json").version;
export const AxiosClient = axios.create({
headers: {
"X-Client-Name": "js-soroban-client",
"X-Client-Version": version,
},
});

export default AxiosClient;
Loading
Loading