@sentio/sdk 1.7.13 → 1.7.16
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/{base-processor-template.d.ts → lib/base-processor-template.d.ts} +0 -0
- package/{base-processor-template.js → lib/base-processor-template.js} +0 -0
- package/lib/base-processor-template.js.map +1 -0
- package/{base-processor.d.ts → lib/base-processor.d.ts} +0 -0
- package/{base-processor.js → lib/base-processor.js} +0 -0
- package/lib/base-processor.js.map +1 -0
- package/{bind-options.d.ts → lib/bind-options.d.ts} +0 -0
- package/{bind-options.js → lib/bind-options.js} +0 -0
- package/lib/bind-options.js.map +1 -0
- package/{binds.d.ts → lib/binds.d.ts} +0 -0
- package/{binds.js → lib/binds.js} +0 -0
- package/lib/binds.js.map +1 -0
- package/{builtin → lib/builtin}/erc20/index.d.ts +0 -0
- package/{builtin → lib/builtin}/erc20/index.js +0 -0
- package/lib/builtin/erc20/index.js.map +1 -0
- package/{builtin → lib/builtin}/erc20/test-utils.d.ts +0 -0
- package/{builtin → lib/builtin}/erc20/test-utils.js +0 -0
- package/lib/builtin/erc20/test-utils.js.map +1 -0
- package/{builtin → lib/builtin}/internal/Erc20.d.ts +0 -0
- package/{builtin → lib/builtin}/internal/Erc20.js +0 -0
- package/lib/builtin/internal/Erc20.js.map +1 -0
- package/{builtin → lib/builtin}/internal/common.d.ts +0 -0
- package/{builtin → lib/builtin}/internal/common.js +0 -0
- package/lib/builtin/internal/common.js.map +1 -0
- package/{builtin → lib/builtin}/internal/erc20_processor.d.ts +0 -0
- package/{builtin → lib/builtin}/internal/erc20_processor.js +0 -0
- package/lib/builtin/internal/erc20_processor.js.map +1 -0
- package/{builtin → lib/builtin}/internal/factories/Erc20__factory.d.ts +0 -0
- package/{builtin → lib/builtin}/internal/factories/Erc20__factory.js +0 -0
- package/lib/builtin/internal/factories/Erc20__factory.js.map +1 -0
- package/{builtin → lib/builtin}/internal/factories/index.d.ts +0 -0
- package/{builtin → lib/builtin}/internal/factories/index.js +0 -0
- package/{builtin → lib/builtin}/internal/factories/index.js.map +1 -1
- package/{builtin → lib/builtin}/internal/index.d.ts +0 -0
- package/{builtin → lib/builtin}/internal/index.js +0 -0
- package/lib/builtin/internal/index.js.map +1 -0
- package/{chain-config.d.ts → lib/chain-config.d.ts} +0 -0
- package/{chain-config.js → lib/chain-config.js} +0 -0
- package/lib/chain-config.js.map +1 -0
- package/{cli → lib/cli}/build.d.ts +0 -0
- package/{cli → lib/cli}/build.js +0 -0
- package/lib/cli/build.js.map +1 -0
- package/{cli → lib/cli}/cli.d.ts +0 -0
- package/{cli → lib/cli}/cli.js +0 -0
- package/lib/cli/cli.js.map +1 -0
- package/{cli → lib/cli}/config.d.ts +0 -0
- package/{cli → lib/cli}/config.js +0 -0
- package/lib/cli/config.js.map +1 -0
- package/{cli → lib/cli}/key.d.ts +0 -0
- package/{cli → lib/cli}/key.js +0 -0
- package/{cli → lib/cli}/key.js.map +1 -1
- package/{cli → lib/cli}/solana-code-gen.d.ts +0 -0
- package/{cli → lib/cli}/solana-code-gen.js +0 -0
- package/{cli → lib/cli}/solana-code-gen.js.map +1 -1
- package/{cli → lib/cli}/upload.d.ts +0 -0
- package/{cli → lib/cli}/upload.js +0 -0
- package/{cli → lib/cli}/upload.js.map +1 -1
- package/{cli → lib/cli}/webpack.config.js +0 -0
- package/{context.d.ts → lib/context.d.ts} +0 -0
- package/{context.js → lib/context.js} +0 -0
- package/lib/context.js.map +1 -0
- package/{contract-namer.d.ts → lib/contract-namer.d.ts} +0 -0
- package/{contract-namer.js → lib/contract-namer.js} +0 -0
- package/{contract-namer.js.map → lib/contract-namer.js.map} +1 -1
- package/{error.d.ts → lib/error.d.ts} +0 -0
- package/{error.js → lib/error.js} +0 -0
- package/lib/error.js.map +1 -0
- package/{gen → lib/gen}/builtin.d.ts +0 -0
- package/{gen → lib/gen}/builtin.js +0 -0
- package/lib/gen/builtin.js.map +1 -0
- package/{gen → lib/gen}/google/protobuf/empty.d.ts +0 -0
- package/{gen → lib/gen}/google/protobuf/empty.js +0 -0
- package/lib/gen/google/protobuf/empty.js.map +1 -0
- package/{gen → lib/gen}/processor/protos/processor.d.ts +0 -0
- package/{gen → lib/gen}/processor/protos/processor.js +0 -0
- package/lib/gen/processor/protos/processor.js.map +1 -0
- package/{generic-processor.d.ts → lib/generic-processor.d.ts} +0 -0
- package/{generic-processor.js → lib/generic-processor.js} +0 -0
- package/lib/generic-processor.js.map +1 -0
- package/{index.d.ts → lib/index.d.ts} +0 -0
- package/{index.js → lib/index.js} +0 -0
- package/lib/index.js.map +1 -0
- package/lib/loader.d.ts +5 -0
- package/lib/loader.js +30 -0
- package/lib/loader.js.map +1 -0
- package/{meter.d.ts → lib/meter.d.ts} +0 -0
- package/{meter.js → lib/meter.js} +0 -0
- package/lib/meter.js.map +1 -0
- package/{numberish.d.ts → lib/numberish.d.ts} +0 -0
- package/{numberish.js → lib/numberish.js} +0 -0
- package/lib/numberish.js.map +1 -0
- package/{numberish.test.d.ts → lib/numberish.test.d.ts} +0 -0
- package/{numberish.test.js → lib/numberish.test.js} +0 -0
- package/{numberish.test.js.map → lib/numberish.test.js.map} +1 -1
- package/{processor-runner.d.ts → lib/processor-runner.d.ts} +0 -0
- package/{processor-runner.js → lib/processor-runner.js} +2 -27
- package/lib/processor-runner.js.map +1 -0
- package/{processor-state.d.ts → lib/processor-state.d.ts} +0 -0
- package/{processor-state.js → lib/processor-state.js} +0 -0
- package/lib/processor-state.js.map +1 -0
- package/{promise-or-void.d.ts → lib/promise-or-void.d.ts} +0 -0
- package/{promise-or-void.js → lib/promise-or-void.js} +0 -0
- package/lib/promise-or-void.js.map +1 -0
- package/{provider.d.ts → lib/provider.d.ts} +0 -0
- package/{provider.js → lib/provider.js} +0 -0
- package/lib/provider.js.map +1 -0
- package/{release.config.js → lib/release.config.js} +0 -0
- package/{service.d.ts → lib/service.d.ts} +2 -1
- package/{service.js → lib/service.js} +6 -3
- package/lib/service.js.map +1 -0
- package/{solana → lib/solana}/builtin/index.d.ts +0 -0
- package/{solana → lib/solana}/builtin/index.js +0 -0
- package/lib/solana/builtin/index.js.map +1 -0
- package/{solana → lib/solana}/builtin/spl-token-processor.d.ts +0 -0
- package/{solana → lib/solana}/builtin/spl-token-processor.js +0 -0
- package/lib/solana/builtin/spl-token-processor.js.map +1 -0
- package/{solana → lib/solana}/builtin/types.d.ts +0 -0
- package/{solana → lib/solana}/builtin/types.js +0 -0
- package/lib/solana/builtin/types.js.map +1 -0
- package/{solana → lib/solana}/builtin/wormhole-processor.d.ts +0 -0
- package/{solana → lib/solana}/builtin/wormhole-processor.js +0 -0
- package/lib/solana/builtin/wormhole-processor.js.map +1 -0
- package/{solana-processor.d.ts → lib/solana-processor.d.ts} +0 -0
- package/{solana-processor.js → lib/solana-processor.js} +0 -0
- package/lib/solana-processor.js.map +1 -0
- package/{target-ethers-sentio → lib/target-ethers-sentio}/codegen.d.ts +0 -0
- package/{target-ethers-sentio → lib/target-ethers-sentio}/codegen.js +0 -0
- package/{target-ethers-sentio → lib/target-ethers-sentio}/codegen.js.map +0 -0
- package/{target-ethers-sentio → lib/target-ethers-sentio}/index.d.ts +0 -0
- package/{target-ethers-sentio → lib/target-ethers-sentio}/index.js +0 -0
- package/{target-ethers-sentio → lib/target-ethers-sentio}/index.js.map +0 -0
- package/{test → lib/test}/codegen.test.d.ts +0 -0
- package/{test → lib/test}/codegen.test.js +1 -1
- package/lib/test/codegen.test.js.map +1 -0
- package/{test → lib/test}/erc20-template.d.ts +0 -0
- package/{test → lib/test}/erc20-template.js +0 -0
- package/lib/test/erc20-template.js.map +1 -0
- package/{test → lib/test}/erc20-template.test.d.ts +0 -0
- package/{test → lib/test}/erc20-template.test.js +1 -3
- package/lib/test/erc20-template.test.js.map +1 -0
- package/{test → lib/test}/erc20.d.ts +0 -0
- package/{test → lib/test}/erc20.js +0 -0
- package/lib/test/erc20.js.map +1 -0
- package/{test → lib/test}/erc20.test.d.ts +0 -0
- package/{test → lib/test}/erc20.test.js +1 -3
- package/lib/test/erc20.test.js.map +1 -0
- package/{test → lib/test}/generic-processor.test.d.ts +0 -0
- package/{test → lib/test}/generic-processor.test.js +14 -4
- package/lib/test/generic-processor.test.js.map +1 -0
- package/{test → lib/test}/index.d.ts +0 -0
- package/{test → lib/test}/index.js +0 -0
- package/{test → lib/test}/index.js.map +1 -1
- package/{test → lib/test}/metric-utils.d.ts +0 -0
- package/{test → lib/test}/metric-utils.js +0 -0
- package/lib/test/metric-utils.js.map +1 -0
- package/{test → lib/test}/mirrorworld.d.ts +0 -0
- package/{test → lib/test}/mirrorworld.js +0 -0
- package/{test → lib/test}/mirrorworld.js.map +1 -1
- package/{test → lib/test}/solana.test.d.ts +0 -0
- package/{test → lib/test}/solana.test.js +3 -3
- package/lib/test/solana.test.js.map +1 -0
- package/{test → lib/test}/test-processor-server.d.ts +1 -1
- package/{test → lib/test}/test-processor-server.js +3 -8
- package/lib/test/test-processor-server.js.map +1 -0
- package/{test → lib/test}/types/game_wallet.d.ts +0 -0
- package/{test → lib/test}/types/game_wallet.js +0 -0
- package/lib/test/types/game_wallet.js.map +1 -0
- package/{test → lib/test}/types/game_wallet_processor.d.ts +0 -0
- package/{test → lib/test}/types/game_wallet_processor.js +0 -0
- package/lib/test/types/game_wallet_processor.js.map +1 -0
- package/{test → lib/test}/wormhole-token-bridge.d.ts +0 -0
- package/{test → lib/test}/wormhole-token-bridge.js +0 -0
- package/lib/test/wormhole-token-bridge.js.map +1 -0
- package/{utils → lib/utils}/chainmap.d.ts +0 -0
- package/{utils → lib/utils}/chainmap.js +0 -0
- package/lib/utils/chainmap.js.map +1 -0
- package/{utils → lib/utils}/convert.d.ts +0 -0
- package/{utils → lib/utils}/convert.js +0 -0
- package/lib/utils/convert.js.map +1 -0
- package/{utils → lib/utils}/index.d.ts +0 -0
- package/{utils → lib/utils}/index.js +0 -0
- package/lib/utils/index.js.map +1 -0
- package/package.json +47 -6
- package/src/abis/erc20.json +198 -0
- package/src/base-processor-template.ts +92 -0
- package/src/base-processor.ts +128 -0
- package/src/bind-options.ts +41 -0
- package/src/binds.ts +73 -0
- package/src/builtin/erc20/index.ts +6 -0
- package/src/builtin/erc20/test-utils.ts +49 -0
- package/src/builtin/internal/Erc20.ts +356 -0
- package/src/builtin/internal/common.ts +46 -0
- package/src/builtin/internal/erc20_processor.ts +295 -0
- package/src/builtin/internal/factories/Erc20__factory.ts +216 -0
- package/src/builtin/internal/factories/index.ts +4 -0
- package/src/builtin/internal/index.ts +6 -0
- package/src/chain-config.ts +6 -0
- package/src/cli/build.ts +180 -0
- package/src/cli/cli.ts +217 -0
- package/src/cli/config.ts +43 -0
- package/src/cli/key.ts +43 -0
- package/src/cli/solana-code-gen.ts +16 -0
- package/src/cli/upload.ts +86 -0
- package/src/cli/webpack.config.js +42 -0
- package/src/context.ts +93 -0
- package/src/contract-namer.ts +17 -0
- package/src/error.ts +43 -0
- package/src/gen/builtin.ts +22 -0
- package/src/gen/google/protobuf/empty.ts +70 -0
- package/src/gen/processor/protos/processor.ts +3071 -0
- package/src/generic-processor.ts +38 -0
- package/src/index.ts +19 -0
- package/src/loader.ts +24 -0
- package/src/meter.ts +122 -0
- package/src/numberish.test.ts +82 -0
- package/src/numberish.ts +99 -0
- package/src/processor-runner.ts +49 -0
- package/src/processor-state.ts +24 -0
- package/src/promise-or-void.ts +1 -0
- package/src/provider.ts +74 -0
- package/src/service.ts +439 -0
- package/src/solana/builtin/index.ts +2 -0
- package/src/solana/builtin/spl-token-processor.ts +164 -0
- package/src/solana/builtin/types.ts +268 -0
- package/src/solana/builtin/wormhole-processor.ts +178 -0
- package/src/solana-processor.ts +105 -0
- package/src/target-ethers-sentio/codegen.ts +289 -0
- package/src/target-ethers-sentio/index.ts +50 -0
- package/src/target-ethers-sentio/tsconfig.json +9 -0
- package/src/test/abis/evm/anyswapRouter.json +490 -0
- package/src/test/abis/solana/mirrorworld.json +1392 -0
- package/src/test/codegen.test.ts +26 -0
- package/src/test/erc20-template.test.ts +37 -0
- package/src/test/erc20-template.ts +25 -0
- package/src/test/erc20.test.ts +90 -0
- package/src/test/erc20.ts +48 -0
- package/src/test/generic-processor.test.ts +70 -0
- package/src/test/index.ts +1 -0
- package/src/test/metric-utils.ts +49 -0
- package/src/test/mirrorworld.ts +40 -0
- package/src/test/sentio.yaml +4 -0
- package/src/test/solana.test.ts +93 -0
- package/src/test/test-processor-server.ts +205 -0
- package/src/test/types/game_wallet.ts +1392 -0
- package/src/test/types/game_wallet_processor.ts +113 -0
- package/src/test/wormhole-token-bridge.ts +21 -0
- package/src/types/global.d.ts +17 -0
- package/src/utils/chainmap.ts +95 -0
- package/src/utils/convert.ts +6 -0
- package/src/utils/index.ts +2 -0
- package/base-processor-template.js.map +0 -1
- package/base-processor.js.map +0 -1
- package/bind-options.js.map +0 -1
- package/binds.js.map +0 -1
- package/builtin/erc20/index.js.map +0 -1
- package/builtin/erc20/test-utils.js.map +0 -1
- package/builtin/internal/Erc20.js.map +0 -1
- package/builtin/internal/common.js.map +0 -1
- package/builtin/internal/erc20_processor.js.map +0 -1
- package/builtin/internal/factories/Erc20__factory.js.map +0 -1
- package/builtin/internal/index.js.map +0 -1
- package/chain-config.js.map +0 -1
- package/cli/build.js.map +0 -1
- package/cli/cli.js.map +0 -1
- package/cli/config.js.map +0 -1
- package/context.js.map +0 -1
- package/error.js.map +0 -1
- package/gen/builtin.js.map +0 -1
- package/gen/google/protobuf/empty.js.map +0 -1
- package/gen/processor/protos/processor.js.map +0 -1
- package/generic-processor.js.map +0 -1
- package/index.js.map +0 -1
- package/meter.js.map +0 -1
- package/numberish.js.map +0 -1
- package/processor-runner.js.map +0 -1
- package/processor-state.js.map +0 -1
- package/promise-or-void.js.map +0 -1
- package/provider.js.map +0 -1
- package/service.js.map +0 -1
- package/solana/builtin/index.js.map +0 -1
- package/solana/builtin/spl-token-processor.js.map +0 -1
- package/solana/builtin/types.js.map +0 -1
- package/solana/builtin/wormhole-processor.js.map +0 -1
- package/solana-processor.js.map +0 -1
- package/test/codegen.test.js.map +0 -1
- package/test/erc20-template.js.map +0 -1
- package/test/erc20-template.test.js.map +0 -1
- package/test/erc20.js.map +0 -1
- package/test/erc20.test.js.map +0 -1
- package/test/generic-processor.test.js.map +0 -1
- package/test/metric-utils.js.map +0 -1
- package/test/solana.test.js.map +0 -1
- package/test/test-processor-server.js.map +0 -1
- package/test/types/game_wallet.js.map +0 -1
- package/test/types/game_wallet_processor.js.map +0 -1
- package/test/wormhole-token-bridge.js.map +0 -1
- package/utils/chainmap.js.map +0 -1
- package/utils/convert.js.map +0 -1
- package/utils/index.js.map +0 -1
package/src/cli/key.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import os from 'os'
|
|
4
|
+
|
|
5
|
+
const homeDir = os.homedir()
|
|
6
|
+
const sentioDir = path.join(homeDir, '.sentio')
|
|
7
|
+
const configFile = path.join(sentioDir, 'config.json')
|
|
8
|
+
|
|
9
|
+
interface SentioKeyConfig {
|
|
10
|
+
[key: string]: {
|
|
11
|
+
api_keys: string
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function WriteKey(host: string, api_key: string) {
|
|
16
|
+
const sentioDir = path.join(homeDir, '.sentio')
|
|
17
|
+
if (!fs.existsSync(sentioDir)) {
|
|
18
|
+
fs.mkdirSync(sentioDir, { recursive: true })
|
|
19
|
+
}
|
|
20
|
+
let config: SentioKeyConfig = {}
|
|
21
|
+
if (fs.existsSync(configFile)) {
|
|
22
|
+
const content = fs.readFileSync(configFile, 'utf8')
|
|
23
|
+
config = JSON.parse(content)
|
|
24
|
+
}
|
|
25
|
+
const hostConfig = config[host] || { api_keys: {} }
|
|
26
|
+
hostConfig.api_keys = api_key
|
|
27
|
+
config[host] = hostConfig
|
|
28
|
+
fs.writeFileSync(configFile, JSON.stringify(config, null, 2))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function ReadKey(host: string): string | undefined {
|
|
32
|
+
if (!fs.existsSync(sentioDir)) {
|
|
33
|
+
return undefined
|
|
34
|
+
}
|
|
35
|
+
const configFile = path.join(sentioDir, 'config.json')
|
|
36
|
+
if (fs.existsSync(configFile)) {
|
|
37
|
+
const content = fs.readFileSync(configFile, 'utf8')
|
|
38
|
+
const config = JSON.parse(content)
|
|
39
|
+
return config[host]?.api_keys
|
|
40
|
+
} else {
|
|
41
|
+
return undefined
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { codeGenSolanaProcessor } from './build'
|
|
4
|
+
|
|
5
|
+
const abisDir = 'abis/solana'
|
|
6
|
+
if (process.argv.length > 2) {
|
|
7
|
+
const rootPath = process.argv[2]
|
|
8
|
+
if (process.argv.length > 3) {
|
|
9
|
+
const targetPath = process.argv[3]
|
|
10
|
+
codeGenSolanaProcessor(abisDir, rootPath, targetPath)
|
|
11
|
+
} else {
|
|
12
|
+
codeGenSolanaProcessor(abisDir, rootPath)
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
codeGenSolanaProcessor(abisDir)
|
|
16
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { execSync } from 'child_process'
|
|
2
|
+
import { createHash } from 'crypto'
|
|
3
|
+
import FormData from 'form-data'
|
|
4
|
+
import fs from 'fs'
|
|
5
|
+
import { SentioProjectConfig } from './config'
|
|
6
|
+
import { ReadKey } from './key'
|
|
7
|
+
import path from 'path'
|
|
8
|
+
import chalk from 'chalk'
|
|
9
|
+
import { buildProcessor } from './build'
|
|
10
|
+
import fetch from 'node-fetch'
|
|
11
|
+
|
|
12
|
+
export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: string) {
|
|
13
|
+
if (options.build) {
|
|
14
|
+
await buildProcessor(false, options.targets)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
console.log(chalk.blue('Uploading'))
|
|
18
|
+
|
|
19
|
+
const PROCESSOR_FILE = path.join(process.cwd(), 'dist/lib.js')
|
|
20
|
+
|
|
21
|
+
const url = new URL(options.host)
|
|
22
|
+
const apiKey = apiKeyOverride || ReadKey(options.host)
|
|
23
|
+
|
|
24
|
+
const isProd = options.host === 'https://app.sentio.xyz'
|
|
25
|
+
if (!apiKey) {
|
|
26
|
+
const cmd = isProd ? 'sentio login' : 'sentio login --host=' + options.host
|
|
27
|
+
console.error(chalk.red('No Credential found for', options.host, '. Please run `' + cmd + '`.'))
|
|
28
|
+
process.exit(1)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!fs.existsSync(PROCESSOR_FILE)) {
|
|
32
|
+
console.error(chalk.red('File not existed ', PROCESSOR_FILE, "don't use --nobuild"))
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const stat = fs.statSync(PROCESSOR_FILE)
|
|
37
|
+
console.log('Packed processor file size', Math.floor(stat.size / 1024) + 'K, last modified', stat.mtime)
|
|
38
|
+
const content = fs.readFileSync(PROCESSOR_FILE)
|
|
39
|
+
const hash = createHash('sha256')
|
|
40
|
+
hash.update(content)
|
|
41
|
+
const digest = hash.digest('hex')
|
|
42
|
+
|
|
43
|
+
const data = new FormData()
|
|
44
|
+
data.append('attachment', fs.createReadStream(PROCESSOR_FILE))
|
|
45
|
+
data.append('sha256', digest)
|
|
46
|
+
|
|
47
|
+
let commitSha
|
|
48
|
+
try {
|
|
49
|
+
commitSha = execSync('git rev-parse HEAD').toString().trim()
|
|
50
|
+
data.append('commitSha', commitSha)
|
|
51
|
+
} catch (e) {
|
|
52
|
+
chalk.yellow(e)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
url.pathname = '/api/v1/processors'
|
|
56
|
+
|
|
57
|
+
let packageJson: { version: string }
|
|
58
|
+
try {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
60
|
+
packageJson = require('../package.json')
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
63
|
+
packageJson = require('../../package.json')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const res = await fetch(url, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: {
|
|
69
|
+
'api-key': apiKey,
|
|
70
|
+
project: options.project,
|
|
71
|
+
version: packageJson.version,
|
|
72
|
+
},
|
|
73
|
+
body: data,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
if (res.ok) {
|
|
77
|
+
console.log(chalk.green('Upload success: '))
|
|
78
|
+
console.log('\t', chalk.blue('sha256:'), digest)
|
|
79
|
+
if (commitSha) {
|
|
80
|
+
console.log('\t', chalk.blue('Git commit SHA:'), commitSha)
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
console.error(chalk.red('Upload Failed'))
|
|
84
|
+
console.error(chalk.red(await res.text()))
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
const path = require('path')
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
entry: {
|
|
6
|
+
lib: './src/processor.ts',
|
|
7
|
+
},
|
|
8
|
+
devtool: 'inline-source-map',
|
|
9
|
+
module: {
|
|
10
|
+
rules: [
|
|
11
|
+
{
|
|
12
|
+
test: /\.tsx?$/,
|
|
13
|
+
use: 'ts-loader',
|
|
14
|
+
exclude: /node_modules/,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
resolve: {
|
|
19
|
+
extensions: ['.ts', '.js'],
|
|
20
|
+
},
|
|
21
|
+
output: {
|
|
22
|
+
filename: '[name].js',
|
|
23
|
+
path: path.resolve(process.cwd(), 'dist'),
|
|
24
|
+
},
|
|
25
|
+
target: 'node',
|
|
26
|
+
mode: 'production',
|
|
27
|
+
externals: [
|
|
28
|
+
{
|
|
29
|
+
ethers: 'commonjs2 ethers',
|
|
30
|
+
'@sentio/sdk': 'root sentio_sdk',
|
|
31
|
+
bs58: 'commonjs2 bs58',
|
|
32
|
+
"bignumber.js": 'commonjs2 bignumber.js',
|
|
33
|
+
'bn.js': 'commonjs2 bn.js',
|
|
34
|
+
},
|
|
35
|
+
function ({ context, request }, callback) {
|
|
36
|
+
if (/^@(ethersproject|solana|project-serum).*$/.test(request)) {
|
|
37
|
+
return callback(null, 'commonjs ' + request)
|
|
38
|
+
}
|
|
39
|
+
callback()
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}
|
package/src/context.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CounterResult, GaugeResult } from './gen/processor/protos/processor'
|
|
2
|
+
import { BaseContract, EventFilter } from 'ethers'
|
|
3
|
+
import { Block, Log } from '@ethersproject/abstract-provider'
|
|
4
|
+
import { Meter } from './meter'
|
|
5
|
+
import Long from 'long'
|
|
6
|
+
|
|
7
|
+
export class EthContext {
|
|
8
|
+
chainId: number
|
|
9
|
+
log?: Log
|
|
10
|
+
block?: Block
|
|
11
|
+
blockNumber: Long
|
|
12
|
+
gauges: GaugeResult[] = []
|
|
13
|
+
counters: CounterResult[] = []
|
|
14
|
+
meter: Meter
|
|
15
|
+
|
|
16
|
+
constructor(chainId: number, block?: Block, log?: Log) {
|
|
17
|
+
this.chainId = chainId
|
|
18
|
+
this.log = log
|
|
19
|
+
this.block = block
|
|
20
|
+
if (log) {
|
|
21
|
+
this.blockNumber = Long.fromNumber(log.blockNumber)
|
|
22
|
+
} else if (block) {
|
|
23
|
+
this.blockNumber = Long.fromNumber(block.number)
|
|
24
|
+
}
|
|
25
|
+
this.meter = new Meter(this)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class Context<
|
|
30
|
+
TContract extends BaseContract,
|
|
31
|
+
TContractBoundView extends BoundContractView<TContract, ContractView<TContract>>
|
|
32
|
+
> extends EthContext {
|
|
33
|
+
contract: TContractBoundView
|
|
34
|
+
|
|
35
|
+
constructor(view: TContractBoundView, chainId: number, block?: Block, log?: Log) {
|
|
36
|
+
super(chainId, block, log)
|
|
37
|
+
view.context = this
|
|
38
|
+
this.contract = view
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class ContractView<TContract extends BaseContract> {
|
|
43
|
+
filters: { [name: string]: (...args: Array<any>) => EventFilter }
|
|
44
|
+
protected contract: TContract
|
|
45
|
+
|
|
46
|
+
constructor(contract: TContract) {
|
|
47
|
+
this.contract = contract
|
|
48
|
+
this.filters = contract.filters
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get rawContract() {
|
|
52
|
+
return this.contract
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get provider() {
|
|
56
|
+
return this.contract.provider
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class BoundContractView<TContract extends BaseContract, TContractView extends ContractView<TContract>> {
|
|
61
|
+
protected view: TContractView
|
|
62
|
+
// context will be set right after context creation (in context's constructor)
|
|
63
|
+
context: Context<TContract, BoundContractView<TContract, TContractView>>
|
|
64
|
+
|
|
65
|
+
constructor(view: TContractView) {
|
|
66
|
+
this.view = view
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get rawContract() {
|
|
70
|
+
return this.view.rawContract
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get provider() {
|
|
74
|
+
return this.view.provider
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get filters() {
|
|
78
|
+
return this.view.filters
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class SolanaContext {
|
|
83
|
+
gauges: GaugeResult[] = []
|
|
84
|
+
counters: CounterResult[] = []
|
|
85
|
+
meter: Meter
|
|
86
|
+
|
|
87
|
+
address: string
|
|
88
|
+
|
|
89
|
+
constructor(address: string) {
|
|
90
|
+
this.meter = new Meter(this)
|
|
91
|
+
this.address = address
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class ContractNamer {
|
|
2
|
+
defaultName: string
|
|
3
|
+
counter: number
|
|
4
|
+
|
|
5
|
+
constructor(defaultName: string) {
|
|
6
|
+
this.defaultName = defaultName
|
|
7
|
+
this.counter = 0
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public nextName(): string {
|
|
11
|
+
const id = this.counter++
|
|
12
|
+
if (id > 0) {
|
|
13
|
+
return this.defaultName + '_' + id
|
|
14
|
+
}
|
|
15
|
+
return this.defaultName
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/error.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Transform error in more readable format
|
|
2
|
+
import { Context } from './context'
|
|
3
|
+
import { errors } from 'ethers'
|
|
4
|
+
|
|
5
|
+
class EthersError extends Error {
|
|
6
|
+
constructor(message: string, stack?: string) {
|
|
7
|
+
super(message)
|
|
8
|
+
this.stack = stack
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
toString() {
|
|
12
|
+
return this.message + '\n' + this.stack?.toString()
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function transformEtherError(e: Error, ctx: Context<any, any> | undefined): Error {
|
|
17
|
+
let msg = ''
|
|
18
|
+
// @ts-ignore expected error fields
|
|
19
|
+
if (e.code === errors.CALL_EXCEPTION) {
|
|
20
|
+
// @ts-ignore expected error fields
|
|
21
|
+
if (e.data === '0x') {
|
|
22
|
+
if (ctx) {
|
|
23
|
+
msg =
|
|
24
|
+
"jsonrpc eth_call return '0x' (likely contract not existed) at chain " +
|
|
25
|
+
ctx.chainId +
|
|
26
|
+
': ' +
|
|
27
|
+
JSON.stringify(e)
|
|
28
|
+
} else {
|
|
29
|
+
msg = "jsonrpc eth_call return '0x' (likely contract not existed): " + JSON.stringify(e)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return new EthersError(msg, e.stack)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (e instanceof EthersError) {
|
|
36
|
+
return e
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// TODO gracefully handle more errors
|
|
40
|
+
|
|
41
|
+
msg = 'ethers call error\n' + e.message + '\n' + e.stack?.toString()
|
|
42
|
+
return new Error(msg)
|
|
43
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Long from 'long'
|
|
2
|
+
|
|
3
|
+
type Builtin =
|
|
4
|
+
| Date
|
|
5
|
+
| Function
|
|
6
|
+
| Uint8Array
|
|
7
|
+
| string
|
|
8
|
+
| number
|
|
9
|
+
| boolean
|
|
10
|
+
| undefined;
|
|
11
|
+
|
|
12
|
+
export type DeepPartial<T> = T extends Builtin
|
|
13
|
+
? T
|
|
14
|
+
: T extends Long
|
|
15
|
+
? string | number | Long
|
|
16
|
+
: T extends Array<infer U>
|
|
17
|
+
? Array<DeepPartial<U>>
|
|
18
|
+
: T extends ReadonlyArray<infer U>
|
|
19
|
+
? ReadonlyArray<DeepPartial<U>>
|
|
20
|
+
: T extends {}
|
|
21
|
+
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
22
|
+
: Partial<T>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import Long from "long";
|
|
3
|
+
import _m0 from "protobufjs/minimal";
|
|
4
|
+
|
|
5
|
+
export interface Empty {}
|
|
6
|
+
|
|
7
|
+
function createBaseEmpty(): Empty {
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Empty = {
|
|
12
|
+
encode(_: Empty, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
13
|
+
return writer;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Empty {
|
|
17
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
18
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
19
|
+
const message = createBaseEmpty();
|
|
20
|
+
while (reader.pos < end) {
|
|
21
|
+
const tag = reader.uint32();
|
|
22
|
+
switch (tag >>> 3) {
|
|
23
|
+
default:
|
|
24
|
+
reader.skipType(tag & 7);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return message;
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
fromJSON(_: any): Empty {
|
|
32
|
+
return {};
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
toJSON(_: Empty): unknown {
|
|
36
|
+
const obj: any = {};
|
|
37
|
+
return obj;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
fromPartial(_: DeepPartial<Empty>): Empty {
|
|
41
|
+
const message = createBaseEmpty();
|
|
42
|
+
return message;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type Builtin =
|
|
47
|
+
| Date
|
|
48
|
+
| Function
|
|
49
|
+
| Uint8Array
|
|
50
|
+
| string
|
|
51
|
+
| number
|
|
52
|
+
| boolean
|
|
53
|
+
| undefined;
|
|
54
|
+
|
|
55
|
+
type DeepPartial<T> = T extends Builtin
|
|
56
|
+
? T
|
|
57
|
+
: T extends Long
|
|
58
|
+
? string | number | Long
|
|
59
|
+
: T extends Array<infer U>
|
|
60
|
+
? Array<DeepPartial<U>>
|
|
61
|
+
: T extends ReadonlyArray<infer U>
|
|
62
|
+
? ReadonlyArray<DeepPartial<U>>
|
|
63
|
+
: T extends {}
|
|
64
|
+
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
65
|
+
: Partial<T>;
|
|
66
|
+
|
|
67
|
+
if (_m0.util.Long !== Long) {
|
|
68
|
+
_m0.util.Long = Long as any;
|
|
69
|
+
_m0.configure();
|
|
70
|
+
}
|