@subsquid/evm-objects 0.0.2-portal-api.a8e10e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -0
- package/lib/augment.d.ts +4 -0
- package/lib/augment.d.ts.map +1 -0
- package/lib/augment.js +11 -0
- package/lib/augment.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +23 -0
- package/lib/index.js.map +1 -0
- package/lib/items.d.ts +125 -0
- package/lib/items.d.ts.map +1 -0
- package/lib/items.js +301 -0
- package/lib/items.js.map +1 -0
- package/lib/relations.d.ts +3 -0
- package/lib/relations.d.ts.map +1 -0
- package/lib/relations.js +70 -0
- package/lib/relations.js.map +1 -0
- package/lib/types.d.ts +68 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/util.d.ts +8 -0
- package/lib/util.d.ts.map +1 -0
- package/lib/util.js +22 -0
- package/lib/util.js.map +1 -0
- package/package.json +29 -0
- package/src/augment.ts +11 -0
- package/src/index.ts +3 -0
- package/src/items.ts +400 -0
- package/src/relations.ts +74 -0
- package/src/types.ts +91 -0
- package/src/util.ts +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @subsquid/evm-objects
|
|
2
|
+
|
|
3
|
+
Augmented EVM data model for use with `@subsquid/evm-stream`.
|
|
4
|
+
|
|
5
|
+
This package provides enhanced EVM data structures with proper relationships between blocks, transactions, logs, traces, and state diffs. It follows the same pattern as `@subsquid/solana-objects` but adapted for EVM chains.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Rich object model**: Classes with methods and relationships instead of plain objects
|
|
10
|
+
- **Automatic ID generation**: Unique IDs for all entities
|
|
11
|
+
- **Relationship setup**: Automatic linking between transactions, logs, traces, and state diffs
|
|
12
|
+
- **Type-safe**: Full TypeScript support with field selection
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @subsquid/evm-objects @subsquid/evm-stream
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import {augmentBlock} from '@subsquid/evm-objects'
|
|
24
|
+
import {run} from '@subsquid/evm-stream'
|
|
25
|
+
|
|
26
|
+
run({
|
|
27
|
+
// ... stream configuration
|
|
28
|
+
}, async (streamBlocks) => {
|
|
29
|
+
for (let block of streamBlocks) {
|
|
30
|
+
// Augment the block with relationships
|
|
31
|
+
let augmented = augmentBlock(block)
|
|
32
|
+
|
|
33
|
+
// Access transactions with their logs
|
|
34
|
+
for (let tx of augmented.transactions) {
|
|
35
|
+
console.log(`Transaction ${tx.id} has ${tx.logs.length} logs`)
|
|
36
|
+
|
|
37
|
+
// Access logs
|
|
38
|
+
for (let log of tx.logs) {
|
|
39
|
+
console.log(`Log ${log.id} belongs to tx ${log.getTransaction().id}`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Access traces with parent-child relationships
|
|
43
|
+
for (let trace of tx.traces) {
|
|
44
|
+
console.log(`Trace ${trace.id} has ${trace.children.length} children`)
|
|
45
|
+
if (trace.parent) {
|
|
46
|
+
console.log(`Parent trace: ${trace.parent.id}`)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
### `augmentBlock<F>(block: Block<F>): Block<F>`
|
|
57
|
+
|
|
58
|
+
Augments a block from `@subsquid/evm-stream` with:
|
|
59
|
+
- Unique IDs for all entities
|
|
60
|
+
- Bidirectional relationships between entities
|
|
61
|
+
- Helper methods like `getTransaction()`, `getParent()`
|
|
62
|
+
- Sorted collections
|
|
63
|
+
|
|
64
|
+
### Enhanced Types
|
|
65
|
+
|
|
66
|
+
All types from `@subsquid/evm-stream` are enhanced with:
|
|
67
|
+
|
|
68
|
+
- **BlockHeader**: Adds `id` field
|
|
69
|
+
- **Transaction**: Adds `id`, `block` reference, and arrays for `logs`, `traces`, `stateDiffs`
|
|
70
|
+
- **Log**: Adds `id`, `block` reference, `transaction` reference, and `getTransaction()` method
|
|
71
|
+
- **Trace**: Adds `id`, `block` reference, `transaction` reference, `parent`/`children` references, and helper methods
|
|
72
|
+
- **StateDiff**: Adds `block` reference, `transaction` reference, and `getTransaction()` method
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
GPL-3.0-or-later
|
package/lib/augment.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augment.d.ts","sourceRoot":"","sources":["../src/augment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAA;AAE5C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAIhC,wBAAgB,YAAY,CAAC,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAI9F"}
|
package/lib/augment.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.augmentBlock = augmentBlock;
|
|
4
|
+
const relations_1 = require("./relations");
|
|
5
|
+
const items_1 = require("./items");
|
|
6
|
+
function augmentBlock(src) {
|
|
7
|
+
let block = items_1.Block.fromPartial(src);
|
|
8
|
+
(0, relations_1.setUpRelations)(block);
|
|
9
|
+
return block;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=augment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augment.js","sourceRoot":"","sources":["../src/augment.ts"],"names":[],"mappings":";;AAMA,oCAIC;AATD,2CAA0C;AAE1C,mCAA6B;AAG7B,SAAgB,YAAY,CAAgC,GAAkB;IAC1E,IAAI,KAAK,GAAG,aAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAClC,IAAA,0BAAc,EAAC,KAAK,CAAC,CAAA;IACrB,OAAO,KAAkC,CAAA;AAC7C,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,QAAQ,CAAA"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.shortHash = exports.formatId = void 0;
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./augment"), exports);
|
|
20
|
+
var util_1 = require("./util");
|
|
21
|
+
Object.defineProperty(exports, "formatId", { enumerable: true, get: function () { return util_1.formatId; } });
|
|
22
|
+
Object.defineProperty(exports, "shortHash", { enumerable: true, get: function () { return util_1.shortHash; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,4CAAyB;AACzB,+BAA0C;AAAlC,gGAAA,QAAQ,OAAA;AAAE,iGAAA,SAAS,OAAA"}
|
package/lib/items.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Bytes, Bytes20, Bytes32 } from '@subsquid/evm-stream';
|
|
2
|
+
import { PartialBlock, PartialBlockHeader, PartialLog, PartialStateDiff, PartialTrace, PartialTransaction } from '@subsquid/evm-stream/lib/data/partial';
|
|
3
|
+
import { EvmTraceCallAction, EvmTraceCallResult, EvmTraceCreateAction, EvmTraceCreateResult, EvmTraceRewardAction, EvmTraceSuicideAction } from '@subsquid/evm-stream/lib/data/evm';
|
|
4
|
+
export declare class Block {
|
|
5
|
+
header: BlockHeader;
|
|
6
|
+
transactions: Transaction[];
|
|
7
|
+
logs: Log[];
|
|
8
|
+
traces: Trace[];
|
|
9
|
+
stateDiffs: StateDiff[];
|
|
10
|
+
constructor(header: BlockHeader, transactions: Transaction[], logs: Log[], traces: Trace[], stateDiffs: StateDiff[]);
|
|
11
|
+
static fromPartial(src: PartialBlock): Block;
|
|
12
|
+
}
|
|
13
|
+
export declare class BlockHeader implements PartialBlockHeader {
|
|
14
|
+
id: string;
|
|
15
|
+
number: number;
|
|
16
|
+
height: number;
|
|
17
|
+
hash: Bytes32;
|
|
18
|
+
parentHash: Bytes32;
|
|
19
|
+
constructor(header: PartialBlockHeader);
|
|
20
|
+
}
|
|
21
|
+
export declare class Transaction implements PartialTransaction {
|
|
22
|
+
#private;
|
|
23
|
+
id: string;
|
|
24
|
+
transactionIndex: number;
|
|
25
|
+
constructor(block: BlockHeader, tx: PartialTransaction);
|
|
26
|
+
get block(): BlockHeader;
|
|
27
|
+
set block(value: BlockHeader);
|
|
28
|
+
get logs(): Log[];
|
|
29
|
+
set logs(value: Log[]);
|
|
30
|
+
get traces(): Trace[];
|
|
31
|
+
set traces(value: Trace[]);
|
|
32
|
+
get stateDiffs(): StateDiff[];
|
|
33
|
+
set stateDiffs(value: StateDiff[]);
|
|
34
|
+
}
|
|
35
|
+
export declare class Log implements PartialLog {
|
|
36
|
+
#private;
|
|
37
|
+
id: string;
|
|
38
|
+
logIndex: number;
|
|
39
|
+
transactionIndex: number;
|
|
40
|
+
constructor(block: BlockHeader, log: PartialLog);
|
|
41
|
+
get block(): BlockHeader;
|
|
42
|
+
set block(value: BlockHeader);
|
|
43
|
+
get transaction(): Transaction | undefined;
|
|
44
|
+
set transaction(value: Transaction | undefined);
|
|
45
|
+
getTransaction(): Transaction;
|
|
46
|
+
}
|
|
47
|
+
declare class TraceBase {
|
|
48
|
+
#private;
|
|
49
|
+
id: string;
|
|
50
|
+
transactionIndex: number;
|
|
51
|
+
traceAddress: number[];
|
|
52
|
+
constructor(block: BlockHeader, trace: PartialTrace);
|
|
53
|
+
get block(): BlockHeader;
|
|
54
|
+
set block(value: BlockHeader);
|
|
55
|
+
get transaction(): Transaction | undefined;
|
|
56
|
+
set transaction(value: Transaction | undefined);
|
|
57
|
+
getTransaction(): Transaction;
|
|
58
|
+
get parent(): Trace | undefined;
|
|
59
|
+
set parent(value: Trace | undefined);
|
|
60
|
+
getParent(): Trace;
|
|
61
|
+
get children(): Trace[];
|
|
62
|
+
set children(value: Trace[]);
|
|
63
|
+
}
|
|
64
|
+
export declare class TraceCreate extends TraceBase {
|
|
65
|
+
type: 'create';
|
|
66
|
+
action?: Partial<EvmTraceCreateAction>;
|
|
67
|
+
result?: Partial<EvmTraceCreateResult>;
|
|
68
|
+
constructor(block: BlockHeader, trace: PartialTrace);
|
|
69
|
+
}
|
|
70
|
+
export declare class TraceCall extends TraceBase {
|
|
71
|
+
type: 'call';
|
|
72
|
+
action?: Partial<EvmTraceCallAction>;
|
|
73
|
+
result?: Partial<EvmTraceCallResult>;
|
|
74
|
+
constructor(block: BlockHeader, trace: PartialTrace);
|
|
75
|
+
}
|
|
76
|
+
export declare class TraceSuicide extends TraceBase {
|
|
77
|
+
type: 'suicide';
|
|
78
|
+
action?: Partial<EvmTraceSuicideAction>;
|
|
79
|
+
constructor(block: BlockHeader, trace: PartialTrace);
|
|
80
|
+
}
|
|
81
|
+
export declare class TraceReward extends TraceBase {
|
|
82
|
+
type: 'reward';
|
|
83
|
+
action?: Partial<EvmTraceRewardAction>;
|
|
84
|
+
constructor(block: BlockHeader, trace: PartialTrace);
|
|
85
|
+
}
|
|
86
|
+
export type Trace = TraceCreate | TraceCall | TraceSuicide | TraceReward;
|
|
87
|
+
declare class StateDiffBase {
|
|
88
|
+
#private;
|
|
89
|
+
transactionIndex: number;
|
|
90
|
+
address: Bytes20;
|
|
91
|
+
key: 'balance' | 'code' | 'nonce' | Bytes32;
|
|
92
|
+
constructor(block: BlockHeader, stateDiff: PartialStateDiff);
|
|
93
|
+
get block(): BlockHeader;
|
|
94
|
+
set block(value: BlockHeader);
|
|
95
|
+
get transaction(): Transaction | undefined;
|
|
96
|
+
set transaction(value: Transaction | undefined);
|
|
97
|
+
getTransaction(): Transaction;
|
|
98
|
+
}
|
|
99
|
+
export declare class StateDiffNoChange extends StateDiffBase {
|
|
100
|
+
kind: '=';
|
|
101
|
+
prev?: null;
|
|
102
|
+
next?: null;
|
|
103
|
+
constructor(block: BlockHeader, stateDiff: PartialStateDiff);
|
|
104
|
+
}
|
|
105
|
+
export declare class StateDiffAdd extends StateDiffBase {
|
|
106
|
+
kind: '+';
|
|
107
|
+
prev?: null;
|
|
108
|
+
next?: Bytes;
|
|
109
|
+
constructor(block: BlockHeader, stateDiff: PartialStateDiff);
|
|
110
|
+
}
|
|
111
|
+
export declare class StateDiffChange extends StateDiffBase {
|
|
112
|
+
kind: '*';
|
|
113
|
+
prev?: Bytes;
|
|
114
|
+
next?: Bytes;
|
|
115
|
+
constructor(block: BlockHeader, stateDiff: PartialStateDiff);
|
|
116
|
+
}
|
|
117
|
+
export declare class StateDiffDelete extends StateDiffBase {
|
|
118
|
+
kind: '-';
|
|
119
|
+
prev?: Bytes;
|
|
120
|
+
next?: null;
|
|
121
|
+
constructor(block: BlockHeader, stateDiff: PartialStateDiff);
|
|
122
|
+
}
|
|
123
|
+
export type StateDiff = StateDiffNoChange | StateDiffAdd | StateDiffChange | StateDiffDelete;
|
|
124
|
+
export {};
|
|
125
|
+
//# sourceMappingURL=items.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAS,MAAM,sBAAsB,CAAA;AACpE,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EACrB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAEH,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACxB,MAAM,mCAAmC,CAAA;AAI1C,qBAAa,KAAK;IAEH,MAAM,EAAE,WAAW;IACnB,YAAY,EAAE,WAAW,EAAE;IAC3B,IAAI,EAAE,GAAG,EAAE;IACX,MAAM,EAAE,KAAK,EAAE;IACf,UAAU,EAAE,SAAS,EAAE;gBAJvB,MAAM,EAAE,WAAW,EACnB,YAAY,EAAE,WAAW,EAAE,EAC3B,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,EAAE,KAAK,EAAE,EACf,UAAU,EAAE,SAAS,EAAE;IAGlC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,KAAK;CAW/C;AAGD,qBAAa,WAAY,YAAW,k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AE,GAAG,CAAM;IACf,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,IAAI,CAAA;gBAEC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB;CAI9D;AAGD,MAAM,MAAM,SAAS,GAAG,iBAAiB,GAAG,YAAY,GAAG,eAAe,GAAG,eAAe,CAAA"}
|
package/lib/items.js
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _Transaction_block, _Transaction_logs, _Transaction_traces, _Transaction_stateDiffs, _Log_block, _Log_transaction, _TraceBase_block, _TraceBase_transaction, _TraceBase_parent, _TraceBase_children, _StateDiffBase_block, _StateDiffBase_transaction;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StateDiffDelete = exports.StateDiffChange = exports.StateDiffAdd = exports.StateDiffNoChange = exports.TraceReward = exports.TraceSuicide = exports.TraceCall = exports.TraceCreate = exports.Log = exports.Transaction = exports.BlockHeader = exports.Block = void 0;
|
|
16
|
+
const util_1 = require("./util");
|
|
17
|
+
class Block {
|
|
18
|
+
constructor(header, transactions, logs, traces, stateDiffs) {
|
|
19
|
+
this.header = header;
|
|
20
|
+
this.transactions = transactions;
|
|
21
|
+
this.logs = logs;
|
|
22
|
+
this.traces = traces;
|
|
23
|
+
this.stateDiffs = stateDiffs;
|
|
24
|
+
}
|
|
25
|
+
static fromPartial(src) {
|
|
26
|
+
let header = new BlockHeader(src.header);
|
|
27
|
+
return new Block(header, src.transactions.map(i => new Transaction(header, i)), src.logs.map(i => new Log(header, i)), src.traces.map(i => createTrace(header, i)), src.stateDiffs.map(i => createStateDiff(header, i)));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Block = Block;
|
|
31
|
+
class BlockHeader {
|
|
32
|
+
constructor(header) {
|
|
33
|
+
this.id = (0, util_1.formatId)(header);
|
|
34
|
+
this.number = header.number;
|
|
35
|
+
this.height = header.height;
|
|
36
|
+
this.hash = header.hash;
|
|
37
|
+
this.parentHash = header.parentHash;
|
|
38
|
+
Object.assign(this, header);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.BlockHeader = BlockHeader;
|
|
42
|
+
class Transaction {
|
|
43
|
+
constructor(block, tx) {
|
|
44
|
+
_Transaction_block.set(this, void 0);
|
|
45
|
+
_Transaction_logs.set(this, void 0);
|
|
46
|
+
_Transaction_traces.set(this, void 0);
|
|
47
|
+
_Transaction_stateDiffs.set(this, void 0);
|
|
48
|
+
this.id = (0, util_1.formatId)(block, tx.transactionIndex);
|
|
49
|
+
this.transactionIndex = tx.transactionIndex;
|
|
50
|
+
__classPrivateFieldSet(this, _Transaction_block, block, "f");
|
|
51
|
+
Object.assign(this, tx);
|
|
52
|
+
}
|
|
53
|
+
get block() {
|
|
54
|
+
return __classPrivateFieldGet(this, _Transaction_block, "f");
|
|
55
|
+
}
|
|
56
|
+
set block(value) {
|
|
57
|
+
__classPrivateFieldSet(this, _Transaction_block, value, "f");
|
|
58
|
+
}
|
|
59
|
+
get logs() {
|
|
60
|
+
if (__classPrivateFieldGet(this, _Transaction_logs, "f") == null) {
|
|
61
|
+
__classPrivateFieldSet(this, _Transaction_logs, [], "f");
|
|
62
|
+
}
|
|
63
|
+
return __classPrivateFieldGet(this, _Transaction_logs, "f");
|
|
64
|
+
}
|
|
65
|
+
set logs(value) {
|
|
66
|
+
__classPrivateFieldSet(this, _Transaction_logs, value, "f");
|
|
67
|
+
}
|
|
68
|
+
get traces() {
|
|
69
|
+
if (__classPrivateFieldGet(this, _Transaction_traces, "f") == null) {
|
|
70
|
+
__classPrivateFieldSet(this, _Transaction_traces, [], "f");
|
|
71
|
+
}
|
|
72
|
+
return __classPrivateFieldGet(this, _Transaction_traces, "f");
|
|
73
|
+
}
|
|
74
|
+
set traces(value) {
|
|
75
|
+
__classPrivateFieldSet(this, _Transaction_traces, value, "f");
|
|
76
|
+
}
|
|
77
|
+
get stateDiffs() {
|
|
78
|
+
if (__classPrivateFieldGet(this, _Transaction_stateDiffs, "f") == null) {
|
|
79
|
+
__classPrivateFieldSet(this, _Transaction_stateDiffs, [], "f");
|
|
80
|
+
}
|
|
81
|
+
return __classPrivateFieldGet(this, _Transaction_stateDiffs, "f");
|
|
82
|
+
}
|
|
83
|
+
set stateDiffs(value) {
|
|
84
|
+
__classPrivateFieldSet(this, _Transaction_stateDiffs, value, "f");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.Transaction = Transaction;
|
|
88
|
+
_Transaction_block = new WeakMap(), _Transaction_logs = new WeakMap(), _Transaction_traces = new WeakMap(), _Transaction_stateDiffs = new WeakMap();
|
|
89
|
+
class Log {
|
|
90
|
+
constructor(block, log) {
|
|
91
|
+
_Log_block.set(this, void 0);
|
|
92
|
+
_Log_transaction.set(this, void 0);
|
|
93
|
+
this.id = (0, util_1.formatId)(block, log.logIndex);
|
|
94
|
+
this.logIndex = log.logIndex;
|
|
95
|
+
this.transactionIndex = log.transactionIndex;
|
|
96
|
+
__classPrivateFieldSet(this, _Log_block, block, "f");
|
|
97
|
+
Object.assign(this, log);
|
|
98
|
+
}
|
|
99
|
+
get block() {
|
|
100
|
+
return __classPrivateFieldGet(this, _Log_block, "f");
|
|
101
|
+
}
|
|
102
|
+
set block(value) {
|
|
103
|
+
__classPrivateFieldSet(this, _Log_block, value, "f");
|
|
104
|
+
}
|
|
105
|
+
get transaction() {
|
|
106
|
+
return __classPrivateFieldGet(this, _Log_transaction, "f");
|
|
107
|
+
}
|
|
108
|
+
set transaction(value) {
|
|
109
|
+
__classPrivateFieldSet(this, _Log_transaction, value, "f");
|
|
110
|
+
}
|
|
111
|
+
getTransaction() {
|
|
112
|
+
if (__classPrivateFieldGet(this, _Log_transaction, "f") == null) {
|
|
113
|
+
throw new Error(`Transaction is not set on log ${this.id}`);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
return __classPrivateFieldGet(this, _Log_transaction, "f");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.Log = Log;
|
|
121
|
+
_Log_block = new WeakMap(), _Log_transaction = new WeakMap();
|
|
122
|
+
class TraceBase {
|
|
123
|
+
constructor(block, trace) {
|
|
124
|
+
_TraceBase_block.set(this, void 0);
|
|
125
|
+
_TraceBase_transaction.set(this, void 0);
|
|
126
|
+
_TraceBase_parent.set(this, void 0);
|
|
127
|
+
_TraceBase_children.set(this, void 0);
|
|
128
|
+
this.id = (0, util_1.formatId)(block, trace.transactionIndex, ...trace.traceAddress);
|
|
129
|
+
this.transactionIndex = trace.transactionIndex;
|
|
130
|
+
this.traceAddress = trace.traceAddress;
|
|
131
|
+
__classPrivateFieldSet(this, _TraceBase_block, block, "f");
|
|
132
|
+
}
|
|
133
|
+
get block() {
|
|
134
|
+
return __classPrivateFieldGet(this, _TraceBase_block, "f");
|
|
135
|
+
}
|
|
136
|
+
set block(value) {
|
|
137
|
+
__classPrivateFieldSet(this, _TraceBase_block, value, "f");
|
|
138
|
+
}
|
|
139
|
+
get transaction() {
|
|
140
|
+
return __classPrivateFieldGet(this, _TraceBase_transaction, "f");
|
|
141
|
+
}
|
|
142
|
+
set transaction(value) {
|
|
143
|
+
__classPrivateFieldSet(this, _TraceBase_transaction, value, "f");
|
|
144
|
+
}
|
|
145
|
+
getTransaction() {
|
|
146
|
+
if (__classPrivateFieldGet(this, _TraceBase_transaction, "f") == null) {
|
|
147
|
+
throw new Error(`Transaction is not set on trace ${this.id}`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return __classPrivateFieldGet(this, _TraceBase_transaction, "f");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
get parent() {
|
|
154
|
+
return __classPrivateFieldGet(this, _TraceBase_parent, "f");
|
|
155
|
+
}
|
|
156
|
+
set parent(value) {
|
|
157
|
+
__classPrivateFieldSet(this, _TraceBase_parent, value, "f");
|
|
158
|
+
}
|
|
159
|
+
getParent() {
|
|
160
|
+
if (__classPrivateFieldGet(this, _TraceBase_parent, "f") == null) {
|
|
161
|
+
throw new Error(`Parent is not set on trace ${this.id}`);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return __classPrivateFieldGet(this, _TraceBase_parent, "f");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
get children() {
|
|
168
|
+
if (__classPrivateFieldGet(this, _TraceBase_children, "f") == null) {
|
|
169
|
+
__classPrivateFieldSet(this, _TraceBase_children, [], "f");
|
|
170
|
+
}
|
|
171
|
+
return __classPrivateFieldGet(this, _TraceBase_children, "f");
|
|
172
|
+
}
|
|
173
|
+
set children(value) {
|
|
174
|
+
__classPrivateFieldSet(this, _TraceBase_children, value, "f");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
_TraceBase_block = new WeakMap(), _TraceBase_transaction = new WeakMap(), _TraceBase_parent = new WeakMap(), _TraceBase_children = new WeakMap();
|
|
178
|
+
class TraceCreate extends TraceBase {
|
|
179
|
+
constructor(block, trace) {
|
|
180
|
+
super(block, trace);
|
|
181
|
+
this.type = 'create';
|
|
182
|
+
Object.assign(this, trace);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.TraceCreate = TraceCreate;
|
|
186
|
+
class TraceCall extends TraceBase {
|
|
187
|
+
constructor(block, trace) {
|
|
188
|
+
super(block, trace);
|
|
189
|
+
this.type = 'call';
|
|
190
|
+
Object.assign(this, trace);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.TraceCall = TraceCall;
|
|
194
|
+
class TraceSuicide extends TraceBase {
|
|
195
|
+
constructor(block, trace) {
|
|
196
|
+
super(block, trace);
|
|
197
|
+
this.type = 'suicide';
|
|
198
|
+
Object.assign(this, trace);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.TraceSuicide = TraceSuicide;
|
|
202
|
+
class TraceReward extends TraceBase {
|
|
203
|
+
constructor(block, trace) {
|
|
204
|
+
super(block, trace);
|
|
205
|
+
this.type = 'reward';
|
|
206
|
+
Object.assign(this, trace);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.TraceReward = TraceReward;
|
|
210
|
+
function createTrace(block, trace) {
|
|
211
|
+
switch (trace.type) {
|
|
212
|
+
case 'create':
|
|
213
|
+
return new TraceCreate(block, trace);
|
|
214
|
+
case 'call':
|
|
215
|
+
return new TraceCall(block, trace);
|
|
216
|
+
case 'suicide':
|
|
217
|
+
return new TraceSuicide(block, trace);
|
|
218
|
+
case 'reward':
|
|
219
|
+
return new TraceReward(block, trace);
|
|
220
|
+
default:
|
|
221
|
+
throw new Error(`Unknown trace type`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
class StateDiffBase {
|
|
225
|
+
constructor(block, stateDiff) {
|
|
226
|
+
_StateDiffBase_block.set(this, void 0);
|
|
227
|
+
_StateDiffBase_transaction.set(this, void 0);
|
|
228
|
+
this.transactionIndex = stateDiff.transactionIndex;
|
|
229
|
+
this.address = stateDiff.address;
|
|
230
|
+
this.key = stateDiff.key;
|
|
231
|
+
__classPrivateFieldSet(this, _StateDiffBase_block, block, "f");
|
|
232
|
+
}
|
|
233
|
+
get block() {
|
|
234
|
+
return __classPrivateFieldGet(this, _StateDiffBase_block, "f");
|
|
235
|
+
}
|
|
236
|
+
set block(value) {
|
|
237
|
+
__classPrivateFieldSet(this, _StateDiffBase_block, value, "f");
|
|
238
|
+
}
|
|
239
|
+
get transaction() {
|
|
240
|
+
return __classPrivateFieldGet(this, _StateDiffBase_transaction, "f");
|
|
241
|
+
}
|
|
242
|
+
set transaction(value) {
|
|
243
|
+
__classPrivateFieldSet(this, _StateDiffBase_transaction, value, "f");
|
|
244
|
+
}
|
|
245
|
+
getTransaction() {
|
|
246
|
+
if (__classPrivateFieldGet(this, _StateDiffBase_transaction, "f") == null) {
|
|
247
|
+
throw new Error(`Transaction is not set on state diff at ${this.block.id}-${this.transactionIndex}-${this.address}-${this.key}`);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
return __classPrivateFieldGet(this, _StateDiffBase_transaction, "f");
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
_StateDiffBase_block = new WeakMap(), _StateDiffBase_transaction = new WeakMap();
|
|
255
|
+
class StateDiffNoChange extends StateDiffBase {
|
|
256
|
+
constructor(block, stateDiff) {
|
|
257
|
+
super(block, stateDiff);
|
|
258
|
+
this.kind = '=';
|
|
259
|
+
Object.assign(this, stateDiff);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
exports.StateDiffNoChange = StateDiffNoChange;
|
|
263
|
+
class StateDiffAdd extends StateDiffBase {
|
|
264
|
+
constructor(block, stateDiff) {
|
|
265
|
+
super(block, stateDiff);
|
|
266
|
+
this.kind = '+';
|
|
267
|
+
Object.assign(this, stateDiff);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
exports.StateDiffAdd = StateDiffAdd;
|
|
271
|
+
class StateDiffChange extends StateDiffBase {
|
|
272
|
+
constructor(block, stateDiff) {
|
|
273
|
+
super(block, stateDiff);
|
|
274
|
+
this.kind = '*';
|
|
275
|
+
Object.assign(this, stateDiff);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
exports.StateDiffChange = StateDiffChange;
|
|
279
|
+
class StateDiffDelete extends StateDiffBase {
|
|
280
|
+
constructor(block, stateDiff) {
|
|
281
|
+
super(block, stateDiff);
|
|
282
|
+
this.kind = '-';
|
|
283
|
+
Object.assign(this, stateDiff);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
exports.StateDiffDelete = StateDiffDelete;
|
|
287
|
+
function createStateDiff(block, stateDiff) {
|
|
288
|
+
switch (stateDiff.kind) {
|
|
289
|
+
case '=':
|
|
290
|
+
return new StateDiffNoChange(block, stateDiff);
|
|
291
|
+
case '+':
|
|
292
|
+
return new StateDiffAdd(block, stateDiff);
|
|
293
|
+
case '*':
|
|
294
|
+
return new StateDiffChange(block, stateDiff);
|
|
295
|
+
case '-':
|
|
296
|
+
return new StateDiffDelete(block, stateDiff);
|
|
297
|
+
default:
|
|
298
|
+
throw new Error(`Unknown state diff kind`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=items.js.map
|
package/lib/items.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"items.js","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAkBA,iCAA+B;AAG/B,MAAa,KAAK;IACd,YACW,MAAmB,EACnB,YAA2B,EAC3B,IAAW,EACX,MAAe,EACf,UAAuB;QAJvB,WAAM,GAAN,MAAM,CAAa;QACnB,iBAAY,GAAZ,YAAY,CAAe;QAC3B,SAAI,GAAJ,IAAI,CAAO;QACX,WAAM,GAAN,MAAM,CAAS;QACf,eAAU,GAAV,UAAU,CAAa;IAC/B,CAAC;IAEJ,MAAM,CAAC,WAAW,CAAC,GAAiB;QAChC,IAAI,MAAM,GAAG,IAA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AA;QAChD;YACI,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAClD,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../src/relations.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAqB,MAAM,SAAS,CAAA;AAGjD,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CA6CjD"}
|
package/lib/relations.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setUpRelations = setUpRelations;
|
|
4
|
+
const util_internal_1 = require("@subsquid/util-internal");
|
|
5
|
+
function setUpRelations(block) {
|
|
6
|
+
block.transactions.sort((a, b) => a.transactionIndex - b.transactionIndex);
|
|
7
|
+
block.logs.sort((a, b) => a.logIndex - b.logIndex);
|
|
8
|
+
block.traces.sort(traceCompare);
|
|
9
|
+
let txs = new Array(((0, util_internal_1.maybeLast)(block.transactions)?.transactionIndex ?? -1) + 1);
|
|
10
|
+
for (let tx of block.transactions) {
|
|
11
|
+
txs[tx.transactionIndex] = tx;
|
|
12
|
+
}
|
|
13
|
+
for (let log of block.logs) {
|
|
14
|
+
let tx = txs[log.transactionIndex];
|
|
15
|
+
if (tx) {
|
|
16
|
+
log.transaction = tx;
|
|
17
|
+
tx.logs.push(log);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (let i = 0; i < block.traces.length; i++) {
|
|
21
|
+
let trace = block.traces[i];
|
|
22
|
+
let tx = txs[trace.transactionIndex];
|
|
23
|
+
if (tx) {
|
|
24
|
+
trace.transaction = tx;
|
|
25
|
+
tx.traces.push(trace);
|
|
26
|
+
}
|
|
27
|
+
for (let j = i + 1; j < block.traces.length; j++) {
|
|
28
|
+
let next = block.traces[j];
|
|
29
|
+
if (isDescendent(trace, next)) {
|
|
30
|
+
trace.children.push(next);
|
|
31
|
+
if (next.traceAddress.length == trace.traceAddress.length + 1) {
|
|
32
|
+
next.parent = trace;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (let stateDiff of block.stateDiffs) {
|
|
41
|
+
let tx = txs[stateDiff.transactionIndex];
|
|
42
|
+
if (tx) {
|
|
43
|
+
stateDiff.transaction = tx;
|
|
44
|
+
tx.stateDiffs.push(stateDiff);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function traceCompare(a, b) {
|
|
49
|
+
return a.transactionIndex - b.transactionIndex || addressCompare(a.traceAddress, b.traceAddress);
|
|
50
|
+
}
|
|
51
|
+
function addressCompare(a, b) {
|
|
52
|
+
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
53
|
+
let order = a[i] - b[i];
|
|
54
|
+
if (order)
|
|
55
|
+
return order;
|
|
56
|
+
}
|
|
57
|
+
return a.length - b.length;
|
|
58
|
+
}
|
|
59
|
+
function isDescendent(parent, child) {
|
|
60
|
+
if (parent.transactionIndex != child.transactionIndex)
|
|
61
|
+
return false;
|
|
62
|
+
if (parent.traceAddress.length >= child.traceAddress.length)
|
|
63
|
+
return false;
|
|
64
|
+
for (let i = 0; i < parent.traceAddress.length; i++) {
|
|
65
|
+
if (parent.traceAddress[i] != child.traceAddress[i])
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=relations.js.map
|