@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.
- package/README.md +110 -3
- package/lib/cli.cjs +3078 -0
- package/lib/cli.cjs.map +1 -0
- package/lib/cli.d.cts +1 -0
- package/lib/cli.d.ts +1 -0
- package/lib/cli.js +3073 -0
- package/lib/cli.js.map +1 -0
- package/lib/clis/index.cjs +3097 -0
- package/lib/clis/index.cjs.map +1 -0
- package/lib/clis/index.d.cts +26 -0
- package/lib/clis/index.d.ts +26 -0
- package/lib/clis/index.js +3077 -0
- package/lib/clis/index.js.map +1 -0
- package/lib/index.cjs +2402 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +11542 -0
- package/lib/index.d.ts +11542 -0
- package/lib/index.js +2333 -0
- package/lib/index.js.map +1 -0
- package/lib/test-utils/index.cjs +2933 -0
- package/lib/test-utils/index.cjs.map +1 -0
- package/lib/test-utils/index.d.cts +180 -0
- package/lib/test-utils/index.d.ts +180 -0
- package/lib/test-utils/index.js +2915 -0
- package/lib/test-utils/index.js.map +1 -0
- package/package.json +50 -45
- package/lib/cjs/WageProtector.d.ts +0 -37
- package/lib/cjs/WageProtector.js +0 -64
- package/lib/cjs/WageProtector.js.map +0 -1
- package/lib/cjs/__test__/WageProtector.test.d.ts +0 -1
- package/lib/cjs/__test__/WageProtector.test.js +0 -28
- package/lib/cjs/__test__/WageProtector.test.js.map +0 -1
- package/lib/cjs/examples/decodePkcs.d.ts +0 -1
- package/lib/cjs/examples/decodePkcs.js +0 -48
- package/lib/cjs/examples/decodePkcs.js.map +0 -1
- package/lib/cjs/examples/findSs58Formats.d.ts +0 -1
- package/lib/cjs/examples/findSs58Formats.js +0 -42
- package/lib/cjs/examples/findSs58Formats.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -32
- package/lib/cjs/index.js +0 -60
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/augment-api-consts.d.ts +0 -442
- package/lib/cjs/interfaces/augment-api-consts.js +0 -8
- package/lib/cjs/interfaces/augment-api-consts.js.map +0 -1
- package/lib/cjs/interfaces/augment-api-errors.d.ts +0 -919
- package/lib/cjs/interfaces/augment-api-errors.js +0 -8
- package/lib/cjs/interfaces/augment-api-errors.js.map +0 -1
- package/lib/cjs/interfaces/augment-api-events.d.ts +0 -1675
- package/lib/cjs/interfaces/augment-api-events.js +0 -8
- package/lib/cjs/interfaces/augment-api-events.js.map +0 -1
- package/lib/cjs/interfaces/augment-api-query.d.ts +0 -988
- package/lib/cjs/interfaces/augment-api-query.js +0 -8
- package/lib/cjs/interfaces/augment-api-query.js.map +0 -1
- package/lib/cjs/interfaces/augment-api-rpc.d.ts +0 -683
- package/lib/cjs/interfaces/augment-api-rpc.js +0 -8
- package/lib/cjs/interfaces/augment-api-rpc.js.map +0 -1
- package/lib/cjs/interfaces/augment-api-runtime.d.ts +0 -204
- package/lib/cjs/interfaces/augment-api-runtime.js +0 -8
- package/lib/cjs/interfaces/augment-api-runtime.js.map +0 -1
- package/lib/cjs/interfaces/augment-api-tx.d.ts +0 -1605
- package/lib/cjs/interfaces/augment-api-tx.js +0 -8
- package/lib/cjs/interfaces/augment-api-tx.js.map +0 -1
- package/lib/cjs/interfaces/augment-api.d.ts +0 -7
- package/lib/cjs/interfaces/augment-api.js +0 -12
- package/lib/cjs/interfaces/augment-api.js.map +0 -1
- package/lib/cjs/interfaces/augment-types.d.ts +0 -1316
- package/lib/cjs/interfaces/augment-types.js +0 -8
- package/lib/cjs/interfaces/augment-types.js.map +0 -1
- package/lib/cjs/interfaces/definitions.d.ts +0 -0
- package/lib/cjs/interfaces/definitions.js +0 -2
- package/lib/cjs/interfaces/definitions.js.map +0 -1
- package/lib/cjs/interfaces/lookup.d.ts +0 -2999
- package/lib/cjs/interfaces/lookup.js +0 -3262
- package/lib/cjs/interfaces/lookup.js.map +0 -1
- package/lib/cjs/interfaces/registry.d.ts +0 -250
- package/lib/cjs/interfaces/registry.js +0 -8
- package/lib/cjs/interfaces/registry.js.map +0 -1
- package/lib/cjs/interfaces/types-lookup.d.ts +0 -2974
- package/lib/cjs/interfaces/types-lookup.js +0 -8
- package/lib/cjs/interfaces/types-lookup.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/esm/WageProtector.d.ts +0 -37
- package/lib/esm/WageProtector.js +0 -60
- package/lib/esm/WageProtector.js.map +0 -1
- package/lib/esm/__test__/WageProtector.test.d.ts +0 -1
- package/lib/esm/__test__/WageProtector.test.js +0 -26
- package/lib/esm/__test__/WageProtector.test.js.map +0 -1
- package/lib/esm/examples/decodePkcs.d.ts +0 -1
- package/lib/esm/examples/decodePkcs.js +0 -45
- package/lib/esm/examples/decodePkcs.js.map +0 -1
- package/lib/esm/examples/findSs58Formats.d.ts +0 -1
- package/lib/esm/examples/findSs58Formats.js +0 -39
- package/lib/esm/examples/findSs58Formats.js.map +0 -1
- package/lib/esm/index.d.ts +0 -32
- package/lib/esm/index.js +0 -50
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/interfaces/augment-api-consts.d.ts +0 -442
- package/lib/esm/interfaces/augment-api-consts.js +0 -6
- package/lib/esm/interfaces/augment-api-consts.js.map +0 -1
- package/lib/esm/interfaces/augment-api-errors.d.ts +0 -919
- package/lib/esm/interfaces/augment-api-errors.js +0 -6
- package/lib/esm/interfaces/augment-api-errors.js.map +0 -1
- package/lib/esm/interfaces/augment-api-events.d.ts +0 -1675
- package/lib/esm/interfaces/augment-api-events.js +0 -6
- package/lib/esm/interfaces/augment-api-events.js.map +0 -1
- package/lib/esm/interfaces/augment-api-query.d.ts +0 -988
- package/lib/esm/interfaces/augment-api-query.js +0 -6
- package/lib/esm/interfaces/augment-api-query.js.map +0 -1
- package/lib/esm/interfaces/augment-api-rpc.d.ts +0 -683
- package/lib/esm/interfaces/augment-api-rpc.js +0 -6
- package/lib/esm/interfaces/augment-api-rpc.js.map +0 -1
- package/lib/esm/interfaces/augment-api-runtime.d.ts +0 -204
- package/lib/esm/interfaces/augment-api-runtime.js +0 -6
- package/lib/esm/interfaces/augment-api-runtime.js.map +0 -1
- package/lib/esm/interfaces/augment-api-tx.d.ts +0 -1605
- package/lib/esm/interfaces/augment-api-tx.js +0 -6
- package/lib/esm/interfaces/augment-api-tx.js.map +0 -1
- package/lib/esm/interfaces/augment-api.d.ts +0 -7
- package/lib/esm/interfaces/augment-api.js +0 -10
- package/lib/esm/interfaces/augment-api.js.map +0 -1
- package/lib/esm/interfaces/augment-types.d.ts +0 -1316
- package/lib/esm/interfaces/augment-types.js +0 -6
- package/lib/esm/interfaces/augment-types.js.map +0 -1
- package/lib/esm/interfaces/definitions.d.ts +0 -0
- package/lib/esm/interfaces/definitions.js +0 -2
- package/lib/esm/interfaces/definitions.js.map +0 -1
- package/lib/esm/interfaces/lookup.d.ts +0 -2999
- package/lib/esm/interfaces/lookup.js +0 -3260
- package/lib/esm/interfaces/lookup.js.map +0 -1
- package/lib/esm/interfaces/registry.d.ts +0 -250
- package/lib/esm/interfaces/registry.js +0 -6
- package/lib/esm/interfaces/registry.js.map +0 -1
- package/lib/esm/interfaces/types-lookup.d.ts +0 -2974
- package/lib/esm/interfaces/types-lookup.js +0 -6
- package/lib/esm/interfaces/types-lookup.js.map +0 -1
- package/lib/tsconfig-cjs.tsbuildinfo +0 -1
- package/lib/tsconfig-types.tsbuildinfo +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types/WageProtector.d.ts +0 -37
- package/lib/types/__test__/WageProtector.test.d.ts +0 -1
- package/lib/types/examples/decodePkcs.d.ts +0 -1
- package/lib/types/examples/findSs58Formats.d.ts +0 -1
- package/lib/types/index.d.ts +0 -32
- package/lib/types/interfaces/augment-api-consts.d.ts +0 -442
- package/lib/types/interfaces/augment-api-errors.d.ts +0 -919
- package/lib/types/interfaces/augment-api-events.d.ts +0 -1675
- package/lib/types/interfaces/augment-api-query.d.ts +0 -988
- package/lib/types/interfaces/augment-api-rpc.d.ts +0 -683
- package/lib/types/interfaces/augment-api-runtime.d.ts +0 -204
- package/lib/types/interfaces/augment-api-tx.d.ts +0 -1605
- package/lib/types/interfaces/augment-api.d.ts +0 -7
- package/lib/types/interfaces/augment-types.d.ts +0 -1316
- package/lib/types/interfaces/definitions.d.ts +0 -0
- package/lib/types/interfaces/lookup.d.ts +0 -2999
- package/lib/types/interfaces/registry.d.ts +0 -250
- 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
|
|
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
|
-
|
|
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.
|