@sentio/sdk 1.30.3 → 1.31.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.
Files changed (85) hide show
  1. package/lib/builtin/erc1155/index.d.ts +2 -0
  2. package/lib/builtin/erc1155/index.js +22 -0
  3. package/lib/builtin/erc1155/index.js.map +1 -0
  4. package/lib/builtin/erc1155/test-utils.d.ts +6 -0
  5. package/lib/builtin/erc1155/test-utils.js +57 -0
  6. package/lib/builtin/erc1155/test-utils.js.map +1 -0
  7. package/lib/builtin/erc721/index.d.ts +2 -0
  8. package/lib/builtin/erc721/index.js +22 -0
  9. package/lib/builtin/erc721/index.js.map +1 -0
  10. package/lib/builtin/erc721/test-utils.d.ts +5 -0
  11. package/lib/builtin/erc721/test-utils.js +46 -0
  12. package/lib/builtin/erc721/test-utils.js.map +1 -0
  13. package/lib/builtin/internal/ERC1155.d.ts +199 -0
  14. package/lib/builtin/internal/ERC1155.js +3 -0
  15. package/lib/builtin/internal/ERC1155.js.map +1 -0
  16. package/lib/builtin/internal/ERC721.d.ts +252 -0
  17. package/lib/builtin/internal/ERC721.js +3 -0
  18. package/lib/builtin/internal/ERC721.js.map +1 -0
  19. package/lib/builtin/internal/erc1155_processor.d.ts +134 -0
  20. package/lib/builtin/internal/erc1155_processor.js +337 -0
  21. package/lib/builtin/internal/erc1155_processor.js.map +1 -0
  22. package/lib/builtin/internal/erc721_processor.d.ts +169 -0
  23. package/lib/builtin/internal/erc721_processor.js +479 -0
  24. package/lib/builtin/internal/erc721_processor.js.map +1 -0
  25. package/lib/builtin/internal/factories/ERC1155__factory.d.ts +35 -0
  26. package/lib/builtin/internal/factories/ERC1155__factory.js +332 -0
  27. package/lib/builtin/internal/factories/ERC1155__factory.js.map +1 -0
  28. package/lib/builtin/internal/factories/ERC721__factory.d.ts +51 -0
  29. package/lib/builtin/internal/factories/ERC721__factory.js +364 -0
  30. package/lib/builtin/internal/factories/ERC721__factory.js.map +1 -0
  31. package/lib/builtin/internal/factories/index.d.ts +2 -0
  32. package/lib/builtin/internal/factories/index.js +5 -1
  33. package/lib/builtin/internal/factories/index.js.map +1 -1
  34. package/lib/builtin/internal/index.d.ts +4 -0
  35. package/lib/builtin/internal/index.js +5 -1
  36. package/lib/builtin/internal/index.js.map +1 -1
  37. package/lib/core/account-processor.d.ts +58 -0
  38. package/lib/core/account-processor.js +147 -0
  39. package/lib/core/account-processor.js.map +1 -0
  40. package/lib/core/base-processor.d.ts +5 -2
  41. package/lib/core/base-processor.js.map +1 -1
  42. package/lib/core/bind-options.d.ts +5 -0
  43. package/lib/core/bind-options.js +7 -1
  44. package/lib/core/bind-options.js.map +1 -1
  45. package/lib/core/context.d.ts +7 -1
  46. package/lib/core/context.js +30 -18
  47. package/lib/core/context.js.map +1 -1
  48. package/lib/core/meter.js +9 -0
  49. package/lib/core/meter.js.map +1 -1
  50. package/lib/gen/chainquery/protos/chainquery.d.ts +1 -0
  51. package/lib/gen/chainquery/protos/chainquery.js +17 -1
  52. package/lib/gen/chainquery/protos/chainquery.js.map +1 -1
  53. package/lib/gen/processor/protos/processor.d.ts +12 -1
  54. package/lib/gen/processor/protos/processor.js +108 -13
  55. package/lib/gen/processor/protos/processor.js.map +1 -1
  56. package/lib/service.d.ts +1 -0
  57. package/lib/service.js +67 -42
  58. package/lib/service.js.map +1 -1
  59. package/lib/testing/test-processor-server.d.ts +6 -2
  60. package/lib/testing/test-processor-server.js +66 -5
  61. package/lib/testing/test-processor-server.js.map +1 -1
  62. package/package.json +1 -1
  63. package/src/abis/ERC1155.json +314 -0
  64. package/src/abis/ERC721.json +346 -0
  65. package/src/builtin/erc1155/index.ts +6 -0
  66. package/src/builtin/erc1155/test-utils.ts +89 -0
  67. package/src/builtin/erc721/index.ts +6 -0
  68. package/src/builtin/erc721/test-utils.ts +71 -0
  69. package/src/builtin/internal/ERC1155.ts +529 -0
  70. package/src/builtin/internal/ERC721.ts +639 -0
  71. package/src/builtin/internal/erc1155_processor.ts +580 -0
  72. package/src/builtin/internal/erc721_processor.ts +768 -0
  73. package/src/builtin/internal/factories/ERC1155__factory.ts +335 -0
  74. package/src/builtin/internal/factories/ERC721__factory.ts +364 -0
  75. package/src/builtin/internal/factories/index.ts +2 -0
  76. package/src/builtin/internal/index.ts +4 -0
  77. package/src/core/account-processor.ts +217 -0
  78. package/src/core/base-processor.ts +6 -2
  79. package/src/core/bind-options.ts +6 -0
  80. package/src/core/context.ts +42 -27
  81. package/src/core/meter.ts +11 -2
  82. package/src/gen/chainquery/protos/chainquery.ts +18 -1
  83. package/src/gen/processor/protos/processor.ts +113 -12
  84. package/src/service.ts +71 -44
  85. package/src/testing/test-processor-server.ts +71 -5
