@argonprotocol/mainchain 1.0.18 → 1.1.0-rc.2

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 (156) hide show
  1. package/README.md +110 -3
  2. package/lib/cli.cjs +3078 -0
  3. package/lib/cli.cjs.map +1 -0
  4. package/lib/cli.d.cts +1 -0
  5. package/lib/cli.d.ts +1 -0
  6. package/lib/cli.js +3073 -0
  7. package/lib/cli.js.map +1 -0
  8. package/lib/clis/index.cjs +3097 -0
  9. package/lib/clis/index.cjs.map +1 -0
  10. package/lib/clis/index.d.cts +26 -0
  11. package/lib/clis/index.d.ts +26 -0
  12. package/lib/clis/index.js +3077 -0
  13. package/lib/clis/index.js.map +1 -0
  14. package/lib/index.cjs +2402 -0
  15. package/lib/index.cjs.map +1 -0
  16. package/lib/index.d.cts +11542 -0
  17. package/lib/index.d.ts +11542 -0
  18. package/lib/index.js +2333 -0
  19. package/lib/index.js.map +1 -0
  20. package/lib/test-utils/index.cjs +2933 -0
  21. package/lib/test-utils/index.cjs.map +1 -0
  22. package/lib/test-utils/index.d.cts +180 -0
  23. package/lib/test-utils/index.d.ts +180 -0
  24. package/lib/test-utils/index.js +2915 -0
  25. package/lib/test-utils/index.js.map +1 -0
  26. package/package.json +50 -45
  27. package/lib/cjs/WageProtector.d.ts +0 -37
  28. package/lib/cjs/WageProtector.js +0 -64
  29. package/lib/cjs/WageProtector.js.map +0 -1
  30. package/lib/cjs/__test__/WageProtector.test.d.ts +0 -1
  31. package/lib/cjs/__test__/WageProtector.test.js +0 -28
  32. package/lib/cjs/__test__/WageProtector.test.js.map +0 -1
  33. package/lib/cjs/examples/decodePkcs.d.ts +0 -1
  34. package/lib/cjs/examples/decodePkcs.js +0 -48
  35. package/lib/cjs/examples/decodePkcs.js.map +0 -1
  36. package/lib/cjs/examples/findSs58Formats.d.ts +0 -1
  37. package/lib/cjs/examples/findSs58Formats.js +0 -42
  38. package/lib/cjs/examples/findSs58Formats.js.map +0 -1
  39. package/lib/cjs/index.d.ts +0 -32
  40. package/lib/cjs/index.js +0 -60
  41. package/lib/cjs/index.js.map +0 -1
  42. package/lib/cjs/interfaces/augment-api-consts.d.ts +0 -442
  43. package/lib/cjs/interfaces/augment-api-consts.js +0 -8
  44. package/lib/cjs/interfaces/augment-api-consts.js.map +0 -1
  45. package/lib/cjs/interfaces/augment-api-errors.d.ts +0 -919
  46. package/lib/cjs/interfaces/augment-api-errors.js +0 -8
  47. package/lib/cjs/interfaces/augment-api-errors.js.map +0 -1
  48. package/lib/cjs/interfaces/augment-api-events.d.ts +0 -1675
  49. package/lib/cjs/interfaces/augment-api-events.js +0 -8
  50. package/lib/cjs/interfaces/augment-api-events.js.map +0 -1
  51. package/lib/cjs/interfaces/augment-api-query.d.ts +0 -988
  52. package/lib/cjs/interfaces/augment-api-query.js +0 -8
  53. package/lib/cjs/interfaces/augment-api-query.js.map +0 -1
  54. package/lib/cjs/interfaces/augment-api-rpc.d.ts +0 -683
  55. package/lib/cjs/interfaces/augment-api-rpc.js +0 -8
  56. package/lib/cjs/interfaces/augment-api-rpc.js.map +0 -1
  57. package/lib/cjs/interfaces/augment-api-runtime.d.ts +0 -204
  58. package/lib/cjs/interfaces/augment-api-runtime.js +0 -8
  59. package/lib/cjs/interfaces/augment-api-runtime.js.map +0 -1
  60. package/lib/cjs/interfaces/augment-api-tx.d.ts +0 -1605
  61. package/lib/cjs/interfaces/augment-api-tx.js +0 -8
  62. package/lib/cjs/interfaces/augment-api-tx.js.map +0 -1
  63. package/lib/cjs/interfaces/augment-api.d.ts +0 -7
  64. package/lib/cjs/interfaces/augment-api.js +0 -12
  65. package/lib/cjs/interfaces/augment-api.js.map +0 -1
  66. package/lib/cjs/interfaces/augment-types.d.ts +0 -1316
  67. package/lib/cjs/interfaces/augment-types.js +0 -8
  68. package/lib/cjs/interfaces/augment-types.js.map +0 -1
  69. package/lib/cjs/interfaces/definitions.d.ts +0 -0
  70. package/lib/cjs/interfaces/definitions.js +0 -2
  71. package/lib/cjs/interfaces/definitions.js.map +0 -1
  72. package/lib/cjs/interfaces/lookup.d.ts +0 -2999
  73. package/lib/cjs/interfaces/lookup.js +0 -3262
  74. package/lib/cjs/interfaces/lookup.js.map +0 -1
  75. package/lib/cjs/interfaces/registry.d.ts +0 -250
  76. package/lib/cjs/interfaces/registry.js +0 -8
  77. package/lib/cjs/interfaces/registry.js.map +0 -1
  78. package/lib/cjs/interfaces/types-lookup.d.ts +0 -2974
  79. package/lib/cjs/interfaces/types-lookup.js +0 -8
  80. package/lib/cjs/interfaces/types-lookup.js.map +0 -1
  81. package/lib/cjs/package.json +0 -3
  82. package/lib/esm/WageProtector.d.ts +0 -37
  83. package/lib/esm/WageProtector.js +0 -60
  84. package/lib/esm/WageProtector.js.map +0 -1
  85. package/lib/esm/__test__/WageProtector.test.d.ts +0 -1
  86. package/lib/esm/__test__/WageProtector.test.js +0 -26
  87. package/lib/esm/__test__/WageProtector.test.js.map +0 -1
  88. package/lib/esm/examples/decodePkcs.d.ts +0 -1
  89. package/lib/esm/examples/decodePkcs.js +0 -45
  90. package/lib/esm/examples/decodePkcs.js.map +0 -1
  91. package/lib/esm/examples/findSs58Formats.d.ts +0 -1
  92. package/lib/esm/examples/findSs58Formats.js +0 -39
  93. package/lib/esm/examples/findSs58Formats.js.map +0 -1
  94. package/lib/esm/index.d.ts +0 -32
  95. package/lib/esm/index.js +0 -50
  96. package/lib/esm/index.js.map +0 -1
  97. package/lib/esm/interfaces/augment-api-consts.d.ts +0 -442
  98. package/lib/esm/interfaces/augment-api-consts.js +0 -6
  99. package/lib/esm/interfaces/augment-api-consts.js.map +0 -1
  100. package/lib/esm/interfaces/augment-api-errors.d.ts +0 -919
  101. package/lib/esm/interfaces/augment-api-errors.js +0 -6
  102. package/lib/esm/interfaces/augment-api-errors.js.map +0 -1
  103. package/lib/esm/interfaces/augment-api-events.d.ts +0 -1675
  104. package/lib/esm/interfaces/augment-api-events.js +0 -6
  105. package/lib/esm/interfaces/augment-api-events.js.map +0 -1
  106. package/lib/esm/interfaces/augment-api-query.d.ts +0 -988
  107. package/lib/esm/interfaces/augment-api-query.js +0 -6
  108. package/lib/esm/interfaces/augment-api-query.js.map +0 -1
  109. package/lib/esm/interfaces/augment-api-rpc.d.ts +0 -683
  110. package/lib/esm/interfaces/augment-api-rpc.js +0 -6
  111. package/lib/esm/interfaces/augment-api-rpc.js.map +0 -1
  112. package/lib/esm/interfaces/augment-api-runtime.d.ts +0 -204
  113. package/lib/esm/interfaces/augment-api-runtime.js +0 -6
  114. package/lib/esm/interfaces/augment-api-runtime.js.map +0 -1
  115. package/lib/esm/interfaces/augment-api-tx.d.ts +0 -1605
  116. package/lib/esm/interfaces/augment-api-tx.js +0 -6
  117. package/lib/esm/interfaces/augment-api-tx.js.map +0 -1
  118. package/lib/esm/interfaces/augment-api.d.ts +0 -7
  119. package/lib/esm/interfaces/augment-api.js +0 -10
  120. package/lib/esm/interfaces/augment-api.js.map +0 -1
  121. package/lib/esm/interfaces/augment-types.d.ts +0 -1316
  122. package/lib/esm/interfaces/augment-types.js +0 -6
  123. package/lib/esm/interfaces/augment-types.js.map +0 -1
  124. package/lib/esm/interfaces/definitions.d.ts +0 -0
  125. package/lib/esm/interfaces/definitions.js +0 -2
  126. package/lib/esm/interfaces/definitions.js.map +0 -1
  127. package/lib/esm/interfaces/lookup.d.ts +0 -2999
  128. package/lib/esm/interfaces/lookup.js +0 -3260
  129. package/lib/esm/interfaces/lookup.js.map +0 -1
  130. package/lib/esm/interfaces/registry.d.ts +0 -250
  131. package/lib/esm/interfaces/registry.js +0 -6
  132. package/lib/esm/interfaces/registry.js.map +0 -1
  133. package/lib/esm/interfaces/types-lookup.d.ts +0 -2974
  134. package/lib/esm/interfaces/types-lookup.js +0 -6
  135. package/lib/esm/interfaces/types-lookup.js.map +0 -1
  136. package/lib/tsconfig-cjs.tsbuildinfo +0 -1
  137. package/lib/tsconfig-types.tsbuildinfo +0 -1
  138. package/lib/tsconfig.tsbuildinfo +0 -1
  139. package/lib/types/WageProtector.d.ts +0 -37
  140. package/lib/types/__test__/WageProtector.test.d.ts +0 -1
  141. package/lib/types/examples/decodePkcs.d.ts +0 -1
  142. package/lib/types/examples/findSs58Formats.d.ts +0 -1
  143. package/lib/types/index.d.ts +0 -32
  144. package/lib/types/interfaces/augment-api-consts.d.ts +0 -442
  145. package/lib/types/interfaces/augment-api-errors.d.ts +0 -919
  146. package/lib/types/interfaces/augment-api-events.d.ts +0 -1675
  147. package/lib/types/interfaces/augment-api-query.d.ts +0 -988
  148. package/lib/types/interfaces/augment-api-rpc.d.ts +0 -683
  149. package/lib/types/interfaces/augment-api-runtime.d.ts +0 -204
  150. package/lib/types/interfaces/augment-api-tx.d.ts +0 -1605
  151. package/lib/types/interfaces/augment-api.d.ts +0 -7
  152. package/lib/types/interfaces/augment-types.d.ts +0 -1316
  153. package/lib/types/interfaces/definitions.d.ts +0 -0
  154. package/lib/types/interfaces/lookup.d.ts +0 -2999
  155. package/lib/types/interfaces/registry.d.ts +0 -250
  156. package/lib/types/interfaces/types-lookup.d.ts +0 -2974
