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

Fe/transactions sdk #1682

Merged
merged 28 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
90651dc
Show to Address text in Transaction only when destination address is …
bigboydiamonds Dec 19, 2023
4431297
Fire off fallback txn slightly before isDelayed turns true
bigboydiamonds Dec 19, 2023
d172046
Simplify PendingTransaction, remove unnecessary useMemo
bigboydiamonds Dec 19, 2023
f99b2ed
Simplify
bigboydiamonds Dec 19, 2023
b598938
Use `checkTransactionsExist` utils to check if store value exists
bigboydiamonds Dec 19, 2023
5b45117
Check fallbackQueryHistoricalTransactions does not include matching k…
bigboydiamonds Dec 19, 2023
2404660
rm legacy util
bigboydiamonds Dec 19, 2023
6405cb0
`getEstimatedBridgeTime` utils
bigboydiamonds Dec 19, 2023
07faa0b
use `getEstimatedBridgeTime` to calculate completion time
bigboydiamonds Dec 19, 2023
274d490
Simplify
bigboydiamonds Dec 20, 2023
16c1c3c
Update awaitingPendingCompletionTransaction when fallbackQueryHistori…
bigboydiamonds Dec 20, 2023
9fe496b
rm unused imports
bigboydiamonds Dec 20, 2023
c1e039a
Add border radius on initializing-status component in PendingTransaction
bigboydiamonds Dec 20, 2023
5008498
Apply styling in shared class
bigboydiamonds Dec 20, 2023
ea07781
`useBridgeTxStatus` hook using `sdk.getBridgeTxStatus`
bigboydiamonds Dec 20, 2023
334c0fc
Implement functionality for fetching bridge tx status
bigboydiamonds Dec 20, 2023
d67bd64
`useBridgeTxStatus` working, returning if is complete
bigboydiamonds Dec 20, 2023
39a320f
`useBridgeTxStatus` can finalize pending tx visual state
bigboydiamonds Dec 20, 2023
23584fe
Use Dest explorer link if kappa not avail to construct synapse explor…
bigboydiamonds Dec 20, 2023
1ba125f
Revert polling interval
bigboydiamonds Dec 20, 2023
3e75a8c
Add back fallback hooks
bigboydiamonds Dec 20, 2023
11601f8
.
bigboydiamonds Dec 20, 2023
617c25e
Update isCompleted state with order of importance between props
bigboydiamonds Dec 20, 2023
74b740f
Merge branch 'fe-release' into fe/transactions-sdk
bigboydiamonds Dec 21, 2023
8009a12
Merge branch 'fe-release' into fe/transactions-sdk
bigboydiamonds Dec 21, 2023
c126e7c
Fire off sdk txn queries at same time as fallback queries
bigboydiamonds Dec 22, 2023
5801539
Merge branch 'master' into fe/transactions-sdk
bigboydiamonds Jan 4, 2024
c9f5bcb
Merge branch 'fe/transactions-sdk' of https://github.com/synapsecns/s…
bigboydiamonds Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,19 @@ export const MostRecentTransaction = () => {
return transactions
}, [userHistoricalTransactions, fallbackQueryHistoricalTransactions])

const lastPendingBridgeTransaction: PendingBridgeTransaction = useMemo(() => {
return pendingBridgeTransactions?.[0]
}, [pendingBridgeTransactions])
const lastPendingBridgeTransaction: PendingBridgeTransaction =
pendingBridgeTransactions?.[0]

const lastPendingTransaction: BridgeTransaction = useMemo(() => {
return pendingAwaitingCompletionTransactionsWithFallback?.[0]
}, [pendingAwaitingCompletionTransactionsWithFallback])
const lastPendingTransaction: BridgeTransaction =
pendingAwaitingCompletionTransactionsWithFallback?.[0]

const lastHistoricalTransaction: BridgeTransaction = useMemo(() => {
return userHistoricalTransactionsWithFallback?.[0]
}, [userHistoricalTransactionsWithFallback])
const lastHistoricalTransaction: BridgeTransaction =
userHistoricalTransactionsWithFallback?.[0]

const recentMinutesInUnix: number = 15 * 60

const isLastHistoricalTransactionRecent: boolean = useMemo(
() =>
currentTime - lastHistoricalTransaction?.toInfo?.time <
recentMinutesInUnix,
[currentTime]
)
const isLastHistoricalTransactionRecent: boolean =
currentTime - lastHistoricalTransaction?.toInfo?.time < recentMinutesInUnix

