@sentio/sdk 0.6.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/base-processor-template.d.ts +20 -0
  2. package/dist/base-processor-template.js +75 -0
  3. package/dist/base-processor-template.js.map +1 -0
  4. package/dist/base-processor.d.ts +22 -0
  5. package/dist/base-processor.js +103 -0
  6. package/dist/base-processor.js.map +1 -0
  7. package/dist/bind-options.d.ts +17 -0
  8. package/dist/bind-options.js +38 -0
  9. package/dist/bind-options.js.map +1 -0
  10. package/dist/binds.d.ts +10 -0
  11. package/dist/binds.js +58 -0
  12. package/dist/binds.js.map +1 -0
  13. package/dist/builtin/erc20/index.d.ts +2 -0
  14. package/dist/builtin/erc20/index.js +22 -0
  15. package/dist/builtin/erc20/index.js.map +1 -0
  16. package/dist/builtin/internal/Erc20.d.ts +150 -0
  17. package/dist/builtin/internal/Erc20.js +3 -0
  18. package/dist/builtin/internal/Erc20.js.map +1 -0
  19. package/dist/builtin/internal/common.d.ts +22 -0
  20. package/dist/builtin/internal/common.js +3 -0
  21. package/dist/builtin/internal/common.js.map +1 -0
  22. package/dist/builtin/internal/erc20_processor.d.ts +38 -0
  23. package/dist/builtin/internal/erc20_processor.js +209 -0
  24. package/dist/builtin/internal/erc20_processor.js.map +1 -0
  25. package/dist/builtin/internal/factories/Erc20__factory.d.ts +35 -0
  26. package/dist/builtin/internal/factories/Erc20__factory.js +216 -0
  27. package/dist/builtin/internal/factories/Erc20__factory.js.map +1 -0
  28. package/dist/builtin/internal/factories/index.d.ts +1 -0
  29. package/dist/builtin/internal/factories/index.js +9 -0
  30. package/dist/builtin/internal/factories/index.js.map +1 -0
  31. package/dist/builtin/internal/index.d.ts +3 -0
  32. package/dist/builtin/internal/index.js +30 -0
  33. package/dist/builtin/internal/index.js.map +1 -0
  34. package/dist/cli/build.d.ts +3 -0
  35. package/dist/cli/build.js +161 -0
  36. package/dist/cli/build.js.map +1 -0
  37. package/dist/cli/cli.d.ts +2 -0
  38. package/dist/cli/cli.js +212 -0
  39. package/dist/cli/cli.js.map +1 -0
  40. package/dist/cli/config.d.ts +14 -0
  41. package/dist/cli/config.js +24 -0
  42. package/dist/cli/config.js.map +1 -0
  43. package/dist/cli/key.d.ts +2 -0
  44. package/dist/cli/key.js +44 -0
  45. package/dist/cli/key.js.map +1 -0
  46. package/dist/cli/solana-code-gen.d.ts +2 -0
  47. package/dist/cli/solana-code-gen.js +19 -0
  48. package/dist/cli/solana-code-gen.js.map +1 -0
  49. package/dist/cli/upload.d.ts +2 -0
  50. package/dist/cli/upload.js +76 -0
  51. package/dist/cli/upload.js.map +1 -0
  52. package/dist/cli/webpack.config.js +41 -0
  53. package/dist/context.d.ts +39 -0
  54. package/dist/context.js +75 -0
  55. package/dist/context.js.map +1 -0
  56. package/dist/contract-namer.d.ts +6 -0
  57. package/dist/contract-namer.js +20 -0
  58. package/dist/contract-namer.js.map +1 -0
  59. package/dist/error.d.ts +2 -0
  60. package/dist/error.js +39 -0
  61. package/dist/error.js.map +1 -0
  62. package/dist/gen/builtin.d.ts +6 -0
  63. package/dist/gen/builtin.js +3 -0
  64. package/dist/gen/builtin.js.map +1 -0
  65. package/dist/gen/google/protobuf/empty.d.ts +16 -0
  66. package/dist/gen/google/protobuf/empty.js +47 -0
  67. package/dist/gen/google/protobuf/empty.js.map +1 -0
  68. package/dist/gen/processor/protos/processor.d.ts +598 -0
  69. package/dist/gen/processor/protos/processor.js +2424 -0
  70. package/dist/gen/processor/protos/processor.js.map +1 -0
  71. package/dist/index.d.ts +13 -0
  72. package/dist/index.js +54 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/meter.d.ts +25 -0
  75. package/dist/meter.js +114 -0
  76. package/dist/meter.js.map +1 -0
  77. package/dist/numberish.d.ts +7 -0
  78. package/dist/numberish.js +74 -0
  79. package/dist/numberish.js.map +1 -0
  80. package/dist/numberish.test.d.ts +1 -0
  81. package/dist/numberish.test.js +54 -0
  82. package/dist/numberish.test.js.map +1 -0
  83. package/dist/processor-runner.d.ts +2 -0
  84. package/dist/processor-runner.js +67 -0
  85. package/dist/processor-runner.js.map +1 -0
  86. package/dist/processor-state.d.ts +16 -0
  87. package/dist/processor-state.js +20 -0
  88. package/dist/processor-state.js.map +1 -0
  89. package/dist/provider.d.ts +5 -0
  90. package/dist/provider.js +56 -0
  91. package/dist/provider.js.map +1 -0
  92. package/dist/service.d.ts +22 -0
  93. package/dist/service.js +361 -0
  94. package/dist/service.js.map +1 -0
  95. package/dist/solana/builtin/spl-token-processor.d.ts +25 -0
  96. package/dist/solana/builtin/spl-token-processor.js +152 -0
  97. package/dist/solana/builtin/spl-token-processor.js.map +1 -0
  98. package/dist/solana-processor.d.ts +28 -0
  99. package/dist/solana-processor.js +79 -0
  100. package/dist/solana-processor.js.map +1 -0
  101. package/dist/target-ethers-sentio/codegen.d.ts +3 -0
  102. package/dist/target-ethers-sentio/codegen.js +201 -0
  103. package/dist/target-ethers-sentio/codegen.js.map +1 -0
  104. package/dist/target-ethers-sentio/index.d.ts +6 -0
  105. package/dist/target-ethers-sentio/index.js +47 -0
  106. package/dist/target-ethers-sentio/index.js.map +1 -0
  107. package/dist/test-case/clean-test.d.ts +1 -0
  108. package/dist/test-case/clean-test.js +9 -0
  109. package/dist/test-case/clean-test.js.map +1 -0
  110. package/dist/test-case/erc20-template.d.ts +1 -0
  111. package/dist/test-case/erc20-template.js +23 -0
  112. package/dist/test-case/erc20-template.js.map +1 -0
  113. package/dist/test-case/erc20-template.test.d.ts +1 -0
  114. package/dist/test-case/erc20-template.test.js +69 -0
  115. package/dist/test-case/erc20-template.test.js.map +1 -0
  116. package/dist/test-case/erc20.d.ts +1 -0
  117. package/dist/test-case/erc20.js +42 -0
  118. package/dist/test-case/erc20.js.map +1 -0
  119. package/dist/test-case/erc20.test.d.ts +1 -0
  120. package/dist/test-case/erc20.test.js +154 -0
  121. package/dist/test-case/erc20.test.js.map +1 -0
  122. package/dist/test-case/mirrorworld.d.ts +1 -0
  123. package/dist/test-case/mirrorworld.js +42 -0
  124. package/dist/test-case/mirrorworld.js.map +1 -0
  125. package/dist/test-case/solana.test.d.ts +1 -0
  126. package/dist/test-case/solana.test.js +58 -0
  127. package/dist/test-case/solana.test.js.map +1 -0
  128. package/dist/test-case/types/game_wallet.d.ts +45 -0
  129. package/dist/test-case/types/game_wallet.js +1396 -0
  130. package/dist/test-case/types/game_wallet.js.map +1 -0
  131. package/dist/test-case/types/game_wallet_processor.d.ts +107 -0
  132. package/dist/test-case/types/game_wallet_processor.js +102 -0
  133. package/dist/test-case/types/game_wallet_processor.js.map +1 -0
  134. package/dist/test-case/types/wormhole_processor.d.ts +16 -0
  135. package/dist/test-case/types/wormhole_processor.js +192 -0
  136. package/dist/test-case/types/wormhole_processor.js.map +1 -0
  137. package/dist/test-case/wormhole-token-bridge.d.ts +1 -0
  138. package/dist/test-case/wormhole-token-bridge.js +7 -0
  139. package/dist/test-case/wormhole-token-bridge.js.map +1 -0
  140. package/dist/utils/chainmap.d.ts +4 -0
  141. package/dist/utils/chainmap.js +95 -0
  142. package/dist/utils/chainmap.js.map +1 -0
  143. package/dist/utils/index.d.ts +1 -0
  144. package/dist/utils/index.js +6 -0
  145. package/dist/utils/index.js.map +1 -0
  146. package/package.json +4 -2
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SPLTokenProcessor = void 0;
4
+ const solana_processor_1 = require("solana-processor");
5
+ const spl_token_1 = require("@solana/spl-token");
6
+ class SPLTokenProcessor extends solana_processor_1.SolanaBaseProcessor {
7
+ TokenInstructionMapCache = new Map();
8
+ static bind(address, endpoint, name = 'Token Program') {
9
+ return new SPLTokenProcessor(name, address, endpoint);
10
+ }
11
+ fromParsedInstruction = (instruction) => {
12
+ const instructionType = instruction.parsed.type;
13
+ if (!instructionType || !this.instructionTypeToTokenInstruction(instructionType)) {
14
+ return null;
15
+ }
16
+ return {
17
+ name: instruction.parsed.type,
18
+ data: {
19
+ instruction: this.instructionTypeToTokenInstruction(instructionType),
20
+ ...instruction.parsed.info,
21
+ },
22
+ };
23
+ };
24
+ onInitializeMint(handler) {
25
+ this.onInstruction('initializeMint', (ins, ctx) => {
26
+ if (ins) {
27
+ handler(ins.data, ctx);
28
+ }
29
+ });
30
+ return this;
31
+ }
32
+ onInitializeAccount(hanlder) {
33
+ this.onInstruction('initializeAccount', (ins, ctx) => {
34
+ if (ins) {
35
+ hanlder(ins.data, ctx);
36
+ }
37
+ });
38
+ return this;
39
+ }
40
+ onInitializeAccount2(hanlder) {
41
+ this.onInstruction('initializeAccount2', (ins, ctx) => {
42
+ if (ins) {
43
+ hanlder(ins.data, ctx);
44
+ }
45
+ });
46
+ return this;
47
+ }
48
+ onInitializeAccount3(hanlder) {
49
+ this.onInstruction('initializeAccount3', (ins, ctx) => {
50
+ if (ins) {
51
+ hanlder(ins.data, ctx);
52
+ }
53
+ });
54
+ return this;
55
+ }
56
+ onInitializeMultisig(handler) {
57
+ this.onInstruction('initializeMultisig', (ins, ctx) => {
58
+ if (ins) {
59
+ handler(ins.data, ctx);
60
+ }
61
+ });
62
+ return this;
63
+ }
64
+ onTransfer(handler) {
65
+ this.onInstruction('transfer', (ins, ctx) => {
66
+ if (ins) {
67
+ handler(ins.data, ctx);
68
+ }
69
+ });
70
+ return this;
71
+ }
72
+ onApprovend(handler) {
73
+ this.onInstruction('approve', (ins, ctx) => {
74
+ if (ins) {
75
+ handler(ins.data, ctx);
76
+ }
77
+ });
78
+ return this;
79
+ }
80
+ onRevoke(handler) {
81
+ this.onInstruction('revoke', (ins, ctx) => {
82
+ if (ins) {
83
+ handler(ins.data, ctx);
84
+ }
85
+ });
86
+ return this;
87
+ }
88
+ onSetAuthority(handler) {
89
+ this.onInstruction('setAuthority', (ins, ctx) => {
90
+ if (ins) {
91
+ handler(ins.data, ctx);
92
+ }
93
+ });
94
+ return this;
95
+ }
96
+ onMintTo(handler) {
97
+ this.onInstruction('mintTo', (ins, ctx) => {
98
+ if (ins) {
99
+ handler(ins.data, ctx);
100
+ }
101
+ });
102
+ return this;
103
+ }
104
+ onBurn(handler) {
105
+ this.onInstruction('burn', (ins, ctx) => {
106
+ if (ins) {
107
+ handler(ins.data, ctx);
108
+ }
109
+ });
110
+ return this;
111
+ }
112
+ onCloseAccount(handler) {
113
+ this.onInstruction('closeAccount', (ins, ctx) => {
114
+ if (ins) {
115
+ handler(ins.data, ctx);
116
+ }
117
+ });
118
+ return this;
119
+ }
120
+ onFreezeAccount(handler) {
121
+ this.onInstruction('freezeAccount', (ins, ctx) => {
122
+ if (ins) {
123
+ handler(ins.data, ctx);
124
+ }
125
+ });
126
+ return this;
127
+ }
128
+ onThawAccount(handler) {
129
+ this.onInstruction('thawAccount', (ins, ctx) => {
130
+ if (ins) {
131
+ handler(ins.data, ctx);
132
+ }
133
+ });
134
+ return this;
135
+ }
136
+ instructionTypeToTokenInstruction(type) {
137
+ const findTokenInstruction = () => {
138
+ const camelCaseType = type[0].toLowerCase() + type.substring(1);
139
+ const index = Object.keys(spl_token_1.TokenInstruction).indexOf(camelCaseType);
140
+ if (index !== -1) {
141
+ return Object.values(spl_token_1.TokenInstruction)[index];
142
+ }
143
+ return undefined;
144
+ };
145
+ if (!this.TokenInstructionMapCache.has(type)) {
146
+ this.TokenInstructionMapCache.set(type, findTokenInstruction());
147
+ }
148
+ return this.TokenInstructionMapCache.get(type);
149
+ }
150
+ }
151
+ exports.SPLTokenProcessor = SPLTokenProcessor;
152
+ //# sourceMappingURL=spl-token-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spl-token-processor.js","sourceRoot":"","sources":["../../../src/solana/builtin/spl-token-processor.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAEtD,iDAe0B;AAI1B,MAAa,iBAAkB,SAAQ,sCAAmB;IAChD,wBAAwB,GAA8C,IAAI,GAAG,EAAE,CAAA;IAEvF,MAAM,CAAC,IAAI,CAAC,OAAe,EAAE,QAAg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connection, ParsedInstruction } from '@solana/web3.js';
4
+ import Long from 'long';
5
+ import { Instruction } from '@project-serum/anchor';
6
+ declare type IndexConfigure = {
7
+ startSlot: Long;
8
+ endSlot?: Long;
9
+ };
10
+ export declare class SolanaBaseProcessor {
11
+ instructionHanlderMap: Map<string, (instruction: Instruction, ctx: SolanaContext) => void>;
12
+ address: string;
13
+ endpoint: string;
14
+ connection: Connection;
15
+ contractName: string;
16
+ processInnerInstruction: boolean;
17
+ config: IndexConfigure;
18
+ decodeInstruction: (rawInstruction: string) => Instruction | null;
19
+ fromParsedInstruction: (instruction: ParsedInstruction) => Instruction | null;
20
+ constructor(contractName: string, address: string, endpoint: string, processInnerInstruction?: boolean);
21
+ bind(address: string): void;
22
+ onInstruction(instructionName: string, handler: (instruction: Instruction, ctx: SolanaContext) => void): this;
23
+ handleInstruction(ins: string | ParsedInstruction): O11yResult;
24
+ isBind(): boolean;
25
+ startSlot(startSlot: Long | number): this;
26
+ endBlock(endBlock: Long | number): this;
27
+ }
28
+ export {};
@@ -0,0 +1,79 @@
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.SolanaBaseProcessor = void 0;
7
+ const context_1 = require("./context");
8
+ const web3_js_1 = require("@solana/web3.js");
9
+ const long_1 = __importDefault(require("long"));
10
+ class SolanaBaseProcessor {
11
+ instructionHanlderMap = new Map();
12
+ address;
13
+ endpoint;
14
+ connection;
15
+ contractName;
16
+ processInnerInstruction;
17
+ config = { startSlot: new long_1.default(0) };
18
+ decodeInstruction;
19
+ fromParsedInstruction;
20
+ constructor(contractName, address, endpoint, processInnerInstruction = false) {
21
+ this.endpoint = endpoint;
22
+ this.address = address;
23
+ global.PROCESSOR_STATE.solanaProcessors.push(this);
24
+ this.connection = new web3_js_1.Connection(endpoint, 'confirmed');
25
+ this.contractName = contractName;
26
+ this.processInnerInstruction = processInnerInstruction;
27
+ }
28
+ bind(address) {
29
+ this.address = address;
30
+ }
31
+ onInstruction(instructionName, handler) {
32
+ if (!this.isBind()) {
33
+ throw new Error("Processor doesn't bind to an address");
34
+ }
35
+ this.instructionHanlderMap.set(instructionName, handler);
36
+ return this;
37
+ }
38
+ handleInstruction(ins) {
39
+ const ctx = new context_1.SolanaContext(this.address);
40
+ let parsedInstruction = null;
41
+ if (ins) {
42
+ if (ins.parsed) {
43
+ parsedInstruction = this.fromParsedInstruction(ins);
44
+ }
45
+ else {
46
+ parsedInstruction = this.decodeInstruction(ins);
47
+ }
48
+ if (parsedInstruction) {
49
+ const handler = this.instructionHanlderMap.get(parsedInstruction.name);
50
+ if (handler) {
51
+ handler(parsedInstruction, ctx);
52
+ }
53
+ }
54
+ }
55
+ return {
56
+ gauges: ctx.gauges,
57
+ counters: ctx.counters,
58
+ };
59
+ }
60
+ isBind() {
61
+ return this.address !== null;
62
+ }
63
+ startSlot(startSlot) {
64
+ if (typeof startSlot === 'number') {
65
+ startSlot = long_1.default.fromNumber(startSlot);
66
+ }
67
+ this.config.startSlot = startSlot;
68
+ return this;
69
+ }
70
+ endBlock(endBlock) {
71
+ if (typeof endBlock === 'number') {
72
+ endBlock = long_1.default.fromNumber(endBlock);
73
+ }
74
+ this.config.endSlot = endBlock;
75
+ return this;
76
+ }
77
+ }
78
+ exports.SolanaBaseProcessor = SolanaBaseProcessor;
79
+ //# sourceMappingURL=solana-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../src/solana-processor.ts"],"names":[],"mappings":";;;;;;AACA,uCAAyC;AACzC,6CAA+D;AAC/D,gDAAuB;AAQvB,MAAa,mBAAmB;IACvB,qBAAqB,GAAwE,IAAI,GAAG,EAAE,CAAA;IAC7G,OAAO,CAAQ;IACf,QAAQ,CAAQ;IAChB,UAAU,CAAY;IACtB,YAAY,CAAQ;IACpB,uBAAuB,CAAS;IAChC,MAAM,GAAmB,EAA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,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;gBACtE,IAAI,OAAO,EAAE;oBACX,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;iBAChC;aACF;SACF;QACD,OAAO;YACL,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAA;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAA;IAC9B,CAAC;IAEM,SAAS,CAAC,SAAwB;QACvC,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;SACvC;QACD,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,QAAQ,CAAC,QAAuB;QACrC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,QAAQ,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;SACrC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA5ED,kDA4EC"}
@@ -0,0 +1,3 @@
1
+ import { Contract } from 'typechain';
2
+ export declare function codeGenIndex(contract: Contract): string;
3
+ export declare function codeGenSentioFile(contract: Contract): string;
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.codeGenSentioFile = exports.codeGenIndex = 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
+ const signatures_1 = require("typechain/dist/utils/signatures");
8
+ function codeGenIndex(contract) {
9
+ return `
10
+ export * from '../internal/${contract.name.toLowerCase()}_processor'
11
+ export * from '../internal/${contract.name}'
12
+ `;
13
+ }
14
+ exports.codeGenIndex = codeGenIndex;
15
+ function codeGenSentioFile(contract) {
16
+ const source = `
17
+ const templateContract = ${contract.name}__factory.connect("", DummyProvider)
18
+
19
+ export class ${contract.name}ContractView extends ContractView<${contract.name}> {
20
+ constructor (contract: ${contract.name}) {
21
+ super(contract);
22
+ }
23
+
24
+ ${Object.values(contract.functions)
25
+ .filter((f) => !reserved_keywords_1.reservedKeywords.has(f[0].name))
26
+ .flatMap((v) => v.filter((f) => f.stateMutability == 'view').map(generateViewFunction))
27
+ .join('\n')}
28
+ }
29
+
30
+ export class ${contract.name}BoundContractView extends BoundContractView<${contract.name}, ${contract.name}ContractView> {
31
+ // constructor (contract: ${contract.name}) {
32
+ // super(contract);
33
+ // }
34
+
35
+ ${Object.values(contract.functions)
36
+ .filter((f) => !reserved_keywords_1.reservedKeywords.has(f[0].name))
37
+ .flatMap((v) => v.filter((f) => f.stateMutability == 'view').map(generateBoundViewFunction))
38
+ .join('\n')}
39
+ }
40
+
41
+ export type ${contract.name}Context = Context<${contract.name}, ${contract.name}BoundContractView>
42
+
43
+ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${contract.name}, ${contract.name}BoundContractView> {
44
+ bindInternal(options: BindOptions) {
45
+ let processor = getProcessor("${contract.name}", options) as ${contract.name}Processor
46
+ if (!processor) {
47
+ const finalOptions = Object.assign({}, options)
48
+ finalOptions.name = getContractName("${contract.name}", options.name, options.address, options.network)
49
+ processor = new ${contract.name}Processor(finalOptions)
50
+ addProcessor("${contract.name}", options, processor)
51
+ }
52
+ return processor
53
+ }
54
+
55
+ ${Object.values(contract.events)
56
+ .map((events) => {
57
+ if (events.length === 1) {
58
+ return generateOnEventFunction(events[0], contract.name, false);
59
+ }
60
+ else {
61
+ return events.map((e) => generateOnEventFunction(e, contract.name, true)).join('\n');
62
+ }
63
+ })
64
+ .join('\n')}
65
+ }
66
+
67
+ export class ${contract.name}Processor extends BaseProcessor<${contract.name}, ${contract.name}BoundContractView> {
68
+ ${Object.values(contract.events)
69
+ .map((events) => {
70
+ if (events.length === 1) {
71
+ return generateOnEventFunction(events[0], contract.name, false);
72
+ }
73
+ else {
74
+ return events.map((e) => generateOnEventFunction(e, contract.name, true)).join('\n');
75
+ }
76
+ })
77
+ .join('\n')}
78
+
79
+ public static filters = templateContract.filters
80
+
81
+ protected CreateBoundContractView(): ${contract.name}BoundContractView {
82
+ const view = get${contract.name}Contract(this.config.address, this.config.network)
83
+ return new ${contract.name}BoundContractView(view)
84
+ }
85
+
86
+ public static bind(options: BindOptions): ${contract.name}Processor {
87
+ let processor = getProcessor("${contract.name}", options) as ${contract.name}Processor
88
+ if (!processor) {
89
+ // const wrapper = get${contract.name}Contract(options.address, options.network)
90
+
91
+ const finalOptions = Object.assign({}, options)
92
+ finalOptions.name = getContractName("${contract.name}", options.name, options.address, options.network)
93
+ processor = new ${contract.name}Processor(finalOptions)
94
+ addProcessor("${contract.name}", options, processor)
95
+ }
96
+ return processor
97
+ }
98
+ }
99
+
100
+ export function get${contract.name}Contract(address: string, network: Networkish = 1): ${contract.name}ContractView {
101
+ let contract = getContractByABI("${contract.name}", address, network) as ${contract.name}ContractView
102
+ if (!contract) {
103
+ const rawContract = ${contract.name}__factory.connect(address, getProvider(network))
104
+ contract = new ${contract.name}ContractView(rawContract)
105
+ addContractByABI("${contract.name}", address, network, contract)
106
+ }
107
+ return contract
108
+ }
109
+ `;
110
+ const imports = (0, typechain_1.createImportsForUsedIdentifiers)({
111
+ ethers: ['BigNumber', 'BigNumberish', 'CallOverrides', 'BytesLike'],
112
+ '@ethersproject/providers': ['Networkish'],
113
+ '@sentio/sdk': [
114
+ 'addContractByABI',
115
+ 'getContractByABI',
116
+ 'addProcessor',
117
+ 'getProcessor',
118
+ 'getProvider',
119
+ 'transformEtherError',
120
+ 'BindOptions',
121
+ 'BaseProcessor',
122
+ 'BaseProcessorTemplate',
123
+ 'BoundContractView',
124
+ 'Context',
125
+ 'ContractView',
126
+ 'DummyProvider',
127
+ 'getContractName',
128
+ ],
129
+ './common': ['PromiseOrValue'],
130
+ './index': [`${contract.name}`, `${contract.name}__factory`],
131
+ [`./${contract.name}`]: [].concat(...Object.values(contract.events).map((events) => {
132
+ if (events.length === 1) {
133
+ return [`${events[0].name}Event`, `${events[0].name}EventFilter`];
134
+ }
135
+ else {
136
+ return events.flatMap((e) => [
137
+ `${(0, typechain_1.getFullSignatureAsSymbolForEvent)(e)}_Event`,
138
+ `${(0, typechain_1.getFullSignatureAsSymbolForEvent)(e)}_EventFilter`,
139
+ ]);
140
+ }
141
+ })),
142
+ }, source);
143
+ return imports + source;
144
+ }
145
+ exports.codeGenSentioFile = codeGenSentioFile;
146
+ function generateOnEventFunction(event, contractName, includeArgTypes) {
147
+ let eventName = event.name;
148
+ if (includeArgTypes) {
149
+ eventName = (0, typechain_1.getFullSignatureAsSymbolForEvent)(event) + '_';
150
+ }
151
+ const filterName = (0, signatures_1.getFullSignatureForEvent)(event);
152
+ return `
153
+ on${eventName}(
154
+ handler: (event: ${eventName}Event, ctx: ${contractName}Context) => void,
155
+ filter?: ${eventName}EventFilter | ${eventName}EventFilter[]
156
+ ) {
157
+ if (!filter) {
158
+ filter = ${contractName}Processor.filters['${filterName}'](${event.inputs.map(() => 'null').join(',')})
159
+ }
160
+ return super.onEvent(handler, filter)
161
+ }
162
+ `;
163
+ }
164
+ function generateViewFunction(func) {
165
+ return `
166
+ async ${func.name}(${(0, types_1.generateInputTypes)(func.inputs, { useStructs: true })}overrides?: CallOverrides) {
167
+ try {
168
+ if (overrides) {
169
+ return await this.contract.${func.name}(${func.inputs.length > 0 ? func.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''} overrides)
170
+ } else {
171
+ return await this.contract.${func.name}(${func.inputs
172
+ .map((input, index) => input.name || `arg${index}`)
173
+ .join(',')})
174
+ }
175
+ } catch (e) {
176
+ throw transformEtherError(e, undefined)
177
+ }
178
+ }
179
+ `;
180
+ }
181
+ function generateBoundViewFunction(func) {
182
+ return `
183
+ async ${func.name}(${(0, types_1.generateInputTypes)(func.inputs, { useStructs: true })}overrides?: CallOverrides) {
184
+ try {
185
+ if (!overrides && this.context) {
186
+ overrides = {
187
+ blockTag: this.context.blockNumber.toNumber(),
188
+ }
189
+ }
190
+ if (overrides) {
191
+ return await this.view.${func.name}(${func.inputs.length > 0 ? func.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''} overrides)
192
+ } else {
193
+ return await this.view.${func.name}(${func.inputs.map((input, index) => input.name || `arg${index}`).join(',')})
194
+ }
195
+ } catch (e) {
196
+ throw transformEtherError(e, this.context)
197
+ }
198
+ }
199
+ `;
200
+ }
201
+ //# sourceMappingURL=codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/target-ethers-sentio/codegen.ts"],"names":[],"mappings":";;;AAAA,yCAMkB;AAElB,2FAAsF;AACtF,mEAA4E;AAC5E,gEAA0E;AAE1E,SAAgB,YAAY,CAAC,QAAkB;IAC7C,OAAO;+BACsB,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE;+BAC3B,QAAQ,CAAC,IAAI;GACzC,CAAA;AACH,CAAC;AALD,oCAKC;AAED,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,MAAM,MAAM,GAAG;6BACY,QAAQ,CAAC,IAAI;;iBAEzB,QAAQ,CAAC,IAAI,qCAAqC,QAAQ,CAAC,IAAI;6BACnD,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,CAAC,CAAC,CAAC,MAAM,CAAC,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MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;;;;;;;;iCAQ3C,IAAI,CAAC,IAAI,IACtC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAC5G;;iCAE+B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;GAMnH,CAAA;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import Ethers from '@typechain/ethers-v5';
2
+ import { Config, FileDescription } from 'typechain';
3
+ export default class EthersSentio extends Ethers {
4
+ constructor(config: Config);
5
+ transformAbiOrFullJsonFile(file: FileDescription): FileDescription[] | void;
6
+ }
@@ -0,0 +1,47 @@
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
+ constructor(config) {
12
+ if (!config.outDir) {
13
+ throw new Error('Out put path not specificed');
14
+ }
15
+ super(config);
16
+ }
17
+ // TODO(pc): also have to override transformBinFile, transformFile
18
+ transformAbiOrFullJsonFile(file) {
19
+ const abi = (0, typechain_1.extractAbi)(file.contents);
20
+ if (abi.length === 0) {
21
+ return;
22
+ }
23
+ const documentation = (0, typechain_1.extractDocumentation)(file.contents);
24
+ const jsonPath = (0, path_1.relative)(this.cfg.inputDir, (0, typechain_1.shortenFullJsonFilePath)(file.path, this.cfg.allFiles));
25
+ const contract = (0, typechain_1.parse)(abi, jsonPath, documentation);
26
+ const files = super.transformAbiOrFullJsonFile(file);
27
+ if (files !== undefined) {
28
+ // files.forEach(this.transformFilePath)
29
+ // for (const file of files) {
30
+ // this.transformFilePath(file)
31
+ // }
32
+ return [
33
+ ...files,
34
+ {
35
+ path: (0, path_1.join)((0, path_1.dirname)(files[0].path), `${contract.name.toLowerCase()}_processor.ts`),
36
+ contents: (0, codegen_1.codeGenSentioFile)(contract),
37
+ },
38
+ {
39
+ path: (0, path_1.join)((0, path_1.dirname)(files[0].path), '..', contract.name.toLowerCase(), 'index.ts'),
40
+ contents: (0, codegen_1.codeGenIndex)(contract),
41
+ },
42
+ ];
43
+ }
44
+ }
45
+ }
46
+ exports.default = EthersSentio;
47
+ //# 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,yCAAqH;AACrH,+BAA8C;AAC9C,uCAA2D;AAE3D,MAAqB,YAAa,SAAQ,mBAAM;IAC9C,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;SAC/C;QACD,KAAK,CAAC,MAAM,CAAC,CAAA;IACf,CAAC;IAED,kEAAkE;IACzD,0BAA0B,CAAC,IAAqB;QACvD,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,QAAQ,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAA,mCAAuB,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;QACnG,MAAM,QAAQ,GAAG,IAAA,iBAAK,EAAC,GAAG,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;QACpD,MAAM,KAAK,GAAG,KAAK,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAA;QAEpD,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,wCAAwC;YACxC,8BAA8B;YAC9B,iCAAiC;YACjC,IAAI;YAEJ,OAAO;gBACL,GAAG,KAAK;gBACR;oBACE,IAAI,EAAE,IAAA,WAAI,EAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC;oBACjF,QAAQ,EAAE,IAAA,2BAAiB,EAAC,QAAQ,CAAC;iBACtC;gBACD;oBACE,IAAI,EAAE,IAAA,WAAI,EAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC;oBACjF,QAAQ,EAAE,IAAA,sBAAY,EAAC,QAAQ,CAAC;iBACjC;aACF,CAAA;SACF;IACH,CAAC;CACF;AAxCD,+BAwCC"}
@@ -0,0 +1 @@
1
+ export declare function cleanTest(): void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanTest = void 0;
4
+ const sdk_1 = require("@sentio/sdk");
5
+ function cleanTest() {
6
+ global.PROCESSOR_STATE = new sdk_1.ProcessorState();
7
+ }
8
+ exports.cleanTest = cleanTest;
9
+ //# sourceMappingURL=clean-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clean-test.js","sourceRoot":"","sources":["../../src/test-case/clean-test.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAE5C,SAAgB,SAAS;IACvB,MAAM,CAAC,eAAe,GAAG,IAAI,oBAAc,EAAE,CAAA;AAC/C,CAAC;AAFD,8BAEC"}
@@ -0,0 +1 @@
1
+ export declare const filter: import("builtin/erc20").TransferEventFilter;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filter = void 0;
4
+ const erc20_1 = require("builtin/erc20");
5
+ exports.filter = erc20_1.Erc20Processor.filters.Transfer('0x0000000000000000000000000000000000000000', '0xb329e39ebefd16f40d38f07643652ce17ca5bac1');
6
+ const processorTemplate = new erc20_1.Erc20ProcessorTemplate().onTransfer(async function (event, ctx) {
7
+ console.log('');
8
+ });
9
+ erc20_1.Erc20Processor.bind({
10
+ address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',
11
+ network: 1,
12
+ name: 'x2y2',
13
+ startBlock: 14201940,
14
+ }).onTransfer(async function (event, ctx) {
15
+ processorTemplate.bind({
16
+ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
17
+ network: 3,
18
+ name: 'dynamic',
19
+ });
20
+ // template.bind('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 3, 'dynamic')
21
+ ctx.meter.Counter('c1').add(1);
22
+ }, exports.filter);
23
+ //# sourceMappingURL=erc20-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc20-template.js","sourceRoot":"","sources":["../../src/test-case/erc20-template.ts"],"names":[],"mappings":";;;AAAA,yCAAsE;AAEzD,QAAA,MAAM,GAAG,sBAAc,CAAC,OAAO,CAAC,QAAQ,CACnD,4CAA4C,EAC5C,4CAA4C,CAC7C,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAI,8BAAsB,EAAE,CAAC,UAAU,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IAC1F,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA;AAEF,sBAAc,CAAC,IAAI,CAAC;IAClB,OAAO,EAAE,4CAA4C;IACrD,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,QAAQ;CACrB,CAAC,CAAC,UAAU,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IACtC,iBAAiB,CAAC,IAAI,CAAC;QACrB,OAAO,EAAE,4CAA4C;QACrD,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,SAAS;KAChB,CAAC,CAAA;IACF,4EAA4E;IAC5E,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC,EAAE,cAAM,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export {};