@injectivelabs/sdk-ts 1.0.268 → 1.0.269

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,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,GAAG,CAAC,OAAe,EAAU,EAAE;IACxE,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC5B,OAA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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.269",
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": "235b4f4404b24c7a09bcb022e2300646756c3899",
71
71
  "typedoc": {
72
72
  "entryPoint": "./src/index.ts",
73
73
  "readmeFile": "./README.md",