@sentio/sdk 1.19.3 → 1.19.5
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/aptos/aptos-processor.d.ts +40 -0
- package/lib/aptos/aptos-processor.js +126 -0
- package/lib/aptos/aptos-processor.js.map +1 -0
- package/lib/aptos/bind-options.d.ts +11 -0
- package/lib/aptos/bind-options.js +17 -0
- package/lib/aptos/bind-options.js.map +1 -0
- package/lib/aptos/context.d.ts +12 -0
- package/lib/aptos/context.js +33 -0
- package/lib/aptos/context.js.map +1 -0
- package/lib/aptos/index.d.ts +5 -0
- package/lib/aptos/index.js +11 -0
- package/lib/aptos/index.js.map +1 -0
- package/lib/core/base-processor-template.js.map +1 -1
- package/lib/core/base-processor.d.ts +1 -1
- package/lib/core/base-processor.js.map +1 -1
- package/lib/core/bind-options.d.ts +0 -2
- package/lib/core/bind-options.js +1 -4
- package/lib/core/bind-options.js.map +1 -1
- package/lib/core/context.d.ts +10 -10
- package/lib/core/context.js +65 -11
- package/lib/core/context.js.map +1 -1
- package/lib/core/generic-processor.test.js +1 -1
- package/lib/core/generic-processor.test.js.map +1 -1
- package/lib/core/index.d.ts +1 -2
- package/lib/core/index.js +1 -4
- package/lib/core/index.js.map +1 -1
- package/lib/core/logger.d.ts +6 -3
- package/lib/core/logger.js +15 -9
- package/lib/core/logger.js.map +1 -1
- package/lib/core/metadata.d.ts +1 -1
- package/lib/core/metadata.js +3 -79
- package/lib/core/metadata.js.map +1 -1
- package/lib/core/meter.d.ts +1 -1
- package/lib/core/meter.js +2 -2
- package/lib/core/meter.js.map +1 -1
- package/lib/core/numberish.d.ts +1 -1
- package/lib/core/numberish.js +7 -7
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/numberish.test.js.map +1 -1
- package/lib/core/solana-processor.d.ts +1 -1
- package/lib/core/solana-processor.js.map +1 -1
- package/lib/core/sui-processor.d.ts +1 -1
- package/lib/core/sui-processor.js.map +1 -1
- package/lib/gen/index.d.ts +1 -0
- package/lib/gen/index.js +18 -0
- package/lib/gen/index.js.map +1 -0
- package/lib/gen/processor/protos/processor.d.ts +165 -163
- package/lib/gen/processor/protos/processor.js +455 -482
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +15 -2
- package/lib/index.js.map +1 -1
- package/lib/processor-state.d.ts +2 -1
- package/lib/processor-state.js.map +1 -1
- package/lib/service.d.ts +13 -7
- package/lib/service.js +133 -44
- package/lib/service.js.map +1 -1
- package/lib/testing/metric-utils.d.ts +1 -1
- package/lib/testing/metric-utils.js +2 -2
- package/lib/testing/metric-utils.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +16 -15
- package/lib/testing/test-processor-server.js +19 -14
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/testing/test-provider.js +2 -2
- package/lib/testing/test-provider.js.map +1 -1
- package/lib/tests/aptos.test.js +44 -12
- package/lib/tests/aptos.test.js.map +1 -1
- package/lib/tests/erc20.test.js +1 -1
- package/lib/tests/erc20.test.js.map +1 -1
- package/lib/tests/logger.test.js +1 -1
- package/lib/tests/logger.test.js.map +1 -1
- package/lib/tests/souffl3.js +16 -4
- package/lib/tests/souffl3.js.map +1 -1
- package/lib/utils/chain.d.ts +1 -0
- package/lib/utils/chain.js +3 -1
- package/lib/utils/chain.js.map +1 -1
- package/lib/utils/erc20.test.js +0 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/package.json +3 -5
- package/src/aptos/aptos-processor.ts +156 -0
- package/src/aptos/bind-options.ts +15 -0
- package/src/aptos/context.ts +35 -0
- package/src/aptos/index.ts +8 -0
- package/src/core/base-processor-template.ts +1 -1
- package/src/core/base-processor.ts +1 -1
- package/src/core/bind-options.ts +0 -1
- package/src/core/context.ts +74 -15
- package/src/core/generic-processor.test.ts +1 -1
- package/src/core/index.ts +2 -2
- package/src/core/logger.ts +13 -5
- package/src/core/metadata.ts +4 -76
- package/src/core/meter.ts +1 -1
- package/src/core/numberish.test.ts +1 -1
- package/src/core/numberish.ts +1 -1
- package/src/core/solana-processor.ts +1 -1
- package/src/core/sui-processor.ts +1 -1
- package/src/gen/index.ts +1 -0
- package/src/gen/processor/protos/processor.ts +606 -650
- package/src/index.ts +4 -1
- package/src/processor-state.ts +3 -1
- package/src/service.ts +153 -61
- package/src/testing/metric-utils.ts +2 -2
- package/src/testing/test-processor-server.ts +31 -33
- package/src/testing/test-provider.ts +1 -1
- package/src/tests/aptos.test.ts +47 -11
- package/src/tests/erc20.test.ts +1 -1
- package/src/tests/logger.test.ts +1 -1
- package/src/tests/souffl3.ts +30 -12
- package/src/utils/chain.ts +2 -0
- package/src/utils/erc20.test.ts +1 -4
- package/lib/core/aptos-processor.d.ts +0 -22
- package/lib/core/aptos-processor.js +0 -67
- package/lib/core/aptos-processor.js.map +0 -1
- package/src/core/aptos-processor.ts +0 -77
package/lib/utils/chain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../src/utils/chain.ts"],"names":[],"mappings":";AAAA,mFAAmF;AACnF,6EAA6E;;;AAEhE,QAAA,SAAS,GAA2B;IAC/C,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,MAAM;IACT,EAAE,EAAE,UAAU;IACd,EAAE,EAAE,UAAU;IACd,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,YAAY;IAChB,EAAE,EAA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,aAAa,CAAA;AAC9B,QAAA,aAAa,GAAG,YAAY,CAAA;AAC5B,QAAA,eAAe,GAAG,aAAa,CAAA;AAC5C,iBAAS,CAAC,sBAAc,CAAC,GAAG,QAAQ,CAAA;AACpC,iBAAS,CAAC,qBAAa,CAAC,GAAG,YAAY,CAAA;AACvC,iBAAS,CAAC,uBAAe,CAAC,GAAG,aAAa,CAAA;AAE7B,QAAA,aAAa,GAAG,YAAY,CAAA;AACzC,iBAAS,CAAC,qBAAa,CAAC,GAAG,SAAS,CAAA;AAEvB,QAAA,gBAAgB,GAAG,eAAe,CAAA;AAClC,QAAA,gBAAgB,GAAG,eAAe,CAAA;AAC/C,iBAAS,CAAC,wBAAgB,CAAC,GAAG,YAAY,CAAA;AAC1C,iBAAS,CAAC,wBAAgB,CAAC,GAAG,eAAe,CAAA;AAE7C,SAAgB,YAAY,CAAC,OAAwB;IACnD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAA;KAC7B;IACD,MAAM,IAAI,GAAG,iBAAS,CAAC,OAAO,CAAC,CAAA;IAC/B,IAAI,IAAI,EAAE;QACR,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AATD,oCASC","sourcesContent":["// copy from https://github.com/DefiLlama/chainlist/blob/main/constants/chainIds.js\n// and https://besu.hyperledger.org/en/stable/Concepts/NetworkID-And-ChainID/\n\nexport const CHAIN_MAP: Record<string, string> = {\n 0: 'kardia',\n 1: 'ethereum',\n 2: 'expanse',\n 3: 'ropsten',\n 4: 'rinkeby',\n 5: 'goerli',\n 6: 'kotti',\n 8: 'ubiq',\n 10: 'optimism',\n 19: 'songbird',\n 20: 'elastos',\n 25: 'cronos',\n 30: 'rsk',\n 40: 'telos',\n 50: 'xdc',\n 52: 'csc',\n 55: 'zyx',\n 56: 'binance',\n 57: 'syscoin',\n 60: 'gochain',\n 61: 'ethclassic',\n 63: 'mordor',\n 66: 'okexchain',\n 70: 'hoo',\n 82: 'meter',\n 88: 'tomochain',\n 100: 'xdai',\n 106: 'velas',\n 108: 'thundercore',\n 122: 'fuse',\n 128: 'heco',\n 137: 'polygon',\n 200: 'xdaiarb',\n 212: 'astor',\n 246: 'energyweb',\n 250: 'fantom',\n 269: 'hpb',\n 288: 'boba',\n 321: 'kucoin',\n 336: 'shiden',\n 361: 'theta',\n 416: 'sx',\n 534: 'candle',\n 592: 'astar',\n 820: 'callisto',\n 888: 'wanchain',\n 1088: 'metis',\n 1246: 'omchain',\n 1284: 'moonbeam',\n 1285: 'moonriver',\n 2018: 'dev',\n 2020: 'ronin',\n 2222: 'kava',\n 2612: 'ezchain',\n 4181: 'phi',\n 4689: 'iotex',\n 5050: 'xlc',\n 5551: 'nahmii',\n 7777: 'nmactest',\n 8217: 'klaytn',\n 9001: 'evmos',\n 10000: 'smartbch',\n 103090: 'crystaleum',\n 32659: 'fusion',\n 42161: 'arbitrum',\n 42220: 'celo',\n 42262: 'oasis',\n 43114: 'avalanche',\n 71402: 'godwoken',\n 200625: 'akroma',\n 333999: 'polis',\n 11155111: 'sepolia',\n 1313161554: 'aurora',\n 1666600000: 'harmony',\n 11297108109: 'palm',\n 836542336838601: 'curio',\n}\n\nexport const SOL_MAINMET_ID = 'sol_mainnet'\nexport const SOL_DEVNET_ID = 'sol_devnet'\nexport const SOL_TESTNENT_ID = 'sol_testnet'\nCHAIN_MAP[SOL_MAINMET_ID] = 'solana'\nCHAIN_MAP[SOL_DEVNET_ID] = 'solana-dev'\nCHAIN_MAP[SOL_TESTNENT_ID] = 'solana-test'\n\nexport const SUI_DEVNET_ID = 'sui_devnet'\nCHAIN_MAP[SUI_DEVNET_ID] = 'sui-dev'\n\nexport const APTOS_TESTNET_ID = 'aptos_testnet'\nexport const APTOS_MAINNET_ID = 'aptos_mainnet'\nCHAIN_MAP[APTOS_TESTNET_ID] = 'aptos-test'\nCHAIN_MAP[APTOS_MAINNET_ID] = 'aptos-mainnet'\n\nexport function getChainName(chainId: string | number): string {\n if (typeof chainId === 'number') {\n chainId = chainId.toString()\n }\n const name = CHAIN_MAP[chainId]\n if (name) {\n return name\n }\n return chainId\n}\n"]}
|
package/lib/utils/erc20.test.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const sdk_1 = require("@sentio/sdk");
|
|
4
|
-
console.log(sdk_1.DummyProvider);
|
|
5
4
|
const token_1 = require("./token");
|
|
6
5
|
const test_provider_1 = require("../testing/test-provider");
|
|
7
6
|
describe('erc20 tests', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20.test.js","sourceRoot":"","sources":["../../src/utils/erc20.test.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"erc20.test.js","sourceRoot":"","sources":["../../src/utils/erc20.test.ts"],"names":[],"mappings":";;AAAA,qCAA4C;AAC5C,mCAA2C;AAC3C,4DAAmE;AAEnE,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,MAAM,CAAC,eAAe,GAAG,IAAI,oBAAc,EAAE,CAAA;IAC7C,MAAM,aAAa,GAAG,IAAA,wCAAwB,EAAC,GAAG,CAAC,CAAA;IAEnD,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;IAE/C,MAAM,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;QAChC,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAiB,EAAC,4CAA4C,CAAC,CAAA;QAElF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAChC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAClC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAiB,EAAC,4CAA4C,CAAC,CAAA;QAElF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACnC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { ProcessorState } from '@sentio/sdk'\nimport { getERC20TokenInfo } from './token'\nimport { loadTestProvidersFromEnv } from '../testing/test-provider'\n\ndescribe('erc20 tests', () => {\n global.PROCESSOR_STATE = new ProcessorState()\n const haveProviders = loadTestProvidersFromEnv('1')\n\n const testIf = haveProviders ? test : test.skip\n\n testIf('test bytes32', async () => {\n const info = await getERC20TokenInfo('0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2')\n\n expect(info.decimal).toEqual(18)\n expect(info.symbol).toEqual('MKR')\n expect(info.name).toEqual('Maker')\n })\n\n testIf('test normal', async () => {\n const info = await getERC20TokenInfo('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')\n\n expect(info.decimal).toEqual(6)\n expect(info.symbol).toEqual('USDC')\n expect(info.name).toEqual('USD Coin')\n })\n})\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.19.
|
|
4
|
+
"version": "1.19.5",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
7
7
|
"compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@typechain/ethers-v5": "^10.0.0",
|
|
27
27
|
"@types/bn.js": "^5.1.0",
|
|
28
28
|
"@types/node-fetch": "^2.6.2",
|
|
29
|
+
"aptos": "^1.3.15",
|
|
29
30
|
"bignumber.js": "^9.1.0",
|
|
30
31
|
"bn.js": "^5.2.1",
|
|
31
32
|
"bs58": "^5.0.0",
|
|
@@ -52,17 +53,14 @@
|
|
|
52
53
|
"@types/expect": "^24.3.0",
|
|
53
54
|
"@types/fs-extra": "^9.0.13",
|
|
54
55
|
"@types/google-protobuf": "^3.15.6",
|
|
55
|
-
"@types/jest": "^29.0.0",
|
|
56
56
|
"@types/js-yaml": "^4.0.5",
|
|
57
57
|
"@types/mkdirp": "^1.0.2",
|
|
58
58
|
"@types/node": "^18.0.4",
|
|
59
59
|
"chai": "^4.3.6",
|
|
60
60
|
"clean-publish": "^4.0.1",
|
|
61
61
|
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
62
|
-
"jest": "^29.0.0",
|
|
63
62
|
"semantic-release": "^19.0.5",
|
|
64
|
-
"ts-
|
|
65
|
-
"ts-node": "^10.8.0",
|
|
63
|
+
"ts-node": "^10.9.1",
|
|
66
64
|
"tsconfig-paths": "^4.0.0",
|
|
67
65
|
"typedoc": "^0.23.15",
|
|
68
66
|
"typescript": "^4.8.0"
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ProcessResult } from '../gen'
|
|
2
|
+
import { AptosBindOptions, AptosContext, AptosNetwork, FunctionPayload, UserTransaction } from '.'
|
|
3
|
+
import type { Event as OldEvent } from 'aptos/src/generated'
|
|
4
|
+
|
|
5
|
+
import Long from 'long'
|
|
6
|
+
import { APTOS_MAINNET_ID, APTOS_TESTNET_ID } from '../utils/chain'
|
|
7
|
+
|
|
8
|
+
export type Event = OldEvent & { version: string }
|
|
9
|
+
|
|
10
|
+
type IndexConfigure = {
|
|
11
|
+
address: string
|
|
12
|
+
network: AptosNetwork
|
|
13
|
+
startVersion: Long
|
|
14
|
+
// endSeqNumber?: Long
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface EventFilter {
|
|
18
|
+
type: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CallFilter {
|
|
22
|
+
function: string
|
|
23
|
+
typeArguments: string[] | undefined
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class EventHandler {
|
|
27
|
+
filters: EventFilter[]
|
|
28
|
+
handler: (event: Event) => Promise<ProcessResult>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class CallHandler {
|
|
32
|
+
filters: CallFilter[]
|
|
33
|
+
handler: (call: UserTransaction) => Promise<ProcessResult>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class AptosBaseProcessor {
|
|
37
|
+
name: string
|
|
38
|
+
config: IndexConfigure
|
|
39
|
+
eventHandlers: EventHandler[] = []
|
|
40
|
+
callHandlers: CallHandler[] = []
|
|
41
|
+
|
|
42
|
+
constructor(options: AptosBindOptions) {
|
|
43
|
+
this.name = options.name || options.address
|
|
44
|
+
this.configure(options)
|
|
45
|
+
global.PROCESSOR_STATE.aptosProcessors.push(this)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public onTransaction(handler: (transaction: UserTransaction, ctx: AptosContext) => void) {
|
|
49
|
+
const address = this.config.address
|
|
50
|
+
this.callHandlers.push({
|
|
51
|
+
handler: async function (tx) {
|
|
52
|
+
const ctx = new AptosContext(address, Long.fromString(tx.version), tx)
|
|
53
|
+
if (tx) {
|
|
54
|
+
handler(tx, ctx)
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
gauges: ctx.gauges,
|
|
58
|
+
counters: ctx.counters,
|
|
59
|
+
logs: ctx.logs,
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
filters: [],
|
|
63
|
+
})
|
|
64
|
+
return this
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public onEvent(handler: (event: Event, ctx: AptosContext) => void, filter: EventFilter | EventFilter[]) {
|
|
68
|
+
let _filters: EventFilter[] = []
|
|
69
|
+
|
|
70
|
+
if (Array.isArray(filter)) {
|
|
71
|
+
_filters = filter
|
|
72
|
+
} else {
|
|
73
|
+
_filters.push(filter)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const address = this.config.address
|
|
77
|
+
|
|
78
|
+
this.eventHandlers.push({
|
|
79
|
+
handler: async function (event) {
|
|
80
|
+
const ctx = new AptosContext(address, Long.fromString(event.version))
|
|
81
|
+
if (event) {
|
|
82
|
+
handler(event, ctx)
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
gauges: ctx.gauges,
|
|
86
|
+
counters: ctx.counters,
|
|
87
|
+
logs: ctx.logs,
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
filters: _filters,
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public onFunctionCall(
|
|
95
|
+
handler: (call: FunctionPayload, ctx: AptosContext) => void,
|
|
96
|
+
filter: CallFilter | CallFilter[]
|
|
97
|
+
) {
|
|
98
|
+
let _filters: CallFilter[] = []
|
|
99
|
+
|
|
100
|
+
if (Array.isArray(filter)) {
|
|
101
|
+
_filters = filter
|
|
102
|
+
} else {
|
|
103
|
+
_filters.push(filter)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const address = this.config.address
|
|
107
|
+
|
|
108
|
+
this.callHandlers.push({
|
|
109
|
+
handler: async function (tx) {
|
|
110
|
+
const ctx = new AptosContext(address, Long.fromString(tx.version), tx)
|
|
111
|
+
if (tx) {
|
|
112
|
+
const payload = tx.payload as FunctionPayload
|
|
113
|
+
handler(payload, ctx)
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
gauges: ctx.gauges,
|
|
117
|
+
counters: ctx.counters,
|
|
118
|
+
logs: ctx.logs,
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
filters: _filters,
|
|
122
|
+
})
|
|
123
|
+
return this
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private configure(options: AptosBindOptions) {
|
|
127
|
+
let startVersion = Long.ZERO
|
|
128
|
+
if (options.startVersion) {
|
|
129
|
+
startVersion = Long.fromValue(options.startVersion)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this.config = {
|
|
133
|
+
startVersion: startVersion,
|
|
134
|
+
address: options.address,
|
|
135
|
+
network: options.network || AptosNetwork.TEST_NET,
|
|
136
|
+
}
|
|
137
|
+
return this
|
|
138
|
+
}
|
|
139
|
+
//
|
|
140
|
+
// public endBlock(endBlock: Long | number) {
|
|
141
|
+
// if (typeof endBlock === 'number') {
|
|
142
|
+
// endBlock = Long.fromNumber(endBlock)
|
|
143
|
+
// }
|
|
144
|
+
// this.config.endSeqNumber = endBlock
|
|
145
|
+
// return this
|
|
146
|
+
// }
|
|
147
|
+
|
|
148
|
+
getChainId(): string {
|
|
149
|
+
switch (this.config.network) {
|
|
150
|
+
case AptosNetwork.TEST_NET:
|
|
151
|
+
return APTOS_TESTNET_ID
|
|
152
|
+
case AptosNetwork.MAIN_NET:
|
|
153
|
+
return APTOS_MAINNET_ID
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Long from 'long'
|
|
2
|
+
|
|
3
|
+
export enum AptosNetwork {
|
|
4
|
+
MAIN_NET = 0,
|
|
5
|
+
TEST_NET = 1,
|
|
6
|
+
// DEV_NET,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class AptosBindOptions {
|
|
10
|
+
address: string
|
|
11
|
+
network?: AptosNetwork = AptosNetwork.TEST_NET
|
|
12
|
+
name?: string
|
|
13
|
+
startVersion?: Long | number
|
|
14
|
+
// endBlock?: Long | number
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Long from 'long'
|
|
2
|
+
import { MetricDescriptor, RecordMetaData } from '../gen'
|
|
3
|
+
import { Labels } from '../core/metadata'
|
|
4
|
+
import { APTOS_TESTNET_ID } from '../utils/chain'
|
|
5
|
+
import { normalizeLabels } from '../core/meter'
|
|
6
|
+
import { BaseContext } from '../core/context'
|
|
7
|
+
import { UserTransaction } from './'
|
|
8
|
+
|
|
9
|
+
export class AptosContext extends BaseContext {
|
|
10
|
+
address: string
|
|
11
|
+
blockNumber: Long
|
|
12
|
+
transaction: UserTransaction
|
|
13
|
+
|
|
14
|
+
constructor(address: string, slot: Long, transaction?: UserTransaction) {
|
|
15
|
+
super()
|
|
16
|
+
this.address = address
|
|
17
|
+
this.blockNumber = slot
|
|
18
|
+
if (transaction) {
|
|
19
|
+
this.transaction = transaction
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getMetaData(descriptor: MetricDescriptor | undefined, labels: Labels): RecordMetaData {
|
|
24
|
+
return {
|
|
25
|
+
contractAddress: this.address,
|
|
26
|
+
blockNumber: this.blockNumber,
|
|
27
|
+
transactionIndex: 0,
|
|
28
|
+
transactionHash: this.transaction?.hash || '', // TODO
|
|
29
|
+
logIndex: 0,
|
|
30
|
+
chainId: APTOS_TESTNET_ID, // TODO set in context
|
|
31
|
+
descriptor: descriptor,
|
|
32
|
+
labels: normalizeLabels(labels),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
Transaction_UserTransaction as UserTransaction,
|
|
3
|
+
TransactionPayload_EntryFunctionPayload as FunctionPayload,
|
|
4
|
+
} from 'aptos/src/generated'
|
|
5
|
+
export type { Event, CallFilter, EventFilter } from './aptos-processor'
|
|
6
|
+
export { AptosBaseProcessor } from './aptos-processor'
|
|
7
|
+
export { AptosContext } from './context'
|
|
8
|
+
export { AptosBindOptions, AptosNetwork } from './bind-options'
|
|
@@ -4,7 +4,7 @@ import { BaseContract, EventFilter } from 'ethers'
|
|
|
4
4
|
import { Event } from '@ethersproject/contracts'
|
|
5
5
|
import { BaseProcessor } from './base-processor'
|
|
6
6
|
import { BindOptions, getOptionsSignature } from './bind-options'
|
|
7
|
-
import { TemplateInstance } from '../gen
|
|
7
|
+
import { TemplateInstance } from '../gen'
|
|
8
8
|
import Long from 'long'
|
|
9
9
|
import { getNetwork } from '@ethersproject/providers'
|
|
10
10
|
import { PromiseOrVoid } from '../promise-or-void'
|
|
@@ -5,7 +5,7 @@ import { BaseContract, EventFilter } from '@ethersproject/contracts'
|
|
|
5
5
|
import Long from 'long'
|
|
6
6
|
|
|
7
7
|
import { BoundContractView, Context, ContractView } from './context'
|
|
8
|
-
import { ProcessResult } from '../gen
|
|
8
|
+
import { ProcessResult } from '../gen'
|
|
9
9
|
import { BindInternalOptions, BindOptions } from './bind-options'
|
|
10
10
|
import { PromiseOrVoid } from '../promise-or-void'
|
|
11
11
|
import { Trace } from './trace'
|
package/src/core/bind-options.ts
CHANGED
package/src/core/context.ts
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { CounterResult, GaugeResult, LogResult } from '../gen
|
|
1
|
+
import { CounterResult, GaugeResult, LogResult, MetricDescriptor, RecordMetaData } from '../gen'
|
|
2
2
|
import { BaseContract, EventFilter } from 'ethers'
|
|
3
3
|
import { Block, Log } from '@ethersproject/abstract-provider'
|
|
4
|
-
import { Meter } from './meter'
|
|
4
|
+
import { Meter, normalizeLabels } from './meter'
|
|
5
5
|
import Long from 'long'
|
|
6
6
|
import { Trace } from './trace'
|
|
7
7
|
import { Logger } from './logger'
|
|
8
|
+
import { Labels } from './metadata'
|
|
9
|
+
import { SOL_MAINMET_ID, SUI_DEVNET_ID } from '../utils/chain'
|
|
8
10
|
|
|
9
|
-
export class BaseContext {
|
|
11
|
+
export abstract class BaseContext {
|
|
10
12
|
gauges: GaugeResult[] = []
|
|
11
13
|
counters: CounterResult[] = []
|
|
12
14
|
logs: LogResult[] = []
|
|
13
15
|
meter: Meter
|
|
14
16
|
logger: Logger
|
|
15
17
|
|
|
16
|
-
constructor() {
|
|
18
|
+
protected constructor() {
|
|
17
19
|
this.meter = new Meter(this)
|
|
18
20
|
this.logger = new Logger(this)
|
|
19
21
|
}
|
|
22
|
+
|
|
23
|
+
abstract getMetaData(descriptor: MetricDescriptor | undefined, labels: Labels): RecordMetaData
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
export class EthContext extends BaseContext {
|
|
26
|
+
export abstract class EthContext extends BaseContext {
|
|
23
27
|
chainId: number
|
|
24
28
|
log?: Log
|
|
25
29
|
block?: Block
|
|
@@ -27,7 +31,7 @@ export class EthContext extends BaseContext {
|
|
|
27
31
|
blockNumber: Long
|
|
28
32
|
transactionHash?: string
|
|
29
33
|
|
|
30
|
-
constructor(chainId: number, block?: Block, log?: Log, trace?: Trace) {
|
|
34
|
+
protected constructor(chainId: number, block?: Block, log?: Log, trace?: Trace) {
|
|
31
35
|
super()
|
|
32
36
|
this.chainId = chainId
|
|
33
37
|
this.log = log
|
|
@@ -58,6 +62,46 @@ export class Context<
|
|
|
58
62
|
this.contract = view
|
|
59
63
|
this.address = view.rawContract.address
|
|
60
64
|
}
|
|
65
|
+
|
|
66
|
+
getMetaData(descriptor: MetricDescriptor | undefined, labels: Labels): RecordMetaData {
|
|
67
|
+
if (this.log) {
|
|
68
|
+
return {
|
|
69
|
+
contractAddress: this.contract.rawContract.address,
|
|
70
|
+
blockNumber: this.blockNumber,
|
|
71
|
+
transactionIndex: this.log.transactionIndex,
|
|
72
|
+
transactionHash: this.transactionHash || '',
|
|
73
|
+
logIndex: this.log.logIndex,
|
|
74
|
+
chainId: this.chainId.toString(),
|
|
75
|
+
descriptor: descriptor,
|
|
76
|
+
labels: normalizeLabels(labels),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (this.block) {
|
|
80
|
+
return {
|
|
81
|
+
contractAddress: this.contract.rawContract.address,
|
|
82
|
+
blockNumber: this.blockNumber,
|
|
83
|
+
transactionIndex: -1,
|
|
84
|
+
transactionHash: '',
|
|
85
|
+
logIndex: -1,
|
|
86
|
+
chainId: this.chainId.toString(),
|
|
87
|
+
descriptor: descriptor,
|
|
88
|
+
labels: normalizeLabels(labels),
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (this.trace) {
|
|
92
|
+
return {
|
|
93
|
+
contractAddress: this.contract.rawContract.address,
|
|
94
|
+
blockNumber: this.blockNumber,
|
|
95
|
+
transactionIndex: this.trace.transactionPosition,
|
|
96
|
+
transactionHash: this.transactionHash || '',
|
|
97
|
+
logIndex: -1,
|
|
98
|
+
chainId: this.chainId.toString(),
|
|
99
|
+
descriptor: descriptor,
|
|
100
|
+
labels: normalizeLabels(labels),
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
throw new Error("Invaid ctx argument can't happen")
|
|
104
|
+
}
|
|
61
105
|
}
|
|
62
106
|
|
|
63
107
|
export class ContractView<TContract extends BaseContract> {
|
|
@@ -109,6 +153,19 @@ export class SolanaContext extends BaseContext {
|
|
|
109
153
|
this.address = address
|
|
110
154
|
this.blockNumber = slot
|
|
111
155
|
}
|
|
156
|
+
|
|
157
|
+
getMetaData(descriptor: MetricDescriptor | undefined, labels: Labels): RecordMetaData {
|
|
158
|
+
return {
|
|
159
|
+
contractAddress: this.address,
|
|
160
|
+
blockNumber: this.blockNumber,
|
|
161
|
+
transactionIndex: 0,
|
|
162
|
+
transactionHash: '', // TODO add
|
|
163
|
+
logIndex: 0,
|
|
164
|
+
chainId: SOL_MAINMET_ID, // TODO set in context
|
|
165
|
+
descriptor: descriptor,
|
|
166
|
+
labels: normalizeLabels(labels),
|
|
167
|
+
}
|
|
168
|
+
}
|
|
112
169
|
}
|
|
113
170
|
|
|
114
171
|
export class SuiContext extends BaseContext {
|
|
@@ -120,15 +177,17 @@ export class SuiContext extends BaseContext {
|
|
|
120
177
|
this.address = address
|
|
121
178
|
this.blockNumber = slot
|
|
122
179
|
}
|
|
123
|
-
}
|
|
124
180
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
181
|
+
getMetaData(descriptor: MetricDescriptor | undefined, labels: Labels): RecordMetaData {
|
|
182
|
+
return {
|
|
183
|
+
contractAddress: this.address,
|
|
184
|
+
blockNumber: this.blockNumber,
|
|
185
|
+
transactionIndex: 0,
|
|
186
|
+
transactionHash: '', // TODO
|
|
187
|
+
logIndex: 0,
|
|
188
|
+
chainId: SUI_DEVNET_ID, // TODO set in context
|
|
189
|
+
descriptor: descriptor,
|
|
190
|
+
labels: normalizeLabels(labels),
|
|
191
|
+
}
|
|
133
192
|
}
|
|
134
193
|
}
|
|
@@ -41,7 +41,7 @@ describe('Test Generic Processor', () => {
|
|
|
41
41
|
const counters = res.result?.counters
|
|
42
42
|
expect(counters).length(2)
|
|
43
43
|
expect(firstCounterValue(res.result, 'event_num')).equals(1n)
|
|
44
|
-
expect(counters?.[0].runtimeInfo?.from).equals(HandlerType.
|
|
44
|
+
expect(counters?.[0].runtimeInfo?.from).equals(HandlerType.ETH_LOG)
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
test('Check log dispatch no buffer over rune', async () => {
|
package/src/core/index.ts
CHANGED
|
@@ -3,13 +3,13 @@ export { Context, ContractView, BoundContractView, SolanaContext } from './conte
|
|
|
3
3
|
export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricDescriptorOption } from './meter'
|
|
4
4
|
export { type Numberish, toBigInteger, toMetricValue } from './numberish'
|
|
5
5
|
|
|
6
|
-
export { BindOptions, SolanaBindOptions, SuiBindOptions
|
|
6
|
+
export { BindOptions, SolanaBindOptions, SuiBindOptions } from './bind-options'
|
|
7
7
|
|
|
8
8
|
export { BaseProcessor } from './base-processor'
|
|
9
9
|
export { GenericProcessor } from './generic-processor'
|
|
10
10
|
export { BaseProcessorTemplate } from './base-processor-template'
|
|
11
11
|
export { SolanaBaseProcessor } from './solana-processor'
|
|
12
12
|
export { SuiBaseProcessor } from './sui-processor'
|
|
13
|
-
export
|
|
13
|
+
// export * from '../aptos'
|
|
14
14
|
|
|
15
15
|
export type { TypedCallTrace, Trace } from './trace'
|
package/src/core/logger.ts
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { BaseContext } from './context'
|
|
2
2
|
import { Labels, GetRecordMetaData } from './metadata'
|
|
3
|
-
import { LogLevel } from '
|
|
3
|
+
import { LogLevel } from '../gen'
|
|
4
|
+
|
|
5
|
+
export type Attributes = Record<string, any>
|
|
4
6
|
|
|
5
7
|
export class Logger {
|
|
6
8
|
private readonly ctx: BaseContext
|
|
9
|
+
private readonly name: string
|
|
7
10
|
|
|
8
|
-
constructor(ctx: BaseContext) {
|
|
11
|
+
constructor(ctx: BaseContext, name = '') {
|
|
9
12
|
this.ctx = ctx
|
|
13
|
+
this.name = name
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
withName(name: string) {
|
|
17
|
+
return new Logger(this.ctx, name)
|
|
18
|
+
}
|
|
14
19
|
|
|
20
|
+
log(level: LogLevel, message: any, attributes: Attributes = {}) {
|
|
15
21
|
if (typeof message !== 'string' && !(message instanceof String)) {
|
|
16
22
|
message = message.toString()
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
this.ctx.logs.push({
|
|
20
|
-
|
|
26
|
+
name: this.name,
|
|
27
|
+
metadata: GetRecordMetaData(this.ctx, undefined, {}),
|
|
21
28
|
level,
|
|
22
29
|
message,
|
|
30
|
+
attributes: JSON.stringify(attributes),
|
|
23
31
|
runtimeInfo: undefined,
|
|
24
32
|
})
|
|
25
33
|
}
|
package/src/core/metadata.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MetricDescriptor, RecordMetaData } from '
|
|
3
|
-
import {
|
|
4
|
-
import { Metric, normalizeLabels, normalizeName } from './meter'
|
|
1
|
+
import { BaseContext } from './context'
|
|
2
|
+
import { MetricDescriptor, RecordMetaData } from '../gen'
|
|
3
|
+
import { Metric, normalizeName } from './meter'
|
|
5
4
|
|
|
6
5
|
export type Labels = { [key: string]: string }
|
|
7
6
|
|
|
@@ -17,76 +16,5 @@ export function GetRecordMetaData(ctx: BaseContext, metric: Metric | undefined,
|
|
|
17
16
|
descriptor.name = normalizeName(descriptor.name)
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
if (ctx.log) {
|
|
22
|
-
return {
|
|
23
|
-
contractAddress: ctx.contract.rawContract.address,
|
|
24
|
-
blockNumber: ctx.blockNumber,
|
|
25
|
-
transactionIndex: ctx.log.transactionIndex,
|
|
26
|
-
transactionHash: ctx.transactionHash || '',
|
|
27
|
-
logIndex: ctx.log.logIndex,
|
|
28
|
-
chainId: ctx.chainId.toString(),
|
|
29
|
-
descriptor: descriptor,
|
|
30
|
-
labels: normalizeLabels(labels),
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (ctx.block) {
|
|
34
|
-
return {
|
|
35
|
-
contractAddress: ctx.contract.rawContract.address,
|
|
36
|
-
blockNumber: ctx.blockNumber,
|
|
37
|
-
transactionIndex: -1,
|
|
38
|
-
transactionHash: '',
|
|
39
|
-
logIndex: -1,
|
|
40
|
-
chainId: ctx.chainId.toString(),
|
|
41
|
-
descriptor: descriptor,
|
|
42
|
-
labels: normalizeLabels(labels),
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (ctx.trace) {
|
|
46
|
-
return {
|
|
47
|
-
contractAddress: ctx.contract.rawContract.address,
|
|
48
|
-
blockNumber: ctx.blockNumber,
|
|
49
|
-
transactionIndex: ctx.trace.transactionPosition,
|
|
50
|
-
transactionHash: ctx.transactionHash || '',
|
|
51
|
-
logIndex: -1,
|
|
52
|
-
chainId: ctx.chainId.toString(),
|
|
53
|
-
descriptor: descriptor,
|
|
54
|
-
labels: normalizeLabels(labels),
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} else if (ctx instanceof SolanaContext) {
|
|
58
|
-
return {
|
|
59
|
-
contractAddress: ctx.address,
|
|
60
|
-
blockNumber: ctx.blockNumber,
|
|
61
|
-
transactionIndex: 0,
|
|
62
|
-
transactionHash: '', // TODO add
|
|
63
|
-
logIndex: 0,
|
|
64
|
-
chainId: SOL_MAINMET_ID, // TODO set in context
|
|
65
|
-
descriptor: descriptor,
|
|
66
|
-
labels: normalizeLabels(labels),
|
|
67
|
-
}
|
|
68
|
-
} else if (ctx instanceof SuiContext) {
|
|
69
|
-
return {
|
|
70
|
-
contractAddress: ctx.address,
|
|
71
|
-
blockNumber: ctx.blockNumber,
|
|
72
|
-
transactionIndex: 0,
|
|
73
|
-
transactionHash: '', // TODO
|
|
74
|
-
logIndex: 0,
|
|
75
|
-
chainId: SUI_DEVNET_ID, // TODO set in context
|
|
76
|
-
descriptor: descriptor,
|
|
77
|
-
labels: normalizeLabels(labels),
|
|
78
|
-
}
|
|
79
|
-
} else if (ctx instanceof AptosContext) {
|
|
80
|
-
return {
|
|
81
|
-
contractAddress: ctx.address,
|
|
82
|
-
blockNumber: ctx.blockNumber,
|
|
83
|
-
transactionIndex: 0,
|
|
84
|
-
transactionHash: '', // TODO
|
|
85
|
-
logIndex: 0,
|
|
86
|
-
chainId: APTOS_TESTNET_ID, // TODO set in context
|
|
87
|
-
descriptor: descriptor,
|
|
88
|
-
labels: normalizeLabels(labels),
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
throw new Error("This can't happen")
|
|
19
|
+
return ctx.getMetaData(descriptor, labels)
|
|
92
20
|
}
|
package/src/core/meter.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { toBigInteger, toMetricValue } from './numberish'
|
|
|
3
3
|
import { webcrypto } from 'crypto'
|
|
4
4
|
import { BigNumber } from 'ethers'
|
|
5
5
|
import { performance } from 'perf_hooks'
|
|
6
|
-
import { BigInteger } from '../gen
|
|
6
|
+
import { BigInteger } from '../gen'
|
|
7
7
|
import { BigDecimal } from '.'
|
|
8
8
|
|
|
9
9
|
// TODO add test for type conversion
|
package/src/core/numberish.ts
CHANGED
package/src/gen/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../gen/processor/protos/processor'
|