@apibara/starknet 2.1.0-beta.17 → 2.1.0-beta.19
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/index.cjs +1221 -232
- package/dist/index.d.cts +2014 -1456
- package/dist/index.d.mts +2014 -1456
- package/dist/index.d.ts +2014 -1456
- package/dist/index.mjs +1213 -233
- package/package.json +2 -2
- package/src/block.ts +158 -0
- package/src/filter.ts +6 -0
- package/src/proto/data.ts +1081 -1
- package/src/proto/filter.ts +76 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/starknet",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"vitest": "^1.6.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@apibara/protocol": "2.1.0-beta.
|
|
45
|
+
"@apibara/protocol": "2.1.0-beta.19",
|
|
46
46
|
"@effect/schema": "^0.67.15",
|
|
47
47
|
"@scure/starknet": "^1.1.0",
|
|
48
48
|
"abi-wan-kanabi": "^2.2.4",
|
package/src/block.ts
CHANGED
|
@@ -634,6 +634,162 @@ export const NonceUpdate = Schema.Struct({
|
|
|
634
634
|
|
|
635
635
|
export type NonceUpdate = typeof NonceUpdate.Type;
|
|
636
636
|
|
|
637
|
+
/** Trace call type. */
|
|
638
|
+
export const CallType = Schema.transform(
|
|
639
|
+
Schema.Enums(proto.data.CallType),
|
|
640
|
+
Schema.Literal("libraryCall", "call", "delegate", "unknown"),
|
|
641
|
+
{
|
|
642
|
+
decode(value) {
|
|
643
|
+
const enumMap = {
|
|
644
|
+
[proto.data.CallType.LIBRARY_CALL]: "libraryCall",
|
|
645
|
+
[proto.data.CallType.CALL]: "call",
|
|
646
|
+
[proto.data.CallType.DELEGATE]: "delegate",
|
|
647
|
+
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
648
|
+
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
649
|
+
} as const;
|
|
650
|
+
|
|
651
|
+
return enumMap[value] ?? "unknown";
|
|
652
|
+
},
|
|
653
|
+
encode(value) {
|
|
654
|
+
throw new Error("encode: not implemented");
|
|
655
|
+
},
|
|
656
|
+
},
|
|
657
|
+
);
|
|
658
|
+
|
|
659
|
+
/** A function invocation.
|
|
660
|
+
*
|
|
661
|
+
* @prop contractAddress The contract address.
|
|
662
|
+
* @prop entryPointSelector The entry point selector.
|
|
663
|
+
* @prop calldata The calldata.
|
|
664
|
+
* @prop callerAddress The caller address.
|
|
665
|
+
* @prop classHash The class hash.
|
|
666
|
+
* @prop callType The call type.
|
|
667
|
+
* @prop result The function invocation result.
|
|
668
|
+
* @prop calls The nested function invocations.
|
|
669
|
+
* @prop events The events index in the current transaction.
|
|
670
|
+
* @prop messages The messages index in the current transaction.
|
|
671
|
+
*/
|
|
672
|
+
export class FunctionInvocation extends Schema.Class<FunctionInvocation>(
|
|
673
|
+
"FunctionInvocation",
|
|
674
|
+
)({
|
|
675
|
+
contractAddress: FieldElement,
|
|
676
|
+
entryPointSelector: FieldElement,
|
|
677
|
+
calldata: Schema.Array(FieldElement),
|
|
678
|
+
callerAddress: FieldElement,
|
|
679
|
+
classHash: FieldElement,
|
|
680
|
+
callType: CallType,
|
|
681
|
+
result: Schema.Array(FieldElement),
|
|
682
|
+
calls: Schema.suspend(
|
|
683
|
+
// biome-ignore lint/suspicious/noExplicitAny: not possible otherwise
|
|
684
|
+
(): Schema.Schema<any> => Schema.Array(FunctionInvocation),
|
|
685
|
+
),
|
|
686
|
+
events: Schema.Array(Schema.Number),
|
|
687
|
+
messages: Schema.Array(Schema.Number),
|
|
688
|
+
}) {}
|
|
689
|
+
|
|
690
|
+
/** A successful invocation of the __execute__ call.
|
|
691
|
+
*
|
|
692
|
+
* @prop success The call.
|
|
693
|
+
*/
|
|
694
|
+
export const ExecuteInvocationSuccess = Schema.Struct({
|
|
695
|
+
_tag: tag("success"),
|
|
696
|
+
success: FunctionInvocation,
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
/** A failed invocation of the __execute__ call.
|
|
700
|
+
*
|
|
701
|
+
* @prop reason The reason for the failure.
|
|
702
|
+
*/
|
|
703
|
+
export const ExecuteInvocationReverted = Schema.Struct({
|
|
704
|
+
_tag: tag("reverted"),
|
|
705
|
+
reverted: Schema.Struct({
|
|
706
|
+
reason: Schema.optional(Schema.String),
|
|
707
|
+
}),
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
/** Trace for invoke transactions.
|
|
711
|
+
*
|
|
712
|
+
* @prop validateInvocation The __validate__ call.
|
|
713
|
+
* @prop executeInvocation The __execute__ call.
|
|
714
|
+
* @prop feeTransferInvocation The __fee_transfer__ call.
|
|
715
|
+
*/
|
|
716
|
+
export const InvokeTransactionTrace = Schema.Struct({
|
|
717
|
+
_tag: tag("invoke"),
|
|
718
|
+
invoke: Schema.Struct({
|
|
719
|
+
validateInvocation: Schema.optional(FunctionInvocation),
|
|
720
|
+
executeInvocation: Schema.Union(
|
|
721
|
+
ExecuteInvocationReverted,
|
|
722
|
+
ExecuteInvocationSuccess,
|
|
723
|
+
),
|
|
724
|
+
feeTransferInvocation: Schema.optional(FunctionInvocation),
|
|
725
|
+
}),
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
export type InvokeTransactionTrace = typeof InvokeTransactionTrace.Type;
|
|
729
|
+
|
|
730
|
+
/** Trace for declare transactions.
|
|
731
|
+
*
|
|
732
|
+
* @prop validateInvocation The __validate__ call.
|
|
733
|
+
* @prop feeTransferInvocation The __fee_transfer__ call.
|
|
734
|
+
*/
|
|
735
|
+
export const DeclareTransactionTrace = Schema.Struct({
|
|
736
|
+
_tag: tag("declare"),
|
|
737
|
+
declare: Schema.Struct({
|
|
738
|
+
validateInvocation: Schema.optional(FunctionInvocation),
|
|
739
|
+
feeTransferInvocation: Schema.optional(FunctionInvocation),
|
|
740
|
+
}),
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
export type DeclareTransactionTrace = typeof DeclareTransactionTrace.Type;
|
|
744
|
+
|
|
745
|
+
/** Trace for deploy account transactions.
|
|
746
|
+
*
|
|
747
|
+
* @prop validateInvocation The __validate__ call.
|
|
748
|
+
* @prop constructorInvocation The __constructor__ call.
|
|
749
|
+
* @prop feeTransferInvocation The __fee_transfer__ call.
|
|
750
|
+
*/
|
|
751
|
+
export const DeployAccountTransactionTrace = Schema.Struct({
|
|
752
|
+
_tag: tag("deployAccount"),
|
|
753
|
+
deployAccount: Schema.Struct({
|
|
754
|
+
validateInvocation: Schema.optional(FunctionInvocation),
|
|
755
|
+
constructorInvocation: Schema.optional(FunctionInvocation),
|
|
756
|
+
feeTransferInvocation: Schema.optional(FunctionInvocation),
|
|
757
|
+
}),
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
export type DeployAccountTransactionTrace =
|
|
761
|
+
typeof DeployAccountTransactionTrace.Type;
|
|
762
|
+
|
|
763
|
+
/** Trace for L1 handler transactions.
|
|
764
|
+
*
|
|
765
|
+
* @prop functionInvocation The L1 handler function invocation.
|
|
766
|
+
*/
|
|
767
|
+
export const L1HandlerTransactionTrace = Schema.Struct({
|
|
768
|
+
_tag: tag("l1Handler"),
|
|
769
|
+
l1Handler: Schema.Struct({
|
|
770
|
+
functionInvocation: Schema.optional(FunctionInvocation),
|
|
771
|
+
}),
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
/** A transaction trace.
|
|
775
|
+
*
|
|
776
|
+
* @prop transactionHash The hash of the trace's transaction.
|
|
777
|
+
* @prp traceRoot the trace root entry.
|
|
778
|
+
*/
|
|
779
|
+
export const TransactionTrace = Schema.Struct({
|
|
780
|
+
filterIds: Schema.Array(Schema.Number),
|
|
781
|
+
transactionIndex: Schema.Number,
|
|
782
|
+
transactionHash: FieldElement,
|
|
783
|
+
traceRoot: Schema.Union(
|
|
784
|
+
InvokeTransactionTrace,
|
|
785
|
+
DeclareTransactionTrace,
|
|
786
|
+
DeployAccountTransactionTrace,
|
|
787
|
+
L1HandlerTransactionTrace,
|
|
788
|
+
),
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
export type TransactionTrace = typeof TransactionTrace.Type;
|
|
792
|
+
|
|
637
793
|
/** A block.
|
|
638
794
|
*
|
|
639
795
|
* @prop header The block header.
|
|
@@ -641,6 +797,7 @@ export type NonceUpdate = typeof NonceUpdate.Type;
|
|
|
641
797
|
* @prop receipts The receipts of the transactions.
|
|
642
798
|
* @prop events The events emitted by the transactions.
|
|
643
799
|
* @prop messages The messages sent to L1 by the transactions.
|
|
800
|
+
* @prop traces The transaction traces.
|
|
644
801
|
* @prop storageDiffs The changes to the storage.
|
|
645
802
|
* @prop contractChanges The changes to contracts and classes.
|
|
646
803
|
*/
|
|
@@ -650,6 +807,7 @@ export const Block = Schema.Struct({
|
|
|
650
807
|
receipts: Schema.Array(TransactionReceipt),
|
|
651
808
|
events: Schema.Array(Event),
|
|
652
809
|
messages: Schema.Array(MessageToL1),
|
|
810
|
+
traces: Schema.Array(TransactionTrace),
|
|
653
811
|
storageDiffs: Schema.Array(StorageDiff),
|
|
654
812
|
contractChanges: Schema.Array(ContractChange),
|
|
655
813
|
nonceUpdates: Schema.Array(NonceUpdate),
|
package/src/filter.ts
CHANGED
|
@@ -106,6 +106,7 @@ export type TransactionStatusFilter = typeof TransactionStatusFilter.Type;
|
|
|
106
106
|
* @prop includeReceipt Include the transaction receipt.
|
|
107
107
|
* @prop includeMessages Include the messages that were sent to L1 in the same transaction.
|
|
108
108
|
* @prop includeSiblings Include the sibling events of the matched events.
|
|
109
|
+
* @prop includeTransactionTrace Include the trace of the transaction that emitted the event.
|
|
109
110
|
*/
|
|
110
111
|
export const EventFilter = Schema.Struct({
|
|
111
112
|
id: Schema.optional(Schema.Number),
|
|
@@ -117,6 +118,7 @@ export const EventFilter = Schema.Struct({
|
|
|
117
118
|
includeReceipt: Schema.optional(Schema.Boolean),
|
|
118
119
|
includeMessages: Schema.optional(Schema.Boolean),
|
|
119
120
|
includeSiblings: Schema.optional(Schema.Boolean),
|
|
121
|
+
includeTransactionTrace: Schema.optional(Schema.Boolean),
|
|
120
122
|
});
|
|
121
123
|
|
|
122
124
|
export type EventFilter = typeof EventFilter.Type;
|
|
@@ -129,6 +131,7 @@ export type EventFilter = typeof EventFilter.Type;
|
|
|
129
131
|
* @prop includeTransaction Include the transaction that sent the message.
|
|
130
132
|
* @prop includeReceipt Include the transaction receipt.
|
|
131
133
|
* @prop includeEvents Include events from the same transaction.
|
|
134
|
+
* @prop includeTransactionTrace Include the trace of the transaction that sent the message.
|
|
132
135
|
*/
|
|
133
136
|
export const MessageToL1Filter = Schema.Struct({
|
|
134
137
|
id: Schema.optional(Schema.Number),
|
|
@@ -138,6 +141,7 @@ export const MessageToL1Filter = Schema.Struct({
|
|
|
138
141
|
includeTransaction: Schema.optional(Schema.Boolean),
|
|
139
142
|
includeReceipt: Schema.optional(Schema.Boolean),
|
|
140
143
|
includeEvents: Schema.optional(Schema.Boolean),
|
|
144
|
+
includeTransactionTrace: Schema.optional(Schema.Boolean),
|
|
141
145
|
});
|
|
142
146
|
|
|
143
147
|
export type MessageToL1Filter = typeof MessageToL1Filter.Type;
|
|
@@ -227,6 +231,7 @@ export type DeployAccountV3TransactionFilter =
|
|
|
227
231
|
* @prop includeReceipt Include the transaction receipt.
|
|
228
232
|
* @prop includeEvents Include events from the same transaction.
|
|
229
233
|
* @prop includeMessages Include messages sent in the transaction.
|
|
234
|
+
* @prop includeTrace Include the transaction's trace.
|
|
230
235
|
*/
|
|
231
236
|
export const TransactionFilter = Schema.Struct({
|
|
232
237
|
id: Schema.optional(Schema.Number),
|
|
@@ -234,6 +239,7 @@ export const TransactionFilter = Schema.Struct({
|
|
|
234
239
|
includeReceipt: Schema.optional(Schema.Boolean),
|
|
235
240
|
includeMessages: Schema.optional(Schema.Boolean),
|
|
236
241
|
includeEvents: Schema.optional(Schema.Boolean),
|
|
242
|
+
includeTrace: Schema.optional(Schema.Boolean),
|
|
237
243
|
transactionType: Schema.optional(
|
|
238
244
|
Schema.Union(
|
|
239
245
|
InvokeTransactionV0Filter,
|