package/README.md CHANGED
@@ -1,7 +1,16 @@
1
- This is a Node.js client for the Argon Protocol (https://argonprotocol.org). It is mostly autogenerated from the
2
- polkadot.js api (https://polkadot.js.org/api/).
1
+ This is a Node.js client for the Argon Protocol (https://argonprotocol.org). It has the following core features:
3
2
 
4
- ## Usage
3
+ 1. A typescript generated RPC client for the Argon Protocol.
4
+ 2. A CLI for interacting with a subset of the Argon Protocol (Mining Bidding, Vaults, Liquidity Pools, Bitcoin)
5
+ 3. A "Wage Protector" class that can be used to protect wages against inflation or deflation of the Argon.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @argonprotocol/mainchain
11
+ ```
12
+
13
+ ## Client Usage
5
14
 
6
15
  To create a client, you can use the `getClient(host)` function in the main module. This will return a client object that
7
16
  is typed to the argon apis.
@@ -47,3 +56,101 @@ interface IArgonCpiSnapshot {
47
56
  tick: bigint;
48
57
  }
49
58
  ```
59
+
60
+ ## Cli
61
+
62
+ To use this CLI, the easiest way is to define an .env file with the following variables (you can also provide these to
63
+ each command).
64
+
65
+ ```env
66
+ MAINCHAIN_URL=ws://localhost:9944
67
+ ACCOUNT_SURI=# a suri for the account
68
+ ACCOUNT_JSON_PATH=# a path to a polkadotjs extracted account json
69
+ ACCOUNT_PASSPHRASE=# a passphrase for the pjs json account
70
+ SUBACCOUNT_RANGE=# number of subaccounts to manage
71
+ KEYS_MNEMONIC=# a mnemonic for the keys to generate
72
+ ```
73
+
74
+ ### Setup
75
+
76
+ To perform actions like `bidding on mining seats`, this cli will need to run for a long period of time. The easiest way
77
+ to do so is to install it alongside a full node. This gives you a server that:
78
+
79
+ 1. Will stay alive.
80
+ 2. Can have signing keys installed without exposing apis.
81
+ 3. Is a trusted source to submit your bid apis through.
82
+
83
+ You can setup an account as per the files above by running this command to start:
84
+
85
+ ```bash
86
+ npx @argonprotocol/mainchain accounts create --path=.env.bob --account-suri=//Bob --register-keys=http://localhost:9944
87
+ ```
88
+
89
+ Or with an exported Polkadotjs account (eg, from Talisman, Polkadot Extension, etc):
90
+
91
+ ```bash
92
+ npx @argonprotocol/mainchain accounts create --path=.env.bob --account-file-path=./bob.json --account-passphrase=1234 --register-keys=http://localhost:9944
93
+ ```
94
+
95
+ This will register your keys with the local node and serve as your `--env` file for the rest of the commands.
96
+
97
+ ### Exporting PolkadotJs Keys
98
+
99
+ You can export encrypted json accounts from Polkadot.js to use in this tool.
100
+
101
+ 1. Go to the [Polkadot.js Apps](https://polkadot.js.org/apps/#/accounts).
102
+ 2. Click on the dropdown for the account you want to export.
103
+ 3. Click on the "Export Account" button.
104
+ 4. Enter a password to encrypt the JSON file.
105
+ 5. Move the file to somewhere accessible from where this tool is run (or to mounted docker volumes).
106
+ 6. Ensure your `.env.<account>` file has a relative path to this JSON file and the password you used to encrypt it.
107
+
108
+ ### Security Concerns (Bid Proxy Account)
109
+
110
+ You might find the idea of putting an account on your server with the private key to be too risky. You can optionally
111
+ create a proxy account for your bidder script using `npx @argonprotocol/mainchain mining create-bid-proxy`. You will
112
+ need to run this from a machine with access to your full account keys (either via export or Polkadotjs directly). This
113
+ will create a new `env`account file with the proxy details, which you'll use as your env file for the rest of the
114
+ commands. The proxy will only be able to make `bid` calls and will not be able to transfer funds or do anything else
115
+ with the account. This is a good way to limit the exposure of your main account keys.
116
+
117
+ NOTE: you will still pay fees from your proxy account, so ensure you keep this account loaded up with fees. This is a
118
+ major downside to this approach that we are still seeking to solve.
119
+
120
+ ### Commands
121
+
122
+ ```
123
+ Usage: Argon CLI [options] [command]
124
+
125
+ Options:
126
+ -e, --env <path> The path to the account .env file to load
127
+ -u, --mainchain-url <url> The mainchain URL to connect to (default: "wss://rpc.argon.network", env: MAINCHAIN_URL)
128
+ --account-file-path <jsonPath> The path to your json seed file from polkadotjs (env: ACCOUNT_JSON_PATH)
129
+ --account-suri <secretUri> A secret uri (suri) to use for the account (env: ACCOUNT_SURI)
130
+ --account-passphrase <password> The password for your seed file (env: ACCOUNT_PASSPHRASE)
131
+ -s, --subaccounts <range> Restrict this operation to a subset of the subaccounts (eg, 0-10) (env: SUBACCOUNT_RANGE)
132
+ -h, --help display help for command
133
+
134
+ Commands:
135
+ accounts Manage subaccounts from a single keypair
136
+ vaults Monitor vaults and manage securitization
137
+ mining Watch mining seats or setup bidding
138
+ liquidity-pools Monitor or bond to liquidity pools
139
+ bitcoin Wait for bitcoin space
140
+ help [command] display help for command
141
+ ```
142
+
143
+ ### Example Commands
144
+
145
+ Create a dynamic bid for a mining seat, maxed at 10 argons per seat. Without a budget, this will use up to 100 argons (
146
+ eg, 10 seats).
147
+
148
+ ```bash
149
+ npx @argonprotocol/mainchain --env=accounts/.env.bob mining bid --min-argons=1 --max-argons=10 --bid-increment=0.1
150
+ ```
151
+
152
+ ### Subaccounts
153
+
154
+ If you want to work with subaccounts during `consolidate` or setup of an account you can use the `-s, --subaccounts`
155
+ flag to specify which subaccount to work with. `-s=0-9` is the default. You can also use `-s=0,1,2` to specify a list of
156
+ subaccounts. You can also use `-s=0-2,4` to specify a range and a list of subaccounts.