-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4872 from leather-wallet/release/ledger-fixes
Release/ledger fixes
- Loading branch information
Showing
81 changed files
with
1,476 additions
and
808 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
src/app/common/account-restoration/legacy-gaia-config-lookup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useGetBrc20TokensQuery } from '@app/query/bitcoin/ordinals/brc20/brc20-tokens.query'; | ||
|
||
export function useBrc20Tokens() { | ||
const { data: allBrc20TokensResponse } = useGetBrc20TokensQuery(); | ||
const brc20Tokens = allBrc20TokensResponse?.pages | ||
.flatMap(page => page.brc20Tokens) | ||
.filter(token => token.length > 0) | ||
.flatMap(token => token); | ||
|
||
return brc20Tokens; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
src/app/common/transactions/bitcoin/fees/bitcoin-fees.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import BigNumber from 'bignumber.js'; | ||
import { sha256 } from 'bitcoinjs-lib/src/crypto'; | ||
|
||
import { UtxoResponseItem } from '@app/query/bitcoin/bitcoin-client'; | ||
|
||
import { filterUneconomicalUtxos } from '../utils'; | ||
import { calculateMaxBitcoinSpend } from './calculate-max-bitcoin-spend'; | ||
|
||
function generateTxId(value: number): UtxoResponseItem { | ||
const buffer = Buffer.from(Math.random().toString()); | ||
return { | ||
txid: sha256(sha256(buffer)).toString(), | ||
vout: 0, | ||
status: { | ||
confirmed: true, | ||
block_height: 2568495, | ||
block_hash: '000000000000008622fafce4a5388861b252d534f819d0f7cb5d4f2c5f9c1638', | ||
block_time: 1703787327, | ||
}, | ||
value, | ||
}; | ||
} | ||
|
||
function generateTransactions(values: number[]) { | ||
return values.map(val => generateTxId(val)); | ||
} | ||
|
||
function generateAverageFee(value: number) { | ||
return { | ||
hourFee: BigNumber(value / 2), | ||
halfHourFee: BigNumber(value), | ||
fastestFee: BigNumber(value * 2), | ||
}; | ||
} | ||
|
||
describe(calculateMaxBitcoinSpend.name, () => { | ||
const utxos = generateTransactions([600, 600, 1200, 1200, 10000, 10000, 25000, 40000, 50000000]); | ||
|
||
test('with 1 sat/vb fee', () => { | ||
const fee = 1; | ||
const maxBitcoinSpend = calculateMaxBitcoinSpend({ | ||
address: '', | ||
utxos, | ||
fetchedFeeRates: generateAverageFee(fee), | ||
}); | ||
expect(maxBitcoinSpend.amount.amount.toNumber()).toEqual(50087948); | ||
}); | ||
|
||
test('with 5 sat/vb fee', () => { | ||
const fee = 5; | ||
const maxBitcoinSpend = calculateMaxBitcoinSpend({ | ||
address: '', | ||
utxos, | ||
fetchedFeeRates: generateAverageFee(fee), | ||
}); | ||
expect(maxBitcoinSpend.amount.amount.toNumber()).toEqual(50085342); | ||
}); | ||
|
||
test('with 30 sat/vb fee', () => { | ||
const fee = 30; | ||
const maxBitcoinSpend = calculateMaxBitcoinSpend({ | ||
address: '', | ||
utxos, | ||
fetchedFeeRates: generateAverageFee(fee), | ||
}); | ||
expect(maxBitcoinSpend.amount.amount.toNumber()).toEqual(50073585); | ||
}); | ||
|
||
test('with 100 sat/vb fee', () => { | ||
const fee = 100; | ||
const maxBitcoinSpend = calculateMaxBitcoinSpend({ | ||
address: '', | ||
utxos, | ||
fetchedFeeRates: generateAverageFee(fee), | ||
}); | ||
expect(maxBitcoinSpend.amount.amount.toNumber()).toEqual(50046950); | ||
}); | ||
|
||
test('with 400 sat/vb fee', () => { | ||
const fee = 400; | ||
const maxBitcoinSpend = calculateMaxBitcoinSpend({ | ||
address: '', | ||
utxos, | ||
fetchedFeeRates: generateAverageFee(fee), | ||
}); | ||
expect(maxBitcoinSpend.amount.amount.toNumber()).toEqual(49969100); | ||
}); | ||
}); | ||
|
||
describe(filterUneconomicalUtxos.name, () => { | ||
const utxos = generateTransactions([600, 600, 1200, 1200, 10000, 10000, 25000, 40000, 50000000]); | ||
|
||
test('with 1 sat/vb fee', () => { | ||
const fee = 1; | ||
const filteredUtxos = filterUneconomicalUtxos({ | ||
address: '', | ||
utxos, | ||
feeRate: fee, | ||
}); | ||
|
||
expect(filteredUtxos.length).toEqual(9); | ||
}); | ||
|
||
test('with 10 sat/vb fee', () => { | ||
const fee = 10; | ||
const filteredUtxos = filterUneconomicalUtxos({ | ||
address: '', | ||
utxos, | ||
feeRate: fee, | ||
}); | ||
expect(filteredUtxos.length).toEqual(7); | ||
}); | ||
|
||
test('with 30 sat/vb fee', () => { | ||
const fee = 30; | ||
const filteredUtxos = filterUneconomicalUtxos({ | ||
address: '', | ||
utxos, | ||
feeRate: fee, | ||
}); | ||
expect(filteredUtxos.length).toEqual(5); | ||
}); | ||
|
||
test('with 200 sat/vb fee', () => { | ||
const fee = 200; | ||
const filteredUtxos = filterUneconomicalUtxos({ | ||
address: '', | ||
utxos, | ||
feeRate: fee, | ||
}); | ||
expect(filteredUtxos.length).toEqual(3); | ||
}); | ||
|
||
test('with 400 sat/vb fee', () => { | ||
const fee = 400; | ||
const filteredUtxos = filterUneconomicalUtxos({ | ||
address: '', | ||
utxos, | ||
feeRate: fee, | ||
}); | ||
expect(filteredUtxos.length).toEqual(2); | ||
}); | ||
}); |
Oops, something went wrong.