@injectivelabs/sdk-ts 1.0.181 → 1.0.183

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 +7 -28
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Total alerts](https://img.shields.io/lgtm/alerts/g/InjectiveLabs/injective-ts.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/InjectiveLabs/injective-ts/alerts/) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/InjectiveLabs/injective-ts.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/InjectiveLabs/injective-ts/context:javascript)
6
6
  [![license](https://img.shields.io/npm/l/express.svg)]()
7
7
 
8
- _Accessing decentralized finance through TypeScript (for Web and Node environment)_
8
+ _Accessing decentralized finance through TypeScript (for Web, Node and React Native environment)_
9
9
 
10
10
  `@injectivelabs/sdk-ts` is a TypeScript SDK for writing applications on top of the Injective chain in both a Node.js and a browser environment.
11
11
 
@@ -46,32 +46,11 @@ There are two pieces of the `sdk-ts` - **querying a data source** and **making t
46
46
 
47
47
  ### Querying a data source
48
48
 
49
- There are 2 data sources that can be accessed through the `sdk-ts`:
50
-
51
- - The Injective chain itself through a sentry node,
52
- - The Indexer API (indexer of events from the Injective chain to a MongoDB),
53
-
54
- For each of the data sources there are two ways that they can be queried:
55
-
56
- - using the gRPC protocol,
57
- - using REST
58
-
59
- We also have a GraphQL consumer of the Peggy subgraph on Ethereum (used only for tracking deposits and withdrawals on Ethereum).
60
-
61
- For the 2 main data sources, there are abstraction classes that developers can use to access specific modules of the Injective Chain **or** specific modules within the Exchange API. The responses of these requests are always mapped into normal JavaScript objects (regardless of the data source type) and served to the end user.
49
+ Read more and find example usages on our [Querying Wiki](https://github.com/InjectiveLabs/injective-ts/wiki/01Querying)
62
50
 
63
51
  ### Making Transactions
64
52
 
65
- To interact with Injective, the user has to issue a transaction. Each transaction that is broadcasted to Injective can hold multiple messages that can change the state of the Injective chain. Within the `core` folder, developers can find a convenient way to make these messages with methods that can convert these messages in a way that they can be used by developers in different scenarios (broadcasting using the normal cosmos way or converted to EIP712 to be signed using Ethereum wallets).
66
-
67
- Every message extends the `MsgBase` interface, which has couple of mapping functionalities:
68
- - `toData` -> Converts the Message to a simple Object representation,
69
- - `toProto` -> Returns a proto representation of the Message,
70
- - `toDirectSign` -> Converts the Message to a proto representation (ready to be used in the normal Cosmos way of handling transactions),
71
- - `toAmino` -> Converts the Message to a amino representation + type (usually used to covert the message to EIP712 typed data to be signable in Ethereum native wallets),
72
- - `toWeb3` -> same as toAmino (deprecated)
73
-
74
- There are also some utility classes and functions that are exposed from the package. There is also a `local` folder that exposes some utility classes that can be used to make developers life easier in a Node environment.
53
+ Read more and find example usages on our [Transactions Wiki](https://github.com/InjectiveLabs/injective-ts/wiki/02Transactions)
75
54
 
76
55
  ---
77
56
 
@@ -132,8 +111,8 @@ console.log(await exchangeGrpcClient.derivatives.fetchMarkets())
132
111
  ```ts
133
112
  import { getNetworkInfo, Network } from "@injectivelabs/networks";
134
113
  import { ChainRestAuthApi } from "@injectivelabs/sdk-ts";
135
- import { PrivateKey } from "@injectivelabs/sdk-ts/dist/local";
136
114
  import {
115
+ PrivateKey,
137
116
  privateKeyToPublicKeyBase64,
138
117
  MsgSend,
139
118
  DEFAULT_STD_FEE,
@@ -149,7 +128,7 @@ import { BigNumberInBase } from "@injectivelabs/utils";
149
128
  const privateKey = PrivateKey.fromPrivateKey(privateKeyHash);
150
129
  const injectiveAddress = privateKey.toBech32();
151
130
  const publicKey = privateKeyToPublicKeyBase64(
152
- Buffer.from(privateKeyHash, "hex")
131
+ Buffer.from(privateKeyHash.replace("0x", ""), "hex")
153
132
  );
154
133
 
155
134
  /** Account Details **/
@@ -169,12 +148,12 @@ import { BigNumberInBase } from "@injectivelabs/utils";
169
148
  dstInjectiveAddress: injectiveAddress,
170
149
  });
171
150
 
172
- /** Prepare the Transaction **/
151
+ /** Prepare the Transaction */
173
152
  const { signBytes, txRaw } = createTransaction({
174
153
  message: msg.toDirectSign(),
175
154
  memo: "",
176
155
  fee: DEFAULT_STD_FEE,
177
- pubKey: Buffer.from(publicKey).toString("base64"),
156
+ pubKey: publicKey,
178
157
  sequence: parseInt(accountDetails.account.base_account.sequence, 10),
179
158
  accountNumber: parseInt(
180
159
  accountDetails.account.base_account.account_number,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/sdk-ts",
3
3
  "description": "SDK in TypeScript for building Injective applications in a Node environment.",
4
- "version": "1.0.181",
4
+ "version": "1.0.183",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Bojan Angjelkoski",
@@ -43,8 +43,8 @@
43
43
  "@injectivelabs/exceptions": "^1.0.23",
44
44
  "@injectivelabs/exchange-api": "^2.2.77",
45
45
  "@injectivelabs/indexer-api": "^1.0.21",
46
- "@injectivelabs/networks": "^1.0.32",
47
- "@injectivelabs/token-metadata": "^1.0.46",
46
+ "@injectivelabs/networks": "^1.0.34",
47
+ "@injectivelabs/token-metadata": "^1.0.48",
48
48
  "@injectivelabs/ts-types": "^1.0.13",
49
49
  "@injectivelabs/utils": "^1.0.29",
50
50
  "@metamask/eth-sig-util": "^4.0.1",
@@ -67,7 +67,7 @@
67
67
  "shx": "^0.3.2",
68
68
  "snakecase-keys": "^5.4.1"
69
69
  },
70
- "gitHead": "2b70430ea2de236666b8ccaca3c7cf2031aa1a0d",
70
+ "gitHead": "514a02c50ed845d5dc40f27be08b320d581850de",
71
71
  "typedoc": {
72
72
  "entryPoint": "./src/index.ts",
73
73
  "readmeFile": "./README.md",