@huma-finance/widgets 0.0.73-beta.919 → 0.0.73-beta.922

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.73-beta.919+131d6ed",
3
+ "version": "0.0.73-beta.922+faafb9d",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -29,9 +29,9 @@
29
29
  "@ethersproject/experimental": "^5.7.0",
30
30
  "@ethersproject/providers": "^5.6.0",
31
31
  "@ethersproject/units": "^5.6.0",
32
- "@huma-finance/sdk": "^0.0.73-beta.919+131d6ed",
33
- "@huma-finance/shared": "^0.0.73-beta.919+131d6ed",
34
- "@huma-finance/web-shared": "^0.0.73-beta.919+131d6ed",
32
+ "@huma-finance/sdk": "^0.0.73-beta.922+faafb9d",
33
+ "@huma-finance/shared": "^0.0.73-beta.922+faafb9d",
34
+ "@huma-finance/web-shared": "^0.0.73-beta.922+faafb9d",
35
35
  "@mui/x-date-pickers": "^5.0.7",
36
36
  "@notifi-network/notifi-frontend-client": "^1.1.2",
37
37
  "@notifi-network/notifi-react": "^1.1.2",
@@ -201,5 +201,5 @@
201
201
  "optionalDependencies": {
202
202
  "encoding": "^0.1.13"
203
203
  },
204
- "gitHead": "131d6ed7649268866c762204921941d96e41388f"
204
+ "gitHead": "faafb9de87c976813ef26c6e352972cb5ad0b57c"
205
205
  }
@@ -77,15 +77,14 @@ export function SolanaTxSendModal({
77
77
  return
78
78
  }
79
79
 
80
- let signatureResult = ''
81
80
  try {
82
81
  // Optimize transaction
83
82
  // Make a copy of the tx so we can use the original tx for retries
84
83
  const txCopy = new Transaction()
85
84
  txCopy.instructions = [...tx.instructions]
86
- const recentBlockhash = await connection.getLatestBlockhash('confirmed')
87
- txCopy.recentBlockhash = recentBlockhash.blockhash
88
- txCopy.lastValidBlockHeight = recentBlockhash.lastValidBlockHeight
85
+ const txBlockhashData = await connection.getLatestBlockhash('confirmed')
86
+ txCopy.recentBlockhash = txBlockhashData.blockhash
87
+ txCopy.lastValidBlockHeight = txBlockhashData.lastValidBlockHeight
89
88
  txCopy.feePayer = publicKey
90
89
  // Extract writable accounts
91
90
  const txAccounts = extractWritableAccounts(txCopy)
@@ -99,39 +98,22 @@ export function SolanaTxSendModal({
99
98
  useHighPriority ? 'High' : undefined,
100
99
  process.env.REACT_APP_HELIUS_API_KEY,
101
100
  )
102
- signatureResult = await sendTransaction(optimizedTx, connection, {
103
- preflightCommitment: 'confirmed',
104
- skipPreflight: true,
105
- })
101
+ const signedTx = await signTransaction(optimizedTx)
102
+ const signatureResult = await connection.sendRawTransaction(
103
+ signedTx.serialize(),
104
+ {
105
+ preflightCommitment: 'confirmed',
106
+ skipPreflight: true,
107
+ maxRetries: 0,
108
+ },
109
+ )
106
110
  setSignature(signatureResult)
107
111
  dispatch(setSolanaSignature(signatureResult))
108
- await connection.confirmTransaction({
109
- blockhash: optimizedTx.recentBlockhash!,
110
- lastValidBlockHeight: optimizedTx.lastValidBlockHeight!,
111
- signature: signatureResult,
112
- })
113
- const txResult = await connection.getParsedTransaction(
114
- signatureResult,
115
- 'confirmed',
116
- )
117
- if (txResult?.meta?.err) {
118
- dispatch(
119
- setError({
120
- errorMessage:
121
- 'Your transaction was confirmed but had errors. Please check the transaction details on the explorer for more information.',
122
- }),
123
- )
124
- return
125
- }
126
- handleSuccess({ signature: signatureResult })
127
- } catch (error: unknown) {
128
- console.log(error)
129
112
 
130
- let signatureStatusRetries = 0
131
- while (signatureStatusRetries < 5) {
132
- // Attempt to load the signature status using transaction history
133
- // eslint-disable-next-line no-await-in-loop
134
- await sleep(1000)
113
+ // Loop and poll the transaction continuously until it is either confirmed or
114
+ // the block height has been exceeded
115
+ // eslint-disable-next-line no-constant-condition
116
+ while (true) {
135
117
  // eslint-disable-next-line no-await-in-loop
136
118
  const result = await connection.getSignatureStatus(signatureResult, {
137
119
  searchTransactionHistory: true,
@@ -153,16 +135,27 @@ export function SolanaTxSendModal({
153
135
  return
154
136
  }
155
137
 
156
- signatureStatusRetries += 1
138
+ // eslint-disable-next-line no-await-in-loop
139
+ const latestBlockhash = await connection.getLatestBlockhash(
140
+ 'confirmed',
141
+ )
142
+ if (
143
+ latestBlockhash.lastValidBlockHeight -
144
+ optimizedTx.lastValidBlockHeight! >
145
+ 100
146
+ ) {
147
+ setShowRetryScreen(true)
148
+ return
149
+ }
150
+
151
+ // eslint-disable-next-line no-await-in-loop
152
+ await sleep(1000)
157
153
  }
154
+ } catch (error: unknown) {
155
+ console.log(error)
158
156
 
159
157
  const err = error as Error
160
- if (err?.message?.includes('block height exceeded')) {
161
- // Allow the user to retry the transaction
162
- setShowRetryScreen(true)
163
- } else {
164
- dispatch(setError({ errorMessage: err?.message || '' }))
165
- }
158
+ dispatch(setError({ errorMessage: err?.message || '' }))
166
159
  }
167
160
  }
168
161
  sendTx()