@exodus/solana-api 1.2.16 → 1.2.18
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/package.json +2 -2
- package/src/index.js +16 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.18",
|
|
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": "
|
|
25
|
+
"gitHead": "d65135b4c452dda913c1673a4465b0438f2d51ec"
|
|
26
26
|
}
|
package/src/index.js
CHANGED
|
@@ -198,12 +198,15 @@ class Api {
|
|
|
198
198
|
staking: {
|
|
199
199
|
method: 'createAccountWithSeed',
|
|
200
200
|
seed: stakeTx.seed,
|
|
201
|
-
|
|
201
|
+
stakeAddresses: [stakeTx.newAccount],
|
|
202
202
|
stake: stakeTx.lamports,
|
|
203
203
|
},
|
|
204
204
|
}
|
|
205
205
|
} else if (stakeWithdraw) {
|
|
206
|
-
|
|
206
|
+
const stakeAccounts = lodash.map(
|
|
207
|
+
lodash.filter(instructions, { program: 'stake', type: 'withdraw' }),
|
|
208
|
+
'stakeAccount'
|
|
209
|
+
)
|
|
207
210
|
tx = {
|
|
208
211
|
owner: stakeWithdraw.withdrawAuthority,
|
|
209
212
|
from: stakeWithdraw.stakeAccount,
|
|
@@ -212,20 +215,24 @@ class Api {
|
|
|
212
215
|
fee,
|
|
213
216
|
staking: {
|
|
214
217
|
method: 'withdraw',
|
|
215
|
-
|
|
218
|
+
stakeAddresses: stakeAccounts,
|
|
216
219
|
stake: stakeWithdraw.lamports,
|
|
217
220
|
},
|
|
218
221
|
}
|
|
219
222
|
} else if (stakeUndelegate) {
|
|
223
|
+
const stakeAccounts = lodash.map(
|
|
224
|
+
lodash.filter(instructions, { program: 'stake', type: 'deactivate' }),
|
|
225
|
+
'stakeAccount'
|
|
226
|
+
)
|
|
220
227
|
tx = {
|
|
221
228
|
owner: stakeUndelegate.stakeAuthority,
|
|
222
229
|
from: stakeUndelegate.stakeAuthority,
|
|
223
|
-
to: stakeUndelegate.stakeAccount,
|
|
230
|
+
to: stakeUndelegate.stakeAccount, // obsolete
|
|
224
231
|
amount: 0,
|
|
225
232
|
fee,
|
|
226
233
|
staking: {
|
|
227
234
|
method: 'undelegate',
|
|
228
|
-
|
|
235
|
+
stakeAddresses: stakeAccounts,
|
|
229
236
|
},
|
|
230
237
|
}
|
|
231
238
|
} else {
|
|
@@ -235,7 +242,9 @@ class Api {
|
|
|
235
242
|
'tokenAccountsByOwner is required when parsing token tx'
|
|
236
243
|
)
|
|
237
244
|
let tokenTxs = lodash
|
|
238
|
-
.filter(instructions, { program
|
|
245
|
+
.filter(instructions, ({ program, type }) => {
|
|
246
|
+
return program === 'spl-token' && ['transfer', 'transferChecked'].includes(type)
|
|
247
|
+
}) // get Token transfer: could have more than 1 instructions
|
|
239
248
|
.map((ix) => {
|
|
240
249
|
// add token details based on source/destination address
|
|
241
250
|
let tokenAccount = lodash.find(tokenAccountsByOwner, { tokenAccountAddress: ix.source })
|
|
@@ -254,7 +263,7 @@ class Api {
|
|
|
254
263
|
token: tokenAccount,
|
|
255
264
|
from: ix.source,
|
|
256
265
|
to: ix.destination,
|
|
257
|
-
amount: Number(ix.amount), //
|
|
266
|
+
amount: Number(ix.amount || lodash.get(ix, 'tokenAmount.amount', 0)), // supporting both types: transfer and transferChecked
|
|
258
267
|
fee: isSending ? fee : 0, // in lamports
|
|
259
268
|
}
|
|
260
269
|
})
|