@sentio/sdk 0.0.5 → 0.0.6
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 +85 -0
- package/dist/cli.js.map +1 -0
- package/dist/context.d.ts +14 -5
- package/dist/context.js +14 -1
- package/dist/context.js.map +1 -1
- package/dist/gen/google/protobuf/empty.js +0 -8
- package/dist/gen/google/protobuf/empty.js.map +1 -1
- package/dist/gen/{model → processor/protos}/processor.d.ts +19 -8
- package/dist/gen/{model → processor/protos}/processor.js +94 -33
- package/dist/gen/processor/protos/processor.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/lib.js +60192 -0
- package/dist/meter.d.ts +6 -10
- package/dist/meter.js +5 -11
- package/dist/meter.js.map +1 -1
- 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 +12 -8
- package/dist/processor.js +39 -25
- package/dist/processor.js.map +1 -1
- package/dist/processor_server.js +2 -2
- package/dist/processor_server.js.LICENSE.txt +9 -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 +1 -1
- package/dist/service.js +25 -18
- package/dist/service.js.map +1 -1
- package/dist/target-ethers-sentio/codegen.js +42 -10
- package/dist/target-ethers-sentio/codegen.js.map +1 -1
- package/dist/test_case/erc20.d.ts +1 -0
- package/dist/test_case/erc20.js +13 -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 +20 -0
- package/dist/test_case/types/erc20_processor.js +50 -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 +17 -14
- package/dist/gen/model/processor.js.map +0 -1
- package/dist/sentio_provider.d.ts +0 -2
- package/dist/sentio_provider.js +0 -8
- package/dist/sentio_provider.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor_server.js","sourceRoot":"","sources":["../src/processor_server.ts"],"names":[],"mappings":";;;;;;AAEA,0EAA+C;AAC/C,yCAAwC;AACxC,gEAAsE;AACtE,uCAAgD;AAChD,yCAAwC;AAExC,SAAS,UAAU,CACjB,IAAY;IAEZ,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAE3B,IAAI;QACF,IAAI,IAAY,CAAA;QAChB,IAAI;YACF,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;SACrD;QAAC,MAAM;YACN,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SACzB;QAED,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QAChD,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAA;QACxC,OAAO,MAAM,CAAA;KACd;IAAC,OAAO,GAAG,EAAE;QACZ,IACE,GA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O,CAAC,IAAI,CAAC,CAAA"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setProvider = exports.getProvider = void 0;
|
|
4
|
+
const providers_1 = require("@ethersproject/providers");
|
|
5
|
+
function getProvider(network) {
|
|
6
|
+
if (!globalThis.SentioProvider) {
|
|
7
|
+
globalThis.SentioProvider = new providers_1.StaticJsonRpcProvider(undefined, network);
|
|
8
|
+
}
|
|
9
|
+
return globalThis.SentioProvider;
|
|
10
|
+
}
|
|
11
|
+
exports.getProvider = getProvider;
|
|
12
|
+
function setProvider(url, network) {
|
|
13
|
+
globalThis.SentioProvider = new providers_1.StaticJsonRpcProvider(url, network);
|
|
14
|
+
return globalThis.SentioProvider;
|
|
15
|
+
}
|
|
16
|
+
exports.setProvider = setProvider;
|
|
17
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;AAAA,wDAA8E;AAG9E,SAAgB,WAAW,CAAC,OAAmB;IAC7C,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE;QAC9B,UAAU,CAAC,cAAc,GAAG,IAAI,iCAAqB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;KAC1E;IACD,OAAO,UAAU,CAAC,cAAc,CAAA;AAClC,CAAC;AALD,kCAKC;AAED,SAAgB,WAAW,CAAC,GAAW,EAAE,OAAmB;IAC1D,UAAU,CAAC,cAAc,GAAG,IAAI,iCAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACnE,OAAO,UAAU,CAAC,cAAc,CAAA;AAClC,CAAC;AAHD,kCAGC"}
|
package/dist/service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CallContext } from 'nice-grpc';
|
|
2
|
-
import { ProcessBlockRequest, ProcessBlockResponse, ProcessConfigRequest, ProcessConfigResponse, ProcessLogRequest, ProcessLogResponse, ProcessorServiceImplementation, ProcessTransactionRequest, ProcessTransactionResponse } from './gen/
|
|
2
|
+
import { ProcessBlockRequest, ProcessBlockResponse, ProcessConfigRequest, ProcessConfigResponse, ProcessLogRequest, ProcessLogResponse, ProcessorServiceImplementation, ProcessTransactionRequest, ProcessTransactionResponse } from './gen/processor/protos/processor';
|
|
3
3
|
import { DeepPartial } from './gen/builtin';
|
|
4
4
|
import { Empty } from './gen/google/protobuf/empty';
|
|
5
5
|
export declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
package/dist/service.js
CHANGED
|
@@ -24,14 +24,16 @@ class ProcessorServiceImpl {
|
|
|
24
24
|
return {};
|
|
25
25
|
}
|
|
26
26
|
for (const processor of globalThis.Processors) {
|
|
27
|
-
const chainId = await processor.contract.provider.getNetwork();
|
|
27
|
+
const chainId = await processor.contract._underlineContract.provider.getNetwork();
|
|
28
28
|
const contractConfig = {
|
|
29
29
|
contract: {
|
|
30
30
|
name: processor.name,
|
|
31
31
|
chainId: chainId.chainId,
|
|
32
|
-
address: processor.contract.address,
|
|
32
|
+
address: processor.contract._underlineContract.address,
|
|
33
|
+
},
|
|
34
|
+
blockConfig: {
|
|
35
|
+
numHandlers: processor.blockHandlers.length,
|
|
33
36
|
},
|
|
34
|
-
blockConfigs: [],
|
|
35
37
|
logConfigs: [],
|
|
36
38
|
startBlock: processor.config.startBlock,
|
|
37
39
|
endBlock: MAX_BLOCK,
|
|
@@ -43,28 +45,34 @@ class ProcessorServiceImpl {
|
|
|
43
45
|
if (processor.config.chunkSize) {
|
|
44
46
|
contractConfig.chunkSize = processor.config.chunkSize;
|
|
45
47
|
}
|
|
46
|
-
processor.eventHandlers
|
|
48
|
+
for (const eventsHandler of processor.eventHandlers) {
|
|
47
49
|
// associate id with filter
|
|
48
|
-
const handlerId = this.eventHandlers.push(handler) - 1;
|
|
50
|
+
const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1;
|
|
49
51
|
const logConfig = {
|
|
50
52
|
handlerId: handlerId,
|
|
51
|
-
|
|
53
|
+
conditions: [],
|
|
52
54
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
for (const ts of filter.topics) {
|
|
57
|
-
let hashes = [];
|
|
58
|
-
if (Array.isArray(ts)) {
|
|
59
|
-
hashes = hashes.concat(ts);
|
|
55
|
+
for (const filter of eventsHandler.filters) {
|
|
56
|
+
if (!filter.topics) {
|
|
57
|
+
throw new Error('Topic should not be null');
|
|
60
58
|
}
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const condition = {
|
|
60
|
+
topics: [],
|
|
61
|
+
};
|
|
62
|
+
for (const ts of filter.topics) {
|
|
63
|
+
let hashes = [];
|
|
64
|
+
if (Array.isArray(ts)) {
|
|
65
|
+
hashes = hashes.concat(ts);
|
|
66
|
+
}
|
|
67
|
+
else if (ts != null) {
|
|
68
|
+
hashes.push(ts);
|
|
69
|
+
}
|
|
70
|
+
condition.topics.push({ hashes: hashes });
|
|
63
71
|
}
|
|
64
|
-
logConfig.
|
|
72
|
+
logConfig.conditions.push(condition);
|
|
65
73
|
}
|
|
66
74
|
contractConfig.logConfigs.push(logConfig);
|
|
67
|
-
}
|
|
75
|
+
}
|
|
68
76
|
this.contractConfigs.push(contractConfig);
|
|
69
77
|
}
|
|
70
78
|
this.started = true;
|
|
@@ -108,7 +116,6 @@ class ProcessorServiceImpl {
|
|
|
108
116
|
if (!this.started) {
|
|
109
117
|
throw new Error('Service Not started.');
|
|
110
118
|
}
|
|
111
|
-
// TODO check decode raw data to block is correct
|
|
112
119
|
if (!request.block) {
|
|
113
120
|
throw new Error("Block can't be empty");
|
|
114
121
|
}
|
package/dist/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"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
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.codeGenSentioFile = void 0;
|
|
4
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");
|
|
5
7
|
function codeGenSentioFile(contract) {
|
|
6
8
|
const source = `
|
|
7
|
-
|
|
9
|
+
class ${contract.name}ContractWrapper extends ContractWrapper<${contract.name}> {
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
class ${contract.name}Processor_ extends BaseProcessor<${contract.name}, ${contract.name}ContractWrapper> {
|
|
24
|
+
bind(address: string, network: Networkish = 1) {
|
|
25
|
+
const contract = ${contract.name}__factory.connect(address, getProvider(network))
|
|
26
|
+
this.contract = new ${contract.name}ContractWrapper(contract);
|
|
12
27
|
return this
|
|
13
28
|
}
|
|
14
29
|
|
|
@@ -18,10 +33,17 @@ function codeGenSentioFile(contract) {
|
|
|
18
33
|
}
|
|
19
34
|
|
|
20
35
|
export const ${contract.name}Processor = new ${contract.name}Processor_("", "${contract.name}")
|
|
21
|
-
|
|
22
36
|
`;
|
|
23
37
|
const imports = (0, typechain_1.createImportsForUsedIdentifiers)({
|
|
24
|
-
|
|
38
|
+
ethers: ['BigNumber', 'BigNumberish', 'BytesLike'],
|
|
39
|
+
'@ethersproject/providers': ['Networkish'],
|
|
40
|
+
'@sentio/sdk': [
|
|
41
|
+
'Context',
|
|
42
|
+
'getProvider',
|
|
43
|
+
'BaseProcessor',
|
|
44
|
+
'ContractWrapper',
|
|
45
|
+
],
|
|
46
|
+
'./common': ['PromiseOrValue'],
|
|
25
47
|
'./index': [`${contract.name}`, `${contract.name}__factory`],
|
|
26
48
|
[`./${contract.name}`]: [].concat(...Object.values(contract.events).flatMap((v) => v.map((e) => [`${e.name}Event`, `${e.name}EventFilter`]))),
|
|
27
49
|
}, source);
|
|
@@ -32,16 +54,26 @@ function generateOnEventFunction(event, contractName) {
|
|
|
32
54
|
return `
|
|
33
55
|
on${event.name}(
|
|
34
56
|
handler: (event: ${event.name}Event, ctx: ${contractName}Context) => void,
|
|
35
|
-
filter?: ${event.name}EventFilter
|
|
36
|
-
) {
|
|
37
|
-
// is there an easier way to do that?
|
|
57
|
+
filter?: ${event.name}EventFilter | ${event.name}EventFilter[]
|
|
58
|
+
): ${contractName}Processor_ {
|
|
38
59
|
if (!filter) {
|
|
39
|
-
// basically just pass this filter into parent class
|
|
40
60
|
filter = this.contract.filters.${event.name}(${event.inputs
|
|
41
61
|
.map(() => 'null')
|
|
42
62
|
.join(',')})
|
|
43
63
|
}
|
|
44
64
|
super.onEvent(handler, filter)
|
|
65
|
+
return this
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
function generateViewFunction(func) {
|
|
70
|
+
return `
|
|
71
|
+
${func.name}(${(0, types_1.generateInputTypes)(func.inputs, { useStructs: true })}) {
|
|
72
|
+
return this.contract.${func.name}(${func.inputs.length > 0
|
|
73
|
+
? func.inputs
|
|
74
|
+
.map((input, index) => input.name || `arg${index}`)
|
|
75
|
+
.join(',') + ','
|
|
76
|
+
: ''} { blockTag: this.block.number })
|
|
45
77
|
}
|
|
46
78
|
`;
|
|
47
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/target-ethers-sentio/codegen.ts"],"names":[],"mappings":";;;AAAA,
|
|
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;;UAEQ,QAAQ,CAAC,IAAI,oCAAoC,QAAQ,CAAC,IAAI,KACpE,QAAQ,CAAC,IACX;;yBAGM,QAAQ,CAAC,IACX;4BACsB,QAAQ,CAAC,IAAI;;;;MAInC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;SAC7B,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,uBAAuB,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;SACvE,IAAI,CAAC,IAAI,CAAC;;;iBAGA,QAAQ,CAAC,IAAI,mBAC1B,QA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C,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 @@
|
|
|
1
|
+
export declare const filter: import("ethers").EventFilter;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
erc20_processor_1.ERC20Processor.bind('0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9').startBlock(14201940);
|
|
6
|
+
exports.filter = erc20_processor_1.ERC20Processor.contract.filters.Transfer('0x0000000000000000000000000000000000000000', '0xb329e39ebefd16f40d38f07643652ce17ca5bac1');
|
|
7
|
+
erc20_processor_1.ERC20Processor.onTransfer(async function handleTransfer(event, ctx) {
|
|
8
|
+
const val = event.args.value.toBigInt() / 10n ** 18n;
|
|
9
|
+
ctx.meter.Counter('c').add(val);
|
|
10
|
+
}, exports.filter).onBlock(async function (block, ctx) {
|
|
11
|
+
ctx.meter.Histogram('h1').record(1, { k: 'v' });
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=erc20.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../src/test_case/erc20.ts"],"names":[],"mappings":";;;AAAA,6DAAsE;AAKtE,gCAAc,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC,UAAU,CAC1E,QAAQ,CACT,CAAA;AAEY,QAAA,MAAM,GAAG,gCAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAC5D,4CAA4C,EAC5C,4CAA4C,CAC7C,CAAA;AAED,gCAAc,CAAC,UAAU,CAAC,KAAK,UAAU,cAAc,CACrD,KAAoB,EACpB,GAAiB;IAEjB,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,GAAG,CAAA;IACpD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACjC,CAAC,EACD,cAAM,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,KAAY,EAAE,GAAiB;IAC7D,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;AACjD,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,20 @@
|
|
|
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
|
+
declare class ERC20Processor_ extends BaseProcessor<ERC20, ERC20ContractWrapper> {
|
|
15
|
+
bind(address: string, network?: Networkish): this;
|
|
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
|
+
}
|
|
19
|
+
export declare const ERC20Processor: ERC20Processor_;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Autogenerated file. Do not edit manually. */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ERC20Processor = void 0;
|
|
7
|
+
const sdk_1 = require("@sentio/sdk");
|
|
8
|
+
const index_1 = require("./index");
|
|
9
|
+
class ERC20ContractWrapper extends sdk_1.ContractWrapper {
|
|
10
|
+
constructor(contract) {
|
|
11
|
+
super(contract);
|
|
12
|
+
}
|
|
13
|
+
allowance(owner, spender) {
|
|
14
|
+
return this.contract.allowance(owner, spender, {
|
|
15
|
+
blockTag: this.block.number,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
balanceOf(account) {
|
|
19
|
+
return this.contract.balanceOf(account, { blockTag: this.block.number });
|
|
20
|
+
}
|
|
21
|
+
decimals() {
|
|
22
|
+
return this.contract.decimals({ blockTag: this.block.number });
|
|
23
|
+
}
|
|
24
|
+
totalSupply() {
|
|
25
|
+
return this.contract.totalSupply({ blockTag: this.block.number });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
class ERC20Processor_ extends sdk_1.BaseProcessor {
|
|
29
|
+
bind(address, network = 1) {
|
|
30
|
+
const contract = index_1.ERC20__factory.connect(address, (0, sdk_1.getProvider)(network));
|
|
31
|
+
this.contract = new ERC20ContractWrapper(contract);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
onApproval(handler, filter) {
|
|
35
|
+
if (!filter) {
|
|
36
|
+
filter = this.contract.filters.Approval(null, null, null);
|
|
37
|
+
}
|
|
38
|
+
super.onEvent(handler, filter);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
onTransfer(handler, filter) {
|
|
42
|
+
if (!filter) {
|
|
43
|
+
filter = this.contract.filters.Transfer(null, null, null);
|
|
44
|
+
}
|
|
45
|
+
super.onEvent(handler, filter);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ERC20Processor = new ERC20Processor_("", "ERC20");
|
|
50
|
+
//# sourceMappingURL=erc20_processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc20_processor.js","sourceRoot":"","sources":["../../../src/test_case/types/erc20_processor.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,oBAAoB;AACpB,oBAAoB;;;AAGpB,qCAKqB;AAErB,mCAAgD;AAOhD,MAAM,oBAAqB,SAAQ,qBAAsB;IACvD,YAAY,QAAe;QACzB,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAED,SA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D,MAAoD;QAEpD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;SAC3D;QACD,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAEY,QAAA,cAAc,GAAG,IAAI,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import type { Provider } from "@ethersproject/providers";
|
|
3
|
+
import type { ERC20, ERC20Interface } from "../ERC20";
|
|
4
|
+
export declare class ERC20__factory {
|
|
5
|
+
static readonly abi: ({
|
|
6
|
+
anonymous: boolean;
|
|
7
|
+
inputs: {
|
|
8
|
+
indexed: boolean;
|
|
9
|
+
internalType: string;
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
}[];
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
outputs?: undefined;
|
|
16
|
+
stateMutability?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
inputs: {
|
|
19
|
+
internalType: string;
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}[];
|
|
23
|
+
name: string;
|
|
24
|
+
outputs: {
|
|
25
|
+
internalType: string;
|
|
26
|
+
name: string;
|
|
27
|
+
type: string;
|
|
28
|
+
}[];
|
|
29
|
+
stateMutability: string;
|
|
30
|
+
type: string;
|
|
31
|
+
anonymous?: undefined;
|
|
32
|
+
})[];
|
|
33
|
+
static createInterface(): ERC20Interface;
|
|
34
|
+
static connect(address: string, signerOrProvider: Signer | Provider): ERC20;
|
|
35
|
+
}
|