@argonprotocol/mainchain 1.3.0 → 1.3.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.
- package/README.md +38 -29
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
This is a Node.js client for the Argon Protocol (https://argonprotocol.org). It has the following
|
|
1
|
+
This is a Node.js client for the Argon Protocol (https://argonprotocol.org). It has the following
|
|
2
|
+
core features:
|
|
2
3
|
|
|
3
4
|
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
|
|
5
|
-
|
|
5
|
+
2. A CLI for interacting with a subset of the Argon Protocol (Mining Bidding, Vaults, Liquidity
|
|
6
|
+
Pools, Bitcoin)
|
|
7
|
+
3. A "Wage Protector" class that can be used to protect wages against inflation or deflation of the
|
|
8
|
+
Argon.
|
|
6
9
|
|
|
7
10
|
## Installation
|
|
8
11
|
|
|
@@ -12,13 +15,13 @@ npm install @argonprotocol/mainchain
|
|
|
12
15
|
|
|
13
16
|
## Client Usage
|
|
14
17
|
|
|
15
|
-
To create a client, you can use the `getClient(host)` function in the main module. This will return
|
|
16
|
-
is typed to the argon apis.
|
|
18
|
+
To create a client, you can use the `getClient(host)` function in the main module. This will return
|
|
19
|
+
a client object that is typed to the argon apis.
|
|
17
20
|
|
|
18
21
|
## Wage Protector
|
|
19
22
|
|
|
20
|
-
If you want to protect wages against inflation or deflation of the Argon, there is a `WageProtector`
|
|
21
|
-
used. You can use it a single time:
|
|
23
|
+
If you want to protect wages against inflation or deflation of the Argon, there is a `WageProtector`
|
|
24
|
+
class that can be used. You can use it a single time:
|
|
22
25
|
|
|
23
26
|
```javascript
|
|
24
27
|
const { WageProtector } = require('@argonprotocol/mainchain');
|
|
@@ -37,7 +40,8 @@ const { unsubscribe } = await WageProtector.subscribe(client, protectedPrice =>
|
|
|
37
40
|
});
|
|
38
41
|
```
|
|
39
42
|
|
|
40
|
-
Each `WageProtector` instance has the details of the Argon Target Price and USD price at the time of
|
|
43
|
+
Each `WageProtector` instance has the details of the Argon Target Price and USD price at the time of
|
|
44
|
+
creation.
|
|
41
45
|
|
|
42
46
|
```typescript
|
|
43
47
|
interface IArgonCpiSnapshot {
|
|
@@ -56,8 +60,8 @@ interface IArgonCpiSnapshot {
|
|
|
56
60
|
|
|
57
61
|
The library has a few classes that are used to interact with the Argon Protocol.
|
|
58
62
|
|
|
59
|
-
`clis` - this is a collection of cli commands and helpers. Included here are two helpers to read and
|
|
60
|
-
wallets from Polkadot.js or a wallet like [Talisman](https://talisman.xyz/).
|
|
63
|
+
`clis` - this is a collection of cli commands and helpers. Included here are two helpers to read and
|
|
64
|
+
store encrypted wallets from Polkadot.js or a wallet like [Talisman](https://talisman.xyz/).
|
|
61
65
|
|
|
62
66
|
`Accountset.ts` - manage subaccounts from a single keypair
|
|
63
67
|
|
|
@@ -141,8 +145,8 @@ const { unsubscribe } = await miningBids.onCohortChange({
|
|
|
141
145
|
|
|
142
146
|
## Cli
|
|
143
147
|
|
|
144
|
-
To use this CLI, the easiest way is to define an .env file with the following variables (you can
|
|
145
|
-
each command).
|
|
148
|
+
To use this CLI, the easiest way is to define an .env file with the following variables (you can
|
|
149
|
+
also provide these to each command).
|
|
146
150
|
|
|
147
151
|
```env
|
|
148
152
|
MAINCHAIN_URL=ws://localhost:9944
|
|
@@ -155,8 +159,8 @@ KEYS_MNEMONIC=# a mnemonic for the keys to generate
|
|
|
155
159
|
|
|
156
160
|
### Setup
|
|
157
161
|
|
|
158
|
-
To perform actions like `bidding on mining seats`, this cli will need to run for a long period of
|
|
159
|
-
to do so is to install it alongside a full node. This gives you a server that:
|
|
162
|
+
To perform actions like `bidding on mining seats`, this cli will need to run for a long period of
|
|
163
|
+
time. The easiest way to do so is to install it alongside a full node. This gives you a server that:
|
|
160
164
|
|
|
161
165
|
1. Will stay alive.
|
|
162
166
|
2. Can have signing keys installed without exposing apis.
|
|
@@ -174,7 +178,8 @@ Or with an exported Polkadotjs account (eg, from Talisman, Polkadot Extension, e
|
|
|
174
178
|
npx @argonprotocol/mainchain accounts create --path=.env.bob --account-file-path=./bob.json --account-passphrase=1234 --register-keys=http://localhost:9944
|
|
175
179
|
```
|
|
176
180
|
|
|
177
|
-
This will register your keys with the local node and serve as your `--env` file for the rest of the
|
|
181
|
+
This will register your keys with the local node and serve as your `--env` file for the rest of the
|
|
182
|
+
commands.
|
|
178
183
|
|
|
179
184
|
### Exporting PolkadotJs Keys
|
|
180
185
|
|
|
@@ -185,19 +190,22 @@ You can export encrypted json accounts from Polkadot.js to use in this tool.
|
|
|
185
190
|
3. Click on the "Export Account" button.
|
|
186
191
|
4. Enter a password to encrypt the JSON file.
|
|
187
192
|
5. Move the file to somewhere accessible from where this tool is run (or to mounted docker volumes).
|
|
188
|
-
6. Ensure your `.env.<account>` file has a relative path to this JSON file and the password you used
|
|
193
|
+
6. Ensure your `.env.<account>` file has a relative path to this JSON file and the password you used
|
|
194
|
+
to encrypt it.
|
|
189
195
|
|
|
190
196
|
### Security Concerns (Bid Proxy Account)
|
|
191
197
|
|
|
192
|
-
You might find the idea of putting an account on your server with the private key to be too risky.
|
|
193
|
-
create a proxy account for your bidder script using
|
|
194
|
-
need to run this from a machine
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
You might find the idea of putting an account on your server with the private key to be too risky.
|
|
199
|
+
You can optionally create a proxy account for your bidder script using
|
|
200
|
+
`npx @argonprotocol/mainchain mining create-bid-proxy`. You will need to run this from a machine
|
|
201
|
+
with access to your full account keys (either via export or Polkadotjs directly). This will create a
|
|
202
|
+
new `env`account file with the proxy details, which you'll use as your env file for the rest of the
|
|
203
|
+
commands. The proxy will only be able to make `bid` calls and will not be able to transfer funds or
|
|
204
|
+
do anything else with the account. This is a good way to limit the exposure of your main account
|
|
205
|
+
keys.
|
|
198
206
|
|
|
199
|
-
NOTE: you will still pay fees from your proxy account, so ensure you keep this account loaded up
|
|
200
|
-
major downside to this approach that we are still seeking to solve.
|
|
207
|
+
NOTE: you will still pay fees from your proxy account, so ensure you keep this account loaded up
|
|
208
|
+
with fees. This is a major downside to this approach that we are still seeking to solve.
|
|
201
209
|
|
|
202
210
|
### Commands
|
|
203
211
|
|
|
@@ -225,8 +233,8 @@ Commands:
|
|
|
225
233
|
|
|
226
234
|
### Example Commands
|
|
227
235
|
|
|
228
|
-
Create a dynamic bid for a mining seat, maxed at 10 argons per seat. Without a budget, this will use
|
|
229
|
-
eg, 10 seats).
|
|
236
|
+
Create a dynamic bid for a mining seat, maxed at 10 argons per seat. Without a budget, this will use
|
|
237
|
+
up to 100 argons ( eg, 10 seats).
|
|
230
238
|
|
|
231
239
|
```bash
|
|
232
240
|
npx @argonprotocol/mainchain --env=accounts/.env.bob mining bid --min-bid=1 --max-bid=10 --bid-increment=0.1
|
|
@@ -234,6 +242,7 @@ npx @argonprotocol/mainchain --env=accounts/.env.bob mining bid --min-bid=1 --ma
|
|
|
234
242
|
|
|
235
243
|
### Subaccounts
|
|
236
244
|
|
|
237
|
-
If you want to work with subaccounts during `consolidate` or setup of an account you can use the
|
|
238
|
-
flag to specify which subaccount to work with. `-s=0-9` is the default. You can
|
|
239
|
-
subaccounts. You can also use `-s=0-2,4` to specify a range
|
|
245
|
+
If you want to work with subaccounts during `consolidate` or setup of an account you can use the
|
|
246
|
+
`-s, --subaccounts` flag to specify which subaccount to work with. `-s=0-9` is the default. You can
|
|
247
|
+
also use `-s=0,1,2` to specify a list of subaccounts. You can also use `-s=0-2,4` to specify a range
|
|
248
|
+
and a list of subaccounts.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argonprotocol/mainchain",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "A client for accessing the Argon mainchain apis.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"dotenv": "^16.4.7"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@argonprotocol/testing": "1.3.
|
|
68
|
+
"@argonprotocol/testing": "1.3.1",
|
|
69
69
|
"@polkadot/typegen": "^16.2.1",
|
|
70
70
|
"@substrate/ss58-registry": "^1.51.0",
|
|
71
71
|
"@types/node": "^18.19.6",
|