@stellar-expert/tx-meta-effects-parser 7.0.0 → 8.0.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/README.MD CHANGED
@@ -535,7 +535,7 @@ ClaimClaimableBalanceOp</sub></td>
535
535
  {
536
536
  type: 'liquidityPoolCreated',
537
537
  source: 'GBWC…DXHN',
538
- pool: '52a876f8',
538
+ pool: 'LA7FHJLT',
539
539
  reserves: [
540
540
  {
541
541
  asset: 'XLM',
@@ -565,7 +565,7 @@ ClaimClaimableBalanceOp</sub></td>
565
565
  {
566
566
  type: 'liquidityPoolUpdated',
567
567
  source: 'GBWC…DXHN',
568
- pool: '52a876f8',
568
+ pool: 'LA7FHJLT',
569
569
  reserves: [
570
570
  {
571
571
  asset: 'XLM',
@@ -595,7 +595,7 @@ ClaimClaimableBalanceOp</sub></td>
595
595
  {
596
596
  type: 'liquidityPoolDeposited',
597
597
  source: 'GBWC…DXHN',
598
- pool: '52a876f8',
598
+ pool: 'LA7FHJLT',
599
599
  assets: [
600
600
  {
601
601
  asset: 'XLM',
@@ -625,7 +625,7 @@ ClaimClaimableBalanceOp</sub></td>
625
625
  {
626
626
  type: 'liquidityPoolWithdrew',
627
627
  source: 'GBWC…DXHN',
628
- pool: '52a876f8',
628
+ pool: 'LA7FHJLT',
629
629
  assets: [
630
630
  {
631
631
  asset: 'XLM',
@@ -655,7 +655,7 @@ ClaimClaimableBalanceOp</sub></td>
655
655
  {
656
656
  type: 'liquidityPoolRemoved',
657
657
  source: 'GBWC…DXHN',
658
- pool: '52a876f8'
658
+ pool: 'LA7FHJLT'
659
659
  }
660
660
  ```
661
661
 
@@ -792,7 +792,7 @@ ClaimClaimableBalanceOp</sub></td>
792
792
  type: 'claimableBalanceCreated',
793
793
  source: 'GBWC…DXHN',
794
794
  sponsor: 'GBWC…DXHN',
795
- balance: '7aba6f9d',
795
+ balance: 'BDKDF75Y',
796
796
  asset: 'XLM',
797
797
  amount: '1000000000',
798
798
  claimants: [
@@ -821,7 +821,7 @@ ClaimClaimableBalanceOp</sub></td>
821
821
  type: 'claimableBalanceRemoved',
822
822
  source: 'GBKP…YDLI',
823
823
  sponsor: 'GBWC…DXHN',
824
- balance: '7aba6f9d',
824
+ balance: 'BDKDF75Y',
825
825
  asset: 'XLM',
826
826
  amount: '1000000000',
827
827
  claimants: [
@@ -1198,61 +1198,6 @@ ClaimClaimableBalanceOp</sub></td>
1198
1198
  </td>
1199
1199
  </tr>
1200
1200
 
1201
- <tr>
1202
- <td>
1203
- <sub><code>liquidityPoolSponsorshipCreated</code></sub>
1204
- </td>
1205
- <td><sub>ChangeThrustOp</sub></td>
1206
- <td>
1207
-
1208
- ```js
1209
- {
1210
- type: 'liquidityPoolSponsorshipCreated',
1211
- source: 'GBWC…DXHN',
1212
- sponsor: 'GBWC…DXHN'
1213
- }
1214
- ```
1215
-
1216
- </td>
1217
- </tr>
1218
-
1219
- <tr>
1220
- <td>
1221
- <sub><code>liquidityPoolSponsorshipUpdated</code></sub>
1222
- </td>
1223
- <td><sub>RevokeSponsorshipOp</sub></td>
1224
- <td>
1225
-
1226
- ```js
1227
- {
1228
- type: 'liquidityPoolSponsorshipUpdated',
1229
- source: 'GBWC…DXHN',
1230
- sponsor: 'GDNP…CMXH',
1231
- prevSponsor: 'GBWC…DXHN'
1232
- }
1233
- ```
1234
-
1235
- </td>
1236
- </tr>
1237
-
1238
- <tr>
1239
- <td>
1240
- <sub><code>liquidityPoolSponsorshipRemoved</code></sub>
1241
- </td>
1242
- <td><sub>RevokeSponsorshipOp</sub></td>
1243
- <td>
1244
-
1245
- ```js
1246
- {
1247
- type: 'liquidityPoolSponsorshipRemoved',
1248
- source: 'GBWC…DXHN',
1249
- prevSponsor: 'GBWC…DXHN'
1250
- }
1251
- ```
1252
-
1253
- </td>
1254
- </tr>
1255
-
1256
1201
  <tr>
1257
1202
  <td>
1258
1203
  <sub><code>contractCodeUploaded</code></sub>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-expert/tx-meta-effects-parser",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "description": "Low-level effects parser for Stellar transaction results and meta XDR",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -344,14 +344,14 @@ class EffectsAnalyzer {
344
344
  }
345
345
 
346
346
  liquidityPoolDeposit() {
347
- const {liquidityPoolId} = this.operation
348
- const change = this.changes.find(ch => ch.type === 'liquidityPool' && ch.action === 'updated' && ch.after.pool === liquidityPoolId)
347
+ const pool = StrKey.encodeLiquidityPool(Buffer.from(this.operation.liquidityPoolId, 'hex'))
348
+ const change = this.changes.find(ch => ch.type === 'liquidityPool' && ch.action === 'updated' && ch.after.pool === pool)
349
349
  if (!change) //tx failed
350
350
  return
351
351
  const {before, after} = change
352
352
  this.addEffect({
353
353
  type: effectTypes.liquidityPoolDeposited,
354
- pool: this.operation.liquidityPoolId,
354
+ pool,
355
355
  assets: after.asset.map((asset, i) => ({
356
356
  asset,
357
357
  amount: (after.amount[i] - before.amount[i]).toString()
@@ -362,7 +362,7 @@ class EffectsAnalyzer {
362
362
  }
363
363
 
364
364
  liquidityPoolWithdraw() {
365
- const pool = this.operation.liquidityPoolId
365
+ const pool = StrKey.encodeLiquidityPool(Buffer.from(this.operation.liquidityPoolId, 'hex'))
366
366
  const change = this.changes.find(ch => ch.type === 'liquidityPool' && ch.action === 'updated' && ch.before.pool === pool)
367
367
  if (!change) //tx failed
368
368
  return
@@ -481,7 +481,7 @@ class EffectsAnalyzer {
481
481
  asset: claimedOffer.asset
482
482
  }
483
483
  if (claimedOffer.poolId) {
484
- trade.pool = claimedOffer.poolId.toString('hex')
484
+ trade.pool = StrKey.encodeLiquidityPool(claimedOffer.poolId)
485
485
  } else {
486
486
  trade.offer = claimedOffer.offerId
487
487
  trade.seller = claimedOffer.account
@@ -1,6 +1,12 @@
1
1
  const {StrKey} = require('@stellar/stellar-base')
2
2
  const {TxMetaEffectParserError, UnexpectedTxMetaChangeError} = require('../errors')
3
- const {xdrParseAsset, xdrParseAccountAddress, xdrParseClaimant, xdrParsePrice, xdrParseSignerKey} = require('./tx-xdr-parser-utils')
3
+ const {
4
+ xdrParseAsset,
5
+ xdrParseAccountAddress,
6
+ xdrParseClaimant,
7
+ xdrParsePrice,
8
+ xdrParseSignerKey
9
+ } = require('./tx-xdr-parser-utils')
4
10
  const {generateContractStateEntryHash, generateContractCodeEntryHash} = require('./ledger-key')
5
11
 
6
12
  /**
@@ -176,8 +182,7 @@ function parseTrustlineEntry(value) {
176
182
  asset = xdrParseAsset(trustlineAsset)
177
183
  break
178
184
  case 3:
179
- asset = trustlineEntryXdr.asset().liquidityPoolId().toString('hex')
180
- //data.liquidityPoolUseCount = trustlineEntryXdr.liquidityPoolUseCount()
185
+ asset = StrKey.encodeLiquidityPool(trustlineEntryXdr.asset().liquidityPoolId())
181
186
  break
182
187
  default:
183
188
  throw new TxMetaEffectParserError(`Unsupported trustline type ` + trustlineType)
@@ -219,7 +224,7 @@ function parseLiquidityPoolEntry(value) {
219
224
  const params = body.params()
220
225
  return {
221
226
  entry: 'liquidityPool',
222
- pool: liquidityPoolEntryXdr.liquidityPoolId().toString('hex'),
227
+ pool: StrKey.encodeLiquidityPool(liquidityPoolEntryXdr.liquidityPoolId()),
223
228
  asset: [xdrParseAsset(params.assetA()), xdrParseAsset(params.assetB())],
224
229
  fee: params.fee(),
225
230
  amount: [body.reserveA().toString(), body.reserveB().toString()],
@@ -247,7 +252,7 @@ function parseOfferEntry(value) {
247
252
  function parseClaimableBalanceEntry(value) {
248
253
  const claimableBalanceXdr = value.value()
249
254
  const data = {
250
- balanceId: Buffer.from(claimableBalanceXdr.balanceId().value()).toString('hex'),
255
+ balanceId: StrKey.encodeClaimableBalance(claimableBalanceXdr.balanceId().value()),
251
256
  entry: 'claimableBalance',
252
257
  asset: xdrParseAsset(claimableBalanceXdr.asset()),
253
258
  amount: claimableBalanceXdr.amount().toString(),