@pear-protocol/exchanges-sdk 0.1.4 → 0.1.6

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.
@@ -9,7 +9,6 @@ async function fetchApiKeys(accountIndex) {
9
9
  }
10
10
  async function fetchAccountsByL1Address(l1Address) {
11
11
  const res = await fetch(`${LIGHTER_BASE_URL}/api/v1/accountsByL1Address?l1_address=${l1Address}`);
12
- if (!res.ok) throw new Error(`Lighter /accountsByL1Address returned ${res.status}`);
13
12
  return res.json();
14
13
  }
15
14
  async function fetchAccount(accountIndex) {
@@ -26,7 +26,7 @@ function createLighterHelper(sdk) {
26
26
  },
27
27
  async connectWallet(walletClient, params) {
28
28
  const apiKeys = await fetchApiKeys(params.accountIndex);
29
- const apiKeyIndex = apiKeys.length === 0 ? 3 : apiKeys.reduce((max, k) => k.api_key_index > max ? k.api_key_index : max, 0) + 1;
29
+ const apiKeyIndex = Math.max(4, ...apiKeys.map((k) => k.api_key_index + 1));
30
30
  const { privateKey, messageToSign, txInfo } = await sdk.core.misc.lighter.createApiKey({
31
31
  accountIndex: params.accountIndex,
32
32
  apiKeyIndex
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/exchanges-sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Pear Protocol Exchanges SDK",
5
5
  "private": false,
6
6
  "type": "module",