Skip to content

Commit

Permalink
Merge pull request #26 from sodazone/optional-basic-flattener
Browse files Browse the repository at this point in the history
feat: support basic flattening (non-correlating)
  • Loading branch information
mfornos committed Jul 29, 2024
2 parents a6090e1 + f345c22 commit ea70dc0
Show file tree
Hide file tree
Showing 25 changed files with 972 additions and 867 deletions.
6 changes: 3 additions & 3 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
"watch-transfer-events": "./dist/watch-transfer-events/main.cjs"
},
"dependencies": {
"@polkadot/rpc-provider": "^12.2.1",
"@polkadot/rpc-provider": "^12.2.2",
"@sodazone/ocelloids-sdk": "1.2.12-dev.0",
"@substrate/connect": "^1.0.7",
"@substrate/connect": "^1.1.0",
"graph-data-structure": "^3.5.0",
"hjson": "^3.2.2",
"rxjs": "^7.8.1",
"yargs": "^17.7.2"
},
"devDependencies": {
"tsup": "^8.1.0",
"tsup": "^8.2.3",
"tsx": "^4.16.2"
},
"tsup": {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"Xueying Wang <xueying@soda.zone>"
],
"bugs": "https://github.com/sodazone/ocelloids-sdk/issues",
"description": "Software development kit for building monitoring applications for Substrate networks.",
"description": "Software development kit for Polkadot and Substrate based networks.",
"engines": {
"node": ">=18.14"
},
Expand Down Expand Up @@ -54,15 +54,15 @@
"@babel/preset-env": "^7.24.8",
"@babel/preset-typescript": "^7.24.7",
"@biomejs/biome": "1.8.3",
"@swc/core": "^1.6.13",
"@swc/core": "^1.7.2",
"@swc/jest": "^0.2.36",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.10",
"@types/node": "^20.14.12",
"esbuild": "^0.23.0",
"jest": "^29.7.0",
"tsup": "^8.1.0",
"typedoc": "^0.26.4",
"typescript": "^5.5.3"
"tsup": "^8.2.3",
"typedoc": "^0.26.5",
"typescript": "^5.5.4"
},
"overrides": {
"word-wrap": "1.2.4"
Expand Down
8 changes: 5 additions & 3 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ You can also explore a practical example of how custom methods and types are reg

## Nested Calls Flattener

The Flattener, a specialized helper class, recursively extracts all nested calls from a given extrinsic. It assigns the subset of events in that extrinsic corresponding to each call and maps any execution errors to the extracted calls. This is particularly useful when dealing with extrinsics containing nested batch, multisig, or proxy calls.
The `CorrelatedFlattener`, a specialized helper class, recursively extracts all nested calls from a given extrinsic. It assigns the subset of events within that extrinsic to each call and maps any execution errors to the extracted calls. This is particularly useful when dealing with extrinsics that contain nested batch, multisig, or proxy calls.

The Flattener is utilized within the `flattenCalls` operator and is also exported for external use, such as in an observer handler:
A `BasicFlattener` is also provided to skip event correlation while still extracting nested calls.

The flatteners are used within the `flattenCalls` operator and are also exported for external use, such as in an observer handler:

```javascript
// Flatten and log extrinsic 8695536-2 on Rococo ([Subscan link](https://rococo.subscan.io/extrinsic/8695536-2))
Expand All @@ -112,7 +114,7 @@ apis.rx.polkadot.pipe(
filter(tx => tx.extrinsic.extrinsicId === '8695536-2') // Filter for only the `forceBatch` extrinsic
).subscribe(tx => {
// Initialise flattener and flatten nested calls
const flattener = new Flattener(tx);
const flattener = new CorrelatedFlattener(tx);
flattener.flatten();
const calls = flattener.flattenedCalls;
calls.forEach(c => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"url": "https://github.com/sodazone/ocelloids-sdk.git"
},
"dependencies": {
"@polkadot/api": "^12.2.1",
"@substrate/connect-known-chains": "^1.1.9",
"@polkadot/api": "^12.2.2",
"@substrate/connect-known-chains": "^1.2.0",
"mingo": "^6.4.15",
"rxjs": "^7.8.1",
"web-worker": "1.3.0"
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/client/known-chains.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* istanbul ignore file */

import { WellKnownChain } from '@substrate/connect'

async function chainSpecOf(conf: Promise<{ chainSpec: string }>) {
Expand Down
Loading

0 comments on commit ea70dc0

Please sign in to comment.