@apibara/indexer 0.1.0 → 0.1.2
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/dist/config.js +1 -2
- package/dist/index.js +1 -17
- package/dist/index.js.map +1 -1
- package/dist/sink/console.js +1 -2
- package/dist/sink/mongo.js +1 -2
- package/dist/sink/parquet.js +1 -2
- package/dist/sink/postgres.js +1 -2
- package/dist/sink/webhook.js +1 -2
- package/dist/starknet/block.js +1 -2
- package/dist/starknet/filter.js +1 -2
- package/dist/starknet/index.js +2 -18
- package/dist/starknet/index.js.map +1 -1
- package/package.json +40 -9
- package/src/config.ts +40 -0
- package/src/index.ts +1 -0
- package/src/sink/console.ts +11 -0
- package/src/sink/mongo.ts +12 -0
- package/src/sink/parquet.ts +9 -0
- package/src/sink/postgres.ts +10 -0
- package/src/sink/webhook.ts +13 -0
- package/src/starknet/block.ts +172 -0
- package/src/starknet/filter.ts +2 -0
- package/src/starknet/index.ts +10 -0
package/dist/config.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
__exportStar(require("./config"), exports);
|
|
1
|
+
export * from './config';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
package/dist/sink/console.js
CHANGED
package/dist/sink/mongo.js
CHANGED
package/dist/sink/parquet.js
CHANGED
package/dist/sink/postgres.js
CHANGED
package/dist/sink/webhook.js
CHANGED
package/dist/starknet/block.js
CHANGED
package/dist/starknet/filter.js
CHANGED
package/dist/starknet/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
__exportStar(require("./filter"), exports);
|
|
18
|
-
__exportStar(require("./block"), exports);
|
|
1
|
+
export * from './filter';
|
|
2
|
+
export * from './block';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/starknet/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/starknet/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/indexer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"exports": {
|
|
5
|
-
".":
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"./sink/
|
|
11
|
-
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./sink/console": {
|
|
12
|
+
"types": "./dist/sink/console.d.ts",
|
|
13
|
+
"import": "./dist/sink/console.js",
|
|
14
|
+
"default": "./dist/sink/console.js"
|
|
15
|
+
},
|
|
16
|
+
"./sink/mongo": {
|
|
17
|
+
"types": "./dist/sink/mongo.d.ts",
|
|
18
|
+
"import": "./dist/sink/mongo.js",
|
|
19
|
+
"default": "./dist/sink/mongo.js"
|
|
20
|
+
},
|
|
21
|
+
"./sink/parquet": {
|
|
22
|
+
"types": "./dist/sink/parquet.d.ts",
|
|
23
|
+
"import": "./dist/sink/parquet.js",
|
|
24
|
+
"default": "./dist/sink/parquet.js"
|
|
25
|
+
},
|
|
26
|
+
"./sink/postgres": {
|
|
27
|
+
"types": "./dist/sink/postgres.d.ts",
|
|
28
|
+
"import": "./dist/sink/postgres.js",
|
|
29
|
+
"default": "./dist/sink/postgres.js"
|
|
30
|
+
},
|
|
31
|
+
"./sink/webhook": {
|
|
32
|
+
"types": "./dist/sink/webhook.d.ts",
|
|
33
|
+
"import": "./dist/sink/webhook.js",
|
|
34
|
+
"default": "./dist/sink/webhook.js"
|
|
35
|
+
},
|
|
36
|
+
"./starknet": {
|
|
37
|
+
"types": "./dist/starknet/index.d.ts",
|
|
38
|
+
"import": "./dist/starknet/index.js",
|
|
39
|
+
"default": "./dist/starknet/index.js"
|
|
40
|
+
}
|
|
12
41
|
},
|
|
13
42
|
"files": [
|
|
14
|
-
"dist"
|
|
43
|
+
"dist",
|
|
44
|
+
"src",
|
|
45
|
+
"README.md"
|
|
15
46
|
],
|
|
16
47
|
"scripts": {
|
|
17
48
|
"build": "tsc"
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Sink-related options. */
|
|
2
|
+
export type SinkOptions = {
|
|
3
|
+
/** Sink type. */
|
|
4
|
+
sinkType: string;
|
|
5
|
+
/** Sink options. */
|
|
6
|
+
sinkOptions: object;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Network-specific options. */
|
|
10
|
+
export type NetworkOptions = {
|
|
11
|
+
/** Network name. */
|
|
12
|
+
network: string;
|
|
13
|
+
/** Data filter. */
|
|
14
|
+
filter: object;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Data finality. */
|
|
18
|
+
export type Finality = 'DATA_STATUS_FINALIZED' | 'DATA_STATUS_ACCEPTED' | 'DATA_STATUS_PENDING';
|
|
19
|
+
|
|
20
|
+
/** Stream-related options. */
|
|
21
|
+
export type StreamOptions = {
|
|
22
|
+
/** The Apibara DNA stream url, e.g. `mainnet.starknet.a5a.ch`. */
|
|
23
|
+
streamUrl?: string;
|
|
24
|
+
/** Maximum message size, e.g. `50Mb` */
|
|
25
|
+
maxMessageSize?: string;
|
|
26
|
+
/** Additional metadata to send when connecting to the stream, in `key: value` form. */
|
|
27
|
+
metadata?: string[];
|
|
28
|
+
/** The Apibara DNA stream auth token. */
|
|
29
|
+
authToken?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type Config<TNetworkOptions extends NetworkOptions, TSink extends SinkOptions> = TSink & TNetworkOptions & StreamOptions & {
|
|
33
|
+
/** How many historical blocks to process in a single batch. */
|
|
34
|
+
batchSize?: number;
|
|
35
|
+
/** Finality of the data to process. */
|
|
36
|
+
finality?: Finality;
|
|
37
|
+
/** Start streaming data from this block. */
|
|
38
|
+
startingBlock?: number;
|
|
39
|
+
}
|
|
40
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Console sink type. */
|
|
2
|
+
export type Console = {
|
|
3
|
+
sinkType: 'console';
|
|
4
|
+
|
|
5
|
+
/** Accept any options.
|
|
6
|
+
*
|
|
7
|
+
* @remarks We do this so that users can quickly switch to the console sink to debug,
|
|
8
|
+
* without having to remove the options from the config file.
|
|
9
|
+
*/
|
|
10
|
+
sinkOptions: object;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** MongoDB sink options */
|
|
2
|
+
export type Mongo = {
|
|
3
|
+
sinkType: 'mongo';
|
|
4
|
+
sinkOptions: {
|
|
5
|
+
/** MongoDB connection string. */
|
|
6
|
+
connectionString?: string;
|
|
7
|
+
/** Target database name. */
|
|
8
|
+
database?: string;
|
|
9
|
+
/** Target collection name. */
|
|
10
|
+
collectionName?: string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Webhook sink options */
|
|
2
|
+
export type Webhook = {
|
|
3
|
+
sinkType: 'webhook';
|
|
4
|
+
sinkOptions: {
|
|
5
|
+
/** Target URL. */
|
|
6
|
+
targetUrl?: string;
|
|
7
|
+
/** Additional headers to send with the request, `key: value` format. */
|
|
8
|
+
header?: string[];
|
|
9
|
+
/** Send the data returned from the transform function as the request body. */
|
|
10
|
+
raw?: boolean;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
export type FieldElement = `0x${string}`
|
|
2
|
+
|
|
3
|
+
export type Block = {
|
|
4
|
+
header?: BlockHeader;
|
|
5
|
+
transactions: TransactionWithReceipt[];
|
|
6
|
+
events: EventWithTransaction[];
|
|
7
|
+
l2ToL1Messages: L2ToL1MessageWithTransaction[];
|
|
8
|
+
stateUpdate: StateUpdate;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type BlockHeader = {
|
|
12
|
+
blockHash: FieldElement;
|
|
13
|
+
parentBlockHash: FieldElement;
|
|
14
|
+
blockNumber: string;
|
|
15
|
+
sequencerAddress: FieldElement;
|
|
16
|
+
newRoot: FieldElement;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type TransactionWithReceipt = {
|
|
21
|
+
transaction: Transaction;
|
|
22
|
+
receipt: TransactionReceipt;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type EventWithTransaction = {
|
|
26
|
+
transaction: Transaction;
|
|
27
|
+
receipt: TransactionReceipt;
|
|
28
|
+
event: Event;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type L2ToL1MessageWithTransaction = {
|
|
32
|
+
transaction: Transaction;
|
|
33
|
+
message: L2ToL1Message;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type Transaction = {
|
|
37
|
+
meta: TransactionMeta;
|
|
38
|
+
} & TransactionBody
|
|
39
|
+
|
|
40
|
+
export type TransactionBody = {
|
|
41
|
+
invokeV0: InvokeTransactionV0
|
|
42
|
+
} | {
|
|
43
|
+
invokeV1: InvokeTransactionV1
|
|
44
|
+
} | {
|
|
45
|
+
deploy: DeployTransaction
|
|
46
|
+
} | {
|
|
47
|
+
declare: DeclareTransaction
|
|
48
|
+
} | {
|
|
49
|
+
deployAccount: DeployAccountTransaction
|
|
50
|
+
} | {
|
|
51
|
+
l1Handler: L1HandlerTransaction
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type TransactionMeta = {
|
|
55
|
+
hash: FieldElement;
|
|
56
|
+
maxFee: FieldElement;
|
|
57
|
+
signature: FieldElement[];
|
|
58
|
+
nonce: FieldElement;
|
|
59
|
+
version: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type InvokeTransactionV0 = {
|
|
63
|
+
contractAddress: FieldElement;
|
|
64
|
+
entryPointSelector: FieldElement;
|
|
65
|
+
calldata: FieldElement[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type InvokeTransactionV1 = {
|
|
69
|
+
contractAddress: FieldElement;
|
|
70
|
+
entryPointSelector: FieldElement;
|
|
71
|
+
calldata: FieldElement[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type DeployTransaction = {
|
|
75
|
+
constructorCalldata: FieldElement[];
|
|
76
|
+
contractAddressSalt: FieldElement;
|
|
77
|
+
classHash: FieldElement;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type DeclareTransaction = {
|
|
81
|
+
classHash: FieldElement;
|
|
82
|
+
senderAddress: FieldElement;
|
|
83
|
+
compiledClassHash: FieldElement;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type DeployAccountTransaction = {
|
|
87
|
+
constructorCalldata: FieldElement[];
|
|
88
|
+
contractAddressSalt: FieldElement;
|
|
89
|
+
classHash: FieldElement;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type L1HandlerTransaction = {
|
|
93
|
+
contractAddress: FieldElement;
|
|
94
|
+
entryPointSelector: FieldElement;
|
|
95
|
+
calldata: FieldElement[];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type TransactionReceipt = {
|
|
99
|
+
executionStatus: ExecutionStatus;
|
|
100
|
+
transactionHash: FieldElement;
|
|
101
|
+
transactionIndex: string;
|
|
102
|
+
actualFee: FieldElement;
|
|
103
|
+
contractAddress: FieldElement;
|
|
104
|
+
l2ToL1Messages: L2ToL1Message[];
|
|
105
|
+
events: Event[];
|
|
106
|
+
revertReason?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type ExecutionStatus = "EXECUTION_STATUS_UNSPECIFIED" | "EXECUTION_STATUS_SUCCEEDED" | "EXECUTION_STATUS_REVERTED"
|
|
110
|
+
|
|
111
|
+
export type Event = {
|
|
112
|
+
index: number;
|
|
113
|
+
fromAddress: FieldElement;
|
|
114
|
+
keys: FieldElement[];
|
|
115
|
+
data: FieldElement[];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type L2ToL1Message = {
|
|
119
|
+
index: number;
|
|
120
|
+
fromAddress: FieldElement;
|
|
121
|
+
toAddress: FieldElement;
|
|
122
|
+
payload: FieldElement[];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type StateUpdate = {
|
|
126
|
+
newRoot: FieldElement;
|
|
127
|
+
oldRoot: FieldElement;
|
|
128
|
+
stateDiff: StateDiff;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type StateDiff = {
|
|
132
|
+
storageDiffs: StorageDiff[];
|
|
133
|
+
declaredContracts: DeclaredContract[];
|
|
134
|
+
deployedContracts: DeployedContract[];
|
|
135
|
+
nonces: NonceUpdate[];
|
|
136
|
+
declaredClasses: DeclaredClass[];
|
|
137
|
+
replacedClasses: ReplacedClass[];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type StorageDiff = {
|
|
141
|
+
contractAddress: FieldElement;
|
|
142
|
+
storageEntries: StorageEntry[];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type StorageEntry = {
|
|
146
|
+
key: FieldElement;
|
|
147
|
+
value: FieldElement;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type DeclaredContract = {
|
|
151
|
+
classHash: FieldElement;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type DeclaredClass = {
|
|
155
|
+
classHash: FieldElement;
|
|
156
|
+
compiledClassHash: FieldElement;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type ReplacedClass = {
|
|
160
|
+
contractAddress: FieldElement;
|
|
161
|
+
classHash: FieldElement;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type DeployedContract = {
|
|
165
|
+
contractAddress: FieldElement;
|
|
166
|
+
classHash: FieldElement;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type NonceUpdate = {
|
|
170
|
+
contractAddress: FieldElement;
|
|
171
|
+
nonce: FieldElement;
|
|
172
|
+
}
|