@wireio/stake 2.0.0 → 2.1.0

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/lib/stake.d.ts CHANGED
@@ -1917,6 +1917,7 @@ type LiqsolCore$1 = {
1917
1917
  },
1918
1918
  {
1919
1919
  "name": "user";
1920
+ "writable": true;
1920
1921
  },
1921
1922
  {
1922
1923
  "name": "outpostAccount";
@@ -2300,6 +2301,9 @@ type LiqsolCore$1 = {
2300
2301
  {
2301
2302
  "name": "tokenProgram";
2302
2303
  },
2304
+ {
2305
+ "name": "associatedTokenProgram";
2306
+ },
2303
2307
  {
2304
2308
  "name": "systemProgram";
2305
2309
  }
@@ -2937,7 +2941,7 @@ type LiqsolCore$1 = {
2937
2941
  ];
2938
2942
  "accounts": [
2939
2943
  {
2940
- "name": "payer";
2944
+ "name": "admin";
2941
2945
  "writable": true;
2942
2946
  "signer": true;
2943
2947
  },
@@ -2945,6 +2949,9 @@ type LiqsolCore$1 = {
2945
2949
  "name": "metadata";
2946
2950
  "writable": true;
2947
2951
  },
2952
+ {
2953
+ "name": "globalConfig";
2954
+ },
2948
2955
  {
2949
2956
  "name": "systemProgram";
2950
2957
  }
@@ -3391,6 +3398,7 @@ type LiqsolCore$1 = {
3391
3398
  "accounts": [
3392
3399
  {
3393
3400
  "name": "admin";
3401
+ "writable": true;
3394
3402
  "signer": true;
3395
3403
  },
3396
3404
  {
@@ -3628,7 +3636,7 @@ type LiqsolCore$1 = {
3628
3636
  "writable": true;
3629
3637
  },
3630
3638
  {
3631
- "name": "userPretokenRecord";
3639
+ "name": "poolPretokenRecord";
3632
3640
  "writable": true;
3633
3641
  },
3634
3642
  {
@@ -6213,6 +6221,10 @@ type LiqsolCore$1 = {
6213
6221
  "type": {
6214
6222
  "kind": "struct";
6215
6223
  "fields": [
6224
+ {
6225
+ "name": "receiptId";
6226
+ "type": "u64";
6227
+ },
6216
6228
  {
6217
6229
  "name": "liqports";
6218
6230
  "type": "u64";
@@ -8861,6 +8873,7 @@ type LiqsolCore = {
8861
8873
  },
8862
8874
  {
8863
8875
  "name": "user";
8876
+ "writable": true;
8864
8877
  },
8865
8878
  {
8866
8879
  "name": "outpostAccount";
@@ -9244,6 +9257,9 @@ type LiqsolCore = {
9244
9257
  {
9245
9258
  "name": "tokenProgram";
9246
9259
  },
9260
+ {
9261
+ "name": "associatedTokenProgram";
9262
+ },
9247
9263
  {
9248
9264
  "name": "systemProgram";
9249
9265
  }
@@ -9881,7 +9897,7 @@ type LiqsolCore = {
9881
9897
  ];
9882
9898
  "accounts": [
9883
9899
  {
9884
- "name": "payer";
9900
+ "name": "admin";
9885
9901
  "writable": true;
9886
9902
  "signer": true;
9887
9903
  },
@@ -9889,6 +9905,9 @@ type LiqsolCore = {
9889
9905
  "name": "metadata";
9890
9906
  "writable": true;
9891
9907
  },
9908
+ {
9909
+ "name": "globalConfig";
9910
+ },
9892
9911
  {
9893
9912
  "name": "systemProgram";
9894
9913
  }
@@ -10335,6 +10354,7 @@ type LiqsolCore = {
10335
10354
  "accounts": [
10336
10355
  {
10337
10356
  "name": "admin";
10357
+ "writable": true;
10338
10358
  "signer": true;
10339
10359
  },
10340
10360
  {
@@ -10572,7 +10592,7 @@ type LiqsolCore = {
10572
10592
  "writable": true;
10573
10593
  },
10574
10594
  {
10575
- "name": "userPretokenRecord";
10595
+ "name": "poolPretokenRecord";
10576
10596
  "writable": true;
10577
10597
  },
10578
10598
  {
@@ -13157,6 +13177,10 @@ type LiqsolCore = {
13157
13177
  "type": {
13158
13178
  "kind": "struct";
13159
13179
  "fields": [
13180
+ {
13181
+ "name": "receiptId";
13182
+ "type": "u64";
13183
+ },
13160
13184
  {
13161
13185
  "name": "liqports";
13162
13186
  "type": "u64";
@@ -15278,25 +15302,21 @@ type ValidatorLeaderboard = {
15278
15302
  ];
15279
15303
  };
15280
15304
 
15281
- type Entry<IDL> = {
15282
- idl: IDL & {
15283
- address: string;
15284
- };
15305
+ type LiqsolCoreClientIdl = (LiqsolCore$1 | LiqsolCore) & {
15285
15306
  address: string;
15286
15307
  };
15287
- declare const PROGRAMS_BY_CHAIN: {
15288
- readonly "mainnet-beta": {
15289
- readonly liqsolCore: Entry<LiqsolCore$1>;
15290
- readonly liqsolToken: Entry<LiqsolToken$1>;
15291
- readonly validatorLeaderboard: Entry<ValidatorLeaderboard$1>;
15292
- };
15293
- readonly devnet: {
15294
- readonly liqsolCore: Entry<LiqsolCore>;
15295
- readonly liqsolToken: Entry<LiqsolToken>;
15296
- readonly validatorLeaderboard: Entry<ValidatorLeaderboard>;
15297
- };
15308
+ type LiqsolTokenClientIdl = (LiqsolToken$1 | LiqsolToken) & {
15309
+ address: string;
15298
15310
  };
15299
- type SolanaProgramName = keyof (typeof PROGRAMS_BY_CHAIN)[SolChainID.Mainnet];
15311
+ type ValidatorLeaderboardClientIdl = (ValidatorLeaderboard$1 | ValidatorLeaderboard) & {
15312
+ address: string;
15313
+ };
15314
+ type SolanaProgramIdlMap = {
15315
+ liqsolCore: LiqsolCoreClientIdl;
15316
+ liqsolToken: LiqsolTokenClientIdl;
15317
+ validatorLeaderboard: ValidatorLeaderboardClientIdl;
15318
+ };
15319
+ type SolanaProgramName = keyof SolanaProgramIdlMap;
15300
15320
  declare class SolanaProgramService {
15301
15321
  private provider;
15302
15322
  private chainId;
@@ -15305,8 +15325,7 @@ declare class SolanaProgramService {
15305
15325
  constructor(provider: AnchorProvider, chainId: ChainID);
15306
15326
  /** Expose per-chain program IDs */
15307
15327
  get programIds(): SolanaProgramIds;
15308
- /** Anchor Program getter */
15309
- getProgram<K extends SolanaProgramName>(name: K): Program<(typeof this.programs)[K]['idl']>;
15328
+ getProgram<K extends SolanaProgramName>(name: K): Program<SolanaProgramIdlMap[K]>;
15310
15329
  listProgramNames(): SolanaProgramName[];
15311
15330
  get PROGRAM_IDS(): SolanaProgramIds;
15312
15331
  deriveGlobalConfigPda(): PublicKey$1;
@@ -15367,28 +15386,6 @@ declare class DepositClient {
15367
15386
  * SOL -> liqSOL via liqsol_core::deposit.
15368
15387
  */
15369
15388
  buildDepositTx(amount: bigint, user?: PublicKey$1): Promise<TransactionInstruction>;
15370
- buildSquadsDepositProposalTx(params: {
15371
- connection: Connection;
15372
- multisigPda: PublicKey$1;
15373
- amountLamports: bigint;
15374
- wallet: WalletLikeSigner;
15375
- vaultIndex?: number;
15376
- }): Promise<{
15377
- tx: Transaction;
15378
- transactionIndex: bigint;
15379
- vaultPda: PublicKey$1;
15380
- }>;
15381
- buildSquadsDepositProposalTx2(params: {
15382
- connection: Connection;
15383
- multisigPda: PublicKey$1;
15384
- amountLamports: bigint;
15385
- wallet: WalletLikeSigner;
15386
- vaultIndex?: number;
15387
- }): Promise<{
15388
- tx: Transaction;
15389
- transactionIndex: bigint;
15390
- vaultPda: PublicKey$1;
15391
- }>;
15392
15389
  /**
15393
15390
  * Build a withdraw-request transaction:
15394
15391
  * liqSOL -> SOL via liqsol_core::requestWithdraw.
@@ -15406,10 +15403,6 @@ declare class DepositClient {
15406
15403
  */
15407
15404
  private buildDepositIxForUser;
15408
15405
  }
15409
- type WalletLikeSigner = {
15410
- publicKey: PublicKey$1;
15411
- signTransaction: (tx: Transaction) => Promise<Transaction>;
15412
- };
15413
15406
 
15414
15407
  /**
15415
15408
  * Distribution client – wraps the distribution portion of the liqsol_core
@@ -15640,11 +15633,6 @@ declare class OutpostClient {
15640
15633
  constructor(provider: AnchorProvider, pgs: SolanaProgramService);
15641
15634
  get connection(): _solana_web3_js.Connection;
15642
15635
  get wallet(): WalletLike;
15643
- /**
15644
- * Expose the raw Program in case callers need to build custom
15645
- * instructions outside this client.
15646
- */
15647
- get liqsolCoreProgram(): Program<LiqsolCore>;
15648
15636
  /**
15649
15637
  * Build all outpost-related PDAs / ATAs for a given user.
15650
15638
  * Defaults to the connected wallet.
@@ -15903,6 +15891,10 @@ declare class SolanaStakingClient implements IStakingClient {
15903
15891
  /**
15904
15892
  * Send a signed transaction over HTTP RPC and wait for confirmation.
15905
15893
  * Throws if the transaction fails.
15894
+ *
15895
+ * - Handles benign "already processed" preflight errors.
15896
+ * - Uses getSignatureStatuses() instead of confirmTransaction()
15897
+ * so we don't care about blockheight expiry.
15906
15898
  */
15907
15899
  private sendAndConfirmHttp;
15908
15900
  /**
package/lib/stake.js CHANGED
@@ -5,6 +5,7 @@ var web3_js = require('@solana/web3.js');
5
5
  var anchor = require('@coral-xyz/anchor');
6
6
  var splToken = require('@solana/spl-token');
7
7
  var multisig = require('@sqds/multisig');
8
+ var bs58 = require('bs58');
8
9
  var ethers = require('ethers');
9
10
 
10
11
  function _interopNamespaceDefault(e) {
@@ -126,63 +127,6 @@ class DepositClient {
126
127
  }).instruction();
127
128
  });
128
129
  }
129
- buildSquadsDepositProposalTx(params) {
130
- return __async$g(this, null, function* () {
131
- var _a, _b, _c, _d;
132
- const { connection, multisigPda, amountLamports, wallet } = params;
133
- const vaultIndex = (_a = params.vaultIndex) != null ? _a : 0;
134
- if (!(wallet == null ? void 0 : wallet.publicKey)) throw new Error("wallet.publicKey missing");
135
- if (!amountLamports || amountLamports <= BigInt(0)) throw new Error("amountLamports must be > 0");
136
- const [vaultPda] = multisig__namespace.getVaultPda({ multisigPda, index: vaultIndex });
137
- const depositBuilt = yield this.buildDepositIxForUser(amountLamports, vaultPda);
138
- const ms = yield multisig__namespace.accounts.Multisig.fromAccountAddress(connection, multisigPda);
139
- const current = BigInt((_d = (_c = (_b = ms.transactionIndex) == null ? void 0 : _b.toString) == null ? void 0 : _c.call(_b)) != null ? _d : 0);
140
- const transactionIndex = current + BigInt(1);
141
- const { blockhash } = yield connection.getLatestBlockhash("confirmed");
142
- const message = new web3_js.TransactionMessage({
143
- payerKey: vaultPda,
144
- recentBlockhash: blockhash,
145
- instructions: [depositBuilt.ix]
146
- });
147
- const createVaultTxIx = yield multisig__namespace.instructions.vaultTransactionCreate({
148
- multisigPda,
149
- transactionIndex,
150
- creator: wallet.publicKey,
151
- vaultIndex,
152
- ephemeralSigners: 0,
153
- transactionMessage: message
154
- });
155
- const tx = new web3_js.Transaction().add(createVaultTxIx);
156
- return { tx, transactionIndex, vaultPda };
157
- });
158
- }
159
- buildSquadsDepositProposalTx2(params) {
160
- return __async$g(this, null, function* () {
161
- var _a, _b, _c, _d;
162
- const { connection, multisigPda, amountLamports, wallet } = params;
163
- const vaultIndex = (_a = params.vaultIndex) != null ? _a : 0;
164
- if (!(wallet == null ? void 0 : wallet.publicKey)) throw new Error("wallet.publicKey missing");
165
- if (!amountLamports || amountLamports <= BigInt(0)) throw new Error("amountLamports must be > 0");
166
- const [vaultPda] = multisig__namespace.getVaultPda({ multisigPda, index: vaultIndex });
167
- const depositBuilt = yield this.buildDepositIxForUser(amountLamports, vaultPda);
168
- const ms = yield multisig__namespace.accounts.Multisig.fromAccountAddress(connection, multisigPda);
169
- const current = BigInt((_d = (_c = (_b = ms.transactionIndex) == null ? void 0 : _b.toString) == null ? void 0 : _c.call(_b)) != null ? _d : 0);
170
- const transactionIndex = current + BigInt(1);
171
- const { blockhash } = yield connection.getLatestBlockhash("confirmed");
172
- new web3_js.TransactionMessage({
173
- payerKey: vaultPda,
174
- recentBlockhash: blockhash,
175
- instructions: [depositBuilt.ix]
176
- });
177
- const createProposalIx = yield multisig__namespace.instructions.proposalCreate({
178
- multisigPda,
179
- transactionIndex,
180
- creator: wallet.publicKey
181
- });
182
- const tx = new web3_js.Transaction().add(createProposalIx);
183
- return { tx, transactionIndex, vaultPda };
184
- });
185
- }
186
130
  buildWithdrawTx(_0) {
187
131
  return __async$g(this, arguments, function* (amount, user = this.wallet.publicKey) {
188
132
  if (!user) {
@@ -863,7 +807,8 @@ var instructions$7 = [
863
807
  writable: true
864
808
  },
865
809
  {
866
- name: "user"
810
+ name: "user",
811
+ writable: true
867
812
  },
868
813
  {
869
814
  name: "outpost_account",
@@ -1250,6 +1195,9 @@ var instructions$7 = [
1250
1195
  {
1251
1196
  name: "token_program"
1252
1197
  },
1198
+ {
1199
+ name: "associated_token_program"
1200
+ },
1253
1201
  {
1254
1202
  name: "system_program"
1255
1203
  }
@@ -1905,7 +1853,7 @@ var instructions$7 = [
1905
1853
  ],
1906
1854
  accounts: [
1907
1855
  {
1908
- name: "payer",
1856
+ name: "admin",
1909
1857
  writable: true,
1910
1858
  signer: true
1911
1859
  },
@@ -1913,6 +1861,9 @@ var instructions$7 = [
1913
1861
  name: "metadata",
1914
1862
  writable: true
1915
1863
  },
1864
+ {
1865
+ name: "global_config"
1866
+ },
1916
1867
  {
1917
1868
  name: "system_program"
1918
1869
  }
@@ -2362,6 +2313,7 @@ var instructions$7 = [
2362
2313
  accounts: [
2363
2314
  {
2364
2315
  name: "admin",
2316
+ writable: true,
2365
2317
  signer: true
2366
2318
  },
2367
2319
  {
@@ -2600,7 +2552,7 @@ var instructions$7 = [
2600
2552
  writable: true
2601
2553
  },
2602
2554
  {
2603
- name: "user_pretoken_record",
2555
+ name: "pool_pretoken_record",
2604
2556
  writable: true
2605
2557
  },
2606
2558
  {
@@ -5199,6 +5151,10 @@ var types$9 = [
5199
5151
  type: {
5200
5152
  kind: "struct",
5201
5153
  fields: [
5154
+ {
5155
+ name: "receipt_id",
5156
+ type: "u64"
5157
+ },
5202
5158
  {
5203
5159
  name: "liqports",
5204
5160
  type: "u64"
@@ -8062,7 +8018,8 @@ var instructions$3 = [
8062
8018
  writable: true
8063
8019
  },
8064
8020
  {
8065
- name: "user"
8021
+ name: "user",
8022
+ writable: true
8066
8023
  },
8067
8024
  {
8068
8025
  name: "outpost_account",
@@ -8449,6 +8406,9 @@ var instructions$3 = [
8449
8406
  {
8450
8407
  name: "token_program"
8451
8408
  },
8409
+ {
8410
+ name: "associated_token_program"
8411
+ },
8452
8412
  {
8453
8413
  name: "system_program"
8454
8414
  }
@@ -9104,7 +9064,7 @@ var instructions$3 = [
9104
9064
  ],
9105
9065
  accounts: [
9106
9066
  {
9107
- name: "payer",
9067
+ name: "admin",
9108
9068
  writable: true,
9109
9069
  signer: true
9110
9070
  },
@@ -9112,6 +9072,9 @@ var instructions$3 = [
9112
9072
  name: "metadata",
9113
9073
  writable: true
9114
9074
  },
9075
+ {
9076
+ name: "global_config"
9077
+ },
9115
9078
  {
9116
9079
  name: "system_program"
9117
9080
  }
@@ -9561,6 +9524,7 @@ var instructions$3 = [
9561
9524
  accounts: [
9562
9525
  {
9563
9526
  name: "admin",
9527
+ writable: true,
9564
9528
  signer: true
9565
9529
  },
9566
9530
  {
@@ -9799,7 +9763,7 @@ var instructions$3 = [
9799
9763
  writable: true
9800
9764
  },
9801
9765
  {
9802
- name: "user_pretoken_record",
9766
+ name: "pool_pretoken_record",
9803
9767
  writable: true
9804
9768
  },
9805
9769
  {
@@ -12398,6 +12362,10 @@ var types$5 = [
12398
12362
  type: {
12399
12363
  kind: "struct",
12400
12364
  fields: [
12365
+ {
12366
+ name: "receipt_id",
12367
+ type: "u64"
12368
+ },
12401
12369
  {
12402
12370
  name: "liqports",
12403
12371
  type: "u64"
@@ -15432,9 +15400,6 @@ class OutpostClient {
15432
15400
  get wallet() {
15433
15401
  return this.provider.wallet;
15434
15402
  }
15435
- get liqsolCoreProgram() {
15436
- return this.program;
15437
- }
15438
15403
  buildAccounts(user) {
15439
15404
  return __async$b(this, null, function* () {
15440
15405
  const userPk = user != null ? user : this.wallet.publicKey;
@@ -15549,7 +15514,8 @@ class OutpostClient {
15549
15514
  liqsolPoolAta: a.liqsolPoolAta,
15550
15515
  outpostAccount: a.outpostAccount,
15551
15516
  tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
15552
- systemProgram: web3_js.SystemProgram.programId
15517
+ systemProgram: web3_js.SystemProgram.programId,
15518
+ associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID
15553
15519
  }).instruction();
15554
15520
  });
15555
15521
  }
@@ -16219,7 +16185,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16219
16185
  const signed = yield this.signTransaction(prepared.tx);
16220
16186
  return this.sendAndConfirmHttp(signed, prepared);
16221
16187
  } catch (err) {
16222
- throw new Error(`Failed to deposit Solana: ${err}`);
16188
+ console.log(`Failed to deposit Solana: ${err}`);
16189
+ throw err;
16223
16190
  }
16224
16191
  });
16225
16192
  }
@@ -16237,7 +16204,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16237
16204
  const signed = yield this.signTransaction(prepared.tx);
16238
16205
  return this.sendAndConfirmHttp(signed, prepared);
16239
16206
  } catch (err) {
16240
- throw new Error(`Failed to withdraw Solana: ${err}`);
16207
+ console.log(`Failed to withdraw Solana: ${err}`);
16208
+ throw err;
16241
16209
  }
16242
16210
  });
16243
16211
  }
@@ -16256,7 +16224,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16256
16224
  const signed = yield this.signTransaction(prepared.tx);
16257
16225
  return this.sendAndConfirmHttp(signed, prepared);
16258
16226
  } catch (err) {
16259
- throw new Error(`Failed to stake Solana: ${err}`);
16227
+ console.log(`Failed to stake Solana: ${err}`);
16228
+ throw err;
16260
16229
  }
16261
16230
  });
16262
16231
  }
@@ -16275,7 +16244,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16275
16244
  const signed = yield this.signTransaction(prepared.tx);
16276
16245
  return this.sendAndConfirmHttp(signed, prepared);
16277
16246
  } catch (err) {
16278
- throw new Error(`Failed to unstake Solana: ${err}`);
16247
+ console.log(`Failed to unstake Solana: ${err}`);
16248
+ throw err;
16279
16249
  }
16280
16250
  });
16281
16251
  }
@@ -16294,7 +16264,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16294
16264
  const signed = yield this.signTransaction(prepared.tx);
16295
16265
  return this.sendAndConfirmHttp(signed, prepared);
16296
16266
  } catch (err) {
16297
- throw new Error(`Failed to buy liqSOL pretokens: ${err}`);
16267
+ console.log(`Failed to buy liqSOL pretokens: ${err}`);
16268
+ throw err;
16298
16269
  }
16299
16270
  });
16300
16271
  }
@@ -16384,7 +16355,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16384
16355
  chainID: this.network.chainId
16385
16356
  };
16386
16357
  } catch (err) {
16387
- throw new Error(`Failed to get Solana portfolio: ${err}`);
16358
+ console.log(`Failed to get Solana portfolio: ${err}`);
16359
+ throw err;
16388
16360
  }
16389
16361
  });
16390
16362
  }
@@ -16422,7 +16394,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16422
16394
  nativePriceTimestamp: timestamp
16423
16395
  });
16424
16396
  } catch (err) {
16425
- throw new Error(`Failed to build Solana tranche snapshot: ${err}`);
16397
+ console.log(`Failed to build Solana tranche snapshot: ${err}`);
16398
+ throw err;
16426
16399
  }
16427
16400
  });
16428
16401
  }
@@ -16435,7 +16408,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16435
16408
  const apyPercent = apyDecimal * 100;
16436
16409
  return apyPercent;
16437
16410
  } catch (err) {
16438
- throw new Error(`Failed to compute Solana system APY: ${err}`);
16411
+ console.log(`Failed to compute Solana system APY: ${err}`);
16412
+ throw err;
16439
16413
  }
16440
16414
  });
16441
16415
  }
@@ -16600,31 +16574,65 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16600
16574
  return singleTxFeeLamports;
16601
16575
  });
16602
16576
  }
16603
- sendAndConfirmHttp(signed, ctx) {
16577
+ sendAndConfirmHttp(signed, _ctx) {
16604
16578
  return __async$8(this, null, function* () {
16579
+ var _a, _b, _c;
16605
16580
  this.ensureUser();
16606
- const signature = yield this.connection.sendRawTransaction(
16607
- signed.serialize(),
16608
- {
16581
+ const rawTx = signed.serialize();
16582
+ let signature;
16583
+ try {
16584
+ signature = yield this.connection.sendRawTransaction(rawTx, {
16609
16585
  skipPreflight: false,
16610
16586
  preflightCommitment: commitment,
16611
16587
  maxRetries: 3
16588
+ });
16589
+ } catch (e) {
16590
+ const msg = (_a = e == null ? void 0 : e.message) != null ? _a : "";
16591
+ const isSendTxError = e instanceof web3_js.SendTransactionError || (e == null ? void 0 : e.name) === "SendTransactionError";
16592
+ if (isSendTxError && msg.includes("already been processed")) {
16593
+ console.warn(
16594
+ 'sendRawTransaction preflight says "already been processed"; treating as success and deriving signature from signed tx.'
16595
+ );
16596
+ const legacy = signed;
16597
+ const first = (_c = (_b = legacy.signatures) == null ? void 0 : _b[0]) == null ? void 0 : _c.signature;
16598
+ if (!first) {
16599
+ throw e;
16600
+ }
16601
+ signature = bs58.encode(first);
16602
+ } else {
16603
+ throw e;
16612
16604
  }
16613
- );
16614
- const conf = yield this.connection.confirmTransaction(
16615
- {
16616
- signature,
16617
- blockhash: ctx.blockhash,
16618
- lastValidBlockHeight: ctx.lastValidBlockHeight
16619
- },
16620
- commitment
16621
- );
16622
- if (conf.value.err) {
16623
- throw new Error(
16624
- `Transaction failed: ${JSON.stringify(conf.value.err)}`
16605
+ }
16606
+ const start = Date.now();
16607
+ const timeoutMs = 3e4;
16608
+ const pollIntervalMs = 500;
16609
+ while (true) {
16610
+ const { value } = yield this.connection.getSignatureStatuses(
16611
+ [signature],
16612
+ { searchTransactionHistory: true }
16625
16613
  );
16614
+ const status = value[0];
16615
+ if (status) {
16616
+ if (status.err) {
16617
+ throw new Error(
16618
+ `Transaction failed: ${JSON.stringify(status.err)}`
16619
+ );
16620
+ }
16621
+ const confirmations = status.confirmations;
16622
+ const confirmationStatus = status.confirmationStatus;
16623
+ const satisfied = confirmationStatus === "confirmed" || confirmationStatus === "finalized" || confirmations === null ||
16624
+ (confirmations != null ? confirmations : 0) > 0;
16625
+ if (satisfied) {
16626
+ return signature;
16627
+ }
16628
+ }
16629
+ if (Date.now() - start > timeoutMs) {
16630
+ throw new Error(
16631
+ `Transaction confirmation timed out for ${signature}`
16632
+ );
16633
+ }
16634
+ yield new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
16626
16635
  }
16627
- return signature;
16628
16636
  });
16629
16637
  }
16630
16638
  signTransaction(tx) {
@@ -42263,7 +42271,6 @@ class EthereumStakingClient {
42263
42271
  }
42264
42272
  getTrancheSnapshot(chainID) {
42265
42273
  return __async(this, null, function* () {
42266
- console.log("getTrancheSnapshot", chainID);
42267
42274
  try {
42268
42275
  const blockNumber = yield this.provider.getBlockNumber();
42269
42276
  const blockTag = { blockTag: blockNumber };