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

feat: modularization and bundling enhancements #1353

Merged
merged 45 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4ef5252
feat: bump pnpm version
andy-haynes Jun 14, 2024
702606a
feat: isomorphic fetch for providers
andy-haynes Jun 14, 2024
cd88aaf
feat: use isomorphic fetch in accounts package
andy-haynes Jun 14, 2024
693c912
feat: remove fetching utils in near-api-js
andy-haynes Jun 14, 2024
0ea2171
feat: remove process reference
andy-haynes Jun 14, 2024
73e8fd0
feat: modules
andy-haynes Jun 14, 2024
d29d80b
feat: bundles
andy-haynes Jun 14, 2024
ab153be
feat: naj config
andy-haynes Jun 14, 2024
c55bad0
feat: extending Assignable no longer works for classes with defined p…
andy-haynes Jun 15, 2024
deb1b23
feat: convert tests to TS
andy-haynes Jun 18, 2024
06df05d
feat: lint updates
andy-haynes Jun 18, 2024
4085e61
build: bump node/pnpm versions
andy-haynes Jun 18, 2024
62c1d49
build: remove extraneous config
andy-haynes Jun 18, 2024
5cdd9f6
feat: test fixes
andy-haynes Jun 18, 2024
59c7054
feat: target es2022
andy-haynes Jun 18, 2024
5dc817c
feat: update Enum class to force extending classes to declare enum
andy-haynes Jun 18, 2024
f843839
feat: update typescript
andy-haynes Jun 18, 2024
a2afd6d
feat: near-api-js as a module
andy-haynes Jun 18, 2024
86f7186
feat: move tsconfig to internal package
andy-haynes Jun 18, 2024
7e46154
feat: remove preserveSymlink overrides, consolidate NAJ tsconfig, and…
andy-haynes Jun 20, 2024
3f1172e
feat: bump to node 20 lts & pnpm 9.4
andy-haynes Jun 20, 2024
50abadb
test: restore timeouts
andy-haynes Jun 20, 2024
c7fee11
feat: export test config
andy-haynes Jun 20, 2024
4a57f85
test: remove bad @ts-ignore-errors
andy-haynes Jun 21, 2024
a673324
refactor: bigint literals
andy-haynes Jun 21, 2024
f021c3e
test: fix test mismatch
andy-haynes Jun 21, 2024
2eeb423
test: fix sort order
andy-haynes Jun 21, 2024
5077010
refactor: enum class
andy-haynes Aug 6, 2024
7bb2161
feat: borsh enum classes must extend Enum
andy-haynes Aug 6, 2024
b6fb0e3
test: reduce noise
andy-haynes Aug 6, 2024
54f86fd
style: lint
andy-haynes Aug 6, 2024
340d667
test: update configuration
andy-haynes Aug 6, 2024
7369055
build: changeset
andy-haynes Aug 6, 2024
eca1aa9
build: update versions on pull-request workflow
andy-haynes Aug 7, 2024
1afa909
feat: commonJS builds
andy-haynes Aug 8, 2024
6d08fcd
chore: package cleanup
andy-haynes Aug 8, 2024
1680cb9
test: fixes
andy-haynes Aug 20, 2024
a674d83
chore: remove logWarning reference
andy-haynes Aug 20, 2024
4c2e74c
test: multi contract keystore
andy-haynes Aug 20, 2024
e1e7c2f
chore: lint
andy-haynes Aug 20, 2024
4dac4fd
chore: duplicate Enum definition
andy-haynes Aug 27, 2024
b23e4c8
fix: export KeyPairString
andy-haynes Aug 27, 2024
9b86356
feat: restore Assignable for backward compatibility
andy-haynes Aug 27, 2024
2fdb57d
fix: keep near-api-js as commonjs, remove bundling
andy-haynes Aug 27, 2024
f027f1b
docs: include breaking changes descriptions in changelog
andy-haynes Sep 3, 2024
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
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
Loading