@sentio/sdk 0.0.16 → 0.0.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/cli.d.ts +2 -0
- package/dist/cli.js +196 -0
- package/dist/cli.js.map +1 -0
- package/dist/context.d.ts +23 -0
- package/dist/context.js +35 -0
- package/dist/context.js.map +1 -0
- package/dist/gen/builtin.d.ts +6 -0
- package/dist/gen/builtin.js +3 -0
- package/dist/gen/builtin.js.map +1 -0
- package/dist/gen/google/protobuf/empty.d.ts +16 -0
- package/dist/gen/google/protobuf/empty.js +70 -0
- package/dist/gen/google/protobuf/empty.js.map +1 -0
- package/dist/gen/processor/protos/processor.d.ts +443 -0
- package/dist/gen/processor/protos/processor.js +1713 -0
- package/dist/gen/processor/protos/processor.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/meter.d.ts +25 -0
- package/dist/meter.js +98 -0
- package/dist/meter.js.map +1 -0
- package/dist/numberish.d.ts +3 -0
- package/dist/numberish.js +12 -0
- package/dist/numberish.js.map +1 -0
- package/dist/processor.d.ts +34 -0
- package/dist/processor.js +109 -0
- package/dist/processor.js.map +1 -0
- package/dist/processor_server.d.ts +2 -0
- package/dist/processor_server.js +61 -0
- package/dist/processor_server.js.map +1 -0
- package/dist/provider.d.ts +4 -0
- package/dist/provider.js +17 -0
- package/dist/provider.js.map +1 -0
- package/dist/service.d.ts +18 -0
- package/dist/service.js +203 -0
- package/dist/service.js.map +1 -0
- package/dist/target-ethers-sentio/codegen.d.ts +2 -0
- package/dist/target-ethers-sentio/codegen.js +85 -0
- package/dist/target-ethers-sentio/codegen.js.map +1 -0
- package/dist/target-ethers-sentio/index.d.ts +5 -0
- package/dist/target-ethers-sentio/index.js +33 -0
- package/dist/target-ethers-sentio/index.js.map +1 -0
- package/dist/test_case/erc20.d.ts +1 -0
- package/dist/test_case/erc20.js +22 -0
- package/dist/test_case/erc20.js.map +1 -0
- package/dist/test_case/types/ERC20.d.ts +150 -0
- package/dist/test_case/types/ERC20.js +3 -0
- package/dist/test_case/types/ERC20.js.map +1 -0
- package/dist/test_case/types/common.d.ts +22 -0
- package/dist/test_case/types/common.js +3 -0
- package/dist/test_case/types/common.js.map +1 -0
- package/dist/test_case/types/erc20_processor.d.ts +27 -0
- package/dist/test_case/types/erc20_processor.js +54 -0
- package/dist/test_case/types/erc20_processor.js.map +1 -0
- package/dist/test_case/types/factories/ERC20__factory.d.ts +35 -0
- package/dist/test_case/types/factories/ERC20__factory.js +216 -0
- package/dist/test_case/types/factories/ERC20__factory.js.map +1 -0
- package/dist/test_case/types/factories/index.d.ts +1 -0
- package/dist/test_case/types/factories/index.js +9 -0
- package/dist/test_case/types/factories/index.js.map +1 -0
- package/dist/test_case/types/index.d.ts +3 -0
- package/dist/test_case/types/index.js +30 -0
- package/dist/test_case/types/index.js.map +1 -0
- package/package.json +5 -5
package/dist/service.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProcessorServiceImpl = void 0;
|
|
7
|
+
const long_1 = __importDefault(require("long"));
|
|
8
|
+
const MAX_BLOCK = new long_1.default(0);
|
|
9
|
+
class ProcessorServiceImpl {
|
|
10
|
+
eventHandlers = [];
|
|
11
|
+
blockHandlers = new Map();
|
|
12
|
+
started = false;
|
|
13
|
+
contractConfigs = [];
|
|
14
|
+
shutdownHandler;
|
|
15
|
+
constructor(shutdownHandler) {
|
|
16
|
+
this.shutdownHandler = shutdownHandler;
|
|
17
|
+
}
|
|
18
|
+
async getConfig(request, context) {
|
|
19
|
+
if (!this.started) {
|
|
20
|
+
throw new Error('Service Not started.');
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
// TODO project setting
|
|
24
|
+
contractConfigs: this.contractConfigs,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async start(request, context) {
|
|
28
|
+
if (this.started) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
for (const processor of globalThis.Processors) {
|
|
32
|
+
// Start basic config for contract
|
|
33
|
+
const chainId = processor.network.chainId;
|
|
34
|
+
const contractConfig = {
|
|
35
|
+
contract: {
|
|
36
|
+
name: processor.name,
|
|
37
|
+
chainId: chainId,
|
|
38
|
+
address: processor.contract._underlineContract.address,
|
|
39
|
+
},
|
|
40
|
+
blockConfig: {
|
|
41
|
+
numHandlers: processor.blockHandlers.length,
|
|
42
|
+
},
|
|
43
|
+
logConfigs: [],
|
|
44
|
+
startBlock: processor.config.startBlock,
|
|
45
|
+
endBlock: MAX_BLOCK,
|
|
46
|
+
chunkSize: 1,
|
|
47
|
+
};
|
|
48
|
+
if (processor.config.endBlock) {
|
|
49
|
+
contractConfig.endBlock = processor.config.endBlock;
|
|
50
|
+
}
|
|
51
|
+
if (processor.config.chunkSize) {
|
|
52
|
+
contractConfig.chunkSize = processor.config.chunkSize;
|
|
53
|
+
}
|
|
54
|
+
// Prepare all the event handlers
|
|
55
|
+
for (const eventsHandler of processor.eventHandlers) {
|
|
56
|
+
// associate id with filter
|
|
57
|
+
const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1;
|
|
58
|
+
const logConfig = {
|
|
59
|
+
handlerId: handlerId,
|
|
60
|
+
conditions: [],
|
|
61
|
+
};
|
|
62
|
+
for (const filter of eventsHandler.filters) {
|
|
63
|
+
if (!filter.topics) {
|
|
64
|
+
throw new Error('Topic should not be null');
|
|
65
|
+
}
|
|
66
|
+
const condition = {
|
|
67
|
+
topics: [],
|
|
68
|
+
};
|
|
69
|
+
for (const ts of filter.topics) {
|
|
70
|
+
let hashes = [];
|
|
71
|
+
if (Array.isArray(ts)) {
|
|
72
|
+
hashes = hashes.concat(ts);
|
|
73
|
+
}
|
|
74
|
+
else if (ts != null) {
|
|
75
|
+
hashes.push(ts);
|
|
76
|
+
}
|
|
77
|
+
condition.topics.push({ hashes: hashes });
|
|
78
|
+
}
|
|
79
|
+
logConfig.conditions.push(condition);
|
|
80
|
+
}
|
|
81
|
+
contractConfig.logConfigs.push(logConfig);
|
|
82
|
+
}
|
|
83
|
+
// Prepare all the block handlers
|
|
84
|
+
let handlersForChain = this.blockHandlers.get(chainId);
|
|
85
|
+
if (handlersForChain === undefined) {
|
|
86
|
+
handlersForChain = [];
|
|
87
|
+
this.blockHandlers.set(chainId, handlersForChain);
|
|
88
|
+
}
|
|
89
|
+
for (const blockHandler of processor.blockHandlers) {
|
|
90
|
+
handlersForChain.push(blockHandler);
|
|
91
|
+
}
|
|
92
|
+
// Finish up a contract
|
|
93
|
+
this.contractConfigs.push(contractConfig);
|
|
94
|
+
}
|
|
95
|
+
this.started = true;
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
async stop(request, context) {
|
|
99
|
+
console.log('Server Shutting down in 5 seconds');
|
|
100
|
+
if (this.shutdownHandler) {
|
|
101
|
+
setTimeout(this.shutdownHandler, 5000);
|
|
102
|
+
}
|
|
103
|
+
return {};
|
|
104
|
+
}
|
|
105
|
+
async processLog(request, context) {
|
|
106
|
+
if (!this.started) {
|
|
107
|
+
throw new Error('Service Not started.');
|
|
108
|
+
}
|
|
109
|
+
const resp = {
|
|
110
|
+
histograms: [],
|
|
111
|
+
counters: [],
|
|
112
|
+
};
|
|
113
|
+
for (const l of request.logs) {
|
|
114
|
+
if (!l.log) {
|
|
115
|
+
throw new Error("Log can't be null");
|
|
116
|
+
}
|
|
117
|
+
// const jsonString = Buffer.from(l.log.raw.buffer).toString("utf-8")
|
|
118
|
+
// const jsonString = String.fromCharCode.apply(null, l.log.raw)
|
|
119
|
+
const jsonString = Utf8ArrayToStr(l.log.raw);
|
|
120
|
+
const log = JSON.parse(jsonString);
|
|
121
|
+
const res = await this.eventHandlers[l.handlerId](log);
|
|
122
|
+
resp.counters = resp.counters.concat(res.counters);
|
|
123
|
+
resp.histograms = resp.histograms.concat(res.histograms);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
result: resp,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
async processTransaction(request, context) {
|
|
130
|
+
throw new Error('Function not implemented.');
|
|
131
|
+
}
|
|
132
|
+
async processBlock(request, context) {
|
|
133
|
+
if (!this.started) {
|
|
134
|
+
throw new Error('Service Not started.');
|
|
135
|
+
}
|
|
136
|
+
if (!request.block) {
|
|
137
|
+
throw new Error("Block can't be empty");
|
|
138
|
+
}
|
|
139
|
+
const jsonString = Utf8ArrayToStr(request.block.raw);
|
|
140
|
+
const block = JSON.parse(jsonString);
|
|
141
|
+
const resp = {
|
|
142
|
+
histograms: [],
|
|
143
|
+
counters: [],
|
|
144
|
+
};
|
|
145
|
+
for (const processor of globalThis.Processors) {
|
|
146
|
+
if (long_1.default.fromNumber(block.number) < processor.config.startBlock) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
// TODO maybe do a map and construct in start
|
|
150
|
+
if (processor.network.chainId !== request.chainId) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
for (const handler of processor.blockHandlers) {
|
|
154
|
+
const res = await handler(block);
|
|
155
|
+
resp.counters = resp.counters.concat(res.counters);
|
|
156
|
+
resp.histograms = resp.histograms.concat(res.histograms);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
result: resp,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.ProcessorServiceImpl = ProcessorServiceImpl;
|
|
165
|
+
// https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript
|
|
166
|
+
/* eslint-disable */
|
|
167
|
+
function Utf8ArrayToStr(array) {
|
|
168
|
+
let out, i, len, c;
|
|
169
|
+
let char2, char3;
|
|
170
|
+
out = '';
|
|
171
|
+
len = array.length;
|
|
172
|
+
i = 0;
|
|
173
|
+
while (i < len) {
|
|
174
|
+
c = array[i++];
|
|
175
|
+
switch (c >> 4) {
|
|
176
|
+
case 0:
|
|
177
|
+
case 1:
|
|
178
|
+
case 2:
|
|
179
|
+
case 3:
|
|
180
|
+
case 4:
|
|
181
|
+
case 5:
|
|
182
|
+
case 6:
|
|
183
|
+
case 7:
|
|
184
|
+
// 0xxxxxxx
|
|
185
|
+
out += String.fromCharCode(c);
|
|
186
|
+
break;
|
|
187
|
+
case 12:
|
|
188
|
+
case 13:
|
|
189
|
+
// 110x xxxx 10xx xxxx
|
|
190
|
+
char2 = array[i++];
|
|
191
|
+
out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f));
|
|
192
|
+
break;
|
|
193
|
+
case 14:
|
|
194
|
+
// 1110 xxxx 10xx xxxx 10xx xxxx
|
|
195
|
+
char2 = array[i++];
|
|
196
|
+
char3 = array[i++];
|
|
197
|
+
out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0));
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AAsBA,gDAAuB;AAEvB,MAAM,SAAS,GAAG,IAAI,cAAI,CAAC,CAAC,CAAC,CAAA;AAE7B,MAAa,oBAAoB;IACvB,aAAa,GAA4C,EAAE,CAAA;IAC3D,aAAa,GAAG,IAAI,GAAG,EAG5B,CAAA;IAEK,OAAO,GAAG,KAAK,CAAA;IACf,eAAe,GAAqB,EAAE,CAAA;IAC7B,eAAe,CAAa;IAE7C,YAAY,eAA4B;QACtC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,C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CACxB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CACnE,CAAA;gBACD,MAAK;SACR;KACF;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.codeGenSentioFile = void 0;
|
|
4
|
+
const typechain_1 = require("typechain");
|
|
5
|
+
const reserved_keywords_1 = require("@typechain/ethers-v5/dist/codegen/reserved-keywords");
|
|
6
|
+
const types_1 = require("@typechain/ethers-v5/dist/codegen/types");
|
|
7
|
+
function codeGenSentioFile(contract) {
|
|
8
|
+
const source = `
|
|
9
|
+
class ${contract.name}ContractWrapper extends ContractWrapper<${contract.name}> {
|
|
10
|
+
|
|
11
|
+
constructor (contract: ${contract.name}) {
|
|
12
|
+
super(contract);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
${Object.values(contract.functions)
|
|
16
|
+
.filter((f) => !reserved_keywords_1.reservedKeywords.has(f[0].name))
|
|
17
|
+
.flatMap((v) => v.filter((f) => f.stateMutability == 'view').map(generateViewFunction))
|
|
18
|
+
.join('\n')}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ${contract.name}Context = Context<${contract.name}, ${contract.name}ContractWrapper>
|
|
22
|
+
|
|
23
|
+
export class ${contract.name}Processor extends BaseProcessor<${contract.name}, ${contract.name}ContractWrapper> {
|
|
24
|
+
bindInternal(address: string, network: Networkish = 1) {
|
|
25
|
+
const contract = ${contract.name}__factory.connect(address, getProvider(network))
|
|
26
|
+
return new ${contract.name}ContractWrapper(contract);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
${Object.values(contract.events)
|
|
30
|
+
.flatMap((v) => v.map((e) => generateOnEventFunction(e, contract.name)))
|
|
31
|
+
.join('\n')}
|
|
32
|
+
|
|
33
|
+
private static templateContract = ${contract.name}__factory.connect("", getProvider(1));
|
|
34
|
+
|
|
35
|
+
static filters = ${contract.name}Processor.templateContract.filters;
|
|
36
|
+
|
|
37
|
+
static bind(address: string, network: Networkish = 1, name = "${contract.name}"): ${contract.name}Processor {
|
|
38
|
+
return new ${contract.name}Processor(address, name, network)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
const imports = (0, typechain_1.createImportsForUsedIdentifiers)({
|
|
43
|
+
ethers: ['BigNumber', 'BigNumberish', 'BytesLike'],
|
|
44
|
+
'@ethersproject/providers': ['Networkish'],
|
|
45
|
+
'@sentio/sdk': [
|
|
46
|
+
'Context',
|
|
47
|
+
'getProvider',
|
|
48
|
+
'BaseProcessor',
|
|
49
|
+
'ContractWrapper',
|
|
50
|
+
],
|
|
51
|
+
'./common': ['PromiseOrValue'],
|
|
52
|
+
'./index': [`${contract.name}`, `${contract.name}__factory`],
|
|
53
|
+
[`./${contract.name}`]: [].concat(...Object.values(contract.events).flatMap((v) => v.map((e) => [`${e.name}Event`, `${e.name}EventFilter`]))),
|
|
54
|
+
}, source);
|
|
55
|
+
return imports + source;
|
|
56
|
+
}
|
|
57
|
+
exports.codeGenSentioFile = codeGenSentioFile;
|
|
58
|
+
function generateOnEventFunction(event, contractName) {
|
|
59
|
+
return `
|
|
60
|
+
on${event.name}(
|
|
61
|
+
handler: (event: ${event.name}Event, ctx: ${contractName}Context) => void,
|
|
62
|
+
filter?: ${event.name}EventFilter | ${event.name}EventFilter[]
|
|
63
|
+
): ${contractName}Processor {
|
|
64
|
+
if (!filter) {
|
|
65
|
+
filter = this.contract.filters.${event.name}(${event.inputs
|
|
66
|
+
.map(() => 'null')
|
|
67
|
+
.join(',')})
|
|
68
|
+
}
|
|
69
|
+
super.onEvent(handler, filter)
|
|
70
|
+
return this
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
function generateViewFunction(func) {
|
|
75
|
+
return `
|
|
76
|
+
${func.name}(${(0, types_1.generateInputTypes)(func.inputs, { useStructs: true })}) {
|
|
77
|
+
return this.contract.${func.name}(${func.inputs.length > 0
|
|
78
|
+
? func.inputs
|
|
79
|
+
.map((input, index) => input.name || `arg${index}`)
|
|
80
|
+
.join(',') + ','
|
|
81
|
+
: ''} { blockTag: this.block.number })
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=codegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/target-ethers-sentio/codegen.ts"],"names":[],"mappings":";;;AAAA,yCAKkB;AAElB,2FAAsF;AACtF,mEAA4E;AAE5E,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,MAAM,MAAM,GAAG;UACP,QAAQ,CAAC,IAAI,2CACnB,QAAQ,CAAC,IACX;;6BAE2B,QAAQ,CAAC,IAAI;;;;MAIpC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;SAChC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,oCAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC/C,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CACb,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,CACvE;SACA,IAAI,CAAC,IAAI,CAAC;;;gBAGD,QAAQ,CAAC,IAAI,qBAAqB,QAAQ,CAAC,IAAI,KAC3D,QAAQ,CAAC,IACX;;iBAEe,QAAQ,CAAC,IAAI,mCAC1B,QAAQ,CAAC,IACX,KAAK,QAAQ,CAAC,IAAI;;yBAGZ,QAAQ,CAAC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C9B,KAAuB,EACvB,YAAoB;IAEpB,OAAO;MACH,KAAK,CAAC,IAAI;uBACO,KAAK,CAAC,IAAI,eAAe,YAAY;eAC7C,KAAK,CAAC,IAAI,iBAAiB,KAAK,CAAC,IAAI;OAC7C,YAAY;;uCAEoB,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM;SAC5D,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;SACjB,IAAI,CAAC,GAAG,CAAC;;;;;GAKX,CAAA;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAyB;IACrD,OAAO;IACL,IAAI,CAAC,IAAI,IAAI,IAAA,0BAAkB,EAAC,IAAI,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;2BAC3C,IAAI,CAAC,IAAI,IAChC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;QACpB,CAAC,CAAC,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,KAAK,EAAE,CAAC;aAClD,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG;QACpB,CAAC,CAAC,EACN;;GAEC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ethers_v5_1 = __importDefault(require("@typechain/ethers-v5"));
|
|
7
|
+
const typechain_1 = require("typechain");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const codegen_1 = require("./codegen");
|
|
10
|
+
class EthersSentio extends ethers_v5_1.default {
|
|
11
|
+
// TODO(pc): also have to override transformBinFile, transformFile
|
|
12
|
+
transformAbiOrFullJsonFile(file) {
|
|
13
|
+
const abi = (0, typechain_1.extractAbi)(file.contents);
|
|
14
|
+
if (abi.length === 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const documentation = (0, typechain_1.extractDocumentation)(file.contents);
|
|
18
|
+
const path = (0, path_1.relative)(this.cfg.inputDir, (0, typechain_1.shortenFullJsonFilePath)(file.path, this.cfg.allFiles));
|
|
19
|
+
const contract = (0, typechain_1.parse)(abi, path, documentation);
|
|
20
|
+
const files = super.transformAbiOrFullJsonFile(file);
|
|
21
|
+
if (files != null) {
|
|
22
|
+
return [
|
|
23
|
+
...files,
|
|
24
|
+
{
|
|
25
|
+
path: (0, path_1.join)((0, path_1.dirname)(files[0].path), `${contract.name.toLowerCase()}_processor.ts`),
|
|
26
|
+
contents: (0, codegen_1.codeGenSentioFile)(contract),
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = EthersSentio;
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/target-ethers-sentio/index.ts"],"names":[],"mappings":";;;;;AAAA,qEAAyC;AACzC,yCAMkB;AAClB,+BAA8C;AAC9C,uCAA6C;AAE7C,MAAqB,YAAa,SAAQ,mBAAM;IAC9C,kEAAkE;IACzD,0BAA0B,CACjC,IAAqB;QAErB,MAAM,GAAG,GAAG,IAAA,sBAAU,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,OAAM;SACP;QAED,MAAM,aAAa,GAAG,IAAA,gCAAoB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEzD,MAAM,IAAI,GAAG,IAAA,eAAQ,EACnB,IAAI,CAAC,GAAG,CAAC,QAAQ,EACjB,IAAA,mCAAuB,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CACtD,CAAA;QAED,MAAM,QAAQ,GAAG,IAAA,iBAAK,EAAC,GAAG,EAAE,IAAI,EAAE,aAAa,CAAC,CAAA;QAEhD,MAAM,KAAK,GAAG,KAAK,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAA;QAEpD,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,OAAO;gBACL,GAAG,KAAK;gBACR;oBACE,IAAI,EAAE,IAAA,WAAI,EACR,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EACtB,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAC9C;oBACD,QAAQ,EAAE,IAAA,2BAAiB,EAAC,QAAQ,CAAC;iBACtC;aACF,CAAA;SACF;IACH,CAAC;CACF;AAlCD,+BAkCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const filter: import("./types/ERC20").TransferEventFilter;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filter = void 0;
|
|
4
|
+
const erc20_processor_1 = require("./types/erc20_processor");
|
|
5
|
+
exports.filter = erc20_processor_1.ERC20Processor.filters.Transfer('0x0000000000000000000000000000000000000000', '0xb329e39ebefd16f40d38f07643652ce17ca5bac1');
|
|
6
|
+
erc20_processor_1.ERC20Processor.bind('0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9', 1, 'x2y2')
|
|
7
|
+
.startBlock(14201940)
|
|
8
|
+
.onTransfer(async function (event, ctx) {
|
|
9
|
+
ctx.meter.Counter('c1').add(1);
|
|
10
|
+
}, exports.filter)
|
|
11
|
+
.onBlock(async function (block, ctx) {
|
|
12
|
+
ctx.meter.Histogram('h1').record(10, { k: 'v' });
|
|
13
|
+
});
|
|
14
|
+
erc20_processor_1.ERC20Processor.bind('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 100, 'usdc')
|
|
15
|
+
// .startBlock(14201940)
|
|
16
|
+
.onTransfer(async function (event, ctx) {
|
|
17
|
+
ctx.meter.Counter('c2').add(2);
|
|
18
|
+
}, exports.filter)
|
|
19
|
+
.onBlock(async function (block, ctx) {
|
|
20
|
+
ctx.meter.Histogram('h1').record(20, { k: 'v' });
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=erc20.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../src/test_case/erc20.ts"],"names":[],"mappings":";;;AAAA,6DAAsE;AAEzD,QAAA,MAAM,GAAG,gCAAc,CAAC,OAAO,CAAC,QAAQ,CACnD,4CAA4C,EAC5C,4CAA4C,CAC7C,CAAA;AAED,gCAAc,CAAC,IAAI,CAAC,4CAA4C,EAAE,CAAC,EAAE,MAAM,CAAC;KACzE,UAAU,CAAC,QAAQ,CAAC;KACpB,UAAU,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACpC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC,EAAE,cAAM,CAAC;KACT,OAAO,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACjC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA;AAEJ,gCAAc,CAAC,IAAI,CAAC,4CAA4C,EAAE,GAAG,EAAE,MAAM,CAAC;IAC5E,wBAAwB;KACvB,UAAU,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACpC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC,EAAE,cAAM,CAAC;KACT,OAAO,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACjC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { BaseContract, BigNumber, BigNumberish, BytesLike, CallOverrides, ContractTransaction, Overrides, PopulatedTransaction, Signer, utils } from "ethers";
|
|
2
|
+
import type { FunctionFragment, Result, EventFragment } from "@ethersproject/abi";
|
|
3
|
+
import type { Listener, Provider } from "@ethersproject/providers";
|
|
4
|
+
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent, PromiseOrValue } from "./common";
|
|
5
|
+
export interface ERC20Interface extends utils.Interface {
|
|
6
|
+
functions: {
|
|
7
|
+
"allowance(address,address)": FunctionFragment;
|
|
8
|
+
"approve(address,uint256)": FunctionFragment;
|
|
9
|
+
"balanceOf(address)": FunctionFragment;
|
|
10
|
+
"decimals()": FunctionFragment;
|
|
11
|
+
"totalSupply()": FunctionFragment;
|
|
12
|
+
"transfer(address,uint256)": FunctionFragment;
|
|
13
|
+
"transferFrom(address,address,uint256)": FunctionFragment;
|
|
14
|
+
};
|
|
15
|
+
getFunction(nameOrSignatureOrTopic: "allowance" | "approve" | "balanceOf" | "decimals" | "totalSupply" | "transfer" | "transferFrom"): FunctionFragment;
|
|
16
|
+
encodeFunctionData(functionFragment: "allowance", values: [PromiseOrValue<string>, PromiseOrValue<string>]): string;
|
|
17
|
+
encodeFunctionData(functionFragment: "approve", values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]): string;
|
|
18
|
+
encodeFunctionData(functionFragment: "balanceOf", values: [PromiseOrValue<string>]): string;
|
|
19
|
+
encodeFunctionData(functionFragment: "decimals", values?: undefined): string;
|
|
20
|
+
encodeFunctionData(functionFragment: "totalSupply", values?: undefined): string;
|
|
21
|
+
encodeFunctionData(functionFragment: "transfer", values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]): string;
|
|
22
|
+
encodeFunctionData(functionFragment: "transferFrom", values: [
|
|
23
|
+
PromiseOrValue<string>,
|
|
24
|
+
PromiseOrValue<string>,
|
|
25
|
+
PromiseOrValue<BigNumberish>
|
|
26
|
+
]): string;
|
|
27
|
+
decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result;
|
|
28
|
+
decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result;
|
|
29
|
+
decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result;
|
|
30
|
+
decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result;
|
|
31
|
+
decodeFunctionResult(functionFragment: "totalSupply", data: BytesLike): Result;
|
|
32
|
+
decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result;
|
|
33
|
+
decodeFunctionResult(functionFragment: "transferFrom", data: BytesLike): Result;
|
|
34
|
+
events: {
|
|
35
|
+
"Approval(address,address,uint256)": EventFragment;
|
|
36
|
+
"Transfer(address,address,uint256)": EventFragment;
|
|
37
|
+
};
|
|
38
|
+
getEvent(nameOrSignatureOrTopic: "Approval"): EventFragment;
|
|
39
|
+
getEvent(nameOrSignatureOrTopic: "Transfer"): EventFragment;
|
|
40
|
+
}
|
|
41
|
+
export interface ApprovalEventObject {
|
|
42
|
+
owner: string;
|
|
43
|
+
spender: string;
|
|
44
|
+
value: BigNumber;
|
|
45
|
+
}
|
|
46
|
+
export declare type ApprovalEvent = TypedEvent<[
|
|
47
|
+
string,
|
|
48
|
+
string,
|
|
49
|
+
BigNumber
|
|
50
|
+
], ApprovalEventObject>;
|
|
51
|
+
export declare type ApprovalEventFilter = TypedEventFilter<ApprovalEvent>;
|
|
52
|
+
export interface TransferEventObject {
|
|
53
|
+
from: string;
|
|
54
|
+
to: string;
|
|
55
|
+
value: BigNumber;
|
|
56
|
+
}
|
|
57
|
+
export declare type TransferEvent = TypedEvent<[
|
|
58
|
+
string,
|
|
59
|
+
string,
|
|
60
|
+
BigNumber
|
|
61
|
+
], TransferEventObject>;
|
|
62
|
+
export declare type TransferEventFilter = TypedEventFilter<TransferEvent>;
|
|
63
|
+
export interface ERC20 extends BaseContract {
|
|
64
|
+
connect(signerOrProvider: Signer | Provider | string): this;
|
|
65
|
+
attach(addressOrName: string): this;
|
|
66
|
+
deployed(): Promise<this>;
|
|
67
|
+
interface: ERC20Interface;
|
|
68
|
+
queryFilter<TEvent extends TypedEvent>(event: TypedEventFilter<TEvent>, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TEvent>>;
|
|
69
|
+
listeners<TEvent extends TypedEvent>(eventFilter?: TypedEventFilter<TEvent>): Array<TypedListener<TEvent>>;
|
|
70
|
+
listeners(eventName?: string): Array<Listener>;
|
|
71
|
+
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this;
|
|
72
|
+
removeAllListeners(eventName?: string): this;
|
|
73
|
+
off: OnEvent<this>;
|
|
74
|
+
on: OnEvent<this>;
|
|
75
|
+
once: OnEvent<this>;
|
|
76
|
+
removeListener: OnEvent<this>;
|
|
77
|
+
functions: {
|
|
78
|
+
allowance(owner: PromiseOrValue<string>, spender: PromiseOrValue<string>, overrides?: CallOverrides): Promise<[BigNumber]>;
|
|
79
|
+
approve(spender: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
80
|
+
from?: PromiseOrValue<string>;
|
|
81
|
+
}): Promise<ContractTransaction>;
|
|
82
|
+
balanceOf(account: PromiseOrValue<string>, overrides?: CallOverrides): Promise<[BigNumber]>;
|
|
83
|
+
decimals(overrides?: CallOverrides): Promise<[number]>;
|
|
84
|
+
totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>;
|
|
85
|
+
transfer(to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
86
|
+
from?: PromiseOrValue<string>;
|
|
87
|
+
}): Promise<ContractTransaction>;
|
|
88
|
+
transferFrom(from: PromiseOrValue<string>, to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
89
|
+
from?: PromiseOrValue<string>;
|
|
90
|
+
}): Promise<ContractTransaction>;
|
|
91
|
+
};
|
|
92
|
+
allowance(owner: PromiseOrValue<string>, spender: PromiseOrValue<string>, overrides?: CallOverrides): Promise<BigNumber>;
|
|
93
|
+
approve(spender: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
94
|
+
from?: PromiseOrValue<string>;
|
|
95
|
+
}): Promise<ContractTransaction>;
|
|
96
|
+
balanceOf(account: PromiseOrValue<string>, overrides?: CallOverrides): Promise<BigNumber>;
|
|
97
|
+
decimals(overrides?: CallOverrides): Promise<number>;
|
|
98
|
+
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
|
|
99
|
+
transfer(to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
100
|
+
from?: PromiseOrValue<string>;
|
|
101
|
+
}): Promise<ContractTransaction>;
|
|
102
|
+
transferFrom(from: PromiseOrValue<string>, to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
103
|
+
from?: PromiseOrValue<string>;
|
|
104
|
+
}): Promise<ContractTransaction>;
|
|
105
|
+
callStatic: {
|
|
106
|
+
allowance(owner: PromiseOrValue<string>, spender: PromiseOrValue<string>, overrides?: CallOverrides): Promise<BigNumber>;
|
|
107
|
+
approve(spender: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: CallOverrides): Promise<boolean>;
|
|
108
|
+
balanceOf(account: PromiseOrValue<string>, overrides?: CallOverrides): Promise<BigNumber>;
|
|
109
|
+
decimals(overrides?: CallOverrides): Promise<number>;
|
|
110
|
+
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
|
|
111
|
+
transfer(to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: CallOverrides): Promise<boolean>;
|
|
112
|
+
transferFrom(from: PromiseOrValue<string>, to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: CallOverrides): Promise<boolean>;
|
|
113
|
+
};
|
|
114
|
+
filters: {
|
|
115
|
+
"Approval(address,address,uint256)"(owner?: PromiseOrValue<string> | null, spender?: PromiseOrValue<string> | null, value?: null): ApprovalEventFilter;
|
|
116
|
+
Approval(owner?: PromiseOrValue<string> | null, spender?: PromiseOrValue<string> | null, value?: null): ApprovalEventFilter;
|
|
117
|
+
"Transfer(address,address,uint256)"(from?: PromiseOrValue<string> | null, to?: PromiseOrValue<string> | null, value?: null): TransferEventFilter;
|
|
118
|
+
Transfer(from?: PromiseOrValue<string> | null, to?: PromiseOrValue<string> | null, value?: null): TransferEventFilter;
|
|
119
|
+
};
|
|
120
|
+
estimateGas: {
|
|
121
|
+
allowance(owner: PromiseOrValue<string>, spender: PromiseOrValue<string>, overrides?: CallOverrides): Promise<BigNumber>;
|
|
122
|
+
approve(spender: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
123
|
+
from?: PromiseOrValue<string>;
|
|
124
|
+
}): Promise<BigNumber>;
|
|
125
|
+
balanceOf(account: PromiseOrValue<string>, overrides?: CallOverrides): Promise<BigNumber>;
|
|
126
|
+
decimals(overrides?: CallOverrides): Promise<BigNumber>;
|
|
127
|
+
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
|
|
128
|
+
transfer(to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
129
|
+
from?: PromiseOrValue<string>;
|
|
130
|
+
}): Promise<BigNumber>;
|
|
131
|
+
transferFrom(from: PromiseOrValue<string>, to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
132
|
+
from?: PromiseOrValue<string>;
|
|
133
|
+
}): Promise<BigNumber>;
|
|
134
|
+
};
|
|
135
|
+
populateTransaction: {
|
|
136
|
+
allowance(owner: PromiseOrValue<string>, spender: PromiseOrValue<string>, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
137
|
+
approve(spender: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
138
|
+
from?: PromiseOrValue<string>;
|
|
139
|
+
}): Promise<PopulatedTransaction>;
|
|
140
|
+
balanceOf(account: PromiseOrValue<string>, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
141
|
+
decimals(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
142
|
+
totalSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
143
|
+
transfer(to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
144
|
+
from?: PromiseOrValue<string>;
|
|
145
|
+
}): Promise<PopulatedTransaction>;
|
|
146
|
+
transferFrom(from: PromiseOrValue<string>, to: PromiseOrValue<string>, amount: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
147
|
+
from?: PromiseOrValue<string>;
|
|
148
|
+
}): Promise<PopulatedTransaction>;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERC20.js","sourceRoot":"","sources":["../../../src/test_case/types/ERC20.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Listener } from "@ethersproject/providers";
|
|
2
|
+
import type { Event, EventFilter } from "ethers";
|
|
3
|
+
export interface TypedEvent<TArgsArray extends Array<any> = any, TArgsObject = any> extends Event {
|
|
4
|
+
args: TArgsArray & TArgsObject;
|
|
5
|
+
}
|
|
6
|
+
export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {
|
|
7
|
+
}
|
|
8
|
+
export interface TypedListener<TEvent extends TypedEvent> {
|
|
9
|
+
(...listenerArg: [...__TypechainArgsArray<TEvent>, TEvent]): void;
|
|
10
|
+
}
|
|
11
|
+
declare type __TypechainArgsArray<T> = T extends TypedEvent<infer U> ? U : never;
|
|
12
|
+
export interface OnEvent<TRes> {
|
|
13
|
+
<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>, listener: TypedListener<TEvent>): TRes;
|
|
14
|
+
(eventName: string, listener: Listener): TRes;
|
|
15
|
+
}
|
|
16
|
+
export declare type MinEthersFactory<C, ARGS> = {
|
|
17
|
+
deploy(...a: ARGS[]): Promise<C>;
|
|
18
|
+
};
|
|
19
|
+
export declare type GetContractTypeFromFactory<F> = F extends MinEthersFactory<infer C, any> ? C : never;
|
|
20
|
+
export declare type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any> ? Parameters<F["deploy"]> : never;
|
|
21
|
+
export declare type PromiseOrValue<T> = T | Promise<T>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/test_case/types/common.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Networkish } from "@ethersproject/providers";
|
|
2
|
+
import { Context, BaseProcessor, ContractWrapper } from "@sentio/sdk";
|
|
3
|
+
import { PromiseOrValue } from "./common";
|
|
4
|
+
import { ERC20 } from "./index";
|
|
5
|
+
import { ApprovalEvent, ApprovalEventFilter, TransferEvent, TransferEventFilter } from "./ERC20";
|
|
6
|
+
declare class ERC20ContractWrapper extends ContractWrapper<ERC20> {
|
|
7
|
+
constructor(contract: ERC20);
|
|
8
|
+
allowance(owner: PromiseOrValue<string>, spender: PromiseOrValue<string>): Promise<import("ethers").BigNumber>;
|
|
9
|
+
balanceOf(account: PromiseOrValue<string>): Promise<import("ethers").BigNumber>;
|
|
10
|
+
decimals(): Promise<number>;
|
|
11
|
+
totalSupply(): Promise<import("ethers").BigNumber>;
|
|
12
|
+
}
|
|
13
|
+
export declare type ERC20Context = Context<ERC20, ERC20ContractWrapper>;
|
|
14
|
+
export declare class ERC20Processor extends BaseProcessor<ERC20, ERC20ContractWrapper> {
|
|
15
|
+
bindInternal(address: string, network?: Networkish): ERC20ContractWrapper;
|
|
16
|
+
onApproval(handler: (event: ApprovalEvent, ctx: ERC20Context) => void, filter?: ApprovalEventFilter | ApprovalEventFilter[]): ERC20Processor;
|
|
17
|
+
onTransfer(handler: (event: TransferEvent, ctx: ERC20Context) => void, filter?: TransferEventFilter | TransferEventFilter[]): ERC20Processor;
|
|
18
|
+
private static templateContract;
|
|
19
|
+
static filters: {
|
|
20
|
+
"Approval(address,address,uint256)"(owner?: PromiseOrValue<string> | null | undefined, spender?: PromiseOrValue<string> | null | undefined, value?: null | undefined): ApprovalEventFilter;
|
|
21
|
+
Approval(owner?: PromiseOrValue<string> | null | undefined, spender?: PromiseOrValue<string> | null | undefined, value?: null | undefined): ApprovalEventFilter;
|
|
22
|
+
"Transfer(address,address,uint256)"(from?: PromiseOrValue<string> | null | undefined, to?: PromiseOrValue<string> | null | undefined, value?: null | undefined): TransferEventFilter;
|
|
23
|
+
Transfer(from?: PromiseOrValue<string> | null | undefined, to?: PromiseOrValue<string> | null | undefined, value?: null | undefined): TransferEventFilter;
|
|
24
|
+
};
|
|
25
|
+
static bind(address: string, network?: Networkish, name?: string): ERC20Processor;
|
|
26
|
+
}
|
|
27
|
+
export {};
|