@@ -0,0 +1,768 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ import { BigNumber, BigNumberish, CallOverrides, BytesLike } from "ethers";
5
+ import { Networkish } from "@ethersproject/providers";
6
+ import {
7
+ addContractByABI,
8
+ getContractByABI,
9
+ addProcessor,
10
+ getProcessor,
11
+ getProvider,
12
+ transformEtherError,
13
+ BindOptions,
14
+ BaseProcessor,
15
+ BaseProcessorTemplate,
16
+ BoundContractView,
17
+ ContractContext,
18
+ ContractView,
19
+ DummyProvider,
20
+ TypedCallTrace,
21
+ } from "@sentio/sdk";
22
+ import { PromiseOrValue } from "./common";
23
+ import { ERC721, ERC721__factory } from "./index";
24
+ import {
25
+ ApprovalEvent,
26
+ ApprovalEventFilter,
27
+ ApprovalForAllEvent,
28
+ ApprovalForAllEventFilter,
29
+ TransferEvent,
30
+ TransferEventFilter,
31
+ } from "./ERC721";
32
+
33
+ export interface ApproveCallObject {
34
+ to: string;
35
+ tokenId: BigNumber;
36
+ }
37
+
38
+ export type ApproveCallTrace = TypedCallTrace<
39
+ [string, BigNumber],
40
+ ApproveCallObject
41
+ >;
42
+
43
+ export interface TotalSupplyCallObject {}
44
+
45
+ export type TotalSupplyCallTrace = TypedCallTrace<[], TotalSupplyCallObject>;
46
+
47
+ export interface BalanceOfCallObject {
48
+ owner: string;
49
+ }
50
+
51
+ export type BalanceOfCallTrace = TypedCallTrace<[string], BalanceOfCallObject>;
52
+
53
+ export interface GetApprovedCallObject {
54
+ tokenId: BigNumber;
55
+ }
56
+
57
+ export type GetApprovedCallTrace = TypedCallTrace<
58
+ [BigNumber],
59
+ GetApprovedCallObject
60
+ >;
61
+
62
+ export interface IsApprovedForAllCallObject {
63
+ owner: string;
64
+ operator: string;
65
+ }
66
+
67
+ export type IsApprovedForAllCallTrace = TypedCallTrace<
68
+ [string, string],
69
+ IsApprovedForAllCallObject
70
+ >;
71
+
72
+ export interface NameCallObject {}
73
+
74
+ export type NameCallTrace = TypedCallTrace<[], NameCallObject>;
75
+
76
+ export interface OwnerOfCallObject {
77
+ tokenId: BigNumber;
78
+ }
79
+
80
+ export type OwnerOfCallTrace = TypedCallTrace<[BigNumber], OwnerOfCallObject>;
81
+
82
+ export interface SafeTransferFrom_address_address_uint256CallObject {
83
+ from: string;
84
+ to: string;
85
+ tokenId: BigNumber;
86
+ }
87
+
88
+ export type SafeTransferFrom_address_address_uint256CallTrace = TypedCallTrace<
89
+ [string, string, BigNumber],
90
+ SafeTransferFrom_address_address_uint256CallObject
91
+ >;
92
+
93
+ export interface SafeTransferFrom_address_address_uint256_bytesCallObject {
94
+ from: string;
95
+ to: string;
96
+ tokenId: BigNumber;
97
+ data: string;
98
+ }
99
+
100
+ export type SafeTransferFrom_address_address_uint256_bytesCallTrace =
101
+ TypedCallTrace<
102
+ [string, string, BigNumber, string],
103
+ SafeTransferFrom_address_address_uint256_bytesCallObject
104
+ >;
105
+
106
+ export interface SetApprovalForAllCallObject {
107
+ operator: string;
108
+ _approved: boolean;
109
+ }
110
+
111
+ export type SetApprovalForAllCallTrace = TypedCallTrace<
112
+ [string, boolean],
113
+ SetApprovalForAllCallObject
114
+ >;
115
+
116
+ export interface SupportsInterfaceCallObject {
117
+ interfaceId: string;
118
+ }
119
+
120
+ export type SupportsInterfaceCallTrace = TypedCallTrace<
121
+ [string],
122
+ SupportsInterfaceCallObject
123
+ >;
124
+
125
+ export interface SymbolCallObject {}
126
+
127
+ export type SymbolCallTrace = TypedCallTrace<[], SymbolCallObject>;
128
+
129
+ export interface TokenURICallObject {
130
+ tokenId: BigNumber;
131
+ }
132
+
133
+ export type TokenURICallTrace = TypedCallTrace<[BigNumber], TokenURICallObject>;
134
+
135
+ export interface TransferFromCallObject {
136
+ from: string;
137
+ to: string;
138
+ tokenId: BigNumber;
139
+ }
140
+
141
+ export type TransferFromCallTrace = TypedCallTrace<
142
+ [string, string, BigNumber],
143
+ TransferFromCallObject
144
+ >;
145
+
146
+ const templateContract = ERC721__factory.connect("", DummyProvider);
147
+
148
+ export class ERC721ContractView extends ContractView<ERC721> {
149
+ constructor(contract: ERC721) {
150
+ super(contract);
151
+ }
152
+
153
+ async totalSupply(overrides?: CallOverrides): Promise<BigNumber> {
154
+ try {
155
+ if (overrides) {
156
+ return await this.contract.totalSupply(overrides);
157
+ } else {
158
+ return await this.contract.totalSupply();
159
+ }
160
+ } catch (e) {
161
+ throw transformEtherError(e, undefined);
162
+ }
163
+ }
164
+
165
+ async balanceOf(
166
+ owner: PromiseOrValue<string>,
167
+ overrides?: CallOverrides
168
+ ): Promise<BigNumber> {
169
+ try {
170
+ if (overrides) {
171
+ return await this.contract.balanceOf(owner, overrides);
172
+ } else {
173
+ return await this.contract.balanceOf(owner);
174
+ }
175
+ } catch (e) {
176
+ throw transformEtherError(e, undefined);
177
+ }
178
+ }
179
+
180
+ async getApproved(
181
+ tokenId: PromiseOrValue<BigNumberish>,
182
+ overrides?: CallOverrides
183
+ ): Promise<string> {
184
+ try {
185
+ if (overrides) {
186
+ return await this.contract.getApproved(tokenId, overrides);
187
+ } else {
188
+ return await this.contract.getApproved(tokenId);
189
+ }
190
+ } catch (e) {
191
+ throw transformEtherError(e, undefined);
192
+ }
193
+ }
194
+
195
+ async isApprovedForAll(
196
+ owner: PromiseOrValue<string>,
197
+ operator: PromiseOrValue<string>,
198
+ overrides?: CallOverrides
199
+ ): Promise<boolean> {
200
+ try {
201
+ if (overrides) {
202
+ return await this.contract.isApprovedForAll(owner, operator, overrides);
203
+ } else {
204
+ return await this.contract.isApprovedForAll(owner, operator);
205
+ }
206
+ } catch (e) {
207
+ throw transformEtherError(e, undefined);
208
+ }
209
+ }
210
+
211
+ async name(overrides?: CallOverrides): Promise<string> {
212
+ try {
213
+ if (overrides) {
214
+ return await this.contract.name(overrides);
215
+ } else {
216
+ return await this.contract.name();
217
+ }
218
+ } catch (e) {
219
+ throw transformEtherError(e, undefined);
220
+ }
221
+ }
222
+
223
+ async ownerOf(
224
+ tokenId: PromiseOrValue<BigNumberish>,
225
+ overrides?: CallOverrides
226
+ ): Promise<string> {
227
+ try {
228
+ if (overrides) {
229
+ return await this.contract.ownerOf(tokenId, overrides);
230
+ } else {
231
+ return await this.contract.ownerOf(tokenId);
232
+ }
233
+ } catch (e) {
234
+ throw transformEtherError(e, undefined);
235
+ }
236
+ }
237
+
238
+ async supportsInterface(
239
+ interfaceId: PromiseOrValue<BytesLike>,
240
+ overrides?: CallOverrides
241
+ ): Promise<boolean> {
242
+ try {
243
+ if (overrides) {
244
+ return await this.contract.supportsInterface(interfaceId, overrides);
245
+ } else {
246
+ return await this.contract.supportsInterface(interfaceId);
247
+ }
248
+ } catch (e) {
249
+ throw transformEtherError(e, undefined);
250
+ }
251
+ }
252
+
253
+ async symbol(overrides?: CallOverrides): Promise<string> {
254
+ try {
255
+ if (overrides) {
256
+ return await this.contract.symbol(overrides);
257
+ } else {
258
+ return await this.contract.symbol();
259
+ }
260
+ } catch (e) {
261
+ throw transformEtherError(e, undefined);
262
+ }
263
+ }
264
+
265
+ async tokenURI(
266
+ tokenId: PromiseOrValue<BigNumberish>,
267
+ overrides?: CallOverrides
268
+ ): Promise<string> {
269
+ try {
270
+ if (overrides) {
271
+ return await this.contract.tokenURI(tokenId, overrides);
272
+ } else {
273
+ return await this.contract.tokenURI(tokenId);
274
+ }
275
+ } catch (e) {
276
+ throw transformEtherError(e, undefined);
277
+ }
278
+ }
279
+ }
280
+
281
+ export class ERC721BoundContractView extends BoundContractView<
282
+ ERC721,
283
+ ERC721ContractView
284
+ > {
285
+ // constructor (contract: ERC721) {
286
+ // super(contract);
287
+ // }
288
+
289
+ async totalSupply(overrides?: CallOverrides): Promise<BigNumber> {
290
+ try {
291
+ if (!overrides && this.context) {
292
+ overrides = {
293
+ blockTag: this.context.blockNumber.toNumber(),
294
+ };
295
+ }
296
+ if (overrides) {
297
+ return await this.view.totalSupply(overrides);
298
+ } else {
299
+ return await this.view.totalSupply();
300
+ }
301
+ } catch (e) {
302
+ throw transformEtherError(e, this.context);
303
+ }
304
+ }
305
+
306
+ async balanceOf(
307
+ owner: PromiseOrValue<string>,
308
+ overrides?: CallOverrides
309
+ ): Promise<BigNumber> {
310
+ try {
311
+ if (!overrides && this.context) {
312
+ overrides = {
313
+ blockTag: this.context.blockNumber.toNumber(),
314
+ };
315
+ }
316
+ if (overrides) {
317
+ return await this.view.balanceOf(owner, overrides);
318
+ } else {
319
+ return await this.view.balanceOf(owner);
320
+ }
321
+ } catch (e) {
322
+ throw transformEtherError(e, this.context);
323
+ }
324
+ }
325
+
326
+ async getApproved(
327
+ tokenId: PromiseOrValue<BigNumberish>,
328
+ overrides?: CallOverrides
329
+ ): Promise<string> {
330
+ try {
331
+ if (!overrides && this.context) {
332
+ overrides = {
333
+ blockTag: this.context.blockNumber.toNumber(),
334
+ };
335
+ }
336
+ if (overrides) {
337
+ return await this.view.getApproved(tokenId, overrides);
338
+ } else {
339
+ return await this.view.getApproved(tokenId);
340
+ }
341
+ } catch (e) {
342
+ throw transformEtherError(e, this.context);
343
+ }
344
+ }
345
+
346
+ async isApprovedForAll(
347
+ owner: PromiseOrValue<string>,
348
+ operator: PromiseOrValue<string>,
349
+ overrides?: CallOverrides
350
+ ): Promise<boolean> {
351
+ try {
352
+ if (!overrides && this.context) {
353
+ overrides = {
354
+ blockTag: this.context.blockNumber.toNumber(),
355
+ };
356
+ }
357
+ if (overrides) {
358
+ return await this.view.isApprovedForAll(owner, operator, overrides);
359
+ } else {
360
+ return await this.view.isApprovedForAll(owner, operator);
361
+ }
362
+ } catch (e) {
363
+ throw transformEtherError(e, this.context);
364
+ }
365
+ }
366
+
367
+ async name(overrides?: CallOverrides): Promise<string> {
368
+ try {
369
+ if (!overrides && this.context) {
370
+ overrides = {
371
+ blockTag: this.context.blockNumber.toNumber(),
372
+ };
373
+ }
374
+ if (overrides) {
375
+ return await this.view.name(overrides);
376
+ } else {
377
+ return await this.view.name();
378
+ }
379
+ } catch (e) {
380
+ throw transformEtherError(e, this.context);
381
+ }
382
+ }
383
+
384
+ async ownerOf(
385
+ tokenId: PromiseOrValue<BigNumberish>,
386
+ overrides?: CallOverrides
387
+ ): Promise<string> {
388
+ try {
389
+ if (!overrides && this.context) {
390
+ overrides = {
391
+ blockTag: this.context.blockNumber.toNumber(),
392
+ };
393
+ }
394
+ if (overrides) {
395
+ return await this.view.ownerOf(tokenId, overrides);
396
+ } else {
397
+ return await this.view.ownerOf(tokenId);
398
+ }
399
+ } catch (e) {
400
+ throw transformEtherError(e, this.context);
401
+ }
402
+ }
403
+
404
+ async supportsInterface(
405
+ interfaceId: PromiseOrValue<BytesLike>,
406
+ overrides?: CallOverrides
407
+ ): Promise<boolean> {
408
+ try {
409
+ if (!overrides && this.context) {
410
+ overrides = {
411
+ blockTag: this.context.blockNumber.toNumber(),
412
+ };
413
+ }
414
+ if (overrides) {
415
+ return await this.view.supportsInterface(interfaceId, overrides);
416
+ } else {
417
+ return await this.view.supportsInterface(interfaceId);
418
+ }
419
+ } catch (e) {
420
+ throw transformEtherError(e, this.context);
421
+ }
422
+ }
423
+
424
+ async symbol(overrides?: CallOverrides): Promise<string> {
425
+ try {
426
+ if (!overrides && this.context) {
427
+ overrides = {
428
+ blockTag: this.context.blockNumber.toNumber(),
429
+ };
430
+ }
431
+ if (overrides) {
432
+ return await this.view.symbol(overrides);
433
+ } else {
434
+ return await this.view.symbol();
435
+ }
436
+ } catch (e) {
437
+ throw transformEtherError(e, this.context);
438
+ }
439
+ }
440
+
441
+ async tokenURI(
442
+ tokenId: PromiseOrValue<BigNumberish>,
443
+ overrides?: CallOverrides
444
+ ): Promise<string> {
445
+ try {
446
+ if (!overrides && this.context) {
447
+ overrides = {
448
+ blockTag: this.context.blockNumber.toNumber(),
449
+ };
450
+ }
451
+ if (overrides) {
452
+ return await this.view.tokenURI(tokenId, overrides);
453
+ } else {
454
+ return await this.view.tokenURI(tokenId);
455
+ }
456
+ } catch (e) {
457
+ throw transformEtherError(e, this.context);
458
+ }
459
+ }
460
+ }
461
+
462
+ export type ERC721Context = ContractContext<ERC721, ERC721BoundContractView>;
463
+
464
+ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
465
+ ERC721,
466
+ ERC721BoundContractView
467
+ > {
468
+ bindInternal(options: BindOptions) {
469
+ if (!options.name) {
470
+ options.name = "ERC721";
471
+ }
472
+ let processor = getProcessor(options) as ERC721Processor;
473
+ if (!processor) {
474
+ processor = new ERC721Processor(options);
475
+ addProcessor(options, processor);
476
+ }
477
+ return processor;
478
+ }
479
+
480
+ onEventApproval(
481
+ handler: (event: ApprovalEvent, ctx: ERC721Context) => void,
482
+ filter?: ApprovalEventFilter | ApprovalEventFilter[]
483
+ ) {
484
+ if (!filter) {
485
+ // @ts-ignore
486
+ filter = ERC721Processor.filters[
487
+ // @ts-ignore
488
+ "Approval(address,address,uint256)"
489
+ ](null, null, null);
490
+ }
491
+ return super.onEvent(handler, filter!);
492
+ }
493
+
494
+ onEventApprovalForAll(
495
+ handler: (event: ApprovalForAllEvent, ctx: ERC721Context) => void,
496
+ filter?: ApprovalForAllEventFilter | ApprovalForAllEventFilter[]
497
+ ) {
498
+ if (!filter) {
499
+ // @ts-ignore
500
+ filter = ERC721Processor.filters[
501
+ // @ts-ignore
502
+ "ApprovalForAll(address,address,bool)"
503
+ ](null, null, null);
504
+ }
505
+ return super.onEvent(handler, filter!);
506
+ }
507
+
508
+ onEventTransfer(
509
+ handler: (event: TransferEvent, ctx: ERC721Context) => void,
510
+ filter?: TransferEventFilter | TransferEventFilter[]
511
+ ) {
512
+ if (!filter) {
513
+ // @ts-ignore
514
+ filter = ERC721Processor.filters[
515
+ // @ts-ignore
516
+ "Transfer(address,address,uint256)"
517
+ ](null, null, null);
518
+ }
519
+ return super.onEvent(handler, filter!);
520
+ }
521
+
522
+ onCallApprove(handler: (call: ApproveCallTrace, ctx: ERC721Context) => void) {
523
+ return super.onTrace("0x095ea7b3", handler);
524
+ }
525
+
526
+ onCallTotalSupply(
527
+ handler: (call: TotalSupplyCallTrace, ctx: ERC721Context) => void
528
+ ) {
529
+ return super.onTrace("0x18160ddd", handler);
530
+ }
531
+
532
+ onCallBalanceOf(
533
+ handler: (call: BalanceOfCallTrace, ctx: ERC721Context) => void
534
+ ) {
535
+ return super.onTrace("0x70a08231", handler);
536
+ }
537
+
538
+ onCallGetApproved(
539
+ handler: (call: GetApprovedCallTrace, ctx: ERC721Context) => void
540
+ ) {
541
+ return super.onTrace("0x081812fc", handler);
542
+ }
543
+
544
+ onCallIsApprovedForAll(
545
+ handler: (call: IsApprovedForAllCallTrace, ctx: ERC721Context) => void
546
+ ) {
547
+ return super.onTrace("0xe985e9c5", handler);
548
+ }
549
+
550
+ onCallName(handler: (call: NameCallTrace, ctx: ERC721Context) => void) {
551
+ return super.onTrace("0x06fdde03", handler);
552
+ }
553
+
554
+ onCallOwnerOf(handler: (call: OwnerOfCallTrace, ctx: ERC721Context) => void) {
555
+ return super.onTrace("0x6352211e", handler);
556
+ }
557
+
558
+ onCallSafeTransferFrom_address_address_uint256(
559
+ handler: (
560
+ call: SafeTransferFrom_address_address_uint256CallTrace,
561
+ ctx: ERC721Context
562
+ ) => void
563
+ ) {
564
+ return super.onTrace("0x42842e0e", handler);
565
+ }
566
+
567
+ onCallSafeTransferFrom_address_address_uint256_bytes(
568
+ handler: (
569
+ call: SafeTransferFrom_address_address_uint256_bytesCallTrace,
570
+ ctx: ERC721Context
571
+ ) => void
572
+ ) {
573
+ return super.onTrace("0xb88d4fde", handler);
574
+ }
575
+
576
+ onCallSetApprovalForAll(
577
+ handler: (call: SetApprovalForAllCallTrace, ctx: ERC721Context) => void
578
+ ) {
579
+ return super.onTrace("0xa22cb465", handler);
580
+ }
581
+
582
+ onCallSupportsInterface(
583
+ handler: (call: SupportsInterfaceCallTrace, ctx: ERC721Context) => void
584
+ ) {
585
+ return super.onTrace("0x01ffc9a7", handler);
586
+ }
587
+
588
+ onCallSymbol(handler: (call: SymbolCallTrace, ctx: ERC721Context) => void) {
589
+ return super.onTrace("0x95d89b41", handler);
590
+ }
591
+
592
+ onCallTokenURI(
593
+ handler: (call: TokenURICallTrace, ctx: ERC721Context) => void
594
+ ) {
595
+ return super.onTrace("0xc87b56dd", handler);
596
+ }
597
+
598
+ onCallTransferFrom(
599
+ handler: (call: TransferFromCallTrace, ctx: ERC721Context) => void
600
+ ) {
601
+ return super.onTrace("0x23b872dd", handler);
602
+ }
603
+ }
604
+
605
+ export class ERC721Processor extends BaseProcessor<
606
+ ERC721,
607
+ ERC721BoundContractView
608
+ > {
609
+ onEventApproval(
610
+ handler: (event: ApprovalEvent, ctx: ERC721Context) => void,
611
+ filter?: ApprovalEventFilter | ApprovalEventFilter[]
612
+ ) {
613
+ if (!filter) {
614
+ // @ts-ignore
615
+ filter = ERC721Processor.filters[
616
+ // @ts-ignore
617
+ "Approval(address,address,uint256)"
618
+ ](null, null, null);
619
+ }
620
+ return super.onEvent(handler, filter!);
621
+ }
622
+
623
+ onEventApprovalForAll(
624
+ handler: (event: ApprovalForAllEvent, ctx: ERC721Context) => void,
625
+ filter?: ApprovalForAllEventFilter | ApprovalForAllEventFilter[]
626
+ ) {
627
+ if (!filter) {
628
+ // @ts-ignore
629
+ filter = ERC721Processor.filters[
630
+ // @ts-ignore
631
+ "ApprovalForAll(address,address,bool)"
632
+ ](null, null, null);
633
+ }
634
+ return super.onEvent(handler, filter!);
635
+ }
636
+
637
+ onEventTransfer(
638
+ handler: (event: TransferEvent, ctx: ERC721Context) => void,
639
+ filter?: TransferEventFilter | TransferEventFilter[]
640
+ ) {
641
+ if (!filter) {
642
+ // @ts-ignore
643
+ filter = ERC721Processor.filters[
644
+ // @ts-ignore
645
+ "Transfer(address,address,uint256)"
646
+ ](null, null, null);
647
+ }
648
+ return super.onEvent(handler, filter!);
649
+ }
650
+
651
+ onCallApprove(handler: (call: ApproveCallTrace, ctx: ERC721Context) => void) {
652
+ return super.onTrace("0x095ea7b3", handler);
653
+ }
654
+
655
+ onCallTotalSupply(
656
+ handler: (call: TotalSupplyCallTrace, ctx: ERC721Context) => void
657
+ ) {
658
+ return super.onTrace("0x18160ddd", handler);
659
+ }
660
+
661
+ onCallBalanceOf(
662
+ handler: (call: BalanceOfCallTrace, ctx: ERC721Context) => void
663
+ ) {
664
+ return super.onTrace("0x70a08231", handler);
665
+ }
666
+
667
+ onCallGetApproved(
668
+ handler: (call: GetApprovedCallTrace, ctx: ERC721Context) => void
669
+ ) {
670
+ return super.onTrace("0x081812fc", handler);
671
+ }
672
+
673
+ onCallIsApprovedForAll(
674
+ handler: (call: IsApprovedForAllCallTrace, ctx: ERC721Context) => void
675
+ ) {
676
+ return super.onTrace("0xe985e9c5", handler);
677
+ }
678
+
679
+ onCallName(handler: (call: NameCallTrace, ctx: ERC721Context) => void) {
680
+ return super.onTrace("0x06fdde03", handler);
681
+ }
682
+
683
+ onCallOwnerOf(handler: (call: OwnerOfCallTrace, ctx: ERC721Context) => void) {
684
+ return super.onTrace("0x6352211e", handler);
685
+ }
686
+
687
+ onCallSafeTransferFrom_address_address_uint256(
688
+ handler: (
689
+ call: SafeTransferFrom_address_address_uint256CallTrace,
690
+ ctx: ERC721Context
691
+ ) => void
692
+ ) {
693
+ return super.onTrace("0x42842e0e", handler);
694
+ }
695
+
696
+ onCallSafeTransferFrom_address_address_uint256_bytes(
697
+ handler: (
698
+ call: SafeTransferFrom_address_address_uint256_bytesCallTrace,
699
+ ctx: ERC721Context
700
+ ) => void
701
+ ) {
702
+ return super.onTrace("0xb88d4fde", handler);
703
+ }
704
+
705
+ onCallSetApprovalForAll(
706
+ handler: (call: SetApprovalForAllCallTrace, ctx: ERC721Context) => void
707
+ ) {
708
+ return super.onTrace("0xa22cb465", handler);
709
+ }
710
+
711
+ onCallSupportsInterface(
712
+ handler: (call: SupportsInterfaceCallTrace, ctx: ERC721Context) => void
713
+ ) {
714
+ return super.onTrace("0x01ffc9a7", handler);
715
+ }
716
+
717
+ onCallSymbol(handler: (call: SymbolCallTrace, ctx: ERC721Context) => void) {
718
+ return super.onTrace("0x95d89b41", handler);
719
+ }
720
+
721
+ onCallTokenURI(
722
+ handler: (call: TokenURICallTrace, ctx: ERC721Context) => void
723
+ ) {
724
+ return super.onTrace("0xc87b56dd", handler);
725
+ }
726
+
727
+ onCallTransferFrom(
728
+ handler: (call: TransferFromCallTrace, ctx: ERC721Context) => void
729
+ ) {
730
+ return super.onTrace("0x23b872dd", handler);
731
+ }
732
+
733
+ public static filters = templateContract.filters;
734
+
735
+ protected CreateBoundContractView(): ERC721BoundContractView {
736
+ const view = getERC721Contract(this.config.address, this.config.network);
737
+ return new ERC721BoundContractView(view);
738
+ }
739
+
740
+ public static bind(options: BindOptions): ERC721Processor {
741
+ if (!options.name) {
742
+ options.name = "ERC721";
743
+ }
744
+ let processor = getProcessor(options) as ERC721Processor;
745
+ if (!processor) {
746
+ processor = new ERC721Processor(options);
747
+ addProcessor(options, processor);
748
+ }
749
+ return processor;
750
+ }
751
+ }
752
+
753
+ export function getERC721Contract(
754
+ address: string,
755
+ network: Networkish = 1
756
+ ): ERC721ContractView {
757
+ let contract = getContractByABI(
758
+ "ERC721",
759
+ address,
760
+ network
761
+ ) as ERC721ContractView;
762
+ if (!contract) {
763
+ const rawContract = ERC721__factory.connect(address, getProvider(network));
764
+ contract = new ERC721ContractView(rawContract);
765
+ addContractByABI("ERC721", address, network, contract);
766
+ }
767
+ return contract;
768
+ }