@injectivelabs/sdk-ts 1.15.23 → 1.15.24

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,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Address = void 0;
4
- const bech32_1 = require("bech32");
4
+ const base_1 = require("@scure/base");
5
5
  const ethereumjs_util_1 = require("ethereumjs-util");
6
6
  const exceptions_1 = require("@injectivelabs/exceptions");
7
7
  const constants_js_1 = require("../../utils/constants.js");
@@ -28,10 +28,10 @@ class Address {
28
28
  */
29
29
  static fromBech32(bech, prefix = constants_js_1.BECH32_ADDR_ACC_PREFIX) {
30
30
  try {
31
- const address = Buffer.from(bech32_1.bech32.fromWords(bech32_1.bech32.decode(bech).words)).toString('hex');
31
+ const address = Buffer.from(base_1.bech32.fromWords(base_1.bech32.decode(bech).words)).toString('hex');
32
32
  const addressInHex = address.startsWith('0x') ? address : `0x${address}`;
33
33
  const addressBuffer = ethereumjs_util_1.Address.fromString(addressInHex.toString()).toBuffer();
34
- const bech32Address = bech32_1.bech32.encode(prefix, bech32_1.bech32.toWords(addressBuffer));
34
+ const bech32Address = base_1.bech32.encode(prefix, base_1.bech32.toWords(addressBuffer));
35
35
  return new Address(bech32Address);
36
36
  }
37
37
  catch (e) {
@@ -50,7 +50,7 @@ class Address {
50
50
  static fromHex(hex, prefix = constants_js_1.BECH32_ADDR_ACC_PREFIX) {
51
51
  const addressHex = hex.startsWith('0x') ? hex : `0x${hex}`;
52
52
  const addressBuffer = ethereumjs_util_1.Address.fromString(addressHex.toString()).toBuffer();
53
- const bech32Address = bech32_1.bech32.encode(prefix, bech32_1.bech32.toWords(addressBuffer));
53
+ const bech32Address = base_1.bech32.encode(prefix, base_1.bech32.toWords(addressBuffer));
54
54
  return new Address(bech32Address);
55
55
  }
56
56
  /**
@@ -62,7 +62,7 @@ class Address {
62
62
  const address = this.toHex();
63
63
  const addressHex = address.startsWith('0x') ? address : `0x${address}`;
64
64
  const addressBuffer = ethereumjs_util_1.Address.fromString(addressHex).toBuffer();
65
- return bech32_1.bech32.encode(prefix, bech32_1.bech32.toWords(addressBuffer));
65
+ return base_1.bech32.encode(prefix, base_1.bech32.toWords(addressBuffer));
66
66
  }
67
67
  /**
68
68
  * Return a bech32-encoded account address
@@ -95,7 +95,7 @@ class Address {
95
95
  * */
96
96
  toHex() {
97
97
  const { bech32Address } = this;
98
- const address = Buffer.from(bech32_1.bech32.fromWords(bech32_1.bech32.decode(bech32Address).words)).toString('hex');
98
+ const address = Buffer.from(base_1.bech32.fromWords(base_1.bech32.decode(bech32Address).words)).toString('hex');
99
99
  return address.startsWith('0x') ? address : `0x${address}`;
100
100
  }
101
101
  /**
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -43,7 +10,6 @@ const secp256k1_1 = __importDefault(require("secp256k1"));
43
10
  const keccak256_1 = __importDefault(require("keccak256"));
44
11
  const PublicKey_js_1 = require("./PublicKey.js");
45
12
  const Address_js_1 = require("./Address.js");
46
- const BytesUtils = __importStar(require("@ethersproject/bytes"));
47
13
  const eth_sig_util_1 = require("@metamask/eth-sig-util");
48
14
  const index_js_1 = require("../../utils/index.js");
49
15
  const core_proto_ts_1 = require("@injectivelabs/core-proto-ts");
@@ -157,8 +123,8 @@ class PrivateKey {
157
123
  const { wallet } = this;
158
124
  const msgHash = (0, keccak256_1.default)(messageBytes);
159
125
  const signature = wallet.signingKey.sign(msgHash);
160
- const splitSignature = BytesUtils.splitSignature(signature);
161
- return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
126
+ const splittedSignature = ethers_1.Signature.from(signature);
127
+ return (0, ethers_1.getBytes)((0, ethers_1.concat)([splittedSignature.r, splittedSignature.s]));
162
128
  }
163
129
  /**
164
130
  * Sign the given message using the edcsa sign_deterministic function.
@@ -183,8 +149,8 @@ class PrivateKey {
183
149
  signHashed(messageHashedBytes) {
184
150
  const { wallet } = this;
185
151
  const signature = wallet.signingKey.sign(messageHashedBytes);
186
- const splitSignature = BytesUtils.splitSignature(signature);
187
- return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
152
+ const splittedSignature = ethers_1.Signature.from(signature);
153
+ return (0, ethers_1.getBytes)((0, ethers_1.concat)([splittedSignature.r, splittedSignature.s]));
188
154
  }
189
155
  /**
190
156
  * Sign the given message using the edcsa sign_deterministic function.
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PublicKey = void 0;
7
7
  const index_js_1 = require("../../utils/index.js");
8
- const bech32_1 = require("bech32");
8
+ const base_1 = require("@scure/base");
9
9
  const ethereumjs_util_1 = require("ethereumjs-util");
10
10
  const secp256k1_1 = __importDefault(require("secp256k1"));
11
11
  const Address_js_1 = require("./Address.js");
@@ -53,7 +53,7 @@ class PublicKey {
53
53
  * Note: this does not convert the public key to an address.
54
54
  */
55
55
  toBech32() {
56
- return bech32_1.bech32.encode(index_js_1.BECH32_PUBKEY_ACC_PREFIX, bech32_1.bech32.toWords(Buffer.from(this.toHex(), 'hex')));
56
+ return base_1.bech32.encode(index_js_1.BECH32_PUBKEY_ACC_PREFIX, base_1.bech32.toWords(Buffer.from(this.toHex(), 'hex')));
57
57
  }
58
58
  toAddress() {
59
59
  const publicKeyHex = this.toHex();
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.removeHexPrefix = exports.addHexPrefix = exports.isCw20ContractAddress = exports.getChecksumAddress = exports.getAddressFromInjectiveAddress = exports.getSubaccountId = exports.getDefaultSubaccountId = exports.getInjectiveAddressFromSubaccountId = exports.getEthereumAddress = exports.getInjectiveAddress = void 0;
7
- const bech32_1 = require("bech32");
7
+ const base_1 = require("@scure/base");
8
8
  const ethereumjs_util_1 = require("ethereumjs-util");
9
9
  const keccak256_1 = __importDefault(require("keccak256"));
10
10
  /**
@@ -15,7 +15,7 @@ const keccak256_1 = __importDefault(require("keccak256"));
15
15
  */
16
16
  const getInjectiveAddress = (ethAddress) => {
17
17
  const addressBuffer = ethereumjs_util_1.Address.fromString(ethAddress.toString()).toBuffer();
18
- return bech32_1.bech32.encode('inj', bech32_1.bech32.toWords(addressBuffer));
18
+ return base_1.bech32.encode('inj', base_1.bech32.toWords(addressBuffer));
19
19
  };
20
20
  exports.getInjectiveAddress = getInjectiveAddress;
21
21
  /**
@@ -28,7 +28,7 @@ const getEthereumAddress = (injectiveAddress) => {
28
28
  if (injectiveAddress.startsWith('0x')) {
29
29
  return injectiveAddress;
30
30
  }
31
- return `0x${Buffer.from(bech32_1.bech32.fromWords(bech32_1.bech32.decode(injectiveAddress).words)).toString('hex')}`;
31
+ return `0x${Buffer.from(base_1.bech32.fromWords(base_1.bech32.decode(injectiveAddress).words)).toString('hex')}`;
32
32
  };
33
33
  exports.getEthereumAddress = getEthereumAddress;
34
34
  /**
@@ -49,7 +49,7 @@ exports.getInjectiveAddressFromSubaccountId = getInjectiveAddressFromSubaccountI
49
49
  * @returns string
50
50
  */
51
51
  const getDefaultSubaccountId = (injectiveAddress) => {
52
- return `0x${Buffer.from(bech32_1.bech32.fromWords(bech32_1.bech32.decode(injectiveAddress).words)).toString('hex')}${'0'.repeat(24)}`;
52
+ return `0x${Buffer.from(base_1.bech32.fromWords(base_1.bech32.decode(injectiveAddress).words)).toString('hex')}${'0'.repeat(24)}`;
53
53
  };
54
54
  exports.getDefaultSubaccountId = getDefaultSubaccountId;
55
55
  /**
@@ -59,7 +59,7 @@ exports.getDefaultSubaccountId = getDefaultSubaccountId;
59
59
  * @returns string
60
60
  */
61
61
  const getSubaccountId = (injectiveAddress, nonce = 0) => {
62
- return `0x${Buffer.from(bech32_1.bech32.fromWords(bech32_1.bech32.decode(injectiveAddress).words)).toString('hex')}${'0'.repeat(23)}${nonce}`;
62
+ return `0x${Buffer.from(base_1.bech32.fromWords(base_1.bech32.decode(injectiveAddress).words)).toString('hex')}${'0'.repeat(23)}${nonce}`;
63
63
  };
64
64
  exports.getSubaccountId = getSubaccountId;
65
65
  /** @deprecated - use getEthereumAddress */
@@ -67,7 +67,7 @@ const getAddressFromInjectiveAddress = (address) => {
67
67
  if (address.startsWith('0x')) {
68
68
  return address;
69
69
  }
70
- return `0x${Buffer.from(bech32_1.bech32.fromWords(bech32_1.bech32.decode(address).words)).toString('hex')}`;
70
+ return `0x${Buffer.from(base_1.bech32.fromWords(base_1.bech32.decode(address).words)).toString('hex')}`;
71
71
  };
72
72
  exports.getAddressFromInjectiveAddress = getAddressFromInjectiveAddress;
73
73
  const getChecksumAddress = (ethAddress) => {
@@ -1,4 +1,4 @@
1
- import { bech32 } from 'bech32';
1
+ import { bech32 } from '@scure/base';
2
2
  import { Address as EthereumUtilsAddress } from 'ethereumjs-util';
3
3
  import { ErrorType, GeneralException } from '@injectivelabs/exceptions';
4
4
  import { BECH32_ADDR_ACC_PREFIX, BECH32_ADDR_CONS_PREFIX, BECH32_ADDR_VAL_PREFIX, } from '../../utils/constants.js';
@@ -1,10 +1,9 @@
1
1
  import { generateMnemonic } from 'bip39';
2
- import { Wallet, HDNodeWallet } from 'ethers';
2
+ import { Wallet, HDNodeWallet, Signature, getBytes, concat } from 'ethers';
3
3
  import secp256k1 from 'secp256k1';
4
4
  import keccak256 from 'keccak256';
5
5
  import { PublicKey } from './PublicKey.js';
6
6
  import { Address } from './Address.js';
7
- import * as BytesUtils from '@ethersproject/bytes';
8
7
  import { signTypedData, SignTypedDataVersion } from '@metamask/eth-sig-util';
9
8
  import { DEFAULT_DERIVATION_PATH, recoverTypedSignaturePubKey, } from '../../utils/index.js';
10
9
  import { InjectiveTypesV1Beta1TxExt, } from '@injectivelabs/core-proto-ts';
@@ -118,8 +117,8 @@ export class PrivateKey {
118
117
  const { wallet } = this;
119
118
  const msgHash = keccak256(messageBytes);
120
119
  const signature = wallet.signingKey.sign(msgHash);
121
- const splitSignature = BytesUtils.splitSignature(signature);
122
- return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
120
+ const splittedSignature = Signature.from(signature);
121
+ return getBytes(concat([splittedSignature.r, splittedSignature.s]));
123
122
  }
124
123
  /**
125
124
  * Sign the given message using the edcsa sign_deterministic function.
@@ -144,8 +143,8 @@ export class PrivateKey {
144
143
  signHashed(messageHashedBytes) {
145
144
  const { wallet } = this;
146
145
  const signature = wallet.signingKey.sign(messageHashedBytes);
147
- const splitSignature = BytesUtils.splitSignature(signature);
148
- return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
146
+ const splittedSignature = Signature.from(signature);
147
+ return getBytes(concat([splittedSignature.r, splittedSignature.s]));
149
148
  }
150
149
  /**
151
150
  * Sign the given message using the edcsa sign_deterministic function.
@@ -1,5 +1,5 @@
1
1
  import { BECH32_PUBKEY_ACC_PREFIX, decompressPubKey } from '../../utils/index.js';
2
- import { bech32 } from 'bech32';
2
+ import { bech32 } from '@scure/base';
3
3
  import { toBuffer } from 'ethereumjs-util';
4
4
  import secp256k1 from 'secp256k1';
5
5
  import { Address } from './Address.js';
@@ -1,4 +1,4 @@
1
- import { bech32 } from 'bech32';
1
+ import { bech32 } from '@scure/base';
2
2
  import { Address } from 'ethereumjs-util';
3
3
  import keccak256 from 'keccak256';
4
4
  /**
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.15.23",
4
+ "version": "1.15.24",
5
5
  "sideEffects": false,
6
6
  "license": "Apache-2.0",
7
7
  "author": {
@@ -121,24 +121,23 @@
121
121
  "@cosmjs/amino": "^0.33.0",
122
122
  "@cosmjs/proto-signing": "^0.33.0",
123
123
  "@cosmjs/stargate": "^0.33.0",
124
- "@ethersproject/bytes": "^5.8.0",
125
124
  "@injectivelabs/abacus-proto-ts": "1.14.0",
126
125
  "@injectivelabs/core-proto-ts": "1.14.3",
127
- "@injectivelabs/exceptions": "^1.15.20",
126
+ "@injectivelabs/exceptions": "^1.15.21",
128
127
  "@injectivelabs/grpc-web": "^0.0.1",
129
128
  "@injectivelabs/grpc-web-node-http-transport": "^0.0.2",
130
129
  "@injectivelabs/grpc-web-react-native-transport": "^0.0.2",
131
130
  "@injectivelabs/indexer-proto-ts": "1.13.12",
132
131
  "@injectivelabs/mito-proto-ts": "1.13.2",
133
- "@injectivelabs/networks": "^1.15.21",
132
+ "@injectivelabs/networks": "^1.15.22",
134
133
  "@injectivelabs/olp-proto-ts": "1.13.4",
135
- "@injectivelabs/ts-types": "^1.15.21",
136
- "@injectivelabs/utils": "^1.15.21",
134
+ "@injectivelabs/ts-types": "^1.15.22",
135
+ "@injectivelabs/utils": "^1.15.22",
137
136
  "@metamask/eth-sig-util": "^8.2.0",
138
137
  "@noble/curves": "^1.8.1",
139
138
  "@noble/hashes": "^1.7.1",
139
+ "@scure/base": "^1.2.6",
140
140
  "axios": "^1.8.1",
141
- "bech32": "^2.0.0",
142
141
  "bip39": "^3.1.0",
143
142
  "cosmjs-types": "^0.9.0",
144
143
  "crypto-js": "^4.2.0",
@@ -152,7 +151,7 @@
152
151
  "shx": "^0.3.4",
153
152
  "snakecase-keys": "^5.4.1"
154
153
  },
155
- "gitHead": "fe69f860c669483a0d1de3419952de88b5e157b0",
154
+ "gitHead": "552058d3ad9ac35a95ca2b3834d0cace8e4559dc",
156
155
  "typedoc": {
157
156
  "entryPoint": "./src/index.ts",
158
157
  "readmeFile": "./README.md",