@apibara/indexer 0.1.2 → 0.2.1
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.d.ts +2 -2
- package/dist/config.test-d.d.ts +1 -0
- package/dist/config.test-d.js +38 -0
- package/dist/config.test-d.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/sink/console.d.ts +1 -1
- package/dist/sink/console.test-d.d.ts +1 -0
- package/dist/sink/console.test-d.js +12 -0
- package/dist/sink/console.test-d.js.map +1 -0
- package/dist/sink/mongo.d.ts +3 -1
- package/dist/sink/parquet.d.ts +1 -1
- package/dist/sink/postgres.d.ts +1 -1
- package/dist/sink/webhook.d.ts +1 -1
- package/dist/starknet/block.d.ts +144 -37
- package/dist/starknet/block.test-d.d.ts +1 -0
- package/dist/starknet/block.test-d.js +95 -0
- package/dist/starknet/block.test-d.js.map +1 -0
- package/dist/starknet/felt.d.ts +3 -0
- package/dist/starknet/felt.js +12 -0
- package/dist/starknet/felt.js.map +1 -0
- package/dist/starknet/felt.test.d.ts +1 -0
- package/dist/starknet/felt.test.js +14 -0
- package/dist/starknet/felt.test.js.map +1 -0
- package/dist/starknet/filter.d.ts +171 -1
- package/dist/starknet/filter.test-d.d.ts +1 -0
- package/dist/starknet/filter.test-d.js +166 -0
- package/dist/starknet/filter.test-d.js.map +1 -0
- package/dist/starknet/index.d.ts +4 -4
- package/dist/starknet/index.js +2 -2
- package/dist/starknet/index.js.map +1 -1
- package/package.json +13 -2
- package/src/config.test-d.ts +55 -0
- package/src/config.ts +20 -13
- package/src/index.ts +1 -1
- package/src/sink/console.test-d.ts +14 -0
- package/src/sink/console.ts +2 -2
- package/src/sink/mongo.ts +5 -3
- package/src/sink/parquet.ts +3 -3
- package/src/sink/postgres.ts +3 -3
- package/src/sink/webhook.ts +3 -4
- package/src/starknet/block.test-d.ts +112 -0
- package/src/starknet/block.ts +182 -64
- package/src/starknet/felt.test.ts +19 -0
- package/src/starknet/felt.ts +16 -0
- package/src/starknet/filter.test-d.ts +197 -0
- package/src/starknet/filter.ts +200 -1
- package/src/starknet/index.ts +5 -5
package/dist/config.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare type NetworkOptions = {
|
|
|
13
13
|
filter: object;
|
|
14
14
|
};
|
|
15
15
|
/** Data finality. */
|
|
16
|
-
export declare type Finality =
|
|
16
|
+
export declare type Finality = "DATA_STATUS_FINALIZED" | "DATA_STATUS_ACCEPTED" | "DATA_STATUS_PENDING";
|
|
17
17
|
/** Stream-related options. */
|
|
18
18
|
export declare type StreamOptions = {
|
|
19
19
|
/** The Apibara DNA stream url, e.g. `mainnet.starknet.a5a.ch`. */
|
|
@@ -25,7 +25,7 @@ export declare type StreamOptions = {
|
|
|
25
25
|
/** The Apibara DNA stream auth token. */
|
|
26
26
|
authToken?: string;
|
|
27
27
|
};
|
|
28
|
-
export declare type Config<TNetworkOptions extends NetworkOptions, TSink extends SinkOptions> = TSink & TNetworkOptions & StreamOptions & {
|
|
28
|
+
export declare type Config<TNetworkOptions extends NetworkOptions = NetworkOptions, TSink extends SinkOptions = SinkOptions> = TSink & TNetworkOptions & StreamOptions & {
|
|
29
29
|
/** How many historical blocks to process in a single batch. */
|
|
30
30
|
batchSize?: number;
|
|
31
31
|
/** Finality of the data to process. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { assertType, describe, test } from "vitest";
|
|
2
|
+
describe("Config", () => {
|
|
3
|
+
test("without any network or sink type", () => {
|
|
4
|
+
assertType({
|
|
5
|
+
network: "test-network",
|
|
6
|
+
filter: {},
|
|
7
|
+
sinkType: "test-sink",
|
|
8
|
+
sinkOptions: {},
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
test("with restrictions on network and sink", () => {
|
|
12
|
+
assertType({
|
|
13
|
+
network: "test-network",
|
|
14
|
+
filter: {
|
|
15
|
+
a: 1,
|
|
16
|
+
},
|
|
17
|
+
sinkType: "test-sink",
|
|
18
|
+
sinkOptions: {
|
|
19
|
+
b: "test",
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
test("network options are required", () => {
|
|
24
|
+
// @ts-expect-error - missing network options
|
|
25
|
+
assertType({
|
|
26
|
+
sinkType: "test-sink",
|
|
27
|
+
sinkOptions: {},
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
test("sink options are required", () => {
|
|
31
|
+
// @ts-expect-error - missing sink options
|
|
32
|
+
assertType({
|
|
33
|
+
network: "test-network",
|
|
34
|
+
filter: {},
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=config.test-d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.test-d.js","sourceRoot":"","sources":["../src/config.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAIpD,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC5C,UAAU,CAAS;YACjB,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE,EAAE;SAChB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAajD,UAAU,CAAwB;YAChC,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE;gBACN,CAAC,EAAE,CAAC;aACL;YACD,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE;gBACX,CAAC,EAAE,MAAM;aACV;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACxC,6CAA6C;QAC7C,UAAU,CAAS;YACjB,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE,EAAE;SAChB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACrC,0CAA0C;QAC1C,UAAU,CAAS;YACjB,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./config";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./config";
|
|
2
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":"AAAA,cAAc,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/dist/sink/console.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { assertType, describe, test } from "vitest";
|
|
2
|
+
describe("Console", () => {
|
|
3
|
+
test("accepts any option", () => {
|
|
4
|
+
assertType({
|
|
5
|
+
sinkType: "console",
|
|
6
|
+
sinkOptions: {
|
|
7
|
+
hello: "world",
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=console.test-d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.test-d.js","sourceRoot":"","sources":["../../src/sink/console.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAIpD,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC9B,UAAU,CAAU;YAClB,QAAQ,EAAE,SAAS;YACnB,WAAW,EAAE;gBACX,KAAK,EAAE,OAAO;aACf;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/sink/mongo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** MongoDB sink options */
|
|
2
2
|
export declare type Mongo = {
|
|
3
|
-
sinkType:
|
|
3
|
+
sinkType: "mongo";
|
|
4
4
|
sinkOptions: {
|
|
5
5
|
/** MongoDB connection string. */
|
|
6
6
|
connectionString?: string;
|
|
@@ -8,5 +8,7 @@ export declare type Mongo = {
|
|
|
8
8
|
database?: string;
|
|
9
9
|
/** Target collection name. */
|
|
10
10
|
collectionName?: string;
|
|
11
|
+
/** Enable entity mode. */
|
|
12
|
+
entityMode?: boolean;
|
|
11
13
|
};
|
|
12
14
|
};
|
package/dist/sink/parquet.d.ts
CHANGED
package/dist/sink/postgres.d.ts
CHANGED
package/dist/sink/webhook.d.ts
CHANGED
package/dist/starknet/block.d.ts
CHANGED
|
@@ -1,145 +1,252 @@
|
|
|
1
|
-
|
|
1
|
+
import { FieldElement } from "./felt";
|
|
2
2
|
export declare type Block = {
|
|
3
|
+
/** Block header. */
|
|
3
4
|
header?: BlockHeader;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/** Transactions. */
|
|
6
|
+
transactions?: TransactionWithReceipt[];
|
|
7
|
+
/** Events. */
|
|
8
|
+
events?: EventWithTransaction[];
|
|
9
|
+
/** Messages from L2 to L1. */
|
|
10
|
+
l2ToL1Messages?: L2ToL1MessageWithTransaction[];
|
|
11
|
+
/** State update. */
|
|
12
|
+
stateUpdate?: StateUpdate;
|
|
8
13
|
};
|
|
9
14
|
export declare type BlockHeader = {
|
|
15
|
+
/** Block hash. */
|
|
10
16
|
blockHash: FieldElement;
|
|
17
|
+
/** Parent block hash. */
|
|
11
18
|
parentBlockHash: FieldElement;
|
|
19
|
+
/** Block number. */
|
|
12
20
|
blockNumber: string;
|
|
21
|
+
/** Sequencer address. */
|
|
13
22
|
sequencerAddress: FieldElement;
|
|
23
|
+
/** New state root. */
|
|
14
24
|
newRoot: FieldElement;
|
|
25
|
+
/** Block production timestamp. */
|
|
15
26
|
timestamp: string;
|
|
16
27
|
};
|
|
17
28
|
export declare type TransactionWithReceipt = {
|
|
29
|
+
/** Transaction. */
|
|
18
30
|
transaction: Transaction;
|
|
31
|
+
/** Transaction receipt. */
|
|
19
32
|
receipt: TransactionReceipt;
|
|
20
33
|
};
|
|
21
34
|
export declare type EventWithTransaction = {
|
|
35
|
+
/** Transaction. */
|
|
22
36
|
transaction: Transaction;
|
|
37
|
+
/** Transaction receipt. */
|
|
23
38
|
receipt: TransactionReceipt;
|
|
39
|
+
/** Event. */
|
|
24
40
|
event: Event;
|
|
25
41
|
};
|
|
26
42
|
export declare type L2ToL1MessageWithTransaction = {
|
|
43
|
+
/** Transaction. */
|
|
27
44
|
transaction: Transaction;
|
|
45
|
+
/** Message from L2 to L1. */
|
|
28
46
|
message: L2ToL1Message;
|
|
29
47
|
};
|
|
30
|
-
export declare type Transaction =
|
|
48
|
+
export declare type Transaction = TransactionCommon & (InvokeTransactionV0 | InvokeTransactionV1 | DeployTransaction | DeclareTransaction | DeployAccountTransaction | L1HandlerTransaction);
|
|
49
|
+
export declare type TransactionCommon = {
|
|
31
50
|
meta: TransactionMeta;
|
|
32
|
-
} & TransactionBody;
|
|
33
|
-
export declare type TransactionBody = {
|
|
34
|
-
invokeV0: InvokeTransactionV0;
|
|
35
|
-
} | {
|
|
36
|
-
invokeV1: InvokeTransactionV1;
|
|
37
|
-
} | {
|
|
38
|
-
deploy: DeployTransaction;
|
|
39
|
-
} | {
|
|
40
|
-
declare: DeclareTransaction;
|
|
41
|
-
} | {
|
|
42
|
-
deployAccount: DeployAccountTransaction;
|
|
43
|
-
} | {
|
|
44
|
-
l1Handler: L1HandlerTransaction;
|
|
45
51
|
};
|
|
46
52
|
export declare type TransactionMeta = {
|
|
53
|
+
/** Transaction hash. */
|
|
47
54
|
hash: FieldElement;
|
|
55
|
+
/** Maximum fee. */
|
|
48
56
|
maxFee: FieldElement;
|
|
57
|
+
/** Signature. */
|
|
49
58
|
signature: FieldElement[];
|
|
59
|
+
/** Nonce. */
|
|
50
60
|
nonce: FieldElement;
|
|
61
|
+
/** Transaction version. */
|
|
51
62
|
version: string;
|
|
52
63
|
};
|
|
53
64
|
export declare type InvokeTransactionV0 = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
invokeV0?: {
|
|
66
|
+
/** Target contract address. */
|
|
67
|
+
contractAddress: FieldElement;
|
|
68
|
+
/** Selector of the function being invoked. */
|
|
69
|
+
entryPointSelector: FieldElement;
|
|
70
|
+
/** Calldata. */
|
|
71
|
+
calldata: FieldElement[];
|
|
72
|
+
};
|
|
73
|
+
invokeV1?: never;
|
|
74
|
+
deploy?: never;
|
|
75
|
+
declare?: never;
|
|
76
|
+
l1Handler?: never;
|
|
77
|
+
deployAccount?: never;
|
|
57
78
|
};
|
|
58
79
|
export declare type InvokeTransactionV1 = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
80
|
+
invokeV1?: {
|
|
81
|
+
/** Address of the account sending the transaction. */
|
|
82
|
+
senderAddress: FieldElement;
|
|
83
|
+
/** Calldata. */
|
|
84
|
+
calldata: FieldElement[];
|
|
85
|
+
};
|
|
86
|
+
invokeV0?: never;
|
|
87
|
+
deploy?: never;
|
|
88
|
+
declare?: never;
|
|
89
|
+
l1Handler?: never;
|
|
90
|
+
deployAccount?: never;
|
|
62
91
|
};
|
|
63
92
|
export declare type DeployTransaction = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
deploy?: {
|
|
94
|
+
/** Constructor calldata. */
|
|
95
|
+
constructorCalldata: FieldElement[];
|
|
96
|
+
/** Salt used when computing the contract's address. */
|
|
97
|
+
contractAddressSalt: FieldElement;
|
|
98
|
+
/** Hash of the class being deployed. */
|
|
99
|
+
classHash: FieldElement;
|
|
100
|
+
};
|
|
101
|
+
invokeV0?: never;
|
|
102
|
+
invokeV1?: never;
|
|
103
|
+
declare?: never;
|
|
104
|
+
l1Handler?: never;
|
|
105
|
+
deployAccount?: never;
|
|
67
106
|
};
|
|
68
107
|
export declare type DeclareTransaction = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
108
|
+
declare?: {
|
|
109
|
+
/** Class hash. */
|
|
110
|
+
classHash: FieldElement;
|
|
111
|
+
/** Address of the account sending the transaction. */
|
|
112
|
+
senderAddress: FieldElement;
|
|
113
|
+
/** Hash of the cairo assembly resulting from the sierra compilation. */
|
|
114
|
+
compiledClassHash: FieldElement;
|
|
115
|
+
};
|
|
116
|
+
invokeV0?: never;
|
|
117
|
+
invokeV1?: never;
|
|
118
|
+
deploy?: never;
|
|
119
|
+
l1Handler?: never;
|
|
120
|
+
deployAccount?: never;
|
|
72
121
|
};
|
|
73
122
|
export declare type DeployAccountTransaction = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
123
|
+
deployAccount?: {
|
|
124
|
+
/** Constructor calldata. */
|
|
125
|
+
constructorCalldata: FieldElement[];
|
|
126
|
+
/** Salt used when computing the contract's address. */
|
|
127
|
+
contractAddressSalt: FieldElement;
|
|
128
|
+
/** Hash of the class being deployed. */
|
|
129
|
+
classHash: FieldElement;
|
|
130
|
+
};
|
|
131
|
+
invokeV0?: never;
|
|
132
|
+
invokeV1?: never;
|
|
133
|
+
deploy?: never;
|
|
134
|
+
declare?: never;
|
|
135
|
+
l1Handler?: never;
|
|
77
136
|
};
|
|
78
137
|
export declare type L1HandlerTransaction = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
138
|
+
l1Handler?: {
|
|
139
|
+
/** Target contract address. */
|
|
140
|
+
contractAddress: FieldElement;
|
|
141
|
+
/** Selector of the function being invoked. */
|
|
142
|
+
entryPointSelector: FieldElement;
|
|
143
|
+
/** Calldata. */
|
|
144
|
+
calldata: FieldElement[];
|
|
145
|
+
};
|
|
146
|
+
invokeV0?: never;
|
|
147
|
+
invokeV1?: never;
|
|
148
|
+
deploy?: never;
|
|
149
|
+
declare?: never;
|
|
150
|
+
deployAccount?: never;
|
|
82
151
|
};
|
|
83
152
|
export declare type TransactionReceipt = {
|
|
153
|
+
/** Transaction status. */
|
|
84
154
|
executionStatus: ExecutionStatus;
|
|
155
|
+
/** Transaction hash. */
|
|
85
156
|
transactionHash: FieldElement;
|
|
157
|
+
/** Transaction index. */
|
|
86
158
|
transactionIndex: string;
|
|
159
|
+
/** Actual fee paid by the account. */
|
|
87
160
|
actualFee: FieldElement;
|
|
161
|
+
/** Address of the contract created by the transaction. */
|
|
88
162
|
contractAddress: FieldElement;
|
|
163
|
+
/** Messages from L2 to L1. */
|
|
89
164
|
l2ToL1Messages: L2ToL1Message[];
|
|
165
|
+
/** Events. */
|
|
90
166
|
events: Event[];
|
|
167
|
+
/** Revert reason. */
|
|
91
168
|
revertReason?: string;
|
|
92
169
|
};
|
|
93
170
|
export declare type ExecutionStatus = "EXECUTION_STATUS_UNSPECIFIED" | "EXECUTION_STATUS_SUCCEEDED" | "EXECUTION_STATUS_REVERTED";
|
|
94
171
|
export declare type Event = {
|
|
172
|
+
/** Event index. */
|
|
95
173
|
index: number;
|
|
174
|
+
/** Contract address. */
|
|
96
175
|
fromAddress: FieldElement;
|
|
176
|
+
/** Event selector. */
|
|
97
177
|
keys: FieldElement[];
|
|
178
|
+
/** Event data. */
|
|
98
179
|
data: FieldElement[];
|
|
99
180
|
};
|
|
100
181
|
export declare type L2ToL1Message = {
|
|
182
|
+
/** Message index. */
|
|
101
183
|
index: number;
|
|
184
|
+
/** L2 sender address. */
|
|
102
185
|
fromAddress: FieldElement;
|
|
186
|
+
/** L1 target address. */
|
|
103
187
|
toAddress: FieldElement;
|
|
188
|
+
/** Calldata. */
|
|
104
189
|
payload: FieldElement[];
|
|
105
190
|
};
|
|
106
191
|
export declare type StateUpdate = {
|
|
192
|
+
/** New state root. */
|
|
107
193
|
newRoot: FieldElement;
|
|
194
|
+
/** Old state root. */
|
|
108
195
|
oldRoot: FieldElement;
|
|
196
|
+
/** State diff. */
|
|
109
197
|
stateDiff: StateDiff;
|
|
110
198
|
};
|
|
111
199
|
export declare type StateDiff = {
|
|
200
|
+
/** Changes in storage. */
|
|
112
201
|
storageDiffs: StorageDiff[];
|
|
202
|
+
/** Declared contracts. */
|
|
113
203
|
declaredContracts: DeclaredContract[];
|
|
204
|
+
/** Deployed contracts. */
|
|
114
205
|
deployedContracts: DeployedContract[];
|
|
206
|
+
/** Nonce updates. */
|
|
115
207
|
nonces: NonceUpdate[];
|
|
208
|
+
/** Classes declared. */
|
|
116
209
|
declaredClasses: DeclaredClass[];
|
|
210
|
+
/** Classes replaced. */
|
|
117
211
|
replacedClasses: ReplacedClass[];
|
|
118
212
|
};
|
|
119
213
|
export declare type StorageDiff = {
|
|
214
|
+
/** Contract address. */
|
|
120
215
|
contractAddress: FieldElement;
|
|
216
|
+
/** Changes in storage. */
|
|
121
217
|
storageEntries: StorageEntry[];
|
|
122
218
|
};
|
|
123
219
|
export declare type StorageEntry = {
|
|
220
|
+
/** Storage key. */
|
|
124
221
|
key: FieldElement;
|
|
222
|
+
/** New storage value. */
|
|
125
223
|
value: FieldElement;
|
|
126
224
|
};
|
|
127
225
|
export declare type DeclaredContract = {
|
|
226
|
+
/** Class hash. */
|
|
128
227
|
classHash: FieldElement;
|
|
129
228
|
};
|
|
130
229
|
export declare type DeclaredClass = {
|
|
230
|
+
/** Class hash. */
|
|
131
231
|
classHash: FieldElement;
|
|
232
|
+
/** Compiled class hash. */
|
|
132
233
|
compiledClassHash: FieldElement;
|
|
133
234
|
};
|
|
134
235
|
export declare type ReplacedClass = {
|
|
236
|
+
/** Contract address. */
|
|
135
237
|
contractAddress: FieldElement;
|
|
238
|
+
/** Class hash. */
|
|
136
239
|
classHash: FieldElement;
|
|
137
240
|
};
|
|
138
241
|
export declare type DeployedContract = {
|
|
242
|
+
/** Contract address. */
|
|
139
243
|
contractAddress: FieldElement;
|
|
244
|
+
/** Class hash. */
|
|
140
245
|
classHash: FieldElement;
|
|
141
246
|
};
|
|
142
247
|
export declare type NonceUpdate = {
|
|
248
|
+
/** Contract address. */
|
|
143
249
|
contractAddress: FieldElement;
|
|
250
|
+
/** New nonce. */
|
|
144
251
|
nonce: FieldElement;
|
|
145
252
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { assertType, describe, test } from "vitest";
|
|
2
|
+
import { FieldElement } from "./felt";
|
|
3
|
+
const address = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
|
|
4
|
+
const entryPointSelector = "0x03943907ef0ef6f9d2e2408b05e520a66daaf74293dbf665e5a20b117676170e";
|
|
5
|
+
const calldata = [FieldElement.parse("0x01"), FieldElement.parse("0x02")];
|
|
6
|
+
const meta = {
|
|
7
|
+
hash: FieldElement.parse("0x01"),
|
|
8
|
+
maxFee: FieldElement.parse("0x02"),
|
|
9
|
+
signature: [FieldElement.parse("0x03")],
|
|
10
|
+
nonce: FieldElement.parse("0x04"),
|
|
11
|
+
version: "0",
|
|
12
|
+
};
|
|
13
|
+
const invokeV0 = {
|
|
14
|
+
contractAddress: FieldElement.parse(address),
|
|
15
|
+
entryPointSelector: FieldElement.parse(entryPointSelector),
|
|
16
|
+
calldata,
|
|
17
|
+
};
|
|
18
|
+
const invokeV1 = {
|
|
19
|
+
senderAddress: FieldElement.parse(address),
|
|
20
|
+
calldata,
|
|
21
|
+
};
|
|
22
|
+
const deploy = {
|
|
23
|
+
constructorCalldata: calldata,
|
|
24
|
+
contractAddressSalt: FieldElement.parse("0x01"),
|
|
25
|
+
classHash: FieldElement.parse("0x02"),
|
|
26
|
+
};
|
|
27
|
+
const declare = {
|
|
28
|
+
classHash: FieldElement.parse("0x01"),
|
|
29
|
+
senderAddress: FieldElement.parse(address),
|
|
30
|
+
compiledClassHash: FieldElement.parse("0x02"),
|
|
31
|
+
};
|
|
32
|
+
describe("Block", () => {
|
|
33
|
+
test("all optional", () => {
|
|
34
|
+
assertType({});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe("BlockHeader", () => {
|
|
38
|
+
test("all fields", () => {
|
|
39
|
+
assertType({
|
|
40
|
+
blockHash: FieldElement.parse("0x01"),
|
|
41
|
+
parentBlockHash: FieldElement.parse("0x00"),
|
|
42
|
+
blockNumber: "1",
|
|
43
|
+
sequencerAddress: FieldElement.parse(address),
|
|
44
|
+
newRoot: FieldElement.parse("0x02"),
|
|
45
|
+
timestamp: "1",
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe("Transaction", () => {
|
|
50
|
+
test("only one type", () => {
|
|
51
|
+
// @ts-expect-error - should be one of the types
|
|
52
|
+
assertType({
|
|
53
|
+
meta,
|
|
54
|
+
invokeV0,
|
|
55
|
+
invokeV1,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
test("invokeV0", () => {
|
|
59
|
+
assertType({
|
|
60
|
+
meta,
|
|
61
|
+
invokeV0,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
test("invokeV1", () => {
|
|
65
|
+
assertType({
|
|
66
|
+
meta,
|
|
67
|
+
invokeV1,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
test("deploy", () => {
|
|
71
|
+
assertType({
|
|
72
|
+
meta,
|
|
73
|
+
deploy,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
test("declare", () => {
|
|
77
|
+
assertType({
|
|
78
|
+
meta,
|
|
79
|
+
declare,
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
test("l1Handler", () => {
|
|
83
|
+
assertType({
|
|
84
|
+
meta,
|
|
85
|
+
l1Handler: invokeV0,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
test("deployAccount", () => {
|
|
89
|
+
assertType({
|
|
90
|
+
meta,
|
|
91
|
+
deployAccount: deploy,
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=block.test-d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.test-d.js","sourceRoot":"","sources":["../../src/starknet/block.test-d.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const FieldElement = z.string().transform((value, ctx) => {
|
|
3
|
+
const regex = /^0x[0-9a-fA-F]{1,64}$/;
|
|
4
|
+
if (!regex.test(value)) {
|
|
5
|
+
ctx.addIssue({
|
|
6
|
+
code: z.ZodIssueCode.custom,
|
|
7
|
+
message: `FieldElement must be a hex string with a 0x prefix, got ${value}`,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=felt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"felt.js","sourceRoot":"","sources":["../../src/starknet/felt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC9D,MAAM,KAAK,GAAG,uBAAuB,CAAC;IAEtC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACtB,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;YAC3B,OAAO,EAAE,2DAA2D,KAAK,EAAE;SAC5E,CAAC,CAAC;KACJ;IAED,OAAO,KAAqB,CAAC;AAC/B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { FieldElement } from "./felt";
|
|
3
|
+
describe("FieldElement", () => {
|
|
4
|
+
test("parse address", () => {
|
|
5
|
+
FieldElement.parse("0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7");
|
|
6
|
+
});
|
|
7
|
+
test("parse value", () => {
|
|
8
|
+
FieldElement.parse("0x1");
|
|
9
|
+
});
|
|
10
|
+
test("parse invalid value", () => {
|
|
11
|
+
expect(() => FieldElement.parse("0x")).toThrowError();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=felt.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"felt.test.js","sourceRoot":"","sources":["../../src/starknet/felt.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QACzB,YAAY,CAAC,KAAK,CAChB,oEAAoE,CACrE,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;QACvB,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC/B,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|