injectivejs 0.2.0 → 0.3.0
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 +71 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,11 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
<img src="https://user-images.githubusercontent.com/545047/193426489-d5d3c9a9-d738-43a0-a628-b8b4f1a8034b.png" width="400">
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
npm install injectivejs
|
|
9
9
|
```
|
|
10
|
+
## Table of contents
|
|
11
|
+
|
|
12
|
+
- [InjectiveJS](#injectivejs)
|
|
13
|
+
- [Install](#install)
|
|
14
|
+
- [Table of contents](#table-of-contents)
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Contracts](#contracts)
|
|
17
|
+
- [Registry](#registry)
|
|
18
|
+
- [RPC Clients](#rpc-clients)
|
|
19
|
+
- [Composing Messages](#composing-messages)
|
|
20
|
+
- Injective
|
|
21
|
+
- [Auction](#auction-messages)
|
|
22
|
+
- [Exchange](#exchange-messages)
|
|
23
|
+
- [Insurance](#insurance-messages)
|
|
24
|
+
- [OCR](#ocr-messages)
|
|
25
|
+
- [Oracle](#oracle-messages)
|
|
26
|
+
- [Peggy](#peggy-messages)
|
|
27
|
+
- Cosmos, CosmWasm, and IBC
|
|
28
|
+
- [CosmWasm](#cosmwasm-messages)
|
|
29
|
+
- [IBC](#ibc-messages)
|
|
30
|
+
- [Cosmos](#cosmos-messages)
|
|
31
|
+
- [Wallets and Signers](#connecting-with-wallets-and-signing-messages)
|
|
32
|
+
- [Stargate Client](#initializing-the-stargate-client)
|
|
33
|
+
- [Creating Signers](#creating-signers)
|
|
34
|
+
- [Broadcasting Messages](#broadcasting-messages)
|
|
35
|
+
- [Advanced Usage](#advanced-usage)
|
|
36
|
+
- [Credits](#credits)
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
### Contracts
|
|
40
|
+
#### Registry
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { contracts } from 'injectivejs';
|
|
44
|
+
const { RegistryClient } = contracts.Registry;
|
|
45
|
+
|
|
46
|
+
const client = new RegistryClient(
|
|
47
|
+
signingCosmWasmClient, // make sure to create your client (see docs below)
|
|
48
|
+
senderAddress,
|
|
49
|
+
contractAddress
|
|
50
|
+
);
|
|
51
|
+
```
|
|
52
|
+
#### Registry.activate
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
await client.activate({
|
|
56
|
+
contractAddress
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Registry.getActiveContracts
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
const activeContracts = await client.getActiveContracts();
|
|
64
|
+
const {
|
|
65
|
+
address,
|
|
66
|
+
gas_limit,
|
|
67
|
+
gas_price,
|
|
68
|
+
is_executable
|
|
69
|
+
} = activeContracts.contracts[0];
|
|
70
|
+
```
|
|
10
71
|
|
|
11
72
|
### RPC Clients
|
|
12
73
|
|
|
@@ -39,7 +100,7 @@ const {
|
|
|
39
100
|
} = injective.exchange.v1beta1.MessageComposer.withTypeUrl;
|
|
40
101
|
```
|
|
41
102
|
|
|
42
|
-
####
|
|
103
|
+
#### Auction Messages
|
|
43
104
|
|
|
44
105
|
```js
|
|
45
106
|
const {
|
|
@@ -47,7 +108,7 @@ const {
|
|
|
47
108
|
} = injective.auction.v1beta1.MessageComposer.withTypeUrl;
|
|
48
109
|
```
|
|
49
110
|
|
|
50
|
-
#### Exchange
|
|
111
|
+
#### Exchange Messages
|
|
51
112
|
|
|
52
113
|
```js
|
|
53
114
|
const {
|
|
@@ -82,7 +143,7 @@ const {
|
|
|
82
143
|
} = injective.exchange.v1beta1.MessageComposer.withTypeUrl;
|
|
83
144
|
```
|
|
84
145
|
|
|
85
|
-
#### Insurance
|
|
146
|
+
#### Insurance Messages
|
|
86
147
|
|
|
87
148
|
```js
|
|
88
149
|
const {
|
|
@@ -92,7 +153,7 @@ const {
|
|
|
92
153
|
} = injective.insurance.v1beta1.MessageComposer.withTypeUrl;
|
|
93
154
|
```
|
|
94
155
|
|
|
95
|
-
#### OCR
|
|
156
|
+
#### OCR Messages
|
|
96
157
|
|
|
97
158
|
```js
|
|
98
159
|
const {
|
|
@@ -107,7 +168,7 @@ const {
|
|
|
107
168
|
} = injective.ocr.v1beta1.MessageComposer.withTypeUrl;
|
|
108
169
|
```
|
|
109
170
|
|
|
110
|
-
#### Oracle
|
|
171
|
+
#### Oracle Messages
|
|
111
172
|
|
|
112
173
|
```js
|
|
113
174
|
const {
|
|
@@ -119,7 +180,7 @@ const {
|
|
|
119
180
|
} = injective.oracle.v1beta1.MessageComposer.withTypeUrl;
|
|
120
181
|
```
|
|
121
182
|
|
|
122
|
-
#### Peggy
|
|
183
|
+
#### Peggy Messages
|
|
123
184
|
|
|
124
185
|
```js
|
|
125
186
|
const {
|
|
@@ -213,7 +274,7 @@ const stargateClient = await getSigningInjectiveClient({
|
|
|
213
274
|
signer // OfflineSigner
|
|
214
275
|
});
|
|
215
276
|
```
|
|
216
|
-
|
|
277
|
+
### Creating Signers
|
|
217
278
|
|
|
218
279
|
To broadcast messages, you can create signers with a variety of options:
|
|
219
280
|
|
|
@@ -246,7 +307,7 @@ const mnemonic =
|
|
|
246
307
|
chain
|
|
247
308
|
});
|
|
248
309
|
```
|
|
249
|
-
### Broadcasting
|
|
310
|
+
### Broadcasting Messages
|
|
250
311
|
|
|
251
312
|
Now that you have your `stargateClient`, you can broadcast messages:
|
|
252
313
|
|
|
@@ -276,7 +337,7 @@ const fee: StdFee = {
|
|
|
276
337
|
const response = await stargateClient.signAndBroadcast(address, [msg], fee);
|
|
277
338
|
```
|
|
278
339
|
|
|
279
|
-
|
|
340
|
+
## Advanced Usage
|
|
280
341
|
|
|
281
342
|
If you want to manually construct a stargate client
|
|
282
343
|
|