Skip to content

Commit 55aad58

Browse files
Merge pull request #1090 from wanderwallet/feat/pending-transactions
feat: Add tooltip/notice for pending transactions with cleanup
2 parents 1666b53 + e710f5a commit 55aad58

File tree

266 files changed

+1642
-710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+1642
-710
lines changed

assets/_locales/en/messages.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,10 @@
10911091
"message": "Could not send transaction. Please try again.",
10921092
"description": "Transfer error notification"
10931093
},
1094+
"transfer_error": {
1095+
"message": "Transfer error",
1096+
"description": "Transfer error notification"
1097+
},
10941098
"failed_tx_with_gateway": {
10951099
"message": "Could not send transaction. Please try again or use a different gateway.",
10961100
"description": "Transfer error notification"
@@ -4650,5 +4654,83 @@
46504654
"not_enough_ao_tokens": {
46514655
"message": "Not enough $$AO tokens.",
46524656
"description": "Not enough $AO tokens text"
4657+
},
4658+
"pending_transactions_message": {
4659+
"message": "$COUNT$ pending $TXS$. Total amount pending: $SENT_BALANCE$ $TICKER$ sent, $RECEIVED_BALANCE$ $TICKER$ received",
4660+
"description": "Pending transactions message text",
4661+
"placeholders": {
4662+
"count": {
4663+
"content": "$1",
4664+
"example": "1"
4665+
},
4666+
"txs": {
4667+
"content": "$2",
4668+
"example": "txs"
4669+
},
4670+
"sent_balance": {
4671+
"content": "$3",
4672+
"example": "1000"
4673+
},
4674+
"received_balance": {
4675+
"content": "$4",
4676+
"example": "1000"
4677+
},
4678+
"ticker": {
4679+
"content": "$5",
4680+
"example": "WNDR"
4681+
}
4682+
}
4683+
},
4684+
"pending_transactions_message_sent": {
4685+
"message": "$COUNT$ pending $TXS$. Total amount pending: $SENT_BALANCE$ $TICKER$ sent",
4686+
"description": "Sent pending transactions message text",
4687+
"placeholders": {
4688+
"count": {
4689+
"content": "$1",
4690+
"example": "1"
4691+
},
4692+
"txs": {
4693+
"content": "$2",
4694+
"example": "txs"
4695+
},
4696+
"sent_balance": {
4697+
"content": "$3",
4698+
"example": "1000"
4699+
},
4700+
"ticker": {
4701+
"content": "$4",
4702+
"example": "WNDR"
4703+
}
4704+
}
4705+
},
4706+
"pending_transactions_message_received": {
4707+
"message": "$COUNT$ pending $TXS$. Total amount pending: $RECEIVED_BALANCE$ $TICKER$ received",
4708+
"description": "Received pending transactions message text",
4709+
"placeholders": {
4710+
"count": {
4711+
"content": "$1",
4712+
"example": "1"
4713+
},
4714+
"txs": {
4715+
"content": "$2",
4716+
"example": "txs"
4717+
},
4718+
"received_balance": {
4719+
"content": "$3",
4720+
"example": "1000"
4721+
},
4722+
"ticker": {
4723+
"content": "$4",
4724+
"example": "WNDR"
4725+
}
4726+
}
4727+
},
4728+
"tx_singular": {
4729+
"message": "tx",
4730+
"description": "Tx singular text"
4731+
},
4732+
"tx_plural": {
4733+
"message": "txs",
4734+
"description": "Tx plural text"
46534735
}
46544736
}

