Skip to content

Commit

Permalink
Merge branch 'fix/t' into tmp/20240816
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvvvv1vvvvvv committed Aug 15, 2024
2 parents 2cf64c1 + 15a1d8f commit 2386470
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 114 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@rabby-wallet/eth-watch-keyring": "1.0.0",
"@rabby-wallet/gnosis-sdk": "1.3.8",
"@rabby-wallet/page-provider": "0.4.0",
"@rabby-wallet/rabby-api": "0.7.25",
"@rabby-wallet/rabby-api": "0.7.26",
"@rabby-wallet/rabby-security-engine": "2.0.5",
"@rabby-wallet/rabby-swap": "0.0.39",
"@rabby-wallet/widgets": "1.0.9",
Expand Down
111 changes: 51 additions & 60 deletions src/ui/views/Approval/components/Actions/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -656,22 +656,25 @@ export const fetchNFTApproveRequiredData = async ({
};

queue.add(async () => {
const credit = await apiProvider.getContractCredit(spender, chainId);
result.rank = credit.rank_at;
});

queue.add(async () => {
const { desc } = await apiProvider.addrDesc(spender);
if (desc.contract && desc.contract[chainId]) {
result.bornAt = desc.contract[chainId].create_at;
}
if (!desc.contract?.[chainId]) {
const contractInfo = await apiProvider.getContractInfo(spender, chainId);
if (!contractInfo) {
result.isEOA = true;
result.bornAt = desc.born_at;
result.rank = null;
} else {
result.rank = contractInfo.credit.rank_at;
result.riskExposure = contractInfo.top_nft_spend_usd_value;
result.bornAt = contractInfo.create_at;
result.isDanger =
contractInfo.is_danger.auto || contractInfo.is_danger.edit;
result.protocol = contractInfo.protocol;
}
result.protocol = getProtocol(desc.protocol, chainId);
result.isDanger = desc.contract?.[chainId]?.is_danger || null;
});
if (result.isEOA) {
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(spender);
result.bornAt = desc.born_at;
});
}
queue.add(async () => {
const hasInteraction = await apiProvider.hasInteraction(
address,
Expand All @@ -680,13 +683,6 @@ export const fetchNFTApproveRequiredData = async ({
);
result.hasInteraction = hasInteraction.has_interaction;
});
queue.add(async () => {
const { usd_value } = await apiProvider.getTokenNFTTrustValue(
chainId,
spender
);
result.riskExposure = usd_value;
});
await waitQueueFinished(queue);
return result;
};
Expand Down Expand Up @@ -723,34 +719,31 @@ const fetchTokenApproveRequireData = async ({
},
};
queue.add(async () => {
const credit = await apiProvider.getContractCredit(spender, chainId);
result.rank = credit.rank_at;
});
queue.add(async () => {
const { usd_value } = await apiProvider.tokenApproveTrustValue(
spender,
chainId
);
result.riskExposure = usd_value;
const contractInfo = await apiProvider.getContractInfo(spender, chainId);
if (!contractInfo) {
result.isEOA = true;
result.rank = null;
} else {
result.rank = contractInfo.credit.rank_at;
result.riskExposure = contractInfo.spend_usd_value;
result.bornAt = contractInfo.create_at;
result.isDanger =
contractInfo.is_danger.auto || contractInfo.is_danger.edit;
result.protocol = contractInfo.protocol;
}
});
if (token) {
queue.add(async () => {
const t = await apiProvider.getToken(address, chainId, token.id);
result.token = t;
});
}
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(spender);
if (desc.contract && desc.contract[chainId]) {
result.bornAt = desc.contract[chainId].create_at;
}
if (!desc.contract?.[chainId]) {
result.isEOA = true;
if (result.isEOA) {
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(spender);
result.bornAt = desc.born_at;
}
result.isDanger = desc.contract?.[chainId]?.is_danger || null;
result.protocol = getProtocol(desc.protocol, chainId);
});
});
}
queue.add(async () => {
const hasInteraction = await apiProvider.hasInteraction(
address,
Expand Down Expand Up @@ -802,17 +795,14 @@ export const fetchActionRequiredData = async ({
receiverInWallet,
};
queue.add(async () => {
const credit = await apiProvider.getContractCredit(id, chainId);
result.rank = credit.rank_at;
});
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(id);
if (desc.contract && desc.contract[chainId]) {
result.bornAt = desc.contract[chainId].create_at;
const contractInfo = await apiProvider.getContractInfo(id, chainId);
if (!contractInfo) {
result.rank = null;
} else {
result.bornAt = desc.born_at;
result.rank = contractInfo.credit.rank_at;
result.bornAt = contractInfo.create_at;
result.protocol = contractInfo.protocol;
}
result.protocol = getProtocol(desc.protocol, chainId);
});
queue.add(async () => {
const hasInteraction = await apiProvider.hasInteraction(
Expand All @@ -839,17 +829,14 @@ export const fetchActionRequiredData = async ({
receiverInWallet,
};
queue.add(async () => {
const credit = await apiProvider.getContractCredit(id, chainId);
result.rank = credit.rank_at;
});
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(id);
if (desc.contract && desc.contract[chainId]) {
result.bornAt = desc.contract[chainId].create_at;
const contractInfo = await apiProvider.getContractInfo(id, chainId);
if (!contractInfo) {
result.rank = null;
} else {
result.bornAt = desc.born_at;
result.rank = contractInfo.credit.rank_at;
result.bornAt = contractInfo.create_at;
result.protocol = contractInfo.protocol;
}
result.protocol = getProtocol(desc.protocol, chainId);
});
queue.add(async () => {
const hasInteraction = await apiProvider.hasInteraction(
Expand Down Expand Up @@ -1175,11 +1162,15 @@ export const fetchActionRequiredData = async ({
receiverInWallet: false,
};
queue.add(async () => {
const credit = await apiProvider.getContractCredit(
const contractInfo = await apiProvider.getContractInfo(
contractCall.contract.id,
chainId
);
result.rank = credit.rank_at;
if (!contractInfo) {
result.rank = null;
} else {
result.rank = contractInfo.credit.rank_at;
}
});
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(contractCall.contract.id);
Expand Down
98 changes: 49 additions & 49 deletions src/ui/views/Approval/components/TypedDataActions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,19 +315,25 @@ export const fetchContractRequireData = async (
unexpectedAddr: null,
receiverInWallet: false,
};
let isEOA = false;
queue.add(async () => {
const credit = await apiProvider.getContractCredit(id, chainId);
result.rank = credit.rank_at;
});
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(id);
if (desc.contract && desc.contract[chainId]) {
result.bornAt = desc.contract[chainId].create_at;
const contractInfo = await apiProvider.getContractInfo(id, chainId);
if (!contractInfo) {
result.rank = null;
isEOA = true;
} else {
result.bornAt = desc.born_at;
result.rank = contractInfo.credit.rank_at;
result.bornAt = contractInfo.create_at;
result.protocol = contractInfo.protocol;
}
result.protocol = getProtocol(desc.protocol, chainId);
});

if (isEOA) {
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(id);
result.bornAt = desc.born_at;
});
}
queue.add(async () => {
const hasInteraction = await apiProvider.hasInteraction(
sender,
Expand Down Expand Up @@ -459,32 +465,29 @@ const fetchTokenApproveRequireData = async ({
},
};
queue.add(async () => {
const credit = await apiProvider.getContractCredit(spender, chainId);
result.rank = credit.rank_at;
});
queue.add(async () => {
const { usd_value } = await apiProvider.tokenApproveExposure(
spender,
chainId
);
result.riskExposure = usd_value;
const contractInfo = await apiProvider.getContractInfo(spender, chainId);
if (!contractInfo) {
result.isEOA = true;
result.rank = null;
} else {
result.rank = contractInfo.credit.rank_at;
result.riskExposure = contractInfo.spend_usd_value;
result.bornAt = contractInfo.create_at;
result.isDanger =
contractInfo.is_danger.auto || contractInfo.is_danger.edit;
result.protocol = contractInfo.protocol;
}
});
queue.add(async () => {
const t = await apiProvider.getToken(address, chainId, token.id);
result.token = t;
});
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(spender);
if (desc.contract && desc.contract[chainId]) {
result.bornAt = desc.contract[chainId].create_at;
}
if (!desc.contract?.[chainId]) {
result.isEOA = true;
if (result.isEOA) {
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(spender);
result.bornAt = desc.born_at;
}
result.isDanger = desc.contract?.[chainId]?.is_danger || null;
result.protocol = getProtocol(desc.protocol, chainId);
});
});
}
queue.add(async () => {
const hasInteraction = await apiProvider.hasInteraction(
address,
Expand Down Expand Up @@ -545,34 +548,31 @@ const fetchBatchTokenApproveRequireData = async ({
})),
};
queue.add(async () => {
const credit = await apiProvider.getContractCredit(spender, chainId);
result.rank = credit.rank_at;
});
queue.add(async () => {
const { usd_value } = await apiProvider.tokenApproveExposure(
spender,
chainId
);
result.riskExposure = usd_value;
const contractInfo = await apiProvider.getContractInfo(spender, chainId);
if (!contractInfo) {
result.isEOA = true;
result.rank = null;
} else {
result.rank = contractInfo.credit.rank_at;
result.riskExposure = contractInfo.spend_usd_value;
result.bornAt = contractInfo.create_at;
result.isDanger =
contractInfo.is_danger.auto || contractInfo.is_danger.edit;
result.protocol = contractInfo.protocol;
}
});
queue.add(async () => {
const list = await Promise.all(
tokens.map((token) => apiProvider.getToken(address, chainId, token.id))
);
result.tokens = list;
});
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(spender);
if (desc.contract && desc.contract[chainId]) {
result.bornAt = desc.contract[chainId].create_at;
}
if (!desc.contract?.[chainId]) {
result.isEOA = true;
if (result.isEOA) {
queue.add(async () => {
const { desc } = await apiProvider.addrDesc(spender);
result.bornAt = desc.born_at;
}
result.isDanger = desc.contract?.[chainId]?.is_danger || null;
result.protocol = getProtocol(desc.protocol, chainId);
});
});
}
queue.add(async () => {
const hasInteraction = await apiProvider.hasInteraction(
address,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4738,10 +4738,10 @@
sinon-chrome "^3.0.1"
webextension-polyfill "0.7.0"

"@rabby-wallet/rabby-api@0.7.25":
version "0.7.25"
resolved "https://registry.yarnpkg.com/@rabby-wallet/rabby-api/-/rabby-api-0.7.25.tgz#c24d469f40507f56693f2447343efefcb50ee36b"
integrity sha512-K/3Sia7WcJuFA3AWoqa8oUO52wm19tJDWvwE/7QEkr+fOeKYw5ycu6IdFiL1HbZGoisqQxtS6jCcv5VgkQWycQ==
"@rabby-wallet/rabby-api@0.7.26":
version "0.7.26"
resolved "https://registry.yarnpkg.com/@rabby-wallet/rabby-api/-/rabby-api-0.7.26.tgz#73273ec1e447a1afbce7523a4f1e31527fbb8372"
integrity sha512-p/0aHoQDY9T0x4Uyr1HsEkbpII3TCe6Fw8vSDlBaI9W+6fahg5J7HKvWbZcjlf7K0zEl3rl4PYqRQ6jBL0oR+w==
dependencies:
"@rabby-wallet/rabby-sign" "^0.3.3"
axios "^0.27.2"
Expand Down

0 comments on commit 2386470

Please sign in to comment.