@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/dist/cjs/index.cjs +27 -39
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +27 -39
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/SolanaTxSendModal.tsx +34 -41
package/dist/cjs/index.cjs
CHANGED
|
@@ -3927,51 +3927,33 @@ function SolanaTxSendModal(_ref) {
|
|
|
3927
3927
|
if (!connection || !tx || !publicKey || !signTransaction) {
|
|
3928
3928
|
return;
|
|
3929
3929
|
}
|
|
3930
|
-
let signatureResult = '';
|
|
3931
3930
|
try {
|
|
3932
|
-
var _txResult$meta;
|
|
3933
3931
|
// Optimize transaction
|
|
3934
3932
|
// Make a copy of the tx so we can use the original tx for retries
|
|
3935
3933
|
const txCopy = new web3_js.Transaction();
|
|
3936
3934
|
txCopy.instructions = [...tx.instructions];
|
|
3937
|
-
const
|
|
3938
|
-
txCopy.recentBlockhash =
|
|
3939
|
-
txCopy.lastValidBlockHeight =
|
|
3935
|
+
const txBlockhashData = await connection.getLatestBlockhash('confirmed');
|
|
3936
|
+
txCopy.recentBlockhash = txBlockhashData.blockhash;
|
|
3937
|
+
txCopy.lastValidBlockHeight = txBlockhashData.lastValidBlockHeight;
|
|
3940
3938
|
txCopy.feePayer = publicKey;
|
|
3941
3939
|
// Extract writable accounts
|
|
3942
3940
|
const txAccounts = sdk.extractWritableAccounts(txCopy);
|
|
3943
3941
|
// Add on compute unit limit + price instructions
|
|
3944
3942
|
const optimizedTx = await sdk.buildOptimalTransactionFromConnection(txCopy, txAccounts, connection, chainId, publicKey, useHighPriority ? 'High' : undefined, process.env.REACT_APP_HELIUS_API_KEY);
|
|
3945
|
-
|
|
3943
|
+
const signedTx = await signTransaction(optimizedTx);
|
|
3944
|
+
const signatureResult = await connection.sendRawTransaction(signedTx.serialize(), {
|
|
3946
3945
|
preflightCommitment: 'confirmed',
|
|
3947
|
-
skipPreflight: true
|
|
3946
|
+
skipPreflight: true,
|
|
3947
|
+
maxRetries: 0
|
|
3948
3948
|
});
|
|
3949
3949
|
setSignature(signatureResult);
|
|
3950
3950
|
dispatch(setSolanaSignature(signatureResult));
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
const txResult = await connection.getParsedTransaction(signatureResult, 'confirmed');
|
|
3957
|
-
if (txResult !== null && txResult !== void 0 && (_txResult$meta = txResult.meta) !== null && _txResult$meta !== void 0 && _txResult$meta.err) {
|
|
3958
|
-
dispatch(setError({
|
|
3959
|
-
errorMessage: 'Your transaction was confirmed but had errors. Please check the transaction details on the explorer for more information.'
|
|
3960
|
-
}));
|
|
3961
|
-
return;
|
|
3962
|
-
}
|
|
3963
|
-
handleSuccess({
|
|
3964
|
-
signature: signatureResult
|
|
3965
|
-
});
|
|
3966
|
-
} catch (error) {
|
|
3967
|
-
var _err$message;
|
|
3968
|
-
console.log(error);
|
|
3969
|
-
let signatureStatusRetries = 0;
|
|
3970
|
-
while (signatureStatusRetries < 5) {
|
|
3951
|
+
|
|
3952
|
+
// Loop and poll the transaction continuously until it is either confirmed or
|
|
3953
|
+
// the block height has been exceeded
|
|
3954
|
+
// eslint-disable-next-line no-constant-condition
|
|
3955
|
+
while (true) {
|
|
3971
3956
|
var _result$value, _result$value2;
|
|
3972
|
-
// Attempt to load the signature status using transaction history
|
|
3973
|
-
// eslint-disable-next-line no-await-in-loop
|
|
3974
|
-
await shared.sleep(1000);
|
|
3975
3957
|
// eslint-disable-next-line no-await-in-loop
|
|
3976
3958
|
const result = await connection.getSignatureStatus(signatureResult, {
|
|
3977
3959
|
searchTransactionHistory: true
|
|
@@ -3989,17 +3971,23 @@ function SolanaTxSendModal(_ref) {
|
|
|
3989
3971
|
});
|
|
3990
3972
|
return;
|
|
3991
3973
|
}
|
|
3992
|
-
|
|
3974
|
+
|
|
3975
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3976
|
+
const latestBlockhash = await connection.getLatestBlockhash('confirmed');
|
|
3977
|
+
if (latestBlockhash.lastValidBlockHeight - optimizedTx.lastValidBlockHeight > 100) {
|
|
3978
|
+
setShowRetryScreen(true);
|
|
3979
|
+
return;
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3983
|
+
await shared.sleep(1000);
|
|
3993
3984
|
}
|
|
3985
|
+
} catch (error) {
|
|
3986
|
+
console.log(error);
|
|
3994
3987
|
const err = error;
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
} else {
|
|
3999
|
-
dispatch(setError({
|
|
4000
|
-
errorMessage: (err === null || err === void 0 ? void 0 : err.message) || ''
|
|
4001
|
-
}));
|
|
4002
|
-
}
|
|
3988
|
+
dispatch(setError({
|
|
3989
|
+
errorMessage: (err === null || err === void 0 ? void 0 : err.message) || ''
|
|
3990
|
+
}));
|
|
4003
3991
|
}
|
|
4004
3992
|
}
|
|
4005
3993
|
sendTx();
|