near-api-js 6.5.0 → 7.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -4
- package/lib/accounts/abi_types.d.ts +716 -0
- package/lib/accounts/abi_types.js +1 -0
- package/lib/accounts/account.d.ts +310 -0
- package/lib/accounts/account.js +473 -0
- package/lib/accounts/errors.d.ts +13 -0
- package/lib/accounts/errors.js +20 -0
- package/lib/accounts/index.d.ts +4 -0
- package/lib/accounts/index.js +3 -0
- package/lib/accounts/typed_contract.d.ts +136 -0
- package/lib/accounts/typed_contract.js +93 -0
- package/lib/crypto/constants.d.ts +12 -0
- package/lib/crypto/constants.js +11 -0
- package/lib/crypto/index.d.ts +7 -0
- package/lib/crypto/index.js +5 -0
- package/lib/crypto/key_pair.d.ts +15 -0
- package/lib/crypto/key_pair.js +40 -0
- package/lib/crypto/key_pair_base.d.ts +12 -0
- package/lib/crypto/key_pair_base.js +2 -0
- package/lib/crypto/key_pair_ed25519.d.ts +52 -0
- package/lib/crypto/key_pair_ed25519.js +74 -0
- package/lib/crypto/key_pair_secp256k1.d.ts +39 -0
- package/lib/crypto/key_pair_secp256k1.js +68 -0
- package/lib/crypto/public_key.d.ts +59 -0
- package/lib/crypto/public_key.js +165 -0
- package/lib/index.d.ts +8 -24
- package/lib/index.js +28 -45
- package/lib/nep413/index.d.ts +4 -0
- package/lib/nep413/index.js +2 -0
- package/lib/nep413/schema.d.ts +9 -0
- package/lib/nep413/schema.js +20 -0
- package/lib/nep413/sign.d.ts +8 -0
- package/lib/nep413/sign.js +6 -0
- package/lib/nep413/verify.d.ts +11 -0
- package/lib/nep413/verify.js +17 -0
- package/lib/providers/exponential-backoff.d.ts +1 -0
- package/lib/providers/exponential-backoff.js +17 -0
- package/lib/providers/failover-rpc-provider.d.ts +134 -1
- package/lib/providers/failover-rpc-provider.js +216 -28
- package/lib/providers/fetch_json.d.ts +31 -0
- package/lib/providers/fetch_json.js +67 -0
- package/lib/providers/index.d.ts +4 -3
- package/lib/providers/index.js +3 -48
- package/lib/providers/json-rpc-provider.d.ts +167 -2
- package/lib/providers/json-rpc-provider.js +406 -33
- package/lib/providers/provider.d.ts +88 -3
- package/lib/providers/provider.js +5 -160
- package/lib/signers/index.d.ts +3 -0
- package/lib/signers/index.js +2 -0
- package/lib/signers/key_pair_signer.d.ts +12 -0
- package/lib/signers/key_pair_signer.js +22 -0
- package/lib/signers/signer.d.ts +56 -0
- package/lib/signers/signer.js +74 -0
- package/lib/tokens/ft/format.d.ts +9 -0
- package/lib/tokens/ft/format.js +61 -0
- package/lib/tokens/ft/index.d.ts +108 -0
- package/lib/tokens/ft/index.js +132 -0
- package/lib/tokens/index.d.ts +3 -0
- package/lib/tokens/index.js +3 -0
- package/lib/tokens/mainnet/index.d.ts +4 -0
- package/lib/tokens/mainnet/index.js +19 -0
- package/lib/tokens/mt/index.d.ts +81 -0
- package/lib/tokens/mt/index.js +114 -0
- package/lib/tokens/nft/index.d.ts +42 -0
- package/lib/tokens/nft/index.js +27 -0
- package/lib/tokens/testnet/index.d.ts +4 -0
- package/lib/tokens/testnet/index.js +19 -0
- package/lib/transactions/action_creators.d.ts +117 -0
- package/lib/transactions/action_creators.js +161 -0
- package/lib/transactions/actions.d.ts +143 -0
- package/lib/transactions/actions.js +115 -0
- package/lib/transactions/create_transaction.d.ts +14 -0
- package/lib/transactions/create_transaction.js +22 -0
- package/lib/transactions/delegate.d.ts +28 -0
- package/lib/transactions/delegate.js +94 -0
- package/lib/transactions/index.d.ts +6 -0
- package/lib/transactions/index.js +6 -0
- package/lib/transactions/prefix.d.ts +21 -0
- package/lib/transactions/prefix.js +35 -0
- package/lib/transactions/schema.d.ts +93 -0
- package/lib/transactions/schema.js +255 -0
- package/lib/transactions/signature.d.ts +23 -0
- package/lib/transactions/signature.js +46 -0
- package/lib/types/accounts.d.ts +20 -0
- package/lib/types/accounts.js +1 -0
- package/lib/types/assignable.d.ts +3 -0
- package/lib/types/assignable.js +8 -0
- package/lib/types/enum.d.ts +4 -0
- package/lib/types/enum.js +12 -0
- package/lib/types/errors.d.ts +15 -0
- package/lib/types/errors.js +22 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.js +5 -0
- package/lib/types/provider/index.d.ts +7 -0
- package/lib/types/provider/index.js +2 -0
- package/lib/types/provider/light_client.d.ts +41 -0
- package/lib/types/provider/light_client.js +9 -0
- package/lib/types/provider/protocol.d.ts +184 -0
- package/lib/types/provider/protocol.js +5 -0
- package/lib/types/provider/request.d.ts +34 -0
- package/lib/types/provider/request.js +5 -0
- package/lib/types/provider/response.d.ts +164 -0
- package/lib/types/provider/response.js +12 -0
- package/lib/types/provider/validator.d.ts +40 -0
- package/lib/types/provider/validator.js +5 -0
- package/lib/utils/errors/error_messages.d.ts +70 -0
- package/lib/utils/errors/error_messages.js +69 -0
- package/lib/utils/errors/errors.d.ts +3 -0
- package/lib/utils/errors/errors.js +2 -0
- package/lib/utils/errors/index.d.ts +2 -0
- package/lib/utils/errors/index.js +2 -0
- package/lib/utils/errors/rpc_error_schema.d.ts +805 -0
- package/lib/utils/errors/rpc_error_schema.js +930 -0
- package/lib/utils/errors/rpc_errors.d.ts +11 -0
- package/lib/utils/errors/rpc_errors.js +114 -0
- package/lib/utils/format.d.ts +40 -1
- package/lib/utils/format.js +124 -34
- package/lib/utils/index.d.ts +5 -9
- package/lib/utils/index.js +5 -65
- package/lib/utils/provider.d.ts +3 -0
- package/lib/utils/provider.js +14 -0
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/utils.js +3 -0
- package/lib/utils/validators.d.ts +24 -0
- package/lib/utils/validators.js +83 -0
- package/package.json +61 -44
- package/lib/account.d.ts +0 -8
- package/lib/account.js +0 -40
- package/lib/account_creator-Bs61dnmU.d.ts +0 -10
- package/lib/account_creator.d.ts +0 -1
- package/lib/account_creator.js +0 -32
- package/lib/browser-connect.d.ts +0 -21
- package/lib/browser-connect.js +0 -44
- package/lib/browser-index-RhYalP0h.d.ts +0 -14
- package/lib/browser-index.d.ts +0 -23
- package/lib/browser-index.js +0 -43
- package/lib/common-index.d.ts +0 -20
- package/lib/common-index.js +0 -70
- package/lib/connect.d.ts +0 -43
- package/lib/connect.js +0 -72
- package/lib/connection.d.ts +0 -1
- package/lib/connection.js +0 -28
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js +0 -28
- package/lib/contract.d.ts +0 -1
- package/lib/contract.js +0 -35
- package/lib/enums-BOxGXwY_.d.ts +0 -8
- package/lib/format-BlG-d3wc.d.ts +0 -11
- package/lib/index-BDdRUK93.d.ts +0 -21
- package/lib/index-CIVdT9gH.d.ts +0 -24
- package/lib/index-Dvb6OQET.d.ts +0 -16
- package/lib/key_pair-D16Om3fY.d.ts +0 -16
- package/lib/key_stores/browser-index.d.ts +0 -2
- package/lib/key_stores/browser-index.js +0 -37
- package/lib/key_stores/browser_local_storage_key_store.d.ts +0 -1
- package/lib/key_stores/browser_local_storage_key_store.js +0 -28
- package/lib/key_stores/in_memory_key_store.d.ts +0 -1
- package/lib/key_stores/in_memory_key_store.js +0 -28
- package/lib/key_stores/index.d.ts +0 -3
- package/lib/key_stores/index.js +0 -40
- package/lib/key_stores/keystore.d.ts +0 -1
- package/lib/key_stores/keystore.js +0 -28
- package/lib/key_stores/merge_key_store.d.ts +0 -1
- package/lib/key_stores/merge_key_store.js +0 -28
- package/lib/key_stores/unencrypted_file_system_keystore.d.ts +0 -1
- package/lib/key_stores/unencrypted_file_system_keystore.js +0 -30
- package/lib/near.d.ts +0 -109
- package/lib/near.js +0 -89
- package/lib/rpc_errors-BbA15mFX.d.ts +0 -12
- package/lib/serialize-DKM2UWTl.d.ts +0 -10
- package/lib/signer.d.ts +0 -1
- package/lib/signer.js +0 -30
- package/lib/transaction-C81hWIM7.d.ts +0 -52
- package/lib/transaction.d.ts +0 -3
- package/lib/transaction.js +0 -101
- package/lib/utils/enums.d.ts +0 -1
- package/lib/utils/enums.js +0 -28
- package/lib/utils/errors.d.ts +0 -2
- package/lib/utils/errors.js +0 -43
- package/lib/utils/exponential-backoff.d.ts +0 -2
- package/lib/utils/exponential-backoff.js +0 -25
- package/lib/utils/key_pair.d.ts +0 -2
- package/lib/utils/key_pair.js +0 -36
- package/lib/utils/logger.d.ts +0 -1
- package/lib/utils/logger.js +0 -28
- package/lib/utils/logging.d.ts +0 -1
- package/lib/utils/logging.js +0 -30
- package/lib/utils/rpc_errors.d.ts +0 -1
- package/lib/utils/rpc_errors.js +0 -36
- package/lib/utils/serialize.d.ts +0 -2
- package/lib/utils/serialize.js +0 -37
- package/lib/validators-q97R8D1k.d.ts +0 -11
- package/lib/validators.d.ts +0 -1
- package/lib/validators.js +0 -34
package/README.md
CHANGED
|
@@ -1,18 +1,92 @@
|
|
|
1
1
|
# NEAR JavaScript API
|
|
2
2
|
|
|
3
|
+
[](https://actions-badge.atrox.dev/near/near-api-js/goto)
|
|
4
|
+
[](https://gitpod.io/#https://github.com/near/near-api-js)
|
|
5
|
+
|
|
3
6
|
NEAR JavaScript API is a complete library to interact with the NEAR blockchain. You can use it in the browser, or in Node.js runtime.
|
|
4
7
|
|
|
5
8
|
## Documentation
|
|
6
9
|
|
|
7
|
-
- [Learn how to use](https://docs.near.org/tools/near-api
|
|
10
|
+
- [Learn how to use](https://docs.near.org/tools/near-api) the library in your project
|
|
8
11
|
|
|
9
12
|
- Read the [TypeDoc API](https://near.github.io/near-api-js/) documentation
|
|
10
13
|
|
|
11
|
-
- [Cookbook](
|
|
14
|
+
- [Cookbook](./packages/cookbook) with common use cases
|
|
12
15
|
|
|
13
16
|
- To quickly get started with integrating NEAR in a _web browser_, read our [Web Frontend integration](https://docs.near.org/develop/integrate/frontend) article.
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
## Contribute to this library
|
|
19
|
+
|
|
20
|
+
1. Install dependencies
|
|
21
|
+
|
|
22
|
+
pnpm install
|
|
23
|
+
|
|
24
|
+
2. Run continuous build with:
|
|
25
|
+
|
|
26
|
+
pnpm -r compile -w
|
|
27
|
+
|
|
28
|
+
### Publish
|
|
29
|
+
|
|
30
|
+
Prepare `dist` version by running:
|
|
31
|
+
|
|
32
|
+
pnpm dist
|
|
33
|
+
|
|
34
|
+
### Integration Test
|
|
35
|
+
|
|
36
|
+
Start the node by following instructions from [nearcore](https://github.com/nearprotocol/nearcore), then
|
|
37
|
+
|
|
38
|
+
pnpm test
|
|
39
|
+
|
|
40
|
+
Tests use sample contract from `near-hello` npm package, see https://github.com/nearprotocol/near-hello
|
|
41
|
+
|
|
42
|
+
### E2E Test
|
|
43
|
+
|
|
44
|
+
From the root directory, run the following commands:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
cd e2e
|
|
48
|
+
pnpm install --ignore-workspace
|
|
49
|
+
pnpm test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The `--ignore-workspace` flag is required because the `e2e` project is intentionally excluded from the workspace.
|
|
53
|
+
This setup ensures that packages are installed just like a real application would — as standalone builds. Workspace linking would not allow this, as it forces symlinks instead of proper package installations.
|
|
54
|
+
|
|
55
|
+
### Update error schema
|
|
56
|
+
|
|
57
|
+
Follow next steps:
|
|
58
|
+
|
|
59
|
+
1. [Optionally, set a specific hash for the commit with errors in the nearcore](https://github.com/near/near-api-js/blob/master/packages/utils/fetch_error_schema.js#L4-L5)
|
|
60
|
+
2. Fetch new schema: `node fetch_error_schema.js`
|
|
61
|
+
3. `pnpm build` and `pnpm test` to check tests still work
|
|
62
|
+
4. `pnpm changeset` to generate a changeset with a minor bump for the @near-js/utils package
|
|
63
|
+
5. commit all changes and submit a PR on GitHub
|
|
64
|
+
|
|
65
|
+
## Packages
|
|
66
|
+
|
|
67
|
+

|
|
68
|
+
<!-- https://www.figma.com/file/TzAPceViAbYW6A6KAuEMCe/NAJ-packages?t=N9nlkGBoAx9FYxoN-1 -->
|
|
69
|
+
|
|
70
|
+
- [accounts](https://github.com/near/near-api-js/tree/master/packages/accounts) account creation & management
|
|
71
|
+
- [crypto](https://github.com/near/near-api-js/tree/master/packages/crypto) cryptographic key pairs & signing
|
|
72
|
+
- [keystores](https://github.com/near/near-api-js/tree/master/packages/keystores) general-purpose key persistence & management
|
|
73
|
+
- [keystores-browser](https://github.com/near/near-api-js/tree/master/packages/keystores-browser) browser keystores
|
|
74
|
+
- [keystores-node](https://github.com/near/near-api-js/tree/master/packages/keystores-node) NodeJS keystores
|
|
75
|
+
- [providers](https://github.com/near/near-api-js/tree/master/packages/providers) RPC interaction
|
|
76
|
+
- [transactions](https://github.com/near/near-api-js/tree/master/packages/transactions) transaction composition & signing
|
|
77
|
+
- [types](https://github.com/near/near-api-js/tree/master/packages/types) common types
|
|
78
|
+
- [utils](https://github.com/near/near-api-js/tree/master/packages/utils) common methods
|
|
79
|
+
- [wallet-account](https://github.com/near/near-api-js/tree/master/packages/wallet-account) accounts in browser-based wallets
|
|
80
|
+
|
|
81
|
+
## Example Templates
|
|
82
|
+
|
|
83
|
+
To help you get started quickly, we have prepared example templates for popular frameworks:
|
|
84
|
+
|
|
85
|
+
- [React Template](https://github.com/LimeChain/nearjs-react-app)
|
|
86
|
+
- [Nuxt.js Template](https://github.com/near/near-api-js-template-nuxt)
|
|
87
|
+
- [Angular Template](https://github.com/near/near-api-js-template-angular)
|
|
88
|
+
|
|
89
|
+
## License
|
|
16
90
|
|
|
17
91
|
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
|
|
18
|
-
See [LICENSE](
|
|
92
|
+
See [LICENSE](LICENSE) and [LICENSE-APACHE](LICENSE-APACHE) for details.
|