@huma-finance/widgets 0.0.73-beta.917 → 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/dist/cjs/index.cjs +28 -40
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +28 -40
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/SolanaTxSendModal.tsx +35 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.73-beta.
|
|
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.
|
|
33
|
-
"@huma-finance/shared": "^0.0.73-beta.
|
|
34
|
-
"@huma-finance/web-shared": "^0.0.73-beta.
|
|
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": "
|
|
204
|
+
"gitHead": "faafb9de87c976813ef26c6e352972cb5ad0b57c"
|
|
205
205
|
}
|
|
@@ -32,7 +32,7 @@ export function SolanaTxSendModal({
|
|
|
32
32
|
const { connection } = useConnection()
|
|
33
33
|
const [signature, setSignature] = useState<string>('')
|
|
34
34
|
const [showRetryScreen, setShowRetryScreen] = useState<boolean>(false)
|
|
35
|
-
const [useHighPriority, setUseHighPriority] = useState<boolean>(
|
|
35
|
+
const [useHighPriority, setUseHighPriority] = useState<boolean>(true)
|
|
36
36
|
const [refreshCount, refresh] = useForceRefresh()
|
|
37
37
|
|
|
38
38
|
const styles = {
|
|
@@ -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
|
|
87
|
-
txCopy.recentBlockhash =
|
|
88
|
-
txCopy.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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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()
|