Skip to content

Commit

Permalink
Merge pull request #1353 from near/feat/bundling-enhancements
Browse files Browse the repository at this point in the history
feat: modularization and bundling enhancements
  • Loading branch information
andy-haynes committed Sep 4, 2024
2 parents 72798d1 + f027f1b commit 6ceb62e
Show file tree
Hide file tree
Showing 168 changed files with 4,312 additions and 6,390 deletions.
35 changes: 35 additions & 0 deletions .changeset/odd-tips-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
"@near-js/accounts": minor
"@near-js/biometric-ed25519": minor
"@near-js/crypto": minor
"@near-js/iframe-rpc": minor
"@near-js/keystores": minor
"@near-js/keystores-browser": minor
"@near-js/keystores-node": minor
"near-api-js": major
"@near-js/providers": major
"@near-js/signers": minor
"@near-js/transactions": minor
"@near-js/types": minor
"@near-js/utils": major
"@near-js/wallet-account": minor
---

Update to Node.js 20 LTS & pnpm 9.4, modularize packages, simplify dependencies, and update tests

**Breaking Changes**

- `[email protected]`
- The following functions are no longer exported:
- `logWarning`
- `fetchJson`
- the unnamed wrapped `fetch` function exported from `setup-node-fetch.ts`
- The browser bundle is no longer being built in version 5; for browser support please use modules

- `@near-js/[email protected]`
- The following functions are no longer exported:
- `fetchJson`

- `@near-js/[email protected]`
- The following functions are no longer exported:
- `logWarning`
2 changes: 1 addition & 1 deletion .eslintrc.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
extends:
- 'eslint:recommended'
parserOptions:
ecmaVersion: 2018
ecmaVersion: 2020
sourceType: module
rules:
indent:
Expand Down
8 changes: 0 additions & 8 deletions .eslintrc.js.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .eslintrc.ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ extends:
- 'plugin:@typescript-eslint/eslint-recommended'
- 'plugin:@typescript-eslint/recommended'
parser: '@typescript-eslint/parser'
overrides:
- rules:
"@typescript-eslint/no-explicit-any": "warn"
"@typescript-eslint/no-empty-function": "warn"
files:
- "*.ts"
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 7
version: 9.4.0

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.15.0
cache: pnpm

- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 7
version: 9.4.0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.15.0

- name: Install Dependencies
run: pnpm install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/typedoc-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
master

env:
NODE_VERSION: 18.x
NODE_VERSION: 20.15.0
ENTRY_FILE: 'packages'
CONFIG_PATH: 'tsconfig.base.json'
USES_PNPM: 'true'
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 7
version: 9.4.0

