Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@xpla/log-finder
Advanced tools
Readme
Generic pattern matcher for XPLA transaction logs
npm i @xpla/log-finder
Any log pattern is defined like below:
export const createCW20TransferRule = (tokenAddress: string) => ({
// type: must match with the log type
type: 'from_contract',
// attributes: list of attributes to be matched against log's key and value.
// - index 0 and 1 are matched against key, value respectively.
// - you can omit index 1 to match only using key; useful when the value is not static.
// - you can also use callback as value `fn(string) => boolean`.
attributes: [
['contract_address', tokenAddress],
['action', 'transfer'],
['from', (address) => address.startsWith('xpla1')],
['to'],
['amount'],
],
// (optional) forces log matcher to find an exact match; rule is no longer partial.
strict: false,
// (optional) matchUntil extends the matched chunk until another attribute (with the key being matchUntil) is found
matchUntil: '...',
});
By default, log finder will match all logs that contain the log rule. This allows your log rule to be partial to the logs you are looking for. This behaviour is useful in case of inter-contract execution; a contract A calling contract B, but you only know the specific log pattern emitted from contract B, and still want to match the logs.
You can also define an optional strict
flag, forcing the log matcher to find an exact occurrence of the rule in the log.
Callback pattern is the default usage. Callback pattern is useful when you need to some transformation of the found logs as soon as they are found.
Note that the callback function is not async
-able.
// create a callback log finder
const logFinder = createLogFinder(
// provide your rule
createCW20TransferRule('xpla1....'),
// callback function to be called every time there is an occurrence
// found: the entire log fragment that triggered callback fn
// match: attributes that matched with the pattern you provided
(found, match) => {
// ... do something
},
);
logFinder({
type: 'from_contract',
attriutes: [
{ key: '...', value: '...' },
{ key: '...', value: '...' },
],
});
Returning pattern is a thin wrapper around callback pattern log finder. It allows you to treat log finder result as array of occurrences.
// use createReturningLogFinder for this usage
const logFinder = createReturningLogFinder(
// provide your rule
createCW20TransferRule('xpla1...'),
// optional transformer function; whatever is returned from this function will be
// included as `transformed` in the result
(found, match) => {
// return something
},
);
const result = logFinder({
type: 'from_contract',
attriutes: [
{ key: '...', value: '...' },
{ key: '...', value: '...' },
],
});
This software is licensed under the MIT license. See LICENSE for full disclosure.
© 2022 XPLA.
FAQs
Generic pattern matcher for XPLA transaction logs
The npm package @xpla/log-finder receives a total of 0 weekly downloads. As such, @xpla/log-finder popularity was classified as not popular.
We found that @xpla/log-finder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.