@exodus/solana-api 3.12.0 → 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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
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
+
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)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+
22
+ * fix: solana nft send (#4768)
23
+
24
+
25
+
6
26
  ## [3.12.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.11.9...@exodus/solana-api@3.12.0) (2025-01-02)
7
27
 
8
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "3.12.0",
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",
@@ -30,7 +30,7 @@
30
30
  "@exodus/fetch": "^1.2.0",
31
31
  "@exodus/models": "^12.0.1",
32
32
  "@exodus/simple-retry": "^0.0.6",
33
- "@exodus/solana-lib": "^3.9.3",
33
+ "@exodus/solana-lib": "^3.9.4",
34
34
  "@exodus/solana-meta": "^2.0.2",
35
35
  "@exodus/timer": "^1.1.1",
36
36
  "bn.js": "^4.11.0",
@@ -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": "70de901b0d9b85f1045949400105203c700fc223",
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 })
package/src/tx-send.js CHANGED
@@ -8,19 +8,17 @@ import {
8
8
  import assert from 'minimalistic-assert'
9
9
 
10
10
  export const createAndBroadcastTXFactory =
11
- (api) =>
12
- async ({ asset, walletAccount, address, amount, options = {} }, { assetClientInterface }) => {
11
+ ({ api, assetClientInterface }) =>
12
+ async ({ asset, walletAccount, address, amount, options = {} }) => {
13
13
  const assetName = asset.name
14
14
  assert(assetClientInterface, `assetClientInterface must be supplied in sendTx for ${assetName}`)
15
15
 
16
16
  const {
17
17
  feeAmount,
18
- method,
19
18
  stakeAddresses,
20
19
  seed,
21
20
  pool,
22
- customMintAddress,
23
- tokenStandard,
21
+ nft,
24
22
  // <MagicEden>
25
23
  initializerAddress,
26
24
  initializerDepositTokenAddress,
@@ -38,12 +36,22 @@ export const createAndBroadcastTXFactory =
38
36
  reference,
39
37
  memo,
40
38
  } = options
39
+
40
+ let { method, customMintAddress, tokenStandard } = options
41
+
41
42
  const { baseAsset } = asset
42
43
  const from = await assetClientInterface.getReceiveAddress({
43
44
  assetName: baseAsset.name,
44
45
  walletAccount,
45
46
  })
46
47
 
48
+ if (nft) {
49
+ customMintAddress = nft.mintAddress
50
+ tokenStandard = nft.tokenStandard
51
+ method = tokenStandard === 4 ? 'metaplexTransfer' : undefined
52
+ amount = asset.currency.baseUnit(1)
53
+ }
54
+
47
55
  const isToken = asset.assetType === api.tokenAssetType
48
56
 
49
57
  // Check if receiver has address active when sending tokens.
@@ -72,15 +80,13 @@ export const createAndBroadcastTXFactory =
72
80
  let tokenParams = Object.create(null)
73
81
  if (isToken || customMintAddress) {
74
82
  const tokenMintAddress = customMintAddress || asset.mintAddress
75
- const tokenProgram =
83
+ const tokenProgramPublicKey =
76
84
  (await api.getAddressType(tokenMintAddress)) === 'token-2022'
77
85
  ? TOKEN_2022_PROGRAM_ID
78
86
  : TOKEN_PROGRAM_ID
79
- const tokenAddress = findAssociatedTokenAddress(
80
- address,
81
- tokenMintAddress,
82
- tokenProgram.toBase58()
83
- )
87
+
88
+ const tokenProgram = tokenProgramPublicKey.toBase58()
89
+ const tokenAddress = findAssociatedTokenAddress(address, tokenMintAddress, tokenProgram)
84
90
  const [destinationAddressType, isAssociatedTokenAccountActive, fromTokenAccountAddresses] =
85
91
  await Promise.all([
86
92
  api.getAddressType(address),