payment-kit 1.18.50 → 1.18.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/api/src/crons/currency.ts +25 -4
  2. package/api/src/libs/payment.ts +92 -0
  3. package/api/src/routes/connect/shared.ts +5 -3
  4. package/api/src/routes/connect/subscribe.ts +36 -5
  5. package/api/src/routes/invoices.ts +47 -0
  6. package/blocklet.yml +1 -1
  7. package/package.json +18 -18
  8. package/public/currencies/0xBTC.png +0 -0
  9. package/public/currencies/1INCH.svg +1 -0
  10. package/public/currencies/AAVE.svg +1 -0
  11. package/public/currencies/ABT.svg +16 -0
  12. package/public/currencies/ACX.png +0 -0
  13. package/public/currencies/ADX.svg +12 -0
  14. package/public/currencies/AIKEK.png +0 -0
  15. package/public/currencies/AJNA.svg +12 -0
  16. package/public/currencies/AKIRA.png +0 -0
  17. package/public/currencies/ALEX.png +0 -0
  18. package/public/currencies/ALI.png +0 -0
  19. package/public/currencies/ALT.svg +12 -0
  20. package/public/currencies/AMKT.svg +5 -0
  21. package/public/currencies/AMP.svg +7 -0
  22. package/public/currencies/APU.png +0 -0
  23. package/public/currencies/APW.svg +21 -0
  24. package/public/currencies/APX.png +0 -0
  25. package/public/currencies/ARC.png +0 -0
  26. package/public/currencies/ARIA20.svg +1 -0
  27. package/public/currencies/ARPA.svg +1 -0
  28. package/public/currencies/ATH.svg +1 -0
  29. package/public/currencies/AVC.png +0 -0
  30. package/public/currencies/AVRK.png +0 -0
  31. package/public/currencies/AXGT.svg +1 -0
  32. package/public/currencies/AZUR.svg +20 -0
  33. package/public/currencies/BAL.png +0 -0
  34. package/public/currencies/BANK.png +0 -0
  35. package/public/currencies/BAXA.svg +3 -0
  36. package/public/currencies/BCAT.png +0 -0
  37. package/public/currencies/BEPRO.svg +1 -0
  38. package/public/currencies/BERRY.svg +1 -0
  39. package/public/currencies/BICO.svg +11 -0
  40. package/public/currencies/BITBOT.jpg +0 -0
  41. package/public/currencies/BITCOIN.png +0 -0
  42. package/public/currencies/BKN.svg +1 -0
  43. package/public/currencies/BLUE.png +0 -0
  44. package/public/currencies/BNB.png +0 -0
  45. package/public/currencies/BOBA.svg +16 -0
  46. package/public/currencies/BOBO.png +0 -0
  47. package/public/currencies/BOND.svg +10 -0
  48. package/public/currencies/BOTTO.svg +4 -0
  49. package/public/currencies/BRIGHT.svg +83 -0
  50. package/public/currencies/BTRST.svg +1 -0
  51. package/public/currencies/BURN.png +0 -0
  52. package/public/currencies/BitANT.png +0 -0
  53. package/public/currencies/BitBTC.png +0 -0
  54. package/public/currencies/CARD.svg +1 -0
  55. package/public/currencies/CBX.svg +1 -0
  56. package/public/currencies/CHI.svg +1 -0
  57. package/public/currencies/CIG.svg +21 -0
  58. package/public/currencies/CNG.svg +9 -0
  59. package/public/currencies/COC.svg +8 -0
  60. package/public/currencies/COLLAB.svg +8 -0
  61. package/public/currencies/COMP.svg +1 -0
  62. package/public/currencies/COW.svg +1 -0
  63. package/public/currencies/CRV.png +0 -0
  64. package/public/currencies/CRYO.svg +1 -0
  65. package/public/currencies/CTRAVL.svg +1 -0
  66. package/public/currencies/CTSI.svg +1 -0
  67. package/public/currencies/CTX.svg +1 -0
  68. package/public/currencies/CUSD.png +0 -0
  69. package/public/currencies/CXT.svg +11 -0
  70. package/public/currencies/D2D.svg +6 -0
  71. package/public/currencies/DAI.svg +13 -0
  72. package/public/currencies/DCN.svg +47 -0
  73. package/public/currencies/DF.svg +15 -0
  74. package/public/currencies/DHT.svg +1 -0
  75. package/public/currencies/DIMO.svg +1 -0
  76. package/public/currencies/DMS.png +0 -0
  77. package/public/currencies/DODO.svg +6 -0
  78. package/public/currencies/DOGEGF.png +0 -0
  79. package/public/currencies/DOLA.svg +1 -0
  80. package/public/currencies/DOSE.svg +1 -0
  81. package/public/currencies/DUCK.png +0 -0
  82. package/public/currencies/DYP.png +0 -0
  83. package/public/currencies/EIGEN.svg +13 -0
  84. package/public/currencies/ENS.png +0 -0
  85. package/public/currencies/EPOCH.svg +1 -0
  86. package/public/currencies/EQB.svg +4 -0
  87. package/public/currencies/EQZ.png +0 -0
  88. package/public/currencies/ERN.png +0 -0
  89. package/public/currencies/ERNTST.png +0 -0
  90. package/public/currencies/EST.png +0 -0
  91. package/public/currencies/ETH.svg +13 -0
  92. package/public/currencies/ETHIX.svg +1 -0
  93. package/public/currencies/EVERY.svg +13 -0
  94. package/public/currencies/F.svg +1 -0
  95. package/public/currencies/FACTR.png +0 -0
  96. package/public/currencies/FANS.svg +11 -0
  97. package/public/currencies/FARM.png +0 -0
  98. package/public/currencies/FCR.png +0 -0
  99. package/public/currencies/FET.svg +21 -0
  100. package/public/currencies/FIS.svg +22 -0
  101. package/public/currencies/FLASH.svg +22 -0
  102. package/public/currencies/FLy.png +0 -0
  103. package/public/currencies/FOAM.svg +23 -0
  104. package/public/currencies/FORTH.svg +1 -0
  105. package/public/currencies/FOX.svg +8 -0
  106. package/public/currencies/FRAX.png +0 -0
  107. package/public/currencies/FU.svg +17 -0
  108. package/public/currencies/FVT.svg +1 -0
  109. package/public/currencies/FXN.svg +25 -0
  110. package/public/currencies/FXS.png +0 -0
  111. package/public/currencies/Froglic.png +0 -0
  112. package/public/currencies/GALAXIS.svg +1 -0
  113. package/public/currencies/GCH.png +0 -0
  114. package/public/currencies/GENOME.svg +23 -0
  115. package/public/currencies/GGTK.svg +1 -0
  116. package/public/currencies/GHST.svg +15 -0
  117. package/public/currencies/GIGACHAD.png +0 -0
  118. package/public/currencies/GIV.svg +6 -0
  119. package/public/currencies/GLS.svg +22 -0
  120. package/public/currencies/GOLD.png +0 -0
  121. package/public/currencies/GRG.png +0 -0
  122. package/public/currencies/GROW.svg +1 -0
  123. package/public/currencies/GRT.svg +11 -0
  124. package/public/currencies/GTC.svg +5 -0
  125. package/public/currencies/GURU.svg +1 -0
  126. package/public/currencies/GYEN.svg +1 -0
  127. package/public/currencies/GYSR.png +0 -0
  128. package/public/currencies/HAIR.svg +1 -0
  129. package/public/currencies/HAN.svg +25 -0
  130. package/public/currencies/HANeP.svg +1 -0
  131. package/public/currencies/HAUS.png +0 -0
  132. package/public/currencies/HEU.svg +5 -0
  133. package/public/currencies/HOBA.png +0 -0
  134. package/public/currencies/HUNT.svg +1 -0
  135. package/public/currencies/IBEX.png +0 -0
  136. package/public/currencies/IDRISS.svg +4 -0
  137. package/public/currencies/IOTX.png +0 -0
  138. package/public/currencies/IPOR.svg +1 -0
  139. package/public/currencies/IPT.svg +7 -0
  140. package/public/currencies/IRARA.svg +1 -0
  141. package/public/currencies/ISK.png +0 -0
  142. package/public/currencies/IYKYK.svg +14 -0
  143. package/public/currencies/JAM.svg +20 -0
  144. package/public/currencies/JRT.svg +8 -0
  145. package/public/currencies/KAGE.png +0 -0
  146. package/public/currencies/KAI.svg +23 -0
  147. package/public/currencies/KIBSHI.png +0 -0
  148. package/public/currencies/KNC.png +0 -0
  149. package/public/currencies/KOMPETE.png +0 -0
  150. package/public/currencies/KROM.png +0 -0
  151. package/public/currencies/LCX.svg +6 -0
  152. package/public/currencies/LDO.svg +5 -0
  153. package/public/currencies/LIF3.svg +27 -0
  154. package/public/currencies/LINK.png +0 -0
  155. package/public/currencies/LIZ.png +0 -0
  156. package/public/currencies/LMEOW.png +0 -0
  157. package/public/currencies/LOCG.png +0 -0
  158. package/public/currencies/LORDS.png +0 -0
  159. package/public/currencies/LPF.svg +18 -0
  160. package/public/currencies/LQTY.svg +1 -0
  161. package/public/currencies/LRC.png +0 -0
  162. package/public/currencies/LRDS.svg +44 -0
  163. package/public/currencies/LSK.png +0 -0
  164. package/public/currencies/LUSD.svg +1 -0
  165. package/public/currencies/LYRA.png +0 -0
  166. package/public/currencies/MASK.svg +4 -0
  167. package/public/currencies/MASQ.png +0 -0
  168. package/public/currencies/MBS.png +0 -0
  169. package/public/currencies/MCADE.svg +26 -0
  170. package/public/currencies/MET.svg +15 -0
  171. package/public/currencies/MINDS.svg +32 -0
  172. package/public/currencies/MKR.png +0 -0
  173. package/public/currencies/MLN.svg +1 -0
  174. package/public/currencies/MOCHI.svg +1 -0
  175. package/public/currencies/MOM.svg +5 -0
  176. package/public/currencies/MONKE.png +0 -0
  177. package/public/currencies/MOOV.svg +5 -0
  178. package/public/currencies/MORPHO.svg +14 -0
  179. package/public/currencies/MPWR.svg +5 -0
  180. package/public/currencies/MTA.svg +15 -0
  181. package/public/currencies/MTL.png +0 -0
  182. package/public/currencies/MUGLOO.png +0 -0
  183. package/public/currencies/Mog.png +0 -0
  184. package/public/currencies/NAVI.svg +1 -0
  185. package/public/currencies/NCT.svg +49 -0
  186. package/public/currencies/NET.svg +11 -0
  187. package/public/currencies/NEURON.svg +38 -0
  188. package/public/currencies/NFD.png +0 -0
  189. package/public/currencies/NOGS.png +0 -0
  190. package/public/currencies/NOUNS.png +0 -0
  191. package/public/currencies/NOVA.png +0 -0
  192. package/public/currencies/NSTR.svg +4 -0
  193. package/public/currencies/Neiro.png +0 -0
  194. package/public/currencies/OCEAN.png +0 -0
  195. package/public/currencies/OGN.svg +8 -0
  196. package/public/currencies/OL.svg +21 -0
  197. package/public/currencies/OLAS.svg +7 -0
  198. package/public/currencies/OM.png +0 -0
  199. package/public/currencies/OMETA.svg +7 -0
  200. package/public/currencies/OMI.svg +42 -0
  201. package/public/currencies/OPENLOOT.svg +21 -0
  202. package/public/currencies/OPN.svg +1 -0
  203. package/public/currencies/OS.svg +1 -0
  204. package/public/currencies/OUTb.svg +4 -0
  205. package/public/currencies/OVR.png +0 -0
  206. package/public/currencies/PAGE.svg +1 -0
  207. package/public/currencies/PAL.svg +1 -0
  208. package/public/currencies/PAPER.svg +4 -0
  209. package/public/currencies/PENDLE.png +0 -0
  210. package/public/currencies/PEPE.png +0 -0
  211. package/public/currencies/PERP.png +0 -0
  212. package/public/currencies/PHTK.svg +14 -0
  213. package/public/currencies/PIP.svg +11 -0
  214. package/public/currencies/POGS.png +0 -0
  215. package/public/currencies/POOL.svg +22 -0
  216. package/public/currencies/POP.svg +8 -0
  217. package/public/currencies/PORK.png +0 -0
  218. package/public/currencies/PRE.svg +66 -0
  219. package/public/currencies/PREMIA.svg +4 -0
  220. package/public/currencies/PRF.png +0 -0
  221. package/public/currencies/PRO.svg +1 -0
  222. package/public/currencies/PSP.svg +35 -0
  223. package/public/currencies/PSTAKE.png +0 -0
  224. package/public/currencies/PSY.svg +26 -0
  225. package/public/currencies/RAC.png +0 -0
  226. package/public/currencies/RAI.svg +1 -0
  227. package/public/currencies/RAZOR.svg +1 -0
  228. package/public/currencies/REKT.png +0 -0
  229. package/public/currencies/RFKJ.png +0 -0
  230. package/public/currencies/RFWSTETH.svg +36 -0
  231. package/public/currencies/RGT.png +0 -0
  232. package/public/currencies/RICE.svg +22 -0
  233. package/public/currencies/RIZE.svg +21 -0
  234. package/public/currencies/RPL.svg +1 -0
  235. package/public/currencies/RSC.svg +6 -0
  236. package/public/currencies/RSR.png +0 -0
  237. package/public/currencies/RSS3.png +0 -0
  238. package/public/currencies/Reach.svg +17 -0
  239. package/public/currencies/SAIL.png +0 -0
  240. package/public/currencies/SALD.png +0 -0
  241. package/public/currencies/SARCO.png +0 -0
  242. package/public/currencies/SCM.svg +1 -0
  243. package/public/currencies/SCRY.svg +13 -0
  244. package/public/currencies/SDL.svg +1 -0
  245. package/public/currencies/SEAM.svg +5 -0
  246. package/public/currencies/SEXY.svg +1 -0
  247. package/public/currencies/SHU.png +0 -0
  248. package/public/currencies/SIPHER.png +0 -0
  249. package/public/currencies/SKAI.svg +1 -0
  250. package/public/currencies/SLN.png +0 -0
  251. package/public/currencies/SMT.svg +1 -0
  252. package/public/currencies/SMURFCAT.png +0 -0
  253. package/public/currencies/SNT.svg +14 -0
  254. package/public/currencies/SNX.svg +20 -0
  255. package/public/currencies/SOFI.png +0 -0
  256. package/public/currencies/SOFT.svg +1 -0
  257. package/public/currencies/SOVRN.svg +13 -0
  258. package/public/currencies/SPANK.png +0 -0
  259. package/public/currencies/SPC.png +0 -0
  260. package/public/currencies/SPOT.svg +1 -0
  261. package/public/currencies/SQD.png +0 -0
  262. package/public/currencies/SQT.svg +14 -0
  263. package/public/currencies/STNT.svg +38 -0
  264. package/public/currencies/STPT.png +0 -0
  265. package/public/currencies/SUDO.svg +6 -0
  266. package/public/currencies/SUKU.png +0 -0
  267. package/public/currencies/SUPER.svg +6 -0
  268. package/public/currencies/SUSHI.svg +19 -0
  269. package/public/currencies/SYNTH.svg +1 -0
  270. package/public/currencies/ShibDoge.png +0 -0
  271. package/public/currencies/Silo.svg +4 -0
  272. package/public/currencies/StaFi.svg +65 -0
  273. package/public/currencies/T.svg +4 -0
  274. package/public/currencies/TEN.svg +1 -0
  275. package/public/currencies/TETU.svg +6 -0
  276. package/public/currencies/THALES.png +0 -0
  277. package/public/currencies/THING.png +0 -0
  278. package/public/currencies/THX.svg +22 -0
  279. package/public/currencies/TKAI.svg +1 -0
  280. package/public/currencies/TKN.png +0 -0
  281. package/public/currencies/TODL.png +0 -0
  282. package/public/currencies/TOWER.svg +1 -0
  283. package/public/currencies/TRAC.png +0 -0
  284. package/public/currencies/TRB.png +0 -0
  285. package/public/currencies/TRUE.svg +11 -0
  286. package/public/currencies/TRX.svg +4 -0
  287. package/public/currencies/TSC.png +0 -0
  288. package/public/currencies/TT.png +0 -0
  289. package/public/currencies/TUSD.png +0 -0
  290. package/public/currencies/TYBENG.png +0 -0
  291. package/public/currencies/TheDAO.svg +1 -0
  292. package/public/currencies/U.png +0 -0
  293. package/public/currencies/UBI.svg +5 -0
  294. package/public/currencies/UCASH.svg +1 -0
  295. package/public/currencies/UDT.svg +4 -0
  296. package/public/currencies/UMA.png +0 -0
  297. package/public/currencies/UNI.png +0 -0
  298. package/public/currencies/USA.png +0 -0
  299. package/public/currencies/USC.svg +23 -0
  300. package/public/currencies/USD3.svg +13 -0
  301. package/public/currencies/USDD.png +0 -0
  302. package/public/currencies/USDS.png +0 -0
  303. package/public/currencies/USDbC.png +0 -0
  304. package/public/currencies/UST.png +0 -0
  305. package/public/currencies/VALX.png +0 -0
  306. package/public/currencies/VIDYA.png +0 -0
  307. package/public/currencies/VITA.svg +10 -0
  308. package/public/currencies/VSP.svg +15 -0
  309. package/public/currencies/VUSD.svg +1 -0
  310. package/public/currencies/WAAC.png +0 -0
  311. package/public/currencies/WAD.png +0 -0
  312. package/public/currencies/WALLET.svg +1 -0
  313. package/public/currencies/WAMPL.svg +53 -0
  314. package/public/currencies/WBTC.png +0 -0
  315. package/public/currencies/WCT.svg +5 -0
  316. package/public/currencies/WEXO.png +0 -0
  317. package/public/currencies/WLD.jpeg +0 -0
  318. package/public/currencies/WMC.png +0 -0
  319. package/public/currencies/WOO.png +0 -0
  320. package/public/currencies/Wildfire.svg +1 -0
  321. package/public/currencies/XCHF.png +0 -0
  322. package/public/currencies/XCN.svg +1 -0
  323. package/public/currencies/XMT.svg +1 -0
  324. package/public/currencies/XYO.svg +1 -0
  325. package/public/currencies/YFI.svg +4 -0
  326. package/public/currencies/YFX.svg +11 -0
  327. package/public/currencies/YGG.svg +11 -0
  328. package/public/currencies/YOKAI.png +0 -0
  329. package/public/currencies/YYY.svg +1 -0
  330. package/public/currencies/ZENT.svg +12 -0
  331. package/public/currencies/ZRX.png +0 -0
  332. package/public/currencies/ZUN.svg +24 -0
  333. package/public/currencies/ZUSD.svg +1 -0
  334. package/public/currencies/ZYN.png +0 -0
  335. package/public/currencies/aCRV.png +0 -0
  336. package/public/currencies/btc.png +0 -0
  337. package/public/currencies/bwAJNA.svg +1 -0
  338. package/public/currencies/cSTONE.svg +23 -0
  339. package/public/currencies/cbETH.svg +9 -0
  340. package/public/currencies/crvUSD.png +0 -0
  341. package/public/currencies/cvxFXS.png +0 -0
  342. package/public/currencies/dollar.png +0 -0
  343. package/public/currencies/ePendle.png +0 -0
  344. package/public/currencies/frxETH.png +0 -0
  345. package/public/currencies/fxUSD.svg +5 -0
  346. package/public/currencies/iFARM.png +0 -0
  347. package/public/currencies/iZi.png +0 -0
  348. package/public/currencies/imgnAI.svg +1 -0
  349. package/public/currencies/mpETH.svg +4 -0
  350. package/public/currencies/nETH.svg +11 -0
  351. package/public/currencies/rETH.svg +1 -0
  352. package/public/currencies/rgUSD.svg +5 -0
  353. package/public/currencies/rnETH.svg +11 -0
  354. package/public/currencies/sDAI.svg +13 -0
  355. package/public/currencies/sFRAX.png +0 -0
  356. package/public/currencies/sUSDS.png +0 -0
  357. package/public/currencies/scWETHv2.svg +1 -0
  358. package/public/currencies/send.svg +12 -0
  359. package/public/currencies/stETH.png +1 -0
  360. package/public/currencies/stZENT.svg +12 -0
  361. package/public/currencies/stkLYRA.svg +26 -0
  362. package/public/currencies/tGS.png +0 -0
  363. package/public/currencies/tSTAR.png +0 -0
  364. package/public/currencies/usdc.png +0 -0
  365. package/public/currencies/usdt.png +0 -0
  366. package/public/currencies/veKWENTA.svg +24 -0
  367. package/public/currencies/wHOGE.svg +14 -0
  368. package/public/currencies/wOpenX.svg +140 -0
  369. package/public/currencies/wPOKT.svg +17 -0
  370. package/public/currencies/wTBT.svg +1 -0
  371. package/public/currencies/weETH.svg +23 -0
  372. package/public/currencies/wstETH.svg +11 -0
  373. package/public/currencies/yETH.svg +8 -0
  374. package/public/currencies/zunETH.svg +46 -0
  375. package/public/currencies/zunUSD.svg +33 -0
  376. package/src/components/customer/overdraft-protection.tsx +37 -9
  377. package/src/components/invoice/action.tsx +20 -0
  378. package/src/components/invoice/list.tsx +4 -1
  379. package/src/components/payment-currency/add.tsx +12 -3
  380. package/src/components/payment-currency/edit.tsx +89 -3
  381. package/src/components/payment-currency/tokenList.json +8847 -8156
  382. package/src/components/payment-intent/list.tsx +2 -4
  383. package/src/components/subscription/portal/actions.tsx +6 -2
  384. package/src/libs/util.ts +2 -0
  385. package/src/locales/en.tsx +11 -3
  386. package/src/locales/zh.tsx +11 -3
  387. package/src/pages/admin/settings/vault-config/edit-form.tsx +13 -0
  388. package/src/pages/customer/recharge/account.tsx +8 -1
  389. package/src/pages/customer/recharge/subscription.tsx +8 -1
  390. package/src/pages/customer/subscription/detail.tsx +1 -3
