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