Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #808

Merged
merged 39 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d625032
update vault token intro
johnloopring Apr 19, 2024
d6c2dd6
trade pro add null data protection
johnloopring Apr 22, 2024
6309c0e
fix a bridge bug
johnloopring Apr 23, 2024
ec4e06b
hide disabled trading pairs
johnloopring Apr 23, 2024
44ade66
working version
johnloopring Apr 23, 2024
7f542d5
fix testnet transfer bug
johnloopring Apr 28, 2024
98d0c59
Merge branch 'prd-fix' into staging
johnloopring Apr 28, 2024
886fc7f
Merge branch 'bridgeBugFix' into staging
johnloopring Apr 28, 2024
66e7f4a
Merge branch 'updateVaultIntru' into staging
johnloopring Apr 28, 2024
b84feab
update sdk version
johnloopring Apr 28, 2024
7c346b6
Merge branch 'prd-fix' into staging
johnloopring Apr 28, 2024
2c4a6ba
fix contact bug
johnloopring Apr 29, 2024
3a271d9
Merge branch 'contactFix' into staging
johnloopring Apr 29, 2024
5d46198
fix a bug
johnloopring Apr 29, 2024
aabb5a5
Merge branch 'prd-fix' into staging
johnloopring Apr 29, 2024
70707b4
fix btrade bug
johnloopring Apr 29, 2024
0f78df7
Merge branch 'prd-fix' into staging
johnloopring Apr 29, 2024
4366c5f
reverse code
johnloopring Apr 29, 2024
c9409b7
update sdk version
johnloopring May 6, 2024
e85c70c
Merge branch 'prd-fix' into staging
johnloopring May 6, 2024
bfce098
fix bugs
johnloopring May 8, 2024
1a87645
Merge branch 'bridgeBugFix' into staging
johnloopring May 8, 2024
9388670
fix a bug
johnloopring May 8, 2024
1684489
Merge branch 'contactFix' into staging
johnloopring May 8, 2024
d4030ae
fix address checking wrong network
johnloopring May 8, 2024
698a7b4
fit 3.0.0 wallet version
johnloopring May 8, 2024
4f47205
Merge branch 'contactFix' into staging
johnloopring May 8, 2024
8d87c3b
add protection
johnloopring May 13, 2024
1098ae4
Merge branch 'USDCBugFix' into staging
johnloopring May 13, 2024
eaaa504
block fee rate hint
johnloopring May 14, 2024
ecc80cb
Merge branch 'feeHint' into staging
johnloopring May 14, 2024
9892352
fix a bug
johnloopring May 14, 2024
3fc05f2
Merge branch 'contactFix' into staging
johnloopring May 14, 2024
07d75e3
fix a bug
johnloopring May 14, 2024
9777804
Merge branch 'contactFix' into staging
johnloopring May 14, 2024
9037d71
fix a bug
johnloopring May 14, 2024
a16d06a
Merge branch 'contactFix' into staging
johnloopring May 14, 2024
417dc1a
update sdk version
johnloopring May 15, 2024
04feea4
Merge branch 'contactFix' into staging
johnloopring May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@loopring-web/loopring-sdk": "3.8.23",
"@loopring-web/loopring-sdk": "3.8.26",
"@loopring-web/recharts": "^2.0.10",
"@loopring-web/web3-provider": "1.4.16",
"@mui/lab": "5.0.0-alpha.45",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ export const { NetworkMap, ChainTests, MapChainId, ChainIdExtends } = (
label: 'Görli',
chainId: '5',
isTest: true,
walletType: 'ETHEREUM',
walletType: 'GOERLI',
},
11155111: {
label: 'Sepolia',
chainId: '11155111',
isTest: true,
walletType: 'ETHEREUM',
walletType: 'SEPOLIA',
},
// 421613: {
// label: 'ARBGOERLI',
Expand Down Expand Up @@ -171,6 +171,7 @@ if (window) {
}

