3.0.0 • Published 2 years ago

@daodiseomoney/log-finder-ruleset v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@daodiseomoney/log-finder-ruleset

Terra standard ruleset for well known log patterns

Example codes

import {
  createActionRuleSet,
  createAmountRuleSet
  createLogMatcherForActions,
  createLogMatcherForAmounts,
  getTxCanonicalMsgs,
  getTxAmounts
} from "@daodiseomoney/log-finder-ruleset"

// https://lcd.daodiseo.dev/txs/:txhash
const tx = {
  "height": ...,
  "txhash": ...,
  "raw_log": ...,
  "logs": ...,
  "gas_wanted": ...,
  "gas_used": ...,
  "tx": ...,
  "timestamp": ...,
}
const address = "daodiseo1..."
const network = "mainnet"

// getTxCanonicalMsgs
const actionRuleset = createActionRuleSet(network)
const actionLogMatcher = createLogMatcherForActions(actionRuleset)
const actionMatchedMsg = getTxCanonicalMsgs(JSON.stringify(tx), actionLogMatcher)

console.log(actionMatchedMsg)


// getTxAmountInfo
const amountRuleset = createAmountRuleSet(network)
const amountLogMatcher = createLogMatcherForAmounts(amountRuleset)
const amountMatchedMsg = getTxAmounts(JSON.stringify(tx), amountLogMatcher, address)

console.log(amountMatchedMsg)