@subsquid/portal-client 0.3.2 → 0.4.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/lib/client.d.ts +40 -18
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +166 -188
- package/lib/client.js.map +1 -1
- package/lib/query/common/data.d.ts +21 -0
- package/lib/query/common/data.d.ts.map +1 -0
- package/lib/query/common/data.js +3 -0
- package/lib/query/common/data.js.map +1 -0
- package/lib/query/common/query.d.ts +7 -0
- package/lib/query/common/query.d.ts.map +1 -0
- package/lib/query/common/query.js +3 -0
- package/lib/query/common/query.js.map +1 -0
- package/lib/query/evm/data.d.ts +159 -0
- package/lib/query/evm/data.d.ts.map +1 -0
- package/lib/query/evm/data.js +3 -0
- package/lib/query/evm/data.js.map +1 -0
- package/lib/query/evm/fields.d.ts +50 -0
- package/lib/query/evm/fields.d.ts.map +1 -0
- package/lib/query/evm/fields.js +3 -0
- package/lib/query/evm/fields.js.map +1 -0
- package/lib/query/evm/index.d.ts +4 -0
- package/lib/query/evm/index.d.ts.map +1 -0
- package/lib/query/evm/index.js +7 -0
- package/lib/query/evm/index.js.map +1 -0
- package/lib/query/evm/query.d.ts +54 -0
- package/lib/query/evm/query.d.ts.map +1 -0
- package/lib/query/evm/query.js +3 -0
- package/lib/query/evm/query.js.map +1 -0
- package/lib/query/evm/schema.d.ts +322 -0
- package/lib/query/evm/schema.d.ts.map +1 -0
- package/lib/query/evm/schema.js +224 -0
- package/lib/query/evm/schema.js.map +1 -0
- package/lib/query/index.d.ts +576 -8
- package/lib/query/index.d.ts.map +1 -1
- package/lib/query/index.js +15 -24
- package/lib/query/index.js.map +1 -1
- package/lib/query/solana/data.d.ts +115 -0
- package/lib/query/solana/data.d.ts.map +1 -0
- package/lib/query/solana/data.js +3 -0
- package/lib/query/solana/data.js.map +1 -0
- package/lib/query/solana/fields.d.ts +31 -0
- package/lib/query/solana/fields.d.ts.map +1 -0
- package/lib/query/solana/fields.js +3 -0
- package/lib/query/solana/fields.js.map +1 -0
- package/lib/query/solana/index.d.ts +4 -0
- package/lib/query/solana/index.d.ts.map +1 -0
- package/lib/query/solana/index.js +7 -0
- package/lib/query/solana/index.js.map +1 -0
- package/lib/query/solana/query.d.ts +74 -0
- package/lib/query/solana/query.d.ts.map +1 -0
- package/lib/query/solana/query.js +3 -0
- package/lib/query/solana/query.js.map +1 -0
- package/lib/query/solana/schema.d.ts +160 -0
- package/lib/query/solana/schema.d.ts.map +1 -0
- package/lib/query/solana/schema.js +130 -0
- package/lib/query/solana/schema.js.map +1 -0
- package/lib/query/substrate/data.d.ts +98 -0
- package/lib/query/substrate/data.d.ts.map +1 -0
- package/lib/query/substrate/data.js +3 -0
- package/lib/query/substrate/data.js.map +1 -0
- package/lib/query/substrate/fields.d.ts +22 -0
- package/lib/query/substrate/fields.d.ts.map +1 -0
- package/lib/query/substrate/fields.js +3 -0
- package/lib/query/substrate/fields.js.map +1 -0
- package/lib/query/substrate/index.d.ts +4 -0
- package/lib/query/substrate/index.d.ts.map +1 -0
- package/lib/query/substrate/index.js +7 -0
- package/lib/query/substrate/index.js.map +1 -0
- package/lib/query/substrate/query.d.ts +50 -0
- package/lib/query/substrate/query.d.ts.map +1 -0
- package/lib/query/substrate/query.js +3 -0
- package/lib/query/substrate/query.js.map +1 -0
- package/lib/query/substrate/schema.d.ts +102 -0
- package/lib/query/substrate/schema.d.ts.map +1 -0
- package/lib/query/substrate/schema.js +88 -0
- package/lib/query/substrate/schema.js.map +1 -0
- package/lib/query/type-util.d.ts +13 -0
- package/lib/query/type-util.d.ts.map +1 -0
- package/lib/query/type-util.js +3 -0
- package/lib/query/type-util.js.map +1 -0
- package/lib/query/util.d.ts +5 -0
- package/lib/query/util.d.ts.map +1 -0
- package/lib/query/util.js +23 -0
- package/lib/query/util.js.map +1 -0
- package/lib/util.d.ts +19 -0
- package/lib/util.d.ts.map +1 -0
- package/lib/util.js +57 -0
- package/lib/util.js.map +1 -0
- package/package.json +3 -3
- package/src/client.ts +231 -247
- package/src/query/common/data.ts +24 -0
- package/src/query/common/query.ts +6 -0
- package/src/query/evm/data.ts +182 -0
- package/src/query/evm/fields.ts +105 -0
- package/src/query/evm/index.ts +3 -0
- package/src/query/evm/query.ts +59 -0
- package/src/query/evm/schema.ts +277 -0
- package/src/query/index.ts +19 -36
- package/src/query/solana/data.ts +132 -0
- package/src/query/solana/fields.ts +42 -0
- package/src/query/solana/index.ts +3 -0
- package/src/query/solana/query.ts +89 -0
- package/src/query/solana/schema.ts +164 -0
- package/src/query/substrate/data.ts +101 -0
- package/src/query/substrate/fields.ts +30 -0
- package/src/query/substrate/index.ts +3 -0
- package/src/query/substrate/query.ts +60 -0
- package/src/query/substrate/schema.ts +114 -0
- package/src/query/type-util.ts +25 -0
- package/src/query/util.ts +23 -0
- package/src/util.ts +56 -0
- package/lib/query/common.d.ts +0 -56
- package/lib/query/common.d.ts.map +0 -1
- package/lib/query/common.js +0 -16
- package/lib/query/common.js.map +0 -1
- package/lib/query/evm.d.ts +0 -267
- package/lib/query/evm.d.ts.map +0 -1
- package/lib/query/evm.js +0 -245
- package/lib/query/evm.js.map +0 -1
- package/lib/query/solana.d.ts +0 -224
- package/lib/query/solana.d.ts.map +0 -1
- package/lib/query/solana.js +0 -121
- package/lib/query/solana.js.map +0 -1
- package/lib/query/substrate.d.ts +0 -173
- package/lib/query/substrate.d.ts.map +0 -1
- package/lib/query/substrate.js +0 -71
- package/lib/query/substrate.js.map +0 -1
- package/src/query/common.ts +0 -83
- package/src/query/evm.ts +0 -677
- package/src/query/solana.ts +0 -438
- package/src/query/substrate.ts +0 -288
package/src/query/solana.ts
DELETED
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ANY,
|
|
3
|
-
ANY_OBJECT,
|
|
4
|
-
array,
|
|
5
|
-
B58,
|
|
6
|
-
BIG_NAT,
|
|
7
|
-
BOOLEAN,
|
|
8
|
-
constant,
|
|
9
|
-
NAT,
|
|
10
|
-
nullable,
|
|
11
|
-
object,
|
|
12
|
-
oneOf,
|
|
13
|
-
option,
|
|
14
|
-
STRING,
|
|
15
|
-
Validator,
|
|
16
|
-
withDefault,
|
|
17
|
-
} from '@subsquid/util-internal-validation'
|
|
18
|
-
import {
|
|
19
|
-
type Select,
|
|
20
|
-
type Selector,
|
|
21
|
-
type Trues,
|
|
22
|
-
type Base58,
|
|
23
|
-
type Hex,
|
|
24
|
-
type Simplify,
|
|
25
|
-
type PortalQuery,
|
|
26
|
-
project,
|
|
27
|
-
type ObjectValidatorShape,
|
|
28
|
-
type Selected,
|
|
29
|
-
} from './common'
|
|
30
|
-
|
|
31
|
-
export type BlockHeaderFields = {
|
|
32
|
-
hash: Base58
|
|
33
|
-
number: number
|
|
34
|
-
height: number
|
|
35
|
-
parentNumber: number
|
|
36
|
-
parentHash: Base58
|
|
37
|
-
timestamp: number
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type TransactionFields = {
|
|
41
|
-
/**
|
|
42
|
-
* Transaction position in block
|
|
43
|
-
*/
|
|
44
|
-
transactionIndex: number
|
|
45
|
-
version: 'legacy' | number
|
|
46
|
-
// transaction message
|
|
47
|
-
accountKeys: Base58[]
|
|
48
|
-
addressTableLookups: AddressTableLookup[]
|
|
49
|
-
numReadonlySignedAccounts: number
|
|
50
|
-
numReadonlyUnsignedAccounts: number
|
|
51
|
-
numRequiredSignatures: number
|
|
52
|
-
recentBlockhash: Base58
|
|
53
|
-
signatures: Base58[]
|
|
54
|
-
// meta fields
|
|
55
|
-
err: null | object
|
|
56
|
-
computeUnitsConsumed: bigint
|
|
57
|
-
fee: bigint
|
|
58
|
-
loadedAddresses?: {
|
|
59
|
-
readonly: Base58[]
|
|
60
|
-
writable: Base58[]
|
|
61
|
-
}
|
|
62
|
-
hasDroppedLogMessages: boolean
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type AddressTableLookup = {
|
|
66
|
-
accountKey: Base58
|
|
67
|
-
readonlyIndexes: number[]
|
|
68
|
-
writableIndexes: number[]
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type InstructionFields = {
|
|
72
|
-
transactionIndex: number
|
|
73
|
-
instructionAddress: number[]
|
|
74
|
-
programId: Base58
|
|
75
|
-
accounts: Base58[]
|
|
76
|
-
data: Base58
|
|
77
|
-
// execution result extracted from logs
|
|
78
|
-
computeUnitsConsumed?: bigint
|
|
79
|
-
error?: unknown
|
|
80
|
-
/**
|
|
81
|
-
* `true` when transaction completed successfully, `false` otherwise
|
|
82
|
-
*/
|
|
83
|
-
isCommitted: boolean
|
|
84
|
-
hasDroppedLogMessages: boolean
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export type LogMessageFields = {
|
|
88
|
-
transactionIndex: number
|
|
89
|
-
logIndex: number
|
|
90
|
-
instructionAddress: number[]
|
|
91
|
-
programId: Base58
|
|
92
|
-
kind: 'log' | 'data' | 'other'
|
|
93
|
-
message: string
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export type BalanceFields = {
|
|
97
|
-
transactionIndex: number
|
|
98
|
-
account: Base58
|
|
99
|
-
pre: bigint
|
|
100
|
-
post: bigint
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export type PreTokenBalanceFields = {
|
|
104
|
-
transactionIndex: number
|
|
105
|
-
account: Base58
|
|
106
|
-
|
|
107
|
-
preProgramId?: Base58
|
|
108
|
-
preMint: Base58
|
|
109
|
-
preDecimals: number
|
|
110
|
-
preOwner?: Base58
|
|
111
|
-
preAmount: bigint
|
|
112
|
-
|
|
113
|
-
postProgramId?: undefined
|
|
114
|
-
postMint?: undefined
|
|
115
|
-
postDecimals?: undefined
|
|
116
|
-
postOwner?: undefined
|
|
117
|
-
postAmount?: undefined
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export type PostTokenBalanceFields = {
|
|
121
|
-
transactionIndex: number
|
|
122
|
-
account: Base58
|
|
123
|
-
|
|
124
|
-
preProgramId?: undefined
|
|
125
|
-
preMint?: undefined
|
|
126
|
-
preDecimals?: undefined
|
|
127
|
-
preOwner?: undefined
|
|
128
|
-
preAmount?: undefined
|
|
129
|
-
|
|
130
|
-
postProgramId?: Base58
|
|
131
|
-
postMint: Base58
|
|
132
|
-
postDecimals: number
|
|
133
|
-
postOwner?: Base58
|
|
134
|
-
postAmount: bigint
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export type PrePostTokenBalanceFields = {
|
|
138
|
-
transactionIndex: number
|
|
139
|
-
account: Base58
|
|
140
|
-
preProgramId?: Base58
|
|
141
|
-
preMint: Base58
|
|
142
|
-
preDecimals: number
|
|
143
|
-
preOwner?: Base58
|
|
144
|
-
preAmount: bigint
|
|
145
|
-
postProgramId?: Base58
|
|
146
|
-
postMint: Base58
|
|
147
|
-
postDecimals: number
|
|
148
|
-
postOwner?: Base58
|
|
149
|
-
postAmount: bigint
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export type TokenBalanceFields = PreTokenBalanceFields | PostTokenBalanceFields | PrePostTokenBalanceFields
|
|
153
|
-
|
|
154
|
-
export type RewardFields = {
|
|
155
|
-
pubkey: Base58
|
|
156
|
-
lamports: bigint
|
|
157
|
-
postBalance: bigint
|
|
158
|
-
rewardType?: string
|
|
159
|
-
commission?: number
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export type BlockHeaderFieldSelection = Selector<keyof BlockHeaderFields, 'number' | 'hash'>
|
|
163
|
-
export type BlockHeader<F extends BlockHeaderFieldSelection = Trues<BlockHeaderFieldSelection>> = Select<
|
|
164
|
-
BlockHeaderFields,
|
|
165
|
-
F
|
|
166
|
-
>
|
|
167
|
-
|
|
168
|
-
export type TransactionFieldSelection = Selector<keyof TransactionFields>
|
|
169
|
-
export type Transaction<F extends TransactionFieldSelection = Trues<TransactionFieldSelection>> = Select<
|
|
170
|
-
TransactionFields,
|
|
171
|
-
F
|
|
172
|
-
>
|
|
173
|
-
|
|
174
|
-
export type InstructionFieldSelection = Selector<keyof InstructionFields>
|
|
175
|
-
export type Instruction<F extends InstructionFieldSelection = Trues<InstructionFieldSelection>> = Select<
|
|
176
|
-
InstructionFields,
|
|
177
|
-
F
|
|
178
|
-
>
|
|
179
|
-
|
|
180
|
-
export type LogMessageFieldSelection = Selector<keyof LogMessageFields>
|
|
181
|
-
export type LogMessage<F extends LogMessageFieldSelection = Trues<LogMessageFieldSelection>> = Select<
|
|
182
|
-
LogMessageFields,
|
|
183
|
-
F
|
|
184
|
-
>
|
|
185
|
-
|
|
186
|
-
export type BalanceFieldSelection = Selector<keyof BalanceFields>
|
|
187
|
-
export type Balance<F extends BalanceFieldSelection = Trues<BalanceFieldSelection>> = Select<BalanceFields, F>
|
|
188
|
-
|
|
189
|
-
export type TokenBalanceFieldSelection = Selector<keyof TokenBalanceFields>
|
|
190
|
-
export type TokenBalance<F extends TokenBalanceFieldSelection = Trues<TokenBalanceFieldSelection>> = Select<
|
|
191
|
-
{[K in keyof TokenBalanceFields]: TokenBalanceFields[K]},
|
|
192
|
-
F
|
|
193
|
-
>
|
|
194
|
-
|
|
195
|
-
export type RewardFieldSelection = Selector<keyof RewardFields>
|
|
196
|
-
export type Reward<F extends RewardFieldSelection = Trues<RewardFieldSelection>> = Select<RewardFields, F>
|
|
197
|
-
|
|
198
|
-
export type FieldSelection = {
|
|
199
|
-
block?: BlockHeaderFieldSelection
|
|
200
|
-
transaction?: TransactionFieldSelection
|
|
201
|
-
instruction?: InstructionFieldSelection
|
|
202
|
-
log?: LogMessageFieldSelection
|
|
203
|
-
balance?: BalanceFieldSelection
|
|
204
|
-
tokenBalance?: TokenBalanceFieldSelection
|
|
205
|
-
reward?: RewardFieldSelection
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export type DataRequest = {
|
|
209
|
-
includeAllBlocks?: boolean
|
|
210
|
-
transactions?: TransactionRequest[]
|
|
211
|
-
instructions?: InstructionRequest[]
|
|
212
|
-
logs?: LogRequest[]
|
|
213
|
-
balances?: BalanceRequest[]
|
|
214
|
-
tokenBalances?: TokenBalanceRequest[]
|
|
215
|
-
rewards?: RewardRequest[]
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export type TransactionRequest = {
|
|
219
|
-
feePayer?: Base58[]
|
|
220
|
-
|
|
221
|
-
instructions?: boolean
|
|
222
|
-
logs?: boolean
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Hex encoded prefix of instruction data
|
|
227
|
-
*/
|
|
228
|
-
export type Discriminator = Hex
|
|
229
|
-
|
|
230
|
-
export type InstructionRequest = {
|
|
231
|
-
programId?: Base58[]
|
|
232
|
-
discriminator?: Discriminator[]
|
|
233
|
-
d0?: Discriminator[]
|
|
234
|
-
d1?: Discriminator[]
|
|
235
|
-
d2?: Discriminator[]
|
|
236
|
-
d4?: Discriminator[]
|
|
237
|
-
d8?: Discriminator[]
|
|
238
|
-
a0?: Base58[]
|
|
239
|
-
a1?: Base58[]
|
|
240
|
-
a2?: Base58[]
|
|
241
|
-
a3?: Base58[]
|
|
242
|
-
a4?: Base58[]
|
|
243
|
-
a5?: Base58[]
|
|
244
|
-
a6?: Base58[]
|
|
245
|
-
a7?: Base58[]
|
|
246
|
-
a8?: Base58[]
|
|
247
|
-
a9?: Base58[]
|
|
248
|
-
isCommitted?: boolean
|
|
249
|
-
|
|
250
|
-
transaction?: boolean
|
|
251
|
-
transactionBalances?: boolean
|
|
252
|
-
transactionTokenBalances?: boolean
|
|
253
|
-
transactionInstructions?: boolean
|
|
254
|
-
logs?: boolean
|
|
255
|
-
innerInstructions?: boolean
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export type LogRequest = {
|
|
259
|
-
programId?: Base58[]
|
|
260
|
-
kind?: LogMessageFields['kind'][]
|
|
261
|
-
|
|
262
|
-
transaction?: boolean
|
|
263
|
-
instruction?: boolean
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export type BalanceRequest = {
|
|
267
|
-
account?: Base58[]
|
|
268
|
-
|
|
269
|
-
transaction?: boolean
|
|
270
|
-
transactionInstructions?: boolean
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export type TokenBalanceRequest = {
|
|
274
|
-
account?: Base58[]
|
|
275
|
-
preProgramId?: Base58[]
|
|
276
|
-
postProgramId?: Base58[]
|
|
277
|
-
preMint?: Base58[]
|
|
278
|
-
postMint?: Base58[]
|
|
279
|
-
preOwner?: Base58[]
|
|
280
|
-
postOwner?: Base58[]
|
|
281
|
-
|
|
282
|
-
transaction?: boolean
|
|
283
|
-
transactionInstructions?: boolean
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export type RewardRequest = {
|
|
287
|
-
pubkey?: Base58[]
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export type Query<F extends FieldSelection = FieldSelection> = Simplify<
|
|
291
|
-
PortalQuery & {
|
|
292
|
-
type: 'solana'
|
|
293
|
-
fields: F
|
|
294
|
-
} & DataRequest
|
|
295
|
-
>
|
|
296
|
-
|
|
297
|
-
export type Block<F extends FieldSelection> = Simplify<{
|
|
298
|
-
header: BlockHeader<Selected<F, 'block'>>
|
|
299
|
-
transactions: Transaction<Selected<F, 'transaction'>>[]
|
|
300
|
-
instructions: Instruction<Selected<F, 'instruction'>>[]
|
|
301
|
-
logs: LogMessage<Selected<F, 'log'>>[]
|
|
302
|
-
balances: Balance<Selected<F, 'balance'>>[]
|
|
303
|
-
tokenBalances: TokenBalance<Selected<F, 'tokenBalance'>>[]
|
|
304
|
-
rewards: Reward<Selected<F, 'reward'>>[]
|
|
305
|
-
}>
|
|
306
|
-
|
|
307
|
-
export function getBlockSchema<F extends FieldSelection>(fields: F): Validator<Block<F>, unknown> {
|
|
308
|
-
let header = object(project(BlockHeaderShape, {...fields.block, number: true, hash: true}))
|
|
309
|
-
|
|
310
|
-
let transaction = object(project(TransactionShape, fields.transaction))
|
|
311
|
-
|
|
312
|
-
let instruction = object(project(InstructionShape, fields.instruction))
|
|
313
|
-
|
|
314
|
-
let balance = object(project(BalanceShape, fields.balance))
|
|
315
|
-
|
|
316
|
-
let tokenBalance = oneOf({
|
|
317
|
-
prePost: object(project(PrePostTokenBalanceShape, fields.tokenBalance)),
|
|
318
|
-
pre: object(project(PreTokenBalanceShape, fields.tokenBalance)),
|
|
319
|
-
post: object(project(PostTokenBalanceShape, fields.tokenBalance)),
|
|
320
|
-
})
|
|
321
|
-
|
|
322
|
-
let logMessage = object(project(LogMessageShape, fields.log))
|
|
323
|
-
|
|
324
|
-
let reward = object(project(RewardShape, fields.reward))
|
|
325
|
-
|
|
326
|
-
return object({
|
|
327
|
-
header,
|
|
328
|
-
transactions: withDefault([], array(transaction)),
|
|
329
|
-
instructions: withDefault([], array(instruction)),
|
|
330
|
-
logs: withDefault([], array(logMessage)),
|
|
331
|
-
balances: withDefault([], array(balance)),
|
|
332
|
-
tokenBalances: withDefault([], array(tokenBalance)),
|
|
333
|
-
rewards: withDefault([], array(reward)),
|
|
334
|
-
}) as Validator<Block<F>, unknown>
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const BlockHeaderShape: ObjectValidatorShape<BlockHeaderFields> = {
|
|
338
|
-
hash: B58,
|
|
339
|
-
number: NAT,
|
|
340
|
-
height: NAT,
|
|
341
|
-
parentNumber: NAT,
|
|
342
|
-
parentHash: B58,
|
|
343
|
-
timestamp: NAT,
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
const AddressTableLookup: Validator<AddressTableLookup> = object({
|
|
347
|
-
accountKey: B58,
|
|
348
|
-
readonlyIndexes: array(NAT),
|
|
349
|
-
writableIndexes: array(NAT),
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
const TransactionShape: ObjectValidatorShape<TransactionFields> = {
|
|
353
|
-
transactionIndex: NAT,
|
|
354
|
-
version: oneOf({legacy: constant('legacy'), versionNumber: NAT}),
|
|
355
|
-
accountKeys: array(B58),
|
|
356
|
-
addressTableLookups: array(AddressTableLookup),
|
|
357
|
-
numReadonlySignedAccounts: NAT,
|
|
358
|
-
numReadonlyUnsignedAccounts: NAT,
|
|
359
|
-
numRequiredSignatures: NAT,
|
|
360
|
-
recentBlockhash: B58,
|
|
361
|
-
signatures: array(B58),
|
|
362
|
-
err: nullable(ANY_OBJECT),
|
|
363
|
-
computeUnitsConsumed: BIG_NAT,
|
|
364
|
-
fee: BIG_NAT,
|
|
365
|
-
loadedAddresses: option(object({readonly: array(B58), writable: array(B58)})),
|
|
366
|
-
hasDroppedLogMessages: BOOLEAN,
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
const InstructionShape: ObjectValidatorShape<InstructionFields> = {
|
|
370
|
-
transactionIndex: NAT,
|
|
371
|
-
instructionAddress: array(NAT),
|
|
372
|
-
programId: B58,
|
|
373
|
-
accounts: array(B58),
|
|
374
|
-
data: B58,
|
|
375
|
-
computeUnitsConsumed: option(BIG_NAT),
|
|
376
|
-
error: ANY,
|
|
377
|
-
isCommitted: BOOLEAN,
|
|
378
|
-
hasDroppedLogMessages: BOOLEAN,
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const LogMessageShape: ObjectValidatorShape<LogMessageFields> = {
|
|
382
|
-
transactionIndex: NAT,
|
|
383
|
-
logIndex: NAT,
|
|
384
|
-
instructionAddress: array(NAT),
|
|
385
|
-
programId: B58,
|
|
386
|
-
kind: oneOf({log: constant('log'), data: constant('data'), other: constant('other')}),
|
|
387
|
-
message: STRING,
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
const BalanceShape: ObjectValidatorShape<BalanceFields> = {
|
|
391
|
-
transactionIndex: NAT,
|
|
392
|
-
account: B58,
|
|
393
|
-
pre: BIG_NAT,
|
|
394
|
-
post: BIG_NAT,
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
const PreTokenBalanceShape: ObjectValidatorShape<PreTokenBalanceFields> = {
|
|
398
|
-
transactionIndex: NAT,
|
|
399
|
-
account: B58,
|
|
400
|
-
preProgramId: option(B58),
|
|
401
|
-
preMint: B58,
|
|
402
|
-
preDecimals: NAT,
|
|
403
|
-
preOwner: option(B58),
|
|
404
|
-
preAmount: BIG_NAT,
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
const PostTokenBalanceShape: ObjectValidatorShape<PostTokenBalanceFields> = {
|
|
408
|
-
transactionIndex: NAT,
|
|
409
|
-
account: B58,
|
|
410
|
-
postProgramId: option(B58),
|
|
411
|
-
postMint: B58,
|
|
412
|
-
postDecimals: NAT,
|
|
413
|
-
postOwner: option(B58),
|
|
414
|
-
postAmount: BIG_NAT,
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
const PrePostTokenBalanceShape: ObjectValidatorShape<PrePostTokenBalanceFields> = {
|
|
418
|
-
transactionIndex: NAT,
|
|
419
|
-
account: B58,
|
|
420
|
-
preProgramId: option(B58),
|
|
421
|
-
preMint: B58,
|
|
422
|
-
preDecimals: NAT,
|
|
423
|
-
preOwner: option(B58),
|
|
424
|
-
preAmount: BIG_NAT,
|
|
425
|
-
postProgramId: option(B58),
|
|
426
|
-
postMint: B58,
|
|
427
|
-
postDecimals: NAT,
|
|
428
|
-
postOwner: option(B58),
|
|
429
|
-
postAmount: BIG_NAT,
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const RewardShape: ObjectValidatorShape<RewardFields> = {
|
|
433
|
-
pubkey: B58,
|
|
434
|
-
lamports: BIG_NAT,
|
|
435
|
-
postBalance: BIG_NAT,
|
|
436
|
-
rewardType: option(STRING),
|
|
437
|
-
commission: option(NAT),
|
|
438
|
-
}
|
package/src/query/substrate.ts
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
array,
|
|
3
|
-
NAT,
|
|
4
|
-
BYTES,
|
|
5
|
-
object,
|
|
6
|
-
Validator,
|
|
7
|
-
STRING,
|
|
8
|
-
option,
|
|
9
|
-
nullable,
|
|
10
|
-
BOOLEAN,
|
|
11
|
-
oneOf,
|
|
12
|
-
constant,
|
|
13
|
-
withDefault,
|
|
14
|
-
ANY_OBJECT,
|
|
15
|
-
BIG_NAT,
|
|
16
|
-
ANY,
|
|
17
|
-
} from '@subsquid/util-internal-validation'
|
|
18
|
-
import {
|
|
19
|
-
type Select,
|
|
20
|
-
type Selector,
|
|
21
|
-
type Trues,
|
|
22
|
-
type Hex,
|
|
23
|
-
type Simplify,
|
|
24
|
-
type PortalQuery,
|
|
25
|
-
project,
|
|
26
|
-
type Selected,
|
|
27
|
-
ObjectValidatorShape,
|
|
28
|
-
} from './common'
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @example 'Balances.Transfer'
|
|
32
|
-
*/
|
|
33
|
-
export type QualifiedName = string & {}
|
|
34
|
-
|
|
35
|
-
export type BlockHeaderFields = {
|
|
36
|
-
/**
|
|
37
|
-
* Block height
|
|
38
|
-
*/
|
|
39
|
-
number: number
|
|
40
|
-
/**
|
|
41
|
-
* Block hash
|
|
42
|
-
*/
|
|
43
|
-
hash: Hex
|
|
44
|
-
/**
|
|
45
|
-
* Hash of the parent block
|
|
46
|
-
*/
|
|
47
|
-
parentHash: Hex
|
|
48
|
-
/**
|
|
49
|
-
* Root hash of the state merkle tree
|
|
50
|
-
*/
|
|
51
|
-
stateRoot: Hex
|
|
52
|
-
/**
|
|
53
|
-
* Root hash of the extrinsics merkle tree
|
|
54
|
-
*/
|
|
55
|
-
extrinsicsRoot: Hex
|
|
56
|
-
digest: {logs: Hex[]}
|
|
57
|
-
specName: string
|
|
58
|
-
specVersion: number
|
|
59
|
-
implName: string
|
|
60
|
-
implVersion: number
|
|
61
|
-
/**
|
|
62
|
-
* Block timestamp as set by `timestamp.now()` (unix epoch ms, compatible with `Date`).
|
|
63
|
-
*/
|
|
64
|
-
timestamp?: number
|
|
65
|
-
/**
|
|
66
|
-
* Account address of block validator
|
|
67
|
-
*/
|
|
68
|
-
validator?: Hex
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type ExtrinsicSignature = {
|
|
72
|
-
address: Hex
|
|
73
|
-
signature: unknown
|
|
74
|
-
signedExtensions: unknown
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export type ExtrinsicFields = {
|
|
78
|
-
/**
|
|
79
|
-
* Ordinal index in the extrinsics array of the current block
|
|
80
|
-
*/
|
|
81
|
-
index: number
|
|
82
|
-
version: number
|
|
83
|
-
signature?: ExtrinsicSignature
|
|
84
|
-
fee?: bigint
|
|
85
|
-
tip?: bigint
|
|
86
|
-
error?: unknown
|
|
87
|
-
success?: boolean
|
|
88
|
-
/**
|
|
89
|
-
* Blake2b 128-bit hash of the raw extrinsic
|
|
90
|
-
*/
|
|
91
|
-
hash?: Hex
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export type CallFields = {
|
|
95
|
-
extrinsicIndex: number
|
|
96
|
-
address: number[]
|
|
97
|
-
name: QualifiedName
|
|
98
|
-
args: unknown
|
|
99
|
-
origin?: unknown
|
|
100
|
-
/**
|
|
101
|
-
* Call error.
|
|
102
|
-
*
|
|
103
|
-
* Absence of error doesn't imply that the call was executed successfully,
|
|
104
|
-
* check {@link success} property for that.
|
|
105
|
-
*/
|
|
106
|
-
error?: unknown
|
|
107
|
-
success?: boolean
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export type EventFields = {
|
|
111
|
-
/**
|
|
112
|
-
* Ordinal index in the event array of the current block
|
|
113
|
-
*/
|
|
114
|
-
index: number
|
|
115
|
-
/**
|
|
116
|
-
* Event name
|
|
117
|
-
*/
|
|
118
|
-
name: QualifiedName
|
|
119
|
-
args: unknown
|
|
120
|
-
phase: 'Initialization' | 'ApplyExtrinsic' | 'Finalization'
|
|
121
|
-
extrinsicIndex?: number
|
|
122
|
-
callAddress?: number[]
|
|
123
|
-
/**
|
|
124
|
-
* This field is not supported by all currently deployed archives.
|
|
125
|
-
* Requesting it may cause internal error.
|
|
126
|
-
*/
|
|
127
|
-
topics: Hex[]
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export type BlockHeaderFieldSelection = Selector<keyof BlockHeaderFields, 'number' | 'hash'>
|
|
131
|
-
export type BlockHeader<T extends BlockHeaderFieldSelection = Trues<BlockHeaderFieldSelection>> = Select<
|
|
132
|
-
BlockHeaderFields,
|
|
133
|
-
T
|
|
134
|
-
>
|
|
135
|
-
|
|
136
|
-
export type ExtrinsicFieldSelection = Selector<keyof ExtrinsicFields>
|
|
137
|
-
export type Extrinsic<T extends ExtrinsicFieldSelection = Trues<ExtrinsicFieldSelection>> = Select<ExtrinsicFields, T>
|
|
138
|
-
|
|
139
|
-
export type CallFieldSelection = Selector<keyof CallFields>
|
|
140
|
-
export type Call<T extends CallFieldSelection = Trues<CallFieldSelection>> = Select<CallFields, T>
|
|
141
|
-
|
|
142
|
-
export type EventFieldSelection = Selector<keyof EventFields>
|
|
143
|
-
export type Event<T extends EventFieldSelection = Trues<EventFieldSelection>> = Select<EventFields, T>
|
|
144
|
-
|
|
145
|
-
export type FieldSelection = {
|
|
146
|
-
block?: BlockHeaderFieldSelection
|
|
147
|
-
extrinsic?: ExtrinsicFieldSelection
|
|
148
|
-
call?: CallFieldSelection
|
|
149
|
-
event?: EventFieldSelection
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export type EventRelations = {
|
|
153
|
-
extrinsic?: boolean
|
|
154
|
-
call?: boolean
|
|
155
|
-
stack?: boolean
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export type EventRequest = Simplify<
|
|
159
|
-
{
|
|
160
|
-
name?: QualifiedName[]
|
|
161
|
-
} & EventRelations
|
|
162
|
-
>
|
|
163
|
-
|
|
164
|
-
export type CallRelations = {
|
|
165
|
-
extrinsic?: boolean
|
|
166
|
-
stack?: boolean
|
|
167
|
-
events?: boolean
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export type CallRequest = Simplify<{name?: QualifiedName[]} & CallRelations>
|
|
171
|
-
|
|
172
|
-
export type EvmLogRequest = Simplify<{address?: Hex[]} & EventRelations>
|
|
173
|
-
|
|
174
|
-
export type EthereumLogRequest = Simplify<
|
|
175
|
-
{
|
|
176
|
-
address?: Hex[]
|
|
177
|
-
topic0?: Hex[]
|
|
178
|
-
topic1?: Hex[]
|
|
179
|
-
topic2?: Hex[]
|
|
180
|
-
topic3?: Hex[]
|
|
181
|
-
} & EventRelations
|
|
182
|
-
>
|
|
183
|
-
|
|
184
|
-
export type EthereumTransactRequest = Simplify<{to?: Hex[]; sighash?: Hex[]} & CallRelations>
|
|
185
|
-
|
|
186
|
-
export type ContractsContractEmittedRequest = Simplify<{address?: Hex[]} & EventRelations>
|
|
187
|
-
|
|
188
|
-
export type GearMessageQueuedRequest = Simplify<{programId?: Hex[]} & EventRelations>
|
|
189
|
-
|
|
190
|
-
export type GearUserMessageSentRequest = Simplify<{programId?: Hex[]} & EventRelations>
|
|
191
|
-
|
|
192
|
-
export type DataRequest = {
|
|
193
|
-
includeAllBlocks?: boolean
|
|
194
|
-
events?: EventRequest[]
|
|
195
|
-
calls?: CallRequest[]
|
|
196
|
-
evmLogs?: EvmLogRequest[]
|
|
197
|
-
ethereumTransactions?: EthereumTransactRequest[]
|
|
198
|
-
contractsEvents?: ContractsContractEmittedRequest[]
|
|
199
|
-
gearMessagesQueued?: GearMessageQueuedRequest[]
|
|
200
|
-
gearUserMessagesSent?: GearUserMessageSentRequest[]
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export type Query<F extends FieldSelection = FieldSelection> = Simplify<
|
|
204
|
-
PortalQuery & {
|
|
205
|
-
type: 'substrate'
|
|
206
|
-
fields: F
|
|
207
|
-
} & DataRequest
|
|
208
|
-
>
|
|
209
|
-
|
|
210
|
-
export type Block<F extends FieldSelection> = Simplify<{
|
|
211
|
-
header: BlockHeader<Selected<F, 'block'>>
|
|
212
|
-
events: Event<Selected<F, 'event'>>[]
|
|
213
|
-
calls: Call<Selected<F, 'call'>>[]
|
|
214
|
-
extrinsics: Extrinsic<Selected<F, 'extrinsic'>>[]
|
|
215
|
-
}>
|
|
216
|
-
|
|
217
|
-
export function getBlockSchema<F extends FieldSelection>(fields: F): Validator<Block<F>, unknown> {
|
|
218
|
-
const header = object(project(BlockHeaderShape, {...fields.block, number: true, hash: true}))
|
|
219
|
-
const extrinsic = object(project(ExtrinsicShape, fields.extrinsic))
|
|
220
|
-
const call = object(project(CallShape, fields.call))
|
|
221
|
-
|
|
222
|
-
const event = object(project(EventShape, fields.event))
|
|
223
|
-
|
|
224
|
-
return object({
|
|
225
|
-
header,
|
|
226
|
-
events: withDefault([], array(event)),
|
|
227
|
-
calls: withDefault([], array(call)),
|
|
228
|
-
extrinsics: withDefault([], array(extrinsic)),
|
|
229
|
-
}) as Validator<Block<F>, unknown>
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const BlockHeaderShape: ObjectValidatorShape<BlockHeaderFields> = {
|
|
233
|
-
number: NAT,
|
|
234
|
-
hash: BYTES,
|
|
235
|
-
parentHash: BYTES,
|
|
236
|
-
stateRoot: BYTES,
|
|
237
|
-
extrinsicsRoot: BYTES,
|
|
238
|
-
digest: object({
|
|
239
|
-
logs: array(BYTES),
|
|
240
|
-
}),
|
|
241
|
-
specName: STRING,
|
|
242
|
-
specVersion: NAT,
|
|
243
|
-
implName: STRING,
|
|
244
|
-
implVersion: NAT,
|
|
245
|
-
timestamp: NAT,
|
|
246
|
-
validator: BYTES,
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const ExtrinsicSignature: Validator<ExtrinsicSignature, unknown> = object({
|
|
250
|
-
address: BYTES,
|
|
251
|
-
signature: ANY_OBJECT,
|
|
252
|
-
signedExtensions: ANY_OBJECT,
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
const ExtrinsicShape: ObjectValidatorShape<ExtrinsicFields> = {
|
|
256
|
-
index: NAT,
|
|
257
|
-
version: NAT,
|
|
258
|
-
signature: option(ExtrinsicSignature),
|
|
259
|
-
fee: BIG_NAT,
|
|
260
|
-
tip: BIG_NAT,
|
|
261
|
-
error: nullable(STRING),
|
|
262
|
-
success: BOOLEAN,
|
|
263
|
-
hash: BYTES,
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const CallShape: ObjectValidatorShape<CallFields> = {
|
|
267
|
-
extrinsicIndex: NAT,
|
|
268
|
-
address: array(NAT),
|
|
269
|
-
name: STRING,
|
|
270
|
-
args: ANY,
|
|
271
|
-
origin: ANY,
|
|
272
|
-
error: ANY,
|
|
273
|
-
success: option(BOOLEAN),
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const EventShape: ObjectValidatorShape<EventFields> = {
|
|
277
|
-
index: NAT,
|
|
278
|
-
name: STRING,
|
|
279
|
-
args: ANY,
|
|
280
|
-
phase: oneOf({
|
|
281
|
-
Initialization: constant('Initialization'),
|
|
282
|
-
ApplyExtrinsic: constant('ApplyExtrinsic'),
|
|
283
|
-
Finalization: constant('Finalization'),
|
|
284
|
-
}),
|
|
285
|
-
extrinsicIndex: NAT,
|
|
286
|
-
callAddress: array(NAT),
|
|
287
|
-
topics: array(BYTES),
|
|
288
|
-
}
|