@@ -174,7 +174,10 @@ export default function InvoiceList({
174
174
  const item = data.list[index] as TInvoiceExpanded;
175
175
  return (
176
176
  <InvoiceLink invoice={item}>
177
- <Typography component="strong" fontWeight={600}>
177
+ <Typography
178
+ component="strong"
179
+ fontWeight={600}
180
+ sx={{ textDecoration: item.status === 'void' ? 'line-through' : 'none' }}>
178
181
  {formatBNStr(item?.total, item?.paymentCurrency.decimal)}&nbsp;
179
182
  {item?.paymentCurrency.symbol}
180
183
  </Typography>
@@ -1,6 +1,6 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import Toast from '@arcblock/ux/lib/Toast';
3
- import { api, formatError } from '@blocklet/payment-react';
3
+ import { api, formatError, getPrefix } from '@blocklet/payment-react';
4
4
  import type { TPaymentCurrency, TPaymentMethodExpanded } from '@blocklet/payment-types';
5
5
  import { AddOutlined } from '@mui/icons-material';
6
6
  import {
@@ -18,6 +18,7 @@ import { useSetState } from 'ahooks';
18
18
  import { FormProvider, useForm } from 'react-hook-form';
19
19
  import { dispatch } from 'use-bus';
20
20
  import { useEffect } from 'react';
21
+ import { joinURL } from 'ufo';
21
22
  import DrawerForm from '../drawer-form';
22
23
  import PaymentCurrencyForm from './form';
23
24
 
@@ -33,6 +34,7 @@ interface TokenInfo {
33
34
  name: string;
34
35
  symbol: string;
35
36
  logoURI?: string;
37
+ localLogoURI?: string;
36
38
  }
37
39
 
38
40
  export default function PaymentCurrencyAdd({
@@ -87,11 +89,18 @@ export default function PaymentCurrencyAdd({
87
89
  }
88
90
  }, [showTokenSelect, chainId]);
89
91
 
92
+ const getLogoURI = (token: TokenInfo) => {
93
+ if (token.localLogoURI) {
94
+ return joinURL(getPrefix(), token.localLogoURI);
95
+ }
96
+ return token.logoURI || '';
97
+ };
98
+
90
99
  const handleTokenSelect = (token: TokenInfo | null) => {
91
100
  if (token) {
92
101
  setValue('name', token.name);
93
102
  setValue('description', `${token.name} (${token.symbol})`);
94
- setValue('logo', token.logoURI || '');
103
+ setValue('logo', getLogoURI(token));
95
104
  setValue('contract', token.address);
96
105
  }
97
106
  };
@@ -162,7 +171,7 @@ export default function PaymentCurrencyAdd({
162
171
  },
163
172
  }}>
164
173
  <Avatar
165
- src={option.logoURI || option.symbol}
174
+ src={getLogoURI(option) || option.symbol}
166
175
  alt={option.symbol}
167
176
  sx={{
168
177
  width: 24,
@@ -1,17 +1,35 @@
1
1
  /* eslint-disable no-nested-ternary */
2
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
3
  import Toast from '@arcblock/ux/lib/Toast';
4
- import { api, formatError } from '@blocklet/payment-react';
4
+ import { api, formatError, getPrefix, CachedRequest } from '@blocklet/payment-react';
5
5
  import type { TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
6
6
  import { AddOutlined } from '@mui/icons-material';
7
7
  import { Button, CircularProgress } from '@mui/material';
8
8
  import { useSetState } from 'ahooks';
9
9
  import { FormProvider, useForm } from 'react-hook-form';
10
10
  import { dispatch } from 'use-bus';
11
+ import { useEffect } from 'react';
12
+ import { joinURL } from 'ufo';
11
13
 
12
14
  import DrawerForm from '../drawer-form';
13
15
  import PaymentCurrencyForm from './form';
14
16
 
17
+ const loadTokenList = () =>
18
+ import(
19
+ /* webpackChunkName: "payment-token-list" */
20
+ './tokenList.json'
21
+ );
22
+
23
+ interface TokenInfo {
24
+ address: string;
25
+ chainId: number;
26
+ decimals: number;
27
+ name: string;
28
+ symbol: string;
29
+ logoURI?: string;
30
+ localLogoURI?: string;
31
+ }
32
+
15
33
  export default function PaymentCurrencyEdit({
16
34
  method,
17
35
  onClose,
@@ -22,7 +40,11 @@ export default function PaymentCurrencyEdit({
22
40
  value: TPaymentCurrency;
23
41
  }) {
24
42
  const { t } = useLocaleContext();
25
- const [state, setState] = useSetState({ loading: false });
43
+ const [state, setState] = useSetState({
44
+ loading: false,
45
+ tokenListLoading: false,
46
+ contractToTokenMap: new Map<string, TokenInfo>(),
47
+ });
26
48
 
27
49
  const methods = useForm<TPaymentCurrency>({
28
50
  defaultValues: {
@@ -33,7 +55,71 @@ export default function PaymentCurrencyEdit({
33
55
  contract: value?.contract,
34
56
  },
35
57
  });
36
- const { handleSubmit } = methods;
58
+ const { handleSubmit, setValue } = methods;
59
+
60
+ const showTokenSelect = ['ethereum', 'base'].includes(method.type);
61
+ // @ts-ignore
62
+ const chainId = method?.settings?.[method.type]?.chain_id || '';
63
+
64
+ const getLogoURI = (token: TokenInfo) => {
65
+ if (token.localLogoURI) {
66
+ return joinURL(getPrefix(), token.localLogoURI);
67
+ }
68
+ return token.logoURI || '';
69
+ };
70
+
71
+ useEffect(() => {
72
+ if (showTokenSelect && chainId) {
73
+ setState({ tokenListLoading: true });
74
+
75
+ // 使用 CachedRequest 直接缓存 contract 映射
76
+ const cachedTokenMapRequest = new CachedRequest(
77
+ `tokenMap_${chainId}`,
78
+ async () => {
79
+ const module = await loadTokenList();
80
+ // @ts-ignore
81
+ const tokenList = (module.default?.[chainId] as TokenInfo[]) || [];
82
+
83
+ // 创建 contract 地址到 token 的映射对象
84
+ const contractToTokenObj: Record<string, TokenInfo> = {};
85
+ tokenList.forEach((token: TokenInfo) => {
86
+ if (token.address) {
87
+ contractToTokenObj[token.address.toLowerCase()] = token;
88
+ }
89
+ });
90
+
91
+ return { data: contractToTokenObj };
92
+ },
93
+ {
94
+ strategy: 'session',
95
+ ttl: 30 * 60 * 1000,
96
+ }
97
+ );
98
+
99
+ cachedTokenMapRequest
100
+ .fetch()
101
+ .then((contractToTokenObj: Record<string, TokenInfo>) => {
102
+ const contractToTokenMap = new Map<string, TokenInfo>(Object.entries(contractToTokenObj));
103
+ setState({
104
+ contractToTokenMap,
105
+ tokenListLoading: false,
106
+ });
107
+
108
+ // 检查当前币种是否需要替换 logo(根据 contract 地址匹配)
109
+ if (value?.contract) {
110
+ const matchedToken = contractToTokenMap.get(value.contract.toLowerCase());
111
+ if (matchedToken && matchedToken.localLogoURI) {
112
+ const newLogoURI = getLogoURI(matchedToken);
113
+ setValue('logo', newLogoURI);
114
+ }
115
+ }
116
+ })
117
+ .catch((error) => {
118
+ console.error('Failed to load token map:', error);
119
+ setState({ tokenListLoading: false });
120
+ });
121
+ }
122
+ }, [showTokenSelect, chainId, value?.contract]);
37
123
 
38
124
  const onSubmit = (data: TPaymentCurrency) => {
39
125
  setState({ loading: true });