Skip to content

Commit

Permalink
Merge pull request #44 from algorandfoundation/or-logic
Browse files Browse the repository at this point in the history
feat: Added partial OR logic for type, sender, receiver, appId and assetId
  • Loading branch information
robdmoore authored Mar 27, 2024
2 parents 2d3b84d + 999803a commit bdb54b7
Show file tree
Hide file tree
Showing 16 changed files with 592 additions and 470 deletions.
26 changes: 13 additions & 13 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ getSubscribedTransactions({filters: [{name: 'filterName', filter: {/* Filter pro

Currently this allows you filter based on any combination (AND logic) of:

- Transaction type e.g. `filter: { type: TransactionType.axfer }`
- Account (sender and receiver) e.g. `filter: { sender: "ABCDE..F" }` and `filter: { receiver: "12345..6" }`
- Transaction type e.g. `filter: { type: TransactionType.axfer }` or `filter: {type: [TransactionType.axfer, TransactionType.pay] }`
- Account (sender and receiver) e.g. `filter: { sender: "ABCDE..F" }` or `filter: { sender: ["ABCDE..F", "ZYXWV..A"] }` and `filter: { receiver: "12345..6" }` or `filter: { receiver: ["ABCDE..F", "ZYXWV..A"] }`
- Note prefix e.g. `filter: { notePrefix: "xyz" }`
- Apps

- ID e.g. `filter: { appId: 54321 }`
- ID e.g. `filter: { appId: 54321 }` or `filter: { appId: [54321, 12345] }`
- Creation e.g. `filter: { appCreate: true }`
- Call on-complete(s) e.g. `filter: { appOnComplete: ApplicationOnComplete.optin }` and `filter: { appOnComplete: [ApplicationOnComplete.optin, ApplicationOnComplete.noop] }`
- ARC4 method signature(s) e.g. `filter: { methodSignature: "MyMethod(uint64,string)" }` and `filter: { methodSignatures: ["MyMethod(uint64,string)uint64", "MyMethod2(unit64)"] }`
- Call on-complete(s) e.g. `filter: { appOnComplete: ApplicationOnComplete.optin }` or `filter: { appOnComplete: [ApplicationOnComplete.optin, ApplicationOnComplete.noop] }`
- ARC4 method signature(s) e.g. `filter: { methodSignature: "MyMethod(uint64,string)" }` or `filter: { methodSignature: ["MyMethod(uint64,string)uint64", "MyMethod2(unit64)"] }`
- Call arguments e.g.
```typescript
filter: {
Expand All @@ -187,7 +187,7 @@ Currently this allows you filter based on any combination (AND logic) of:
Note: For this to work you need to [specify ARC-28 events in the subscription config](#arc-28-event-subscription-and-reads).

- Assets
- ID e.g. `filter: { assetId: 123456 }`
- ID e.g. `filter: { assetId: 123456 }` or `filter: { assetId: [123456, 456789] }`
- Creation e.g. `filter: { assetCreate: true }`
- Amount transferred (min and/or max) e.g. `filter: { type: TransactionType.axfer, minAmount: 1, maxAmount: 100 }`
- Balance changes (asset ID, sender, receiver, close to, min and/or max change) e.g. `filter: { balanceChanges: [{assetId: [15345, 36234], roles: [BalanceChangeRole.sender], address: "ABC...", minAmount: 1, maxAmount: 2}]}`
Expand Down Expand Up @@ -328,14 +328,14 @@ The indexer catchup isn't magic - if the filter you are trying to catch up with
To understand how the indexer behaviour works to know if you are likely to generate a lot of transactions it's worth understanding the architecture of the indexer catchup; indexer catchup runs in two stages:
1. **Pre-filtering**: Any filters that can be translated to the [indexer search transactions endpoint](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactions). This query is then run between the rounds that need to be synced and paginated in the max number of results (1000) at a time until all of the transactions are retrieved. This ensures we get round-based transactional consistency. This is the filter that can easily explode out though and take a long time when using indexer catchup. For avoidance of doubt, the following filters are the ones that are converted to a pre-filter:
- `sender`
- `receiver`
- `type`
- `sender` (single value)
- `receiver` (single value)
- `type` (single value)
- `notePrefix`
- `appId`
- `assetId`
- `minAmount`
- `maxAmount`
- `appId` (single value)
- `assetId` (single value)
- `minAmount` (and `type = pay` or `assetId` provided)
- `maxAmount` (and `maxAmount < Number.MAX_SAFE_INTEGER` and `type = pay` or (`assetId` provided and `minAmount > 0`))
2. **Post-filtering**: All remaining filters are then applied in-memory to the resulting list of transactions that are returned from the pre-filter before being returned as subscribed transactions.
## Entry points
Expand Down
6 changes: 3 additions & 3 deletions docs/code/interfaces/types_arc_28.Arc28Event.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The arguments of the event, in order

#### Defined in

[types/arc-28.ts:15](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L15)
[types/arc-28.ts:14](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L14)

___

Expand All @@ -36,7 +36,7 @@ Optional, user-friendly description for the event

#### Defined in

[types/arc-28.ts:13](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L13)
[types/arc-28.ts:12](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L12)

___

Expand All @@ -48,4 +48,4 @@ The name of the event

#### Defined in

[types/arc-28.ts:11](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L11)
[types/arc-28.ts:10](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L10)
10 changes: 5 additions & 5 deletions docs/code/interfaces/types_arc_28.Arc28EventGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Whether or not to silently (with warning log) continue if an error is encountere

#### Defined in

[types/arc-28.ts:56](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L56)
[types/arc-28.ts:55](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L55)

___

Expand All @@ -38,7 +38,7 @@ The list of ARC-28 event definitions

#### Defined in

[types/arc-28.ts:58](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L58)
[types/arc-28.ts:57](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L57)

___

Expand All @@ -50,7 +50,7 @@ The name to designate for this group of events.

#### Defined in

[types/arc-28.ts:50](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L50)
[types/arc-28.ts:49](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L49)

___

Expand All @@ -62,7 +62,7 @@ Optional list of app IDs that this event should apply to

#### Defined in

[types/arc-28.ts:52](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L52)
[types/arc-28.ts:51](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L51)

___

Expand All @@ -88,4 +88,4 @@ Optional predicate to indicate if these ARC-28 events should be processed for th

#### Defined in

[types/arc-28.ts:54](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L54)
[types/arc-28.ts:53](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L53)
10 changes: 5 additions & 5 deletions docs/code/interfaces/types_arc_28.Arc28EventToProcess.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The ARC-28 definition of the event

#### Defined in

[types/arc-28.ts:36](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L36)
[types/arc-28.ts:35](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L35)

___

Expand All @@ -44,7 +44,7 @@ The name of the ARC-28 event that was triggered

#### Defined in

[types/arc-28.ts:30](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L30)
[types/arc-28.ts:29](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L29)

___

Expand All @@ -56,7 +56,7 @@ The 4-byte hex prefix for the event

#### Defined in

[types/arc-28.ts:34](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L34)
[types/arc-28.ts:33](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L33)

___

Expand All @@ -68,7 +68,7 @@ The signature of the event e.g. `EventName(type1,type2)`

#### Defined in

[types/arc-28.ts:32](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L32)
[types/arc-28.ts:31](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L31)

___

Expand All @@ -80,4 +80,4 @@ The name of the ARC-28 event group the event belongs to

#### Defined in

[types/arc-28.ts:28](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L28)
[types/arc-28.ts:27](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L27)
14 changes: 7 additions & 7 deletions docs/code/interfaces/types_arc_28.EmittedArc28Event.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The ordered arguments extracted from the event that was emitted

#### Defined in

[types/arc-28.ts:42](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L42)
[types/arc-28.ts:41](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L41)

___

Expand All @@ -46,7 +46,7 @@ The named arguments extracted from the event that was emitted (where the argumen

#### Defined in

[types/arc-28.ts:44](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L44)
[types/arc-28.ts:43](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L43)

___

Expand All @@ -62,7 +62,7 @@ The ARC-28 definition of the event

#### Defined in

[types/arc-28.ts:36](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L36)
[types/arc-28.ts:35](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L35)

___

Expand All @@ -78,7 +78,7 @@ The name of the ARC-28 event that was triggered

#### Defined in

[types/arc-28.ts:30](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L30)
[types/arc-28.ts:29](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L29)

___

Expand All @@ -94,7 +94,7 @@ The 4-byte hex prefix for the event

#### Defined in

[types/arc-28.ts:34](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L34)
[types/arc-28.ts:33](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L33)

___

Expand All @@ -110,7 +110,7 @@ The signature of the event e.g. `EventName(type1,type2)`

#### Defined in

[types/arc-28.ts:32](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L32)
[types/arc-28.ts:31](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L31)

___

Expand All @@ -126,4 +126,4 @@ The name of the ARC-28 event group the event belongs to

#### Defined in

[types/arc-28.ts:28](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L28)
[types/arc-28.ts:27](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L27)
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The set of filters to subscribe to / emit events for, along with optional data m

#### Defined in

[types/subscription.ts:227](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L227)
[types/subscription.ts:225](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L225)

___

Expand All @@ -67,7 +67,7 @@ The frequency to poll for new blocks in seconds; defaults to 1s

#### Defined in

[types/subscription.ts:229](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L229)
[types/subscription.ts:227](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L227)

___

Expand Down Expand Up @@ -155,7 +155,7 @@ Whether to wait via algod `/status/wait-for-block-after` endpoint when at the ti

#### Defined in

[types/subscription.ts:231](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L231)
[types/subscription.ts:229](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L229)

___

Expand All @@ -175,4 +175,4 @@ its position in the chain

#### Defined in

[types/subscription.ts:234](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L234)
[types/subscription.ts:232](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L232)
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Note: if you provide multiple filters with the same name then only the mapper of

#### Defined in

[types/subscription.ts:250](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L250)
[types/subscription.ts:248](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L248)

___

Expand Down
Loading

0 comments on commit bdb54b7

Please sign in to comment.