@sentio/sdk 1.13.1 → 1.14.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.
- package/lib/cli/commands/run-create.js +2 -0
- package/lib/cli/commands/run-create.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +0 -1
- package/lib/gen/processor/protos/processor.js +0 -10
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/meter.js +0 -5
- package/lib/meter.js.map +1 -1
- package/lib/test/metric-utils.js +2 -2
- package/lib/test/metric-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/run-create.ts +3 -0
- package/src/gen/processor/protos/processor.ts +0 -11
- package/src/meter.ts +0 -5
- package/src/test/metric-utils.ts +2 -2
- package/template/package.json +2 -3
- package/template/src/processor.test.ts +1 -1
- package/template/src/processor.ts +20 -16
- package/template/node_modules/@sentio/sdk/lib/base-processor-template.d.ts +0 -27
- package/template/node_modules/@sentio/sdk/lib/base-processor-template.js +0 -80
- package/template/node_modules/@sentio/sdk/lib/base-processor-template.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/base-processor.d.ts +0 -30
- package/template/node_modules/@sentio/sdk/lib/base-processor.js +0 -148
- package/template/node_modules/@sentio/sdk/lib/base-processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/bind-options.d.ts +0 -21
- package/template/node_modules/@sentio/sdk/lib/bind-options.js +0 -42
- package/template/node_modules/@sentio/sdk/lib/bind-options.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/binds.d.ts +0 -10
- package/template/node_modules/@sentio/sdk/lib/binds.js +0 -59
- package/template/node_modules/@sentio/sdk/lib/binds.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20/index.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20/index.js +0 -22
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20/test-utils.d.ts +0 -5
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20/test-utils.js +0 -46
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20/test-utils.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20bytes/index.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20bytes/index.js +0 -22
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20bytes/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20bytes/test-utils.d.ts +0 -4
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20bytes/test-utils.js +0 -35
- package/template/node_modules/@sentio/sdk/lib/builtin/erc20bytes/test-utils.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/ERC20.d.ts +0 -307
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/ERC20.js +0 -3
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/ERC20.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/ERC20Bytes.d.ts +0 -166
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/ERC20Bytes.js +0 -3
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/ERC20Bytes.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/WETH9.d.ts +0 -221
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/WETH9.js +0 -3
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/WETH9.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/common.d.ts +0 -22
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/common.js +0 -3
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/common.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/erc20_processor.d.ts +0 -184
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/erc20_processor.js +0 -453
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/erc20_processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/erc20bytes_processor.d.ts +0 -110
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/erc20bytes_processor.js +0 -325
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/erc20bytes_processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/ERC20Bytes__factory.d.ts +0 -48
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/ERC20Bytes__factory.js +0 -254
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/ERC20Bytes__factory.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/ERC20__factory.d.ts +0 -42
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/ERC20__factory.js +0 -404
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/ERC20__factory.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/WETH9__factory.d.ts +0 -45
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/WETH9__factory.js +0 -297
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/WETH9__factory.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/index.d.ts +0 -3
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/index.js +0 -13
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/factories/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/index.d.ts +0 -7
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/index.js +0 -34
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/weth9_processor.d.ts +0 -126
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/weth9_processor.js +0 -361
- package/template/node_modules/@sentio/sdk/lib/builtin/internal/weth9_processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/weth9/index.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/builtin/weth9/index.js +0 -22
- package/template/node_modules/@sentio/sdk/lib/builtin/weth9/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/builtin/weth9/test-utils.d.ts +0 -6
- package/template/node_modules/@sentio/sdk/lib/builtin/weth9/test-utils.js +0 -57
- package/template/node_modules/@sentio/sdk/lib/builtin/weth9/test-utils.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/chain-config.d.ts +0 -6
- package/template/node_modules/@sentio/sdk/lib/chain-config.js +0 -3
- package/template/node_modules/@sentio/sdk/lib/chain-config.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/build.d.ts +0 -4
- package/template/node_modules/@sentio/sdk/lib/cli/build.js +0 -178
- package/template/node_modules/@sentio/sdk/lib/cli/build.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/cli.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/cli/cli.js +0 -163
- package/template/node_modules/@sentio/sdk/lib/cli/cli.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/commands/run-create.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/commands/run-create.js +0 -43
- package/template/node_modules/@sentio/sdk/lib/cli/commands/run-create.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/commands/run-login.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/commands/run-login.js +0 -77
- package/template/node_modules/@sentio/sdk/lib/cli/commands/run-login.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/config.d.ts +0 -16
- package/template/node_modules/@sentio/sdk/lib/cli/config.js +0 -36
- package/template/node_modules/@sentio/sdk/lib/cli/config.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/key.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/cli/key.js +0 -44
- package/template/node_modules/@sentio/sdk/lib/cli/key.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/solana-code-gen.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/cli/solana-code-gen.js +0 -19
- package/template/node_modules/@sentio/sdk/lib/cli/solana-code-gen.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/upload.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/cli/upload.js +0 -85
- package/template/node_modules/@sentio/sdk/lib/cli/upload.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/cli/webpack.config.js +0 -42
- package/template/node_modules/@sentio/sdk/lib/context.d.ts +0 -49
- package/template/node_modules/@sentio/sdk/lib/context.js +0 -93
- package/template/node_modules/@sentio/sdk/lib/context.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/contract-namer.d.ts +0 -6
- package/template/node_modules/@sentio/sdk/lib/contract-namer.js +0 -20
- package/template/node_modules/@sentio/sdk/lib/contract-namer.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/error.d.ts +0 -7
- package/template/node_modules/@sentio/sdk/lib/error.js +0 -43
- package/template/node_modules/@sentio/sdk/lib/error.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/gen/builtin.d.ts +0 -6
- package/template/node_modules/@sentio/sdk/lib/gen/builtin.js +0 -3
- package/template/node_modules/@sentio/sdk/lib/gen/builtin.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/gen/google/protobuf/empty.d.ts +0 -16
- package/template/node_modules/@sentio/sdk/lib/gen/google/protobuf/empty.js +0 -47
- package/template/node_modules/@sentio/sdk/lib/gen/google/protobuf/empty.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/gen/processor/protos/processor.d.ts +0 -666
- package/template/node_modules/@sentio/sdk/lib/gen/processor/protos/processor.js +0 -2837
- package/template/node_modules/@sentio/sdk/lib/gen/processor/protos/processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/generic-processor.d.ts +0 -10
- package/template/node_modules/@sentio/sdk/lib/generic-processor.js +0 -32
- package/template/node_modules/@sentio/sdk/lib/generic-processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/index.d.ts +0 -18
- package/template/node_modules/@sentio/sdk/lib/index.js +0 -63
- package/template/node_modules/@sentio/sdk/lib/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/loader.d.ts +0 -5
- package/template/node_modules/@sentio/sdk/lib/loader.js +0 -30
- package/template/node_modules/@sentio/sdk/lib/loader.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/meter.d.ts +0 -26
- package/template/node_modules/@sentio/sdk/lib/meter.js +0 -131
- package/template/node_modules/@sentio/sdk/lib/meter.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/meter.test.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/meter.test.js +0 -16
- package/template/node_modules/@sentio/sdk/lib/meter.test.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/numberish.d.ts +0 -6
- package/template/node_modules/@sentio/sdk/lib/numberish.js +0 -96
- package/template/node_modules/@sentio/sdk/lib/numberish.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/numberish.test.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/numberish.test.js +0 -70
- package/template/node_modules/@sentio/sdk/lib/numberish.test.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/processor-runner.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/processor-runner.js +0 -40
- package/template/node_modules/@sentio/sdk/lib/processor-runner.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/processor-state.d.ts +0 -16
- package/template/node_modules/@sentio/sdk/lib/processor-state.js +0 -20
- package/template/node_modules/@sentio/sdk/lib/processor-state.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/promise-or-void.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/promise-or-void.js +0 -3
- package/template/node_modules/@sentio/sdk/lib/promise-or-void.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/provider.d.ts +0 -6
- package/template/node_modules/@sentio/sdk/lib/provider.js +0 -66
- package/template/node_modules/@sentio/sdk/lib/provider.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/release.config.js +0 -31
- package/template/node_modules/@sentio/sdk/lib/service.d.ts +0 -25
- package/template/node_modules/@sentio/sdk/lib/service.js +0 -406
- package/template/node_modules/@sentio/sdk/lib/service.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/index.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/index.js +0 -19
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/spl-token-processor.d.ts +0 -26
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/spl-token-processor.js +0 -138
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/spl-token-processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/types.d.ts +0 -330
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/types.js +0 -203
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/types.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/wormhole-processor.d.ts +0 -18
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/wormhole-processor.js +0 -192
- package/template/node_modules/@sentio/sdk/lib/solana/builtin/wormhole-processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/solana-processor.d.ts +0 -34
- package/template/node_modules/@sentio/sdk/lib/solana-processor.js +0 -95
- package/template/node_modules/@sentio/sdk/lib/solana-processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/codegen.d.ts +0 -4
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/codegen.js +0 -292
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/codegen.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/functions.d.ts +0 -3
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/functions.js +0 -61
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/functions.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/index.d.ts +0 -6
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/index.js +0 -51
- package/template/node_modules/@sentio/sdk/lib/target-ethers-sentio/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/codegen.test.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/codegen.test.js +0 -49
- package/template/node_modules/@sentio/sdk/lib/test/codegen.test.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/erc20-template.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/erc20-template.js +0 -23
- package/template/node_modules/@sentio/sdk/lib/test/erc20-template.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/erc20-template.test.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/erc20-template.test.js +0 -37
- package/template/node_modules/@sentio/sdk/lib/test/erc20-template.test.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/erc20.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/erc20.js +0 -44
- package/template/node_modules/@sentio/sdk/lib/test/erc20.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/erc20.test.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/erc20.test.js +0 -96
- package/template/node_modules/@sentio/sdk/lib/test/erc20.test.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/generic-processor.test.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/generic-processor.test.js +0 -59
- package/template/node_modules/@sentio/sdk/lib/test/generic-processor.test.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/index.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/test/index.js +0 -8
- package/template/node_modules/@sentio/sdk/lib/test/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/metric-utils.d.ts +0 -6
- package/template/node_modules/@sentio/sdk/lib/test/metric-utils.js +0 -50
- package/template/node_modules/@sentio/sdk/lib/test/metric-utils.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/mirrorworld.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/mirrorworld.js +0 -42
- package/template/node_modules/@sentio/sdk/lib/test/mirrorworld.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/solana.test.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/solana.test.js +0 -90
- package/template/node_modules/@sentio/sdk/lib/test/solana.test.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/test-processor-server.d.ts +0 -34
- package/template/node_modules/@sentio/sdk/lib/test/test-processor-server.js +0 -205
- package/template/node_modules/@sentio/sdk/lib/test/test-processor-server.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/test-provider.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/test-provider.js +0 -25
- package/template/node_modules/@sentio/sdk/lib/test/test-provider.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/types/game_wallet.d.ts +0 -45
- package/template/node_modules/@sentio/sdk/lib/test/types/game_wallet.js +0 -1396
- package/template/node_modules/@sentio/sdk/lib/test/types/game_wallet.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/types/game_wallet_processor.d.ts +0 -107
- package/template/node_modules/@sentio/sdk/lib/test/types/game_wallet_processor.js +0 -105
- package/template/node_modules/@sentio/sdk/lib/test/types/game_wallet_processor.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/wormhole-token-bridge.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/test/wormhole-token-bridge.js +0 -22
- package/template/node_modules/@sentio/sdk/lib/test/wormhole-token-bridge.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/trace.d.ts +0 -35
- package/template/node_modules/@sentio/sdk/lib/trace.js +0 -43
- package/template/node_modules/@sentio/sdk/lib/trace.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/utils/chainmap.d.ts +0 -2
- package/template/node_modules/@sentio/sdk/lib/utils/chainmap.js +0 -98
- package/template/node_modules/@sentio/sdk/lib/utils/chainmap.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/utils/convert.d.ts +0 -5
- package/template/node_modules/@sentio/sdk/lib/utils/convert.js +0 -27
- package/template/node_modules/@sentio/sdk/lib/utils/convert.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/utils/erc20.d.ts +0 -14
- package/template/node_modules/@sentio/sdk/lib/utils/erc20.js +0 -62
- package/template/node_modules/@sentio/sdk/lib/utils/erc20.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/utils/erc20.test.d.ts +0 -1
- package/template/node_modules/@sentio/sdk/lib/utils/erc20.test.js +0 -23
- package/template/node_modules/@sentio/sdk/lib/utils/erc20.test.js.map +0 -1
- package/template/node_modules/@sentio/sdk/lib/utils/index.d.ts +0 -3
- package/template/node_modules/@sentio/sdk/lib/utils/index.js +0 -14
- package/template/node_modules/@sentio/sdk/lib/utils/index.js.map +0 -1
- package/template/node_modules/@sentio/sdk/package.json +0 -78
- package/template/node_modules/@sentio/sdk/src/abis/ERC20.json +0 -174
- package/template/node_modules/@sentio/sdk/src/abis/ERC20Bytes.json +0 -236
- package/template/node_modules/@sentio/sdk/src/abis/WETH9.json +0 -153
- package/template/node_modules/@sentio/sdk/src/base-processor-template.ts +0 -105
- package/template/node_modules/@sentio/sdk/src/base-processor.ts +0 -172
- package/template/node_modules/@sentio/sdk/src/bind-options.ts +0 -41
- package/template/node_modules/@sentio/sdk/src/binds.ts +0 -73
- package/template/node_modules/@sentio/sdk/src/builtin/erc20/index.ts +0 -6
- package/template/node_modules/@sentio/sdk/src/builtin/erc20/test-utils.ts +0 -71
- package/template/node_modules/@sentio/sdk/src/builtin/erc20bytes/index.ts +0 -6
- package/template/node_modules/@sentio/sdk/src/builtin/erc20bytes/test-utils.ts +0 -53
- package/template/node_modules/@sentio/sdk/src/builtin/internal/ERC20.ts +0 -679
- package/template/node_modules/@sentio/sdk/src/builtin/internal/ERC20Bytes.ts +0 -384
- package/template/node_modules/@sentio/sdk/src/builtin/internal/WETH9.ts +0 -480
- package/template/node_modules/@sentio/sdk/src/builtin/internal/common.ts +0 -46
- package/template/node_modules/@sentio/sdk/src/builtin/internal/erc20_processor.ts +0 -762
- package/template/node_modules/@sentio/sdk/src/builtin/internal/erc20bytes_processor.ts +0 -531
- package/template/node_modules/@sentio/sdk/src/builtin/internal/factories/ERC20Bytes__factory.ts +0 -257
- package/template/node_modules/@sentio/sdk/src/builtin/internal/factories/ERC20__factory.ts +0 -404
- package/template/node_modules/@sentio/sdk/src/builtin/internal/factories/WETH9__factory.ts +0 -297
- package/template/node_modules/@sentio/sdk/src/builtin/internal/factories/index.ts +0 -6
- package/template/node_modules/@sentio/sdk/src/builtin/internal/index.ts +0 -10
- package/template/node_modules/@sentio/sdk/src/builtin/internal/weth9_processor.ts +0 -589
- package/template/node_modules/@sentio/sdk/src/builtin/weth9/index.ts +0 -6
- package/template/node_modules/@sentio/sdk/src/builtin/weth9/test-utils.ts +0 -89
- package/template/node_modules/@sentio/sdk/src/chain-config.ts +0 -6
- package/template/node_modules/@sentio/sdk/src/cli/build.ts +0 -196
- package/template/node_modules/@sentio/sdk/src/cli/cli.ts +0 -160
- package/template/node_modules/@sentio/sdk/src/cli/commands/run-create.ts +0 -36
- package/template/node_modules/@sentio/sdk/src/cli/commands/run-login.ts +0 -70
- package/template/node_modules/@sentio/sdk/src/cli/config.ts +0 -45
- package/template/node_modules/@sentio/sdk/src/cli/key.ts +0 -43
- package/template/node_modules/@sentio/sdk/src/cli/solana-code-gen.ts +0 -16
- package/template/node_modules/@sentio/sdk/src/cli/upload.ts +0 -88
- package/template/node_modules/@sentio/sdk/src/cli/webpack.config.js +0 -42
- package/template/node_modules/@sentio/sdk/src/context.ts +0 -103
- package/template/node_modules/@sentio/sdk/src/contract-namer.ts +0 -17
- package/template/node_modules/@sentio/sdk/src/error.ts +0 -45
- package/template/node_modules/@sentio/sdk/src/gen/builtin.ts +0 -22
- package/template/node_modules/@sentio/sdk/src/gen/google/protobuf/empty.ts +0 -70
- package/template/node_modules/@sentio/sdk/src/gen/processor/protos/processor.ts +0 -3626
- package/template/node_modules/@sentio/sdk/src/generic-processor.ts +0 -35
- package/template/node_modules/@sentio/sdk/src/index.ts +0 -21
- package/template/node_modules/@sentio/sdk/src/loader.ts +0 -24
- package/template/node_modules/@sentio/sdk/src/meter.test.ts +0 -16
- package/template/node_modules/@sentio/sdk/src/meter.ts +0 -140
- package/template/node_modules/@sentio/sdk/src/numberish.test.ts +0 -82
- package/template/node_modules/@sentio/sdk/src/numberish.ts +0 -100
- package/template/node_modules/@sentio/sdk/src/processor-runner.ts +0 -46
- package/template/node_modules/@sentio/sdk/src/processor-state.ts +0 -24
- package/template/node_modules/@sentio/sdk/src/promise-or-void.ts +0 -1
- package/template/node_modules/@sentio/sdk/src/provider.ts +0 -74
- package/template/node_modules/@sentio/sdk/src/service.ts +0 -491
- package/template/node_modules/@sentio/sdk/src/solana/builtin/index.ts +0 -2
- package/template/node_modules/@sentio/sdk/src/solana/builtin/spl-token-processor.ts +0 -164
- package/template/node_modules/@sentio/sdk/src/solana/builtin/types.ts +0 -268
- package/template/node_modules/@sentio/sdk/src/solana/builtin/wormhole-processor.ts +0 -178
- package/template/node_modules/@sentio/sdk/src/solana-processor.ts +0 -106
- package/template/node_modules/@sentio/sdk/src/target-ethers-sentio/codegen.ts +0 -315
- package/template/node_modules/@sentio/sdk/src/target-ethers-sentio/functions.ts +0 -68
- package/template/node_modules/@sentio/sdk/src/target-ethers-sentio/index.ts +0 -50
- package/template/node_modules/@sentio/sdk/src/target-ethers-sentio/tsconfig.json +0 -9
- package/template/node_modules/@sentio/sdk/src/test/abis/evm/CommitmentPool.json +0 -1034
- package/template/node_modules/@sentio/sdk/src/test/abis/evm/anyswapRouter.json +0 -490
- package/template/node_modules/@sentio/sdk/src/test/abis/solana/mirrorworld.json +0 -1392
- package/template/node_modules/@sentio/sdk/src/test/codegen.test.ts +0 -29
- package/template/node_modules/@sentio/sdk/src/test/erc20-template.test.ts +0 -37
- package/template/node_modules/@sentio/sdk/src/test/erc20-template.ts +0 -25
- package/template/node_modules/@sentio/sdk/src/test/erc20.test.ts +0 -117
- package/template/node_modules/@sentio/sdk/src/test/erc20.ts +0 -50
- package/template/node_modules/@sentio/sdk/src/test/generic-processor.test.ts +0 -70
- package/template/node_modules/@sentio/sdk/src/test/index.ts +0 -2
- package/template/node_modules/@sentio/sdk/src/test/metric-utils.ts +0 -49
- package/template/node_modules/@sentio/sdk/src/test/mirrorworld.ts +0 -40
- package/template/node_modules/@sentio/sdk/src/test/sentio.yaml +0 -4
- package/template/node_modules/@sentio/sdk/src/test/solana.test.ts +0 -93
- package/template/node_modules/@sentio/sdk/src/test/test-processor-server.ts +0 -258
- package/template/node_modules/@sentio/sdk/src/test/test-provider.ts +0 -25
- package/template/node_modules/@sentio/sdk/src/test/types/game_wallet.ts +0 -1392
- package/template/node_modules/@sentio/sdk/src/test/types/game_wallet_processor.ts +0 -113
- package/template/node_modules/@sentio/sdk/src/test/wormhole-token-bridge.ts +0 -21
- package/template/node_modules/@sentio/sdk/src/trace.ts +0 -86
- package/template/node_modules/@sentio/sdk/src/types/global.d.ts +0 -17
- package/template/node_modules/@sentio/sdk/src/utils/chainmap.ts +0 -95
- package/template/node_modules/@sentio/sdk/src/utils/convert.ts +0 -26
- package/template/node_modules/@sentio/sdk/src/utils/erc20.test.ts +0 -26
- package/template/node_modules/@sentio/sdk/src/utils/erc20.ts +0 -66
- package/template/node_modules/@sentio/sdk/src/utils/index.ts +0 -3
- package/template/node_modules/base-x/LICENSE.md +0 -22
- package/template/node_modules/base-x/README.md +0 -73
- package/template/node_modules/base-x/package.json +0 -46
- package/template/node_modules/base-x/src/index.d.ts +0 -9
- package/template/node_modules/base-x/src/index.js +0 -121
- package/template/node_modules/bs58/CHANGELOG.md +0 -65
- package/template/node_modules/bs58/LICENSE +0 -21
- package/template/node_modules/bs58/README.md +0 -91
- package/template/node_modules/bs58/index.d.ts +0 -5
- package/template/node_modules/bs58/index.js +0 -4
- package/template/node_modules/bs58/package.json +0 -39
- package/template/src/types/internal/X2y2.ts +0 -684
- package/template/src/types/internal/common.ts +0 -46
- package/template/src/types/internal/factories/X2y2__factory.ts +0 -436
- package/template/src/types/internal/factories/index.ts +0 -4
- package/template/src/types/internal/index.ts +0 -6
- package/template/src/types/internal/x2y2_processor.ts +0 -1004
- package/template/src/types/x2y2/index.ts +0 -6
- package/template/src/types/x2y2/test-utils.ts +0 -89
package/lib/meter.js
CHANGED
|
@@ -47,7 +47,6 @@ function GetRecordMetaData(ctx, metric, labels) {
|
|
|
47
47
|
transactionIndex: ctx.log.transactionIndex,
|
|
48
48
|
logIndex: ctx.log.logIndex,
|
|
49
49
|
chainId: ctx.chainId.toString(),
|
|
50
|
-
name: descriptor.name,
|
|
51
50
|
descriptor: descriptor,
|
|
52
51
|
labels: normalizeLabels(labels),
|
|
53
52
|
};
|
|
@@ -59,7 +58,6 @@ function GetRecordMetaData(ctx, metric, labels) {
|
|
|
59
58
|
transactionIndex: -1,
|
|
60
59
|
logIndex: -1,
|
|
61
60
|
chainId: ctx.chainId.toString(),
|
|
62
|
-
name: descriptor.name,
|
|
63
61
|
descriptor: descriptor,
|
|
64
62
|
labels: normalizeLabels(labels),
|
|
65
63
|
};
|
|
@@ -71,7 +69,6 @@ function GetRecordMetaData(ctx, metric, labels) {
|
|
|
71
69
|
transactionIndex: ctx.trace.transactionPosition,
|
|
72
70
|
logIndex: -1,
|
|
73
71
|
chainId: ctx.chainId.toString(),
|
|
74
|
-
name: descriptor.name,
|
|
75
72
|
descriptor: descriptor,
|
|
76
73
|
labels: normalizeLabels(labels),
|
|
77
74
|
};
|
|
@@ -84,7 +81,6 @@ function GetRecordMetaData(ctx, metric, labels) {
|
|
|
84
81
|
transactionIndex: 0,
|
|
85
82
|
logIndex: 0,
|
|
86
83
|
chainId: 'SOL_mainnet',
|
|
87
|
-
name: descriptor.name,
|
|
88
84
|
descriptor: descriptor,
|
|
89
85
|
labels: normalizeLabels(labels),
|
|
90
86
|
};
|
|
@@ -96,7 +92,6 @@ function GetRecordMetaData(ctx, metric, labels) {
|
|
|
96
92
|
transactionIndex: 0,
|
|
97
93
|
logIndex: 0,
|
|
98
94
|
chainId: 'SUI_devnet',
|
|
99
|
-
name: descriptor.name,
|
|
100
95
|
descriptor: descriptor,
|
|
101
96
|
labels: normalizeLabels(labels),
|
|
102
97
|
};
|
package/lib/meter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter.js","sourceRoot":"","sources":["../src/meter.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAmF;AACnF,uCAA2E;AAC3E,2CAAsD;AACtD,gDAAuB;AAEvB,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AAC/C,CAAC;AAHD,sCAGC;AAED,SAAgB,YAAY,CAAC,IAAY;IACvC,IAAI,IAAI,KAAK,QAAQ,EAAE;QACrB,OAAO,SAAS,CAAA;KACjB;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AALD,oCAKC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AAC3B,CAAC;AAFD,wCAEC;AAED,SAAgB,eAAe,CAAC,MAAc;IAC5C,MAAM,UAAU,GAAW,EAAE,CAAA;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;KAC5D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AAA;QAC5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,MAAM,CAAC,KAAgB,EAAE,SAAiB,EAAE;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;CACF;AAZD,oCAYC;AAED,MAAa,KAAK;IACC,GAAG,CAAa;IAEjC,YAAY,GAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;CACF;AAdD,sBAcC","sourcesContent":["import { MetricDescriptor, RecordMetaData } from './gen/processor/protos/processor'\nimport { BaseContext, Context, SolanaContext, SuiContext } from './context'\nimport { toMetricValue, Numberish } from './numberish'\nimport Long from 'long'\n\nexport function normalizeName(name: string): string {\n const regex = new RegExp('![_.a-zA-Z0-9]')\n return name.slice(0, 100).replace(regex, '_')\n}\n\nexport function normalizeKey(name: string): string {\n if (name === 'labels') {\n return 'labels_'\n }\n return normalizeName(name)\n}\n\nexport function normalizeValue(name: string): string {\n return name.slice(0, 100)\n}\n\nexport function normalizeLabels(labels: Labels): Labels {\n const normLabels: Labels = {}\n for (const key in labels) {\n normLabels[normalizeKey(key)] = normalizeValue(labels[key])\n }\n return normLabels\n}\n\nfunction GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): RecordMetaData {\n let descriptor = metric.descriptor\n if (metric.usage > 0) {\n // Other setting don't need to be write multiple times\n descriptor = MetricDescriptor.fromPartial({ name: descriptor.name })\n }\n\n descriptor.name = normalizeName(descriptor.name)\n\n if (ctx instanceof Context) {\n if (ctx.log) {\n return {\n contractAddress: ctx.contract.rawContract.address,\n blockNumber: Long.fromNumber(ctx.log.blockNumber, true), // TODO need number type to be long\n transactionIndex: ctx.log.transactionIndex,\n logIndex: ctx.log.logIndex,\n chainId: ctx.chainId.toString(),\n name: descriptor.name,\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n }\n if (ctx.block) {\n return {\n contractAddress: ctx.contract.rawContract.address,\n blockNumber: Long.fromNumber(ctx.block.number, true),\n transactionIndex: -1,\n logIndex: -1,\n chainId: ctx.chainId.toString(),\n name: descriptor.name,\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n }\n if (ctx.trace) {\n return {\n contractAddress: ctx.contract.rawContract.address,\n blockNumber: Long.fromNumber(ctx.trace.blockNumber, true),\n transactionIndex: ctx.trace.transactionPosition, // TODO make sure if this is the right value to set\n logIndex: -1,\n chainId: ctx.chainId.toString(),\n name: descriptor.name,\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n }\n } else if (ctx instanceof SolanaContext) {\n return {\n contractAddress: ctx.address,\n blockNumber: Long.ZERO, // TODO need number type to be long\n transactionIndex: 0,\n logIndex: 0,\n chainId: 'SOL_mainnet', // TODO set in context\n name: descriptor.name,\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n } else if (ctx instanceof SuiContext) {\n return {\n contractAddress: ctx.address,\n blockNumber: Long.ZERO, // TODO need number type to be long\n transactionIndex: 0,\n logIndex: 0,\n chainId: 'SUI_devnet', // TODO set in context\n name: descriptor.name,\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n }\n throw new Error(\"This can't happen\")\n}\n\nexport type Labels = { [key: string]: string }\n\nexport class MetricDescriptorOption {\n unit?: string\n description?: string\n sparse?: boolean\n}\n\nexport class Metric {\n descriptor: MetricDescriptor = MetricDescriptor.fromPartial({})\n usage = 0\n\n constructor(name: string, option?: MetricDescriptorOption) {\n this.descriptor.name = name\n if (option) {\n if (option.unit) {\n this.descriptor.unit = option.unit\n }\n if (option.description) {\n this.descriptor.description = option.description\n }\n if (option.sparse) {\n this.descriptor.sparse = option.sparse\n }\n }\n }\n}\n\nexport class Counter extends Metric {\n add(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, true)\n }\n\n sub(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, false)\n }\n\n private record(ctx: BaseContext, value: Numberish, labels: Labels, add: boolean) {\n ctx.counters.push({\n metadata: GetRecordMetaData(ctx, this, labels),\n metricValue: toMetricValue(value),\n add: add,\n runtimeInfo: undefined,\n })\n this.usage++\n }\n}\n\nexport class CounterBinding {\n private readonly ctx: BaseContext\n private readonly counter: Counter\n\n constructor(name: string, ctx: BaseContext) {\n this.counter = new Counter(name)\n this.ctx = ctx\n }\n\n add(value: Numberish, labels: Labels = {}) {\n this.counter.add(this.ctx, value, labels)\n }\n\n sub(value: Numberish, labels: Labels = {}) {\n this.counter.sub(this.ctx, value, labels)\n }\n}\n\nexport class Gauge extends Metric {\n record(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n ctx.gauges.push({\n metadata: GetRecordMetaData(ctx, this, labels),\n metricValue: toMetricValue(value),\n runtimeInfo: undefined,\n })\n this.usage++\n }\n}\n\nexport class GaugeBinding {\n private readonly gauge: Gauge\n private readonly ctx: BaseContext\n\n constructor(name: string, ctx: BaseContext) {\n this.gauge = new Gauge(name)\n this.ctx = ctx\n }\n\n record(value: Numberish, labels: Labels = {}) {\n this.gauge.record(this.ctx, value, labels)\n }\n}\n\nexport class Meter {\n private readonly ctx: BaseContext\n\n constructor(ctx: BaseContext) {\n this.ctx = ctx\n }\n\n Counter(name: string): CounterBinding {\n return new CounterBinding(name, this.ctx)\n }\n\n Gauge(name: string): GaugeBinding {\n return new GaugeBinding(name, this.ctx)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"meter.js","sourceRoot":"","sources":["../src/meter.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAmF;AACnF,uCAA2E;AAC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C,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;CACF;AAhBD,wCAgBC;AAED,MAAa,KAAM,SAAQ,MAAM;IAC/B,MAAM,CAAC,GAAgB,EAAE,KAAgB,EAAE,SAAiB,EAAE;QAC5D,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;YACd,QAAQ,EAAE,iBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC;YAC9C,WAAW,EAAE,IAAA,yBAAa,EAAC,KAAK,CAAC;YACjC,WAAW,EAAE,SAAS;SACvB,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;CACF;AATD,sBASC;AAED,MAAa,YAAY;IACN,KAAK,CAAO;IACZ,GAAG,CAAa;IAEjC,YAAY,IAAY,EAAE,GAAgB;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;QAC5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,MAAM,CAAC,KAAgB,EAAE,SAAiB,EAAE;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;CACF;AAZD,oCAYC;AAED,MAAa,KAAK;IACC,GAAG,CAAa;IAEjC,YAAY,GAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;CACF;AAdD,sBAcC","sourcesContent":["import { MetricDescriptor, RecordMetaData } from './gen/processor/protos/processor'\nimport { BaseContext, Context, SolanaContext, SuiContext } from './context'\nimport { toMetricValue, Numberish } from './numberish'\nimport Long from 'long'\n\nexport function normalizeName(name: string): string {\n const regex = new RegExp('![_.a-zA-Z0-9]')\n return name.slice(0, 100).replace(regex, '_')\n}\n\nexport function normalizeKey(name: string): string {\n if (name === 'labels') {\n return 'labels_'\n }\n return normalizeName(name)\n}\n\nexport function normalizeValue(name: string): string {\n return name.slice(0, 100)\n}\n\nexport function normalizeLabels(labels: Labels): Labels {\n const normLabels: Labels = {}\n for (const key in labels) {\n normLabels[normalizeKey(key)] = normalizeValue(labels[key])\n }\n return normLabels\n}\n\nfunction GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): RecordMetaData {\n let descriptor = metric.descriptor\n if (metric.usage > 0) {\n // Other setting don't need to be write multiple times\n descriptor = MetricDescriptor.fromPartial({ name: descriptor.name })\n }\n\n descriptor.name = normalizeName(descriptor.name)\n\n if (ctx instanceof Context) {\n if (ctx.log) {\n return {\n contractAddress: ctx.contract.rawContract.address,\n blockNumber: Long.fromNumber(ctx.log.blockNumber, true), // TODO need number type to be long\n transactionIndex: ctx.log.transactionIndex,\n logIndex: ctx.log.logIndex,\n chainId: ctx.chainId.toString(),\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n }\n if (ctx.block) {\n return {\n contractAddress: ctx.contract.rawContract.address,\n blockNumber: Long.fromNumber(ctx.block.number, true),\n transactionIndex: -1,\n logIndex: -1,\n chainId: ctx.chainId.toString(),\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n }\n if (ctx.trace) {\n return {\n contractAddress: ctx.contract.rawContract.address,\n blockNumber: Long.fromNumber(ctx.trace.blockNumber, true),\n transactionIndex: ctx.trace.transactionPosition, // TODO make sure if this is the right value to set\n logIndex: -1,\n chainId: ctx.chainId.toString(),\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n }\n } else if (ctx instanceof SolanaContext) {\n return {\n contractAddress: ctx.address,\n blockNumber: Long.ZERO, // TODO need number type to be long\n transactionIndex: 0,\n logIndex: 0,\n chainId: 'SOL_mainnet', // TODO set in context\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n } else if (ctx instanceof SuiContext) {\n return {\n contractAddress: ctx.address,\n blockNumber: Long.ZERO, // TODO need number type to be long\n transactionIndex: 0,\n logIndex: 0,\n chainId: 'SUI_devnet', // TODO set in context\n descriptor: descriptor,\n labels: normalizeLabels(labels),\n }\n }\n throw new Error(\"This can't happen\")\n}\n\nexport type Labels = { [key: string]: string }\n\nexport class MetricDescriptorOption {\n unit?: string\n description?: string\n sparse?: boolean\n}\n\nexport class Metric {\n descriptor: MetricDescriptor = MetricDescriptor.fromPartial({})\n usage = 0\n\n constructor(name: string, option?: MetricDescriptorOption) {\n this.descriptor.name = name\n if (option) {\n if (option.unit) {\n this.descriptor.unit = option.unit\n }\n if (option.description) {\n this.descriptor.description = option.description\n }\n if (option.sparse) {\n this.descriptor.sparse = option.sparse\n }\n }\n }\n}\n\nexport class Counter extends Metric {\n add(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, true)\n }\n\n sub(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, false)\n }\n\n private record(ctx: BaseContext, value: Numberish, labels: Labels, add: boolean) {\n ctx.counters.push({\n metadata: GetRecordMetaData(ctx, this, labels),\n metricValue: toMetricValue(value),\n add: add,\n runtimeInfo: undefined,\n })\n this.usage++\n }\n}\n\nexport class CounterBinding {\n private readonly ctx: BaseContext\n private readonly counter: Counter\n\n constructor(name: string, ctx: BaseContext) {\n this.counter = new Counter(name)\n this.ctx = ctx\n }\n\n add(value: Numberish, labels: Labels = {}) {\n this.counter.add(this.ctx, value, labels)\n }\n\n sub(value: Numberish, labels: Labels = {}) {\n this.counter.sub(this.ctx, value, labels)\n }\n}\n\nexport class Gauge extends Metric {\n record(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n ctx.gauges.push({\n metadata: GetRecordMetaData(ctx, this, labels),\n metricValue: toMetricValue(value),\n runtimeInfo: undefined,\n })\n this.usage++\n }\n}\n\nexport class GaugeBinding {\n private readonly gauge: Gauge\n private readonly ctx: BaseContext\n\n constructor(name: string, ctx: BaseContext) {\n this.gauge = new Gauge(name)\n this.ctx = ctx\n }\n\n record(value: Numberish, labels: Labels = {}) {\n this.gauge.record(this.ctx, value, labels)\n }\n}\n\nexport class Meter {\n private readonly ctx: BaseContext\n\n constructor(ctx: BaseContext) {\n this.ctx = ctx\n }\n\n Counter(name: string): CounterBinding {\n return new CounterBinding(name, this.ctx)\n }\n\n Gauge(name: string): GaugeBinding {\n return new GaugeBinding(name, this.ctx)\n }\n}\n"]}
|
package/lib/test/metric-utils.js
CHANGED
|
@@ -28,7 +28,7 @@ function firstCounterValue(result, name) {
|
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
for (const counter of result.counters) {
|
|
31
|
-
if (counter.metadata?.name === name) {
|
|
31
|
+
if (counter.metadata?.descriptor?.name === name) {
|
|
32
32
|
return MetricValueToNumber(counter.metricValue);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -40,7 +40,7 @@ function firstGaugeValue(result, name) {
|
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
42
42
|
for (const gauge of result.gauges) {
|
|
43
|
-
if (gauge.metadata?.name === name) {
|
|
43
|
+
if (gauge.metadata?.descriptor?.name === name) {
|
|
44
44
|
return MetricValueToNumber(gauge.metricValue);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metric-utils.js","sourceRoot":"","sources":["../../src/test/metric-utils.ts"],"names":[],"mappings":";;;AACA,qCAAoE;AAEpE,mCAAkC;AAElC,SAAgB,mBAAmB,CAAC,CAAuC;IACzE,IAAI,CAAC,KAAK,SAAS,EAAE;QACnB,OAAO,SAAS,CAAA;KACjB;IAED,IAAI,CAAC,CAAC,WAAW,KAAK,SAAS,EAAE;QAC/B,OAAO,CAAC,CAAC,WAAW,C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CAAA;SACrB;QACD,OAAO,QAAQ,CAAA;KAChB;IACD,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS,EAAE;QAC9B,OAAO,IAAI,gBAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;KACpC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAnBD,kDAmBC;AAED,SAAgB,iBAAiB,CAAC,MAAiC,EAAE,IAAY;IAC/E,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAA;KACjB;IACD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE;QACrC,IAAI,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,KAAK,IAAI,EAAE;YAC/C,OAAO,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;SAChD;KACF;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAVD,8CAUC;AAED,SAAgB,eAAe,CAAC,MAAiC,EAAE,IAAY;IAC7E,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAA;KACjB;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE;QACjC,IAAI,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,KAAK,IAAI,EAAE;YAC7C,OAAO,mBAAmB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;SAC9C;KACF;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAVD,0CAUC","sourcesContent":["import { DeepPartial } from '../gen/builtin'\nimport { BigDecimal, MetricValue, ProcessResult } from '@sentio/sdk'\nimport { Numberish } from '../numberish'\nimport { BigNumber } from 'ethers'\n\nexport function MetricValueToNumber(v: DeepPartial<MetricValue> | undefined): Numberish | undefined {\n if (v === undefined) {\n return undefined\n }\n\n if (v.doubleValue !== undefined) {\n return v.doubleValue\n }\n if (v.bigInteger !== undefined) {\n let intValue = BigNumber.from(v.bigInteger.data).toBigInt()\n if (v.bigInteger.negative) {\n intValue = -intValue\n }\n return intValue\n }\n if (v.bigDecimal !== undefined) {\n return new BigDecimal(v.bigDecimal)\n }\n return undefined\n}\n\nexport function firstCounterValue(result: ProcessResult | undefined, name: string): Numberish | undefined {\n if (!result) {\n return undefined\n }\n for (const counter of result.counters) {\n if (counter.metadata?.descriptor?.name === name) {\n return MetricValueToNumber(counter.metricValue)\n }\n }\n return undefined\n}\n\nexport function firstGaugeValue(result: ProcessResult | undefined, name: string): Numberish | undefined {\n if (!result) {\n return undefined\n }\n for (const gauge of result.gauges) {\n if (gauge.metadata?.descriptor?.name === name) {\n return MetricValueToNumber(gauge.metricValue)\n }\n }\n return undefined\n}\n"]}
|
package/package.json
CHANGED
|
@@ -76,6 +76,9 @@ export function runCreate(argv: string[]) {
|
|
|
76
76
|
packageJson.version = cliVersion
|
|
77
77
|
packageJson.name = projectName
|
|
78
78
|
|
|
79
|
+
// Don't add directly to avoid deps issue
|
|
80
|
+
packageJson.scripts.postinstall = 'sentio gen'
|
|
81
|
+
|
|
79
82
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
|
|
80
83
|
}
|
|
81
84
|
console.log(chalk.green("successfully create project '" + projectName + "'"))
|
|
@@ -276,7 +276,6 @@ export interface RecordMetaData {
|
|
|
276
276
|
transactionIndex: number;
|
|
277
277
|
logIndex: number;
|
|
278
278
|
chainId: string;
|
|
279
|
-
name: string;
|
|
280
279
|
descriptor: MetricDescriptor | undefined;
|
|
281
280
|
labels: { [key: string]: string };
|
|
282
281
|
}
|
|
@@ -2756,7 +2755,6 @@ function createBaseRecordMetaData(): RecordMetaData {
|
|
|
2756
2755
|
transactionIndex: 0,
|
|
2757
2756
|
logIndex: 0,
|
|
2758
2757
|
chainId: "",
|
|
2759
|
-
name: "",
|
|
2760
2758
|
descriptor: undefined,
|
|
2761
2759
|
labels: {},
|
|
2762
2760
|
};
|
|
@@ -2782,9 +2780,6 @@ export const RecordMetaData = {
|
|
|
2782
2780
|
if (message.chainId !== "") {
|
|
2783
2781
|
writer.uint32(42).string(message.chainId);
|
|
2784
2782
|
}
|
|
2785
|
-
if (message.name !== "") {
|
|
2786
|
-
writer.uint32(50).string(message.name);
|
|
2787
|
-
}
|
|
2788
2783
|
if (message.descriptor !== undefined) {
|
|
2789
2784
|
MetricDescriptor.encode(
|
|
2790
2785
|
message.descriptor,
|
|
@@ -2822,9 +2817,6 @@ export const RecordMetaData = {
|
|
|
2822
2817
|
case 5:
|
|
2823
2818
|
message.chainId = reader.string();
|
|
2824
2819
|
break;
|
|
2825
|
-
case 6:
|
|
2826
|
-
message.name = reader.string();
|
|
2827
|
-
break;
|
|
2828
2820
|
case 8:
|
|
2829
2821
|
message.descriptor = MetricDescriptor.decode(reader, reader.uint32());
|
|
2830
2822
|
break;
|
|
@@ -2858,7 +2850,6 @@ export const RecordMetaData = {
|
|
|
2858
2850
|
: 0,
|
|
2859
2851
|
logIndex: isSet(object.logIndex) ? Number(object.logIndex) : 0,
|
|
2860
2852
|
chainId: isSet(object.chainId) ? String(object.chainId) : "",
|
|
2861
|
-
name: isSet(object.name) ? String(object.name) : "",
|
|
2862
2853
|
descriptor: isSet(object.descriptor)
|
|
2863
2854
|
? MetricDescriptor.fromJSON(object.descriptor)
|
|
2864
2855
|
: undefined,
|
|
@@ -2885,7 +2876,6 @@ export const RecordMetaData = {
|
|
|
2885
2876
|
message.logIndex !== undefined &&
|
|
2886
2877
|
(obj.logIndex = Math.round(message.logIndex));
|
|
2887
2878
|
message.chainId !== undefined && (obj.chainId = message.chainId);
|
|
2888
|
-
message.name !== undefined && (obj.name = message.name);
|
|
2889
2879
|
message.descriptor !== undefined &&
|
|
2890
2880
|
(obj.descriptor = message.descriptor
|
|
2891
2881
|
? MetricDescriptor.toJSON(message.descriptor)
|
|
@@ -2909,7 +2899,6 @@ export const RecordMetaData = {
|
|
|
2909
2899
|
message.transactionIndex = object.transactionIndex ?? 0;
|
|
2910
2900
|
message.logIndex = object.logIndex ?? 0;
|
|
2911
2901
|
message.chainId = object.chainId ?? "";
|
|
2912
|
-
message.name = object.name ?? "";
|
|
2913
2902
|
message.descriptor =
|
|
2914
2903
|
object.descriptor !== undefined && object.descriptor !== null
|
|
2915
2904
|
? MetricDescriptor.fromPartial(object.descriptor)
|
package/src/meter.ts
CHANGED
|
@@ -44,7 +44,6 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
|
|
|
44
44
|
transactionIndex: ctx.log.transactionIndex,
|
|
45
45
|
logIndex: ctx.log.logIndex,
|
|
46
46
|
chainId: ctx.chainId.toString(),
|
|
47
|
-
name: descriptor.name,
|
|
48
47
|
descriptor: descriptor,
|
|
49
48
|
labels: normalizeLabels(labels),
|
|
50
49
|
}
|
|
@@ -56,7 +55,6 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
|
|
|
56
55
|
transactionIndex: -1,
|
|
57
56
|
logIndex: -1,
|
|
58
57
|
chainId: ctx.chainId.toString(),
|
|
59
|
-
name: descriptor.name,
|
|
60
58
|
descriptor: descriptor,
|
|
61
59
|
labels: normalizeLabels(labels),
|
|
62
60
|
}
|
|
@@ -68,7 +66,6 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
|
|
|
68
66
|
transactionIndex: ctx.trace.transactionPosition, // TODO make sure if this is the right value to set
|
|
69
67
|
logIndex: -1,
|
|
70
68
|
chainId: ctx.chainId.toString(),
|
|
71
|
-
name: descriptor.name,
|
|
72
69
|
descriptor: descriptor,
|
|
73
70
|
labels: normalizeLabels(labels),
|
|
74
71
|
}
|
|
@@ -80,7 +77,6 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
|
|
|
80
77
|
transactionIndex: 0,
|
|
81
78
|
logIndex: 0,
|
|
82
79
|
chainId: 'SOL_mainnet', // TODO set in context
|
|
83
|
-
name: descriptor.name,
|
|
84
80
|
descriptor: descriptor,
|
|
85
81
|
labels: normalizeLabels(labels),
|
|
86
82
|
}
|
|
@@ -91,7 +87,6 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
|
|
|
91
87
|
transactionIndex: 0,
|
|
92
88
|
logIndex: 0,
|
|
93
89
|
chainId: 'SUI_devnet', // TODO set in context
|
|
94
|
-
name: descriptor.name,
|
|
95
90
|
descriptor: descriptor,
|
|
96
91
|
labels: normalizeLabels(labels),
|
|
97
92
|
}
|
package/src/test/metric-utils.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function firstCounterValue(result: ProcessResult | undefined, name: strin
|
|
|
29
29
|
return undefined
|
|
30
30
|
}
|
|
31
31
|
for (const counter of result.counters) {
|
|
32
|
-
if (counter.metadata?.name === name) {
|
|
32
|
+
if (counter.metadata?.descriptor?.name === name) {
|
|
33
33
|
return MetricValueToNumber(counter.metricValue)
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -41,7 +41,7 @@ export function firstGaugeValue(result: ProcessResult | undefined, name: string)
|
|
|
41
41
|
return undefined
|
|
42
42
|
}
|
|
43
43
|
for (const gauge of result.gauges) {
|
|
44
|
-
if (gauge.metadata?.name === name) {
|
|
44
|
+
if (gauge.metadata?.descriptor?.name === name) {
|
|
45
45
|
return MetricValueToNumber(gauge.metricValue)
|
|
46
46
|
}
|
|
47
47
|
}
|
package/template/package.json
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
"test": "jest",
|
|
7
7
|
"gen": "sentio gen",
|
|
8
8
|
"build": "sentio build",
|
|
9
|
-
"upload": "sentio upload"
|
|
10
|
-
"postinstall": "sentio gen"
|
|
9
|
+
"upload": "sentio upload"
|
|
11
10
|
},
|
|
12
11
|
"dependencies": {
|
|
13
|
-
"@sentio/sdk": "^1.0.0"
|
|
12
|
+
"@sentio/sdk": "^1.0.0-development"
|
|
14
13
|
},
|
|
15
14
|
"devDependencies": {
|
|
16
15
|
"@types/jest": "^29.0.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TestProcessorServer } from '@sentio/sdk/lib/test'
|
|
2
2
|
import { mockTransferLog } from '@sentio/sdk/lib/builtin/erc20/test-utils'
|
|
3
|
-
import { BigNumber } from 'ethers'
|
|
4
3
|
import { firstCounterValue } from '@sentio/sdk/lib/test/metric-utils'
|
|
4
|
+
import { BigNumber } from 'ethers'
|
|
5
5
|
|
|
6
6
|
describe('Test Processor', () => {
|
|
7
7
|
const service = new TestProcessorServer(() => require('./processor'))
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Counter, Gauge } from '@sentio/sdk'
|
|
2
|
+
import { toBigDecimal } from '@sentio/sdk/lib/utils'
|
|
3
|
+
import { ERC20Processor } from '@sentio/sdk/lib/builtin/erc20'
|
|
4
|
+
import { X2y2Processor } from './types/x2y2'
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
6
|
+
const rewardPerBlock = new Gauge('reward_per_block', {
|
|
7
|
+
description: 'rewards for each block grouped by phase',
|
|
8
|
+
unit: 'x2y2',
|
|
9
|
+
})
|
|
10
|
+
const token = new Counter('token')
|
|
11
|
+
|
|
12
|
+
X2y2Processor.bind({ address: '0xB329e39Ebefd16f40d38f07643652cE17Ca5Bac1' }).onBlock(async (_, ctx) => {
|
|
13
|
+
const phase = (await ctx.contract.currentPhase()).toString()
|
|
14
|
+
const reward = toBigDecimal(await ctx.contract.rewardPerBlockForStaking()).div(10 ** 18)
|
|
15
|
+
rewardPerBlock.record(ctx, reward, { phase })
|
|
16
|
+
})
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
const filter = ERC20Processor.filters.Transfer(
|
|
13
19
|
'0x0000000000000000000000000000000000000000',
|
|
14
20
|
'0xb329e39ebefd16f40d38f07643652ce17ca5bac1'
|
|
15
21
|
)
|
|
16
22
|
|
|
17
23
|
ERC20Processor.bind({ address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9' }).onEventTransfer(
|
|
18
|
-
|
|
24
|
+
async (event, ctx) => {
|
|
25
|
+
const val = toBigDecimal(event.args.value).div(10 ** 18)
|
|
26
|
+
token.add(ctx, val)
|
|
27
|
+
},
|
|
19
28
|
filter // filter is an optional parameter
|
|
20
29
|
)
|
|
21
|
-
|
|
22
|
-
async function handleTransfer(event: TransferEvent, ctx: ERC20Context) {
|
|
23
|
-
const val = Number(event.args.value.toBigInt() / 10n ** 18n)
|
|
24
|
-
ctx.meter.Counter('token').add(val)
|
|
25
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { BoundContractView, Context, ContractView } from './context';
|
|
2
|
-
import { Block } from '@ethersproject/abstract-provider';
|
|
3
|
-
import { BaseContract, EventFilter } from 'ethers';
|
|
4
|
-
import { Event } from '@ethersproject/contracts';
|
|
5
|
-
import { BaseProcessor } from './base-processor';
|
|
6
|
-
import { BindOptions } from './bind-options';
|
|
7
|
-
import { PromiseOrVoid } from './promise-or-void';
|
|
8
|
-
import { Trace } from './trace';
|
|
9
|
-
export declare abstract class BaseProcessorTemplate<TContract extends BaseContract, TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>> {
|
|
10
|
-
id: number;
|
|
11
|
-
binds: Set<string>;
|
|
12
|
-
blockHandlers: ((block: Block, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid)[];
|
|
13
|
-
traceHandlers: {
|
|
14
|
-
signature: string;
|
|
15
|
-
handler: (trace: Trace, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid;
|
|
16
|
-
}[];
|
|
17
|
-
eventHandlers: {
|
|
18
|
-
handler: (event: Event, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid;
|
|
19
|
-
filter: EventFilter | EventFilter[];
|
|
20
|
-
}[];
|
|
21
|
-
constructor();
|
|
22
|
-
bind(options: BindOptions): BaseProcessor<TContract, TBoundContractView> | undefined;
|
|
23
|
-
onEvent(handler: (event: Event, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid, filter: EventFilter | EventFilter[]): this;
|
|
24
|
-
onBlock(handler: (block: Block, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid): this;
|
|
25
|
-
onTrace(signature: string, handler: (trace: Trace, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid): this;
|
|
26
|
-
protected abstract bindInternal(options: BindOptions): BaseProcessor<TContract, TBoundContractView>;
|
|
27
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
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.BaseProcessorTemplate = void 0;
|
|
7
|
-
const bind_options_1 = require("./bind-options");
|
|
8
|
-
const long_1 = __importDefault(require("long"));
|
|
9
|
-
const providers_1 = require("@ethersproject/providers");
|
|
10
|
-
class BaseProcessorTemplate {
|
|
11
|
-
id;
|
|
12
|
-
binds = new Set();
|
|
13
|
-
blockHandlers = [];
|
|
14
|
-
traceHandlers = [];
|
|
15
|
-
eventHandlers = [];
|
|
16
|
-
constructor() {
|
|
17
|
-
this.id = global.PROCESSOR_STATE.templates.length;
|
|
18
|
-
global.PROCESSOR_STATE.templates.push(this);
|
|
19
|
-
}
|
|
20
|
-
bind(options) {
|
|
21
|
-
const sig = (0, bind_options_1.getOptionsSignature)(options);
|
|
22
|
-
if (this.binds.has(sig)) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
this.binds.add(sig);
|
|
26
|
-
const processor = this.bindInternal(options);
|
|
27
|
-
for (const eh of this.eventHandlers) {
|
|
28
|
-
processor.onEvent(eh.handler, eh.filter);
|
|
29
|
-
}
|
|
30
|
-
for (const bh of this.blockHandlers) {
|
|
31
|
-
processor.onBlock(bh);
|
|
32
|
-
}
|
|
33
|
-
const instance = {
|
|
34
|
-
templateId: this.id,
|
|
35
|
-
contract: {
|
|
36
|
-
address: options.address,
|
|
37
|
-
name: options.name || '',
|
|
38
|
-
chainId: options.network ? (0, providers_1.getNetwork)(options.network).chainId.toString() : '1',
|
|
39
|
-
abi: '',
|
|
40
|
-
},
|
|
41
|
-
startBlock: long_1.default.ZERO,
|
|
42
|
-
endBlock: long_1.default.ZERO,
|
|
43
|
-
};
|
|
44
|
-
if (options.startBlock) {
|
|
45
|
-
if (typeof options.startBlock === 'number') {
|
|
46
|
-
instance.startBlock = long_1.default.fromNumber(options.startBlock);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
instance.startBlock = options.startBlock;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (options.endBlock) {
|
|
53
|
-
if (typeof options.endBlock === 'number') {
|
|
54
|
-
instance.endBlock = long_1.default.fromNumber(options.endBlock);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
instance.endBlock = options.endBlock;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
global.PROCESSOR_STATE.templatesInstances.push(instance);
|
|
61
|
-
return processor;
|
|
62
|
-
}
|
|
63
|
-
onEvent(handler, filter) {
|
|
64
|
-
this.eventHandlers.push({
|
|
65
|
-
handler: handler,
|
|
66
|
-
filter: filter,
|
|
67
|
-
});
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
onBlock(handler) {
|
|
71
|
-
this.blockHandlers.push(handler);
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
onTrace(signature, handler) {
|
|
75
|
-
this.traceHandlers.push({ signature, handler });
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.BaseProcessorTemplate = BaseProcessorTemplate;
|
|
80
|
-
//# sourceMappingURL=base-processor-template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-processor-template.js","sourceRoot":"","sources":["../src/base-processor-template.ts"],"names":[],"mappings":";;;;;;AAKA,iDAAiE;AAEjE,gDAAuB;AACvB,wDAAqD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Context, ContractView } from './context'\nimport { Block } from '@ethersproject/abstract-provider'\nimport { BaseContract, EventFilter } from 'ethers'\nimport { Event } from '@ethersproject/contracts'\nimport { BaseProcessor } from './base-processor'\nimport { BindOptions, getOptionsSignature } from './bind-options'\nimport { TemplateInstance } from './gen/processor/protos/processor'\nimport Long from 'long'\nimport { getNetwork } from '@ethersproject/providers'\nimport { PromiseOrVoid } from './promise-or-void'\nimport { Trace } from './trace'\n\nexport abstract class BaseProcessorTemplate<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n id: number\n binds = new Set<string>()\n blockHandlers: ((block: Block, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid)[] = []\n traceHandlers: {\n signature: string\n handler: (trace: Trace, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid\n }[] = []\n eventHandlers: {\n handler: (event: Event, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid\n filter: EventFilter | EventFilter[]\n }[] = []\n\n constructor() {\n this.id = global.PROCESSOR_STATE.templates.length\n global.PROCESSOR_STATE.templates.push(this)\n }\n\n public bind(options: BindOptions) {\n const sig = getOptionsSignature(options)\n if (this.binds.has(sig)) {\n return\n }\n this.binds.add(sig)\n\n const processor = this.bindInternal(options)\n\n for (const eh of this.eventHandlers) {\n processor.onEvent(eh.handler, eh.filter)\n }\n for (const bh of this.blockHandlers) {\n processor.onBlock(bh)\n }\n\n const instance: TemplateInstance = {\n templateId: this.id,\n contract: {\n address: options.address,\n name: options.name || '',\n chainId: options.network ? getNetwork(options.network).chainId.toString() : '1',\n abi: '',\n },\n startBlock: Long.ZERO,\n endBlock: Long.ZERO,\n }\n if (options.startBlock) {\n if (typeof options.startBlock === 'number') {\n instance.startBlock = Long.fromNumber(options.startBlock)\n } else {\n instance.startBlock = options.startBlock\n }\n }\n if (options.endBlock) {\n if (typeof options.endBlock === 'number') {\n instance.endBlock = Long.fromNumber(options.endBlock)\n } else {\n instance.endBlock = options.endBlock\n }\n }\n global.PROCESSOR_STATE.templatesInstances.push(instance)\n\n return processor\n }\n\n public onEvent(\n handler: (event: Event, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: EventFilter | EventFilter[]\n ) {\n this.eventHandlers.push({\n handler: handler,\n filter: filter,\n })\n return this\n }\n\n public onBlock(handler: (block: Block, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid) {\n this.blockHandlers.push(handler)\n return this\n }\n\n public onTrace(\n signature: string,\n handler: (trace: Trace, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid\n ) {\n this.traceHandlers.push({ signature, handler })\n return this\n }\n\n protected abstract bindInternal(options: BindOptions): BaseProcessor<TContract, TBoundContractView>\n}\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Event } from '@ethersproject/contracts';
|
|
2
|
-
import { Block, Log } from '@ethersproject/providers';
|
|
3
|
-
import { BaseContract, EventFilter } from '@ethersproject/contracts';
|
|
4
|
-
import { BoundContractView, Context, ContractView } from './context';
|
|
5
|
-
import { ProcessResult } from './gen/processor/protos/processor';
|
|
6
|
-
import { BindInternalOptions, BindOptions } from './bind-options';
|
|
7
|
-
import { PromiseOrVoid } from './promise-or-void';
|
|
8
|
-
import { Trace } from './trace';
|
|
9
|
-
export declare class EventsHandler {
|
|
10
|
-
filters: EventFilter[];
|
|
11
|
-
handler: (event: Log) => Promise<ProcessResult>;
|
|
12
|
-
}
|
|
13
|
-
export declare class TraceHandler {
|
|
14
|
-
signature: string;
|
|
15
|
-
handler: (trace: Trace) => Promise<ProcessResult>;
|
|
16
|
-
}
|
|
17
|
-
export declare abstract class BaseProcessor<TContract extends BaseContract, TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>> {
|
|
18
|
-
blockHandlers: ((block: Block) => Promise<ProcessResult>)[];
|
|
19
|
-
eventHandlers: EventsHandler[];
|
|
20
|
-
traceHandlers: TraceHandler[];
|
|
21
|
-
name: string;
|
|
22
|
-
config: BindInternalOptions;
|
|
23
|
-
constructor(config: BindOptions);
|
|
24
|
-
protected abstract CreateBoundContractView(): TBoundContractView;
|
|
25
|
-
getChainId(): number;
|
|
26
|
-
onEvent(handler: (event: Event, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid, filter: EventFilter | EventFilter[]): this;
|
|
27
|
-
onBlock(handler: (block: Block, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid): this;
|
|
28
|
-
onAllEvents(handler: (event: Log, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid): this;
|
|
29
|
-
protected onTrace(signature: string, handler: (trace: Trace, ctx: Context<TContract, TBoundContractView>) => PromiseOrVoid): this;
|
|
30
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
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.BaseProcessor = exports.TraceHandler = exports.EventsHandler = void 0;
|
|
7
|
-
const providers_1 = require("@ethersproject/providers");
|
|
8
|
-
const long_1 = __importDefault(require("long"));
|
|
9
|
-
const context_1 = require("./context");
|
|
10
|
-
class EventsHandler {
|
|
11
|
-
filters;
|
|
12
|
-
handler;
|
|
13
|
-
}
|
|
14
|
-
exports.EventsHandler = EventsHandler;
|
|
15
|
-
class TraceHandler {
|
|
16
|
-
signature;
|
|
17
|
-
handler;
|
|
18
|
-
}
|
|
19
|
-
exports.TraceHandler = TraceHandler;
|
|
20
|
-
class BaseProcessor {
|
|
21
|
-
blockHandlers = [];
|
|
22
|
-
eventHandlers = [];
|
|
23
|
-
traceHandlers = [];
|
|
24
|
-
name;
|
|
25
|
-
config;
|
|
26
|
-
constructor(config) {
|
|
27
|
-
this.config = {
|
|
28
|
-
address: config.address,
|
|
29
|
-
name: config.name || '',
|
|
30
|
-
network: config.network ? config.network : 1,
|
|
31
|
-
startBlock: new long_1.default(0),
|
|
32
|
-
};
|
|
33
|
-
if (config.startBlock) {
|
|
34
|
-
if (typeof config.startBlock === 'number') {
|
|
35
|
-
this.config.startBlock = long_1.default.fromNumber(config.startBlock);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.config.startBlock = config.startBlock;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (config.endBlock) {
|
|
42
|
-
if (typeof config.endBlock === 'number') {
|
|
43
|
-
this.config.endBlock = long_1.default.fromNumber(config.endBlock);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this.config.endBlock = config.endBlock;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
getChainId() {
|
|
51
|
-
return (0, providers_1.getNetwork)(this.config.network).chainId;
|
|
52
|
-
}
|
|
53
|
-
onEvent(handler, filter) {
|
|
54
|
-
const chainId = this.getChainId();
|
|
55
|
-
let _filters = [];
|
|
56
|
-
if (Array.isArray(filter)) {
|
|
57
|
-
_filters = filter;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
_filters.push(filter);
|
|
61
|
-
}
|
|
62
|
-
const contractView = this.CreateBoundContractView();
|
|
63
|
-
this.eventHandlers.push({
|
|
64
|
-
filters: _filters,
|
|
65
|
-
handler: async function (log) {
|
|
66
|
-
const ctx = new context_1.Context(contractView, chainId, undefined, log);
|
|
67
|
-
// let event: Event = <Event>deepCopy(log);
|
|
68
|
-
const event = log;
|
|
69
|
-
const parsed = contractView.rawContract.interface.parseLog(log);
|
|
70
|
-
if (parsed) {
|
|
71
|
-
event.args = parsed.args;
|
|
72
|
-
event.decode = (data, topics) => {
|
|
73
|
-
return contractView.rawContract.interface.decodeEventLog(parsed.eventFragment, data, topics);
|
|
74
|
-
};
|
|
75
|
-
event.event = parsed.name;
|
|
76
|
-
event.eventSignature = parsed.signature;
|
|
77
|
-
// TODO fix this bug
|
|
78
|
-
await handler(event, ctx);
|
|
79
|
-
return {
|
|
80
|
-
gauges: ctx.gauges,
|
|
81
|
-
counters: ctx.counters,
|
|
82
|
-
logs: [],
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
gauges: [],
|
|
87
|
-
counters: [],
|
|
88
|
-
logs: [],
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
onBlock(handler) {
|
|
95
|
-
const chainId = this.getChainId();
|
|
96
|
-
const contractView = this.CreateBoundContractView();
|
|
97
|
-
this.blockHandlers.push(async function (block) {
|
|
98
|
-
const ctx = new context_1.Context(contractView, chainId, block, undefined);
|
|
99
|
-
await handler(block, ctx);
|
|
100
|
-
return {
|
|
101
|
-
gauges: ctx.gauges,
|
|
102
|
-
counters: ctx.counters,
|
|
103
|
-
logs: [],
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
return this;
|
|
107
|
-
}
|
|
108
|
-
onAllEvents(handler) {
|
|
109
|
-
const _filters = [];
|
|
110
|
-
const tmpContract = this.CreateBoundContractView();
|
|
111
|
-
for (const key in tmpContract.filters) {
|
|
112
|
-
_filters.push(tmpContract.filters[key]());
|
|
113
|
-
}
|
|
114
|
-
return this.onEvent(function (log, ctx) {
|
|
115
|
-
return handler(log, ctx);
|
|
116
|
-
}, _filters);
|
|
117
|
-
}
|
|
118
|
-
onTrace(signature, handler) {
|
|
119
|
-
const chainId = this.getChainId();
|
|
120
|
-
const contractView = this.CreateBoundContractView();
|
|
121
|
-
this.traceHandlers.push({
|
|
122
|
-
signature,
|
|
123
|
-
handler: async function (trace) {
|
|
124
|
-
const contractInterface = contractView.rawContract.interface;
|
|
125
|
-
const fragment = contractInterface.getFunction(signature);
|
|
126
|
-
if (!trace.action.input) {
|
|
127
|
-
return {
|
|
128
|
-
gauges: [],
|
|
129
|
-
counters: [],
|
|
130
|
-
logs: [],
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
const traceData = '0x' + trace.action.input.slice(10);
|
|
134
|
-
trace.args = contractInterface._abiCoder.decode(fragment.inputs, traceData);
|
|
135
|
-
const ctx = new context_1.Context(contractView, chainId, undefined, undefined, trace);
|
|
136
|
-
await handler(trace, ctx);
|
|
137
|
-
return {
|
|
138
|
-
gauges: ctx.gauges,
|
|
139
|
-
counters: ctx.counters,
|
|
140
|
-
logs: [],
|
|
141
|
-
};
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
exports.BaseProcessor = BaseProcessor;
|
|
148
|
-
//# sourceMappingURL=base-processor.js.map
|