Skip to content

Commit

Permalink
Merge branch 'styles/approval_and_bridge' into tmp/20241210
Browse files Browse the repository at this point in the history
  • Loading branch information
hz002 committed Dec 11, 2024
2 parents 670d220 + ed106ce commit 862ca55
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@rabby-wallet/object-multiplex": "workspace:^",
"@rabby-wallet/persist-store": "workspace:^",
"@rabby-wallet/rabby-action": "0.1.8",
"@rabby-wallet/rabby-api": "0.8.5",
"@rabby-wallet/rabby-api": "0.9.3-beta.2",
"@rabby-wallet/rabby-security-engine": "2.0.7",
"@rabby-wallet/rabby-sign-bvm": "0.1.0",
"@rabby-wallet/rabby-swap": "0.0.42",
Expand Down
18 changes: 11 additions & 7 deletions apps/mobile/src/screens/Bridge/components/BridgeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,6 @@ export const BridgeContent = ({ isForMultipleAdderss = false }) => {

const [fetchingBridgeQuote, setFetchingBridgeQuote] = useState(false);

const btnText = useMemo(() => {
if (selectedBridgeQuote?.shouldApproveToken) {
return t('page.bridge.approve-and-bridge');
}
return t('page.bridge.title');
}, [t, selectedBridgeQuote?.shouldApproveToken]);

const [isShowSign, setIsShowSign] = useState(false);

const gotoBridge = useMemoizedFn(async () => {
Expand Down Expand Up @@ -500,6 +493,17 @@ export const BridgeContent = ({ isForMultipleAdderss = false }) => {
quoteLoading ||
!quoteList?.length;

const btnText = useMemo(() => {
if (btnDisabled) {
return t('page.bridge.title');
}

if (selectedBridgeQuote?.shouldApproveToken) {
return t('page.bridge.approve-and-bridge');
}
return t('page.bridge.title');
}, [t, selectedBridgeQuote?.shouldApproveToken, btnDisabled]);

const navigation = useNavigation();

const handleConfirm = () => {
Expand Down
18 changes: 3 additions & 15 deletions apps/mobile/src/screens/Home/hooks/approvals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ const appprovalsMap = atom<IApprovalsInfo>({
address2approvalCount: {},
});

// TODO: ONLY FOR TEST need use rabby-api pkg
const getApprovalAccount = async (address: string) => {
try {
const approvalCountRes = await fetch(
`https://approval.rabby-api.debank.dbkops.com/v1/user/total_approval_asset_cnt?id=${address}`,
).then(res => res.json());
return approvalCountRes?.['total_asset_cnt'] || 0;
} catch (error) {
console.log('🔍 CUSTOM_LOGGER:=>: getApprovalAccount)', error);
return 0;
}
};
export const useApprovalAlertCounts = () => {
const [appprovalInfo, setAppprovalInfo] = useAtom(appprovalsMap);
const { accounts, fetchAccounts } = useAccounts({
Expand All @@ -101,11 +89,11 @@ export const useApprovalAlertCounts = () => {
displayAccounts.map(async acc => {
try {
const data = await openapi.approvalStatus(acc.address);
// TODO: const approvalCount = await openapi.getApprovalCount(acc.address);
console.log('🔍 CUSTOM_LOGGER:=>: acc.address)', acc.address);
const approvalCount = await getApprovalAccount(acc.address);
const approvalCountRes = await openapi.getApprovalCount(acc.address);

address2ApprovalCount[acc.address] = approvalCount;
address2ApprovalCount[acc.address] =
approvalCountRes['total_asset_cnt'];
if (data) {
const alertCount = data.reduce(
(pre, now) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/biz-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@rabby-wallet/base-utils": "workspace:^",
"@rabby-wallet/rabby-api": "0.7.25",
"@rabby-wallet/rabby-api": "0.9.3-beta.2",
"bignumber.js": "^9.1.2",
"ethereumjs-util": "^7.1.5"
},
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6218,7 +6218,7 @@ __metadata:
dependencies:
"@metamask/auto-changelog": ^3.4.3
"@rabby-wallet/base-utils": "workspace:^"
"@rabby-wallet/rabby-api": 0.7.25
"@rabby-wallet/rabby-api": 0.9.3-beta.2
"@types/jest": ^27.4.1
"@types/sinon": ^9.0.10
bignumber.js: ^9.1.2
Expand Down Expand Up @@ -6574,9 +6574,9 @@ __metadata:
languageName: node
linkType: hard

"@rabby-wallet/rabby-api@npm:0.8.5":
version: 0.8.5
resolution: "@rabby-wallet/rabby-api@npm:0.8.5"
"@rabby-wallet/rabby-api@npm:0.9.3-beta.2":
version: 0.9.3-beta.2
resolution: "@rabby-wallet/rabby-api@npm:0.9.3-beta.2"
dependencies:
"@rabby-wallet/rabby-sign": 0.4.0
axios: ^0.27.2
Expand All @@ -6587,7 +6587,7 @@ __metadata:
peerDependencies:
"@debank/common": ^0.3.9
"@rabby-wallet/rabby-sign": ">= 0.3"
checksum: 6c3c602761b289c9fccc50953059f6ec004e828529529527d7a13bc76a29aa19089497e12a45ce88e3e36a259b48fc2ce8770b18ceca089cefac748a29b0314a
checksum: a6ffb174a5a759fbdd9966fad4c148212cbd80c34b2b2b2191354281cafcdc39bf31b60c7128776cac4cdf6e6d0e46f49d2b3f808c6e5e64cdf48d33e17cbea6
languageName: node
linkType: hard

Expand Down Expand Up @@ -27677,7 +27677,7 @@ __metadata:
"@rabby-wallet/object-multiplex": "workspace:^"
"@rabby-wallet/persist-store": "workspace:^"
"@rabby-wallet/rabby-action": 0.1.8
"@rabby-wallet/rabby-api": 0.8.5
"@rabby-wallet/rabby-api": 0.9.3-beta.2
"@rabby-wallet/rabby-security-engine": 2.0.7
"@rabby-wallet/rabby-sign-bvm": 0.1.0
"@rabby-wallet/rabby-swap": 0.0.42
Expand Down

0 comments on commit 862ca55

Please sign in to comment.