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

Commit

Permalink
Merge pull request #1907 from LedgerHQ/release/v22.0.2
Browse files Browse the repository at this point in the history
Release/v22.0.2
  • Loading branch information
lambertkevin authored Apr 21, 2022
2 parents 1360070 + 2ef02b4 commit d1c2520
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "git",
"url": "https://github.com/LedgerHQ/ledger-live-common"
},
"version": "22.0.1",
"version": "22.0.2",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("testing xpub legacy transactions", () => {
// Initialize the xpub with 2 txs. So that it has 2 utxo
dataset.xpub.storage.appendTxs([
{
hash: "9e1b337875c21f751e70ee2c2c6ee93d8a6733d0f3ba6d139ae6a0479ebcefb0",
id: "9e1b337875c21f751e70ee2c2c6ee93d8a6733d0f3ba6d139ae6a0479ebcefb0",
inputs: [],
outputs: [
{
Expand Down Expand Up @@ -93,7 +93,7 @@ describe("testing xpub legacy transactions", () => {
received_at: "2021-07-28T13:34:17Z",
},
{
hash: "0b9f98d07eb418fa20573112d3cba6b871d429a06c724a7888ff0886be5213d1",
id: "0b9f98d07eb418fa20573112d3cba6b871d429a06c724a7888ff0886be5213d1",
inputs: [
{
output_hash:
Expand Down Expand Up @@ -188,7 +188,7 @@ describe("testing xpub legacy transactions", () => {
// Add 3 txs for the xpub. So that it has 5 utxo
dataset.xpub.storage.appendTxs([
{
hash: "8f30fe84da5a5846d668b4bad260730f2b0125fa66fb2633fa1cee23c6b11053",
id: "8f30fe84da5a5846d668b4bad260730f2b0125fa66fb2633fa1cee23c6b11053",
inputs: [
{
output_hash:
Expand Down Expand Up @@ -230,7 +230,7 @@ describe("testing xpub legacy transactions", () => {
received_at: "2021-07-28T14:46:51Z",
},
{
hash: "2f90f3312ffd4dce490cb2f7429c586a43ef68c99fc2f8e549127b72af7b4209",
id: "2f90f3312ffd4dce490cb2f7429c586a43ef68c99fc2f8e549127b72af7b4209",
inputs: [
{
output_hash:
Expand Down Expand Up @@ -272,7 +272,7 @@ describe("testing xpub legacy transactions", () => {
received_at: "2021-07-28T14:46:51Z",
},
{
hash: "2fee0c4b55e08583aa5bc565d7e428f7cdcbd2b73262f62208a6a72a74e2c945",
id: "2fee0c4b55e08583aa5bc565d7e428f7cdcbd2b73262f62208a6a72a74e2c945",
inputs: [
{
output_hash:
Expand Down
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const envDefinitions = {
},
SOLANA_VALIDATORS_APP_BASE_URL: {
parser: stringParser,
def: "http://validators-solana.coin.ledger.com/api/v1/validators/",
def: "https://validators-solana.coin.ledger.com/api/v1/validators",
desc: "base url for validators.app validator list",
},
BASE_SOCKET_URL: {
Expand Down
10 changes: 5 additions & 5 deletions src/families/bitcoin/js-synchronisation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const mapTxToOperations = (
changeAddresses: Set<string>
): $Shape<Operation[]> => {
const operations: Operation[] = [];
const hash = tx.hash;
const txId = tx.id;
const fee = new BigNumber(tx.fees);
const blockHeight = tx.block?.height;
const blockHash = tx.block?.hash;
Expand Down Expand Up @@ -189,8 +189,8 @@ const mapTxToOperations = (

type = "OUT";
operations.push({
id: encodeOperationId(accountId, hash, type),
hash,
id: encodeOperationId(accountId, txId, type),
hash: txId,
type,
value,
fee,
Expand Down Expand Up @@ -223,8 +223,8 @@ const mapTxToOperations = (
value = finalAmount;
type = "IN";
operations.push({
id: encodeOperationId(accountId, hash, type),
hash,
id: encodeOperationId(accountId, txId, type),
hash: txId,
type,
value,
fee,
Expand Down
15 changes: 10 additions & 5 deletions src/families/bitcoin/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { pickSiblings } from "../../bot/specs";
import { bitcoinPickingStrategy } from "./types";
import type { MutationSpec, AppSpec } from "../../bot/types";
import { LowerThanMinimumRelayFee } from "../../errors";
import { getMinRelayFee, getUTXOStatus } from "./logic";
import {
getMinRelayFee,
getUTXOStatus,
bchToCashaddrAddressWithoutPrefix,
} from "./logic";
import { DeviceModelId } from "@ledgerhq/devices";
type Arg = Partial<{
minimalAmount: BigNumber;
Expand Down Expand Up @@ -81,7 +85,11 @@ const genericTest = ({
: txInputs.map((t) => t.address).filter(Boolean),
recipients: txOutputs
.filter((o) => o.address && !o.isChange)
.map((o) => o.address)
.map((o) =>
account.currency.id === "bitcoin_cash"
? bchToCashaddrAddressWithoutPrefix(o.address)
: o.address
)
.filter(Boolean),
})
);
Expand Down Expand Up @@ -308,9 +316,6 @@ const bitcoinGold: AppSpec<Transaction> = {
mutations: bitcoinLikeMutations(),
};

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

const bitcoinCash: AppSpec<Transaction> = {
name: "Bitcoin Cash",
currency: getCryptoCurrencyById("bitcoin_cash"),
Expand Down
4 changes: 2 additions & 2 deletions src/families/bitcoin/wallet-btc/explorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
delete tx.confirmations;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delete tx.id;
delete tx.hash;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delete tx.lock_time;
Expand All @@ -269,7 +269,7 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
// @ts-ignore
delete output.script_hex;
// eslint-disable-next-line no-param-reassign
output.output_hash = tx.hash;
output.output_hash = tx.id;
// eslint-disable-next-line no-param-reassign
output.block_height = tx.block ? tx.block.height : null;
// Definition of replaceable, per the standard: https://github.com/bitcoin/bips/blob/61ccc84930051e5b4a99926510d0db4a8475a4e6/bip-0125.mediawiki#summary
Expand Down
10 changes: 5 additions & 5 deletions src/families/bitcoin/wallet-btc/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class BitcoinLikeStorage implements IStorage {
return tx;
}

getTx(address: string, hash: string) {
const index = `${address}-${hash}`;
getTx(address: string, txId: string) {
const index = `${address}-${txId}`;
return this.txs[this.primaryIndex[index]];
}

Expand All @@ -72,7 +72,7 @@ class BitcoinLikeStorage implements IStorage {

txs.forEach((tx) => {
const indexAddress = tx.address;
const index = `${indexAddress}-${tx.hash}`;
const index = `${indexAddress}-${tx.id}`;

// we reject already seen tx
if (this.txs[this.primaryIndex[index]]) {
Expand Down Expand Up @@ -142,7 +142,7 @@ class BitcoinLikeStorage implements IStorage {
this.txs.forEach((tx: TX) => {
// clean
const indexAddress = tx.address;
const index = `${indexAddress}-${tx.hash}`;
const index = `${indexAddress}-${tx.id}`;

if (tx.account !== txsFilter.account || tx.index !== txsFilter.index) {
this.primaryIndex[index] = newTxs.push(tx) - 1;
Expand All @@ -166,7 +166,7 @@ class BitcoinLikeStorage implements IStorage {
this.txs.forEach((tx: TX) => {
// clean
const indexAddress = tx.address;
const index = `${indexAddress}-${tx.hash}`;
const index = `${indexAddress}-${tx.id}`;

if (tx.account !== txsFilter.account || tx.index !== txsFilter.index) {
this.primaryIndex[index] = newTxs.push(tx) - 1;
Expand Down
4 changes: 2 additions & 2 deletions src/families/bitcoin/wallet-btc/storage/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface TX {
hash: string;
id: string;
account: number;
index: number;
received_at: string;
Expand Down Expand Up @@ -50,7 +50,7 @@ export interface IStorage {
confirmed?: boolean;
}): TX | undefined;
getLastUnconfirmedTx(): TX | undefined;
getTx(address: string, hash: string): TX | undefined;
getTx(address: string, txId: string): TX | undefined;
getUniquesAddresses(addressesFilter: {
account?: number;
index?: number;
Expand Down
4 changes: 3 additions & 1 deletion src/families/celo/js-getTransactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ const getTransactionStatus = async (

const estimatedFees = transaction.fees || new BigNumber(0);

const amount = useAllAmount
let amount = useAllAmount
? account.spendableBalance.minus(estimatedFees)
: new BigNumber(transaction.amount);

if (amount.lt(0)) amount = new BigNumber(0);

if (amount.lte(0) && !transaction.useAllAmount) {
errors.amount = new AmountRequired();
}
Expand Down
4 changes: 3 additions & 1 deletion src/walletconnect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export const parseCallRequest: Parser = async (account, payload) => {
data: payload.params[0],
};

case "eth_signTypedData":
// @dev: Today, `eth_signTypedData` is versionned. We can't only check `eth_signTypedData`
// This regex matches `eth_signTypedData` and `eth_signTypedData_v[0-9]`
case payload.method.match(/eth_signTypedData(_v.)?$/)?.input:
message = JSON.parse(payload.params[1]);
hashes = {
// $FlowFixMe
Expand Down
3 changes: 1 addition & 2 deletions tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@ledgerhq/cryptoassets": "6.8.1",
"@ledgerhq/hw-transport": "^6.7.0",
"@ledgerhq/hw-transport-http": "^6.7.0",
"@ledgerhq/hw-transport-u2f": "^5.36.0-deprecated",
Expand Down Expand Up @@ -37,7 +36,7 @@
"webpack": "4.42"
},
"scripts": {
"start": "HTTS=true react-app-rewired start",
"start": "react-app-rewired start",
"build": "react-app-rewired build && cp build/index.html build/200.html && cp build/index.html build/404.html",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-app-rewired eject"
Expand Down

0 comments on commit d1c2520

Please sign in to comment.