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

refactor: ESM and CJS transpilation #1067

Closed
wants to merge 84 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
5089f6f
refactor: create core package
andy-haynes Nov 4, 2022
f11e1e8
refactor: add @near-js/core as a dependency
andy-haynes Nov 4, 2022
de0e6db
refactor: core exports
andy-haynes Nov 4, 2022
b9a966d
refactor: move signer to core
andy-haynes Nov 4, 2022
d8fdcce
refactor: move keystore code
andy-haynes Nov 4, 2022
0d77c35
refactor: move key pair code
andy-haynes Nov 4, 2022
ee89bf9
refactor: common, non-exported location for Assignable
andy-haynes Nov 5, 2022
25dfba2
refactor: move transaction code
andy-haynes Nov 5, 2022
01826bf
refactor: export all
andy-haynes Nov 5, 2022
3e542c2
refactor: break up and move provider logic to core
andy-haynes Nov 14, 2022
2e38bc3
refactor: move format methods to core
andy-haynes Nov 14, 2022
302fc3b
refactor: move error modules to core
andy-haynes Nov 14, 2022
7c4e186
refactor: json-rpc-provider package
andy-haynes Nov 14, 2022
490b29a
refactor: rename module after sole exported function
andy-haynes Nov 18, 2022
e0c971e
fix: remove vestigial prepare command to fix circular failure
andy-haynes Nov 18, 2022
904adf8
refactor: move Provider abstract class to json-rpc-provider package
andy-haynes Nov 18, 2022
812aae4
refactor: rename package to represent class of implementations, not t…
andy-haynes Nov 18, 2022
4348177
refactor: separate transactions package
andy-haynes Nov 18, 2022
ed9c45f
refactor: move MergeKeyStore into core
andy-haynes Nov 18, 2022
b2d2bee
refactor: move tests from near-api-js to core
andy-haynes Nov 18, 2022
a0e6b54
refactor: move tests from near-api-js to providers
andy-haynes Nov 18, 2022
2481903
refactor: rename web to fetch_json
andy-haynes Nov 18, 2022
a234431
refactor: rename core to client-core
andy-haynes Nov 18, 2022
4cdfe9f
refactor: client-node package with UnencryptedFileSystemKeyStore
andy-haynes Nov 18, 2022
9c76a1d
refactor: client-browser package with localstorage keystore, polyfill…
andy-haynes Nov 19, 2022
979f745
refactor: fix duplicate export
andy-haynes Nov 19, 2022
3d6df96
feat: accounts package
andy-haynes Dec 2, 2022
af64299
feat: split up Account2FA and AccountMultisig
andy-haynes Dec 2, 2022
a5ed04c
feat: move account_creator to accounts package
andy-haynes Dec 2, 2022
c7f1d88
feat: connected-wallet package
andy-haynes Dec 2, 2022
fc2a3cb
refactor: break out platform-specific packages by domain model
andy-haynes Dec 2, 2022
ec417f1
feat: connected-wallet package
andy-haynes Dec 2, 2022
f8c3114
chore: remove old dependencies
andy-haynes Dec 2, 2022
bf1295d
refactor: break out platform-specific packages by domain model
andy-haynes Dec 2, 2022
7ce12c5
refactor: move validators to core
andy-haynes Dec 2, 2022
3932efe
refactor: move contract to accounts
andy-haynes Dec 3, 2022
17c6157
refactor: rename connected-wallet to wallet-account
andy-haynes Dec 3, 2022
394b401
refactor: fix circular dependency
andy-haynes Dec 17, 2022
26b4ae1
refactor: moving tests
andy-haynes Dec 17, 2022
052a99c
refactor: split up providers tests between providers and accounts pac…
andy-haynes Jan 3, 2023
97e06f2
refactor: remove unused/moved methods
andy-haynes Jan 3, 2023
9d14709
refactor: move contract tests
andy-haynes Jan 3, 2023
fcf6f73
refactor: transactions tests
andy-haynes Jan 3, 2023
d94c7ce
refactor: move remaining top-level tests
andy-haynes Jan 3, 2023
d6f99b7
refactor: inline test method
andy-haynes Jan 3, 2023
5416305
refactor: remove unused assets/modules
andy-haynes Jan 3, 2023
06d46ce
fix: remove unused dependencies
andy-haynes Jan 3, 2023
1f55c41
refactor: split up key pair implementation
andy-haynes Jan 3, 2023
d3349cb
refactor: split up client-core into keypairs, keystores, signers, and…
andy-haynes Jan 4, 2023
d0bdac8
refactor: shared tsconfig
andy-haynes Jan 4, 2023
7870cb7
chore: set TS as dev dependency
andy-haynes Jan 4, 2023
54f2704
refactor: rename client-core to utils
andy-haynes Jan 4, 2023
d5f5db4
refactor: move keystore tests
andy-haynes Jan 4, 2023
3c3999b
refactor: move error script to utils
andy-haynes Jan 4, 2023
c57a826
chore: linting
andy-haynes Jan 4, 2023
f7fa15e
refactor: fix transactions test
andy-haynes Jan 5, 2023
1a98ff7
fix: unmerged changes
andy-haynes Jan 5, 2023
17c376e
fix: matching ts versions
andy-haynes Jan 7, 2023
7d6a206
refactor: export action creators under separate key
andy-haynes Jan 9, 2023
416ee21
test: add missing jest config
andy-haynes Jan 9, 2023
879f240
test: fix references
andy-haynes Jan 9, 2023
ef722dc
test: retain now-duplicated near-api-js tests during transition
andy-haynes Jan 9, 2023
688bcac
test: missing test eslint
andy-haynes Jan 9, 2023
f9ea92b
test: temporarily test in dependency order to resolve issues with dup…
andy-haynes Jan 9, 2023
b0ef6c0
docs: readmes
andy-haynes Jan 10, 2023
9698764
docs: changeset
andy-haynes Jan 11, 2023
fcbf76b
refactor: rename keypairs to crypto
andy-haynes Jan 13, 2023
5c21ed4
chore: update changeset to promote near-api-js change and rename package
andy-haynes Jan 13, 2023
e3705e6
docs: describe breaking change
andy-haynes Jan 19, 2023
b2553d3
chore: merge abi validation for contract
andy-haynes Jan 25, 2023
5413d8a
fix: export errors from utils/errors
andy-haynes Jan 25, 2023
9386ead
fix: restore promisify shim on NAJ-dependent versions
andy-haynes Jan 26, 2023
4abbe3f
ci: properly cache build output
andy-haynes Jan 26, 2023
9149734
ci: command for sanitizing dev environment
andy-haynes Jan 26, 2023
62f6b03
build: transpile cjs and esm for @near-js/accounts
andy-haynes Jan 31, 2023
321f6f6
build: transpile cjs and esm for @near-js/transactions
andy-haynes Jan 31, 2023
d4ad5c4
build: modulify remaining packages
andy-haynes Jan 31, 2023
aa41362
build: guard global references
andy-haynes Jan 31, 2023
25b84ab
feat: example usage packages
andy-haynes Feb 2, 2023
d09e4e9
feat: update tests
andy-haynes Feb 4, 2023
f1b5051
feat: add missing dev dependency
andy-haynes Feb 6, 2023
a4b3488
fix: example rpc URLs
andy-haynes Mar 2, 2023
58064e9
fix: import workaround JSON
andy-haynes Mar 7, 2023
5960b51
test: fix accounts tests
andy-haynes Mar 7, 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
19 changes: 19 additions & 0 deletions .changeset/slimy-baboons-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"near-api-js": major
"@near-js/accounts": patch
"@near-js/crypto": patch
"@near-js/keystores": patch
"@near-js/keystores-browser": patch
"@near-js/keystores-node": patch
"@near-js/providers": patch
"@near-js/signers": patch
"@near-js/transactions": patch
"@near-js/types": patch
"@near-js/utils": patch
"@near-js/wallet-account": patch
---

