@sentio/sdk 1.35.1-rc.2 → 1.36.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/network.d.ts +1 -1
- package/lib/aptos/network.js +7 -7
- package/lib/aptos/network.js.map +1 -1
- package/lib/aptos-codegen/codegen.d.ts +1 -0
- package/lib/aptos-codegen/codegen.js +10 -2
- package/lib/aptos-codegen/codegen.js.map +1 -1
- package/lib/core/context.js +2 -2
- package/lib/core/context.js.map +1 -1
- package/lib/service.js +2 -2
- package/lib/service.js.map +1 -1
- package/lib/solana-codegen/codegen.d.ts +1 -0
- package/lib/{cli/build.js → solana-codegen/codegen.js} +3 -92
- package/lib/solana-codegen/codegen.js.map +1 -0
- package/lib/test-abi-code-gen.js +4 -3
- package/lib/test-abi-code-gen.js.map +1 -1
- package/lib/utils/chain.d.ts +86 -6
- package/lib/utils/chain.js +95 -91
- package/lib/utils/chain.js.map +1 -1
- package/package.json +3 -11
- package/src/aptos/network.ts +6 -6
- package/src/aptos-codegen/codegen.ts +10 -2
- package/src/core/context.ts +3 -3
- package/src/service.ts +3 -3
- package/src/{cli/build.ts → solana-codegen/codegen.ts} +1 -113
- package/src/test-abi-code-gen.ts +2 -1
- package/src/utils/chain.ts +94 -91
- package/lib/cli/build.d.ts +0 -4
- package/lib/cli/build.js.map +0 -1
- package/lib/cli/cli.d.ts +0 -2
- package/lib/cli/cli.js +0 -186
- package/lib/cli/cli.js.map +0 -1
- package/lib/cli/commands/login-server.d.ts +0 -7
- package/lib/cli/commands/login-server.js +0 -133
- package/lib/cli/commands/login-server.js.map +0 -1
- package/lib/cli/commands/run-create.d.ts +0 -1
- package/lib/cli/commands/run-create.js +0 -111
- package/lib/cli/commands/run-create.js.map +0 -1
- package/lib/cli/commands/run-login.d.ts +0 -1
- package/lib/cli/commands/run-login.js +0 -136
- package/lib/cli/commands/run-login.js.map +0 -1
- package/lib/cli/commands/run-version.d.ts +0 -1
- package/lib/cli/commands/run-version.js +0 -39
- package/lib/cli/commands/run-version.js.map +0 -1
- package/lib/cli/config.d.ts +0 -14
- package/lib/cli/config.js +0 -64
- package/lib/cli/config.js.map +0 -1
- package/lib/cli/key.d.ts +0 -2
- package/lib/cli/key.js +0 -44
- package/lib/cli/key.js.map +0 -1
- package/lib/cli/upload.d.ts +0 -2
- package/lib/cli/upload.js +0 -189
- package/lib/cli/upload.js.map +0 -1
- package/lib/cli/utils.d.ts +0 -1
- package/lib/cli/utils.js +0 -16
- package/lib/cli/utils.js.map +0 -1
- package/lib/cli/webpack.config.js +0 -47
- package/src/cli/cli.ts +0 -184
- package/src/cli/commands/login-server.ts +0 -119
- package/src/cli/commands/run-create.ts +0 -115
- package/src/cli/commands/run-login.ts +0 -111
- package/src/cli/commands/run-version.ts +0 -32
- package/src/cli/config.ts +0 -72
- package/src/cli/key.ts +0 -43
- package/src/cli/upload.ts +0 -214
- package/src/cli/utils.ts +0 -10
- package/src/cli/webpack.config.js +0 -47
- package/templates/aptos/abis/aptos/souffle.json +0 -389
- package/templates/aptos/jest.config.js +0 -7
- package/templates/aptos/package.json +0 -20
- package/templates/aptos/sentio.yaml +0 -1
- package/templates/aptos/src/processor.ts +0 -13
- package/templates/aptos/tsconfig.json +0 -20
- package/templates/evm/abis/evm/x2y2.json +0 -296
- package/templates/evm/jest.config.js +0 -7
- package/templates/evm/package.json +0 -20
- package/templates/evm/sentio.yaml +0 -3
- package/templates/evm/src/processor.ts +0 -29
- package/templates/evm/tsconfig.json +0 -20
- package/templates/raw/jest.config.js +0 -7
- package/templates/raw/package.json +0 -20
- package/templates/raw/sentio.yaml +0 -3
- package/templates/raw/src/processor.ts +0 -0
- package/templates/raw/tsconfig.json +0 -20
- package/templates/raw/yarn.lock +0 -4095
package/src/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Block, Log } from '@ethersproject/abstract-provider'
|
|
2
2
|
import { CallContext, ServerError, Status } from 'nice-grpc'
|
|
3
|
-
import {
|
|
3
|
+
import { CHAIN_IDS } from './utils/chain'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
AccountConfig,
|
|
@@ -277,7 +277,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
277
277
|
processorType: USER_PROCESSOR,
|
|
278
278
|
contract: {
|
|
279
279
|
name: solanaProcessor.contractName,
|
|
280
|
-
chainId:
|
|
280
|
+
chainId: CHAIN_IDS.SOLANA_MAINNET,
|
|
281
281
|
address: solanaProcessor.address,
|
|
282
282
|
abi: '',
|
|
283
283
|
},
|
|
@@ -303,7 +303,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
303
303
|
processorType: USER_PROCESSOR,
|
|
304
304
|
contract: {
|
|
305
305
|
name: 'sui contract',
|
|
306
|
-
chainId:
|
|
306
|
+
chainId: CHAIN_IDS.SUI_DEVNET,
|
|
307
307
|
address: suiProcessor.address,
|
|
308
308
|
abi: '',
|
|
309
309
|
},
|
|
@@ -1,94 +1,6 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
1
|
import path from 'path'
|
|
3
2
|
import fs from 'fs'
|
|
4
|
-
import
|
|
5
|
-
import { generate } from '../aptos-codegen/codegen'
|
|
6
|
-
// import { EVM, SOLANA, Target } from './config'
|
|
7
|
-
|
|
8
|
-
export async function buildProcessor(onlyGen: boolean) {
|
|
9
|
-
if (!onlyGen) {
|
|
10
|
-
await installDeps()
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// targets.forEach(async (target) => await buildProcessorForTarget(onlyGen, target))
|
|
14
|
-
// for (const target) {
|
|
15
|
-
await buildProcessorForTarget(onlyGen)
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
if (!onlyGen) {
|
|
19
|
-
const WEBPACK_CONFIG = path.join(__dirname, 'webpack.config.js')
|
|
20
|
-
await execStep('yarn tsc -p .', 'Compile')
|
|
21
|
-
await execStep('yarn webpack --config=' + WEBPACK_CONFIG, 'Packaging')
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function buildProcessorForTarget(onlyGen: boolean) {
|
|
26
|
-
await codeGenEthersProcessor(path.join('abis', 'evm'))
|
|
27
|
-
codeGenSolanaProcessor(path.join('abis', 'solana'))
|
|
28
|
-
codeGenAptosProcessor(path.join('abis', 'aptos'))
|
|
29
|
-
|
|
30
|
-
if (onlyGen) {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function installDeps() {
|
|
36
|
-
await execStep('yarn install --ignore-scripts', 'Yarn Install')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function codeGenAptosProcessor(abisDir: string, outDir = 'src/types/aptos') {
|
|
40
|
-
if (!fs.existsSync(abisDir)) {
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// const files = fs.readdirSync(abisDir)
|
|
45
|
-
|
|
46
|
-
console.log(chalk.green('Generated Types for Aptos'))
|
|
47
|
-
|
|
48
|
-
generate(abisDir, outDir)
|
|
49
|
-
// for (const file of files) {
|
|
50
|
-
// if (path.extname(file) === '.json') {
|
|
51
|
-
// if (!fs.existsSync(outDir)) {
|
|
52
|
-
// fs.mkdirSync(outDir, { recursive: true })
|
|
53
|
-
// }
|
|
54
|
-
// }
|
|
55
|
-
// const codegen = new AptosAccountCodegen({
|
|
56
|
-
// srcFile: path.join(abisDir, file),
|
|
57
|
-
// outputDir: outDir,
|
|
58
|
-
// })
|
|
59
|
-
// codegen.generate()
|
|
60
|
-
// }
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export async function codeGenEthersProcessor(
|
|
64
|
-
abisDir: string,
|
|
65
|
-
ETHERS_TARGET = path.join(__dirname, '../target-ethers-sentio'),
|
|
66
|
-
outDir = 'src/types/internal'
|
|
67
|
-
) {
|
|
68
|
-
if (!fs.existsSync(abisDir)) {
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let haveJson = false
|
|
73
|
-
const files = fs.readdirSync(abisDir)
|
|
74
|
-
for (const file of files) {
|
|
75
|
-
if (file.toLowerCase().endsWith('.json')) {
|
|
76
|
-
haveJson = true
|
|
77
|
-
break
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (!haveJson) {
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log(chalk.green('Generated Types for EVM'))
|
|
85
|
-
|
|
86
|
-
// TODO this will fail during postinstall, need to locate real typechain path
|
|
87
|
-
await execStep(
|
|
88
|
-
'yarn typechain --target ' + ETHERS_TARGET + ` --out-dir ${outDir} ${path.join(abisDir, '*.json')}`,
|
|
89
|
-
'Type definitions gen'
|
|
90
|
-
)
|
|
91
|
-
}
|
|
3
|
+
import chalk from 'chalk'
|
|
92
4
|
|
|
93
5
|
export function codeGenSolanaProcessor(abisDir: string, targetPath = path.join('src', 'types', 'solana')) {
|
|
94
6
|
if (!fs.existsSync(abisDir)) {
|
|
@@ -202,27 +114,3 @@ function toPascalCase(str: string) {
|
|
|
202
114
|
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3}`)
|
|
203
115
|
.replace(new RegExp(/\w/), (s) => s.toUpperCase())
|
|
204
116
|
}
|
|
205
|
-
|
|
206
|
-
async function execStep(cmd: string, stepName: string) {
|
|
207
|
-
const child = exec(cmd)
|
|
208
|
-
console.log(chalk.blue(stepName + ' begin'))
|
|
209
|
-
|
|
210
|
-
if (!child.stdout || !child.stderr) {
|
|
211
|
-
console.error(chalk.red(stepName + ' failed'))
|
|
212
|
-
process.exit(1)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
child.stdout.pipe(process.stdout)
|
|
216
|
-
child.stderr.pipe(process.stderr)
|
|
217
|
-
|
|
218
|
-
await new Promise((resolve) => {
|
|
219
|
-
child.on('close', resolve)
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
if (child.exitCode) {
|
|
223
|
-
console.error(chalk.red(stepName + ' failed'))
|
|
224
|
-
process.exit(child.exitCode)
|
|
225
|
-
}
|
|
226
|
-
console.log(chalk.blue(stepName + ' success'))
|
|
227
|
-
console.log()
|
|
228
|
-
}
|
package/src/test-abi-code-gen.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { codeGenAptosProcessor, codeGenSolanaProcessor } from './cli/build'
|
|
4
3
|
import path from 'path'
|
|
4
|
+
import { codeGenSolanaProcessor } from './solana-codegen/codegen'
|
|
5
|
+
import { codeGenAptosProcessor } from './aptos-codegen/codegen'
|
|
5
6
|
|
|
6
7
|
if (process.argv.length > 3) {
|
|
7
8
|
const abisDir = process.argv[2]
|
package/src/utils/chain.ts
CHANGED
|
@@ -1,100 +1,103 @@
|
|
|
1
1
|
// copy from https://github.com/DefiLlama/chainlist/blob/main/constants/chainIds.js
|
|
2
2
|
// and https://besu.hyperledger.org/en/stable/Concepts/NetworkID-And-ChainID/
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
4
|
+
export const CHAIN_IDS = {
|
|
5
|
+
KARDIA: '0',
|
|
6
|
+
ETHEREUM: '1',
|
|
7
|
+
EXPANSE: '2',
|
|
8
|
+
ROPSTEN: '3',
|
|
9
|
+
RINKEBY: '4',
|
|
10
|
+
GOERLI: '5',
|
|
11
|
+
KOTTI: '6',
|
|
12
|
+
UBIQ: '8',
|
|
13
|
+
OPTIMISM: '10',
|
|
14
|
+
SONGBIRD: '19',
|
|
15
|
+
ELASTOS: '20',
|
|
16
|
+
CRONOS: '25',
|
|
17
|
+
RSK: '30',
|
|
18
|
+
TELOS: '40',
|
|
19
|
+
XDC: '50',
|
|
20
|
+
CSC: '52',
|
|
21
|
+
ZYX: '55',
|
|
22
|
+
BINANCE: '56',
|
|
23
|
+
SYSCOIN: '57',
|
|
24
|
+
GOCHAIN: '60',
|
|
25
|
+
ETHCLASSIC: '61',
|
|
26
|
+
MORDOR: '63',
|
|
27
|
+
OKEXCHAIN: '66',
|
|
28
|
+
HOO: '70',
|
|
29
|
+
METER: '82',
|
|
30
|
+
TOMOCHAIN: '88',
|
|
31
|
+
XDAI: '100',
|
|
32
|
+
VELAS: '106',
|
|
33
|
+
THUNDERCORE: '108',
|
|
34
|
+
FUSE: '122',
|
|
35
|
+
HECO: '128',
|
|
36
|
+
POLYGON: '137',
|
|
37
|
+
XDAIARB: '200',
|
|
38
|
+
ASTOR: '212',
|
|
39
|
+
ENERGYWEB: '246',
|
|
40
|
+
FANTOM: '250',
|
|
41
|
+
HPB: '269',
|
|
42
|
+
BOBA: '288',
|
|
43
|
+
KUCOIN: '321',
|
|
44
|
+
SHIDEN: '336',
|
|
45
|
+
THETA: '361',
|
|
46
|
+
SX: '416',
|
|
47
|
+
CANDLE: '534',
|
|
48
|
+
ASTAR: '592',
|
|
49
|
+
CALLISTO: '820',
|
|
50
|
+
WANCHAIN: '888',
|
|
51
|
+
METIS: '1088',
|
|
52
|
+
OMCHAIN: '1246',
|
|
53
|
+
MOONBEAM: '1284',
|
|
54
|
+
MOONRIVER: '1285',
|
|
55
|
+
DEV: '2018',
|
|
56
|
+
RONIN: '2020',
|
|
57
|
+
KAVA: '2222',
|
|
58
|
+
EZCHAIN: '2612',
|
|
59
|
+
PHI: '4181',
|
|
60
|
+
IOTEX: '4689',
|
|
61
|
+
XLC: '5050',
|
|
62
|
+
NAHMII: '5551',
|
|
63
|
+
NMACTEST: '7777',
|
|
64
|
+
KLAYTN: '8217',
|
|
65
|
+
EVMOS: '9001',
|
|
66
|
+
SMARTBCH: '10000',
|
|
67
|
+
CRYSTALEUM: '103090',
|
|
68
|
+
FUSION: '32659',
|
|
69
|
+
ARBITRUM: '42161',
|
|
70
|
+
CELO: '42220',
|
|
71
|
+
OASIS: '42262',
|
|
72
|
+
AVALANCHE: '43114',
|
|
73
|
+
GODWOKEN: '71402',
|
|
74
|
+
AKROMA: '200625',
|
|
75
|
+
POLIS: '333999',
|
|
76
|
+
ARBITRUM_TEST: '421613',
|
|
77
|
+
SEPOLIA: '11155111',
|
|
78
|
+
AURORA: '1313161554',
|
|
79
|
+
HARMONY: '1666600000',
|
|
80
|
+
PALM: '11297108109',
|
|
81
|
+
CURIO: '836542336838601',
|
|
82
|
+
SOLANA_MAINNET: 'sol_mainnet',
|
|
83
|
+
SOLANA_DEVNET: 'sol_devnet',
|
|
84
|
+
SOLANA_TESTNET: 'sol_testnet',
|
|
85
|
+
SOLANA_PYTH: 'sol_pyth',
|
|
86
|
+
SUI_DEVNET: 'sui_devnet',
|
|
87
|
+
APTOS_MAINNET: 'aptos_mainnet',
|
|
88
|
+
APTOS_TESTNET: 'aptos_testnet',
|
|
82
89
|
}
|
|
83
90
|
|
|
84
|
-
export const
|
|
85
|
-
export const SOL_DEVNET_ID = 'sol_devnet'
|
|
86
|
-
export const SOL_TESTNENT_ID = 'sol_testnet'
|
|
87
|
-
CHAIN_MAP[SOL_MAINMET_ID] = 'solana'
|
|
88
|
-
CHAIN_MAP[SOL_DEVNET_ID] = 'solana-dev'
|
|
89
|
-
CHAIN_MAP[SOL_TESTNENT_ID] = 'solana-test'
|
|
91
|
+
export const CHAIN_MAP: Record<string, string> = {}
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
for (const [key, value] of Object.entries(CHAIN_IDS)) {
|
|
94
|
+
const parts = key.split('_')
|
|
95
|
+
CHAIN_MAP[value] = parts
|
|
96
|
+
.map((part, index) => {
|
|
97
|
+
return part[0] + part.slice(1).toLowerCase()
|
|
98
|
+
})
|
|
99
|
+
.join(' ')
|
|
100
|
+
}
|
|
98
101
|
|
|
99
102
|
export function getChainName(chainId: string | number | null | undefined): string {
|
|
100
103
|
if (typeof chainId === 'number') {
|
package/lib/cli/build.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function buildProcessor(onlyGen: boolean): Promise<void>;
|
|
2
|
-
export declare function codeGenAptosProcessor(abisDir: string, outDir?: string): void;
|
|
3
|
-
export declare function codeGenEthersProcessor(abisDir: string, ETHERS_TARGET?: string, outDir?: string): Promise<void>;
|
|
4
|
-
export declare function codeGenSolanaProcessor(abisDir: string, targetPath?: string): void;
|
package/lib/cli/build.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/cli/build.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CAAC,MAAM,CAAC,CAAA;IACjC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAEjC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC5B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;KAC7B;IACD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAA;AACf,CAAC","sourcesContent":["import chalk from 'chalk'\nimport path from 'path'\nimport fs from 'fs'\nimport { exec } from 'child_process'\nimport { generate } from '../aptos-codegen/codegen'\n// import { EVM, SOLANA, Target } from './config'\n\nexport async function buildProcessor(onlyGen: boolean) {\n if (!onlyGen) {\n await installDeps()\n }\n\n // targets.forEach(async (target) => await buildProcessorForTarget(onlyGen, target))\n // for (const target) {\n await buildProcessorForTarget(onlyGen)\n // }\n\n if (!onlyGen) {\n const WEBPACK_CONFIG = path.join(__dirname, 'webpack.config.js')\n await execStep('yarn tsc -p .', 'Compile')\n await execStep('yarn webpack --config=' + WEBPACK_CONFIG, 'Packaging')\n }\n}\n\nasync function buildProcessorForTarget(onlyGen: boolean) {\n await codeGenEthersProcessor(path.join('abis', 'evm'))\n codeGenSolanaProcessor(path.join('abis', 'solana'))\n codeGenAptosProcessor(path.join('abis', 'aptos'))\n\n if (onlyGen) {\n return\n }\n}\n\nasync function installDeps() {\n await execStep('yarn install --ignore-scripts', 'Yarn Install')\n}\n\nexport function codeGenAptosProcessor(abisDir: string, outDir = 'src/types/aptos') {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n // const files = fs.readdirSync(abisDir)\n\n console.log(chalk.green('Generated Types for Aptos'))\n\n generate(abisDir, outDir)\n // for (const file of files) {\n // if (path.extname(file) === '.json') {\n // if (!fs.existsSync(outDir)) {\n // fs.mkdirSync(outDir, { recursive: true })\n // }\n // }\n // const codegen = new AptosAccountCodegen({\n // srcFile: path.join(abisDir, file),\n // outputDir: outDir,\n // })\n // codegen.generate()\n // }\n}\n\nexport async function codeGenEthersProcessor(\n abisDir: string,\n ETHERS_TARGET = path.join(__dirname, '../target-ethers-sentio'),\n outDir = 'src/types/internal'\n) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n let haveJson = false\n const files = fs.readdirSync(abisDir)\n for (const file of files) {\n if (file.toLowerCase().endsWith('.json')) {\n haveJson = true\n break\n }\n }\n if (!haveJson) {\n return\n }\n\n console.log(chalk.green('Generated Types for EVM'))\n\n // TODO this will fail during postinstall, need to locate real typechain path\n await execStep(\n 'yarn typechain --target ' + ETHERS_TARGET + ` --out-dir ${outDir} ${path.join(abisDir, '*.json')}`,\n 'Type definitions gen'\n )\n}\n\nexport function codeGenSolanaProcessor(abisDir: string, targetPath = path.join('src', 'types', 'solana')) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n const abisFiles = fs.readdirSync(abisDir)\n\n if (abisFiles.length > 0) {\n console.log(chalk.green('Generated Types for Solana'))\n }\n\n for (const file of abisFiles) {\n if (path.extname(file) === '.json') {\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true })\n }\n const idlContent = fs.readFileSync(path.join(abisDir, file), 'utf-8')\n const idlObj = JSON.parse(idlContent)\n const idlName = idlObj.name\n const idlFile = path.join(targetPath, idlName + '.ts')\n fs.writeFileSync(idlFile, `export const ${idlName}_idl = ${idlContent}`)\n fs.writeFileSync(path.join(targetPath, `${idlName}_processor.ts`), codeGenSolanaIdlProcessor(idlObj))\n }\n }\n}\n\nfunction codeGenSolanaIdlProcessor(idlObj: any): string {\n const idlName = idlObj.name\n const idlNamePascalCase = toPascalCase(idlName)\n const instructions: any[] = idlObj.instructions\n return `import { BorshInstructionCoder, Instruction, Idl, BN } from '@project-serum/anchor'\nimport { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from \"@sentio/sdk\"\nimport { ${idlName}_idl } from \"./${idlName}\"\nimport bs58 from 'bs58'\nimport { PublicKey } from '@solana/web3.js'\n\nexport class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {\n static bind(options: SolanaBindOptions): ${idlNamePascalCase}Processor {\n if (options && !options.name) {\n options.name = '${idlNamePascalCase}'\n }\n return new ${idlNamePascalCase}Processor(options)\n }\n\n decodeInstruction: (rawInstruction: string) => Instruction | null = (rawInstruction) => {\n const instructionCoder = new BorshInstructionCoder(${idlName}_idl as Idl)\n const decodedIns = instructionCoder.decode(Buffer.from(bs58.decode(rawInstruction)))\n return decodedIns\n }\n\n ${instructions.map((ins) => codeGenSolanaInstruction(idlNamePascalCase, ins)).join('')}\n}\n `\n}\n\nfunction codeGenSolanaInstruction(idlName: string, ins: any): string {\n const instructionName = ins.name\n const argsTypeString = codeGenInstructionArgs(ins.args)\n return `\n on${\n instructionName.charAt(0).toUpperCase() + instructionName.slice(1)\n }(handler: (args: ${argsTypeString}, accounts: string[], ctx: SolanaContext) => void): ${idlName}Processor {\n this.onInstruction('${instructionName}', (ins: Instruction, ctx, accounts: string[]) => {\n if (ins) {\n handler(ins.data as ${argsTypeString}, accounts, ctx)\n }\n })\n return this\n }\n `\n}\n\nfunction codeGenInstructionArgs(args: { name: string; type: string }[]): string {\n return `{ ${args.map((arg) => arg.name + ': ' + mapType(arg.type)).join(', ')} }`\n}\n\n// Reference: https://github.com/coral-xyz/anchor/blob/93332766f13e86efbe77c9986722731742317ede/ts/src/program/namespace/types.ts#L104\nfunction mapType(tpe: string): string {\n switch (tpe) {\n case 'publicKey':\n return 'PublicKey'\n case 'bool':\n return 'boolean'\n case 'string':\n return 'string'\n case 'u8':\n case 'i8':\n case 'u16':\n case 'i16':\n case 'u32':\n case 'i32':\n case 'f32':\n case 'f64':\n return 'number'\n case 'u64':\n case 'i64':\n case 'u128':\n case 'i128':\n return 'BN'\n default:\n return 'any'\n }\n}\n\nfunction toPascalCase(str: string) {\n return `${str}`\n .toLowerCase()\n .replace(new RegExp(/[-_]+/, 'g'), ' ')\n .replace(new RegExp(/[^\\w\\s]/, 'g'), '')\n .replace(new RegExp(/\\s+(.)(\\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3}`)\n .replace(new RegExp(/\\w/), (s) => s.toUpperCase())\n}\n\nasync function execStep(cmd: string, stepName: string) {\n const child = exec(cmd)\n console.log(chalk.blue(stepName + ' begin'))\n\n if (!child.stdout || !child.stderr) {\n console.error(chalk.red(stepName + ' failed'))\n process.exit(1)\n }\n\n child.stdout.pipe(process.stdout)\n child.stderr.pipe(process.stderr)\n\n await new Promise((resolve) => {\n child.on('close', resolve)\n })\n\n if (child.exitCode) {\n console.error(chalk.red(stepName + ' failed'))\n process.exit(child.exitCode)\n }\n console.log(chalk.blue(stepName + ' success'))\n console.log()\n}\n"]}
|
package/lib/cli/cli.d.ts
DELETED
package/lib/cli/cli.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const command_line_args_1 = __importDefault(require("command-line-args"));
|
|
8
|
-
const command_line_usage_1 = __importDefault(require("command-line-usage"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
12
|
-
const config_1 = require("./config");
|
|
13
|
-
const upload_1 = require("./upload");
|
|
14
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
15
|
-
const build_1 = require("./build");
|
|
16
|
-
const run_create_1 = require("./commands/run-create");
|
|
17
|
-
const run_version_1 = require("./commands/run-version");
|
|
18
|
-
const run_login_1 = require("./commands/run-login");
|
|
19
|
-
const mainDefinitions = [{ name: 'command', defaultOption: true }];
|
|
20
|
-
const mainOptions = (0, command_line_args_1.default)(mainDefinitions, {
|
|
21
|
-
stopAtFirstUnknown: true,
|
|
22
|
-
});
|
|
23
|
-
const argv = mainOptions._unknown || [];
|
|
24
|
-
if (!mainOptions.command) {
|
|
25
|
-
usage();
|
|
26
|
-
}
|
|
27
|
-
if (mainOptions.command === 'login') {
|
|
28
|
-
(0, run_login_1.runLogin)(argv);
|
|
29
|
-
}
|
|
30
|
-
else if (mainOptions.command === 'create') {
|
|
31
|
-
(0, run_create_1.runCreate)(argv);
|
|
32
|
-
}
|
|
33
|
-
else if (mainOptions.command === 'version') {
|
|
34
|
-
(0, run_version_1.runVersion)(argv);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
// For all the commands that need read project configs
|
|
38
|
-
// TODO move them to their own modules
|
|
39
|
-
// Process configs
|
|
40
|
-
let processorConfig = { host: '', project: '', build: true, debug: false };
|
|
41
|
-
// Fist step, read from project yaml file
|
|
42
|
-
try {
|
|
43
|
-
console.log(chalk_1.default.blue('Loading Process config'));
|
|
44
|
-
// TODO correctly located sentio.yaml
|
|
45
|
-
const pwd = process.cwd();
|
|
46
|
-
const packageJson = path_1.default.join(pwd, 'package.json');
|
|
47
|
-
if (!fs_1.default.existsSync(packageJson)) {
|
|
48
|
-
console.error('package.json not found, please run this command in the root of your project');
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
const yamlPath = path_1.default.join(pwd, 'sentio.yaml');
|
|
52
|
-
if (!fs_1.default.existsSync(yamlPath)) {
|
|
53
|
-
console.error('sentio.yaml not found, please create one according to: TODO docs');
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
processorConfig = js_yaml_1.default.load(fs_1.default.readFileSync('sentio.yaml', 'utf8'));
|
|
57
|
-
if (!processorConfig.project === undefined) {
|
|
58
|
-
console.error('Config yaml must have contain a valid project identifier');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
if (processorConfig.build === undefined) {
|
|
62
|
-
processorConfig.build = true;
|
|
63
|
-
}
|
|
64
|
-
if (!processorConfig.host) {
|
|
65
|
-
processorConfig.host = 'prod';
|
|
66
|
-
}
|
|
67
|
-
if (processorConfig.debug === undefined) {
|
|
68
|
-
processorConfig.debug = false;
|
|
69
|
-
}
|
|
70
|
-
// if (!processorConfig.source) {
|
|
71
|
-
// processorConfig.source = 'src/processor.ts'
|
|
72
|
-
// }
|
|
73
|
-
// if (!processorConfig.targets) {
|
|
74
|
-
// console.warn('targets is not defined, use EVM as the default target')
|
|
75
|
-
// processorConfig.targets = []
|
|
76
|
-
// }
|
|
77
|
-
// if (processorConfig.targets.length === 0) {
|
|
78
|
-
// // By default evm
|
|
79
|
-
// processorConfig.targets.push({ chain: EVM })
|
|
80
|
-
// }
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
console.error(e);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
if (mainOptions.command === 'upload') {
|
|
87
|
-
const optionDefinitions = [
|
|
88
|
-
{
|
|
89
|
-
name: 'help',
|
|
90
|
-
alias: 'h',
|
|
91
|
-
type: Boolean,
|
|
92
|
-
description: 'Display this usage guide.',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'api-key',
|
|
96
|
-
type: String,
|
|
97
|
-
description: '(Optional) Manually provide API key rather than use saved credential',
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
name: 'host',
|
|
101
|
-
description: '(Optional) Override Sentio Host name',
|
|
102
|
-
type: String,
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: 'owner',
|
|
106
|
-
description: '(Optional) Override Project owner',
|
|
107
|
-
type: String,
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'nobuild',
|
|
111
|
-
description: '(Optional) Skip build & pack file before uploading, default false',
|
|
112
|
-
type: Boolean,
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: 'debug',
|
|
116
|
-
description: '(Optional) Set driver logging level to debug',
|
|
117
|
-
type: Boolean,
|
|
118
|
-
},
|
|
119
|
-
];
|
|
120
|
-
const options = (0, command_line_args_1.default)(optionDefinitions, { argv });
|
|
121
|
-
if (options.help) {
|
|
122
|
-
const usage = (0, command_line_usage_1.default)([
|
|
123
|
-
{
|
|
124
|
-
header: 'Sentio upload',
|
|
125
|
-
content: 'sentio upload',
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
header: 'Options',
|
|
129
|
-
optionList: optionDefinitions,
|
|
130
|
-
},
|
|
131
|
-
]);
|
|
132
|
-
console.log(usage);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
if (options.host) {
|
|
136
|
-
processorConfig.host = options.host;
|
|
137
|
-
}
|
|
138
|
-
if (options.nobuild) {
|
|
139
|
-
processorConfig.build = false;
|
|
140
|
-
}
|
|
141
|
-
if (options.debug) {
|
|
142
|
-
processorConfig.debug = true;
|
|
143
|
-
}
|
|
144
|
-
(0, config_1.finalizeHost)(processorConfig);
|
|
145
|
-
(0, config_1.FinalizeProjectName)(processorConfig, options.owner);
|
|
146
|
-
console.log(processorConfig);
|
|
147
|
-
let apiOverride = undefined;
|
|
148
|
-
if (options['api-key']) {
|
|
149
|
-
apiOverride = options['api-key'];
|
|
150
|
-
}
|
|
151
|
-
(0, upload_1.uploadFile)(processorConfig, apiOverride);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else if (mainOptions.command === 'build') {
|
|
155
|
-
(0, build_1.buildProcessor)(false);
|
|
156
|
-
}
|
|
157
|
-
else if (mainOptions.command === 'gen') {
|
|
158
|
-
(0, build_1.buildProcessor)(true);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
usage();
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function usage() {
|
|
165
|
-
const usage = (0, command_line_usage_1.default)([
|
|
166
|
-
{
|
|
167
|
-
header: 'Sentio',
|
|
168
|
-
content: 'Login & Manage your project files to Sentio.',
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
header: 'Usage',
|
|
172
|
-
content: [
|
|
173
|
-
'sentio <command> --help\t\tshow detail usage of specific command',
|
|
174
|
-
'sentio login\t\t\t\tlogin to sentio',
|
|
175
|
-
'sentio create\t\t\t\tcreate a template project',
|
|
176
|
-
'sentio upload\t\t\t\tbuild and upload processor to sentio',
|
|
177
|
-
'sentio gen\t\t\t\tgenerate abi',
|
|
178
|
-
'sentio build\t\t\t\tgenerate abi and build',
|
|
179
|
-
'sentio version\t\t\tcurrent cli version',
|
|
180
|
-
],
|
|
181
|
-
},
|
|
182
|
-
]);
|
|
183
|
-
console.log(usage);
|
|
184
|
-
process.exit(1);
|
|
185
|
-
}
|
|
186
|
-
//# sourceMappingURL=cli.js.map
|
package/lib/cli/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;;;;;AAEA,0EAA+C;AAC/C,4EAAiD;AACjD,4CAAmB;AACnB,gDAAuB;AAEvB,sDAA0B;AAC1B,qCAAiF;AACjF,qCAAqC;AACrC,kDAAyB;AACzB,mCAAwC;AACxC,sDAAiD;AACjD,wDAAmD;AACnD,oDAA+C;AAE/C,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAClE,MAAM,WAAW,GAAG,IAAA,2BAAe,EAAC,eAAe,EAAE;IACnD,kBAAkB,EAAE,IAAI;CACzB,CAAC,CAAA;AACF,MAAM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AAE,WAAW,CAAC,CAAA;SACzC;KACF;SAAM,IAAI,WAAW,CAAC,OAAO,KAAK,OAAO,EAAE;QAC1C,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAA;KACtB;SAAM,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,EAAE;QACxC,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAA;KACrB;SAAM;QACL,KAAK,EAAE,CAAA;KACR;CACF;AAED,SAAS,KAAK;IACZ,MAAM,KAAK,GAAG,IAAA,4BAAgB,EAAC;QAC7B;YACE,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,8CAA8C;SACxD;QACD;YACE,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP,kEAAkE;gBAClE,qCAAqC;gBACrC,gDAAgD;gBAChD,2DAA2D;gBAC3D,gCAAgC;gBAChC,4CAA4C;gBAC5C,yCAAyC;aAC1C;SACF;KACF,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport commandLineArgs from 'command-line-args'\nimport commandLineUsage from 'command-line-usage'\nimport fs from 'fs'\nimport path from 'path'\n\nimport yaml from 'js-yaml'\nimport { finalizeHost, FinalizeProjectName, SentioProjectConfig } from './config'\nimport { uploadFile } from './upload'\nimport chalk from 'chalk'\nimport { buildProcessor } from './build'\nimport { runCreate } from './commands/run-create'\nimport { runVersion } from './commands/run-version'\nimport { runLogin } from './commands/run-login'\n\nconst mainDefinitions = [{ name: 'command', defaultOption: true }]\nconst mainOptions = commandLineArgs(mainDefinitions, {\n stopAtFirstUnknown: true,\n})\nconst argv = mainOptions._unknown || []\n\nif (!mainOptions.command) {\n usage()\n}\n\nif (mainOptions.command === 'login') {\n runLogin(argv)\n} else if (mainOptions.command === 'create') {\n runCreate(argv)\n} else if (mainOptions.command === 'version') {\n runVersion(argv)\n} else {\n // For all the commands that need read project configs\n // TODO move them to their own modules\n\n // Process configs\n let processorConfig: SentioProjectConfig = { host: '', project: '', build: true, debug: false }\n // Fist step, read from project yaml file\n try {\n console.log(chalk.blue('Loading Process config'))\n // TODO correctly located sentio.yaml\n const pwd = process.cwd()\n const packageJson = path.join(pwd, 'package.json')\n if (!fs.existsSync(packageJson)) {\n console.error('package.json not found, please run this command in the root of your project')\n process.exit(1)\n }\n\n const yamlPath = path.join(pwd, 'sentio.yaml')\n if (!fs.existsSync(yamlPath)) {\n console.error('sentio.yaml not found, please create one according to: TODO docs')\n process.exit(1)\n }\n\n processorConfig = yaml.load(fs.readFileSync('sentio.yaml', 'utf8')) as SentioProjectConfig\n if (!processorConfig.project === undefined) {\n console.error('Config yaml must have contain a valid project identifier')\n process.exit(1)\n }\n if (processorConfig.build === undefined) {\n processorConfig.build = true\n }\n if (!processorConfig.host) {\n processorConfig.host = 'prod'\n }\n if (processorConfig.debug === undefined) {\n processorConfig.debug = false\n }\n\n // if (!processorConfig.source) {\n // processorConfig.source = 'src/processor.ts'\n // }\n // if (!processorConfig.targets) {\n // console.warn('targets is not defined, use EVM as the default target')\n // processorConfig.targets = []\n // }\n // if (processorConfig.targets.length === 0) {\n // // By default evm\n // processorConfig.targets.push({ chain: EVM })\n // }\n } catch (e) {\n console.error(e)\n process.exit(1)\n }\n\n if (mainOptions.command === 'upload') {\n const optionDefinitions = [\n {\n name: 'help',\n alias: 'h',\n type: Boolean,\n description: 'Display this usage guide.',\n },\n {\n name: 'api-key',\n type: String,\n description: '(Optional) Manually provide API key rather than use saved credential',\n },\n {\n name: 'host',\n description: '(Optional) Override Sentio Host name',\n type: String,\n },\n {\n name: 'owner',\n description: '(Optional) Override Project owner',\n type: String,\n },\n {\n name: 'nobuild',\n description: '(Optional) Skip build & pack file before uploading, default false',\n type: Boolean,\n },\n {\n name: 'debug',\n description: '(Optional) Set driver logging level to debug',\n type: Boolean,\n },\n ]\n const options = commandLineArgs(optionDefinitions, { argv })\n if (options.help) {\n const usage = commandLineUsage([\n {\n header: 'Sentio upload',\n content: 'sentio upload',\n },\n {\n header: 'Options',\n optionList: optionDefinitions,\n },\n ])\n console.log(usage)\n } else {\n if (options.host) {\n processorConfig.host = options.host\n }\n if (options.nobuild) {\n processorConfig.build = false\n }\n if (options.debug) {\n processorConfig.debug = true\n }\n finalizeHost(processorConfig)\n FinalizeProjectName(processorConfig, options.owner)\n console.log(processorConfig)\n\n let apiOverride = undefined\n if (options['api-key']) {\n apiOverride = options['api-key']\n }\n uploadFile(processorConfig, apiOverride)\n }\n } else if (mainOptions.command === 'build') {\n buildProcessor(false)\n } else if (mainOptions.command === 'gen') {\n buildProcessor(true)\n } else {\n usage()\n }\n}\n\nfunction usage() {\n const usage = commandLineUsage([\n {\n header: 'Sentio',\n content: 'Login & Manage your project files to Sentio.',\n },\n {\n header: 'Usage',\n content: [\n 'sentio <command> --help\\t\\tshow detail usage of specific command',\n 'sentio login\\t\\t\\t\\tlogin to sentio',\n 'sentio create\\t\\t\\t\\tcreate a template project',\n 'sentio upload\\t\\t\\t\\tbuild and upload processor to sentio',\n 'sentio gen\\t\\t\\t\\tgenerate abi',\n 'sentio build\\t\\t\\t\\tgenerate abi and build',\n 'sentio version\\t\\t\\tcurrent cli version',\n ],\n },\n ])\n console.log(usage)\n process.exit(1)\n}\n"]}
|