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.
Files changed (194) hide show
  1. package/README.md +78 -4
  2. package/lib/accounts/abi_types.d.ts +716 -0
  3. package/lib/accounts/abi_types.js +1 -0
  4. package/lib/accounts/account.d.ts +310 -0
  5. package/lib/accounts/account.js +473 -0
  6. package/lib/accounts/errors.d.ts +13 -0
  7. package/lib/accounts/errors.js +20 -0
  8. package/lib/accounts/index.d.ts +4 -0
  9. package/lib/accounts/index.js +3 -0
  10. package/lib/accounts/typed_contract.d.ts +136 -0
  11. package/lib/accounts/typed_contract.js +93 -0
  12. package/lib/crypto/constants.d.ts +12 -0
  13. package/lib/crypto/constants.js +11 -0
  14. package/lib/crypto/index.d.ts +7 -0
  15. package/lib/crypto/index.js +5 -0
  16. package/lib/crypto/key_pair.d.ts +15 -0
  17. package/lib/crypto/key_pair.js +40 -0
  18. package/lib/crypto/key_pair_base.d.ts +12 -0
  19. package/lib/crypto/key_pair_base.js +2 -0
  20. package/lib/crypto/key_pair_ed25519.d.ts +52 -0
  21. package/lib/crypto/key_pair_ed25519.js +74 -0
  22. package/lib/crypto/key_pair_secp256k1.d.ts +39 -0
  23. package/lib/crypto/key_pair_secp256k1.js +68 -0
  24. package/lib/crypto/public_key.d.ts +59 -0
  25. package/lib/crypto/public_key.js +165 -0
  26. package/lib/index.d.ts +8 -24
  27. package/lib/index.js +28 -45
  28. package/lib/nep413/index.d.ts +4 -0
  29. package/lib/nep413/index.js +2 -0
  30. package/lib/nep413/schema.d.ts +9 -0
  31. package/lib/nep413/schema.js +20 -0
  32. package/lib/nep413/sign.d.ts +8 -0
  33. package/lib/nep413/sign.js +6 -0
  34. package/lib/nep413/verify.d.ts +11 -0
  35. package/lib/nep413/verify.js +17 -0
  36. package/lib/providers/exponential-backoff.d.ts +1 -0
  37. package/lib/providers/exponential-backoff.js +17 -0
  38. package/lib/providers/failover-rpc-provider.d.ts +134 -1
  39. package/lib/providers/failover-rpc-provider.js +216 -28
  40. package/lib/providers/fetch_json.d.ts +31 -0
  41. package/lib/providers/fetch_json.js +67 -0
  42. package/lib/providers/index.d.ts +4 -3
  43. package/lib/providers/index.js +3 -48
  44. package/lib/providers/json-rpc-provider.d.ts +167 -2
  45. package/lib/providers/json-rpc-provider.js +406 -33
  46. package/lib/providers/provider.d.ts +88 -3
  47. package/lib/providers/provider.js +5 -160
  48. package/lib/signers/index.d.ts +3 -0
  49. package/lib/signers/index.js +2 -0
  50. package/lib/signers/key_pair_signer.d.ts +12 -0
  51. package/lib/signers/key_pair_signer.js +22 -0
  52. package/lib/signers/signer.d.ts +56 -0
  53. package/lib/signers/signer.js +74 -0
  54. package/lib/tokens/ft/format.d.ts +9 -0
  55. package/lib/tokens/ft/format.js +61 -0
  56. package/lib/tokens/ft/index.d.ts +108 -0
  57. package/lib/tokens/ft/index.js +132 -0
  58. package/lib/tokens/index.d.ts +3 -0
  59. package/lib/tokens/index.js +3 -0
  60. package/lib/tokens/mainnet/index.d.ts +4 -0
  61. package/lib/tokens/mainnet/index.js +19 -0
  62. package/lib/tokens/mt/index.d.ts +81 -0
  63. package/lib/tokens/mt/index.js +114 -0
  64. package/lib/tokens/nft/index.d.ts +42 -0
  65. package/lib/tokens/nft/index.js +27 -0
  66. package/lib/tokens/testnet/index.d.ts +4 -0
  67. package/lib/tokens/testnet/index.js +19 -0
  68. package/lib/transactions/action_creators.d.ts +117 -0
  69. package/lib/transactions/action_creators.js +161 -0
  70. package/lib/transactions/actions.d.ts +143 -0
  71. package/lib/transactions/actions.js +115 -0
  72. package/lib/transactions/create_transaction.d.ts +14 -0
  73. package/lib/transactions/create_transaction.js +22 -0
  74. package/lib/transactions/delegate.d.ts +28 -0
  75. package/lib/transactions/delegate.js +94 -0
  76. package/lib/transactions/index.d.ts +6 -0
  77. package/lib/transactions/index.js +6 -0
  78. package/lib/transactions/prefix.d.ts +21 -0
  79. package/lib/transactions/prefix.js +35 -0
  80. package/lib/transactions/schema.d.ts +93 -0
  81. package/lib/transactions/schema.js +255 -0
  82. package/lib/transactions/signature.d.ts +23 -0
  83. package/lib/transactions/signature.js +46 -0
  84. package/lib/types/accounts.d.ts +20 -0
  85. package/lib/types/accounts.js +1 -0
  86. package/lib/types/assignable.d.ts +3 -0
  87. package/lib/types/assignable.js +8 -0
  88. package/lib/types/enum.d.ts +4 -0
  89. package/lib/types/enum.js +12 -0
  90. package/lib/types/errors.d.ts +15 -0
  91. package/lib/types/errors.js +22 -0
  92. package/lib/types/index.d.ts +5 -0
  93. package/lib/types/index.js +5 -0
  94. package/lib/types/provider/index.d.ts +7 -0
  95. package/lib/types/provider/index.js +2 -0
  96. package/lib/types/provider/light_client.d.ts +41 -0
  97. package/lib/types/provider/light_client.js +9 -0
  98. package/lib/types/provider/protocol.d.ts +184 -0
  99. package/lib/types/provider/protocol.js +5 -0
  100. package/lib/types/provider/request.d.ts +34 -0
  101. package/lib/types/provider/request.js +5 -0
  102. package/lib/types/provider/response.d.ts +164 -0
  103. package/lib/types/provider/response.js +12 -0
  104. package/lib/types/provider/validator.d.ts +40 -0
  105. package/lib/types/provider/validator.js +5 -0
  106. package/lib/utils/errors/error_messages.d.ts +70 -0
  107. package/lib/utils/errors/error_messages.js +69 -0
  108. package/lib/utils/errors/errors.d.ts +3 -0
  109. package/lib/utils/errors/errors.js +2 -0
  110. package/lib/utils/errors/index.d.ts +2 -0
  111. package/lib/utils/errors/index.js +2 -0
  112. package/lib/utils/errors/rpc_error_schema.d.ts +805 -0
  113. package/lib/utils/errors/rpc_error_schema.js +930 -0
  114. package/lib/utils/errors/rpc_errors.d.ts +11 -0
  115. package/lib/utils/errors/rpc_errors.js +114 -0
  116. package/lib/utils/format.d.ts +40 -1
  117. package/lib/utils/format.js +124 -34
  118. package/lib/utils/index.d.ts +5 -9
  119. package/lib/utils/index.js +5 -65
  120. package/lib/utils/provider.d.ts +3 -0
  121. package/lib/utils/provider.js +14 -0
  122. package/lib/utils/utils.d.ts +1 -0
  123. package/lib/utils/utils.js +3 -0
  124. package/lib/utils/validators.d.ts +24 -0
  125. package/lib/utils/validators.js +83 -0
  126. package/package.json +61 -44
  127. package/lib/account.d.ts +0 -8
  128. package/lib/account.js +0 -40
  129. package/lib/account_creator-Bs61dnmU.d.ts +0 -10
  130. package/lib/account_creator.d.ts +0 -1
  131. package/lib/account_creator.js +0 -32
  132. package/lib/browser-connect.d.ts +0 -21
  133. package/lib/browser-connect.js +0 -44
  134. package/lib/browser-index-RhYalP0h.d.ts +0 -14
  135. package/lib/browser-index.d.ts +0 -23
  136. package/lib/browser-index.js +0 -43
  137. package/lib/common-index.d.ts +0 -20
  138. package/lib/common-index.js +0 -70
  139. package/lib/connect.d.ts +0 -43
  140. package/lib/connect.js +0 -72
  141. package/lib/connection.d.ts +0 -1
  142. package/lib/connection.js +0 -28
  143. package/lib/constants.d.ts +0 -1
  144. package/lib/constants.js +0 -28
  145. package/lib/contract.d.ts +0 -1
  146. package/lib/contract.js +0 -35
  147. package/lib/enums-BOxGXwY_.d.ts +0 -8
  148. package/lib/format-BlG-d3wc.d.ts +0 -11
  149. package/lib/index-BDdRUK93.d.ts +0 -21
  150. package/lib/index-CIVdT9gH.d.ts +0 -24
  151. package/lib/index-Dvb6OQET.d.ts +0 -16
  152. package/lib/key_pair-D16Om3fY.d.ts +0 -16
  153. package/lib/key_stores/browser-index.d.ts +0 -2
  154. package/lib/key_stores/browser-index.js +0 -37
  155. package/lib/key_stores/browser_local_storage_key_store.d.ts +0 -1
  156. package/lib/key_stores/browser_local_storage_key_store.js +0 -28
  157. package/lib/key_stores/in_memory_key_store.d.ts +0 -1
  158. package/lib/key_stores/in_memory_key_store.js +0 -28
  159. package/lib/key_stores/index.d.ts +0 -3
  160. package/lib/key_stores/index.js +0 -40
  161. package/lib/key_stores/keystore.d.ts +0 -1
  162. package/lib/key_stores/keystore.js +0 -28
  163. package/lib/key_stores/merge_key_store.d.ts +0 -1
  164. package/lib/key_stores/merge_key_store.js +0 -28
  165. package/lib/key_stores/unencrypted_file_system_keystore.d.ts +0 -1
  166. package/lib/key_stores/unencrypted_file_system_keystore.js +0 -30
  167. package/lib/near.d.ts +0 -109
  168. package/lib/near.js +0 -89
  169. package/lib/rpc_errors-BbA15mFX.d.ts +0 -12
  170. package/lib/serialize-DKM2UWTl.d.ts +0 -10
  171. package/lib/signer.d.ts +0 -1
  172. package/lib/signer.js +0 -30
  173. package/lib/transaction-C81hWIM7.d.ts +0 -52
  174. package/lib/transaction.d.ts +0 -3
  175. package/lib/transaction.js +0 -101
  176. package/lib/utils/enums.d.ts +0 -1
  177. package/lib/utils/enums.js +0 -28
  178. package/lib/utils/errors.d.ts +0 -2
  179. package/lib/utils/errors.js +0 -43
  180. package/lib/utils/exponential-backoff.d.ts +0 -2
  181. package/lib/utils/exponential-backoff.js +0 -25
  182. package/lib/utils/key_pair.d.ts +0 -2
  183. package/lib/utils/key_pair.js +0 -36
  184. package/lib/utils/logger.d.ts +0 -1
  185. package/lib/utils/logger.js +0 -28
  186. package/lib/utils/logging.d.ts +0 -1
  187. package/lib/utils/logging.js +0 -30
  188. package/lib/utils/rpc_errors.d.ts +0 -1
  189. package/lib/utils/rpc_errors.js +0 -36
  190. package/lib/utils/serialize.d.ts +0 -2
  191. package/lib/utils/serialize.js +0 -37
  192. package/lib/validators-q97R8D1k.d.ts +0 -11
  193. package/lib/validators.d.ts +0 -1
  194. package/lib/validators.js +0 -34
package/README.md CHANGED
@@ -1,18 +1,92 @@
1
1
  # NEAR JavaScript API
2
2
 
3
+ [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fnear%2Fnear-api-js%2Fbadge&style=flat&label=Build)](https://actions-badge.atrox.dev/near/near-api-js/goto)
4
+ [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](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-js/quick-reference) the library in your project
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](https://github.com/near/near-api-js/blob/master/packages/cookbook/README.md) with common use cases
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
- # License
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
+ ![Package Architecture in Onion Diagram](./docs/package-architecture.png)
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](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.
92
+ See [LICENSE](LICENSE) and [LICENSE-APACHE](LICENSE-APACHE) for details.