Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: revisit the match filter #729

Merged
merged 17 commits into from
Mar 3, 2024
1,343 changes: 636 additions & 707 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,25 @@ source-utxorpc = ["tonic", "futures"]
sql = ["sqlx"]

[dependencies]
pallas = "0.21.0"
# pallas = "0.21.0"
# pallas = { path = "../pallas/pallas" }
# pallas = { git = "https://github.com/txpipe/pallas" }
pallas = { git = "https://github.com/txpipe/pallas" }

gasket = { version = "^0.6", features = ["derive"] }
# gasket = { path = "../../construkts/gasket-rs/gasket", features = ["derive"] }
# gasket = { git = "https://github.com/construkts/gasket-rs.git", features = ["derive"] }

utxorpc = { version = "1.0.0-alpha.1" }
utxorpc = { version = "^0.1" }

hex = "0.4.3"
net2 = "0.2.37"
bech32 = "0.9.1"
clap = { version = "4.2.7", features = ["derive"] }
env_logger = "0.10.0"
crossterm = "0.26"
merge = "0.1.0"
regex = "1.10.3"
handlebars = "^5.1"
config = { version = "0.13.2", default-features = false, features = ["toml", "yaml", "json"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = { version = "1.0.104", features = ["arbitrary_precision"] }
Expand Down Expand Up @@ -83,4 +86,3 @@ aws-types = { version = "^1.1", optional = true }
aws-sdk-s3 = { version = "^1.1", optional = true }
aws-sdk-sqs = { version = "^1.1", optional = true }
aws-sdk-lambda = { version = "^1.1", optional = true }
handlebars = "5.1.1"
3 changes: 0 additions & 3 deletions docs/pages/v2/filters/dsl.mdx

This file was deleted.

75 changes: 75 additions & 0 deletions docs/pages/v2/filters/select.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Select filter

## Examples

Match any tx that interacts with this particular address

```toml
predicate = "addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x"
```

Match any tx that interacts with this particular stake address

```toml
predicate = "stake178phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcccycj5"
```

Match any tx that interacts with this particular asset

```toml
predicate = "asset17jd78wukhtrnmjh3fngzasxm8rck0l2r4hhyyt"
```

Match any tx that holds a particular datum

```toml
predicate = "datum1httkxyxp8x0dlpdt3k6cwng5pxj3j"
```

Match any tx that holds a particular metadata label

```toml
predicate = "#127"
```

Match any tx that interacts with any of these particular address

```toml
[filters.predicate]
any = [
"addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x",
"addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx",
"addr1vx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzers66hrl8",
]
```

Match any tx that interacts with all of these particular address simultaneously

```toml
[filters.predicate]
all = [
"addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx",
"stake178phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcccycj5",
]
```

Match any tx that simultanously interacts with a particlar address, holds a particular asset and present a particular metadata label

```toml
[filters.predicate]
all = [
"addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx",
"asset17jd78wukhtrnmjh3fngzasxm8rck0l2r4hhyyt",
"#789",
]
```

Match tx that has an output that simultaneously points to a particular address and contains a particular asset

```toml
[filters.predicate.match.output]
address = "addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx"
assets = ["asset17jd78wukhtrnmjh3fngzasxm8rck0l2r4hhyyt"]
datum = "datum1httkxyxp8x0dlpdt3k6cwng5pxj3j"
```

29 changes: 0 additions & 29 deletions examples/match_pattern/daemon.toml

This file was deleted.

21 changes: 21 additions & 0 deletions examples/select/daemon.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[source]
type = "N2N"
peers = ["relays-new.cardano-mainnet.iohk.io:3001"]

[intersect]
type = "Point"
value = [37225013, "65b3d40e6114e05b662ddde737da63bbab05b86d476148614e82cde98462a6f5"]

[[filters]]
type = "SplitBlock"

[[filters]]
type = "ParseCbor"

[[filters]]
type = "Select"
skip_uncertain = true
predicate = "addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x"

[sink]
type = "Stdout"
Binary file added examples/sqlite/mydatabase.db
Binary file not shown.
Loading
Loading