@h2protocol/v4-client-js 1.3.42-h2.1 → 1.3.44-h2.1

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 (136) hide show
  1. package/.env +1 -1
  2. package/.eslintignore +1 -1
  3. package/.eslintrc.js +15 -15
  4. package/.gitleaks.toml +24 -24
  5. package/.gitleaksignore +1 -1
  6. package/.nvmrc +1 -1
  7. package/.prettierignore +3 -3
  8. package/.prettierrc.json +6 -6
  9. package/.releaserc +10 -10
  10. package/.vscode/launch.json +11 -11
  11. package/.yarn/install-state.gz +0 -0
  12. package/.yarnrc.yml +1 -1
  13. package/LICENSE +13 -13
  14. package/README.md +83 -83
  15. package/__tests__/clients/composite-client.test.ts +140 -140
  16. package/__tests__/helpers/baseClients.ts +23 -23
  17. package/__tests__/helpers/constants.ts +131 -131
  18. package/__tests__/lib/helpers.test.ts +53 -53
  19. package/__tests__/lib/util.test.ts +77 -77
  20. package/__tests__/lib/validation.test.ts +290 -290
  21. package/__tests__/modules/client/AccountEndpoints.test.ts +236 -236
  22. package/__tests__/modules/client/FaucetEndpoint.test.ts +14 -14
  23. package/__tests__/modules/client/MarketsEndpoints.test.ts +84 -84
  24. package/__tests__/modules/client/Transfers.test.ts +44 -44
  25. package/__tests__/modules/client/UtilityEndpoints.test.ts +29 -29
  26. package/__tests__/modules/client/ValidatorGetEndpoints.test.ts +50 -50
  27. package/__tests__/modules/client/ValidatorPostEndpoints.test.ts +52 -52
  28. package/__tests__/modules/client/constants.ts +5 -5
  29. package/__tests__/modules/onboarding.test.ts +66 -66
  30. package/build/cjs/examples/native_examples.js +28 -28
  31. package/build/cjs/package.json +1 -1
  32. package/build/cjs/src/clients/composite-client.js +2 -2
  33. package/build/cjs/src/clients/lib/registry.js +229 -10
  34. package/build/cjs/src/clients/modules/composer.js +3 -8
  35. package/build/cjs/src/clients/types.js +2 -6
  36. package/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  37. package/build/esm/examples/native_examples.js +28 -28
  38. package/build/esm/src/clients/composite-client.js +2 -2
  39. package/build/esm/src/clients/lib/registry.d.ts.map +1 -1
  40. package/build/esm/src/clients/lib/registry.js +230 -11
  41. package/build/esm/src/clients/modules/composer.d.ts +18 -4
  42. package/build/esm/src/clients/modules/composer.d.ts.map +1 -1
  43. package/build/esm/src/clients/modules/composer.js +2 -6
  44. package/build/esm/src/clients/types.js +1 -3
  45. package/build/esm/tsconfig.esm.tsbuildinfo +1 -1
  46. package/commitlint.config.js +8 -8
  47. package/examples/account_endpoints.ts +129 -129
  48. package/examples/batch_cancel_orders_example.ts +130 -130
  49. package/examples/composite_example.ts +65 -65
  50. package/examples/constants.ts +42 -42
  51. package/examples/faucet_endpoint.ts +24 -24
  52. package/examples/gov_add_new_market.json +64 -64
  53. package/examples/gov_add_new_market.ts +95 -95
  54. package/examples/human_readable_orders.json +86 -86
  55. package/examples/human_readable_short_term_orders.json +42 -42
  56. package/examples/json-encoding.ts +33 -33
  57. package/examples/long_term_order_cancel_example.ts +87 -87
  58. package/examples/markets_endpoints.ts +134 -134
  59. package/examples/native_examples.ts +151 -151
  60. package/examples/noble_example.ts +107 -107
  61. package/examples/optimal_node.ts +70 -70
  62. package/examples/permissioned_keys_example.ts +162 -162
  63. package/examples/raw_orders.json +130 -130
  64. package/examples/short_term_order_cancel_example.ts +68 -68
  65. package/examples/short_term_order_composite_example.ts +80 -80
  66. package/examples/test.ts +65 -65
  67. package/examples/transfer_example_deposit.ts +28 -28
  68. package/examples/transfer_example_send.ts +60 -60
  69. package/examples/transfer_example_subaccount_transfer.ts +29 -29
  70. package/examples/transfer_example_withdraw.ts +31 -31
  71. package/examples/transfer_example_withdraw_other.ts +60 -60
  72. package/examples/utility_endpoints.ts +42 -42
  73. package/examples/validator_get_example.ts +160 -160
  74. package/examples/validator_post_example.ts +81 -81
  75. package/examples/wallet_address.ts +18 -18
  76. package/examples/websocket_example.ts +44 -44
  77. package/examples/websocket_orderbook_example.ts +239 -239
  78. package/jest.config.js +12 -12
  79. package/jest.globalSetup.js +5 -5
  80. package/jest.setup.js +1 -1
  81. package/package.json +122 -122
  82. package/protobuf/transfer.proto +105 -105
  83. package/protobuf/tx.proto +47 -47
  84. package/scripts/bump_version.sh +16 -16
  85. package/scripts/generate-cctp-protos.sh +41 -41
  86. package/scripts/mobile_build_pack.sh +5 -5
  87. package/scripts/publish-if-not-exists.sh +21 -21
  88. package/src/clients/composite-client.ts +1533 -1533
  89. package/src/clients/constants.ts +379 -379
  90. package/src/clients/faucet-client.ts +48 -48
  91. package/src/clients/helpers/chain-helpers.ts +239 -239
  92. package/src/clients/helpers/request-helpers.ts +71 -71
  93. package/src/clients/indexer-client.ts +61 -61
  94. package/src/clients/lib/axios/axiosRequest.ts +41 -41
  95. package/src/clients/lib/axios/errors.ts +41 -41
  96. package/src/clients/lib/axios/index.ts +7 -7
  97. package/src/clients/lib/axios/types.ts +6 -6
  98. package/src/clients/lib/cctpProto.ts +4197 -4197
  99. package/src/clients/lib/errors.ts +61 -61
  100. package/src/clients/lib/registry.ts +453 -228
  101. package/src/clients/modules/account.ts +406 -406
  102. package/src/clients/modules/composer.ts +26 -8
  103. package/src/clients/modules/get.ts +637 -637
  104. package/src/clients/modules/local-wallet.ts +79 -79
  105. package/src/clients/modules/markets.ts +167 -167
  106. package/src/clients/modules/post.ts +1018 -1018
  107. package/src/clients/modules/proto-includes.ts +37 -37
  108. package/src/clients/modules/rest.ts +40 -40
  109. package/src/clients/modules/signer.ts +139 -139
  110. package/src/clients/modules/tendermintClient.ts +164 -164
  111. package/src/clients/modules/utility.ts +47 -47
  112. package/src/clients/modules/vault.ts +23 -23
  113. package/src/clients/native.ts +1469 -1469
  114. package/src/clients/noble-client.ts +108 -108
  115. package/src/clients/socket-client.ts +331 -331
  116. package/src/clients/subaccount.ts +57 -57
  117. package/src/clients/types.ts +193 -193
  118. package/src/clients/validator-client.ts +103 -103
  119. package/src/index.ts +20 -20
  120. package/src/lib/bigint-long.ts +274 -274
  121. package/src/lib/constants.ts +28 -28
  122. package/src/lib/errors.ts +38 -38
  123. package/src/lib/helpers.ts +124 -124
  124. package/src/lib/long.ts +21 -21
  125. package/src/lib/onboarding.ts +96 -96
  126. package/src/lib/trading-key-utils.ts +136 -136
  127. package/src/lib/utils.ts +83 -83
  128. package/src/lib/validation.ts +196 -196
  129. package/src/network_optimizer.ts +132 -132
  130. package/src/types.ts +44 -44
  131. package/tasks.json +16 -16
  132. package/tsconfig.base.json +16 -16
  133. package/tsconfig.cjs.json +9 -9
  134. package/tsconfig.eslint.json +14 -14
  135. package/tsconfig.esm.json +10 -10
  136. package/webpack.config.js +56 -56
