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

Prepare v0.11.0 for release #126

Merged
merged 15 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = {
parser: "@babel/eslint-parser",
parser: '@babel/eslint-parser',
env: {
node: true,
node: true
},
extends: ["eslint:recommended", "plugin:node/recommended"],
extends: ['eslint:recommended', 'plugin:node/recommended'],
rules: {
"node/no-unpublished-require": 0,
},
'node/no-unpublished-require': 0
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
ref: soroban
path: js-stellar-base

- name: Install Node (14.x)
- name: Install Node 16
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: 16

- name: Install Dependencies
run: yarn install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: 16
registry-url: 'https://registry.npmjs.org'

- name: Install Depencencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
node-version: [14, 16, 18]
node-version: [16, 18, 20]

steps:
- name: Checkout
Expand Down
21 changes: 16 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ A breaking change should be clearly marked in this log.
## Unreleased


## v0.11.0

### Fixed
* The `SimulateTransactionResponse`'s error field now has the correct type (that is, `string`: [#123](https://github.com/stellar/js-soroban-client/pull/123)).
* Many irrelevant or unused dependencies have been eliminated (such as `eventsource`, `lodash`, and others), lowering overall bundle size ([#126](https://github.com/stellar/js-soroban-client/pull/126)).

### Added
* A new `ContractSpec` class to facilitate building native JavaScript structures from custom contract types. Given a specification for the data structure (i.e. `xdr.ScSpecEntry[]`), it will interpret the values via the specified type ([#115](https://github.com/stellar/js-soroban-client/pull/115)).

### Breaking Changes
* The minimum supported NodeJS version is now Node 16.
* `Server.prepareTransaction` now returns a `TransactionBuilder` instance rather than an immutable `Transaction`, in order to facilitate modifying your transaction after assembling it alongside the simulation response ([https://github.com/stellar/js-soroban-client/pull/127](#127)).
* `Server.prepareTransaction` now returns a `TransactionBuilder` instance rather than an immutable `Transaction`, in order to facilitate modifying your transaction after assembling it alongside the simulation response ([#127](https://github.com/stellar/js-soroban-client/pull/127)).
- The intent is to avoid cloning the transaction again (via `TransactionBuilder.cloneFrom`) if you need to modify parameters such as the storage access footprint.
- To migrate your code, just call `.build()` on the return value.
* The RPC response schemas for simulation (see `Server.simulateTransaction()`) have been upgraded to parse the base64-encoded XDR automatically. The full interface changes are in the pull request ([https://github.com/stellar/js-soroban-client/pull/127](#127)), but succinctly:
* The RPC response schemas for simulation (see `Server.simulateTransaction()`) have been upgraded to parse the base64-encoded XDR automatically. The full interface changes are in the pull request ([#127](https://github.com/stellar/js-soroban-client/pull/127)), but succinctly:
- `SimulateTransactionResponse` -> `RawSimulateTransactionResponse`
- `SimulateHostFunctionResult` -> `RawSimulateHostFunctionResult`
- Now, `SimulateTransactionResponse` and `SimulateHostFunctionResult` include the full, decoded XDR structures instead of raw, base64-encoded strings for the relevant fields (e.g. `SimulateTransactionResponse.transactionData` is now an instance of `SorobanDataBuilder`, `events` is now an `xdr.DiagnosticEvent[]` [try out `humanizeEvents` for a friendlier representation of this field]).
- The `SimulateTransactionResponse.results[]` field has been moved to `SimulateTransactionResponse.result?`, since there will always be exactly zero or one result.
* The RPC response schemas for retrieving transaction details (`Server.getTransaction()`) have been upgraded to parse the base64-encoded XDR automatically. The full interface changes are in the pull request ([https://github.com/stellar/js-soroban-client/pull/129](#129)), but succinctly:
* The `GetTransactionStatus` is now an `enum` with actual values rather than a `type` ([#129](https://github.com/stellar/js-soroban-client/pull/129)).
* The RPC response schemas for retrieving transaction details (`Server.getTransaction()`) have been upgraded to parse the base64-encoded XDR automatically. The full interface changes are in the pull request ([#129](https://github.com/stellar/js-soroban-client/pull/129)), but succinctly:
- `GetTransactionResponse` -> `RawGetTransactionResponse`
- `GetTransactionResponse` is now one of `GetSuccessfulTransactionResponse | GetFailedTransactionResponse | GetMissingTransactionResponse`, which gives proper typing to the interface depending on the response's `status` field.
- All of the `*Xdr` properties are now full, decoded XDR structures.
- There is a new `returnValue` field which is a decoded `xdr.ScVal`, present iff the transaction was a successful Soroban function invocation.

Expand All @@ -29,14 +40,14 @@ Not all schemas have been broken in this manner in order to facilitate user feed
## v0.10.1

### Fixed
* The `stellar-base` dependency has been upgraded to fix a TypeScript bug ([#665](https://github.com/stellar/js-stellar-base/pull/665)).
* The `stellar-base` dependency has been upgraded to fix a TypeScript bug ([js-stellar-base#665](https://github.com/stellar/js-stellar-base/pull/665)).
* Decreased bundle size by refactoring `assembleTransaction` to use new abstractions from `stellar-base` ([#120](https://github.com/stellar/js-soroban-client/pull/120)).


## v0.10.0

### Breaking Changes
* We have dropped all support for the deprecated hex-encoded contract ID format ([#117](https://github.com/stellar/js-soroban-client/pull/117), [#658](https://github.com/stellar/js-stellar-base/pull/658)).
* We have dropped all support for the deprecated hex-encoded contract ID format ([#117](https://github.com/stellar/js-soroban-client/pull/117), [js-stellar-base#658](https://github.com/stellar/js-stellar-base/pull/658)).

You should use the well-supported `C...` strkey format, instead. To migrate, you can do something like

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ cd js-soroban-client
yarn install
```

3. Install Node 14
3. Install Node 16

Because we support the latest maintenance version of Node, please install and develop on Node 14 so you don't get surprised when your code works locally but breaks in CI.
Because we support the latest maintenance version of Node, please install and develop on Node 16 so you don't get surprised when your code works locally but breaks in CI.

Here's how to install `nvm` if you haven't: https://github.com/creationix/nvm

```shell
nvm install

# if you've never installed 14 before you'll want to re-install yarn
# if you've never installed 16 before you'll want to re-install yarn
yarn install -g yarn
```

Expand Down
5 changes: 3 additions & 2 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"@babel/typescript"
],
"targets": {
"browsers": [ "> 2%" ] // target modern browsers and ES6
"browsers": [ "> 2%" ], // target modern browsers and ES6
"node": 16
},
"env": {
"development": {
Expand All @@ -14,7 +15,7 @@
"production": {
"comments": false,
"targets": {
"node": 14,
// smaller feature set for prod bundle
"browsers": [
"> 2%",
"ie 11",
Expand Down
26 changes: 13 additions & 13 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
const webpackConfig = require("./webpack.config.browser.js");
const webpackConfig = require('./webpack.config.browser.js');

delete webpackConfig.output;
delete webpackConfig.entry; // karma fills these in
webpackConfig.plugins.shift(); // drop eslinter plugin

module.exports = function (config) {
config.set({
frameworks: ["mocha", "sinon-chai"],
browsers: ["FirefoxHeadless", "ChromeHeadless"],
frameworks: ['mocha', 'sinon-chai'],
browsers: ['FirefoxHeadless', 'ChromeHeadless'],

files: [
"./dist/soroban-client.js", // webpack should build this first
"./test/test-browser.js",
"./test/unit/**/*.js",
'./dist/soroban-client.js', // webpack should build this first
'./test/test-browser.js',
'./test/unit/**/*.js'
],

preprocessors: {
"./test/**/*.js": ["webpack"],
'./test/**/*.js': ['webpack']
},

webpack: webpackConfig,
webpackMiddleware: {
noInfo: true,
noInfo: true
},

colors: true,
singleRun: true,

reporters: ["dots", "coverage"],
reporters: ['dots', 'coverage'],
coverageReporter: {
type: "text-summary",
type: 'text-summary',
instrumenterOptions: {
istanbul: { noCompact: true },
},
},
istanbul: { noCompact: true }
}
}
});
};
41 changes: 15 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"_build": "yarn build:node && yarn build:browser",
"_babel": "babel --extensions '.ts' --out-dir lib/ src/",
"_nyc": "nyc --nycrc-path .nycrc",
"_prettier": "prettier --ignore-path .prettierignore --write './**/*.js'"
"_prettier": "prettier --config prettier.config.js --ignore-path .prettierignore --write './**/*.js'"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -77,40 +77,36 @@
]
},
"devDependencies": {
"@babel/cli": "^7.22.9",
"@babel/core": "^7.22.9",
"@babel/eslint-parser": "^7.22.9",
"@babel/eslint-plugin": "^7.22.5",
"@babel/preset-env": "^7.22.9",
"@babel/cli": "^7.22.10",
"@babel/core": "^7.22.10",
"@babel/eslint-parser": "^7.22.10",
"@babel/eslint-plugin": "^7.22.10",
"@babel/preset-env": "^7.22.10",
"@babel/preset-typescript": "^7.22.5",
"@babel/register": "^7.22.5",
"@definitelytyped/dtslint": "^0.0.163",
"@definitelytyped/dtslint": "^0.0.166",
"@istanbuljs/nyc-config-babel": "3.0.0",
"@stellar/tsconfig": "^1.0.2",
"@types/chai": "^4.3.5",
"@types/detect-node": "^2.0.0",
"@types/eventsource": "^1.1.2",
"@types/lodash": "^4.14.197",
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.2",
"@types/randombytes": "^2.0.0",
"@types/node": "^20.5.1",
"@types/sinon": "^10.0.16",
"@types/urijs": "^1.19.6",
"@typescript-eslint/parser": "^5.60.1",
"@typescript-eslint/parser": "^6.4.1",
"axios-mock-adapter": "^1.21.5",
"babel-loader": "^9.1.2",
"babel-plugin-istanbul": "^6.1.1",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"chai-http": "^4.4.0",
"cross-env": "^7.0.3",
"eslint": "^8.45.0",
"eslint": "^8.47.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 @@ -123,13 +119,12 @@
"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",
"minami": "^1.1.1",
"mocha": "^10.2.0",
"node-polyfill-webpack-plugin": "^2.0.1",
"nyc": "^15.1.0",
"prettier": "^2.8.8",
"randombytes": "^2.1.0",
"prettier": "^3.0.2",
"sinon": "^15.2.0",
"sinon-chai": "^3.7.0",
"taffydb": "^2.7.3",
Expand All @@ -144,13 +139,7 @@
"axios": "^1.4.0",
"bignumber.js": "^9.1.1",
"buffer": "^6.0.3",
"detect-node": "^2.0.4",
"es6-promise": "^4.2.4",
"eventsource": "^2.0.2",
"lodash": "^4.17.21",
"randombytes": "^2.1.0",
"stellar-base": "10.0.0-soroban.7",
"toml": "^3.0.0",
"urijs": "^1.19.1"
}
}
13 changes: 13 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
arrowParens: 'always',
bracketSpacing: true,
bracketSameLine: false,
printWidth: 80,
proseWrap: 'always',
semi: true,
singleQuote: true,
tabWidth: 2,
parser: 'babel',
trailingComma: 'none',
useTabs: false
};
56 changes: 28 additions & 28 deletions src/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
module.exports = {
env: {
es6: true,
es6: true
},
parser: "@babel/eslint-parser",
extends: ["airbnb-base", "prettier"],
plugins: ["prettier", "prefer-import"],
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,
'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,
'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": [
'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,
},
requireReturnDescription: false
}
],
"prefer-const": 1,
"object-shorthand": 1,
"require-await": 1,
'prefer-const': 1,
'object-shorthand': 1,
'require-await': 1,

// ERROR
"no-unused-expressions": [2, { allowTaggedTemplates: true }],
},
'no-unused-expressions': [2, { allowTaggedTemplates: true }]
}
};
4 changes: 0 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// tslint:disable-next-line: no-reference
/// <reference path="../types/dom-monkeypatch.d.ts" />

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

// Expose all types
Expand Down
10 changes: 3 additions & 7 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/* tslint:disable:variable-name no-namespace */

import isEmpty from "lodash/isEmpty";
import merge from "lodash/merge";
import {
Account,
Address,
Expand Down Expand Up @@ -69,11 +66,10 @@ export class Server {
if (opts.appVersion) {
customHeaders["X-App-Version"] = opts.appVersion;
}
if (!isEmpty(customHeaders)) {
if (Object.keys(customHeaders).length === 0) {
AxiosClient.interceptors.request.use((config: any) => {
// merge the custom headers with an existing headers
config.headers = merge(customHeaders, config.headers);

// merge the custom headers into any existing headers
config.headers = Object.assign(config.headers, customHeaders);
return config;
});
}
Expand Down
Loading