- name: Install dependencies
run: pnpm install
Expand Down
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"name": "@near-js/monorepo",
"private": true,
"engines": {
"node": ">=16.14.0",
"pnpm": ">=7"
"node": ">=20.15.0",
"pnpm": ">=9.4.0"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "turbo run build",
"clean": "turbo run clean",
"lint": "turbo run lint:ts lint:js",
"lint:fix": "turbo run lint:ts:fix lint:js:fix",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
"autoclave": "rimraf packages/**/dist && rimraf packages/**/lib && rimraf packages/**/node_modules && rimraf packages/**/coverage && rimraf packages/**/.turbo && rm -rf node_modules",
"test": "turbo run test",
"release": "changeset publish",
Expand All @@ -20,17 +20,18 @@
"devDependencies": {
"@changesets/changelog-github": "0.4.6",
"@changesets/cli": "2.24.4",
"@commitlint/cli": "17.0.3",
"@commitlint/config-conventional": "17.0.3",
"@typescript-eslint/eslint-plugin": "5.31.0",
"@typescript-eslint/parser": "5.31.0",
"commitlint": "17.0.3",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"commitlint": "19.3.0",
"eslint": "8.20.0",
"husky": "7.0.4",
"rimraf": "3.0.2",
"rimraf": "6.0.1",
"turbo": "1.4.5",
"typedoc": "0.25.3",
"typescript": "4.9.4"
"typedoc": "0.25.13",
"tsconfig": "workspace:*",
"typescript": "5.4.5"
},
"resolutions": {
"near-sandbox": "0.0.18",
Expand Down
22 changes: 0 additions & 22 deletions packages/accounts/jest.config.js

This file was deleted.

13 changes: 13 additions & 0 deletions packages/accounts/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
preset: 'ts-jest',
collectCoverage: true,
testEnvironment: 'node',
testRegex: "(/tests/.*|(\\.|/)(test|spec))\\.[jt]sx?$",
transform: {
'^.+\\.[tj]s$': ['ts-jest', {
tsconfig: {
allowJs: true,
},
}],
},
};
38 changes: 23 additions & 15 deletions packages/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"name": "@near-js/accounts",
"version": "1.2.2",
"description": "Classes encapsulating account-specific functionality",
"main": "lib/index.js",
"main": "lib/esm/index.js",
"type": "module",
"scripts": {
"build": "pnpm compile",
"compile": "tsc -p tsconfig.json",
"lint:js": "eslint -c ../../.eslintrc.js.yml test/**/*.js --no-eslintrc",
"lint:js:fix": "eslint -c ../../.eslintrc.js.yml test/**/*.js --no-eslintrc --fix",
"lint:ts": "eslint -c ../../.eslintrc.ts.yml src/**/*.ts --no-eslintrc",
"lint:ts:fix": "eslint -c ../../.eslintrc.ts.yml src/**/*.ts --no-eslintrc --fix",
"test": "jest test"
"build": "pnpm compile:esm && pnpm compile:cjs",
"compile:esm": "tsc -p tsconfig.json",
"compile:cjs": "tsc -p tsconfig.cjs.json && cjsify ./lib/commonjs",
"lint": "eslint -c ../../.eslintrc.ts.yml src/**/*.ts test/**/*.ts --no-eslintrc",
"lint:fix": "eslint -c ../../.eslintrc.ts.yml src/**/*.ts test/**/*.ts --no-eslintrc --fix",
"test": "jest"
},
"keywords": [],
"author": "",
Expand All @@ -22,27 +22,35 @@
"@near-js/transactions": "workspace:*",
"@near-js/types": "workspace:*",
"@near-js/utils": "workspace:*",
"@noble/hashes": "1.3.3",
"borsh": "1.0.0",
"depd": "2.0.0",
"is-my-json-valid": "^2.20.6",
"isomorphic-unfetch": "^3.1.0",
"lru_map": "0.4.1",
"near-abi": "0.1.1"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@near-js/keystores": "workspace:*",
"@types/node": "18.11.18",
"@types/json-schema": "^7.0.15",
"@types/node": "20.0.0",
"bs58": "4.0.0",
"jest": "26.0.1",
"build": "workspace:*",
"jest": "29.7.0",
"near-hello": "0.5.1",
"near-workspaces": "3.5.0",
"ts-jest": "26.5.6",
"typescript": "4.9.4"
"node-fetch": "2.6.7",
"semver": "7.1.1",
"ts-jest": "29.1.5",
"tsconfig": "workspace:*",
"typescript": "5.4.5"
},
"files": [
"lib"
],
"resolutions": {
"near-sandbox": "0.0.18",
"near-api-js": "4.0.0"
"exports": {
"require": "./lib/commonjs/index.cjs",
"import": "./lib/esm/index.js"
}
}
8 changes: 4 additions & 4 deletions packages/accounts/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class Account implements IntoConnection {
const block = await this.connection.provider.block({ finality: 'final' });
const blockHash = block.header.hash;

const nonce = accessKey.nonce + BigInt(1);
const nonce = accessKey.nonce + 1n;
return await signTransaction(
receiverId, nonce, actions, baseDecode(blockHash), this.connection.signer, this.accountId, this.connection.networkId
);
Expand Down Expand Up @@ -444,7 +444,7 @@ export class Account implements IntoConnection {
const delegateAction = buildDelegateAction({
actions,
maxBlockHeight: BigInt(header.height) + BigInt(blockHeightTtl),
nonce: BigInt(accessKey.nonce) + BigInt(1),
nonce: BigInt(accessKey.nonce) + 1n,
publicKey,
receiverId,
senderId: this.accountId,
Expand Down Expand Up @@ -610,7 +610,7 @@ export class Account implements IntoConnection {
const validatorId = uniquePools[index];
if (state.status === 'fulfilled') {
const currentBN = BigInt(state.value);
if (currentBN !== BigInt(0)) {
if (currentBN !== 0n) {
return {
...result,
stakedValidators: [...result.stakedValidators, { validatorId, amount: currentBN.toString() }],
Expand All @@ -626,7 +626,7 @@ export class Account implements IntoConnection {
}
return result;
},
{ stakedValidators: [], failedValidators: [], total: BigInt(0) });
{ stakedValidators: [], failedValidators: [], total: 0n });

return {
...summary,
Expand Down
Loading

0 comments on commit 6ceb62e

Please sign in to comment.