Skip to content

Commit 4182cca

Browse files
ShapticPaul Bellamyovercatdependabot[bot]orbitlens
authored
Merge: Adds Protocol 20/Soroban support to the XDR and API. (#538)
* Correctly set `minAccountSequence` in `TransactionBuilder` for large values (#539) * Add support of CAP40 ed25519SignedPayload signer for SetOptionOp (#542) * Add TypeScript interfaces for Ed25519SignedPayload signers * Coalesce all xLM, Xlm, etc. => 'XLM' native asset code (#546) * make sure sodium is not an empty object in service workers (#567) * Add futurenet passphrase for soroban. (#550) * Include standalone network passphrase (#555) * Soroban auth next updates (#570) * Add strkey parsing for contracts, and Address helper for building ScAddresses (#572) * Update xdr to include HashIdPreimageContractAuth.nonce (#577) * Add Address.toBuffer method (#578) * Soroban value overhaul (#582) * Update generated XDR to latest version. (#587) * Update XDR and contract invocations to conform to the latest version (Preview 9). (#601) * added soroban transaction data as tx builder param (#604) * Add Contract support for strkey-style contract IDs (#612) * Add Contract.address() method (#614) * Add wrappers to easily deal with the myriad of `ScVal` integer types. (#620) * Upgrade `js-xdr` to v3.0.0 to support `bigint` encoding. * Add wrappers to easily convert between `ScVal` and native types. (#630) * Update XDR to support Preview 10 (#633) * Fix TypeScript definition for `invokeHostFunction` options (#635) * Add fully-qualified `Operation` type to XDR type definitions. (#591) * Adds Operation.isValidAmount jsdoc (#609) * Removes the dependency on `crc` by calculating checksum in strkey (#621) * Improve type flexibility when building `ScVal`s from native types (#638) * Fix Preview 10 contract invoke & release `v10.0.0-soroban.3` (#642) * Add GitHub Action that compares before-and-after bundle sizes. (#644) * Make opinionated judgements about string/symbol decoding (#645) * Make Node 16 the minimum version. (#651) * Add standalone/futurenet passphrases to jsdoc (#654) * Clean up unnecessary dependency entries (#652) * Add `SorobanDataBuilder` builder pattern to prepare transactions easier (#660) * Adds a way to create a `TransactionBuilder` from an existing transaction. (#656) * Add basic contract event parsing into a human-readable structure (#659) * Drop support for deprecated hex contract IDs (#658) * Add helpers method to build authorization entries. (#663) * Fix TypeScript definition for new static `TransactionBuilder` constructor (#665) * Add ability to clear out operations from the transaction builder (#670) * Add an existing method to XdrLargeInt, jsdoc/types fixup (#668) * Expand contract footprint with contract code ledger key. (#662) * Decode base64-encoded strings in new SorobanDataBuilder (#673) * Add ability to modify and retrieve the resource footprint (#680) * Fixes error messages for required amount parameters (#679) * Add `Asset.contractId()` helper to predict contract IDs (#684) * Upgrade dependencies to their latest minor/patch version (#685) * Improves `SorobanDataBuilder` construction and adds a getter (#686) * Add JSON-ification of Soroban invocation trees. (#669) * Add utilities for formatting token amounts (`formatTokenAmount` & `parseTokenAmount`) (#667) * Merges the final Protocol 20 XDR (i.e. for testnet) into `soroban` (#688) * Add support to convert strings to large integer and address `ScVal`s (#690) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Paul Bellamy <paul@stellar.org> Co-authored-by: George <Shaptic@users.noreply.github.com> Co-authored-by: Jun Luo <4catcode@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: OrbitLens <33724849+orbitlens@users.noreply.github.com> Co-authored-by: Piyal Basu <pbasu235@gmail.com> Co-authored-by: George Kudrayvtsev <george@stellar.org> Co-authored-by: shawn <sreuland@users.noreply.github.com> Co-authored-by: Silence <35656692+silence48@users.noreply.github.com> Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Co-authored-by: jeesun 지선 <jeesunikim@users.noreply.github.com>
2 parents 91094a1 + 1240976 commit 4182cca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+40270
-26957
lines changed

.github/workflows/bundle_size.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Bundle Size
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Install Node.js 16
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version: 16
16+
17+
# Workaround for some `yarn` nonsense, see:
18+
# https://github.com/yarnpkg/yarn/issues/6312#issuecomment-429685210
19+
- name: Install Dependencies
20+
run: yarn install --network-concurrency 1
21+
22+
- name: Build All
23+
run: yarn build:prod
24+
25+
- name: Report Bundle Size
26+
uses: preactjs/compressed-size-action@v2
27+
with:
28+
repo-token: ${{ secrets.GITHUB_TOKEN }}
29+
pattern: "dist/*.js"
30+
compression: "none"

.github/workflows/gh_pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
with:
1313
fetch-depth: 0
1414

15-
- name: Install Node (14.x)
15+
- name: Install Node (16.x)
1616
uses: actions/setup-node@v3
1717
with:
18-
node-version: '14.x'
18+
node-version: 16
1919

2020
- name: Install Dependencies
2121
run: yarn install

.github/workflows/npm_publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Install Node
1414
uses: actions/setup-node@v3
1515
with:
16-
node-version: '14.x'
16+
node-version: 16
1717
registry-url: 'https://registry.npmjs.org'
1818

1919
- name: Install Depencencies
@@ -22,7 +22,7 @@ jobs:
2222
- name: Test & Build
2323
run: yarn preversion
2424

25-
- name: Publish npm package
26-
run: yarn publish
25+
- name: Publish release npm package
26+
run: yarn publish --tag beta
2727
env:
2828
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
max-parallel: 4
1515
matrix:
16-
node-version: [14, 16, 18]
16+
node-version: [16, 18, 20]
1717

1818
steps:
1919
- name: Checkout
@@ -29,9 +29,6 @@ jobs:
2929
- name: Install Dependencies
3030
run: yarn install --network-concurrency 1
3131

32-
- name: Run Linter
33-
run: yarn lint
34-
3532
- name: Build All
3633
run: yarn build:prod
3734

@@ -40,3 +37,6 @@ jobs:
4037

4138
- name: Run Browser Tests
4239
run: yarn test:browser
40+
41+
- name: Run Linter Checks
42+
run: yarn fmt && yarn lint && (git diff-index --quiet HEAD; git diff)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/tmp/
55
/dist/
66
/config/dist/
7+
/lib/
78
/coverage/
89
/jsdoc/
910
.DS_Store

CHANGELOG.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,39 @@
44
## Unreleased
55

66

7+
## [`v10.0.0-beta.0`](https://github.com/stellar/js-stellar-base/compare/v9.0.0...v10.0.0-beta.0): Protocol 20
8+
9+
### Breaking Changes
10+
* **Node 16 is the new minimum version** to use the SDKs.
11+
* The XDR has been massively overhauled to support [Soroban in Protocol 20](https://soroban.stellar.org/docs/category/fundamentals-and-concepts), which means new operations, data structures, and a transaction format as well as new overlay features ([#538](https://github.com/stellar/js-stellar-base/pull/538)).
12+
13+
The core data structure of Soroban is a generic type called an `ScVal` (**s**mart **c**ontract **val**ue, which is a union of types that can basically represent anything [numbers, strings, arrays, maps, contract bytecode, etc.]). You can refer to the XDR for details, and you can utilize new APIs to make dealing with these complex values easier:
14+
- `nativeToScVal` helps convert native types to their closest Soroban equivalent
15+
- `scValToNative` helps find the closest native JavaScript type(s) corresponding to a smart contract value
16+
- `scValToBigInt` helps convert numeric `ScVal`s into native `bigint`s
17+
- `ScInt` and `XdrLargeInt` help convert to and from `bigint`s to other types and form sized integer types for smart contract usage
18+
19+
### Added
20+
The following are new APIs to deal with new Soroban constructs:
21+
- **`Address`, which helps manage "smart" addresses in the Soroban context.** Addresses there (used for auth and identity purposes) can either be contracts (strkey `C...`) or accounts (strkey `G...`). This abstraction helps manage them and distinguish between them easily.
22+
- **`Contract`, which helps manage contract identifiers.** The primary purpose is to build invocations of its methods via the generic `call(...)`, but it also provides utilities for converting to an `Address` or calculating its minimum footprint for state expiration.
23+
- **Three new operations** have been added related to Soroban transactions:
24+
* `invokeHostFunction` for calling contract code
25+
* `bumpFootprintExpiration` for extending the state lifetime of Soroban data
26+
* `restoreFootprint` for restoring expired, off-chain state back onto the ledger
27+
- The `TransactionBuilder` now takes a `sorobanData` parameter (and has a corresponding `.setSorobanData()` builder method) which primarily describes the storage footprint of a Soroban (that is, which parts of the ledger state [in the form of `xdr.LedgerKey`s] it plans to read and write as part of the transaction).
28+
* To facilitate building this out, there's a new `SorobanDataBuilder` factory to set fields individually
29+
- The `TransactionBuilder` now has a `cloneFrom(tx, opts)` constructor method to create an instance from an existing transaction, also allowing parameter overrides via `opts`.
30+
- The following are convenience methods for building out certain types of smart contract-related structures:
31+
* `buildInvocationTree` and `walkInvocationTree` are both ways to visualize invocation calling trees better
32+
* `authorizeInvocation` helps multiple parties sign invocation calling trees
33+
* `humanizeEvents` helps make diagnostic events more readable
34+
- We've added a GHA to track bundle size changes as PRs are made. This protocol upgrade adds +18% to the final, minified bundle size which is significant but acceptable given the size of the upgrade.
35+
36+
### Fixes
37+
* Improves the error messages when passing invalid amounts to deposit and withdraw operations ([#679](https://github.com/stellar/js-stellar-base/pull/679)).
38+
39+
740
## [v9.0.0](https://github.com/stellar/js-stellar-base/compare/v8.2.2..v9.0.0)
841

942
This is a large update and the following changelog incorporates ALL changes across the `beta.N` versions of this upgrade.
@@ -15,7 +48,6 @@ The browser bundle size has decreased **significantly**:
1548
* `stellar-base.min.js` is **340 KiB**, down from **1.2 MiB** previously.
1649
* the new, unminified `stellar-base.js` is **895 KiB**.
1750

18-
1951
### Breaking Changes
2052

2153
- 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)).

Makefile

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
XDR_BASE_URL_CURR=https://github.com/stellar/stellar-xdr/raw/curr
1+
XDR_BASE_URL_CURR=https://github.com/stellar/stellar-xdr/raw/9ac02641139e6717924fdad716f6e958d0168491
22
XDR_BASE_LOCAL_CURR=xdr/curr
33
XDR_FILES_CURR= \
44
Stellar-SCP.x \
55
Stellar-ledger-entries.x \
66
Stellar-ledger.x \
77
Stellar-overlay.x \
88
Stellar-transaction.x \
9-
Stellar-types.x
9+
Stellar-types.x \
10+
Stellar-contract.x \
11+
Stellar-contract-env-meta.x \
12+
Stellar-contract-meta.x \
13+
Stellar-contract-spec.x \
14+
Stellar-contract-config-setting.x
1015
XDR_FILES_LOCAL_CURR=$(addprefix xdr/curr/,$(XDR_FILES_CURR))
1116

12-
XDR_BASE_URL_NEXT=https://github.com/stellar/stellar-xdr/raw/next
17+
XDR_BASE_URL_NEXT=https://github.com/stellar/stellar-xdr/raw/440dc9512b6e72cf84965641c5eb495d6043ed73
1318
XDR_BASE_LOCAL_NEXT=xdr/next
1419
XDR_FILES_NEXT= \
1520
Stellar-SCP.x \
@@ -20,7 +25,9 @@ XDR_FILES_NEXT= \
2025
Stellar-types.x \
2126
Stellar-contract.x \
2227
Stellar-contract-env-meta.x \
23-
Stellar-contract-spec.x
28+
Stellar-contract-meta.x \
29+
Stellar-contract-spec.x \
30+
Stellar-contract-config-setting.x
2431
XDR_FILES_LOCAL_NEXT=$(addprefix xdr/next/,$(XDR_FILES_NEXT))
2532

2633
XDRGEN_COMMIT=master
@@ -33,17 +40,17 @@ generate: src/generated/curr_generated.js types/curr.d.ts src/generated/next_gen
3340
src/generated/curr_generated.js: $(XDR_FILES_LOCAL_CURR)
3441
mkdir -p $(dir $@)
3542
> $@
36-
docker run -it --rm -v $$PWD:/wd -w /wd ruby /bin/bash -c '\
37-
gem install specific_install -v 0.3.7 && \
43+
docker run -it --rm -v $$PWD:/wd -w /wd ruby:3.1 /bin/bash -c '\
44+
gem install specific_install -v 0.3.8 && \
3845
gem specific_install https://github.com/stellar/xdrgen.git -b $(XDRGEN_COMMIT) && \
3946
xdrgen --language javascript --namespace curr --output src/generated $^ \
4047
'
4148

4249
src/generated/next_generated.js: $(XDR_FILES_LOCAL_NEXT)
4350
mkdir -p $(dir $@)
4451
> $@
45-
docker run -it --rm -v $$PWD:/wd -w /wd ruby /bin/bash -c '\
46-
gem install specific_install -v 0.3.7 && \
52+
docker run -it --rm -v $$PWD:/wd -w /wd ruby:3.1 /bin/bash -c '\
53+
gem install specific_install -v 0.3.8 && \
4754
gem specific_install https://github.com/stellar/xdrgen.git -b $(XDRGEN_COMMIT) && \
4855
xdrgen --language javascript --namespace next --output src/generated $^ \
4956
'
@@ -53,7 +60,7 @@ types/curr.d.ts: src/generated/curr_generated.js
5360
apk add --update git && \
5461
git clone --depth 1 https://github.com/stellar/dts-xdr -b $(DTSXDR_COMMIT) --single-branch && \
5562
cd /dts-xdr && \
56-
yarn install && \
63+
yarn install --network-concurrency 1 && \
5764
OUT=/wd/$@ npx jscodeshift -t src/transform.js /wd/$< && \
5865
cd /wd && \
5966
yarn run prettier --write /wd/$@ \
@@ -64,7 +71,7 @@ types/next.d.ts: src/generated/next_generated.js
6471
apk add --update git && \
6572
git clone --depth 1 https://github.com/stellar/dts-xdr -b $(DTSXDR_COMMIT) --single-branch && \
6673
cd /dts-xdr && \
67-
yarn install && \
74+
yarn install --network-concurrency 1 && \
6875
OUT=/wd/$@ npx jscodeshift -t src/transform.js /wd/$< && \
6976
cd /wd && \
7077
yarn run prettier --write /wd/$@ \
@@ -83,6 +90,7 @@ $(XDR_FILES_LOCAL_NEXT):
8390

8491
reset-xdr:
8592
rm -f xdr/*/*.x
93+
rm -f src/generated/*.js
8694
rm -f types/curr.d.ts
8795
rm -f types/next.d.ts
8896
$(MAKE) generate

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ Make sure that you are using the latest version number. They can be found on the
9898

9999
### To develop and test js-stellar-base itself
100100

101-
1. Install Node 14.x
101+
1. Install Node 16.x
102102

103-
We support the oldest LTS release of Node, which is [currently 14.x](https://nodejs.org/en/about/releases/). Please likewise install and develop on Node 14 so you don't get surprised when your code works locally but breaks in CI.
103+
We support the oldest LTS release of Node, which is [currently 16.x](https://nodejs.org/en/about/releases/). Please likewise install and develop on Node 16 so you don't get surprised when your code works locally but breaks in CI.
104104

105105
If you work on several projects that use different Node versions, you might find helpful to install a NodeJS version manager:
106106

config/.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
env: {
3-
es6: true
3+
es6: true,
4+
es2020: true
45
},
56
extends: ['airbnb-base', 'prettier'],
67
plugins: ['@babel', 'prettier', 'prefer-import'],

config/webpack.config.browser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const config = {
1414
},
1515
resolve: {
1616
fallback: {
17-
crypto: require.resolve('crypto-browserify'),
1817
stream: require.resolve('stream-browserify'),
1918
buffer: require.resolve('buffer')
2019
},

package.json

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "stellar-base",
3-
"version": "9.0.0",
3+
"version": "10.0.0-beta.0",
44
"description": "Low-level support library for the Stellar network.",
55
"main": "./lib/index.js",
6-
"browser": "./dist/stellar-base.min.js",
6+
"browser": {
7+
"main": "./dist/stellar-base.min.js",
8+
"sodium-native": false
9+
},
710
"types": "./types/index.d.ts",
811
"scripts": {
912
"build": "yarn build:node && yarn build:browser",
@@ -13,14 +16,15 @@
1316
"build:browser:prod": "cross-env NODE_ENV=production yarn build:browser",
1417
"build:prod": "cross-env NODE_ENV=production yarn build",
1518
"test": "yarn build && yarn test:node && yarn test:browser",
16-
"test:node": "nyc --nycrc-path ./config/.nycrc mocha",
19+
"test:node": "yarn _nyc mocha",
1720
"test:browser": "karma start ./config/karma.conf.js",
1821
"docs": "jsdoc -c ./config/.jsdoc.json --verbose",
1922
"lint": "eslint -c ./config/.eslintrc.js src/ && dtslint --localTs node_modules/typescript/lib types/",
2023
"preversion": "yarn clean && yarn fmt && yarn lint && yarn build:prod && yarn test",
2124
"fmt": "prettier --config ./config/prettier.config.js --ignore-path ./config/.prettierignore --write './**/*.js'",
2225
"prepare": "yarn build:prod",
23-
"clean": "rm -rf lib/ dist/ coverage/ .nyc_output/"
26+
"clean": "rm -rf lib/ dist/ coverage/ .nyc_output/",
27+
"_nyc": "nyc --nycrc-path ./config/.nycrc"
2428
},
2529
"mocha": {
2630
"require": [
@@ -52,9 +56,6 @@
5256
"yarn lint"
5357
]
5458
},
55-
"browser": {
56-
"sodium-native": false
57-
},
5859
"repository": {
5960
"type": "git",
6061
"url": "https://github.com/stellar/js-stellar-base.git"
@@ -69,60 +70,59 @@
6970
},
7071
"homepage": "https://github.com/stellar/js-stellar-base",
7172
"devDependencies": {
72-
"@babel/cli": "^7.21.0",
73-
"@babel/core": "^7.12.0",
74-
"@babel/eslint-parser": "^7.21.3",
75-
"@babel/eslint-plugin": "^7.19.1",
76-
"@babel/preset-env": "^7.21.4",
77-
"@babel/register": "^7.21.0",
78-
"@definitelytyped/dtslint": "^0.0.163",
73+
"@babel/cli": "^7.22.15",
74+
"@babel/core": "^7.22.17",
75+
"@babel/eslint-parser": "^7.22.15",
76+
"@babel/eslint-plugin": "^7.22.10",
77+
"@babel/preset-env": "^7.22.15",
78+
"@babel/register": "^7.22.15",
79+
"@definitelytyped/dtslint": "^0.0.177",
7980
"@istanbuljs/nyc-config-babel": "3.0.0",
80-
"@types/node": "^20.1.4",
81-
"@typescript-eslint/parser": "^5.59.6",
82-
"babel-loader": "^9.1.2",
81+
"@types/node": "^20.6.0",
82+
"@typescript-eslint/parser": "^6.7.0",
83+
"babel-loader": "^9.1.3",
8384
"babel-plugin-istanbul": "^6.1.1",
84-
"buffer": "^6.0.3",
85-
"chai": "^4.3.7",
85+
"chai": "^4.3.8",
8686
"cross-env": "^7.0.3",
87-
"eslint": "^8.37.0",
87+
"eslint": "^8.49.0",
8888
"eslint-config-airbnb-base": "^15.0.0",
89-
"eslint-config-prettier": "^8.8.0",
90-
"eslint-plugin-import": "^2.25.2",
89+
"eslint-config-prettier": "^9.0.0",
90+
"eslint-plugin-import": "^2.28.1",
9191
"eslint-plugin-node": "^11.1.0",
9292
"eslint-plugin-prefer-import": "^0.0.1",
93-
"eslint-plugin-prettier": "^4.2.1",
93+
"eslint-plugin-prettier": "^5.0.0",
9494
"eslint-webpack-plugin": "^4.0.0",
9595
"ghooks": "^2.0.4",
9696
"husky": "^8.0.3",
9797
"jsdoc": "^4.0.2",
98-
"karma": "^6.4.1",
98+
"karma": "^6.4.2",
9999
"karma-chrome-launcher": "^3.1.0",
100-
"karma-coverage": "^2.2.0",
100+
"karma-coverage": "^2.2.1",
101101
"karma-firefox-launcher": "^2.1.1",
102102
"karma-mocha": "^2.0.0",
103103
"karma-sinon-chai": "^2.0.2",
104104
"karma-webpack": "^5.0.0",
105-
"lint-staged": "^13.2.0",
105+
"lint-staged": "^14.0.1",
106106
"minami": "^1.1.1",
107107
"mocha": "^10.2.0",
108108
"node-polyfill-webpack-plugin": "^2.0.1",
109109
"nyc": "^15.1.0",
110-
"prettier": "^2.8.7",
110+
"prettier": "^3.0.3",
111111
"randombytes": "^2.1.0",
112112
"sinon": "^15.0.3",
113113
"sinon-chai": "^3.7.0",
114114
"taffydb": "^2.7.3",
115-
"terser-webpack-plugin": "^5.3.7",
115+
"terser-webpack-plugin": "^5.3.8",
116116
"ts-node": "^10.9.1",
117-
"typescript": "^5.0.3",
117+
"typescript": "^5.2.2",
118118
"webpack": "^5.82.1",
119119
"webpack-cli": "^5.1.1"
120120
},
121121
"dependencies": {
122122
"base32.js": "^0.1.0",
123-
"bignumber.js": "^9.1.1",
124-
"crypto-browserify": "^3.12.0",
125-
"js-xdr": "^2.0.0",
123+
"bignumber.js": "^9.1.2",
124+
"buffer": "^6.0.3",
125+
"js-xdr": "^3.0.0",
126126
"sha.js": "^2.3.6",
127127
"tweetnacl": "^1.0.3"
128128
},

0 commit comments

Comments
 (0)