const seenLastHistoricalTransaction: boolean = useMemo(() => {
if (!seenHistoricalTransactions || !userHistoricalTransactions) {
Expand All @@ -133,136 +126,114 @@ export const MostRecentTransaction = () => {

let transaction

return useMemo(() => {
if (
isUserHistoricalTransactionsLoading ||
isUserPendingTransactionsLoading
) {
return null
}

if (!masqueradeActive && lastPendingBridgeTransaction) {
transaction = lastPendingBridgeTransaction as PendingBridgeTransaction
return (
<div
data-test-id="most-recent-transaction-bridge-pending"
className="mt-6"
>
<PendingTransaction
connectedAddress={address as Address}
originChain={transaction.originChain as Chain}
originToken={transaction.originToken as Token}
originValue={Number(transaction.originValue)}
destinationChain={transaction.destinationChain as Chain}
destinationToken={transaction.destinationToken as Token}
estimatedDuration={transaction?.estimatedTime}
bridgeModuleName={transaction?.bridgeModuleName}
startedTimestamp={
transaction.timestamp ? transaction.timestamp : transaction.id
}
transactionHash={transaction.transactionHash}
isSubmitted={transaction.isSubmitted}
transactionType={TransactionType.PENDING}
/>
</div>
)
}

if (!masqueradeActive && lastPendingTransaction) {
transaction = lastPendingTransaction as BridgeTransaction
return (
<div data-test-id="most-recent-transaction-pending" className="mt-6">
<PendingTransaction
connectedAddress={address as Address}
startedTimestamp={transaction?.fromInfo?.time}
transactionHash={transaction?.fromInfo?.txnHash}
transactionType={TransactionType.PENDING}
originValue={transaction?.fromInfo?.value}
originChain={CHAINS_BY_ID[transaction?.fromInfo?.chainID] as Chain}
destinationChain={
CHAINS_BY_ID[transaction?.fromInfo?.destinationChainID] as Chain
}
originToken={
tokenAddressToToken(
transaction?.fromInfo?.chainID,
transaction?.fromInfo?.tokenAddress
) as Token
}
destinationToken={
tokenAddressToToken(
transaction?.toInfo?.chainID,
transaction?.toInfo?.tokenAddress
) as Token
}
formattedEventType={transaction?.fromInfo?.formattedEventType}
estimatedDuration={transaction?.estimatedTime}
destinationAddress={transaction?.fromInfo?.address as Address}
isSubmitted={transaction?.fromInfo?.txnHash ? true : false}
isCompleted={transaction?.toInfo?.time ? true : false}
kappa={transaction?.kappa}
/>
</div>
)
}

if (
!masqueradeActive &&
lastHistoricalTransaction &&
isLastHistoricalTransactionRecent &&
!seenLastHistoricalTransaction
) {
transaction = lastHistoricalTransaction as BridgeTransaction
return (
<div data-test-id="most-recent-transaction-historical" className="mt-6">
<PendingTransaction
connectedAddress={address as Address}
destinationAddress={transaction?.fromInfo?.address as Address}
startedTimestamp={transaction?.fromInfo?.time}
completedTimestamp={transaction?.toInfo?.time}
transactionHash={transaction?.fromInfo?.txnHash}
kappa={transaction?.kappa}
transactionType={TransactionType.PENDING}
originValue={transaction?.fromInfo?.value}
destinationValue={transaction?.toInfo?.value}
originChain={CHAINS_BY_ID[transaction?.fromInfo?.chainID] as Chain}
destinationChain={
CHAINS_BY_ID[transaction?.fromInfo?.destinationChainID] as Chain
}
originToken={
tokenAddressToToken(
transaction?.fromInfo?.chainID,
transaction?.fromInfo?.tokenAddress
) as Token
}
destinationToken={
tokenAddressToToken(
transaction?.toInfo?.chainID,
transaction?.toInfo?.tokenAddress
) as Token
}
formattedEventType={transaction?.fromInfo?.formattedEventType}
isSubmitted={transaction?.fromInfo?.txnHash ? true : false}
isCompleted={true}
/>
</div>
)
}
}, [
currentTime,
lastPendingBridgeTransaction,
lastHistoricalTransaction,
lastPendingTransaction,
userHistoricalTransactions,
isUserHistoricalTransactionsLoading,
isUserPendingTransactionsLoading,
seenHistoricalTransactions,
pendingAwaitingCompletionTransactions,
fallbackQueryHistoricalTransactions,
fallbackQueryPendingTransactions,
pendingBridgeTransactions,
masqueradeActive,
seenLastHistoricalTransaction,
isUserHistoricalTransactionsLoading,
isUserPendingTransactionsLoading,
])
if (isUserHistoricalTransactionsLoading || isUserPendingTransactionsLoading) {
return null
}

if (!masqueradeActive && lastPendingBridgeTransaction) {
transaction = lastPendingBridgeTransaction as PendingBridgeTransaction
return (
<div
data-test-id="most-recent-transaction-bridge-pending"
className="mt-6"
>
<PendingTransaction
connectedAddress={address as Address}
originChain={transaction.originChain as Chain}
originToken={transaction.originToken as Token}
originValue={Number(transaction.originValue)}
destinationChain={transaction.destinationChain as Chain}
destinationToken={transaction.destinationToken as Token}
estimatedDuration={transaction?.estimatedTime}
bridgeModuleName={transaction?.bridgeModuleName}
startedTimestamp={
transaction.timestamp ? transaction.timestamp : transaction.id
}
transactionHash={transaction.transactionHash}
isSubmitted={transaction.isSubmitted}
transactionType={TransactionType.PENDING}
/>
</div>
)
}

if (!masqueradeActive && lastPendingTransaction) {
transaction = lastPendingTransaction as BridgeTransaction
return (
<div data-test-id="most-recent-transaction-pending" className="mt-6">
<PendingTransaction
connectedAddress={address as Address}
startedTimestamp={transaction?.fromInfo?.time}
transactionHash={transaction?.fromInfo?.txnHash}
transactionType={TransactionType.PENDING}
originValue={transaction?.fromInfo?.value}
originChain={CHAINS_BY_ID[transaction?.fromInfo?.chainID] as Chain}
destinationChain={
CHAINS_BY_ID[transaction?.fromInfo?.destinationChainID] as Chain
}
originToken={
tokenAddressToToken(
transaction?.fromInfo?.chainID,
transaction?.fromInfo?.tokenAddress
) as Token
}
destinationToken={
tokenAddressToToken(
transaction?.toInfo?.chainID,
transaction?.toInfo?.tokenAddress
) as Token
}
formattedEventType={transaction?.fromInfo?.formattedEventType}
estimatedDuration={transaction?.estimatedTime}
destinationAddress={transaction?.fromInfo?.address as Address}
isSubmitted={transaction?.fromInfo?.txnHash ? true : false}
isCompleted={transaction?.toInfo?.time ? true : false}
kappa={transaction?.kappa}
/>
</div>
)
}

if (
!masqueradeActive &&
lastHistoricalTransaction &&
isLastHistoricalTransactionRecent &&
!seenLastHistoricalTransaction
) {
transaction = lastHistoricalTransaction as BridgeTransaction
return (
<div data-test-id="most-recent-transaction-historical" className="mt-6">
<PendingTransaction
connectedAddress={address as Address}
destinationAddress={transaction?.fromInfo?.address as Address}
startedTimestamp={transaction?.fromInfo?.time}
completedTimestamp={transaction?.toInfo?.time}
transactionHash={transaction?.fromInfo?.txnHash}
kappa={transaction?.kappa}
transactionType={TransactionType.PENDING}
originValue={transaction?.fromInfo?.value}
destinationValue={transaction?.toInfo?.value}
originChain={CHAINS_BY_ID[transaction?.fromInfo?.chainID] as Chain}
destinationChain={
CHAINS_BY_ID[transaction?.fromInfo?.destinationChainID] as Chain
}
originToken={
tokenAddressToToken(
transaction?.fromInfo?.chainID,
transaction?.fromInfo?.tokenAddress
) as Token
}
destinationToken={
tokenAddressToToken(
transaction?.toInfo?.chainID,
transaction?.toInfo?.tokenAddress
) as Token
}
formattedEventType={transaction?.fromInfo?.formattedEventType}
isSubmitted={transaction?.fromInfo?.txnHash ? true : false}
isCompleted={true}
/>
</div>
)
}
}
Loading
Loading