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 upstream master branch into Soroban. #636

Merged
merged 21 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
777e85c
SDK Modernization (#585)
Shaptic Apr 13, 2023
6cefb3e
Update generated XDR to latest version. (#587)
Shaptic Apr 20, 2023
89219ab
Update deps/workflows for v9.0.0-beta.0 release (#586)
Shaptic Apr 20, 2023
c29784d
Update changelog for `v9.0.0-beta.0`. (#589)
Shaptic Apr 20, 2023
c7bcd02
Add fully-qualified `Operation` type to XDR type definitions. (#591)
Shaptic Apr 21, 2023
fa467c6
Update completed sprint on issue/pr closed (#595)
Apr 27, 2023
3014ad4
Bump yaml from 2.2.1 to 2.2.2 (#594)
dependabot[bot] May 8, 2023
c50a0b5
Bump engine.io from 6.4.1 to 6.4.2 (#597)
dependabot[bot] May 8, 2023
3fed7d3
Upgrades dependencies to their latest versions (incl. `js-xdr@v2.0.0`…
Shaptic May 8, 2023
c4ff6ed
Fix asset code sorting with mixed cases (#606)
May 12, 2023
1c8ab8e
Bump all dependencies to their latest versions. (#608)
Shaptic May 15, 2023
13efc36
Adds Operation.isValidAmount jsdoc (#609)
Shaptic May 16, 2023
3297d8b
Bump socket.io-parser from 4.2.2 to 4.2.3 (#611)
dependabot[bot] May 24, 2023
e19a17a
Removes the dependency on `crc` by calculating checksum in strkey (#621)
silence48 Jun 12, 2023
c11e1a8
Prepare `v9.0.0-beta.3` for release. (#623)
Shaptic Jun 13, 2023
f10a747
Removes `lodash` dependency entirely (#624)
silence48 Jun 13, 2023
40644e3
Prepare `v9.0.0` for promotion and release. (#625)
Shaptic Jun 13, 2023
afaacb5
Fix jsdoc generation and always publish GHA. (#626)
Shaptic Jun 13, 2023
ab38bf4
Merge branch 'master' into upstream-merge
Shaptic Jun 29, 2023
ec470f4
Fixup bad merge: lodash is gone
Shaptic Jun 29, 2023
a992b0e
Remove browser test (it was doing nothing??)
Shaptic Jun 30, 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
2 changes: 2 additions & 0 deletions .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
path: jsdoc

- name: Generate JS docs
# because parsing errors still result in renderable docs
continue-on-error: true
run: yarn docs

- name: Publish JS docs
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 @@ -19,7 +19,7 @@ jobs:
registry-url: 'https://registry.npmjs.org'

- name: Install Depencencies
run: yarn
run: yarn install

- name: Test & Build
run: yarn preversion
Expand Down
39 changes: 21 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,35 @@ jobs:

strategy:
fail-fast: false
max-parallel: 2
max-parallel: 4
matrix:
node-version: [14, 16, 18]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: yarn install --network-concurrency 1

- name: Build All
run: yarn build:prod
# Workaround for some `yarn` nonsense, see:
# https://github.com/yarnpkg/yarn/issues/6312#issuecomment-429685210
- name: Install Dependencies
run: yarn install --network-concurrency 1

- name: Run Node Tests
run: yarn test:node
- name: Build All
run: yarn build:prod

- name: Run Browser Tests
run: yarn build:browser:prod && yarn test:browser
- name: Run Node Tests
run: yarn test:node

- name: Run Prettier Checks
run: yarn fmt && (git diff-index --quiet HEAD; git diff)
- name: Run Browser Tests
run: yarn test:browser

- name: Run Linter
run: yarn lint
- name: Run Prettier Checks
run: yarn fmt && (git diff-index --quiet HEAD; git diff)

- name: Run Linter
run: yarn lint
25 changes: 25 additions & 0 deletions .github/workflows/update-completed-sprint-on-issue-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Update CompletedSprint on Issue Closed

on:
issues:
types: [closed]
pull_request:
types: [closed]

jobs:
update-completed-sprint:
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_PROJECT_MANAGEMENT_APP_ID }}
private_key: ${{ secrets.GH_PROJECT_MANAGEMENT_APP_PEM }}
- name: Update CompletedSprint on Issue Closed
id: update_completedsprint_on_issue_closed
uses: stellar/actions/update-completed-sprint-on-issue-closed@main
with:
project_name: "Platform Scrum"
field_name: "CompletedSprint"
project_token: ${{ steps.generate_token.outputs.token }}
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,54 @@
## Unreleased


## [v9.0.0](https://github.com/stellar/js-stellar-base/compare/v8.2.2..v9.0.0)

This is a large update and the following changelog incorporates ALL changes across the `beta.N` versions of this upgrade.

This version is marked by a major version bump because of the significant upgrades to underlying dependencies. While there should be no noticeable API changes from a downstream perspective, there may be breaking changes in the way that this library is bundled.

The browser bundle size has decreased **significantly**:

* `stellar-base.min.js` is **340 KiB**, down from **1.2 MiB** previously.
* the new, unminified `stellar-base.js` is **895 KiB**.

### Breaking Changes

- The build system has been completely overhauled to support Webpack 5 ([#584](https://github.com/stellar/js-stellar-base/pull/584), [#585](https://github.com/stellar/js-stellar-base/pull/585)).

Though we have tried to maintain compatibility with older JavaScript implementations, this still means you may need to update your build pipeline to transpile to certain targets.

### Fixes

- Fixes a bug when sorting mixed-case assets for liquidity pools ([#606](https://github.com/stellar/js-stellar-base/pull/606)).
- Documentation is fixed and should generate correctly on https://stellar.github.io/js-stellar-base/ ([#609](https://github.com/stellar/js-stellar-base/pull/609)).

### Updates

- XDR has been updated to its latest version (both `curr` and `next` versions, [#587](https://github.com/stellar/js-stellar-base/pull/587)).
- Drop the `lodash` dependency entirely ([#624](https://github.com/stellar/js-stellar-base/issues/624)).
- Drop the `crc` dependency and inline it to lower bundle size ([#621](https://github.com/stellar/js-stellar-base/pull/621)).
- Upgrade all dependencies to their latest versions ([#608](https://github.com/stellar/js-stellar-base/pull/608)).


## [v9.0.0-beta.3](https://github.com/stellar/js-stellar-base/compare/v9.0.0-beta.1..v9.0.0-beta.2)

### Fix

- Fixes a bug when sorting mixed-case assets for liquidity pools ([#606](https://github.com/stellar/js-stellar-base/pull/606)).

### Update
- Upgrade all dependencies to their latest versions ([#608](https://github.com/stellar/js-stellar-base/pull/608)).
- Drop the `crc` dependency and inline it to lower bundle size ([#621](https://github.com/stellar/js-stellar-base/pull/621)).


## [v9.0.0-beta.2](https://github.com/stellar/js-stellar-base/compare/v9.0.0-beta.1..v9.0.0-beta.2)

### Update

- Upgrades the `js-xdr` dependency (major performance improvements, see [`js-xdr@v2.0.0`](https://github.com/stellar/js-xdr/releases/tag/v2.0.0)) and other dependencies to their latest versions ([#592](https://github.com/stellar/js-stellar-base/pull/592)).


## [v9.0.0-beta.1](https://github.com/stellar/js-stellar-base/compare/v9.0.0-beta.0..v9.0.0-beta.1)

### Fix
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "10.0.0-soroban.1",
"description": "Low-level support library for the Stellar network.",
"main": "./lib/index.js",
"browser": "./dist/stellar-base.min.js",
"types": "./types/index.d.ts",
"scripts": {
"build": "yarn build:node && yarn build:browser",
Expand All @@ -22,6 +23,9 @@
"clean": "rm -rf lib/ dist/ coverage/ .nyc_output/",
"_nyc": "nyc --nycrc-path ./config/.nycrc"
},
"browser": {
"sodium-native": false
},
"mocha": {
"require": [
"@babel/register",
Expand Down Expand Up @@ -52,9 +56,6 @@
"yarn lint"
]
},
"browser": {
"sodium-native": false
},
"repository": {
"type": "git",
"url": "https://github.com/stellar/js-stellar-base.git"
Expand Down Expand Up @@ -114,8 +115,8 @@
"terser-webpack-plugin": "^5.3.8",
"ts-node": "^10.9.1",
"typescript": "^5.0.3",
"webpack": "^5.82.0",
"webpack-cli": "^5.1.0"
"webpack": "^5.82.1",
"webpack-cli": "^5.1.1"
},
"dependencies": {
"base32.js": "^0.1.0",
Expand All @@ -124,7 +125,6 @@
"crc": "^4.3.2",
"crypto-browserify": "^3.12.0",
"js-xdr": "^3.0.0",
"lodash": "^4.17.21",
"sha.js": "^2.3.6",
"tweetnacl": "^1.0.3"
},
Expand Down
3 changes: 1 addition & 2 deletions src/account.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import isString from 'lodash/isString';
import BigNumber from 'bignumber.js';

import { StrKey } from './strkey';
Expand Down Expand Up @@ -29,7 +28,7 @@ export class Account {
if (!StrKey.isValidEd25519PublicKey(accountId)) {
throw new Error('accountId is invalid');
}
if (!isString(sequence)) {
if (!(typeof sequence === 'string')) {
throw new Error('sequence must be of type string');
}

Expand Down
20 changes: 11 additions & 9 deletions src/asset.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import clone from 'lodash/clone';
import padEnd from 'lodash/padEnd';
import trimEnd from 'lodash/trimEnd';
import { trimEnd } from './util/util';
import xdr from './xdr';
import { Keypair } from './keypair';
import { StrKey } from './strkey';
Expand Down Expand Up @@ -119,7 +117,7 @@ export class Asset {

// pad code with null bytes if necessary
const padLength = this.code.length <= 4 ? 4 : 12;
const paddedCode = padEnd(this.code, padLength, '\0');
const paddedCode = this.code.padEnd(padLength, '\0');

// eslint-disable-next-line new-cap
const assetType = new xdrType({
Expand All @@ -134,14 +132,20 @@ export class Asset {
* @returns {string} Asset code
*/
getCode() {
return clone(this.code);
if (this.code === undefined) {
return undefined;
}
return String(this.code);
}

/**
* @returns {string} Asset issuer
*/
getIssuer() {
return clone(this.issuer);
if (this.issuer === undefined) {
return undefined;
}
return String(this.issuer);
}

/**
Expand Down Expand Up @@ -257,9 +261,7 @@ export class Asset {
* -1 if `a < b`, 0 if `a == b`, and 1 if `a > b`
*
* @warning No type-checks are done on the parameters
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
*/
function asciiCompare(a, b) {
return a.localeCompare(b, 'en', { caseFirst: 'upper' });
return Buffer.compare(Buffer.from(a, 'ascii'), Buffer.from(b, 'ascii'));
}
6 changes: 2 additions & 4 deletions src/keypair.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint no-bitwise: ["error", {"allow": ["^"]}] */

import nacl from 'tweetnacl';
import isUndefined from 'lodash/isUndefined';
import isString from 'lodash/isString';

import { sign, verify, generate } from './signing';
import { StrKey } from './strkey';
Expand Down Expand Up @@ -139,8 +137,8 @@ export class Keypair {
* @return {xdr.MuxedAccount}
*/
xdrMuxedAccount(id) {
if (!isUndefined(id)) {
if (!isString(id)) {
if (typeof id !== 'undefined') {
if (typeof id !== 'string') {
throw new TypeError(`expected string for ID, got ${typeof id}`);
}

Expand Down
6 changes: 3 additions & 3 deletions src/liquidity_pool_asset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import clone from 'lodash/clone';
import xdr from './xdr';
import { Asset } from './asset';
import {
Expand Down Expand Up @@ -83,11 +82,12 @@ export class LiquidityPoolAsset {
* @returns {LiquidityPoolParameters} Liquidity pool parameters.
*/
getLiquidityPoolParameters() {
return clone({
return {
...this,
assetA: this.assetA,
assetB: this.assetB,
fee: this.fee
});
};
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/liquidity_pool_id.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import clone from 'lodash/clone';
import xdr from './xdr';

/**
Expand Down Expand Up @@ -53,7 +52,7 @@ export class LiquidityPoolId {
* @returns {string} Liquidity pool ID.
*/
getLiquidityPoolId() {
return clone(this.liquidityPoolId);
return String(this.liquidityPoolId);
}

/**
Expand Down
15 changes: 6 additions & 9 deletions src/memo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import isUndefined from 'lodash/isUndefined';
import isString from 'lodash/isString';
import clone from 'lodash/clone';
import { UnsignedHyper } from 'js-xdr';
import BigNumber from 'bignumber.js';
import xdr from './xdr';
Expand Down Expand Up @@ -52,7 +49,7 @@ export class Memo {
case MemoReturn:
Memo._validateHashValue(value);
// We want MemoHash and MemoReturn to have Buffer as a value
if (isString(value)) {
if (typeof value === 'string') {
this._value = Buffer.from(value, 'hex');
}
break;
Expand All @@ -65,7 +62,7 @@ export class Memo {
* Contains memo type: `MemoNone`, `MemoID`, `MemoText`, `MemoHash` or `MemoReturn`
*/
get type() {
return clone(this._type);
return this._type;
}

set type(type) {
Expand All @@ -85,7 +82,7 @@ export class Memo {
return null;
case MemoID:
case MemoText:
return clone(this._value);
return this._value;
case MemoHash:
case MemoReturn:
return Buffer.from(this._value);
Expand All @@ -101,7 +98,7 @@ export class Memo {
static _validateIdValue(value) {
const error = new Error(`Expects a int64 as a string. Got ${value}`);

if (!isString(value)) {
if (typeof value !== 'string') {
throw error;
}

Expand Down Expand Up @@ -134,12 +131,12 @@ export class Memo {
`Expects a 32 byte hash value or hex encoded string. Got ${value}`
);

if (value === null || isUndefined(value)) {
if (value === null || typeof value === 'undefined') {
throw error;
}

let valueBuffer;
if (isString(value)) {
if (typeof value === 'string') {
if (!/^[0-9A-Fa-f]{64}$/g.test(value)) {
throw error;
}
Expand Down
4 changes: 1 addition & 3 deletions src/muxed_account.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import isString from 'lodash/isString';

import xdr from './xdr';
import { Account } from './account';
import { StrKey } from './strkey';
Expand Down Expand Up @@ -99,7 +97,7 @@ export class MuxedAccount {
}

setId(id) {
if (!isString(id)) {
if (typeof id !== 'string') {
throw new Error('id should be a string representing a number (uint64)');
}

Expand Down
Loading