@subsquid/portal-client 0.0.0
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 +3 -0
- package/lib/client.d.ts +102 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.example.d.ts +2 -0
- package/lib/client.example.d.ts.map +1 -0
- package/lib/client.example.js +158 -0
- package/lib/client.example.js.map +1 -0
- package/lib/client.js +440 -0
- package/lib/client.js.map +1 -0
- package/lib/query/common.d.ts +47 -0
- package/lib/query/common.d.ts.map +1 -0
- package/lib/query/common.js +3 -0
- package/lib/query/common.js.map +1 -0
- package/lib/query/evm.d.ts +268 -0
- package/lib/query/evm.d.ts.map +1 -0
- package/lib/query/evm.js +3 -0
- package/lib/query/evm.js.map +1 -0
- package/lib/query/index.d.ts +5 -0
- package/lib/query/index.d.ts.map +1 -0
- package/lib/query/index.js +3 -0
- package/lib/query/index.js.map +1 -0
- package/lib/query/solana.d.ts +224 -0
- package/lib/query/solana.d.ts.map +1 -0
- package/lib/query/solana.js +3 -0
- package/lib/query/solana.js.map +1 -0
- package/lib/query/substrate.d.ts +180 -0
- package/lib/query/substrate.d.ts.map +1 -0
- package/lib/query/substrate.js +3 -0
- package/lib/query/substrate.js.map +1 -0
- package/package.json +32 -0
- package/src/client.example.ts +167 -0
- package/src/client.ts +639 -0
- package/src/query/common.ts +59 -0
- package/src/query/evm.ts +367 -0
- package/src/query/index.ts +4 -0
- package/src/query/solana.ts +276 -0
- package/src/query/substrate.ts +194 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type {Select, Selector, Trues, Hex, Simplify, PortalBlock, PortalQuery} from './common'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @example 'Balances.Transfer'
|
|
5
|
+
*/
|
|
6
|
+
export type QualifiedName = string & {}
|
|
7
|
+
|
|
8
|
+
export type BlockHeaderFields = {
|
|
9
|
+
/**
|
|
10
|
+
* Block height
|
|
11
|
+
*/
|
|
12
|
+
number: number
|
|
13
|
+
/**
|
|
14
|
+
* Block hash
|
|
15
|
+
*/
|
|
16
|
+
hash: Hex
|
|
17
|
+
/**
|
|
18
|
+
* Hash of the parent block
|
|
19
|
+
*/
|
|
20
|
+
parentHash: Hex
|
|
21
|
+
/**
|
|
22
|
+
* Root hash of the state merkle tree
|
|
23
|
+
*/
|
|
24
|
+
stateRoot: Hex
|
|
25
|
+
/**
|
|
26
|
+
* Root hash of the extrinsics merkle tree
|
|
27
|
+
*/
|
|
28
|
+
extrinsicsRoot: Hex
|
|
29
|
+
digest: {logs: Hex[]}
|
|
30
|
+
specName: string
|
|
31
|
+
specVersion: number
|
|
32
|
+
implName: string
|
|
33
|
+
implVersion: number
|
|
34
|
+
/**
|
|
35
|
+
* Block timestamp as set by `timestamp.now()` (unix epoch ms, compatible with `Date`).
|
|
36
|
+
*/
|
|
37
|
+
timestamp?: number
|
|
38
|
+
/**
|
|
39
|
+
* Account address of block validator
|
|
40
|
+
*/
|
|
41
|
+
validator?: Hex
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type ExtrinsicSignatureFields = {
|
|
45
|
+
address: unknown
|
|
46
|
+
signature: unknown
|
|
47
|
+
signedExtensions: unknown
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type ExtrinsicFields = {
|
|
51
|
+
/**
|
|
52
|
+
* Ordinal index in the extrinsics array of the current block
|
|
53
|
+
*/
|
|
54
|
+
index: number
|
|
55
|
+
version: number
|
|
56
|
+
signature?: ExtrinsicSignatureFields
|
|
57
|
+
fee?: bigint
|
|
58
|
+
tip?: bigint
|
|
59
|
+
error?: unknown
|
|
60
|
+
success?: boolean
|
|
61
|
+
/**
|
|
62
|
+
* Blake2b 128-bit hash of the raw extrinsic
|
|
63
|
+
*/
|
|
64
|
+
hash?: Hex
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type CallFields = {
|
|
68
|
+
extrinsicIndex: number
|
|
69
|
+
address: number[]
|
|
70
|
+
name: QualifiedName
|
|
71
|
+
args: unknown
|
|
72
|
+
origin?: unknown
|
|
73
|
+
/**
|
|
74
|
+
* Call error.
|
|
75
|
+
*
|
|
76
|
+
* Absence of error doesn't imply that the call was executed successfully,
|
|
77
|
+
* check {@link success} property for that.
|
|
78
|
+
*/
|
|
79
|
+
error?: unknown
|
|
80
|
+
success?: boolean
|
|
81
|
+
_ethereumTransactTo?: Hex
|
|
82
|
+
_ethereumTransactSighash?: Hex
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type EventFields = {
|
|
86
|
+
/**
|
|
87
|
+
* Ordinal index in the event array of the current block
|
|
88
|
+
*/
|
|
89
|
+
index: number
|
|
90
|
+
/**
|
|
91
|
+
* Event name
|
|
92
|
+
*/
|
|
93
|
+
name: QualifiedName
|
|
94
|
+
args: unknown
|
|
95
|
+
phase: 'Initialization' | 'ApplyExtrinsic' | 'Finalization'
|
|
96
|
+
extrinsicIndex?: number
|
|
97
|
+
callAddress?: number[]
|
|
98
|
+
/**
|
|
99
|
+
* This field is not supported by all currently deployed archives.
|
|
100
|
+
* Requesting it may cause internal error.
|
|
101
|
+
*/
|
|
102
|
+
topics: Hex[]
|
|
103
|
+
_evmLogAddress?: Hex
|
|
104
|
+
_evmLogTopics?: Hex[]
|
|
105
|
+
_contractAddress?: Hex
|
|
106
|
+
_gearProgramId?: Hex
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type BlockHeaderFieldSelection = Simplify<Selector<keyof BlockHeaderFields> & {number: true; hash: true}>
|
|
110
|
+
export type BlockHeader<T extends BlockHeaderFieldSelection = Trues<BlockHeaderFieldSelection>> = Select<
|
|
111
|
+
BlockHeaderFields,
|
|
112
|
+
T
|
|
113
|
+
>
|
|
114
|
+
|
|
115
|
+
export type ExtrinsicFieldSelection = Selector<keyof ExtrinsicFields>
|
|
116
|
+
export type Extrinsic<T extends ExtrinsicFieldSelection = Trues<ExtrinsicFieldSelection>> = Select<ExtrinsicFields, T>
|
|
117
|
+
|
|
118
|
+
export type CallFieldSelection = Selector<keyof CallFields>
|
|
119
|
+
export type Call<T extends CallFieldSelection = Trues<CallFieldSelection>> = Select<CallFields, T>
|
|
120
|
+
|
|
121
|
+
export type EventFieldSelection = Selector<keyof EventFields>
|
|
122
|
+
export type Event<T extends EventFieldSelection = Trues<CallFieldSelection>> = Select<EventFields, T>
|
|
123
|
+
|
|
124
|
+
export type FieldSelection = {
|
|
125
|
+
block?: BlockHeaderFieldSelection
|
|
126
|
+
extrinsic?: ExtrinsicFieldSelection
|
|
127
|
+
call?: CallFieldSelection
|
|
128
|
+
event?: EventFieldSelection
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type EventRelations = {
|
|
132
|
+
extrinsic?: boolean
|
|
133
|
+
call?: boolean
|
|
134
|
+
stack?: boolean
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type EventRequest = Simplify<
|
|
138
|
+
{
|
|
139
|
+
name?: QualifiedName[]
|
|
140
|
+
} & EventRelations
|
|
141
|
+
>
|
|
142
|
+
|
|
143
|
+
export type CallRelations = {
|
|
144
|
+
extrinsic?: boolean
|
|
145
|
+
stack?: boolean
|
|
146
|
+
events?: boolean
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export type CallRequest = Simplify<{name?: QualifiedName[]} & CallRelations>
|
|
150
|
+
|
|
151
|
+
export type EvmLogRequest = Simplify<{address?: Hex[]} & EventRelations>
|
|
152
|
+
|
|
153
|
+
export type EthereumLogRequest = Simplify<
|
|
154
|
+
{
|
|
155
|
+
address?: Hex[]
|
|
156
|
+
topic0?: Hex[]
|
|
157
|
+
topic1?: Hex[]
|
|
158
|
+
topic2?: Hex[]
|
|
159
|
+
topic3?: Hex[]
|
|
160
|
+
} & EventRelations
|
|
161
|
+
>
|
|
162
|
+
|
|
163
|
+
export type EthereumTransactRequest = Simplify<{to?: Hex[]; sighash?: Hex[]} & CallRelations>
|
|
164
|
+
|
|
165
|
+
export type ContractsContractEmittedRequest = Simplify<{address?: Hex[]} & EventRelations>
|
|
166
|
+
|
|
167
|
+
export type GearMessageQueuedRequest = Simplify<{programId?: Hex[]} & EventRelations>
|
|
168
|
+
|
|
169
|
+
export type GearUserMessageSentRequest = Simplify<{programId?: Hex[]} & EventRelations>
|
|
170
|
+
|
|
171
|
+
export type DataRequest = {
|
|
172
|
+
includeAllBlocks?: boolean
|
|
173
|
+
events?: EventRequest[]
|
|
174
|
+
calls?: CallRequest[]
|
|
175
|
+
evmLogs?: EvmLogRequest[]
|
|
176
|
+
ethereumTransactions?: EthereumTransactRequest[]
|
|
177
|
+
contractsEvents?: ContractsContractEmittedRequest[]
|
|
178
|
+
gearMessagesQueued?: GearMessageQueuedRequest[]
|
|
179
|
+
gearUserMessagesSent?: GearUserMessageSentRequest[]
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export type Query = Simplify<
|
|
183
|
+
PortalQuery & {
|
|
184
|
+
type: 'substrate'
|
|
185
|
+
fields: FieldSelection
|
|
186
|
+
} & DataRequest
|
|
187
|
+
>
|
|
188
|
+
|
|
189
|
+
export type Block<F extends FieldSelection> = Simplify<{
|
|
190
|
+
header: BlockHeader<F['block'] & {}>
|
|
191
|
+
events?: Event<F['event'] & {}>[]
|
|
192
|
+
calls?: Call<F['call'] & {}>[]
|
|
193
|
+
extrinsics?: Extrinsic<F['extrinsic'] & {}>[]
|
|
194
|
+
}>
|