injectivejs 1.6.2 → 1.6.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 (2) hide show
  1. package/README.md +373 -2
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,7 +1,8 @@
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="80">
4
+ <img src="https://user-images.githubusercontent.com/545047/193426489-d5d3c9a9-d738-43a0-a628-b8b4f1a8034b.png" width="80"><br />
5
+ Building the future of decentralized exchange
5
6
  </p>
6
7
 
7
8
  <p align="center" width="100%">
@@ -12,7 +13,377 @@
12
13
  <a href="https://github.com/cosmology-tech/interchainjs/blob/main/LICENSE-Apache"><img height="20" src="https://img.shields.io/badge/license-Apache-blue.svg"></a>
13
14
  </p>
14
15
 
15
- Functionalities(Tx, Query) generated by Telescope.
16
+ ## install
17
+
18
+ ```sh
19
+ npm install injectivejs
20
+ ```
21
+
22
+ ## Table of contents
23
+
24
+ - [InjectiveJS](#injectivejs)
25
+ - [Install](#install)
26
+ - [Table of contents](#table-of-contents)
27
+ - [Usage](#usage)
28
+ - [RPC Clients](#rpc-clients)
29
+ - [Tx Helpers](#tx-helpers)
30
+ - Injective
31
+ - [Auction](#auction-messages)
32
+ - [Exchange](#exchange-messages)
33
+ - [Insurance](#insurance-messages)
34
+ - [OCR](#ocr-messages)
35
+ - [Oracle](#oracle-messages)
36
+ - [Peggy](#peggy-messages)
37
+ - Cosmos, CosmWasm, and IBC
38
+ - [CosmWasm](#cosmwasm-messages)
39
+ - [IBC](#ibc-messages)
40
+ - [Cosmos](#cosmos-messages)
41
+ - [Wallets and Signers](#connecting-with-wallets-and-signing-messages)
42
+ - [Stargate Client](#initializing-the-stargate-client)
43
+ - [Creating Signers](#creating-signers)
44
+ - [Broadcasting Messages](#broadcasting-messages)
45
+ - [Advanced Usage](#advanced-usage)
46
+ - [Developing](#developing)
47
+ - [Credits](#credits)
48
+
49
+ ## Usage
50
+
51
+ ### RPC Clients
52
+
53
+ ```js
54
+ import { createQueryRpc } from "@interchainjs/cosmos/utils";
55
+ import { createGetAllBalances } from "injectivejs/cosmos/bank/v1beta1/query.rpc.func";
56
+ import { createGetExchangeBalances } from "injectivejs/injective/exchange/v1beta1/query.rpc.func";
57
+
58
+ { getRpcEndpoint } = useChain("osmosis");
59
+
60
+ const endpoint = await getRpcEndpoint();
61
+ const rpc = createQueryRpc(endpoint);
62
+
63
+ // get the tree shakable helper functions using the rpc client
64
+ const getAllBalances = createGetAllBalances(rpc);
65
+
66
+ // now you can query the cosmos modules
67
+ const balance = await getAllBalances({
68
+ address: "inj1addresshere",
69
+ });
70
+
71
+ // you can also query the injective modules
72
+ const getExchangeBalances = createGetExchangeBalances(rpc);
73
+ const exchangeBalance = await getExchangeBalances({});
74
+ ```
75
+
76
+ ### Tx Helpers
77
+
78
+ For tx messages, there're helper functions to sign and broadcast messages:
79
+
80
+ ```js
81
+ import {
82
+ createDeposit,
83
+ createLiquidatePosition,
84
+ createActivateStakeGrant,
85
+ } from "injectivejs/injective/exchange/v1beta1/tx.rpc.func";
86
+ ```
87
+
88
+ #### Auction Messages
89
+
90
+ ```js
91
+ import { createBid } from "injectivejs/injective/auction/v1beta1/tx.rpc.func";
92
+ ```
93
+
94
+ #### Exchange Messages
95
+
96
+ ```js
97
+ import {
98
+ createActivateStakeGrant,
99
+ createAdminUpdateBinaryOptionsMarket,
100
+ createAuthorizeStakeGrants,
101
+ createBatchCancelBinaryOptionsOrders,
102
+ createBatchCancelDerivativeOrders,
103
+ createBatchCancelSpotOrders,
104
+ createBatchCreateDerivativeLimitOrders,
105
+ createBatchCreateSpotLimitOrders,
106
+ createBatchUpdateOrders,
107
+ createCancelBinaryOptionsOrder,
108
+ createCancelDerivativeOrder,
109
+ createCancelSpotOrder,
110
+ createCreateBinaryOptionsLimitOrder,
111
+ createCreateBinaryOptionsMarketOrder,
112
+ createCreateDerivativeLimitOrder,
113
+ createCreateDerivativeMarketOrder,
114
+ createCreateSpotLimitOrder,
115
+ createCreateSpotMarketOrder,
116
+ createDecreasePositionMargin,
117
+ createDeposit,
118
+ createEmergencySettleMarket,
119
+ createExternalTransfer,
120
+ createIncreasePositionMargin,
121
+ createInstantBinaryOptionsMarketLaunch,
122
+ createInstantExpiryFuturesMarketLaunch,
123
+ createInstantPerpetualMarketLaunch,
124
+ createInstantSpotMarketLaunch,
125
+ createLiquidatePosition,
126
+ createPrivilegedExecuteContract,
127
+ createRewardsOptOut,
128
+ createSubaccountTransfer,
129
+ createUpdateDerivativeMarket,
130
+ createUpdateParams,
131
+ createUpdateSpotMarket,
132
+ createWithdraw,
133
+ } from "injectivejs/injective/exchange/v1beta1/tx.rpc.func";
134
+ ```
135
+
136
+ #### Insurance Messages
137
+
138
+ ```js
139
+ import {
140
+ createCreateInsuranceFund,
141
+ createRequestRedemption,
142
+ createUnderwrite,
143
+ } from "injectivejs/injective/insurance/v1beta1/tx.rpc.func";
144
+ ```
145
+
146
+ #### OCR Messages
147
+
148
+ ```js
149
+ import {
150
+ createAcceptPayeeship,
151
+ createCreateFeed,
152
+ createFundFeedRewardPool,
153
+ createSetPayees,
154
+ createTransferPayeeship,
155
+ createTransmit,
156
+ createUpdateFeed,
157
+ createWithdrawFeedRewardPool,
158
+ } from "injectivejs/injective/ocr/v1beta1/tx.rpc.func";
159
+ ```
160
+
161
+ #### Oracle Messages
162
+
163
+ ```js
164
+ import {
165
+ createRelayBandRates,
166
+ createRelayCoinbaseMessages,
167
+ createRelayPriceFeedPrice,
168
+ createRelayProviderPrices,
169
+ createRelayPythPrices,
170
+ createRelayStorkMessage,
171
+ createRequestBandIBCRates,
172
+ } from "injectivejs/injective/oracle/v1beta1/tx.rpc.func";
173
+ ```
174
+
175
+ #### Peggy Messages
176
+
177
+ ```js
178
+ import {
179
+ createBlacklistEthereumAddresses,
180
+ createCancelSendToEth,
181
+ createConfirmBatch,
182
+ createDepositClaim,
183
+ createERC20DeployedClaim,
184
+ createRequestBatch,
185
+ createRevokeEthereumBlacklist,
186
+ createSendToEth,
187
+ createSetOrchestratorAddresses,
188
+ createSubmitBadSignatureEvidence,
189
+ createValsetConfirm,
190
+ createValsetUpdateClaim,
191
+ createWithdrawClaim,
192
+ } from "injectivejs/injective/peggy/v1/msgs.rpc.func";
193
+ ```
194
+
195
+ #### CosmWasm Messages
196
+
197
+ ```js
198
+ import {
199
+ createExecuteContract,
200
+ createClearAdmin,
201
+ createInstantiateContract,
202
+ createInstantiateContract2,
203
+ createMigrateContract,
204
+ createPinCodes,
205
+ createRemoveCodeUploadParamsAddresses,
206
+ createStoreAndInstantiateContract,
207
+ createStoreCode,
208
+ createSudoContract,
209
+ createUnpinCodes,
210
+ createUpdateAdmin,
211
+ createUpdateContractLabel,
212
+ createUpdateInstantiateConfig,
213
+ createAddCodeUploadParamsAddresses,
214
+ createStoreAndMigrateContract,
215
+ } from "injectivejs/cosmwasm/wasm/v1/tx.rpc.func";
216
+ ```
217
+
218
+ #### IBC Messages
219
+
220
+ ```js
221
+ import { createTransfer } from "injectivejs/ibc/applications/transfer/v1/tx.rpc.func";
222
+ ```
223
+
224
+ #### Cosmos Messages
225
+
226
+ ```js
227
+ import {
228
+ createFundCommunityPool,
229
+ createCommunityPoolSpend,
230
+ createDepositValidatorRewardsPool,
231
+ } from "injectivejs/cosmos/distribution/v1beta1/tx.rpc.func";
232
+
233
+ import {
234
+ createSend,
235
+ createMultiSend,
236
+ } from "injectivejs/cosmos/bank/v1beta1/tx.rpc.func";
237
+
238
+ import {
239
+ createDelegate,
240
+ createUndelegate,
241
+ createCancelUnbondingDelegation,
242
+ createCreateValidator,
243
+ } from "injectivejs/cosmos/staking/v1beta1/tx.rpc.func";
244
+
245
+ import {
246
+ createDeposit,
247
+ createSubmitProposal,
248
+ createVote,
249
+ createVoteWeighted,
250
+ } from "injectivejs/cosmos/gov/v1beta1/tx.rpc.func";
251
+ ```
252
+
253
+ ## Connecting with Wallets and Signing Messages
254
+
255
+ ⚡️ For web interfaces, we recommend using [interchain-kit](https://github.com/cosmology-tech/interchain-kit/). Continue below to see how to manually construct signers and clients.
256
+
257
+ Here are the docs on [creating signers](https://github.com/cosmology-tech/interchain-kit/blob/main/packages/core/README.md) in interchain-kit that can be used with Keplr and other wallets.
258
+
259
+ ### Initializing the Stargate Client
260
+
261
+ Use `getSigningInjectiveClient` to get your `SigningStargateClient`, with the proto/amino messages full-loaded. No need to manually add amino types, just require and initialize the client:
262
+
263
+ ```js
264
+ import { InjSigningClient } from "@interchainjs/injective/signing-client";
265
+
266
+ signingClient = await InjSigningClient.connectWithSigner(
267
+ await getRpcEndpoint(),
268
+ new AminoGenericOfflineSigner(aminoOfflineSigner)
269
+ );
270
+ ```
271
+
272
+ ### Creating Signers
273
+
274
+ To broadcast messages, you can create signers with a variety of options:
275
+
276
+ - [interchain-kit](https://github.com/cosmology-tech/interchain-kit/) (recommended)
277
+ - [keplr](https://docs.keplr.app/api/cosmjs.html)
278
+ - [cosmjs](https://gist.github.com/webmaster128/8444d42a7eceeda2544c8a59fbd7e1d9)
279
+
280
+ ### Broadcasting Messages
281
+
282
+ When you have your `signing client`, you can broadcast messages:
283
+
284
+ ```js
285
+ const msg = {
286
+ typeUrl: MsgSend.typeUrl,
287
+ value: MsgSend.fromPartial({
288
+ amount: [
289
+ {
290
+ denom: "inj",
291
+ amount: "1000",
292
+ },
293
+ ],
294
+ toAddress: address,
295
+ fromAddress: address,
296
+ }),
297
+ };
298
+
299
+ const fee: StdFee = {
300
+ amount: [
301
+ {
302
+ denom: "inj",
303
+ amount: "864",
304
+ },
305
+ ],
306
+ gas: "86364",
307
+ };
308
+ const response = await stargateClient.signAndBroadcast(address, [msg], fee);
309
+ ```
310
+
311
+ ## Advanced Usage
312
+
313
+ If you want to manually construct a stargate client
314
+
315
+ ```js
316
+ import {
317
+ cosmosAminoConverters,
318
+ cosmosProtoRegistry,
319
+ cosmwasmAminoConverters,
320
+ cosmwasmProtoRegistry,
321
+ ibcProtoRegistry,
322
+ ibcAminoConverters,
323
+ injectiveAminoConverters,
324
+ injectiveProtoRegistry
325
+ } from 'injectivejs';
326
+
327
+ const signer: OfflineSigner = /* create your signer (see above) */
328
+ const rpcEndpoint = 'https://rpc.cosmos.directory/injective'; // or another URL
329
+
330
+ const protoRegistry: ReadonlyArray<[string, GeneratedType]> = [
331
+ ...cosmosProtoRegistry,
332
+ ...cosmwasmProtoRegistry,
333
+ ...ibcProtoRegistry,
334
+ ...injectiveProtoRegistry
335
+ ];
336
+
337
+ const aminoConverters = {
338
+ ...cosmosAminoConverters,
339
+ ...cosmwasmAminoConverters,
340
+ ...ibcAminoConverters,
341
+ ...injectiveAminoConverters
342
+ };
343
+
344
+ const registry = new Registry(protoRegistry);
345
+ const aminoTypes = new AminoTypes(aminoConverters);
346
+
347
+ const signingClient = await InjSigningClient.connectWithSigner(rpcEndpoint, signer);
348
+
349
+ signingClient.addEncoders(registry);
350
+ signingClient.addConverters(aminoTypes);
351
+ ```
352
+
353
+ ## Developing
354
+
355
+ When first cloning the repo:
356
+
357
+ ```shell
358
+ yarn
359
+ yarn build:dev
360
+ ```
361
+
362
+ ### Codegen
363
+
364
+ Contract schemas live in `./contracts`, and protos in `./proto`. Look inside of `scripts/inj.telescope.json` and configure the settings for bundling your SDK and contracts into `injectivejs`:
365
+
366
+ ```shell
367
+ yarn codegen
368
+ ```
369
+
370
+ ### Publishing
371
+
372
+ Build the types and then publish:
373
+
374
+ ```shell
375
+ yarn build
376
+ yarn publish
377
+ ```
378
+
379
+ ## Credits
380
+
381
+ 🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator)
382
+
383
+ Code built with the help of these related projects:
384
+
385
+ - [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes
386
+ - [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.
16
387
 
17
388
  ## License
18
389
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "injectivejs",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "Injectivejs is a JavaScript library for interacting with injective sdk.",
5
5
  "main": "index.js",
6
6
  "module": "esm/index.js",
@@ -25,10 +25,10 @@
25
25
  "prepare": "npm run build"
26
26
  },
27
27
  "dependencies": {
28
- "@interchainjs/cosmos": "1.6.2",
29
- "@interchainjs/cosmos-types": "1.6.2",
30
- "@interchainjs/types": "1.6.2",
31
- "@interchainjs/utils": "1.6.2",
28
+ "@interchainjs/cosmos": "1.6.3",
29
+ "@interchainjs/cosmos-types": "1.6.3",
30
+ "@interchainjs/types": "1.6.3",
31
+ "@interchainjs/utils": "1.6.3",
32
32
  "@noble/hashes": "^1.3.1",
33
33
  "decimal.js": "^10.4.3"
34
34
  },
@@ -45,5 +45,5 @@
45
45
  "cosmjs",
46
46
  "wallet"
47
47
  ],
48
- "gitHead": "1470d5d3811a672c458f9acffe052e22516bfc80"
48
+ "gitHead": "999f0fc009a1e058f067e8605de5fbfe763c9c68"
49
49
  }