assets/_locales/zh_CN/messages.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,10 @@
10791079
"message": "无法发送交易,请重试。",
10801080
"description": "Transfer error notification"
10811081
},
1082+
"transfer_error": {
1083+
"message": "转账错误",
1084+
"description": "Transfer error notification"
1085+
},
10821086
"failed_tx_with_gateway": {
10831087
"message": "无法发送交易。请重试或使用不同的网关。",
10841088
"description": "Transfer error notification"
@@ -4609,5 +4613,83 @@
46094613
"not_enough_ao_tokens": {
46104614
"message": "没有足够的 $$AO 代币。",
46114615
"description": "Not enough $AO tokens text"
4616+
},
4617+
"pending_transactions_message": {
4618+
"message": "$COUNT$ 待处理 $TXS$。待处理总额:$SENT_BALANCE$ $TICKER$ 发送,$RECEIVED_BALANCE$ $TICKER$ 接收",
4619+
"description": "Pending transactions message text",
4620+
"placeholders": {
4621+
"count": {
4622+
"content": "$1",
4623+
"example": "1"
4624+
},
4625+
"txs": {
4626+
"content": "$2",
4627+
"example": "txs"
4628+
},
4629+
"sent_balance": {
4630+
"content": "$3",
4631+
"example": "1000"
4632+
},
4633+
"received_balance": {
4634+
"content": "$4",
4635+
"example": "1000"
4636+
},
4637+
"ticker": {
4638+
"content": "$5",
4639+
"example": "WNDR"
4640+
}
4641+
}
4642+
},
4643+
"pending_transactions_message_sent": {
4644+
"message": "$COUNT$ 待处理 $TXS$。待处理总额:$SENT_BALANCE$ $TICKER$ 发送",
4645+
"description": "Sent pending transactions message text",
4646+
"placeholders": {
4647+
"count": {
4648+
"content": "$1",
4649+
"example": "1"
4650+
},
4651+
"txs": {
4652+
"content": "$2",
4653+
"example": "txs"
4654+
},
4655+
"sent_balance": {
4656+
"content": "$3",
4657+
"example": "1000"
4658+
},
4659+
"ticker": {
4660+
"content": "$4",
4661+
"example": "WNDR"
4662+
}
4663+
}
4664+
},
4665+
"pending_transactions_message_received": {
4666+
"message": "$COUNT$ 待处理 $TXS$。待处理总额:$RECEIVED_BALANCE$ $TICKER$ 接收",
4667+
"description": "Received pending transactions message text",
4668+
"placeholders": {
4669+
"count": {
4670+
"content": "$1",
4671+
"example": "1"
4672+
},
4673+
"txs": {
4674+
"content": "$2",
4675+
"example": "txs"
4676+
},
4677+
"received_balance": {
4678+
"content": "$3",
4679+
"example": "1000"
4680+
},
4681+
"ticker": {
4682+
"content": "$4",
4683+
"example": "WNDR"
4684+
}
4685+
}
4686+
},
4687+
"tx_singular": {
4688+
"message": "交易",
4689+
"description": "Tx singular text"
4690+
},
4691+
"tx_plural": {
4692+
"message": "笔交易",
4693+
"description": "Tx plural text"
46124694
}
46134695
}

assets/icons/clockwise.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"dependencies": {
6161
"@ar.io/sdk": "^3.18.0",
6262
"@arconnect/components": "^1.0.0",
63-
"@arconnect/components-rebrand": "https://github.com/wanderwallet/components-rebrand.git#master",
6463
"@arconnect/keystone-sdk": "^0.0.5",
6564
"@dha-team/arbundles": "^1.0.2",
6665
"@iconicicons/react": "^1.5.0",
@@ -77,6 +76,7 @@
7776
"@tanstack/react-query-persist-client": "^5.84.2",
7877
"@untitled-ui/icons-react": "^0.1.1",
7978
"@vitejs/plugin-react": "^4.3.4",
79+
"@wanderapp/components": "^1.0.1",
8080
"@wanderapp/webext-bridge": "^5.0.7",
8181
"ao-tokens": "^0.0.6",
8282
"ar-gql": "3.1.1",

shim.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DisplayTheme } from "@arconnect/components-rebrand";
1+
import type { DisplayTheme } from "@wanderapp/components";
22
import type { Chunk } from "~api/modules/sign/chunks";
33
import type { InjectedEvents } from "~utils/events";
44
import "styled-components";

