Skip to content

yazadzhy/tx-meta-effects-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

135 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@stellar-expert/tx-meta-effects-parser

Low-level effects parser for Stellar transaction results and meta XDR

Some Stellar operations yield non-deterministic results, so developers often have to pull the data from Horizon /effects API endpoints. This package provides the ability to retrieve atomic ledger state modifications directly from the transaction execution result and metadata.

Installation

npm i @stellar-expert/tx-meta-effects-parser

Usage

const {parseTxOperationsMeta} = require('@stellar-expert/tx-meta-effects-parser')

const res = parseTxOperationsMeta({
  network: 'Public Global Stellar Network ; September 2015',
  tx: '_base64-encoded_transaction_envelope_XDR_',
  result: '_base64-encoded_transaction_result_XDR_',
  meta: '_base64-encoded_transaction_result_meta_XDR_'
})

console.log(res.effects)
console.log(res.operations[0].effects)

All effects

Effect Yielded by Example
feeCharged Transaction, FeeBumpTransaction
{
  type: 'feeCharged',
  source: 'GBKP…YDLI',
  asset: 'XLM',
  bid: '0.001',
  charged: '0.00001'
}
accountCreated CreateAccountOp
{
  type: 'accountCreated',
  source: 'GBKP…YDLI',
  account: 'GBWC…DXHN'
}
accountRemoved AccountMergeOp
{
  type: 'accountRemoved',
  source: 'GBKP…YDLI'
}
accountDebited CreateAccountOp, AccountMergeOp, PaymentOp, PathPaymentStrictReceiveOp, PathPaymentStrictSendOp, CreateClaimableBalanceOp, ClawbackOp
{
  type: 'accountDebited',
  source: 'GBKP…YDLI',
  asset: 'XLM',
  amount: '100'
}
accountCredited CreateAccountOp, AccountMergeOp, PaymentOp, PathPaymentStrictReceiveOp, PathPaymentStrictSendOp, ClaimClaimableBalanceOp, ClawbackOp, ClawbackClaimableBalance, InflationOp
{
  type: 'accountCredited',
  source: 'GBWC…DXHN',
  asset: 'XLM',
  amount: '100'
}
accountHomeDomainUpdated SetOptionsOp
{
  type: 'accountHomeDomainUpdated',
  source: 'GBWC…DXHN',
  domain: 'example.com'
}
accountThresholdsUpdated SetOptionsOp
{
  type: 'accountThresholdsUpdated',
  source: 'GBWC…DXHN',
  thresholds: [1, 1 ,3]
}
accountFlagsUpdated SetOptionsOp
{
  type: 'accountFlagsUpdated',
  source: 'GBWC…DXHN',
  flags: 2,
  prevFlags: 0
}
accountInflationDestinationUpdated SetOptionsOp
{
  type: 'accountInflationDestinationUpdated',
  source: 'GBWC…DXHN',
  inflationDestination: 'GBKP…YDLI'
}
accountSignerCreated SetOptionsOp
{
  type: 'accountSignerCreated',
  source: 'GBWC…DXHN',
  signer: 'GBKP…YDLI',
  weight: 1,
  signers: [
    {key: 'GBWC…DXHN', weight: 1},
    {key: 'GBKP…YDLI', weight: 1}
  ]
}
accountSignerUpdated SetOptionsOp
{
  type: 'accountSignerUpdated',
  source: 'GBWC…DXHN',
  signer: 'GBKP…YDLI',
  weight: 2,
  signers: [
    {key: 'GBWC…DXHN', weight: 2},
    {key: 'GBKP…YDLI', weight: 1}
  ]
}
accountSignerRemoved SetOptionsOp
{
  type: 'accountSignerRemoved',
  source: 'GBWC…DXHN',
  weight: 0,
  signer: 'GBKP…YDLI',
  signers: [
    {key: 'GBWC…DXHN', weight: 1}
  ]
}
trustlineCreated ChangeTrustOp
{
  type: 'trustlineCreated',
  source: 'GBWC…DXHN',
  asset: 'USD-GBKP…YDLI-1',
  kind: 'asset',
  limit: '100',
  flags: 1
}
trustlineUpdated ChangeTrustOp, AllowTrustOp, SetTrustLineFlagsOp
{
  type: 'trustlineUpdated',
  source: 'GBWC…DXHN',
  asset: 'USD-GBKP…YDLI-1',
  kind: 'asset',
  limit: '200',
  flags: 5
}
trustlineRemoved ChangeTrustOp
{
  type: 'trustlineRemoved',
  source: 'GBWC…DXHN',
  asset: 'USD-GBKP…YDLI-1',
  kind: 'asset',
  flags: 4,
}
trustlineAuthorizationUpdated AllowTrustOp, SetTrustLineFlagsOp
{
  type: 'trustlineAuthorizationUpdated',
  source: 'GBWC…DXHN',
  trustor: 'GBKP…YDLI',
  asset: 'USD-GBWC…DXHN-1',
  flags: 5,
  prevFlags: 2
}
assetMinted PaymentOp, PathPaymentStrictReceiveOp, PathPaymentStrictSendOp, CreateClaimableBalanceOp, ManageBuyOfferOp, ManageSellOfferOp, CreatePassiveOfferOp, DepositLiquidityOp
{
  type: 'assetMinted',
  source: 'GBWC…DXHN',
  asset: 'USD-GBWC…DXHN-1',
  amount: 100,
}
assetBurned PaymentOp, PathPaymentStrictReceiveOp, PathPaymentStrictSendOp, CreateClaimableBalanceOp, ManageBuyOfferOp, ManageSellOfferOp, CreatePassiveOfferOp, WithdrawLiquidityOp, ClawbackOp, ClaimClaimableBalanceOp
{
  type: 'assetBurned',
  source: 'GBWC…DXHN',
  asset: 'USD-GBWC…DXHN-1',
  amount: 200,
}
offerCreated CreatePassiveOfferOp, ManageBuyOfferOp, ManageSellOfferOp
{
  type: 'offerCreated',
  source: 'GBWC…DXHN',
  offer: '90427',
  owner: 'GBWC…DXHN',
  amount: '100',
  asset: [
    'USD-GBKP…YDLI-1',
    'XLM'
  ],
  price: 0.09215,
  flags: 0
}
offerUpdated CreatePassiveOfferOp, ManageBuyOfferOp, ManageSellOfferOp, PathPaymentOp
{
  type: 'offerUpdated',
  source: 'GBWC…DXHN',
  offer: '90427',
  owner: 'GBWC…DXHN',
  amount: '90',
  asset: [
    'USD-GBKP…YDLI-1',
    'XLM'
  ],
  price: 0.09215,
  flags: 0
}
offerRemoved CreatePassiveOfferOp, ManageBuyOfferOp, ManageSellOfferOp, PathPaymentOp, AllowTrustOp, SetTrustLineFlagsOp
{
  type: 'offerRemoved',
  source: 'GBWC…DXHN',
  offer: '90427',
  owner: 'GBWC…DXHN',
  asset: [
    'USD-GBKP…YDLI-1',
    'XLM'
  ],
  flags: 0
}
liquidityPoolCreated ChangeTrustOp
{
  type: 'liquidityPoolCreated',
  source: 'GBWC…DXHN',
  pool: '52a8…76f8',
  reserves: [
    {
      asset: 'XLM',
      amount: '0'
    },
    {
      asset: 'USD-GBKP…YDLI-1',
      amount: '0'
    }
  ],
  shares: '0',
  accounts: 1
}
liquidityPoolUpdated DepositLiquidityOp, WithdrawLiquidityOp, AllowTrustOp, SetTrustLineFlagsOp
{
  type: 'liquidityPoolUpdated',
  source: 'GBWC…DXHN',
  pool: '52a8…76f8',
  reserves: [
    {
      asset: 'XLM',
      amount: '1000'
    },
    {
      asset: 'USD-GBKP…YDLI-1',
      amount: '1000'
    }
  ],
  shares: '10000000000',
  accounts: 2
}
liquidityPoolDeposited DepositLiquidityOp
{
  type: 'liquidityPoolDeposited',
  source: 'GBWC…DXHN',
  pool: '52a8…76f8',
  assets: [
    {
      asset: 'XLM',
      amount: '1000'
    },
    {
      asset: 'USD-GBKP…YDLI-1',
      amount: '1000'
    }
  ],
  shares: '10000000000'
}
liquidityPoolWithdrew WithdrawLiquidityOp
{
  type: 'liquidityPoolWithdrew',
  source: 'GBWC…DXHN',
  pool: '52a8…76f8',
  assets: [
    {
      asset: 'XLM',
      amount: '500'
    },
    {
      asset: 'USD-GBKP…YDLI-1',
      amount: '500'
    }
  ],
  shares: '5000000000'
}
liquidityPoolRemoved ChangeTrustOp, AllowTrustOp, SetTrustLineFlagsOp
{
  type: 'liquidityPoolRemoved',
  source: 'GBWC…DXHN',
  pool: '52a8…76f8'
}
trade CreatePassiveOfferOp, ManageBuyOfferOp, ManageSellOfferOp, PathPaymentOp
{
  type: 'trade',
  source: 'GBWC…DXHN',
  offer: '1',
  amount: ['10', '10'],
  asset: [
    'USD-GBKP…YDLI-1',
    'XLM'
  ],
  seller: 'GBKP…YDLI'
}
dataEntryCreated ManageDataOp
{
  type: 'dataEntryCreated',
  source: 'GBWC…DXHN',
  name: 'test',
  value: 'dGVzdA=='
}
dataEntryUpdated ManageDataOp
{
  type: 'dataEntryUpdated',
  source: 'GBWC…DXHN',
  name: 'test',
  value: 'dGVzVA=='
}
dataEntryRemoved ManageDataOp
{
  type: 'dataEntryRemoved',
  source: 'GBWC…DXHN',
  name: 'test'
}
sequenceBumped BumpSequenceOp
{
  type: 'sequenceBumped',
  source: 'GBWC…DXHN',
  sequence: '100'
}
inflation InflationOp
{
  type: 'inflation',
  source: 'GBWC…DXHN'
}
claimableBalanceCreated CreateClaimableBalanceOp, AllowTrustOp, SetTrustLineFlagsOp
{
  type: 'claimableBalanceCreated',
  source: 'GBWC…DXHN',
  sponsor: 'GBWC…DXHN',
  balance: '7aba…6f9d',
  asset: 'XLM',
  amount: '100',
  claimants: [
    {
      destination: 'GBKP…YDLI',
      predicate: {
        absBefore: '1671220240580'
      }
    }
  ]
}
claimableBalanceRemoved ClaimClaimableBalanceOp, ClawbackClaimableBalanceOp
{
  type: 'claimableBalanceRemoved',
  source: 'GBKP…YDLI',
  sponsor: 'GBWC…DXHN',
  balance: '7aba…6f9d',
  asset: 'XLM',
  amount: '100',
  claimants: [
    {
      destination: 'GBKP…YDLI',
      predicate: {
        absBefore: '1671220240580'
      }
    }
  ]
}
accountSponsorshipCreated CreateAccountOp
{
  type: 'accountSponsorshipCreated',
  source: 'GBWC…DXHN',
  sponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI'
}
accountSponsorshipUpdated RevokeSponsorshipOp
{
  type: 'accountSponsorshipUpdated',
  source: 'GBWC…DXHN',
  sponsor: 'GDNP…CMXH',
  prevSponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI'
}
accountSponsorshipRemoved RevokeSponsorshipOp
{
  type: 'accountSponsorshipRemoved',
  source: 'GBWC…DXHN',
  prevSponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI'
}
trustlineSponsorshipCreated ChangeThrustOp
{
  type: 'trustlineSponsorshipCreated',
  source: 'GBWC…DXHN',
  sponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  asset: 'USD-GBKP…YDLI-1'
}
trustlineSponsorshipUpdated RevokeSponsorshipOp
{
  type: 'trustlineSponsorshipUpdated',
  source: 'GBWC…DXHN',
  sponsor: 'GDNP…CMXH',
  prevSponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  asset: 'USD-GBKP…YDLI-1'
}
trustlineSponsorshipRemoved RevokeSponsorshipOp
{
  type: 'trustlineSponsorshipRemoved',
  source: 'GBWC…DXHN',
  prevSponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  asset: 'USD-GBKP…YDLI-1'
}
offerSponsorshipCreated CreatePassiveOfferOp, ManageBuyOfferOp, ManageSellOfferOp
{
  type: 'offerSponsorshipCreated',
  source: 'GBWC…DXHN',
  sponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  offer: '100'
}
offerSponsorshipUpdated RevokeSponsorshipOp
{
  type: 'offerSponsorshipUpdated',
  source: 'GBWC…DXHN',
  sponsor: 'GDNP…CMXH',
  prevSponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  offer: '100'
}
offerSponsorshipRemoved RevokeSponsorshipOp
{
  type: 'offerSponsorshipRemoved',
  source: 'GBWC…DXHN',
  prevSponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  offer: '100'
}
dataSponsorshipCreated ManageDataOp
{
  type: 'dataSponsorshipCreated',
  source: 'GBWC…DXHN',
  sponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  name: 'name'
}
dataSponsorshipUpdated RevokeSponsorshipOp
{
  type: 'dataSponsorshipUpdated',
  source: 'GBWC…DXHN',
  sponsor: 'GDNP…CMXH',
  prevSponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  name: 'name'
}
dataSponsorshipRemoved RevokeSponsorshipOp
{
  type: 'dataSponsorshipRemoved',
  source: 'GBWC…DXHN',
  prevSponsor: 'GBWC…DXHN',
  account: 'GBKP…YDLI',
  name: 'name'
}
claimableBalanceSponsorshipCreated CreateClaimableBalanceOp
{
  type: 'claimableBalanceSponsorshipCreated',
  source: 'GBWC…DXHN',
  sponsor: 'GBWC…DXHN',
  balance: '7aba…6f9d'
}
claimableBalanceSponsorshipUpdated RevokeSponsorshipOp
{
  type: 'claimableBalanceSponsorshipUpdated',
  source: 'GBWC…DXHN',
  sponsor: 'GDNP…CMXH',
  prevSponsor: 'GBWC…DXHN',
  balance: '7aba…6f9d'
}
claimableBalanceSponsorshipRemoved RevokeSponsorshipOp
{
  type: 'claimableBalanceSponsorshipRemoved',
  source: 'GBWC…DXHN',
  prevSponsor: 'GBWC…DXHN',
  balance: '7aba…6f9d'
}
signerSponsorshipCreated SetOptionsOp
{
  type: 'signerSponsorshipCreated',
  source: 'GBWC…DXHN',
  sponsor: 'GBWC…DXHN',
  signer: 'GALF…CR2V',
  account: 'GBKP…YDLI'
}
signerSponsorshipUpdated RevokeSponsorshipOp
{
  type: 'signerSponsorshipUpdated',
  source: 'GBWC…DXHN',
  sponsor: 'GDNP…CMXH',
  prevSponsor: 'GBWC…DXHN',
  signer: 'GALF…CR2V',
  account: 'GBKP…YDLI'
}
signerSponsorshipRemoved RevokeSponsorshipOp
{
  type: 'signerSponsorshipRemoved',
  source: 'GBWC…DXHN',
  prevSponsor: 'GBWC…DXHN',
  signer: 'GALF…CR2V',
  account: 'GBKP…YDLI'
}
liquidityPoolSponsorshipCreated ChangeThrustOp
{
  type: 'liquidityPoolSponsorshipCreated',
  source: 'GBWC…DXHN',
  sponsor: 'GBWC…DXHN'
}
liquidityPoolSponsorshipUpdated RevokeSponsorshipOp
{
  type: 'liquidityPoolSponsorshipUpdated',
  source: 'GBWC…DXHN',
  sponsor: 'GDNP…CMXH',
  prevSponsor: 'GBWC…DXHN'
}
liquidityPoolSponsorshipRemoved RevokeSponsorshipOp
{
  type: 'liquidityPoolSponsorshipRemoved',
  source: 'GBWC…DXHN',
  prevSponsor: 'GBWC…DXHN'
}
contractCodeUploaded InvokeHostFunctionOp
{
  type: 'contractCodeUploaded',
  source: 'GBWC…DXHN',
  wasm: 'AGFz…AAAF',
  wasmHash: '5c55…e46d',
  keyHash: 'a833…f27f'
}
contractCodeRemoved InvokeHostFunctionOp
{
  type: 'contractCodeRemoved',
  source: 'GBWC…DXHN',
  wasmHash: '5c55…e46d',
  keyHash: 'a833…f27f'
}
contractCreated InvokeHostFunctionOp
{
  type: 'contractCreated',
  source: 'GBWC…DXHN',
  contract: 'CBIH…AZAD',
  kind: 'fromAsset',
  asset: 'ICGVCWUQXIHO-GBD2…FUAC-2'
}
contractUpdated InvokeHostFunctionOp
{
  type: 'contractUpdated',
  source: 'GBWC…DXHN',
  contract: 'CBIH…AZAD',
  kind: 'wasm',
  wasmHash: '5c55…e46d',
  prevWasmHash: 'eb94…19ae'

}
contractInvoked InvokeHostFunctionOp
{
  type: 'contractInvoked',
  source: 'GBWC…DXHN',
  contract: 'CBIH…AZAD',
  function: 'mint',
  rawArgs: 'AAAA…Ag==',
  depth: 1,
  args: [
    'CDFD…ITT3',
    '1000'
  ]
}
contractError InvokeHostFunctionOp
{
  type: 'contractError',
  source: 'GB6V…UIYN',
  contract: 'CBIH…AZAD',
  code: 13,
  details: [
    'trustline entry is missing for account',
    'GB6V…UIYN'
  ]
}
contractDataCreated InvokeHostFunctionOp
{
  type: 'contractDataCreated',
  source: 'GC3E…XMJY',
  owner: 'CCM3…OFJX',
  key: 'AAAA…0SQ=',
  value: 'AAAA…AA==',
  durability: 'persistent',
  keyHash: '2177…a56a'
}
contractDataUpdated InvokeHostFunctionOp
{
  type: 'contractDataUpdated',
  source: 'GC3E…XMJY',
  owner: 'CCM3…OFJX',
  key: 'AAAAFA==',
  value: 'AAAA…AA==',
  prevValue: 'AAAA…AAA=',
  durability: 'persistent',
  keyHash: '2177…a56a'
}
contractDataRemoved InvokeHostFunctionOp
{
  type: 'contractDataRemoved',
  source: 'GC3E…XMJY',
  owner: 'CCM3…OFJX',
  key: 'AAAAFA==',
  prevValue: 'AAAA…AAA=',
  durability: 'instance'
}
contractEvent InvokeHostFunctionOp
{
  type: 'contractEvent',
  source: 'GC3E…XMJY',
  contract: 'CCM3…OFJX',
  topics: [
    'mint',
    'GC3E…XMJY',
    'CDFD…ITT3',
    'AMDL:GC3E…XMJY'
  ],
  rawTopics: [
    'AAAA…aW50',
    'AAAA…gLs=',
    'AAAA…JA==',
    'AAAA…AAAA'
  ],
  data: '1000',
  rawData: 'AAAA…A+g='
}
contractMetrics InvokeHostFunctionOp
{
  type: 'contractMetrics',
  source: 'GC3E…XMJY',
  contract: 'CCM3…OFJX',
  cpu_insn: 25470499,
  emit_event: 5,
  emit_event_byte: 1176,
  invoke_time_nsecs: 2013675,
  ledger_read_byte: 36624,
  ledger_write_byte: 1028,
  max_emit_event_byte: 328,
  max_rw_code_byte: 16352,
  max_rw_data_byte: 924,
  max_rw_key_byte: 160,
  mem_byte: 10204502,
  read_code_byte: 33508,
  read_data_byte: 3116,
  read_entry: 16,
  read_key_byte: 1244,
  write_code_byte: 0,
  write_data_byte: 1028,
  write_entry: 5,
  write_key_byte: 0
}
setTtl ExtendFootprintTTLOp, RestoreFootprintOp
{
  type: 'setTtl',
  source: 'GC3E…XMJY',
  owner: 'CDAE…EH7T',
  kind: 'contractData',
  keyHash: '7594…b429',
  ttl: 2873856
}

About

Low-level effects parser for Stellar transaction results and meta XDR

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%