@exodus/solana-api 3.13.6 → 3.14.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 +22 -0
- package/README.md +21 -5
- package/package.json +4 -5
- package/src/api.js +59 -7
- package/src/tx-log/solana-monitor.js +8 -1
- package/src/txs-utils.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.14.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.13.7...@exodus/solana-api@3.14.0) (2025-03-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* feat: SOL internal sends in txLog (#5199)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [3.13.7](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.13.6...@exodus/solana-api@3.13.7) (2025-03-03)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
* fix: await result in retry (#5113)
|
|
23
|
+
|
|
24
|
+
* fix: SOL getAccountInfo commitment (#5114)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [3.13.6](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.13.5...@exodus/solana-api@3.13.6) (2025-02-17)
|
|
7
29
|
|
|
8
30
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
# @exodus/solana-api
|
|
1
|
+
# @exodus/solana-api · [](https://www.npmjs.com/package/@exodus/solana-api)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The **solana-api** provides utilities for interacting with the Solana blockchain.
|
|
4
|
+
It offers functionality to query transaction data, monitor network health, and broadcast transactions, specifically:
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
- Provides an interface for communicating with the Solana backend, exposing methods to fetch transaction and account details, check node health, query staked amounts, and retrieve withdrawal histories.
|
|
7
|
+
- Includes functions for broadcasting transactions to the Solana network.
|
|
8
|
+
- Monitors transactions, retrieves staking data, and logs transaction history, ensuring the wallet’s state remains in sync with on-chain data.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Install the package via `yarn`:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
yarn add @exodus/solana-api
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
This project is licensed under the MIT License.
|
|
23
|
+
You are free to use, modify, and distribute this software under the terms of the MIT License.
|
|
24
|
+
For more details, see the [LICENSE](LICENSE) file.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.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",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@exodus/assets": "^11.0.0",
|
|
28
28
|
"@exodus/basic-utils": "^3.0.1",
|
|
29
29
|
"@exodus/currency": "^6.0.1",
|
|
30
|
-
"@exodus/fetch": "^1.
|
|
30
|
+
"@exodus/fetch": "^1.7.3",
|
|
31
31
|
"@exodus/models": "^12.0.1",
|
|
32
32
|
"@exodus/simple-retry": "^0.0.6",
|
|
33
33
|
"@exodus/solana-lib": "^3.9.4",
|
|
@@ -40,14 +40,13 @@
|
|
|
40
40
|
"make-concurrent": "^4.0.0",
|
|
41
41
|
"minimalistic-assert": "^1.0.1",
|
|
42
42
|
"ms": "^2.1.3",
|
|
43
|
-
"url-join": "^4.0.0"
|
|
44
|
-
"wretch": "^1.5.2"
|
|
43
|
+
"url-join": "^4.0.0"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@exodus/assets-testing": "^1.0.0",
|
|
48
47
|
"@exodus/solana-web3.js": "^1.63.1-exodus.9-rc3"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "0ad4bff46edd70ed69c9351d682d36b3436dbd1f",
|
|
51
50
|
"bugs": {
|
|
52
51
|
"url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
|
|
53
52
|
},
|
package/src/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import createApiCJS from '@exodus/asset-json-rpc'
|
|
2
2
|
import { memoize } from '@exodus/basic-utils'
|
|
3
|
+
import wretch from '@exodus/fetch/wretch'
|
|
3
4
|
import { retry } from '@exodus/simple-retry'
|
|
4
5
|
import {
|
|
5
6
|
buildRawTransaction,
|
|
@@ -18,11 +19,10 @@ import BN from 'bn.js'
|
|
|
18
19
|
import lodash from 'lodash'
|
|
19
20
|
import ms from 'ms'
|
|
20
21
|
import urljoin from 'url-join'
|
|
21
|
-
import wretch from 'wretch'
|
|
22
22
|
|
|
23
23
|
import { Connection } from './connection.js'
|
|
24
24
|
import { getStakeActivation } from './get-stake-activation/index.js'
|
|
25
|
-
import { isSplTransferInstruction } from './txs-utils.js'
|
|
25
|
+
import { isSolTransferInstruction, isSplTransferInstruction } from './txs-utils.js'
|
|
26
26
|
|
|
27
27
|
const createApi = createApiCJS.default || createApiCJS
|
|
28
28
|
|
|
@@ -215,9 +215,13 @@ export class Api {
|
|
|
215
215
|
const fetchRetry = retry(
|
|
216
216
|
async () => {
|
|
217
217
|
try {
|
|
218
|
-
return this.rpcCall(
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
return await this.rpcCall(
|
|
219
|
+
'getSignaturesForAddress',
|
|
220
|
+
[address, { until, before, limit }],
|
|
221
|
+
{
|
|
222
|
+
address,
|
|
223
|
+
}
|
|
224
|
+
)
|
|
221
225
|
} catch (error) {
|
|
222
226
|
if (
|
|
223
227
|
error.message &&
|
|
@@ -445,7 +449,11 @@ export class Api {
|
|
|
445
449
|
return [...acc, ...val.instructions]
|
|
446
450
|
}, [])
|
|
447
451
|
.filter(
|
|
448
|
-
(ix) =>
|
|
452
|
+
(ix) =>
|
|
453
|
+
ix.parsed &&
|
|
454
|
+
(isSplTransferInstruction({ program: ix.program, type: ix.parsed.type }) ||
|
|
455
|
+
(!includeUnparsed &&
|
|
456
|
+
isSolTransferInstruction({ program: ix.program, type: ix.parsed.type })))
|
|
449
457
|
)
|
|
450
458
|
.map((ix) => {
|
|
451
459
|
const source = lodash.get(ix, 'parsed.info.source')
|
|
@@ -466,6 +474,49 @@ export class Api {
|
|
|
466
474
|
return
|
|
467
475
|
}
|
|
468
476
|
|
|
477
|
+
if (
|
|
478
|
+
source === ownerAddress &&
|
|
479
|
+
isSolTransferInstruction({ program: ix.program, type: ix.parsed.type })
|
|
480
|
+
) {
|
|
481
|
+
const lamports = Number(lodash.get(ix, 'parsed.info.lamports', 0))
|
|
482
|
+
if (solanaTransferTx) {
|
|
483
|
+
solanaTransferTx.lamports += lamports
|
|
484
|
+
if (!Array.isArray(solanaTransferTx.to)) {
|
|
485
|
+
solanaTransferTx.data = {
|
|
486
|
+
sent: [
|
|
487
|
+
{
|
|
488
|
+
address: solanaTransferTx.to,
|
|
489
|
+
amount: solanaTransferTx.amount,
|
|
490
|
+
},
|
|
491
|
+
],
|
|
492
|
+
}
|
|
493
|
+
solanaTransferTx.to = [solanaTransferTx.to]
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
solanaTransferTx.to.push(destination)
|
|
497
|
+
solanaTransferTx.data.sent.push({ address: destination, amount })
|
|
498
|
+
} else {
|
|
499
|
+
solanaTransferTx = {
|
|
500
|
+
source,
|
|
501
|
+
owner: source,
|
|
502
|
+
from: source,
|
|
503
|
+
to: [destination],
|
|
504
|
+
lamports,
|
|
505
|
+
data: {
|
|
506
|
+
sent: [
|
|
507
|
+
{
|
|
508
|
+
address: destination,
|
|
509
|
+
amount,
|
|
510
|
+
},
|
|
511
|
+
],
|
|
512
|
+
},
|
|
513
|
+
fee,
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return
|
|
518
|
+
}
|
|
519
|
+
|
|
469
520
|
const tokenAccount = tokenAccountsByOwner.find(({ tokenAccountAddress }) => {
|
|
470
521
|
return [source, destination].includes(tokenAccountAddress)
|
|
471
522
|
})
|
|
@@ -553,6 +604,7 @@ export class Api {
|
|
|
553
604
|
to: solanaTransferTx.destination,
|
|
554
605
|
amount: solanaTransferTx.lamports, // number
|
|
555
606
|
fee: isSending ? fee : 0,
|
|
607
|
+
data: solanaTransferTx.data,
|
|
556
608
|
}
|
|
557
609
|
}
|
|
558
610
|
|
|
@@ -833,7 +885,7 @@ export class Api {
|
|
|
833
885
|
async getAccountInfo(address, encoding = 'jsonParsed') {
|
|
834
886
|
const { value } = await this.rpcCall(
|
|
835
887
|
'getAccountInfo',
|
|
836
|
-
[address, { encoding, commitment: '
|
|
888
|
+
[address, { encoding, commitment: 'confirmed' }],
|
|
837
889
|
{ address }
|
|
838
890
|
)
|
|
839
891
|
return value
|
|
@@ -249,11 +249,18 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
249
249
|
|
|
250
250
|
if (tx.owner === address) {
|
|
251
251
|
// send transaction
|
|
252
|
-
item.to = tx.to
|
|
252
|
+
item.to = Array.isArray(tx.to) ? undefined : tx.to
|
|
253
253
|
item.feeAmount = baseAsset.currency.baseUnit(tx.fee) // in SOL
|
|
254
254
|
item.feeCoinName = baseAsset.name
|
|
255
255
|
item.coinAmount = item.coinAmount.negate()
|
|
256
256
|
|
|
257
|
+
if (tx.data?.sent) {
|
|
258
|
+
item.data.sent = tx.data.sent.map((s) => ({
|
|
259
|
+
address: s.address,
|
|
260
|
+
amount: baseAsset.currency.baseUnit(s.amount).toDefaultString({ unit: true }),
|
|
261
|
+
}))
|
|
262
|
+
}
|
|
263
|
+
|
|
257
264
|
if (tx.to === tx.owner) {
|
|
258
265
|
item.selfSend = true
|
|
259
266
|
item.coinAmount = asset.currency.ZERO
|
package/src/txs-utils.js
CHANGED
|
@@ -15,3 +15,6 @@ export const isSolanaRewardsActivityTx = (tx) =>
|
|
|
15
15
|
|
|
16
16
|
export const isSplTransferInstruction = ({ program, type }) =>
|
|
17
17
|
program === 'spl-token' && TRANSFER_INSTRUCTION_TYPES.has(type)
|
|
18
|
+
|
|
19
|
+
export const isSolTransferInstruction = ({ program, type }) =>
|
|
20
|
+
program === 'system' && TRANSFER_INSTRUCTION_TYPES.has(type)
|