@injectivelabs/sdk-ts 1.0.268 → 1.0.270

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.
@@ -1,6 +1,9 @@
1
1
  import { Coin as GrpcCoin } from '@injectivelabs/chain-api/cosmos/base/v1beta1/coin_pb';
2
+ import { DirectSignResponse } from '@cosmjs/proto-signing';
3
+ import { TxRaw } from '@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb';
2
4
  export * from './exchange';
3
5
  export * from './pagination';
6
+ export * from './provider';
4
7
  export interface Coin {
5
8
  denom: string;
6
9
  amount: string;
@@ -12,5 +15,5 @@ export declare enum StreamOperation {
12
15
  Update = "update",
13
16
  Invalidate = "invalidate"
14
17
  }
15
- export { GrpcCoin };
18
+ export { GrpcCoin, DirectSignResponse, TxRaw };
16
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,sDAAsD,CAAA;AAEvF,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAE5B,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,oBAAY,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,sDAAsD,CAAA;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAA;AAExE,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAE1B,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,oBAAY,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAA"}
@@ -14,11 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.GrpcCoin = exports.StreamOperation = void 0;
17
+ exports.TxRaw = exports.GrpcCoin = exports.StreamOperation = void 0;
18
18
  const coin_pb_1 = require("@injectivelabs/chain-api/cosmos/base/v1beta1/coin_pb");
19
19
  Object.defineProperty(exports, "GrpcCoin", { enumerable: true, get: function () { return coin_pb_1.Coin; } });
20
+ const tx_pb_1 = require("@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb");
21
+ Object.defineProperty(exports, "TxRaw", { enumerable: true, get: function () { return tx_pb_1.TxRaw; } });
20
22
  __exportStar(require("./exchange"), exports);
21
23
  __exportStar(require("./pagination"), exports);
24
+ __exportStar(require("./provider"), exports);
22
25
  var StreamOperation;
23
26
  (function (StreamOperation) {
24
27
  StreamOperation["Insert"] = "insert";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kFAAuF;AAkB9E,yFAlBQ,cAAQ,OAkBR;AAhBjB,6CAA0B;AAC1B,+CAA4B;AAO5B,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,4CAAyB,CAAA;AAC3B,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kFAAuF;AAqB9E,yFArBQ,cAAQ,OAqBR;AAnBjB,4EAAwE;AAmBjC,sFAnB9B,aAAK,OAmB8B;AAjB5C,6CAA0B;AAC1B,+CAA4B;AAC5B,6CAA0B;AAO1B,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,4CAAyB,CAAA;AAC3B,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B"}
@@ -0,0 +1,41 @@
1
+ import { DirectSignResponse } from '@cosmjs/proto-signing';
2
+ import { TxRaw } from '@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb';
3
+ import { ChainId, CosmosChainId } from '@injectivelabs/ts-types';
4
+ export interface InjectiveWalletProvider {
5
+ /**
6
+ * The the accounts from the wallet (addresses)
7
+ */
8
+ getAddresses(): Promise<string[]>;
9
+ /**
10
+ * Get the PubKey from the wallet
11
+ * in base64 for Cosmos native wallets
12
+ */
13
+ getPubKey(): Promise<string>;
14
+ /**
15
+ * Sends Cosmos transaction. Returns a transaction hash
16
+ * @param transaction should implement TransactionConfig
17
+ * @param options
18
+ */
19
+ sendTransaction(transaction: DirectSignResponse | TxRaw, options: {
20
+ address: string;
21
+ chainId: ChainId;
22
+ }): Promise<string>;
23
+ isChainIdSupported(chainId?: CosmosChainId): Promise<boolean>;
24
+ signTransaction(transaction: {
25
+ txRaw: TxRaw;
26
+ chainId: string;
27
+ accountNumber: number;
28
+ }, address: string): Promise<DirectSignResponse>;
29
+ /**
30
+ * Sign a cosmos transaction using the wallet provider
31
+ *
32
+ * @param transaction
33
+ * @param address - injective address
34
+ */
35
+ signCosmosTransaction(transaction: {
36
+ txRaw: TxRaw;
37
+ accountNumber: number;
38
+ chainId: string;
39
+ }, address: string): Promise<DirectSignResponse>;
40
+ }
41
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/types/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEhE,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAEjC;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAE5B;;;;OAIG;IACH,eAAe,CACb,WAAW,EAAE,kBAAkB,GAAG,KAAK,EACvC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,GAC7C,OAAO,CAAC,MAAM,CAAC,CAAA;IAElB,kBAAkB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE7D,eAAe,CACb,WAAW,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,EACrE,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAE9B;;;;;OAKG;IACH,qBAAqB,CACnB,WAAW,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EACrE,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAC/B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/types/provider.ts"],"names":[],"mappings":""}
@@ -1,3 +1,17 @@
1
- export declare const getInjectiveAddress: (address: string) => string;
1
+ /**
2
+ * Get injective address from Ethereum hex address
3
+ *
4
+ * @param ethAddress string
5
+ * @returns string
6
+ */
7
+ export declare const getInjectiveAddress: (ethAddress: string) => string;
8
+ /**
9
+ * Get ethereum address from injective bech32 address
10
+ *
11
+ * @param ethAddress string
12
+ * @returns string
13
+ */
14
+ export declare const getEthereumAddress: (injectiveAddress: string) => string;
15
+ /** @deprecated - use getEthereumAddress */
2
16
  export declare const getAddressFromInjectiveAddress: (address: string) => string;
3
17
  //# sourceMappingURL=address.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,YAAa,MAAM,KAAG,MAIrD,CAAA;AAED,eAAO,MAAM,8BAA8B,YAAa,MAAM,KAAG,MAQhE,CAAA"}
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,eAAgB,MAAM,KAAG,MAIxD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,qBAAsB,MAAM,KAAG,MAQ7D,CAAA;AAED,2CAA2C;AAC3C,eAAO,MAAM,8BAA8B,YAAa,MAAM,KAAG,MAQhE,CAAA"}
@@ -1,13 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAddressFromInjectiveAddress = exports.getInjectiveAddress = void 0;
3
+ exports.getAddressFromInjectiveAddress = exports.getEthereumAddress = exports.getInjectiveAddress = void 0;
4
4
  const bech32_1 = require("bech32");
5
5
  const ethereumjs_util_1 = require("ethereumjs-util");
6
- const getInjectiveAddress = (address) => {
7
- const addressBuffer = ethereumjs_util_1.Address.fromString(address.toString()).toBuffer();
6
+ /**
7
+ * Get injective address from Ethereum hex address
8
+ *
9
+ * @param ethAddress string
10
+ * @returns string
11
+ */
12
+ const getInjectiveAddress = (ethAddress) => {
13
+ const addressBuffer = ethereumjs_util_1.Address.fromString(ethAddress.toString()).toBuffer();
8
14
  return bech32_1.bech32.encode('inj', bech32_1.bech32.toWords(addressBuffer));
9
15
  };
10
16
  exports.getInjectiveAddress = getInjectiveAddress;
17
+ /**
18
+ * Get ethereum address from injective bech32 address
19
+ *
20
+ * @param ethAddress string
21
+ * @returns string
22
+ */
23
+ const getEthereumAddress = (injectiveAddress) => {
24
+ if (injectiveAddress.startsWith('0x')) {
25
+ return injectiveAddress;
26
+ }
27
+ return `0x${Buffer.from(bech32_1.bech32.fromWords(bech32_1.bech32.decode(injectiveAddress).words)).toString('hex')}`;
28
+ };
29
+ exports.getEthereumAddress = getEthereumAddress;
30
+ /** @deprecated - use getEthereumAddress */
11
31
  const getAddressFromInjectiveAddress = (address) => {
12
32
  if (address.startsWith('0x')) {
13
33
  return address;
@@ -1 +1 @@
1
- {"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAC/B,qDAAyC;AAElC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE;IAC7D,MAAM,aAAa,GAAG,yBAAO,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;IAEvE,OAAO,eAAM,CAAC,MAAM,CAAC,KAAK,EAAE,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAA;AAJY,QAAA,mBAAmB,uBAI/B;AAEM,MAAM,8BAA8B,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CAAC,EAAE;QAC5B,OAAO,OAAO,CAAA;KACf;IAED,OAAO,KAAK,MAAM,CAAC,IAAI,CACrB,eAAM,CAAC,SAAS,CAAC,eAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAC/C,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAA;AACrB,CAAC,CAAA;AARY,QAAA,8BAA8B,kCAQ1C"}
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 browser, node, and react native environment.",
4
- "version": "1.0.268",
4
+ "version": "1.0.270",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "Bojan Angjelkoski",
@@ -67,7 +67,7 @@
67
67
  "shx": "^0.3.2",
68
68
  "snakecase-keys": "^5.4.1"
69
69
  },
70
- "gitHead": "a9c4cae9e160fd8968428c4e0983b243a815ba75",
70
+ "gitHead": "453b3700ceff5dbbf8437ca3169c74ae1aed880f",
71
71
  "typedoc": {
72
72
  "entryPoint": "./src/index.ts",
73
73
  "readmeFile": "./README.md",