@huma-finance/widgets 0.0.62-beta.720 → 0.0.62-beta.722

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/widgets",
3
- "version": "0.0.62-beta.720+a8e676c",
3
+ "version": "0.0.62-beta.722+4b0a7f4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -31,7 +31,7 @@
31
31
  "@ethersproject/units": "^5.6.0",
32
32
  "@huma-finance/sdk": "^0.0.61",
33
33
  "@huma-finance/shared": "^0.0.61",
34
- "@huma-finance/web-shared": "^0.0.62-beta.720+a8e676c",
34
+ "@huma-finance/web-shared": "^0.0.61",
35
35
  "@mui/icons-material": "^5.3.0",
36
36
  "@mui/material": "^5.0.6",
37
37
  "@mui/styles": "^5.0.2",
@@ -203,5 +203,5 @@
203
203
  "optionalDependencies": {
204
204
  "encoding": "^0.1.13"
205
205
  },
206
- "gitHead": "a8e676c365b2ad2658475a83b59f04a95ad2fd18"
206
+ "gitHead": "4b0a7f4e2f447b4b105f2a9200226921b2b085cb"
207
207
  }
@@ -1,4 +1,5 @@
1
- import { SolanaChainEnum } from '@huma-finance/shared'
1
+ /* eslint-disable no-await-in-loop */
2
+ import { SolanaChainEnum, timeUtil } from '@huma-finance/shared'
2
3
  import React, { useEffect, useState } from 'react'
3
4
 
4
5
  import { useConnection, useWallet } from '@solana/wallet-adapter-react'
@@ -31,17 +32,29 @@ export function SolanaTxSendModal({
31
32
  }
32
33
 
33
34
  try {
34
- const latestBlockHash = await connection.getLatestBlockhash()
35
35
  const signature = await sendTransaction(tx, connection)
36
36
  setSignature(signature)
37
37
  dispatch(setSolanaSignature(signature))
38
38
 
39
- await connection.confirmTransaction({
40
- blockhash: latestBlockHash.blockhash,
41
- lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
42
- signature,
43
- })
44
- handleSuccess({ signature })
39
+ let transactionConfirmed = false
40
+ for (let i = 0; i < 30; i += 1) {
41
+ timeUtil.sleep(1000)
42
+ const result = await connection.getSignatureStatus(signature)
43
+ if (result?.value?.confirmations) {
44
+ transactionConfirmed = true
45
+ break
46
+ }
47
+ }
48
+
49
+ if (transactionConfirmed) {
50
+ handleSuccess({ signature })
51
+ } else {
52
+ dispatch(
53
+ setError({
54
+ errorMessage: 'Transaction failed to confirm in time',
55
+ }),
56
+ )
57
+ }
45
58
  } catch (error: unknown) {
46
59
  const err = error as Error
47
60
  dispatch(setError({ errorMessage: err?.message || '' }))