@argonprotocol/mainchain 1.1.0-rc.1 → 1.1.0-rc.3

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 (150) hide show
  1. package/README.md +110 -3
  2. package/lib/cli.cjs +3108 -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 +3104 -0
  7. package/lib/cli.js.map +1 -0
  8. package/lib/clis/index.cjs +3127 -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 +3108 -0
  13. package/lib/clis/index.js.map +1 -0
  14. package/lib/index.cjs +2433 -0
  15. package/lib/index.cjs.map +1 -0
  16. package/lib/index.d.cts +11550 -0
  17. package/lib/index.d.ts +11550 -0
  18. package/lib/index.js +2363 -0
  19. package/lib/index.js.map +1 -0
  20. package/package.json +37 -46
  21. package/lib/cjs/WageProtector.d.ts +0 -37
  22. package/lib/cjs/WageProtector.js +0 -64
  23. package/lib/cjs/WageProtector.js.map +0 -1
  24. package/lib/cjs/__test__/WageProtector.test.d.ts +0 -1
  25. package/lib/cjs/__test__/WageProtector.test.js +0 -28
  26. package/lib/cjs/__test__/WageProtector.test.js.map +0 -1
  27. package/lib/cjs/examples/decodePkcs.d.ts +0 -1
  28. package/lib/cjs/examples/decodePkcs.js +0 -48
  29. package/lib/cjs/examples/decodePkcs.js.map +0 -1
  30. package/lib/cjs/examples/findSs58Formats.d.ts +0 -1
  31. package/lib/cjs/examples/findSs58Formats.js +0 -42
  32. package/lib/cjs/examples/findSs58Formats.js.map +0 -1
  33. package/lib/cjs/index.d.ts +0 -32
  34. package/lib/cjs/index.js +0 -60
  35. package/lib/cjs/index.js.map +0 -1
  36. package/lib/cjs/interfaces/augment-api-consts.d.ts +0 -455
  37. package/lib/cjs/interfaces/augment-api-consts.js +0 -8
  38. package/lib/cjs/interfaces/augment-api-consts.js.map +0 -1
  39. package/lib/cjs/interfaces/augment-api-errors.d.ts +0 -960
  40. package/lib/cjs/interfaces/augment-api-errors.js +0 -8
  41. package/lib/cjs/interfaces/augment-api-errors.js.map +0 -1
  42. package/lib/cjs/interfaces/augment-api-events.d.ts +0 -1698
  43. package/lib/cjs/interfaces/augment-api-events.js +0 -8
  44. package/lib/cjs/interfaces/augment-api-events.js.map +0 -1
  45. package/lib/cjs/interfaces/augment-api-query.d.ts +0 -1006
  46. package/lib/cjs/interfaces/augment-api-query.js +0 -8
  47. package/lib/cjs/interfaces/augment-api-query.js.map +0 -1
  48. package/lib/cjs/interfaces/augment-api-rpc.d.ts +0 -683
  49. package/lib/cjs/interfaces/augment-api-rpc.js +0 -8
  50. package/lib/cjs/interfaces/augment-api-rpc.js.map +0 -1
  51. package/lib/cjs/interfaces/augment-api-runtime.d.ts +0 -204
  52. package/lib/cjs/interfaces/augment-api-runtime.js +0 -8
  53. package/lib/cjs/interfaces/augment-api-runtime.js.map +0 -1
  54. package/lib/cjs/interfaces/augment-api-tx.d.ts +0 -1631
  55. package/lib/cjs/interfaces/augment-api-tx.js +0 -8
  56. package/lib/cjs/interfaces/augment-api-tx.js.map +0 -1
  57. package/lib/cjs/interfaces/augment-api.d.ts +0 -7
  58. package/lib/cjs/interfaces/augment-api.js +0 -12
  59. package/lib/cjs/interfaces/augment-api.js.map +0 -1
  60. package/lib/cjs/interfaces/augment-types.d.ts +0 -1316
  61. package/lib/cjs/interfaces/augment-types.js +0 -8
  62. package/lib/cjs/interfaces/augment-types.js.map +0 -1
  63. package/lib/cjs/interfaces/definitions.d.ts +0 -0
  64. package/lib/cjs/interfaces/definitions.js +0 -2
  65. package/lib/cjs/interfaces/definitions.js.map +0 -1
  66. package/lib/cjs/interfaces/lookup.d.ts +0 -3055
  67. package/lib/cjs/interfaces/lookup.js +0 -3329
  68. package/lib/cjs/interfaces/lookup.js.map +0 -1
  69. package/lib/cjs/interfaces/registry.d.ts +0 -254
  70. package/lib/cjs/interfaces/registry.js +0 -8
  71. package/lib/cjs/interfaces/registry.js.map +0 -1
  72. package/lib/cjs/interfaces/types-lookup.d.ts +0 -3022
  73. package/lib/cjs/interfaces/types-lookup.js +0 -8
  74. package/lib/cjs/interfaces/types-lookup.js.map +0 -1
  75. package/lib/cjs/package.json +0 -3
  76. package/lib/esm/WageProtector.d.ts +0 -37
  77. package/lib/esm/WageProtector.js +0 -60
  78. package/lib/esm/WageProtector.js.map +0 -1
  79. package/lib/esm/__test__/WageProtector.test.d.ts +0 -1
  80. package/lib/esm/__test__/WageProtector.test.js +0 -26
  81. package/lib/esm/__test__/WageProtector.test.js.map +0 -1
  82. package/lib/esm/examples/decodePkcs.d.ts +0 -1
  83. package/lib/esm/examples/decodePkcs.js +0 -45
  84. package/lib/esm/examples/decodePkcs.js.map +0 -1
  85. package/lib/esm/examples/findSs58Formats.d.ts +0 -1
  86. package/lib/esm/examples/findSs58Formats.js +0 -39
  87. package/lib/esm/examples/findSs58Formats.js.map +0 -1
  88. package/lib/esm/index.d.ts +0 -32
  89. package/lib/esm/index.js +0 -50
  90. package/lib/esm/index.js.map +0 -1
  91. package/lib/esm/interfaces/augment-api-consts.d.ts +0 -455
  92. package/lib/esm/interfaces/augment-api-consts.js +0 -6
  93. package/lib/esm/interfaces/augment-api-consts.js.map +0 -1
  94. package/lib/esm/interfaces/augment-api-errors.d.ts +0 -960
  95. package/lib/esm/interfaces/augment-api-errors.js +0 -6
  96. package/lib/esm/interfaces/augment-api-errors.js.map +0 -1
  97. package/lib/esm/interfaces/augment-api-events.d.ts +0 -1698
  98. package/lib/esm/interfaces/augment-api-events.js +0 -6
  99. package/lib/esm/interfaces/augment-api-events.js.map +0 -1
  100. package/lib/esm/interfaces/augment-api-query.d.ts +0 -1006
  101. package/lib/esm/interfaces/augment-api-query.js +0 -6
  102. package/lib/esm/interfaces/augment-api-query.js.map +0 -1
  103. package/lib/esm/interfaces/augment-api-rpc.d.ts +0 -683
  104. package/lib/esm/interfaces/augment-api-rpc.js +0 -6
  105. package/lib/esm/interfaces/augment-api-rpc.js.map +0 -1
  106. package/lib/esm/interfaces/augment-api-runtime.d.ts +0 -204
  107. package/lib/esm/interfaces/augment-api-runtime.js +0 -6
  108. package/lib/esm/interfaces/augment-api-runtime.js.map +0 -1
  109. package/lib/esm/interfaces/augment-api-tx.d.ts +0 -1631
  110. package/lib/esm/interfaces/augment-api-tx.js +0 -6
  111. package/lib/esm/interfaces/augment-api-tx.js.map +0 -1
  112. package/lib/esm/interfaces/augment-api.d.ts +0 -7
  113. package/lib/esm/interfaces/augment-api.js +0 -10
  114. package/lib/esm/interfaces/augment-api.js.map +0 -1
  115. package/lib/esm/interfaces/augment-types.d.ts +0 -1316
  116. package/lib/esm/interfaces/augment-types.js +0 -6
  117. package/lib/esm/interfaces/augment-types.js.map +0 -1
  118. package/lib/esm/interfaces/definitions.d.ts +0 -0
  119. package/lib/esm/interfaces/definitions.js +0 -2
  120. package/lib/esm/interfaces/definitions.js.map +0 -1
  121. package/lib/esm/interfaces/lookup.d.ts +0 -3055
  122. package/lib/esm/interfaces/lookup.js +0 -3327
  123. package/lib/esm/interfaces/lookup.js.map +0 -1
  124. package/lib/esm/interfaces/registry.d.ts +0 -254
  125. package/lib/esm/interfaces/registry.js +0 -6
  126. package/lib/esm/interfaces/registry.js.map +0 -1
  127. package/lib/esm/interfaces/types-lookup.d.ts +0 -3022
  128. package/lib/esm/interfaces/types-lookup.js +0 -6
  129. package/lib/esm/interfaces/types-lookup.js.map +0 -1
  130. package/lib/tsconfig-cjs.tsbuildinfo +0 -1
  131. package/lib/tsconfig-types.tsbuildinfo +0 -1
  132. package/lib/tsconfig.tsbuildinfo +0 -1
  133. package/lib/types/WageProtector.d.ts +0 -37
  134. package/lib/types/__test__/WageProtector.test.d.ts +0 -1
  135. package/lib/types/examples/decodePkcs.d.ts +0 -1
  136. package/lib/types/examples/findSs58Formats.d.ts +0 -1
  137. package/lib/types/index.d.ts +0 -32
  138. package/lib/types/interfaces/augment-api-consts.d.ts +0 -455
  139. package/lib/types/interfaces/augment-api-errors.d.ts +0 -960
  140. package/lib/types/interfaces/augment-api-events.d.ts +0 -1698
  141. package/lib/types/interfaces/augment-api-query.d.ts +0 -1006
  142. package/lib/types/interfaces/augment-api-rpc.d.ts +0 -683
  143. package/lib/types/interfaces/augment-api-runtime.d.ts +0 -204
  144. package/lib/types/interfaces/augment-api-tx.d.ts +0 -1631
  145. package/lib/types/interfaces/augment-api.d.ts +0 -7
  146. package/lib/types/interfaces/augment-types.d.ts +0 -1316
  147. package/lib/types/interfaces/definitions.d.ts +0 -0
  148. package/lib/types/interfaces/lookup.d.ts +0 -3055
  149. package/lib/types/interfaces/registry.d.ts +0 -254
  150. package/lib/types/interfaces/types-lookup.d.ts +0 -3022
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.