@exodus/solana-api 3.11.4 → 3.11.5

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,15 @@
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.11.5](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.11.4...@exodus/solana-api@3.11.5) (2024-10-24)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * SOL activation state ([#4347](https://github.com/ExodusMovement/assets/issues/4347)) ([534a39c](https://github.com/ExodusMovement/assets/commit/534a39c4210eedce70736e70753902cce2e25565))
12
+
13
+
14
+
6
15
  ## [3.11.4](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.11.3...@exodus/solana-api@3.11.4) (2024-10-24)
7
16
 
8
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "3.11.4",
3
+ "version": "3.11.5",
4
4
  "description": "Exodus internal Solana asset API wrapper",
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": "55c9603915258ecf69934fcb3a4dcd910c7f4758",
50
+ "gitHead": "caa493c31c23640adf1c56b61c411e432fed9f66",
51
51
  "bugs": {
52
52
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
53
53
  },
@@ -15,7 +15,7 @@ function getStakeAndActivating(
15
15
  targetEpoch, // number
16
16
  stakeHistory // StakeHistoryEntry[]
17
17
  ) {
18
- if (delegation.activationEpoch === delegation.deactivationEpoch) {
18
+ if (Number(delegation.activationEpoch) === Number(delegation.deactivationEpoch)) {
19
19
  // activated but instantly deactivated; no stake at all regardless of target_epoch
20
20
  return {
21
21
  effective: 0,
@@ -23,7 +23,7 @@ function getStakeAndActivating(
23
23
  }
24
24
  }
25
25
 
26
- if (targetEpoch === delegation.activationEpoch) {
26
+ if (targetEpoch === Number(delegation.activationEpoch)) {
27
27
  // all is activating
28
28
  return {
29
29
  effective: 0,
@@ -31,7 +31,7 @@ function getStakeAndActivating(
31
31
  }
32
32
  }
33
33
 
34
- if (targetEpoch < delegation.activationEpoch) {
34
+ if (targetEpoch < Number(delegation.activationEpoch)) {
35
35
  // not yet enabled
36
36
  return {
37
37
  effective: 0,
@@ -39,7 +39,7 @@ function getStakeAndActivating(
39
39
  }
40
40
  }
41
41
 
42
- let currentEpoch = delegation.activationEpoch
42
+ let currentEpoch = Number(delegation.activationEpoch)
43
43
  let entry = getStakeHistoryEntry(currentEpoch, stakeHistory)
44
44
  if (entry !== null) {
45
45
  // target_epoch > self.activation_epoch
@@ -60,7 +60,7 @@ function getStakeAndActivating(
60
60
  break
61
61
  }
62
62
 
63
- if (currentEpoch >= targetEpoch || currentEpoch >= delegation.deactivationEpoch) {
63
+ if (currentEpoch >= targetEpoch || currentEpoch >= Number(delegation.deactivationEpoch)) {
64
64
  break
65
65
  }
66
66
 
@@ -82,9 +82,10 @@ function getStakeAndActivating(
82
82
 
83
83
  export function getStakeActivatingAndDeactivating(delegation, targetEpoch, stakeHistory) {
84
84
  const { effective, activating } = getStakeAndActivating(delegation, targetEpoch, stakeHistory)
85
+ const deactivationEpoch = Number(delegation.deactivationEpoch)
85
86
 
86
87
  // then de-activate some portion if necessary
87
- if (targetEpoch < delegation.deactivationEpoch) {
88
+ if (targetEpoch < deactivationEpoch) {
88
89
  return {
89
90
  effective,
90
91
  activating,
@@ -92,7 +93,7 @@ export function getStakeActivatingAndDeactivating(delegation, targetEpoch, stake
92
93
  }
93
94
  }
94
95
 
95
- if (targetEpoch === delegation.deactivationEpoch) {
96
+ if (targetEpoch === deactivationEpoch) {
96
97
  // can only deactivate what's activated
97
98
  return {
98
99
  effective,
@@ -101,7 +102,7 @@ export function getStakeActivatingAndDeactivating(delegation, targetEpoch, stake
101
102
  }
102
103
  }
103
104
 
104
- let currentEpoch = delegation.deactivationEpoch
105
+ let currentEpoch = deactivationEpoch
105
106
  let entry = getStakeHistoryEntry(currentEpoch, stakeHistory)
106
107
  if (entry !== null) {
107
108
  // target_epoch > self.activation_epoch
@@ -9,6 +9,7 @@ export async function getStakeActivation(api, stakeAddress) {
9
9
  api.getEpochInfo(),
10
10
  (async () => {
11
11
  const stakeAccount = await api.getAccountInfo(stakeAddress)
12
+ if (!stakeAccount) return null
12
13
  if (stakeAccount.data.discriminant === 0) {
13
14
  throw new Error('data.discriminant is 0')
14
15
  }
@@ -20,6 +21,13 @@ export async function getStakeActivation(api, stakeAddress) {
20
21
  })(),
21
22
  ])
22
23
 
24
+ if (!stakeAccount)
25
+ return {
26
+ status: 'inactive',
27
+ active: 0,
28
+ inactive: 0,
29
+ }
30
+
23
31
  const rentExemptReserve = stakeAccount.data.parsed.info.meta.rentExemptReserve
24
32
  if (stakeAccount.data.parsed.discriminant === 1) {
25
33
  return {