@exodus/solana-api 3.12.1 → 3.13.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/package.json +2 -2
  3. package/src/api.js +26 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.13.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.12.1...@exodus/solana-api@3.13.0) (2025-01-08)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat: add SOL waitForTransactionStatus method (#4800)
13
+
14
+
15
+
6
16
  ## [3.12.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.12.0...@exodus/solana-api@3.12.1) (2025-01-02)
7
17
 
8
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "3.12.1",
3
+ "version": "3.13.0",
4
4
  "description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Solana",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -47,7 +47,7 @@
47
47
  "@exodus/assets-testing": "^1.0.0",
48
48
  "@exodus/solana-web3.js": "^1.63.1-exodus.9-rc3"
49
49
  },
50
- "gitHead": "8a6a0d1a70d14e86a9cf4d47b8884939f10be724",
50
+ "gitHead": "aac8ba83fb14935634067e0870c88939afa92b00",
51
51
  "bugs": {
52
52
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
53
53
  },
package/src/api.js CHANGED
@@ -178,6 +178,32 @@ export class Api {
178
178
  return this.rpcCall('getBlockTime', [slot])
179
179
  }
180
180
 
181
+ async waitForTransactionStatus(txIds, status = 'finalized', timeoutMs = ms('1m')) {
182
+ if (!Array.isArray(txIds)) txIds = [txIds]
183
+ const startTime = Date.now()
184
+
185
+ while (true) {
186
+ const response = await this.rpcCall('getSignatureStatuses', [
187
+ txIds,
188
+ { searchTransactionHistory: true },
189
+ ])
190
+ const data = response.value
191
+ const allTxsAreConfirmed = data.every((elem) => elem?.confirmationStatus === status)
192
+ if (allTxsAreConfirmed) {
193
+ return true
194
+ }
195
+
196
+ // Check if the timeout has elapsed
197
+ if (Date.now() - startTime >= timeoutMs) {
198
+ // timeout
199
+ throw new Error('waitForTransactionStatus timeout')
200
+ }
201
+
202
+ // Wait for the specified interval before the next request
203
+ await new Promise((resolve) => setTimeout(resolve, ms('10s')))
204
+ }
205
+ }
206
+
181
207
  async getSignaturesForAddress(address, { until, before, limit } = {}) {
182
208
  until = until || undefined
183
209
  return this.rpcCall('getSignaturesForAddress', [address, { until, before, limit }], { address })