src/api/background/background-setup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { handleAuthStateChange } from "./handlers/storage/auth-state-change/auth
3737
import { initInactivityTracking } from "~utils/inactivity/inactivity.utils";
3838
import { handleRefreshWalletLifetimeSavingsAlarm } from "./handlers/alarms/tiers/refresh-wallet-lifetime-savings-alarm.handler";
3939
import { handleSwapMonitorAlarm } from "~routes/popup/swap/utils/alarms/swap-monitor/swap-monitor-alarm.handler";
40+
import { handlePendingTransactionsAlarm } from "./handlers/alarms/pending-transactions/pending-transactions-alarm.handler";
4041

4142
export function setupBackgroundService() {
4243
log(
@@ -105,6 +106,7 @@ export function setupBackgroundService() {
105106
browser.alarms.onAlarm.addListener(handleAoTokenCacheAlarm);
106107
browser.alarms.onAlarm.addListener(handleAoTokensImportAlarm);
107108
browser.alarms.onAlarm.addListener(handleFairLaunchTokensImportAlarm);
109+
browser.alarms.onAlarm.addListener(handlePendingTransactionsAlarm);
108110

109111
// handle keep alive alarm
110112
browser.alarms.onAlarm.addListener((alarm) => {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { type Alarms } from "webextension-polyfill";
2+
import { checkAndCleanPendingTransactions } from "~utils/transactions/pending/pending.utils";
3+
import { log, LOG_GROUP } from "~utils/log/log.utils";
4+
import {
5+
PENDING_TRANSACTIONS_ALARM_NAME,
6+
AO_PENDING_CLEANUP_ALARM_NAME_PREFIX,
7+
} from "~utils/transactions/pending/pending.constants";
8+
9+
/**
10+
* Handle pending transactions cleanup alarm
11+
* Checks and removes pending transactions that are now confirmed in GraphQL
12+
*/
13+
export async function handlePendingTransactionsAlarm(alarm?: Alarms.Alarm) {
14+
if (
15+
alarm?.name !== PENDING_TRANSACTIONS_ALARM_NAME &&
16+
!alarm?.name.startsWith(AO_PENDING_CLEANUP_ALARM_NAME_PREFIX)
17+
) {
18+
return;
19+
}
20+
21+
try {
22+
await checkAndCleanPendingTransactions();
23+
log(LOG_GROUP.TRANSACTIONS, "Pending transactions cleanup completed");
24+
} catch (error) {
25+
log(LOG_GROUP.TRANSACTIONS, "Error in pending transactions alarm:", error);
26+
}
27+
}
28+
29+
export { schedulePendingTransactionsCleanupAlarm } from "~utils/transactions/pending/pending.alarms";

src/api/background/handlers/browser/install/install.handler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { openOrSelectWelcomePage } from "~wallets";
77
import { ExtensionStorage } from "~utils/storage";
88
import { resetAllPermissions } from "./permissions.handler";
99
import { scheduleFairLaunchTokensAlarm } from "~utils/fair_launch/fair_launch.alarms";
10+
import { schedulePendingTransactionsCleanupAlarm } from "~api/background/handlers/alarms/pending-transactions/pending-transactions-alarm.handler";
1011

1112
/**
1213
* On extension installed event handler
@@ -36,6 +37,9 @@ export async function handleInstall(details: Runtime.OnInstalledDetailsType) {
3637

3738
// create alarm to sync labels every 6 hours
3839
browser.alarms.create("sync_labels", { delayInMinutes: 1, periodInMinutes: 360 });
40+
41+
// create alarm to schedule pending transactions cleanup
42+
schedulePendingTransactionsCleanupAlarm();
3943
}
4044

4145
// init monthly AR

src/components/AdaptiveBalanceDisplay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Text } from "@arconnect/components-rebrand";
1+
import { Text } from "@wanderapp/components";
22
import styled from "styled-components";
33
import { formatTokenBalance } from "~tokens/currency";
44
import { TokenLogo } from "~components/popup/TokenLogo";

src/components/Checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Text, type TextProps } from "@arconnect/components-rebrand";
1+
import { Text, type TextProps } from "@wanderapp/components";
22
import { useCallback, useMemo, type HTMLAttributes, type HTMLProps } from "react";
33
import styled from "styled-components";
44

0 commit comments

Comments
 (0)