From 1dc764be70f86d4f41e71a1fa93b17aee361ffcd Mon Sep 17 00:00:00 2001 From: Lavanya Kasturi Date: Mon, 21 Aug 2023 11:21:43 -0500 Subject: [PATCH 1/3] Added example for contains to use regex --- .../how-to-use-chainhooks-with-stacks.md | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md b/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md index 796c73154..4d17caec0 100644 --- a/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md +++ b/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md @@ -100,8 +100,11 @@ Get any transaction moving STX tokens: Get any transaction emitting given print events predicate - `contract-identifier` mandatory argument admits: - - string type, fully qualifying the contract to observe. Example: `ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.monkey-sip09` `contains` mandatory argument admits: - - string type, used for matching event + - string type, fully qualifying the contract to observe. Example: `ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.monkey-sip09` + - `contains` argument admits string type, used for matching an event containing the specified string. Example: `vault` + - `matches_regex` argument admits string type that should be valid regex, used for matching an event that regex matches with the specified string. Example: `(?:^|\\W)vault(?:$|\\W)` + +The following example uses `contains` argument: ```json { @@ -113,13 +116,25 @@ Get any transaction emitting given print events predicate } ``` +The following example uses `matches_regex` argument: + +```json +{ + "if_this": { + "scope": "print_event", + "contract_identifier": "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.monkey-sip09", + "matches_regex": "(?:^|\\W)vault(?:$|\\W)" + }, +} +``` + Get any transaction calling a specific method for a given contract **directly**. > [!Warning] > If the observed method is being called by another contract, this predicate won't detect it. - `contract-identifier` mandatory argument admits: - - string type, fully qualifying the contract to observe. Example: `SP000000000000000000002Q6VF78.pox` `method` mandatory argument admits: - string type, used for specifying the method to observe. Example: `stack-stx`. + - string type, fully qualifying the contract to observe. Example: `SP000000000000000000002Q6VF78.pox` `method` mandatory argument admits: - string type, used for specifying the method to observe. Example: `stack-stx` ```json { From 6de4def719f68b5a4d692137272e8802b5873b80 Mon Sep 17 00:00:00 2001 From: Lavanya Kasturi Date: Tue, 22 Aug 2023 11:15:00 -0500 Subject: [PATCH 2/3] Update docs/how-to-guides/how-to-use-chainhooks-with-stacks.md Co-authored-by: Micaiah Reid --- docs/how-to-guides/how-to-use-chainhooks-with-stacks.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md b/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md index 4d17caec0..8819aac54 100644 --- a/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md +++ b/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md @@ -101,6 +101,7 @@ Get any transaction emitting given print events predicate - `contract-identifier` mandatory argument admits: - string type, fully qualifying the contract to observe. Example: `ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.monkey-sip09` + - Either the `contains` or `matches_regex` argument: - `contains` argument admits string type, used for matching an event containing the specified string. Example: `vault` - `matches_regex` argument admits string type that should be valid regex, used for matching an event that regex matches with the specified string. Example: `(?:^|\\W)vault(?:$|\\W)` From 293a907ed06be3b67e334f2350ca15ddd832b210 Mon Sep 17 00:00:00 2001 From: Lavanya Kasturi Date: Wed, 23 Aug 2023 10:03:18 -0500 Subject: [PATCH 3/3] Fixed formatting --- docs/how-to-guides/how-to-use-chainhooks-with-stacks.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md b/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md index 8819aac54..0a5b5c506 100644 --- a/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md +++ b/docs/how-to-guides/how-to-use-chainhooks-with-stacks.md @@ -102,8 +102,8 @@ Get any transaction emitting given print events predicate - `contract-identifier` mandatory argument admits: - string type, fully qualifying the contract to observe. Example: `ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.monkey-sip09` - Either the `contains` or `matches_regex` argument: - - `contains` argument admits string type, used for matching an event containing the specified string. Example: `vault` - - `matches_regex` argument admits string type that should be valid regex, used for matching an event that regex matches with the specified string. Example: `(?:^|\\W)vault(?:$|\\W)` + - `contains` argument admits string type, used for matching an event containing the specified string. Example: `vault` + - `matches_regex` argument admits string type that should be valid regex, used for matching an event that regex matches with the specified string. Example: `(?:^|\\W)vault(?:$|\\W)` The following example uses `contains` argument: @@ -135,7 +135,9 @@ Get any transaction calling a specific method for a given contract **directly**. > If the observed method is being called by another contract, this predicate won't detect it. - `contract-identifier` mandatory argument admits: - - string type, fully qualifying the contract to observe. Example: `SP000000000000000000002Q6VF78.pox` `method` mandatory argument admits: - string type, used for specifying the method to observe. Example: `stack-stx` + - string type, fully qualifying the contract to observe.Example: `SP000000000000000000002Q6VF78.pox` +- `method` mandatory argument admits: + - string type, used for specifying the method to observe. Example: `stack-stx` ```json { @@ -165,7 +167,6 @@ Get any transaction, including a contract deployment implementing a given trait // coming soon - `implement-trait` mandatory argument admits: - - string type, fully qualifying the trait's shape to observe. Example: `ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.sip09-protocol` ```json