@wireio/stake 2.1.0 → 2.1.1

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": "@wireio/stake",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "LIQ Staking Module for Wire Network",
5
5
  "homepage": "https://gitea.gitgo.app/Wire/sdk-stake",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -1034,12 +1034,13 @@ export class SolanaStakingClient implements IStakingClient {
1034
1034
  // ---------------------------------------------------------------------
1035
1035
 
1036
1036
  /**
1037
- * Send a signed transaction over HTTP RPC and wait for confirmation.
1038
- * Throws if the transaction fails.
1037
+ * Send a signed transaction over HTTP RPC.
1039
1038
  *
1040
- * - Handles benign "already processed" preflight errors.
1041
- * - Uses getSignatureStatuses() instead of confirmTransaction()
1042
- * so we don't care about blockheight expiry.
1039
+ * - Returns immediately on successful sendRawTransaction.
1040
+ * - If sendRawTransaction throws a SendTransactionError with
1041
+ * "already been processed", we treat it as success and
1042
+ * just return a derived signature.
1043
+ * - No confirmTransaction / polling / blockheight handling.
1043
1044
  */
1044
1045
  private async sendAndConfirmHttp(
1045
1046
  signed: SolanaTransaction,
@@ -1048,94 +1049,42 @@ export class SolanaStakingClient implements IStakingClient {
1048
1049
  this.ensureUser();
1049
1050
 
1050
1051
  const rawTx = signed.serialize();
1051
- let signature: string;
1052
1052
 
1053
- // -------------------------------------------------------------
1054
- // 1) Send the raw transaction
1055
- // Handle "already been processed" as a soft success.
1056
- // -------------------------------------------------------------
1057
1053
  try {
1058
- signature = await this.connection.sendRawTransaction(rawTx, {
1054
+ // Normal happy path: RPC accepts the tx and returns a signature
1055
+ const signature = await this.connection.sendRawTransaction(rawTx, {
1059
1056
  skipPreflight: false,
1060
1057
  preflightCommitment: commitment,
1061
1058
  maxRetries: 3,
1062
1059
  });
1060
+ return signature;
1063
1061
  } catch (e: any) {
1064
1062
  const msg = e?.message ?? '';
1065
-
1066
1063
  const isSendTxError =
1067
1064
  e instanceof SendTransactionError || e?.name === 'SendTransactionError';
1068
1065
 
1066
+ // Benign duplicate case: tx is already in the ledger / cache
1069
1067
  if (isSendTxError && msg.includes('already been processed')) {
1070
- // Preflight is telling us this exact txid already landed.
1071
- // Derive the signature from the signed tx and continue to confirmation.
1072
1068
  console.warn(
1073
- 'sendRawTransaction preflight says "already been processed"; ' +
1074
- 'treating as success and deriving signature from signed tx.',
1069
+ 'sendRawTransaction reports "already been processed"; ' +
1070
+ 'treating as success without further confirmation.',
1075
1071
  );
1076
1072
 
1077
- // Assuming SolanaTransaction is a legacy Transaction here.
1073
+ // Try to derive a signature from the signed Transaction.
1074
+ // If SolanaTransaction is a legacy Transaction, this works.
1078
1075
  const legacy = signed as unknown as Transaction;
1079
1076
  const first = legacy.signatures?.[0]?.signature;
1080
1077
 
1081
- if (!first) {
1082
- // No way to recover the txid → rethrow
1083
- throw e;
1084
- }
1085
-
1086
- signature = bs58.encode(first);
1087
- } else {
1088
- // Any other send error is a real failure
1089
- throw e;
1090
- }
1091
- }
1092
-
1093
- // -------------------------------------------------------------
1094
- // 2) Poll getSignatureStatuses until confirmed/finalized or timeout
1095
- // -------------------------------------------------------------
1096
- const start = Date.now();
1097
- const timeoutMs = 30_000; // tune this if you want longer for devnet
1098
- const pollIntervalMs = 500; // 0.5s between polls
1099
-
1100
- // eslint-disable-next-line no-constant-condition
1101
- while (true) {
1102
- const { value } = await this.connection.getSignatureStatuses(
1103
- [signature],
1104
- { searchTransactionHistory: true },
1105
- );
1106
- const status = value[0];
1107
-
1108
- if (status) {
1109
- if (status.err) {
1110
- // On-chain error (instruction error, etc.)
1111
- throw new Error(
1112
- `Transaction failed: ${JSON.stringify(status.err)}`,
1113
- );
1114
- }
1115
-
1116
- const confirmations = status.confirmations;
1117
- const confirmationStatus = status.confirmationStatus;
1118
-
1119
- const satisfied =
1120
- confirmationStatus === 'confirmed' ||
1121
- confirmationStatus === 'finalized' ||
1122
- confirmations === null || // rooted
1123
- (confirmations ?? 0) > 0; // at least 1 confirmation
1124
-
1125
- if (satisfied) {
1126
- // We consider this successfully confirmed
1127
- return signature;
1078
+ if (first) {
1079
+ return bs58.encode(first);
1128
1080
  }
1129
- }
1130
1081
 
1131
- // Timeout guard so we don't spin forever on a tx that never lands
1132
- if (Date.now() - start > timeoutMs) {
1133
- throw new Error(
1134
- `Transaction confirmation timed out for ${signature}`,
1135
- );
1082
+ // Fallback: return a dummy string
1083
+ return 'already-processed';
1136
1084
  }
1137
1085
 
1138
- await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
1086
+ // Any other send error is a real failure
1087
+ throw e;
1139
1088
  }
1140
1089
  }
1141
1090