Skip to content

Commit

Permalink
Upgrade edge-core-js to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Dec 22, 2023
1 parent d8feded commit bc6964e
Show file tree
Hide file tree
Showing 165 changed files with 985 additions and 699 deletions.
12 changes: 12 additions & 0 deletions src/__tests__/actions/TransactionExportActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const edgeTxs: EdgeTransaction[] = [
{
blockHeight: 500000,
currencyCode: 'BTC',
tokenId: null,
date: 1524476980,
deviceDescription: 'iphone12',
isSend: false,
Expand All @@ -32,6 +33,7 @@ const edgeTxs: EdgeTransaction[] = [
{
blockHeight: 500000,
currencyCode: 'BTC',
tokenId: null,
date: 1524576980,
deviceDescription: 'iphone12',
isSend: true,
Expand All @@ -53,6 +55,8 @@ const edgeTxs: EdgeTransaction[] = [
{
blockHeight: 500000,
currencyCode: 'BTC',
tokenId: null,

date: 1524676980,
deviceDescription: 'iphone12',
memos: [],
Expand All @@ -73,6 +77,8 @@ const edgeTxs: EdgeTransaction[] = [
{
blockHeight: 500000,
currencyCode: 'BTC',
tokenId: null,

date: 1524776980,
deviceDescription: 'iphone12',
memos: [],
Expand All @@ -93,6 +99,8 @@ const edgeTxs: EdgeTransaction[] = [
{
blockHeight: 500000,
currencyCode: 'USDC',
tokenId: null,

date: 1524876980,
deviceDescription: 'iphone12',
isSend: true,
Expand All @@ -114,6 +122,8 @@ const edgeTxs: EdgeTransaction[] = [
{
blockHeight: 500000,
currencyCode: 'BTC',
tokenId: null,

date: 1524976980,
deviceDescription: 'iphone12',
memos: [],
Expand All @@ -134,6 +144,8 @@ const edgeTxs: EdgeTransaction[] = [
{
blockHeight: 500000,
currencyCode: 'BTC',
tokenId: null,

date: 1525076980,
deviceDescription: 'iphone12',
isSend: true,
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/components/BuyCrypto.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('BuyCrypto', () => {

const renderer = TestRenderer.create(
<FakeProviders initialState={mockState}>
<BuyCrypto wallet={fakeWallet} tokenId={undefined} navigation={fakeNavigation} />
<BuyCrypto wallet={fakeWallet} tokenId={null} navigation={fakeNavigation} />
</FakeProviders>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('WalletListRow', () => {

const renderer = TestRenderer.create(
<FakeProviders initialState={mockState}>
<CreateWalletSelectCryptoRow pluginId={pluginId} walletName={walletName} onPress={onPress} rightSide={rightSide} />
<CreateWalletSelectCryptoRow pluginId={pluginId} tokenId={null} walletName={walletName} onPress={onPress} rightSide={rightSide} />
</FakeProviders>
)

Expand Down
1 change: 1 addition & 0 deletions src/__tests__/components/ExchangeQuoteComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('ExchangeQuote', () => {
return {
transaction: {
blockHeight: 500000,
tokenId: null,
currencyCode: 'BTC',
date: 1524476980,
deviceDescription: 'iphone12',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/components/TransactionListRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ describe('TransactionListRow', () => {
<TransactionListRow
navigation={fakeNavigation}
wallet={fakeWallet}
currencyCode="BTC"
transaction={{
blockHeight: 10,
currencyCode: 'BTC',
tokenId: null,
date: 123456789,
nativeAmount: '-100001',
isSend: true,
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/components/TransactionListTop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('TransactionListTop', () => {
}

const fakeWallet: any = {
balances: { BTC: '123123' },
balanceMap: new Map([[null, '123123']]),
blockHeight: 12345,
currencyConfig: fakeCurrencyConfig,
currencyInfo,
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('TransactionListTop', () => {
isEmpty={false}
navigation={fakeNavigation}
searching={false}
tokenId={undefined}
tokenId={null}
wallet={fakeWallet}
onSearchingChange={() => undefined}
onSearchTextChange={() => undefined}
Expand All @@ -88,7 +88,7 @@ describe('TransactionListTop', () => {
isEmpty={false}
navigation={fakeNavigation}
searching={false}
tokenId={undefined}
tokenId={null}
wallet={fakeWallet}
onSearchingChange={() => undefined}
onSearchTextChange={() => undefined}
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/components/WalletListSortableRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('WalletListSortableRow', () => {
const fakeWallet: any = {
currencyInfo: fakeCurrencyInfo,
name: 'Test wallet',
balances: {}
balanceMap: new Map()
}

const renderer = TestRenderer.create(
Expand Down
24 changes: 14 additions & 10 deletions src/__tests__/edgeProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ describe('upgradeExtendedCurrencyCodes', () => {
// As well, BSC is not an actual currencyCode so it won't be included either. BSC can only be specified using object
// params with pluginId = binancesmartchain
const result = upgradeExtendedCurrencyCodes(currencyConfig, undefined, ['BTC', 'ETH', 'MATIC', 'BNB', 'DOGE', 'BSC'])
expect(result).toEqual([{ pluginId: 'bitcoin' }, { pluginId: 'ethereum' }, { pluginId: 'dogecoin' }])
expect(result).toEqual([
{ pluginId: 'bitcoin', tokenId: null },
{ pluginId: 'ethereum', tokenId: null },
{ pluginId: 'dogecoin', tokenId: null }
])
})
test('single code tokens', () => {
const result = upgradeExtendedCurrencyCodes(currencyConfig, undefined, ['BTC', 'USDC', 'REP', 'USDT'])
expect(result).toEqual([
{ pluginId: 'bitcoin' },
{ pluginId: 'bitcoin', tokenId: null },
{ pluginId: 'ethereum', tokenId: 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' },
{ pluginId: 'ethereum', tokenId: '1985365e9f78359a9b6ad760e32412f4a445e862' },
{ pluginId: 'ethereum', tokenId: 'dac17f958d2ee523a2206206994597c13d831ec7' }
Expand All @@ -37,22 +41,22 @@ describe('upgradeExtendedCurrencyCodes', () => {
test('double code tokens', () => {
const result = upgradeExtendedCurrencyCodes(currencyConfig, undefined, ['BTC', 'MATIC-USDC', 'ETH-REP', 'ETH-USDT'])
expect(result).toEqual([
{ pluginId: 'bitcoin' },
{ pluginId: 'bitcoin', tokenId: null },
{ pluginId: 'polygon', tokenId: '2791bca1f2de4661ed88a30c99a7a9449aa84174' },
{ pluginId: 'ethereum', tokenId: '1985365e9f78359a9b6ad760e32412f4a445e862' },
{ pluginId: 'ethereum', tokenId: 'dac17f958d2ee523a2206206994597c13d831ec7' }
])
})
test('object list', () => {
const result = upgradeExtendedCurrencyCodes(currencyConfig, undefined, [
{ pluginId: 'bitcoin', tokenId: undefined, currencyCode: undefined },
{ pluginId: 'polygon', tokenId: undefined, currencyCode: 'USDC' },
{ pluginId: 'ethereum', tokenId: undefined, currencyCode: 'REP' },
{ pluginId: 'ethereum', tokenId: undefined, currencyCode: 'USDT' },
{ pluginId: 'ethereum', tokenId: undefined, currencyCode: 'MATIC' }
{ pluginId: 'bitcoin', tokenId: null },
{ pluginId: 'polygon', currencyCode: 'USDC' },
{ pluginId: 'ethereum', currencyCode: 'REP' },
{ pluginId: 'ethereum', currencyCode: 'USDT' },
{ pluginId: 'ethereum', currencyCode: 'MATIC' }
])
expect(result).toEqual([
{ pluginId: 'bitcoin' },
{ pluginId: 'bitcoin', tokenId: null },
{ pluginId: 'polygon', tokenId: '2791bca1f2de4661ed88a30c99a7a9449aa84174' },
{ pluginId: 'ethereum', tokenId: '1985365e9f78359a9b6ad760e32412f4a445e862' },
{ pluginId: 'ethereum', tokenId: 'dac17f958d2ee523a2206206994597c13d831ec7' },
Expand All @@ -66,7 +70,7 @@ describe('upgradeExtendedCurrencyCodes', () => {
['BTC', 'USDC', 'REP', 'USDTERC20']
)
expect(result).toEqual([
{ pluginId: 'bitcoin' },
{ pluginId: 'bitcoin', tokenId: null },
{ pluginId: 'ethereum', tokenId: 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' },
{ pluginId: 'ethereum', tokenId: '1985365e9f78359a9b6ad760e32412f4a445e862' },
{ pluginId: 'ethereum', tokenId: 'dac17f958d2ee523a2206206994597c13d831ec7' }
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/modals/AccelerateTxModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('AccelerateTxModalComponent', () => {
replacedTx={{
blockHeight: 0,
currencyCode: 'BTC',
tokenId: null,
date: 0,
isSend: true,
memos: [],
Expand All @@ -38,6 +39,7 @@ describe('AccelerateTxModalComponent', () => {
acceleratedTx={{
blockHeight: 0,
currencyCode: 'BTC',
tokenId: null,
date: 0,
isSend: true,
memos: [],
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/modals/AdvancedDetailsCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('AdvancedDetailsCard', () => {
transaction={{
blockHeight: 0,
currencyCode: 'BCH',
tokenId: null,
date: 0,
isSend: true,
memos: [],
Expand Down
18 changes: 12 additions & 6 deletions src/__tests__/modals/WalletListModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,30 @@ describe('WalletListModal', () => {

it("Should upgrade currency codes to token ID's", () => {
const data: { [code: string]: EdgeAsset[] } = {
ETH: [{ pluginId: 'ethereum' }],
BNB: [{ pluginId: 'binance' }, { pluginId: 'ethereum', tokenId: '1234abcd' }]
ETH: [{ pluginId: 'ethereum', tokenId: null }],
BNB: [
{ pluginId: 'binance', tokenId: null },
{ pluginId: 'ethereum', tokenId: '1234abcd' }
]
}
function lookup(currencyCode: string): EdgeAsset[] {
return data[currencyCode.toUpperCase()] ?? []
}

// Check ambiguous currency codes:
expect(upgradeCurrencyCodes(lookup, ['ETH', 'BNB'])).toEqual([
{ pluginId: 'ethereum' },
{ pluginId: 'binance' },
{ pluginId: 'ethereum', tokenId: null },
{ pluginId: 'binance', tokenId: null },
{ pluginId: 'ethereum', tokenId: '1234abcd' }
])

// Check scoped currency codes:
expect(upgradeCurrencyCodes(lookup, ['ETH', 'ETH-BNB'])).toEqual([{ pluginId: 'ethereum' }, { pluginId: 'ethereum', tokenId: '1234abcd' }])
expect(upgradeCurrencyCodes(lookup, ['ETH', 'ETH-BNB'])).toEqual([
{ pluginId: 'ethereum', tokenId: null },
{ pluginId: 'ethereum', tokenId: '1234abcd' }
])

// Check missing currency codes:
expect(upgradeCurrencyCodes(lookup, ['ETH', 'LOL'])).toEqual([{ pluginId: 'ethereum' }])
expect(upgradeCurrencyCodes(lookup, ['ETH', 'LOL'])).toEqual([{ pluginId: 'ethereum', tokenId: null }])
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('CreateWalletAccountSelect', () => {
selectedWalletType: {
currencyName: 'bitcoin',
walletType: 'wallet:bitcoin',
pluginId: 'bitcoin',
currencyCode: 'BTC'
} as any,
isReactivation: true,
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/scenes/CreateWalletImportScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('CreateWalletImportScene', () => {
currencyCode: 'BTC',
displayName: 'Bitcoin',
pluginId: 'bitcoin',
tokenId: null,
walletType: 'wallet:bitcoin-bip49'
}
],
Expand Down
10 changes: 9 additions & 1 deletion src/__tests__/scenes/CreateWalletSelectFiatScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ describe('CreateWalletSelectFiatComponent', () => {
currencyCode: 'BTC',
displayName: 'Bitcoin (no Segwit)',
pluginId: 'bitcoin',
tokenId: null,
walletType: 'wallet:bitcoin-bip44'
},
{ key: 'create-wallet:ethereum-ethereum', currencyCode: 'ETH', displayName: 'Ethereum', pluginId: 'ethereum', walletType: 'wallet:ethereum' },
{
key: 'create-wallet:ethereum-ethereum',
currencyCode: 'ETH',
displayName: 'Ethereum',
pluginId: 'ethereum',
tokenId: null,
walletType: 'wallet:ethereum'
},
{
key: 'create-ethereum-9992ec3cf6a55b00978cddf2b27bc6882d88d1ec',
currencyCode: 'POLY',
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/scenes/CryptoExchangeQuoteScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ describe('CryptoExchangeQuoteScreenComponent', () => {
transaction: {
blockHeight: 500000,
currencyCode: 'BTC',
tokenId: null,
date: 1524476980,
deviceDescription: 'iphone12',
isSend: false,
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/scenes/CryptoExchangeScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('CryptoExchangeComponent', () => {
account={fakeAccount}
exchangeInfo={initialState}
fromWalletId=""
fromWalletBalances={[''] as any}
fromTokenId={null}
fromWalletBalanceMap={new Map()}
fromFiatCurrencyCode="USD"
fromIsoFiatCurrencyCode="iso:USD"
fromWalletName="BTC Wallet"
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/scenes/RequestScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Request', () => {

const fakeWallet: any = {
currencyInfo: { pluginId: 'bitcoin', displayName: 'Bitcoin' },
balances: { BTC: '1234' }
balanceMap: new Map([[null, '1234']])
}

const actual = renderer.render(
Expand All @@ -47,7 +47,7 @@ describe('Request', () => {
currencyCode="BTC"
wallet={fakeWallet}
exchangeSecondaryToPrimaryRatio={{} as any}
primaryCurrencyInfo={{ displayDenomination: { multiplier: '100000000' }, exchangeDenomination: { multiplier: '100000000' } } as any}
primaryCurrencyInfo={{ tokenId: null, displayDenomination: { multiplier: '100000000' }, exchangeDenomination: { multiplier: '100000000' } } as any}
secondaryCurrencyInfo={{} as any}
theme={getTheme()}
refreshAllFioAddresses={async () => {}}
Expand Down
11 changes: 11 additions & 0 deletions src/__tests__/scenes/SendScene2.ui.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe('SendScene2', () => {
<SendScene2
{...fakeSceneProps('send2', {
walletId: btcWallet.id,
tokenId: null,
doCheckAndShowGetCryptoModal: false
})}
/>
Expand All @@ -107,7 +108,9 @@ describe('SendScene2', () => {
<SendScene2
{...fakeSceneProps('send2', {
walletId: btcWallet.id,
tokenId: null,
spendInfo: {
tokenId: null,
spendTargets: [{ publicAddress: 'some pub address', nativeAmount: '1234' }]
},
doCheckAndShowGetCryptoModal: false
Expand All @@ -133,7 +136,9 @@ describe('SendScene2', () => {
{ label: 'info tile label 2', value: 'info tile value 2' }
],
walletId: btcWallet.id,
tokenId: null,
spendInfo: {
tokenId: null,
spendTargets: [{ publicAddress: 'some pub address', nativeAmount: '1234' }]
},
doCheckAndShowGetCryptoModal: false
Expand All @@ -155,7 +160,9 @@ describe('SendScene2', () => {
<SendScene2
{...fakeSceneProps('send2', {
walletId: btcWallet.id,
tokenId: null,
spendInfo: {
tokenId: null,
spendTargets: [
{ publicAddress: 'some pub address', nativeAmount: '1234' },
{ publicAddress: 'some pub address 2', nativeAmount: '12345' }
Expand All @@ -179,7 +186,9 @@ describe('SendScene2', () => {
const params: SendScene2Params = {
hiddenFeaturesMap: { address: true },
walletId: btcWallet.id,
tokenId: null,
spendInfo: {
tokenId: null,
spendTargets: [
{ publicAddress: 'some pub address', nativeAmount: '1234' },
{ publicAddress: 'some pub address 2', nativeAmount: '12345' }
Expand Down Expand Up @@ -222,7 +231,9 @@ describe('SendScene2', () => {
const params: SendScene2Params = {
lockTilesMap: { address: true },
walletId: btcWallet.id,
tokenId: null,
spendInfo: {
tokenId: null,
spendTargets: [
{ publicAddress: 'some pub address', nativeAmount: '1234' },
{ publicAddress: 'some pub address 2', nativeAmount: '12345' }
Expand Down
Loading

0 comments on commit bc6964e

Please sign in to comment.