@sentio/sdk 2.2.0 → 2.3.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/base-context.d.ts +0 -1
- package/lib/core/base-context.js +0 -4
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/event-logger.d.ts +0 -6
- package/lib/core/event-logger.js +0 -26
- package/lib/core/event-logger.js.map +1 -1
- package/lib/eth/codegen/ethers-sentio.js +1 -1
- package/lib/eth/codegen/ethers-sentio.js.map +1 -1
- package/lib/utils/price.d.ts +14 -0
- package/package.json +5 -5
- package/src/core/base-context.ts +0 -4
- package/src/core/event-logger.ts +0 -33
- package/src/eth/codegen/ethers-sentio.ts +1 -1
|
@@ -5,7 +5,6 @@ import { BoundedEventTracker } from './event-tracker.js';
|
|
|
5
5
|
export declare abstract class BaseContext {
|
|
6
6
|
meter: Meter;
|
|
7
7
|
eventLogger: EventLogger;
|
|
8
|
-
logger: EventLogger;
|
|
9
8
|
/** @deprecated use {@link this.eventLogger} instead */
|
|
10
9
|
eventTracker: BoundedEventTracker;
|
|
11
10
|
_res: ProcessResult;
|
package/lib/core/base-context.js
CHANGED
|
@@ -4,7 +4,6 @@ import { BoundedEventTracker } from './event-tracker.js';
|
|
|
4
4
|
export class BaseContext {
|
|
5
5
|
meter;
|
|
6
6
|
eventLogger;
|
|
7
|
-
logger;
|
|
8
7
|
/** @deprecated use {@link this.eventLogger} instead */
|
|
9
8
|
eventTracker;
|
|
10
9
|
_res = {
|
|
@@ -12,14 +11,11 @@ export class BaseContext {
|
|
|
12
11
|
events: [],
|
|
13
12
|
exports: [],
|
|
14
13
|
gauges: [],
|
|
15
|
-
logs: [],
|
|
16
14
|
};
|
|
17
15
|
constructor() {
|
|
18
16
|
this.meter = new Meter(this);
|
|
19
17
|
this.eventLogger = new EventLogger(this);
|
|
20
18
|
// eslint-disable-next-line deprecation/deprecation
|
|
21
|
-
this.logger = this.eventLogger;
|
|
22
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
23
19
|
this.eventTracker = new BoundedEventTracker(this);
|
|
24
20
|
}
|
|
25
21
|
getProcessResult() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-context.js","sourceRoot":"","sources":["../../src/core/base-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAU,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,OAAgB,WAAW;IAC/B,KAAK,CAAO;IACZ,WAAW,CAAa;IAExB,
|
|
1
|
+
{"version":3,"file":"base-context.js","sourceRoot":"","sources":["../../src/core/base-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAU,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,OAAgB,WAAW;IAC/B,KAAK,CAAO;IACZ,WAAW,CAAa;IAExB,uDAAuD;IACvD,YAAY,CAAqB;IAEjC,IAAI,GAAkB;QACpB,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,EAAE;KACX,CAAA;IAED;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAA;QACxC,mDAAmD;QACnD,IAAI,CAAC,YAAY,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAA;IACnD,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;CAGF","sourcesContent":["import { ProcessResult, RecordMetaData } from '@sentio/protos'\nimport { EventLogger } from './event-logger.js'\nimport { Meter, Labels } from './meter.js'\nimport { BoundedEventTracker } from './event-tracker.js'\n\nexport abstract class BaseContext {\n meter: Meter\n eventLogger: EventLogger\n\n /** @deprecated use {@link this.eventLogger} instead */\n eventTracker: BoundedEventTracker\n\n _res: ProcessResult = {\n counters: [],\n events: [],\n exports: [],\n gauges: [],\n }\n\n protected constructor() {\n this.meter = new Meter(this)\n this.eventLogger = new EventLogger(this)\n // eslint-disable-next-line deprecation/deprecation\n this.eventTracker = new BoundedEventTracker(this)\n }\n\n getProcessResult(): ProcessResult {\n return this._res\n }\n\n abstract getMetaData(name: string, labels: Labels): RecordMetaData\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseContext } from './base-context.js';
|
|
2
|
-
import { LogLevel } from '@sentio/protos';
|
|
3
2
|
import { NamedResultDescriptor } from './metadata.js';
|
|
4
3
|
import { Event } from './event-tracker.js';
|
|
5
4
|
export type Attributes = Record<string, any>;
|
|
@@ -7,10 +6,5 @@ export declare class EventLogger extends NamedResultDescriptor {
|
|
|
7
6
|
private readonly ctx;
|
|
8
7
|
constructor(ctx: BaseContext, name?: string);
|
|
9
8
|
withName(name: string): EventLogger;
|
|
10
|
-
protected log(level: LogLevel, message: any, attributes?: Attributes): void;
|
|
11
|
-
info(msg: any, attributes?: Attributes): void;
|
|
12
|
-
warn(msg: any, attributes?: Attributes): void;
|
|
13
|
-
error(msg: any, attributes?: Attributes): void;
|
|
14
|
-
critical(msg: any, attributes?: Attributes): void;
|
|
15
9
|
emit(eventName: string, event: Event): void;
|
|
16
10
|
}
|
package/lib/core/event-logger.js
CHANGED
|
@@ -10,32 +10,6 @@ export class EventLogger extends NamedResultDescriptor {
|
|
|
10
10
|
withName(name) {
|
|
11
11
|
return new EventLogger(this.ctx, name);
|
|
12
12
|
}
|
|
13
|
-
log(level, message, attributes = {}) {
|
|
14
|
-
if (typeof message !== 'string' && !(message instanceof String)) {
|
|
15
|
-
message = JSON.stringify(message);
|
|
16
|
-
}
|
|
17
|
-
const norm = normalizeAttribute(attributes);
|
|
18
|
-
this.ctx._res.logs.push({
|
|
19
|
-
// name: this.name,
|
|
20
|
-
metadata: this.ctx.getMetaData(this.name, {}),
|
|
21
|
-
level,
|
|
22
|
-
message,
|
|
23
|
-
attributes2: norm,
|
|
24
|
-
runtimeInfo: undefined,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
info(msg, attributes = {}) {
|
|
28
|
-
this.log(LogLevel.INFO, msg, attributes);
|
|
29
|
-
}
|
|
30
|
-
warn(msg, attributes = {}) {
|
|
31
|
-
this.log(LogLevel.WARNING, msg, attributes);
|
|
32
|
-
}
|
|
33
|
-
error(msg, attributes = {}) {
|
|
34
|
-
this.log(LogLevel.ERROR, msg, attributes);
|
|
35
|
-
}
|
|
36
|
-
critical(msg, attributes = {}) {
|
|
37
|
-
this.log(LogLevel.CRITICAL, msg, attributes);
|
|
38
|
-
}
|
|
39
13
|
emit(eventName, event) {
|
|
40
14
|
const { distinctId, severity, message, ...payload } = event;
|
|
41
15
|
const res = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-logger.js","sourceRoot":"","sources":["../../src/core/event-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAKvD,MAAM,OAAO,WAAY,SAAQ,qBAAqB;IACnC,GAAG,CAAa;IAEjC,YAAY,GAAgB,EAAE,IAAI,GAAG,EAAE;QACrC,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;
|
|
1
|
+
{"version":3,"file":"event-logger.js","sourceRoot":"","sources":["../../src/core/event-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAKvD,MAAM,OAAO,WAAY,SAAQ,qBAAqB;IACnC,GAAG,CAAa;IAEjC,YAAY,GAAgB,EAAE,IAAI,GAAG,EAAE;QACrC,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,CAAC,SAAiB,EAAE,KAAY;QAClC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,CAAA;QAE3D,MAAM,GAAG,GAAwB;YAC/B,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC;YAC7C,QAAQ,EAAE,QAAQ,IAAI,QAAQ,CAAC,IAAI;YACnC,OAAO,EAAE,OAAO,IAAI,EAAE;YACtB,gBAAgB,EAAE,UAAU,IAAI,EAAE;YAClC,UAAU,EAAE,kBAAkB,CAAC,OAAO,CAAC;YACvC,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;SACf,CAAA;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;CACF","sourcesContent":["import { BaseContext } from './base-context.js'\nimport { EventTrackingResult, LogLevel } from '@sentio/protos'\nimport { NamedResultDescriptor } from './metadata.js'\nimport { normalizeAttribute } from './normalization.js'\nimport { Event } from './event-tracker.js'\n\nexport type Attributes = Record<string, any>\n\nexport class EventLogger extends NamedResultDescriptor {\n private readonly ctx: BaseContext\n\n constructor(ctx: BaseContext, name = '') {\n super(name)\n this.ctx = ctx\n }\n\n withName(name: string) {\n return new EventLogger(this.ctx, name)\n }\n\n emit(eventName: string, event: Event) {\n const { distinctId, severity, message, ...payload } = event\n\n const res: EventTrackingResult = {\n metadata: this.ctx.getMetaData(eventName, {}),\n severity: severity || LogLevel.INFO,\n message: message || '',\n distinctEntityId: distinctId || '',\n attributes: normalizeAttribute(payload),\n runtimeInfo: undefined,\n noMetric: true,\n }\n this.ctx._res.events.push(res)\n }\n}\n"]}
|
|
@@ -60,7 +60,7 @@ export default class EthersSentio extends Ethers.default {
|
|
|
60
60
|
indexContent =
|
|
61
61
|
indexContent +
|
|
62
62
|
`
|
|
63
|
-
export * as ${contract.name.toLowerCase()} from './${contract.name.toLowerCase()}.js'
|
|
63
|
+
export * as ${contract.name.toLowerCase().replaceAll('-', '_')} from './${contract.name.toLowerCase()}.js'
|
|
64
64
|
export { ${contract.name}Processor, ${contract.name}ProcessorTemplate } from './${contract.name.toLowerCase()}.js'
|
|
65
65
|
`;
|
|
66
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethers-sentio.js","sourceRoot":"","sources":["../../../src/eth/codegen/ethers-sentio.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAEL,UAAU,EACV,oBAAoB,EAEpB,KAAK,EACL,uBAAuB,GAExB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEjF,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM,CAAC,OAAO;IACtD,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,C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ACD,IAAI,YAAY,GAAG,EAAE,CAAA;QACrB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC9C,YAAY;gBACV,YAAY;oBACZ;0BACkB,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,YAAY,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE;uBAC1F,QAAQ,CAAC,IAAI,cAC1B,QAAQ,CAAC,IACX,+BAA+B,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE;aACrD,CAAA;SACR;QACD,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;YACjD,QAAQ,EAAE,YAAY;SACvB,CAAC,CAAA;QACF,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import Ethers from '@sentio/ethers-v6'\nimport {\n Config,\n extractAbi,\n extractDocumentation,\n FileDescription,\n parse,\n shortenFullJsonFilePath,\n Contract,\n} from 'typechain'\nimport { dirname, join, relative } from 'path'\nimport { codeGenIndex, codeGenSentioFile, codeGenTestUtilsFile } from './file.js'\n\nexport default class EthersSentio extends Ethers.default {\n constructor(config: Config) {\n if (!config.outDir) {\n throw new Error('Out put path not specificed')\n }\n super(config)\n }\n\n private processedContracts: Contract[] = []\n\n // TODO(pc): also have to override transformBinFile, transformFile\n override transformAbiOrFullJsonFile(file: FileDescription): FileDescription[] | void {\n const abi = extractAbi(file.contents)\n if (abi.length === 0) {\n return\n }\n\n const documentation = extractDocumentation(file.contents)\n\n const jsonPath = relative(this.cfg.inputDir, shortenFullJsonFilePath(file.path, this.cfg.allFiles))\n const contract = parse(abi, jsonPath, documentation)\n const files = super.transformAbiOrFullJsonFile(file)\n this.processedContracts.push(contract)\n\n if (files !== undefined) {\n // files.forEach(this.transformFilePath)\n // for (const file of files) {\n // this.transformFilePath(file)\n // }\n\n return [\n ...files,\n {\n path: join(dirname(files[0].path), `${contract.name.toLowerCase()}_processor.ts`),\n contents: codeGenSentioFile(contract),\n },\n {\n path: join(dirname(files[0].path), '..', `${contract.name.toLowerCase()}.ts`),\n contents: codeGenIndex(contract),\n },\n {\n path: join(dirname(files[0].path), `${contract.name.toLowerCase()}_test-utils.ts`),\n contents: codeGenTestUtilsFile(contract),\n },\n ]\n }\n }\n\n override afterRun() {\n const files = super.afterRun()\n for (const [idx, file] of files.entries()) {\n if (file.path.endsWith('__factory.ts')) {\n file.contents = '// @ts-nocheck\\n' + file.contents\n } else if (file.path.endsWith('factories/index.ts')) {\n file.contents = file.contents.replaceAll(\"__factory'\", \"__factory.js'\")\n } else if (file.path.endsWith('_processor.ts')) {\n }\n }\n let indexContent = ''\n for (const contract of this.processedContracts) {\n indexContent =\n indexContent +\n `\n export * as ${contract.name.toLowerCase().replaceAll('-', '_')} from './${contract.name.toLowerCase()}.js'\n export { ${contract.name}Processor, ${\n contract.name\n }ProcessorTemplate } from './${contract.name.toLowerCase()}.js'\n `\n }\n files.push({\n path: join(dirname(files[0].path), '../index.ts'),\n contents: indexContent,\n })\n return files\n }\n}\n"]}
|
package/lib/utils/price.d.ts
CHANGED
|
@@ -10,6 +10,16 @@ export declare function getPriceClient(address?: string): import("nice-grpc").Ra
|
|
|
10
10
|
decode(input: Uint8Array | import("protobufjs").Reader, length?: number | undefined): import("@sentio/protos/price").GetPriceRequest;
|
|
11
11
|
fromJSON(object: any): import("@sentio/protos/price").GetPriceRequest;
|
|
12
12
|
toJSON(message: import("@sentio/protos/price").GetPriceRequest): unknown;
|
|
13
|
+
create(base?: {
|
|
14
|
+
timestamp?: Date | undefined;
|
|
15
|
+
coinId?: {
|
|
16
|
+
symbol?: string | undefined;
|
|
17
|
+
address?: {
|
|
18
|
+
address?: string | undefined;
|
|
19
|
+
chain?: string | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
} | undefined): import("@sentio/protos/price").GetPriceRequest;
|
|
13
23
|
fromPartial(object: {
|
|
14
24
|
timestamp?: Date | undefined;
|
|
15
25
|
coinId?: {
|
|
@@ -27,6 +37,10 @@ export declare function getPriceClient(address?: string): import("nice-grpc").Ra
|
|
|
27
37
|
decode(input: Uint8Array | import("protobufjs").Reader, length?: number | undefined): import("@sentio/protos/price").GetPriceResponse;
|
|
28
38
|
fromJSON(object: any): import("@sentio/protos/price").GetPriceResponse;
|
|
29
39
|
toJSON(message: import("@sentio/protos/price").GetPriceResponse): unknown;
|
|
40
|
+
create(base?: {
|
|
41
|
+
price?: number | undefined;
|
|
42
|
+
timestamp?: Date | undefined;
|
|
43
|
+
} | undefined): import("@sentio/protos/price").GetPriceResponse;
|
|
30
44
|
fromPartial(object: {
|
|
31
45
|
price?: number | undefined;
|
|
32
46
|
timestamp?: Date | undefined;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0-rc.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"@project-serum/anchor": "^0.26.0",
|
|
20
20
|
"@sentio/bigdecimal": "^9.1.1-patch.3",
|
|
21
21
|
"@sentio/ethers-v6": "^1.0.25",
|
|
22
|
-
"@sentio/protos": "^2.
|
|
23
|
-
"@sentio/runtime": "^2.
|
|
24
|
-
"@sentio/sdk": "^2.
|
|
22
|
+
"@sentio/protos": "^2.3.0-rc.2",
|
|
23
|
+
"@sentio/runtime": "^2.3.0-rc.2",
|
|
24
|
+
"@sentio/sdk": "^2.3.0-rc.2",
|
|
25
25
|
"@solana/web3.js": "^1.47.3",
|
|
26
26
|
"@types/prettier": "^2.7.2",
|
|
27
27
|
"aptos-sdk": "npm:@sentio/aptos@^1.6.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"typedoc": {
|
|
79
79
|
"entryPoint": "./src/index.ts"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "cf8fa9ac382b830e87f38c1487d65081e7089c0f"
|
|
82
82
|
}
|
package/src/core/base-context.ts
CHANGED
|
@@ -7,7 +7,6 @@ export abstract class BaseContext {
|
|
|
7
7
|
meter: Meter
|
|
8
8
|
eventLogger: EventLogger
|
|
9
9
|
|
|
10
|
-
logger: EventLogger
|
|
11
10
|
/** @deprecated use {@link this.eventLogger} instead */
|
|
12
11
|
eventTracker: BoundedEventTracker
|
|
13
12
|
|
|
@@ -16,15 +15,12 @@ export abstract class BaseContext {
|
|
|
16
15
|
events: [],
|
|
17
16
|
exports: [],
|
|
18
17
|
gauges: [],
|
|
19
|
-
logs: [],
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
protected constructor() {
|
|
23
21
|
this.meter = new Meter(this)
|
|
24
22
|
this.eventLogger = new EventLogger(this)
|
|
25
23
|
// eslint-disable-next-line deprecation/deprecation
|
|
26
|
-
this.logger = this.eventLogger
|
|
27
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
28
24
|
this.eventTracker = new BoundedEventTracker(this)
|
|
29
25
|
}
|
|
30
26
|
|
package/src/core/event-logger.ts
CHANGED
|
@@ -18,39 +18,6 @@ export class EventLogger extends NamedResultDescriptor {
|
|
|
18
18
|
return new EventLogger(this.ctx, name)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
protected log(level: LogLevel, message: any, attributes: Attributes = {}) {
|
|
22
|
-
if (typeof message !== 'string' && !(message instanceof String)) {
|
|
23
|
-
message = JSON.stringify(message)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const norm = normalizeAttribute(attributes)
|
|
27
|
-
|
|
28
|
-
this.ctx._res.logs.push({
|
|
29
|
-
// name: this.name,
|
|
30
|
-
metadata: this.ctx.getMetaData(this.name, {}), // GetRecordMetaData(this.ctx, this, {}),
|
|
31
|
-
level,
|
|
32
|
-
message,
|
|
33
|
-
attributes2: norm,
|
|
34
|
-
runtimeInfo: undefined,
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
info(msg: any, attributes: Attributes = {}) {
|
|
39
|
-
this.log(LogLevel.INFO, msg, attributes)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
warn(msg: any, attributes: Attributes = {}) {
|
|
43
|
-
this.log(LogLevel.WARNING, msg, attributes)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
error(msg: any, attributes: Attributes = {}) {
|
|
47
|
-
this.log(LogLevel.ERROR, msg, attributes)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
critical(msg: any, attributes: Attributes = {}) {
|
|
51
|
-
this.log(LogLevel.CRITICAL, msg, attributes)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
21
|
emit(eventName: string, event: Event) {
|
|
55
22
|
const { distinctId, severity, message, ...payload } = event
|
|
56
23
|
|
|
@@ -74,7 +74,7 @@ export default class EthersSentio extends Ethers.default {
|
|
|
74
74
|
indexContent =
|
|
75
75
|
indexContent +
|
|
76
76
|
`
|
|
77
|
-
export * as ${contract.name.toLowerCase()} from './${contract.name.toLowerCase()}.js'
|
|
77
|
+
export * as ${contract.name.toLowerCase().replaceAll('-', '_')} from './${contract.name.toLowerCase()}.js'
|
|
78
78
|
export { ${contract.name}Processor, ${
|
|
79
79
|
contract.name
|
|
80
80
|
}ProcessorTemplate } from './${contract.name.toLowerCase()}.js'
|