Major functionality in near-api-js has now been broken up into packages under @near-js

Breaking changes:
- `KeyPairEd25519` no longer supports the `fromString` static method. This method is now only available on the `KeyPair` class.
2 changes: 2 additions & 0 deletions .eslintrc.yml → .eslintrc.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ extends:
- 'eslint:recommended'
parserOptions:
ecmaVersion: 2018
sourceType: module
rules:
indent:
- error
- 4
- SwitchCase: 1
linebreak-style:
- error
- unix
Expand Down
7 changes: 7 additions & 0 deletions .eslintrc.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends: './.eslintrc.base.yml'
env:
jest: true
globals:
jasmine: true
window: false
fail: true
5 changes: 5 additions & 0 deletions .eslintrc.ts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends:
- './.eslintrc.base.yml'
- 'plugin:@typescript-eslint/eslint-recommended'
- 'plugin:@typescript-eslint/recommended'
parser: '@typescript-eslint/parser'
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ Follow next steps:
2. Fetch new schema: `node fetch_error_schema.js`
3. `pnpm build` to update `lib/**.js` files


## Packages

- [accounts](https://github.com/near/near-api-js/tree/master/packages/accounts) account creation & management
- [keypairs](https://github.com/near/near-api-js/tree/master/packages/keypairs) cryptographic key pairs & signing
- [keystores](https://github.com/near/near-api-js/tree/master/packages/keystores) general-purpose key persistence & management
- [keystores-browser](https://github.com/near/near-api-js/tree/master/packages/keystores-browser) browser keystores
- [keystores-node](https://github.com/near/near-api-js/tree/master/packages/keystores-node) NodeJS keystores
- [providers](https://github.com/near/near-api-js/tree/master/packages/providers) RPC interaction
- [transactions](https://github.com/near/near-api-js/tree/master/packages/transactions) transaction composition & signing
- [types](https://github.com/near/near-api-js/tree/master/packages/types) common types
- [utils](https://github.com/near/near-api-js/tree/master/packages/types) common methods
- [wallet-account](https://github.com/near/near-api-js/tree/master/packages/wallet-account) accounts in browser-based wallets

## License

This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"preinstall": "npx only-allow pnpm",
"build": "turbo run build",
"clean": "turbo run clean",
"lint": "turbo run lint",
"lint": "concurrently \"turbo run lint:ts\" \"turbo run lint:js\"",
"lint:fix": "concurrently \"turbo run lint:ts:fix\" \"turbo run lint:js:fix\"",
"autoclave": "concurrently \"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",
"prepare": "husky install"
Expand All @@ -19,13 +21,14 @@
"@changesets/cli": "^2.24.4",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"typescript": "^4.7.4",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"commitlint": "^17.0.3",
"eslint": "^8.20.0",
"concurrently": "^7.6.0",
"eslint": "^8.32.0",
"husky": "^7.0.4",
"rimraf": "^3.0.2",
"turbo": "^1.4.5"
"turbo": "^1.4.5",
"typescript": "^4.9.4"
}
}
19 changes: 19 additions & 0 deletions packages/accounts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# @near-js/accounts

A collection of classes, functions, and types for interacting with accounts and contracts.

## Modules

- [Account](src/account.ts) a class with methods to transfer NEAR, manage account keys, sign transactions, etc.
- [AccountMultisig](src/account_multisig.ts) a [multisig](https://github.com/near/core-contracts/tree/master/multisig) deployed `Account` requiring multiple keys to sign transactions
- [Account2FA](src/account_2fa.ts) extension of `AccountMultisig` used in conjunction with 2FA provided by [near-contract-helper](https://github.com/near/near-contract-helper)
- [AccountCreator](src/account_creator.ts) classes for creating NEAR accounts
- [Contract](src/contract.ts) represents a deployed smart contract with view and/or change methods
- [Connection](src/connection.ts) a record containing the information required to connect to NEAR RPC
- [Constants](src/constants.ts) account-specific constants
- [Types](src/types.ts) account-specific types

# License

This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See [LICENSE](https://github.com/near/near-api-js/blob/master/LICENSE) and [LICENSE-APACHE](https://github.com/near/near-api-js/blob/master/LICENSE-APACHE) for details.
5 changes: 5 additions & 0 deletions packages/accounts/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverage: true
};
51 changes: 51 additions & 0 deletions packages/accounts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@near-js/accounts",
"version": "0.0.1",
"description": "Classes encapsulating account-specific functionality",
"main": "lib/esm/index.js",
"type": "module",
"browser": "./lib/cjs/index.js",
"scripts": {
"build": "pnpm compile",
"compile": "concurrently \"tsc -p tsconfig.cjs.json\" \"tsc -p tsconfig.esm.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": "NODE_OPTIONS=--experimental-vm-modules jest test"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@near-js/crypto": "workspace:*",
"@near-js/providers": "workspace:*",
"@near-js/signers": "workspace:*",
"@near-js/transactions": "workspace:*",
"@near-js/types": "workspace:*",
"@near-js/utils": "workspace:*",
"ajv": "^8.11.2",
"ajv-formats": "^2.1.1",
"bn.js": "5.2.1",
"borsh": "^0.7.0",
"depd": "^2.0.0",
"near-abi": "0.1.1"
},
"devDependencies": {
"@near-js/keystores": "workspace:*",
"@types/node": "^18.11.18",
"bs58": "^4.0.0",
"jest": "^26.0.1",
"near-hello": "^0.5.1",
"ts-jest": "^26.5.6",
"tsconfig": "workspace:*",
"typescript": "^4.9.4"
},
"exports": {
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.js"
},
"files": [
"lib"
]
}
Loading