@sentio/cli 1.0.1 → 1.0.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/build.js CHANGED
@@ -38,9 +38,7 @@ async function buildProcessorForTarget(onlyGen) {
38
38
  async function installDeps() {
39
39
  await execStep('yarn install --ignore-scripts', 'Yarn Install');
40
40
  }
41
- async function codeGenEthersProcessor(abisDir,
42
- // eslint-disable-next-line @typescript-eslint/no-var-requires
43
- ETHERS_TARGET = path_1.default.dirname(require.resolve('@sentio/sdk/lib/target-ethers-sentio')), outDir = 'src/types/internal') {
41
+ async function codeGenEthersProcessor(abisDir, ETHERS_TARGET = path_1.default.dirname(require.resolve('@sentio/sdk/lib/target-ethers-sentio')), outDir = 'src/types/internal') {
44
42
  if (!fs_1.default.existsSync(abisDir)) {
45
43
  return;
46
44
  }
package/lib/build.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,gDAAuB;AACvB,4CAAmB;AACnB,iDAAoC;AAE7B,KAAK,UAAU,cAAc,CAAC,OAAgB;IACnD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,WAAW,EAAE,CAAA;KACpB;IAED,oFAAoF;IACpF,uBAAuB;IACvB,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAA;IACtC,IAAI;IAEJ,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,cAAc,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;QAChE,MAAM,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;QAC1C,MAAM,QAAQ,CAAC,wBAAwB,GAAG,cAAc,EAAE,WAAW,CAAC,CAAA;KACvE;AACH,CAAC;AAfD,wCAeC;AAED,KAAK,UAAU,uBAAuB,CAAC,OAAgB;IACrD,MAAM,sBAAsB,CAAC,cAAI,CAAC,I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} from 'child_process'\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\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const solanaModule = require('@sentio/sdk/lib/solana-codegen/codegen')\n solanaModule.codeGenSolanaProcessor(path.join('abis', 'solana'))\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const aptosModuole = require('@sentio/sdk/lib/aptos-codegen/codegen')\n aptosModuole.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 async function codeGenEthersProcessor(\n abisDir: string,\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n ETHERS_TARGET = path.dirname(require.resolve('@sentio/sdk/lib/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\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"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,gDAAuB;AACvB,4CAAmB;AACnB,iDAAoC;AAE7B,KAAK,UAAU,cAAc,CAAC,OAAgB;IACnD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,WAAW,EAAE,CAAA;KACpB;IAED,oFAAoF;IACpF,uBAAuB;IACvB,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAA;IACtC,IAAI;IAEJ,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,cAAc,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;QAChE,MAAM,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;QAC1C,MAAM,QAAQ,CAAC,wBAAwB,GAAG,cAAc,EAAE,WAAW,CAAC,CAAA;KACvE;AACH,CAAC;AAfD,wCAeC;AAED,KAAK,UAAU,uBAAuB,CAAC,OAAgB;IACrD,MAAM,sBAAsB,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;IAEtD,8DAA8D;IAC9D,MAAM,YAAY,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAA;IACtE,YAAY,CAAC,sBAAsB,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IAEhE,8DAA8D;IAC9D,MAAM,YAAY,GAAG,OAAO,CAAC,uCAAuC,CAAC,CAAA;IACrE,YAAY,CAAC,qBAAqB,CAAC,cAAI,CAAC,IA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,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QAClC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IAED,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,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'\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\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const solanaModule = require('@sentio/sdk/lib/solana-codegen/codegen')\n solanaModule.codeGenSolanaProcessor(path.join('abis', 'solana'))\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const aptosModuole = require('@sentio/sdk/lib/aptos-codegen/codegen')\n aptosModuole.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 async function codeGenEthersProcessor(\n abisDir: string,\n ETHERS_TARGET = path.dirname(require.resolve('@sentio/sdk/lib/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\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/upload.js CHANGED
@@ -68,7 +68,7 @@ async function uploadFile(options, apiKeyOverride) {
68
68
  }
69
69
  console.log(chalk_1.default.blue(triedCount > 1 ? 'Retry uploading' : 'Uploading'));
70
70
  // get gcs upload url
71
- const initUploadResRaw = await initUpload(options.host, apiKey, options.project, (0, utils_1.getCliVersion)());
71
+ const initUploadResRaw = await initUpload(options.host, apiKey, options.project, (0, utils_1.getSdkVersion)());
72
72
  if (!initUploadResRaw.ok) {
73
73
  console.error(chalk_1.default.red('Failed to get upload url'));
74
74
  console.error(chalk_1.default.red((await initUploadResRaw.json()).message));
@@ -119,7 +119,7 @@ async function uploadFile(options, apiKeyOverride) {
119
119
  return;
120
120
  }
121
121
  // finish uploading
122
- const finishUploadResRaw = await finishUpload(options.host, apiKey, options.project, (0, utils_1.getCliVersion)(), sha256, commitSha, gitUrl, options.debug);
122
+ const finishUploadResRaw = await finishUpload(options.host, apiKey, options.project, (0, utils_1.getSdkVersion)(), sha256, commitSha, gitUrl, options.debug);
123
123
  if (!finishUploadResRaw.ok) {
124
124
  console.error(chalk_1.default.red('Failed to finish uploading'));
125
125
  console.error(chalk_1.default.red(await finishUploadResRaw.text()));
package/lib/upload.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAwC;AACxC,mCAAmC;AACnC,4CAAmB;AACnB,wDAA+B;AAE/B,+BAA+B;AAC/B,gDAAuB;AACvB,kDAAyB;AACzB,mCAAwC;AACxC,4DAA8B;AAC9B,mCAAuC;AACvC,6BAAyB;AAEzB,KAAK,UAAU,aAAa,CAAC,OAA4B,EAAE,MAAc;IACvE,MAAM,GAAG,GAAG,IAAI,SAAG,CAAC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IACrD,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IACnH,OAAO,IAA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CAAC,CAAC,CAAA;gBACzD,MAAM,YAAY,EAAE,CAAA;aACrB;iBAAM;gBACL,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;SACF;IACH,CAAC,CAAA;IAED,MAAM,YAAY,EAAE,CAAA;AACtB,CAAC;AAnJD,gCAmJC;AAED,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,MAAc,EAAE,WAAmB,EAAE,UAAkB;IAC7F,MAAM,aAAa,GAAG,IAAI,SAAG,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAA;IACrE,OAAO,IAAA,oBAAK,EAAC,aAAa,EAAE;QAC1B,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,SAAS,EAAE,MAAM;SAClB;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,YAAY,EAAE,WAAW;YACzB,WAAW,EAAE,UAAU;SACxB,CAAC;KACH,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,IAAY,EACZ,MAAc,EACd,WAAmB,EACnB,UAAkB,EAClB,MAAc,EACd,SAAiB,EACjB,MAAc,EACd,KAAc;IAEd,MAAM,eAAe,GAAG,IAAI,SAAG,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAA;IACzE,OAAO,IAAA,oBAAK,EAAC,eAAe,EAAE;QAC5B,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,SAAS,EAAE,MAAM;SAClB;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,YAAY,EAAE,WAAW;YACzB,WAAW,EAAE,UAAU;YACvB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,MAAM;YACf,KAAK,EAAE,KAAK;SACb,CAAC;KACH,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { execSync } from 'child_process'\nimport { createHash } from 'crypto'\nimport fs from 'fs'\nimport readline from 'readline'\nimport { SentioProjectConfig } from './config'\nimport { ReadKey } from './key'\nimport path from 'path'\nimport chalk from 'chalk'\nimport { buildProcessor } from './build'\nimport fetch from 'node-fetch'\nimport { getCliVersion } from './utils'\nimport { URL } from 'url'\n\nasync function createProject(options: SentioProjectConfig, apiKey: string) {\n const url = new URL('/api/v1/projects', options.host)\n const [ownerName, slug] = options.project.includes('/') ? options.project.split('/') : [undefined, options.project]\n return fetch(url, {\n method: 'POST',\n headers: {\n 'api-key': apiKey,\n },\n body: JSON.stringify({ slug, ownerName, visibility: 'PRIVATE' }),\n })\n}\n\nexport async function uploadFile(options: SentioProjectConfig, apiKeyOverride: string) {\n if (options.build) {\n await buildProcessor(false)\n }\n\n console.log(chalk.blue('Prepare to upload'))\n\n const PROCESSOR_FILE = path.join(process.cwd(), 'dist/lib.js')\n\n const apiKey = apiKeyOverride || ReadKey(options.host)\n\n const isProd = options.host === 'https://app.sentio.xyz'\n if (!apiKey) {\n const cmd = isProd ? 'sentio login' : 'sentio login --host=' + options.host\n console.error(chalk.red('No Credential found for', options.host, '. Please run `' + cmd + '`.'))\n process.exit(1)\n }\n\n if (!fs.existsSync(PROCESSOR_FILE)) {\n console.error(chalk.red('File not existed ', PROCESSOR_FILE, \"don't use --nobuild\"))\n process.exit(1)\n }\n\n const stat = fs.statSync(PROCESSOR_FILE)\n console.log('Packed processor file size', Math.floor(stat.size / 1024) + 'K, last modified', stat.mtime)\n const content = fs.readFileSync(PROCESSOR_FILE)\n const hash = createHash('sha256')\n hash.update(content)\n const digest = hash.digest('hex')\n\n let triedCount = 0\n const upload = async () => {\n let commitSha = ''\n let gitUrl = ''\n const sha256 = digest\n try {\n commitSha = execSync('git rev-parse HEAD').toString().trim()\n } catch (e) {\n chalk.yellow(e)\n }\n try {\n gitUrl = execSync('git remote get-url origin').toString().trim()\n } catch (e) {\n // skip errors\n }\n console.log(chalk.blue(triedCount > 1 ? 'Retry uploading' : 'Uploading'))\n\n // get gcs upload url\n const initUploadResRaw = await initUpload(options.host, apiKey, options.project, getCliVersion())\n if (!initUploadResRaw.ok) {\n console.error(chalk.red('Failed to get upload url'))\n console.error(chalk.red((await initUploadResRaw.json()).message))\n\n if (initUploadResRaw.status === 404) {\n // create project if not exist\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n const prompt = async () => {\n const answer: string = await new Promise((resolve) =>\n rl.question(`Do you want to create it and continue the uploading process? (yes/no) `, resolve)\n )\n if (['y', 'yes'].includes(answer.toLowerCase())) {\n rl.close()\n const res = await createProject(options, apiKey)\n if (!res.ok) {\n console.error(chalk.red('Create Project Failed'))\n console.error(chalk.red((await res.json()).message))\n return\n }\n console.log(chalk.green('Project created'))\n await upload()\n } else if (['n', 'no'].includes(answer.toLowerCase())) {\n rl.close()\n } else {\n await prompt()\n }\n }\n await prompt()\n }\n return\n }\n const initUploadRes = await initUploadResRaw.json()\n const uploadUrl = initUploadRes['url'] as string\n\n // do actual uploading\n const file = fs.createReadStream(PROCESSOR_FILE)\n const uploadResRaw = await fetch(uploadUrl, {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/octet-stream',\n },\n body: file,\n })\n if (!uploadResRaw.ok) {\n console.error(chalk.red('Failed to upload'))\n console.error(chalk.red(await uploadResRaw.text()))\n return\n }\n\n // finish uploading\n const finishUploadResRaw = await finishUpload(\n options.host,\n apiKey,\n options.project,\n getCliVersion(),\n sha256,\n commitSha,\n gitUrl,\n options.debug\n )\n if (!finishUploadResRaw.ok) {\n console.error(chalk.red('Failed to finish uploading'))\n console.error(chalk.red(await finishUploadResRaw.text()))\n return\n }\n\n console.log(chalk.green('Upload success: '))\n console.log('\\t', chalk.blue('sha256:'), digest)\n if (commitSha) {\n console.log('\\t', chalk.blue('Git commit SHA:'), commitSha)\n }\n const { projectFullSlug } = await finishUploadResRaw.json()\n console.log('\\t', chalk.blue('Check status:'), `${options.host}/${projectFullSlug}/datasource`)\n }\n\n let error: Error\n const tryUploading = async () => {\n if (triedCount++ >= 5) {\n console.error(error)\n return\n }\n try {\n await upload()\n } catch (e) {\n if (e.constructor.name === 'FetchError' && e.type === 'system' && e.code === 'EPIPE') {\n error = e\n await new Promise((resolve) => setTimeout(resolve, 1000))\n await tryUploading()\n } else {\n console.error(e)\n }\n }\n }\n\n await tryUploading()\n}\n\nasync function initUpload(host: string, apiKey: string, projectSlug: string, sdkVersion: string) {\n const initUploadUrl = new URL(`/api/v1/processors/init_upload`, host)\n return fetch(initUploadUrl, {\n method: 'POST',\n headers: {\n 'api-key': apiKey,\n },\n body: JSON.stringify({\n project_slug: projectSlug,\n sdk_version: sdkVersion,\n }),\n })\n}\n\nasync function finishUpload(\n host: string,\n apiKey: string,\n projectSlug: string,\n sdkVersion: string,\n sha256: string,\n commitSha: string,\n gitUrl: string,\n debug: boolean\n) {\n const finishUploadUrl = new URL(`/api/v1/processors/finish_upload`, host)\n return fetch(finishUploadUrl, {\n method: 'POST',\n headers: {\n 'api-key': apiKey,\n },\n body: JSON.stringify({\n project_slug: projectSlug,\n sdk_version: sdkVersion,\n sha256: sha256,\n commit_sha: commitSha,\n git_url: gitUrl,\n debug: debug,\n }),\n })\n}\n"]}
1
+ {"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAwC;AACxC,mCAAmC;AACnC,4CAAmB;AACnB,wDAA+B;AAE/B,+BAA+B;AAC/B,gDAAuB;AACvB,kDAAyB;AACzB,mCAAwC;AACxC,4DAA8B;AAC9B,mCAAsD;AACtD,6BAAyB;AAEzB,KAAK,UAAU,aAAa,CAAC,OAA4B,EAAE,MAAc;IACvE,MAAM,GAAG,GAAG,IAAI,SAAG,CAAC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IACrD,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,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AE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;gBACzD,MAAM,YAAY,EAAE,CAAA;aACrB;iBAAM;gBACL,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;SACF;IACH,CAAC,CAAA;IAED,MAAM,YAAY,EAAE,CAAA;AACtB,CAAC;AAnJD,gCAmJC;AAED,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,MAAc,EAAE,WAAmB,EAAE,UAAkB;IAC7F,MAAM,aAAa,GAAG,IAAI,SAAG,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAA;IACrE,OAAO,IAAA,oBAAK,EAAC,aAAa,EAAE;QAC1B,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,SAAS,EAAE,MAAM;SAClB;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,YAAY,EAAE,WAAW;YACzB,WAAW,EAAE,UAAU;SACxB,CAAC;KACH,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,IAAY,EACZ,MAAc,EACd,WAAmB,EACnB,UAAkB,EAClB,MAAc,EACd,SAAiB,EACjB,MAAc,EACd,KAAc;IAEd,MAAM,eAAe,GAAG,IAAI,SAAG,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAA;IACzE,OAAO,IAAA,oBAAK,EAAC,eAAe,EAAE;QAC5B,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,SAAS,EAAE,MAAM;SAClB;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,YAAY,EAAE,WAAW;YACzB,WAAW,EAAE,UAAU;YACvB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,MAAM;YACf,KAAK,EAAE,KAAK;SACb,CAAC;KACH,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { execSync } from 'child_process'\nimport { createHash } from 'crypto'\nimport fs from 'fs'\nimport readline from 'readline'\nimport { SentioProjectConfig } from './config'\nimport { ReadKey } from './key'\nimport path from 'path'\nimport chalk from 'chalk'\nimport { buildProcessor } from './build'\nimport fetch from 'node-fetch'\nimport { getCliVersion, getSdkVersion } from './utils'\nimport { URL } from 'url'\n\nasync function createProject(options: SentioProjectConfig, apiKey: string) {\n const url = new URL('/api/v1/projects', options.host)\n const [ownerName, slug] = options.project.includes('/') ? options.project.split('/') : [undefined, options.project]\n return fetch(url, {\n method: 'POST',\n headers: {\n 'api-key': apiKey,\n },\n body: JSON.stringify({ slug, ownerName, visibility: 'PRIVATE' }),\n })\n}\n\nexport async function uploadFile(options: SentioProjectConfig, apiKeyOverride: string) {\n if (options.build) {\n await buildProcessor(false)\n }\n\n console.log(chalk.blue('Prepare to upload'))\n\n const PROCESSOR_FILE = path.join(process.cwd(), 'dist/lib.js')\n\n const apiKey = apiKeyOverride || ReadKey(options.host)\n\n const isProd = options.host === 'https://app.sentio.xyz'\n if (!apiKey) {\n const cmd = isProd ? 'sentio login' : 'sentio login --host=' + options.host\n console.error(chalk.red('No Credential found for', options.host, '. Please run `' + cmd + '`.'))\n process.exit(1)\n }\n\n if (!fs.existsSync(PROCESSOR_FILE)) {\n console.error(chalk.red('File not existed ', PROCESSOR_FILE, \"don't use --nobuild\"))\n process.exit(1)\n }\n\n const stat = fs.statSync(PROCESSOR_FILE)\n console.log('Packed processor file size', Math.floor(stat.size / 1024) + 'K, last modified', stat.mtime)\n const content = fs.readFileSync(PROCESSOR_FILE)\n const hash = createHash('sha256')\n hash.update(content)\n const digest = hash.digest('hex')\n\n let triedCount = 0\n const upload = async () => {\n let commitSha = ''\n let gitUrl = ''\n const sha256 = digest\n try {\n commitSha = execSync('git rev-parse HEAD').toString().trim()\n } catch (e) {\n chalk.yellow(e)\n }\n try {\n gitUrl = execSync('git remote get-url origin').toString().trim()\n } catch (e) {\n // skip errors\n }\n console.log(chalk.blue(triedCount > 1 ? 'Retry uploading' : 'Uploading'))\n\n // get gcs upload url\n const initUploadResRaw = await initUpload(options.host, apiKey, options.project, getSdkVersion())\n if (!initUploadResRaw.ok) {\n console.error(chalk.red('Failed to get upload url'))\n console.error(chalk.red((await initUploadResRaw.json()).message))\n\n if (initUploadResRaw.status === 404) {\n // create project if not exist\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n const prompt = async () => {\n const answer: string = await new Promise((resolve) =>\n rl.question(`Do you want to create it and continue the uploading process? (yes/no) `, resolve)\n )\n if (['y', 'yes'].includes(answer.toLowerCase())) {\n rl.close()\n const res = await createProject(options, apiKey)\n if (!res.ok) {\n console.error(chalk.red('Create Project Failed'))\n console.error(chalk.red((await res.json()).message))\n return\n }\n console.log(chalk.green('Project created'))\n await upload()\n } else if (['n', 'no'].includes(answer.toLowerCase())) {\n rl.close()\n } else {\n await prompt()\n }\n }\n await prompt()\n }\n return\n }\n const initUploadRes = await initUploadResRaw.json()\n const uploadUrl = initUploadRes['url'] as string\n\n // do actual uploading\n const file = fs.createReadStream(PROCESSOR_FILE)\n const uploadResRaw = await fetch(uploadUrl, {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/octet-stream',\n },\n body: file,\n })\n if (!uploadResRaw.ok) {\n console.error(chalk.red('Failed to upload'))\n console.error(chalk.red(await uploadResRaw.text()))\n return\n }\n\n // finish uploading\n const finishUploadResRaw = await finishUpload(\n options.host,\n apiKey,\n options.project,\n getSdkVersion(),\n sha256,\n commitSha,\n gitUrl,\n options.debug\n )\n if (!finishUploadResRaw.ok) {\n console.error(chalk.red('Failed to finish uploading'))\n console.error(chalk.red(await finishUploadResRaw.text()))\n return\n }\n\n console.log(chalk.green('Upload success: '))\n console.log('\\t', chalk.blue('sha256:'), digest)\n if (commitSha) {\n console.log('\\t', chalk.blue('Git commit SHA:'), commitSha)\n }\n const { projectFullSlug } = await finishUploadResRaw.json()\n console.log('\\t', chalk.blue('Check status:'), `${options.host}/${projectFullSlug}/datasource`)\n }\n\n let error: Error\n const tryUploading = async () => {\n if (triedCount++ >= 5) {\n console.error(error)\n return\n }\n try {\n await upload()\n } catch (e) {\n if (e.constructor.name === 'FetchError' && e.type === 'system' && e.code === 'EPIPE') {\n error = e\n await new Promise((resolve) => setTimeout(resolve, 1000))\n await tryUploading()\n } else {\n console.error(e)\n }\n }\n }\n\n await tryUploading()\n}\n\nasync function initUpload(host: string, apiKey: string, projectSlug: string, sdkVersion: string) {\n const initUploadUrl = new URL(`/api/v1/processors/init_upload`, host)\n return fetch(initUploadUrl, {\n method: 'POST',\n headers: {\n 'api-key': apiKey,\n },\n body: JSON.stringify({\n project_slug: projectSlug,\n sdk_version: sdkVersion,\n }),\n })\n}\n\nasync function finishUpload(\n host: string,\n apiKey: string,\n projectSlug: string,\n sdkVersion: string,\n sha256: string,\n commitSha: string,\n gitUrl: string,\n debug: boolean\n) {\n const finishUploadUrl = new URL(`/api/v1/processors/finish_upload`, host)\n return fetch(finishUploadUrl, {\n method: 'POST',\n headers: {\n 'api-key': apiKey,\n },\n body: JSON.stringify({\n project_slug: projectSlug,\n sdk_version: sdkVersion,\n sha256: sha256,\n commit_sha: commitSha,\n git_url: gitUrl,\n debug: debug,\n }),\n })\n}\n"]}
package/lib/utils.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export declare function getCliVersion(): any;
2
+ export declare function getSdkVersion(): any;
package/lib/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCliVersion = void 0;
6
+ exports.getSdkVersion = exports.getCliVersion = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  function getCliVersion() {
@@ -13,4 +13,11 @@ function getCliVersion() {
13
13
  return packageJson.version;
14
14
  }
15
15
  exports.getCliVersion = getCliVersion;
16
+ function getSdkVersion() {
17
+ const packageJsonPath = require.resolve('@sentio/sdk/package.json');
18
+ const packageJsonContent = fs_extra_1.default.readFileSync(packageJsonPath, 'utf-8');
19
+ const packageJson = JSON.parse(packageJsonContent);
20
+ return packageJson.version;
21
+ }
22
+ exports.getSdkVersion = getSdkVersion;
16
23
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAyB;AACzB,gDAAuB;AAEvB,SAAgB,aAAa;IAC3B,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAA;IACrE,MAAM,kBAAkB,GAAG,kBAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IACpE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAElD,OAAO,WAAW,CAAC,OAAO,CAAA;AAC5B,CAAC;AAND,sCAMC","sourcesContent":["import fs from 'fs-extra'\nimport path from 'path'\n\nexport function getCliVersion() {\n const packageJsonPath = path.resolve(__dirname, '../../package.json')\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(packageJsonContent)\n\n return packageJson.version\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAyB;AACzB,gDAAuB;AAEvB,SAAgB,aAAa;IAC3B,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAA;IACrE,MAAM,kBAAkB,GAAG,kBAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IACpE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAElD,OAAO,WAAW,CAAC,OAAO,CAAA;AAC5B,CAAC;AAND,sCAMC;AAED,SAAgB,aAAa;IAC3B,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAA;IACnE,MAAM,kBAAkB,GAAG,kBAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IACpE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAElD,OAAO,WAAW,CAAC,OAAO,CAAA;AAC5B,CAAC;AAND,sCAMC","sourcesContent":["import fs from 'fs-extra'\nimport path from 'path'\n\nexport function getCliVersion() {\n const packageJsonPath = path.resolve(__dirname, '../../package.json')\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(packageJsonContent)\n\n return packageJson.version\n}\n\nexport function getSdkVersion() {\n const packageJsonPath = require.resolve('@sentio/sdk/package.json')\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(packageJsonContent)\n\n return packageJson.version\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentio/cli",
3
3
  "license": "Apache-2.0",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "scripts": {
6
6
  "compile": "tsc -p . && cp src/webpack.config.js lib/",
7
7
  "build": "yarn compile",
@@ -29,23 +29,13 @@
29
29
  "@types/expect": "^24.3.0",
30
30
  "@types/express": "^4.17.14",
31
31
  "@types/fs-extra": "^9.0.13",
32
- "@types/google-protobuf": "^3.15.6",
33
32
  "@types/js-yaml": "^4.0.5",
34
- "@types/mkdirp": "^1.0.2",
35
33
  "@types/node": "^18.0.4",
36
34
  "@types/node-fetch": "^2.6.2",
37
35
  "chai": "^4.3.6",
38
- "clean-publish": "^4.0.1",
39
- "conventional-changelog-conventionalcommits": "^5.0.0",
40
- "eslint": "^8.27.0",
41
- "eslint-import-resolver-typescript": "^3.5.2",
42
- "eslint-plugin-import": "^2.26.0",
43
36
  "jest": "^29.0.3",
44
- "semantic-release": "^19.0.5",
45
37
  "ts-jest": "^29.0.3",
46
- "ts-node": "^10.9.1",
47
- "tsconfig-paths": "^4.0.0",
48
- "typescript": "^4.8.0"
38
+ "ts-node": "^10.9.1"
49
39
  },
50
40
  "bin": {
51
41
  "sentio": "./lib/cli.js"
package/src/build.ts CHANGED
@@ -42,7 +42,6 @@ async function installDeps() {
42
42
 
43
43
  export async function codeGenEthersProcessor(
44
44
  abisDir: string,
45
- // eslint-disable-next-line @typescript-eslint/no-var-requires
46
45
  ETHERS_TARGET = path.dirname(require.resolve('@sentio/sdk/lib/target-ethers-sentio')),
47
46
  outDir = 'src/types/internal'
48
47
  ) {
@@ -1,6 +1,7 @@
1
1
  import commandLineArgs from 'command-line-args'
2
2
  import commandLineUsage from 'command-line-usage'
3
- import { getCliVersion } from '../utils'
3
+ import { getCliVersion, getSdkVersion } from '../utils'
4
+ import * as console from 'console'
4
5
 
5
6
  export function runVersion(argv: string[]) {
6
7
  const optionDefinitions = [
@@ -27,6 +28,11 @@ export function runVersion(argv: string[]) {
27
28
  console.log(usage)
28
29
  } else {
29
30
  console.log('CLI Version: ', getCliVersion())
30
- // TODO show SDK version for current package
31
+ const sdkVersion = getSdkVersion()
32
+ if (sdkVersion) {
33
+ console.log('SDK Version: ', sdkVersion)
34
+ } else {
35
+ console.log('SDK Not installed for this project')
36
+ }
31
37
  }
32
38
  }
package/src/upload.ts CHANGED
@@ -8,7 +8,7 @@ import path from 'path'
8
8
  import chalk from 'chalk'
9
9
  import { buildProcessor } from './build'
10
10
  import fetch from 'node-fetch'
11
- import { getCliVersion } from './utils'
11
+ import { getSdkVersion } from './utils'
12
12
  import { URL } from 'url'
13
13
 
14
14
  async function createProject(options: SentioProjectConfig, apiKey: string) {
@@ -71,7 +71,7 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
71
71
  console.log(chalk.blue(triedCount > 1 ? 'Retry uploading' : 'Uploading'))
72
72
 
73
73
  // get gcs upload url
74
- const initUploadResRaw = await initUpload(options.host, apiKey, options.project, getCliVersion())
74
+ const initUploadResRaw = await initUpload(options.host, apiKey, options.project, getSdkVersion())
75
75
  if (!initUploadResRaw.ok) {
76
76
  console.error(chalk.red('Failed to get upload url'))
77
77
  console.error(chalk.red((await initUploadResRaw.json()).message))
@@ -129,7 +129,7 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
129
129
  options.host,
130
130
  apiKey,
131
131
  options.project,
132
- getCliVersion(),
132
+ getSdkVersion(),
133
133
  sha256,
134
134
  commitSha,
135
135
  gitUrl,
package/src/utils.ts CHANGED
@@ -8,3 +8,14 @@ export function getCliVersion() {
8
8
 
9
9
  return packageJson.version
10
10
  }
11
+
12
+ export function getSdkVersion() {
13
+ try {
14
+ const packageJsonPath = require.resolve('@sentio/sdk/package.json')
15
+ const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8')
16
+ const packageJson = JSON.parse(packageJsonContent)
17
+ return packageJson.version
18
+ } catch (e) {
19
+ return undefined
20
+ }
21
+ }
@@ -0,0 +1,107 @@
1
+ .idea
2
+ src/types
3
+
4
+ # Logs
5
+ logs
6
+ *.log
7
+ npm-debug.log*
8
+ yarn-debug.log*
9
+ yarn-error.log*
10
+ lerna-debug.log*
11
+
12
+ # Diagnostic reports (https://nodejs.org/api/report.html)
13
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
14
+
15
+ # Runtime data
16
+ pids
17
+ *.pid
18
+ *.seed
19
+ *.pid.lock
20
+
21
+ # Directory for instrumented libs generated by jscoverage/JSCover
22
+ lib-cov
23
+
24
+ # Coverage directory used by tools like istanbul
25
+ coverage
26
+ *.lcov
27
+
28
+ # nyc test coverage
29
+ .nyc_output
30
+
31
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32
+ .grunt
33
+
34
+ # Bower dependency directory (https://bower.io/)
35
+ bower_components
36
+
37
+ # node-waf configuration
38
+ .lock-wscript
39
+
40
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
41
+ build/Release
42
+
43
+ # Dependency directories
44
+ node_modules/
45
+ jspm_packages/
46
+
47
+ # TypeScript v1 declaration files
48
+ typings/
49
+
50
+ # TypeScript cache
51
+ *.tsbuildinfo
52
+
53
+ # Optional npm cache directory
54
+ .npm
55
+
56
+ # Optional eslint cache
57
+ .eslintcache
58
+
59
+ # Microbundle cache
60
+ .rpt2_cache/
61
+ .rts2_cache_cjs/
62
+ .rts2_cache_es/
63
+ .rts2_cache_umd/
64
+
65
+ # Optional REPL history
66
+ .node_repl_history
67
+
68
+ # Output of 'npm pack'
69
+ *.tgz
70
+
71
+ # Yarn Integrity file
72
+ .yarn-integrity
73
+
74
+ # dotenv environment variables file
75
+ .env
76
+ .env.test
77
+
78
+ # parcel-bundler cache (https://parceljs.org/)
79
+ .cache
80
+
81
+ # Next.js build output
82
+ .next
83
+
84
+ # Nuxt.js build / generate output
85
+ .nuxt
86
+ dist
87
+
88
+ # Gatsby files
89
+ .cache/
90
+ # Comment in the public line in if your project uses Gatsby and *not* Next.js
91
+ # https://nextjs.org/blog/next-9-1#public-directory-support
92
+ # public
93
+
94
+ # vuepress build output
95
+ .vuepress/dist
96
+
97
+ # Serverless directories
98
+ .serverless/
99
+
100
+ # FuseBox cache
101
+ .fusebox/
102
+
103
+ # DynamoDB Local files
104
+ .dynamodb/
105
+
106
+ # TernJS port file
107
+ .tern-port
@@ -0,0 +1,14 @@
1
+ import { TestProcessorServer } from '@sentio/sdk/lib/testing'
2
+
3
+ describe('Test Processor', () => {
4
+ const service = new TestProcessorServer(() => require('./processor'))
5
+
6
+ beforeAll(async () => {
7
+ await service.start()
8
+ })
9
+
10
+ test('has config', async () => {
11
+ const config = await service.getConfig({})
12
+ expect(config.contractConfigs.length > 0)
13
+ })
14
+ })
@@ -0,0 +1,107 @@
1
+ .idea
2
+ src/types
3
+
4
+ # Logs
5
+ logs
6
+ *.log
7
+ npm-debug.log*
8
+ yarn-debug.log*
9
+ yarn-error.log*
10
+ lerna-debug.log*
11
+
12
+ # Diagnostic reports (https://nodejs.org/api/report.html)
13
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
14
+
15
+ # Runtime data
16
+ pids
17
+ *.pid
18
+ *.seed
19
+ *.pid.lock
20
+
21
+ # Directory for instrumented libs generated by jscoverage/JSCover
22
+ lib-cov
23
+
24
+ # Coverage directory used by tools like istanbul
25
+ coverage
26
+ *.lcov
27
+
28
+ # nyc test coverage
29
+ .nyc_output
30
+
31
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32
+ .grunt
33
+
34
+ # Bower dependency directory (https://bower.io/)
35
+ bower_components
36
+
37
+ # node-waf configuration
38
+ .lock-wscript
39
+
40
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
41
+ build/Release
42
+
43
+ # Dependency directories
44
+ node_modules/
45
+ jspm_packages/
46
+
47
+ # TypeScript v1 declaration files
48
+ typings/
49
+
50
+ # TypeScript cache
51
+ *.tsbuildinfo
52
+
53
+ # Optional npm cache directory
54
+ .npm
55
+
56
+ # Optional eslint cache
57
+ .eslintcache
58
+
59
+ # Microbundle cache
60
+ .rpt2_cache/
61
+ .rts2_cache_cjs/
62
+ .rts2_cache_es/
63
+ .rts2_cache_umd/
64
+
65
+ # Optional REPL history
66
+ .node_repl_history
67
+
68
+ # Output of 'npm pack'
69
+ *.tgz
70
+
71
+ # Yarn Integrity file
72
+ .yarn-integrity
73
+
74
+ # dotenv environment variables file
75
+ .env
76
+ .env.test
77
+
78
+ # parcel-bundler cache (https://parceljs.org/)
79
+ .cache
80
+
81
+ # Next.js build output
82
+ .next
83
+
84
+ # Nuxt.js build / generate output
85
+ .nuxt
86
+ dist
87
+
88
+ # Gatsby files
89
+ .cache/
90
+ # Comment in the public line in if your project uses Gatsby and *not* Next.js
91
+ # https://nextjs.org/blog/next-9-1#public-directory-support
92
+ # public
93
+
94
+ # vuepress build output
95
+ .vuepress/dist
96
+
97
+ # Serverless directories
98
+ .serverless/
99
+
100
+ # FuseBox cache
101
+ .fusebox/
102
+
103
+ # DynamoDB Local files
104
+ .dynamodb/
105
+
106
+ # TernJS port file
107
+ .tern-port
@@ -0,0 +1,29 @@
1
+ import { TestProcessorServer, firstCounterValue } from '@sentio/sdk/lib/testing'
2
+ import { mockTransferLog } from '@sentio/sdk/lib/builtin/erc20/test-utils'
3
+ import { BigNumber } from 'ethers'
4
+
5
+ describe('Test Processor', () => {
6
+ const service = new TestProcessorServer(() => require('./processor'))
7
+
8
+ beforeAll(async () => {
9
+ await service.start()
10
+ })
11
+
12
+ test('has valid config', async () => {
13
+ const config = await service.getConfig({})
14
+ expect(config.contractConfigs.length > 0).toBeTruthy()
15
+ })
16
+
17
+ test('check transfer event handling', async () => {
18
+ const resp = await service.testLog(
19
+ mockTransferLog('0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9', {
20
+ from: '0x0000000000000000000000000000000000000000',
21
+ to: '0xb329e39ebefd16f40d38f07643652ce17ca5bac1',
22
+ value: BigNumber.from(10n ** 18n * 10n),
23
+ })
24
+ )
25
+
26
+ const tokenCounter = firstCounterValue(resp.result, 'token')
27
+ expect(tokenCounter).toEqual(10n)
28
+ })
29
+ })
@@ -0,0 +1,107 @@
1
+ .idea
2
+ src/types
3
+
4
+ # Logs
5
+ logs
6
+ *.log
7
+ npm-debug.log*
8
+ yarn-debug.log*
9
+ yarn-error.log*
10
+ lerna-debug.log*
11
+
12
+ # Diagnostic reports (https://nodejs.org/api/report.html)
13
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
14
+
15
+ # Runtime data
16
+ pids
17
+ *.pid
18
+ *.seed
19
+ *.pid.lock
20
+
21
+ # Directory for instrumented libs generated by jscoverage/JSCover
22
+ lib-cov
23
+
24
+ # Coverage directory used by tools like istanbul
25
+ coverage
26
+ *.lcov
27
+
28
+ # nyc test coverage
29
+ .nyc_output
30
+
31
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32
+ .grunt
33
+
34
+ # Bower dependency directory (https://bower.io/)
35
+ bower_components
36
+
37
+ # node-waf configuration
38
+ .lock-wscript
39
+
40
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
41
+ build/Release
42
+
43
+ # Dependency directories
44
+ node_modules/
45
+ jspm_packages/
46
+
47
+ # TypeScript v1 declaration files
48
+ typings/
49
+
50
+ # TypeScript cache
51
+ *.tsbuildinfo
52
+
53
+ # Optional npm cache directory
54
+ .npm
55
+
56
+ # Optional eslint cache
57
+ .eslintcache
58
+
59
+ # Microbundle cache
60
+ .rpt2_cache/
61
+ .rts2_cache_cjs/
62
+ .rts2_cache_es/
63
+ .rts2_cache_umd/
64
+
65
+ # Optional REPL history
66
+ .node_repl_history
67
+
68
+ # Output of 'npm pack'
69
+ *.tgz
70
+
71
+ # Yarn Integrity file
72
+ .yarn-integrity
73
+
74
+ # dotenv environment variables file
75
+ .env
76
+ .env.test
77
+
78
+ # parcel-bundler cache (https://parceljs.org/)
79
+ .cache
80
+
81
+ # Next.js build output
82
+ .next
83
+
84
+ # Nuxt.js build / generate output
85
+ .nuxt
86
+ dist
87
+
88
+ # Gatsby files
89
+ .cache/
90
+ # Comment in the public line in if your project uses Gatsby and *not* Next.js
91
+ # https://nextjs.org/blog/next-9-1#public-directory-support
92
+ # public
93
+
94
+ # vuepress build output
95
+ .vuepress/dist
96
+
97
+ # Serverless directories
98
+ .serverless/
99
+
100
+ # FuseBox cache
101
+ .fusebox/
102
+
103
+ # DynamoDB Local files
104
+ .dynamodb/
105
+
106
+ # TernJS port file
107
+ .tern-port
@@ -0,0 +1,14 @@
1
+ import { TestProcessorServer } from '@sentio/sdk/lib/testing'
2
+
3
+ describe('Test Processor', () => {
4
+ const service = new TestProcessorServer(() => require('./processor'))
5
+
6
+ beforeAll(async () => {
7
+ await service.start()
8
+ })
9
+
10
+ test('has valid config', async () => {
11
+ // const config = await service.getConfig({})
12
+ // expect(config.contractConfigs.length > 0).toBeTruthy()
13
+ })
14
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "inlineSources": true,
5
+ "rootDir": "./src",
6
+ "baseUrl": "./src",
7
+ "paths": {
8
+ "@sentio/sdk": ["."]
9
+ },
10
+ "outDir": "lib"
11
+ },
12
+ "exclude": ["lib", "templates"]
13
+ }