@exodus/solana-api 1.2.17 → 1.2.19

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +8 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "1.2.17",
3
+ "version": "1.2.19",
4
4
  "description": "Exodus internal Solana asset API wrapper",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -22,5 +22,5 @@
22
22
  "devDependencies": {
23
23
  "node-fetch": "~1.6.3"
24
24
  },
25
- "gitHead": "6e6162c94eefd164c7dd63d039be60f790b37ced"
25
+ "gitHead": "3c07cdab72a42b26fcb199418f7e61f71bf3d91f"
26
26
  }
package/src/index.js CHANGED
@@ -171,7 +171,10 @@ class Api {
171
171
  }))
172
172
 
173
173
  // program:type tells us if it's a SOL or Token transfer
174
- const solanaTx = lodash.find(instructions, { program: 'system', type: 'transfer' }) // get SOL transfer
174
+ const solanaTx = lodash.find(instructions, (ix) => {
175
+ if (![ix.source, ix.destination].includes(ownerAddress)) return false
176
+ return ix.program === 'system' && ix.type === 'transfer'
177
+ }) // get SOL transfer
175
178
  const stakeTx = lodash.find(instructions, { program: 'system', type: 'createAccountWithSeed' })
176
179
  const stakeWithdraw = lodash.find(instructions, { program: 'stake', type: 'withdraw' })
177
180
  const stakeUndelegate = lodash.find(instructions, { program: 'stake', type: 'deactivate' })
@@ -242,7 +245,9 @@ class Api {
242
245
  'tokenAccountsByOwner is required when parsing token tx'
243
246
  )
244
247
  let tokenTxs = lodash
245
- .filter(instructions, { program: 'spl-token', type: 'transfer' }) // get Token transfer: could have more than 1 instructions
248
+ .filter(instructions, ({ program, type }) => {
249
+ return program === 'spl-token' && ['transfer', 'transferChecked'].includes(type)
250
+ }) // get Token transfer: could have more than 1 instructions
246
251
  .map((ix) => {
247
252
  // add token details based on source/destination address
248
253
  let tokenAccount = lodash.find(tokenAccountsByOwner, { tokenAccountAddress: ix.source })
@@ -261,7 +266,7 @@ class Api {
261
266
  token: tokenAccount,
262
267
  from: ix.source,
263
268
  to: ix.destination,
264
- amount: Number(ix.amount), // token
269
+ amount: Number(ix.amount || lodash.get(ix, 'tokenAmount.amount', 0)), // supporting both types: transfer and transferChecked
265
270
  fee: isSending ? fee : 0, // in lamports
266
271
  }
267
272
  })