package/.env CHANGED
@@ -1 +1 @@
1
- SERVICE_NAME=v4-client-js
1
+ SERVICE_NAME=v4-client-js
package/.eslintignore CHANGED
@@ -1,2 +1,2 @@
1
- __native__/*.js
1
+ __native__/*.js
2
2
  __native__/__ios__/*.js
package/.eslintrc.js CHANGED
@@ -1,15 +1,15 @@
1
- module.exports = {
2
- extends: ['./node_modules/@dydxprotocol/node-service-base-dev/.eslintrc.js', 'prettier'],
3
-
4
- parser: '@typescript-eslint/parser',
5
- // Override the base configuration to set the correct tsconfigRootDir.
6
- parserOptions: {
7
- tsconfigRootDir: __dirname,
8
- },
9
-
10
- ignorePatterns: ['**/examples/**/*.js', '**/codegen/**/*.ts'],
11
-
12
- rules: {
13
- 'no-console': 'off',
14
- },
15
- };
1
+ module.exports = {
2
+ extends: ['./node_modules/@dydxprotocol/node-service-base-dev/.eslintrc.js', 'prettier'],
3
+
4
+ parser: '@typescript-eslint/parser',
5
+ // Override the base configuration to set the correct tsconfigRootDir.
6
+ parserOptions: {
7
+ tsconfigRootDir: __dirname,
8
+ },
9
+
10
+ ignorePatterns: ['**/examples/**/*.js', '**/codegen/**/*.ts'],
11
+
12
+ rules: {
13
+ 'no-console': 'off',
14
+ },
15
+ };
package/.gitleaks.toml CHANGED
@@ -1,24 +1,24 @@
1
- # Title for the gitleaks configuration file.
2
- title = "Gitleaks title"
3
-
4
- [extend]
5
- # useDefault will extend the base configuration with the default gitleaks config:
6
- # https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml
7
- useDefault = true
8
-
9
- [allowlist]
10
- paths = [
11
- '''gitleaks\.toml''',
12
- ]
13
-
14
- regexTarget = "line"
15
- regexes = [
16
- '''clientId''',
17
- '''isEd25519Pubkey''',
18
- '''isSecp256k1Pubkey''',
19
- '''Ed25519Keypair;''',
20
- '''Secp256k1Pubkey''',
21
- '''e92a6595c934c991d3b3e987ea9b3125bf61a076deab3a9cb519787b7b3e8d77''',
22
- '''8d805729d752cbeccbbce08531cc38b271031ae250f7b67bd5f1bf3827c46d87''',
23
- '''44de77c4ee23e1008d4ebf23c9b4b6dca0fd29aadb0950a5bf96dc81b4f4bfc3''',
24
- ]
1
+ # Title for the gitleaks configuration file.
2
+ title = "Gitleaks title"
3
+
4
+ [extend]
5
+ # useDefault will extend the base configuration with the default gitleaks config:
6
+ # https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml
7
+ useDefault = true
8
+
9
+ [allowlist]
10
+ paths = [
11
+ '''gitleaks\.toml''',
12
+ ]
13
+
14
+ regexTarget = "line"
15
+ regexes = [
16
+ '''clientId''',
17
+ '''isEd25519Pubkey''',
18
+ '''isSecp256k1Pubkey''',
19
+ '''Ed25519Keypair;''',
20
+ '''Secp256k1Pubkey''',
21
+ '''e92a6595c934c991d3b3e987ea9b3125bf61a076deab3a9cb519787b7b3e8d77''',
22
+ '''8d805729d752cbeccbbce08531cc38b271031ae250f7b67bd5f1bf3827c46d87''',
23
+ '''44de77c4ee23e1008d4ebf23c9b4b6dca0fd29aadb0950a5bf96dc81b4f4bfc3''',
24
+ ]
package/.gitleaksignore CHANGED
@@ -1 +1 @@
1
- ee48563a588a0d4bef717c4a64288d676b1f2c84:.coveralls.yml:generic-api-key:1
1
+ ee48563a588a0d4bef717c4a64288d676b1f2c84:.coveralls.yml:generic-api-key:1
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v20.8.1
1
+ v20.8.1
package/.prettierignore CHANGED
@@ -1,3 +1,3 @@
1
- __native__/*.js
2
- __native__/__ios__/*.js
3
- node_modules/
1
+ __native__/*.js
2
+ __native__/__ios__/*.js
3
+ node_modules/
package/.prettierrc.json CHANGED
@@ -1,6 +1,6 @@
1
- {
2
- "printWidth": 100,
3
- "singleQuote": true,
4
- "trailingComma": "all",
5
- "jsxBracketSameLine": false
6
- }
1
+ {
2
+ "printWidth": 100,
3
+ "singleQuote": true,
4
+ "trailingComma": "all",
5
+ "jsxBracketSameLine": false
6
+ }
package/.releaserc CHANGED
@@ -1,10 +1,10 @@
1
- {
2
- "branches": ["main"],
3
- "tagFormat": "v4-client-js@${version}",
4
- "plugins": [
5
- "@semantic-release/commit-analyzer",
6
- "@semantic-release/release-notes-generator",
7
- "@semantic-release/changelog",
8
- "@semantic-release/npm"
9
- ]
10
- }
1
+ {
2
+ "branches": ["main"],
3
+ "tagFormat": "v4-client-js@${version}",
4
+ "plugins": [
5
+ "@semantic-release/commit-analyzer",
6
+ "@semantic-release/release-notes-generator",
7
+ "@semantic-release/changelog",
8
+ "@semantic-release/npm"
9
+ ]
10
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "version": "0.2.0",
3
- "configurations": [
4
- {
5
- "name": "Node.js - Debug Current File",
6
- "type": "node",
7
- "request": "launch",
8
- "program": "${file}"
9
- }
10
- ]
11
- }
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Node.js - Debug Current File",
6
+ "type": "node",
7
+ "request": "launch",
8
+ "program": "${file}"
9
+ }
10
+ ]
11
+ }
Binary file
package/.yarnrc.yml CHANGED
@@ -1 +1 @@
1
- nodeLinker: node-modules
1
+ nodeLinker: node-modules
package/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
- Copyright (C) 2025 dYdX Trading Inc.
2
-
3
- Subject to your compliance with applicable law and the v4 Terms of Use, available at dydx.exchange/legal, you are granted the right to use the Software (defined below) under the terms of the license as set forth below; provided, however, that if you violate any such applicable law in your use of the Software, all of your rights and licenses to use (including any rights to reproduce, distribute, install or modify) the Software will automatically and immediately terminate.
4
-
5
- The "Software" shall mean the following: dydxprotocol/v4-clients and any dYdX or dYdX Trading Inc. repository reflecting a copy of, or linking to, this license.
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy of this Software and associated documentation files, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
-
10
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
-
12
- For more information about this software, see https://dydx.exchange.
13
- Copyright (C) 2025 dYdX Trading Inc.
1
+ Copyright (C) 2025 dYdX Trading Inc.
2
+
3
+ Subject to your compliance with applicable law and the v4 Terms of Use, available at dydx.exchange/legal, you are granted the right to use the Software (defined below) under the terms of the license as set forth below; provided, however, that if you violate any such applicable law in your use of the Software, all of your rights and licenses to use (including any rights to reproduce, distribute, install or modify) the Software will automatically and immediately terminate.
4
+
5
+ The "Software" shall mean the following: dydxprotocol/v4-clients and any dYdX or dYdX Trading Inc. repository reflecting a copy of, or linking to, this license.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this Software and associated documentation files, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+
12
+ For more information about this software, see https://dydx.exchange.
13
+ Copyright (C) 2025 dYdX Trading Inc.
package/README.md CHANGED
@@ -1,83 +1,83 @@
1
- <p align="center"><img src="https://dydx.exchange/icon.svg?" width="256" /></p>
2
-
3
- <h1 align="center">dYdX Chain Client for Javascript</h1>
4
-
5
- <div align="center">
6
- <a href='https://www.npmjs.com/package/@dydxprotocol/v4-client-js'>
7
- <img src='https://img.shields.io/npm/v/@dydxprotocol/v4-client-js.svg' alt='npm'/>
8
- </a>
9
- <a href='https://github.com/dydxprotocol/v4-clients/blob/main/v4-client-js/LICENSE'>
10
- <img src='https://img.shields.io/badge/License-AGPL_v3-blue.svg' alt='License' />
11
- </a>
12
- </div>
13
-
14
- The v4-Client Typescript client is used for placing transactions and querying the dYdX chain.
15
-
16
- ## Development
17
-
18
- `v4-client-js` uses node `v18` for development, see the .nvmrc file [here](https://github.com/dydxprotocol/v4-clients/blob/main/v4-client-js/.nvmrc).
19
- You can use `nvm` to manage different versions of node.
20
-
21
- ```
22
- nvm install
23
- nvm use
24
- nvm alias default $(nvm version) # optional
25
- ```
26
-
27
- You can run the following commands to ensure that you are running the correct `node` and `npm` versions.
28
-
29
- ```
30
- node -v # expected: v20.x.x (should match .nvmrc)
31
- npm -v # expected: 10.x.x
32
- ```
33
-
34
- ### 1. Clone or fork the V4 clients repo
35
-
36
- ```bash
37
- git clone git@github.com:dydxprotocol/v4-clients.git
38
- ```
39
-
40
- ### 2. Go to one of the examples
41
-
42
- - Go to `v4-client-js/examples`
43
-
44
- ```bash
45
- cd v4-client-js/examples
46
- ```
47
-
48
- These examples by default use a test account with `DYDX_TEST_MNEMONIC` from the TS client library under `v4-client-js/examples/constants`, but you can use any test address that you own.
49
-
50
- ### 3. Run the scripts with node
51
-
52
- ```bash
53
- npm install
54
- npm run build
55
- ```
56
-
57
- You should now see a `/build/examples` dir generated with JS files. We will use node to run these scripts
58
-
59
- - Open a terminal to run an example, e.g. account_endpoints.
60
-
61
- ```bash
62
- node ../build/examples/composite_example.js
63
-
64
- ```
65
-
66
- Everytime you change the TS code, you need to run `npm run build` again, before you execute using node.
67
-
68
- ## Single-JS for mobile apps
69
-
70
- Mobile apps needs to load JS as a single JS file. To build, run
71
-
72
- ```
73
- npm run webpack
74
- ```
75
-
76
- The file is generated in **native**/**ios**/v4-native-client.js
77
- Pending: Different configurations may be needed to generate JS for Android app
78
-
79
- ## Release
80
-
81
- Using the `npm version` command will update the appropriate version tags within the package locks and also will add a git tag with the version number..
82
- For example `npm version minor` will perform the necessary changes for a minor version release. After the change is merged, a GitHub action will
83
- [publish](https://github.com/dydxprotocol/v4-clients/blob/master/.github/workflows/js-publish.yml) the new release.
1
+ <p align="center"><img src="https://dydx.exchange/icon.svg?" width="256" /></p>
2
+
3
+ <h1 align="center">dYdX Chain Client for Javascript</h1>
4
+
5
+ <div align="center">
6
+ <a href='https://www.npmjs.com/package/@dydxprotocol/v4-client-js'>
7
+ <img src='https://img.shields.io/npm/v/@dydxprotocol/v4-client-js.svg' alt='npm'/>
8
+ </a>
9
+ <a href='https://github.com/dydxprotocol/v4-clients/blob/main/v4-client-js/LICENSE'>
10
+ <img src='https://img.shields.io/badge/License-AGPL_v3-blue.svg' alt='License' />
11
+ </a>
12
+ </div>
13
+
14
+ The v4-Client Typescript client is used for placing transactions and querying the dYdX chain.
15
+
16
+ ## Development
17
+
18
+ `v4-client-js` uses node `v18` for development, see the .nvmrc file [here](https://github.com/dydxprotocol/v4-clients/blob/main/v4-client-js/.nvmrc).
19
+ You can use `nvm` to manage different versions of node.
20
+
21
+ ```
22
+ nvm install
23
+ nvm use
24
+ nvm alias default $(nvm version) # optional
25
+ ```
26
+
27
+ You can run the following commands to ensure that you are running the correct `node` and `npm` versions.
28
+
29
+ ```
30
+ node -v # expected: v20.x.x (should match .nvmrc)
31
+ npm -v # expected: 10.x.x
32
+ ```
33
+
34
+ ### 1. Clone or fork the V4 clients repo
35
+
36
+ ```bash
37
+ git clone git@github.com:dydxprotocol/v4-clients.git
38
+ ```
39
+
40
+ ### 2. Go to one of the examples
41
+
42
+ - Go to `v4-client-js/examples`
43
+
44
+ ```bash
45
+ cd v4-client-js/examples
46
+ ```
47
+
48
+ These examples by default use a test account with `DYDX_TEST_MNEMONIC` from the TS client library under `v4-client-js/examples/constants`, but you can use any test address that you own.
49
+
50
+ ### 3. Run the scripts with node
51
+
52
+ ```bash
53
+ npm install
54
+ npm run build
55
+ ```
56
+
57
+ You should now see a `/build/examples` dir generated with JS files. We will use node to run these scripts
58
+
59
+ - Open a terminal to run an example, e.g. account_endpoints.
60
+
61
+ ```bash
62
+ node ../build/examples/composite_example.js
63
+
64
+ ```
65
+
66
+ Everytime you change the TS code, you need to run `npm run build` again, before you execute using node.
67
+
68
+ ## Single-JS for mobile apps
69
+
70
+ Mobile apps needs to load JS as a single JS file. To build, run
71
+
72
+ ```
73
+ npm run webpack
74
+ ```
75
+
76
+ The file is generated in **native**/**ios**/v4-native-client.js
77
+ Pending: Different configurations may be needed to generate JS for Android app
78
+
79
+ ## Release
80
+
81
+ Using the `npm version` command will update the appropriate version tags within the package locks and also will add a git tag with the version number..
82
+ For example `npm version minor` will perform the necessary changes for a minor version release. After the change is merged, a GitHub action will
83
+ [publish](https://github.com/dydxprotocol/v4-clients/blob/master/.github/workflows/js-publish.yml) the new release.
@@ -1,140 +1,140 @@
1
- import { Authenticator, AuthenticatorType, Network } from '../../src';
2
- import { CompositeClient } from '../../src/clients/composite-client'
3
-
4
- describe('CompositeClient', () => {
5
- describe('validateAuthenticators', () => {
6
- const network = Network.staging();
7
-
8
- it('Validates top level AnyOf authenticators', async () => {
9
- const client = await CompositeClient.connect(network);
10
- const auth: Authenticator = {
11
- type: AuthenticatorType.ANY_OF,
12
- config: [
13
- { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
14
- { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
15
- ],
16
- }
17
- expect(client.validateAuthenticator(auth)).toEqual(true);
18
- });
19
-
20
- it('Fails top level AnyOf authenticators with non-signature nested authenticator', async () => {
21
- const client = await CompositeClient.connect(network);
22
- const auth: Authenticator = {
23
- type: AuthenticatorType.ANY_OF,
24
- config: [
25
- { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
26
- { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
27
- ],
28
- }
29
- expect(client.validateAuthenticator(auth)).toEqual(false);
30
- });
31
-
32
- it('Validates top level AllOf authenticators', async () => {
33
- const client = await CompositeClient.connect(network);
34
- const auth: Authenticator = {
35
- type: AuthenticatorType.ALL_OF,
36
- config: [
37
- { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
38
- { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
39
- ],
40
- }
41
- expect(client.validateAuthenticator(auth)).toEqual(true);
42
- });
43
-
44
- it('Fails top level AllOf authenticators, without signature verification', async () => {
45
- const client = await CompositeClient.connect(network);
46
- const auth: Authenticator = {
47
- type: AuthenticatorType.ALL_OF,
48
- config: [
49
- { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
50
- { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
51
- ],
52
- }
53
- expect(client.validateAuthenticator(auth)).toEqual(false);
54
- });
55
-
56
- it('Validates nested anyOf authenticators', async () => {
57
- const client = await CompositeClient.connect(network);
58
- const nestedAnyOf = {
59
- type: AuthenticatorType.ANY_OF,
60
- config: [
61
- { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
62
- { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
63
- ]
64
- }
65
- const signatureVerification = {
66
- type: AuthenticatorType.SIGNATURE_VERIFICATION,
67
- config: ""
68
- }
69
-
70
- const auth: Authenticator = {
71
- type: AuthenticatorType.ALL_OF,
72
- config: [signatureVerification, nestedAnyOf],
73
- };
74
- expect(client.validateAuthenticator(auth)).toEqual(true);
75
- });
76
-
77
- it('Validates nested allOf authenticators', async () => {
78
- const client = await CompositeClient.connect(network);
79
- const nestedAllOf = {
80
- type: AuthenticatorType.ALL_OF,
81
- config: [
82
- { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
83
- { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
84
- ]
85
- }
86
- const messageVerification = {
87
- type: AuthenticatorType.MESSAGE_FILTER,
88
- config: ""
89
- }
90
-
91
- const auth: Authenticator = {
92
- type: AuthenticatorType.ALL_OF,
93
- config: [messageVerification, nestedAllOf],
94
- };
95
- expect(client.validateAuthenticator(auth)).toEqual(true);
96
- });
97
-
98
- it('Fails nested anyOf signatureVerification authenticators', async () => {
99
- const client = await CompositeClient.connect(network);
100
- const nestedAnyOf = {
101
- type: AuthenticatorType.ANY_OF,
102
- config: [
103
- { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
104
- { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
105
- ]
106
- }
107
- const messageVerification = {
108
- type: AuthenticatorType.MESSAGE_FILTER,
109
- config: ""
110
- }
111
-
112
- const auth: Authenticator = {
113
- type: AuthenticatorType.ALL_OF,
114
- config: [messageVerification, nestedAnyOf],
115
- };
116
- expect(client.validateAuthenticator(auth)).toEqual(false);
117
- });
118
-
119
- it('Fails nested anyOf authenticators', async () => {
120
- const client = await CompositeClient.connect(network);
121
- const nestedAnyOf = {
122
- type: AuthenticatorType.ANY_OF,
123
- config: [
124
- { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
125
- { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
126
- ]
127
- }
128
- const messageVerification = {
129
- type: AuthenticatorType.MESSAGE_FILTER,
130
- config: ""
131
- }
132
-
133
- const auth: Authenticator = {
134
- type: AuthenticatorType.ANY_OF,
135
- config: [messageVerification, nestedAnyOf],
136
- };
137
- expect(client.validateAuthenticator(auth)).toEqual(false);
138
- });
139
- });
140
- });
1
+ import { Authenticator, AuthenticatorType, Network } from '../../src';
2
+ import { CompositeClient } from '../../src/clients/composite-client'
3
+
4
+ describe('CompositeClient', () => {
5
+ describe('validateAuthenticators', () => {
6
+ const network = Network.staging();
7
+
8
+ it('Validates top level AnyOf authenticators', async () => {
9
+ const client = await CompositeClient.connect(network);
10
+ const auth: Authenticator = {
11
+ type: AuthenticatorType.ANY_OF,
12
+ config: [
13
+ { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
14
+ { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
15
+ ],
16
+ }
17
+ expect(client.validateAuthenticator(auth)).toEqual(true);
18
+ });
19
+
20
+ it('Fails top level AnyOf authenticators with non-signature nested authenticator', async () => {
21
+ const client = await CompositeClient.connect(network);
22
+ const auth: Authenticator = {
23
+ type: AuthenticatorType.ANY_OF,
24
+ config: [
25
+ { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
26
+ { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
27
+ ],
28
+ }
29
+ expect(client.validateAuthenticator(auth)).toEqual(false);
30
+ });
31
+
32
+ it('Validates top level AllOf authenticators', async () => {
33
+ const client = await CompositeClient.connect(network);
34
+ const auth: Authenticator = {
35
+ type: AuthenticatorType.ALL_OF,
36
+ config: [
37
+ { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
38
+ { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
39
+ ],
40
+ }
41
+ expect(client.validateAuthenticator(auth)).toEqual(true);
42
+ });
43
+
44
+ it('Fails top level AllOf authenticators, without signature verification', async () => {
45
+ const client = await CompositeClient.connect(network);
46
+ const auth: Authenticator = {
47
+ type: AuthenticatorType.ALL_OF,
48
+ config: [
49
+ { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
50
+ { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
51
+ ],
52
+ }
53
+ expect(client.validateAuthenticator(auth)).toEqual(false);
54
+ });
55
+
56
+ it('Validates nested anyOf authenticators', async () => {
57
+ const client = await CompositeClient.connect(network);
58
+ const nestedAnyOf = {
59
+ type: AuthenticatorType.ANY_OF,
60
+ config: [
61
+ { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
62
+ { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
63
+ ]
64
+ }
65
+ const signatureVerification = {
66
+ type: AuthenticatorType.SIGNATURE_VERIFICATION,
67
+ config: ""
68
+ }
69
+
70
+ const auth: Authenticator = {
71
+ type: AuthenticatorType.ALL_OF,
72
+ config: [signatureVerification, nestedAnyOf],
73
+ };
74
+ expect(client.validateAuthenticator(auth)).toEqual(true);
75
+ });
76
+
77
+ it('Validates nested allOf authenticators', async () => {
78
+ const client = await CompositeClient.connect(network);
79
+ const nestedAllOf = {
80
+ type: AuthenticatorType.ALL_OF,
81
+ config: [
82
+ { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
83
+ { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
84
+ ]
85
+ }
86
+ const messageVerification = {
87
+ type: AuthenticatorType.MESSAGE_FILTER,
88
+ config: ""
89
+ }
90
+
91
+ const auth: Authenticator = {
92
+ type: AuthenticatorType.ALL_OF,
93
+ config: [messageVerification, nestedAllOf],
94
+ };
95
+ expect(client.validateAuthenticator(auth)).toEqual(true);
96
+ });
97
+
98
+ it('Fails nested anyOf signatureVerification authenticators', async () => {
99
+ const client = await CompositeClient.connect(network);
100
+ const nestedAnyOf = {
101
+ type: AuthenticatorType.ANY_OF,
102
+ config: [
103
+ { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
104
+ { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
105
+ ]
106
+ }
107
+ const messageVerification = {
108
+ type: AuthenticatorType.MESSAGE_FILTER,
109
+ config: ""
110
+ }
111
+
112
+ const auth: Authenticator = {
113
+ type: AuthenticatorType.ALL_OF,
114
+ config: [messageVerification, nestedAnyOf],
115
+ };
116
+ expect(client.validateAuthenticator(auth)).toEqual(false);
117
+ });
118
+
119
+ it('Fails nested anyOf authenticators', async () => {
120
+ const client = await CompositeClient.connect(network);
121
+ const nestedAnyOf = {
122
+ type: AuthenticatorType.ANY_OF,
123
+ config: [
124
+ { type: AuthenticatorType.MESSAGE_FILTER, config: "" },
125
+ { type: AuthenticatorType.SIGNATURE_VERIFICATION, config: "" },
126
+ ]
127
+ }
128
+ const messageVerification = {
129
+ type: AuthenticatorType.MESSAGE_FILTER,
130
+ config: ""
131
+ }
132
+
133
+ const auth: Authenticator = {
134
+ type: AuthenticatorType.ANY_OF,
135
+ config: [messageVerification, nestedAnyOf],
136
+ };
137
+ expect(client.validateAuthenticator(auth)).toEqual(false);
138
+ });
139
+ });
140
+ });