Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

update polkadot lib version #1858

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
"@ledgerhq/json-bignumber": "^1.1.0",
"@ledgerhq/live-app-sdk": "^0.2.0",
"@ledgerhq/logs": "6.10.0",
"@polkadot/types": "7.8.1",
"@polkadot/types-known": "7.8.1",
"@polkadot/types": "7.15.1",
"@polkadot/types-known": "7.15.1",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "^1.32.0",
"@taquito/ledger-signer": "stablelib",
Expand Down
5 changes: 2 additions & 3 deletions src/families/bitcoin/logic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import cashaddr from "cashaddrjs";
import bchaddr from "bchaddrjs";
import { Currency, isValidAddress } from "./wallet-btc";
import { RecipientRequired, InvalidAddress } from "@ledgerhq/errors";
import type { Account, CryptoCurrency, CryptoCurrencyIds } from "./../../types";
Expand Down Expand Up @@ -143,8 +142,8 @@ type CoinLogic = {
injectGetAddressParams?: (arg0: Account) => any;
};

const bchToCashaddrAddressWithoutPrefix = (recipient) =>
recipient ? bchaddr.toCashAddress(recipient).split(":")[1] : recipient;
export const bchToCashaddrAddressWithoutPrefix = (recipient) =>
recipient ? recipient.substring(recipient.indexOf(":") + 1) : recipient;

export const perCoinLogic: Record<
CryptoCurrencyIds,
Expand Down
4 changes: 3 additions & 1 deletion src/families/bitcoin/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ const bitcoinLikeMutations = ({
test: ({ account }) => {
expect(
account.bitcoinResources?.utxos
.filter((u) => u.blockHeight && u.blockHeight < account.blockHeight) // Exclude pending UTXOs and the Utxos just written into new block
.filter(
(u) => u.blockHeight && u.blockHeight < account.blockHeight - 10
) // Exclude pending UTXOs and the Utxos just written into new block (10 blocks time)
.reduce((p, c) => p.plus(c.value), new BigNumber(0))
.toString()
).toBe("0");
Expand Down
5 changes: 1 addition & 4 deletions src/families/bitcoin/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber } from "bignumber.js";
import bchaddr from "bchaddrjs";
import { bchToCashaddrAddressWithoutPrefix } from "./logic";
import cashaddr from "cashaddrjs";
import type {
Transaction,
Expand Down Expand Up @@ -134,9 +134,6 @@ function bchExplicit(str: string): string {
return str;
}

const bchToCashaddrAddressWithoutPrefix = (recipient) =>
recipient ? bchaddr.toCashAddress(recipient).split(":")[1] : recipient;

export type CoinLogic = {
hasExtraData?: boolean;
hasExpiryHeight?: boolean;
Expand Down
42 changes: 21 additions & 21 deletions src/families/bitcoin/wallet-btc/explorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,28 +207,29 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {

// TODO add a test for failure (at the sync level)
const client = await this.client.acquire();
const res = (
await client.client.get(url, {
params,
// some altcoin may have outputs with values > MAX_SAFE_INTEGER
transformResponse: (string) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
JSONBigNumber.parse(string, (key: string, value: any) => {
if (BigNumber.isBigNumber(value)) {
if (key === "value") {
return value.toString();
let res: { txs: TX[] } = { txs: [] };
try {
res = (
await client.client.get(url, {
params,
// some altcoin may have outputs with values > MAX_SAFE_INTEGER
transformResponse: (string) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
JSONBigNumber.parse(string, (key: string, value: any) => {
if (BigNumber.isBigNumber(value)) {
if (key === "value") {
return value.toString();
}
return value.toNumber();
}

return value.toNumber();
}
return value;
}),
})
).data as { txs: TX[] };
await this.client.release(client);

return value;
}),
})
).data;
} finally {
await this.client.release(client);
}
this.emit("fetched-address-transaction", { url, params, res });

return res;
}

Expand Down Expand Up @@ -305,7 +306,6 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
params.block_hash = lastTx.block.hash;
}
}

const res = await this.fetchTxs(address, params);

const hydratedTxs: TX[] = [];
Expand Down
Loading