export const HEBAO_CONTRACT_MAP = [
['V3_0_0', sdk.AddressType.LOOPRING_HEBAO_CONTRACT_3_0_0],
['V2_2_0', sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_2_0],
['V2_1_0', sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_1_0],
['V2_0_0', sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_0_0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ export default {
labelBtradePool: 'Loopring Pool',
labelBtradeToleranceTooltips:
'Your trade will revert if the price changes unfavorably by more than this percentage.',
labelBtradeFeeTooltips: 'The trading fee is fixed at 0.3%.',
labelBtradeFeeTooltips: 'The trading fee is fixed at {{feeRate}}.',
labelBtradeMinReceiveTooltips:
'The price in other liquidity source changes dynamically, the price you see when placing an order may be inconsistent with the final transaction price; also the received amount needs to deduct the fees from converted amount. The protocol can guarantee that the received token is at least this amount.',
labelBtradeInsufficient: 'Insufficient',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ export default {
labelBtradePool: 'Loopring Pool',
labelBtradeToleranceTooltips:
'Your trade will revert if the price changes unfavorably by more than this percentage.',
labelBtradeFeeTooltips: 'The trading fee is fixed at 0.3%.',
labelBtradeFeeTooltips: 'The trading fee is fixed at {{feeRate}}.',
labelBtradeMinReceiveTooltips:
'The price in other liquidity source changes dynamically, the price you see when placing an order may be inconsistent with the final transaction price; also the received amount needs to deduct the fees from converted amount. The protocol can guarantee that the received token is at least this amount.',
labelBtradeInsufficient: 'Insufficient',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const AddressTypeTag = ({ addressType }: { addressType }) => {
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_0_0:
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_1_0:
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_2_0:
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_3_0_0:
return (
<ChipStyle
label={t('labelLoopringWallet')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class StockChart extends React.Component<StockChartProps & IndicatorProps & Stoc
}
return d
})
.accessor((d: any = {}) => d[`sma${periodMA}`])
.accessor((d: any = {}) => d && d[`sma${periodMA}`])
mainIndicatorLst.push({ func: indMA, type: item.indicator })
maToolTipOptions.push({
yAccessor: indMA.accessor(),
Expand All @@ -188,9 +188,9 @@ class StockChart extends React.Component<StockChartProps & IndicatorProps & Stoc
.id(id++)
.options({ windowSize: periodEMA })
.merge((d: any, c: any) => {
d[`ema${periodEMA}`] = c
d && (d[`ema${periodEMA}`] = c)
})
.accessor((d: any = {}) => d[`ema${periodEMA}`])
.accessor((d: any = {}) => d && d[`ema${periodEMA}`])
mainIndicatorLst.push({ func: indEMA, type: item.indicator })
maToolTipOptions.push({
yAccessor: indEMA.accessor(),
Expand All @@ -203,9 +203,9 @@ class StockChart extends React.Component<StockChartProps & IndicatorProps & Stoc
const indBOLL = bollingerBand()
.id(id++)
.merge((d: any, c: any) => {
d.bb = c
d && (d.bb = c)
})
.accessor((d: any = {}) => d.bb)
.accessor((d: any = {}) => d && d.bb)
mainIndicatorLst.push({ func: indBOLL, type: item.indicator })
bollToolTipOption = indBOLL.options()
break
Expand All @@ -229,7 +229,7 @@ class StockChart extends React.Component<StockChartProps & IndicatorProps & Stoc
.merge((d: any, c: any) => {
d.macd = c
})
.accessor((d: any = {}) => d.macd)
.accessor((d: any = {}) => d && d.macd)
subIndicatorLst.push({
func: macdCalculator,
type: item.indicator,
Expand All @@ -241,7 +241,7 @@ class StockChart extends React.Component<StockChartProps & IndicatorProps & Stoc
.merge((d: any, c: any) => {
d.rsi = c
})
.accessor((d: any = {}) => d.rsi)
.accessor((d: any = {}) => d && d.rsi)
subIndicatorLst.push({
func: rsiCalculator,
type: item.indicator,
Expand All @@ -257,7 +257,7 @@ class StockChart extends React.Component<StockChartProps & IndicatorProps & Stoc
.merge((d: any, c: any) => {
d.sar = c
})
.accessor((d: any = {}) => d.sar)
.accessor((d: any = {}) => d && d.sar)
subIndicatorLst.push({
func: sarCalculator,
type: item.indicator,
Expand Down Expand Up @@ -412,7 +412,7 @@ class StockChart extends React.Component<StockChartProps & IndicatorProps & Stoc
<BollingerSeries strokeStyle={bbStroke} />
<BollingerBandTooltip
origin={[8, 64]}
yAccessor={(d) => d.bb}
yAccessor={(d) => d && d.bb}
options={bollToolTipOption}
textFill={colorBase.textPrimary}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,6 @@ export const MarketDetail = ({
) : (
<></>
)}
<Typography
component={'p'}
display={'inline-flex'}
justifyContent={'space-between'}
marginTop={2}
whiteSpace={'pre-line'}
>
{tokenInfo.description}
</Typography>
</Box>
</>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ export const SwapTradeWrap = <
tradeCalcData && tradeCalcData.fee
? `${tradeCalcData.fee} ${buySymbol}` //(parseFloat(tradeCalcData.fee) / 100).toString() + "%"
: EmptyValueTag
myLog('tradeCalcDatatradeCalcData', tradeCalcData)
myLog('tradeCalcDatatradeCalcData', tradeData)

const userTakerRate =
tradeCalcData && tradeCalcData.feeTakerRate
Expand Down Expand Up @@ -474,8 +476,7 @@ export const SwapTradeWrap = <
>
<Tooltip
title={t('labelBtradeFeeTooltips', {
rate: userTakerRate,
value: tradeCostMin,
feeRate: `${(tradeCalcData as any).maxFeeBips / 100}%`,
}).toString()}
placement={'top'}
>
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/hooks/common/useAddrCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export const useAddressCheck = (checkLayer2Status: boolean = true) => {
})
}
}
}, [])
}, [defaultNetwork])

const debounceCheck = _.debounce(
async (address) => {
Expand All @@ -217,6 +217,7 @@ export const useAddressCheck = (checkLayer2Status: boolean = true) => {
sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_0_0,
sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_1_0,
sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_2_0,
sdk.AddressType.LOOPRING_HEBAO_CONTRACT_3_0_0,
sdk.AddressType.EXCHANGE_OTHER,
sdk.AddressType.EXCHANGE_BINANCE,
sdk.AddressType.EXCHANGE_OKX,
Expand All @@ -241,7 +242,8 @@ export const useAddressCheck = (checkLayer2Status: boolean = true) => {
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_1_2_0:
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_0_0:
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_1_0:
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_2_0: {
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_2_0:
case sdk.AddressType.LOOPRING_HEBAO_CONTRACT_3_0_0: {
if (found.addressType === sdk.AddressType.LOOPRING_HEBAO_CF) {
// recheck CF Wallet
const walletTypeResponse = await LoopringAPI.walletAPI?.getWalletType({
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/hooks/common/useAllowances.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import BigNumber from 'bignumber.js'
import { LoopringAPI, useTokenMap } from '../../index'
import { LoopringAPI, useSystem, useTokenMap } from '../../index'
import React from 'react'
import * as sdk from '@loopring-web/loopring-sdk'

export function useAllowances({ owner, symbol }: { owner: string; symbol: string }) {
const { tokenMap } = useTokenMap()
const { status: systemStatus } = useSystem()

const [allowanceInfo, setAllowanceInfo] = React.useState<{
allowance: BigNumber
Expand Down Expand Up @@ -45,7 +46,7 @@ export function useAllowances({ owner, symbol }: { owner: string; symbol: string

React.useEffect(() => {
updateAllowance(symbol)
}, [owner, symbol])
}, [owner, symbol, systemStatus])

return {
allowanceInfo,
Expand Down
18 changes: 14 additions & 4 deletions packages/core/src/hooks/common/useInjectWeb3Modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const useInjectWeb3Modal = (type: 'MAIN' | 'EARN' | 'BRIDGE' | 'GUARDIAN'
}, [event])
React.useEffect(() => {
;(async () => {
if (address && walletProvider ) {
if (address && walletProvider) {
const { defaultNetwork } = store.getState().settings
const accAddress = store.getState().account.accAddress
if (address.toLowerCase() !== accAddress.toLowerCase() || chainId !== defaultNetwork) {
Expand All @@ -102,13 +102,23 @@ export const useInjectWeb3Modal = (type: 'MAIN' | 'EARN' | 'BRIDGE' | 'GUARDIAN'
)
store.dispatch(setDefaultNetwork(chainId))
}
if (type === 'BRIDGE') {
updateWalletLayer1()
}
checkAccount(address, chainId)
}
if (type === 'BRIDGE' && address && status === SagaStatus.DONE) {
updateWalletLayer1()
}
})()
}, [address, walletProvider, chainId, status])
React.useEffect(() => {
if (type === 'BRIDGE') {
store.dispatch(
updateSystem({
chainId,
}),
)
store.dispatch(setDefaultNetwork(chainId))
}
}, [])
React.useEffect(() => {
if (walletProvider) {
if (walletProvider.isMetaMask) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useractions/hookSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ export const useSwap = <
// @ts-ignore
const [, _coinA] = market.match(/(\w+)-(\w+)/i)
btos = getValuePrecisionThousand(
1 / Number(close.replaceAll(sdk.SEP, '')),
1 / Number(typeof close === 'number' ? close : close.replaceAll(sdk.SEP, '')),
tokenMap[_coinA].precision,
tokenMap[_coinA].precision,
tokenMap[_coinA].precision,
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/hooks/useractions/useContact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ export const useContact = ({ viewHeightRatio = 0.85, viewHeightOffset = 130 }) =
type: ToastType.error,
content: t('labelContactsDeleteFailed'),
})
return
}
// setPage to page - 1 if there is only one contact on this page when page >= 1
if (
page > 1 && page === Math.ceil(contacts.length / pageSize) && contacts.length % pageSize === 1
) {
setPage(page - 1)
}
updateContacts()
setToastOpen({
Expand All @@ -158,7 +165,7 @@ export const useContact = ({ viewHeightRatio = 0.85, viewHeightOffset = 130 }) =
onCloseDelete()
// if(result as sdk.RESULT_INFO)
},
[contacts],
[contacts, page, pageSize],
)
return {
contacts:
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useractions/useDeposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export const useDeposit = <
return () => {
subscription.unsubscribe()
}
}, [subject])
}, [subject, accountStatus, systemStatus])

const title =
account.readyState === AccountStatus.NO_ACCOUNT
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/stores/contacts/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { updateContacts, getContactsStatus } from './reducer'

import { LoopringAPI, store } from '../../index'
import * as sdk from '@loopring-web/loopring-sdk'
import { NetworkMap } from '@loopring-web/common-resources'

const getContractsApi = async ({ limit = 100 }: { limit?: number }) => {
const { isContractAddress, isCFAddress, accountId, apiKey } = store.getState().account
const { defaultNetwork } = store.getState().settings
let contacts: any[] = []
if (apiKey && LoopringAPI.contactAPI && accountId) {
const response = await LoopringAPI.contactAPI?.getContacts(
Expand All @@ -14,6 +16,8 @@ const getContractsApi = async ({ limit = 100 }: { limit?: number }) => {
accountId,
limit,
offset: 0,
// @ts-ignore
network: NetworkMap[defaultNetwork].walletType,
},
apiKey,
)
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/utils/addressTypeMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const addressToExWalletMap: [
[sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_0_0, WALLET_TYPE.Loopring],
[sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_1_0, WALLET_TYPE.Loopring],
[sdk.AddressType.LOOPRING_HEBAO_CONTRACT_2_2_0, WALLET_TYPE.Loopring],
[sdk.AddressType.LOOPRING_HEBAO_CONTRACT_3_0_0, WALLET_TYPE.Loopring],
[sdk.AddressType.CONTRACT, WALLET_TYPE.OtherSmart],
]
export const addressToExWalletMapFn = (a: (typeof sdk.AddressType)[sdk.AddressTypeKeys]) => {
Expand Down
21 changes: 13 additions & 8 deletions packages/webapp/src/pages/QuotePage/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,19 @@ export function useTickList<C extends { [key: string]: string }>() {
}, [] as QuoteTableRawDataItem[])
: []

const newTickListWithPrecision = _tickList.map((o: any) => {
const pair = o.__rawTicker__.symbol
const precision = marketMap ? marketMap[pair]?.precisionForPrice : undefined
return {
...o,
precision,
}
})
const newTickListWithPrecision = _tickList
.filter((o: any) => {
const pair = o.__rawTicker__.symbol
return marketMap ? marketMap[pair]?.enabled : undefined
})
.map((o: any) => {
const pair = o.__rawTicker__.symbol
const precision = marketMap ? marketMap[pair]?.precisionForPrice : undefined
return {
...o,
precision,
}
})

setTickList(newTickListWithPrecision)
while (_recommendationsFloat.length < 4) {
Expand Down