@sentio/cli 2.0.0-rc.1 → 2.0.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.
Files changed (51) hide show
  1. package/lib/build.js +37 -32
  2. package/lib/build.js.map +1 -1
  3. package/lib/cli.js +25 -28
  4. package/lib/cli.js.map +1 -1
  5. package/lib/commands/login-server.js +31 -36
  6. package/lib/commands/login-server.js.map +1 -1
  7. package/lib/commands/run-create.js +23 -28
  8. package/lib/commands/run-create.js.map +1 -1
  9. package/lib/commands/run-login.js +28 -33
  10. package/lib/commands/run-login.js.map +1 -1
  11. package/lib/commands/run-upload.d.ts +1 -1
  12. package/lib/commands/run-upload.js +62 -68
  13. package/lib/commands/run-upload.js.map +1 -1
  14. package/lib/commands/run-version.js +9 -14
  15. package/lib/commands/run-version.js.map +1 -1
  16. package/lib/config.js +4 -11
  17. package/lib/config.js.map +1 -1
  18. package/lib/key.js +18 -24
  19. package/lib/key.js.map +1 -1
  20. package/lib/utils.js +7 -13
  21. package/lib/utils.js.map +1 -1
  22. package/package.json +8 -9
  23. package/src/build.ts +25 -11
  24. package/src/cli.ts +6 -6
  25. package/src/commands/login-server.ts +12 -12
  26. package/src/commands/run-login.ts +4 -4
  27. package/src/commands/run-upload.ts +16 -13
  28. package/src/commands/run-version.ts +1 -1
  29. package/templates/aptos/jest.config.ts +8 -0
  30. package/templates/aptos/package.json +1 -0
  31. package/templates/aptos/src/processor.ts +3 -3
  32. package/templates/aptos/tsconfig.json +3 -2
  33. package/templates/evm/jest.config.ts +8 -0
  34. package/templates/evm/package.json +1 -0
  35. package/templates/evm/src/processor.ts +3 -3
  36. package/templates/evm/tsconfig.json +3 -2
  37. package/templates/raw/jest.config.ts +8 -0
  38. package/templates/raw/package.json +1 -0
  39. package/templates/raw/tsconfig.json +3 -2
  40. package/templates/solana/jest.config.ts +8 -0
  41. package/templates/solana/package.json +1 -0
  42. package/templates/solana/src/processor.ts +1 -1
  43. package/templates/solana/tsconfig.json +3 -2
  44. package/lib/webpack.config.js +0 -50
  45. package/src/webpack.config.js +0 -50
  46. package/templates/aptos/jest.config.js +0 -7
  47. package/templates/evm/jest.config.js +0 -7
  48. package/templates/raw/jest.config.js +0 -7
  49. package/templates/raw/yarn.lock +0 -4095
  50. package/templates/solana/jest.config.js +0 -7
  51. package/templates/solana/yarn.lock +0 -4918
package/lib/key.js CHANGED
@@ -1,36 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReadKey = exports.WriteKey = void 0;
4
- const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const fs_1 = tslib_1.__importDefault(require("fs"));
7
- const os_1 = tslib_1.__importDefault(require("os"));
8
- const homeDir = os_1.default.homedir();
9
- const sentioDir = path_1.default.join(homeDir, '.sentio');
10
- const configFile = path_1.default.join(sentioDir, 'config.json');
11
- function WriteKey(host, api_key) {
12
- const sentioDir = path_1.default.join(homeDir, '.sentio');
13
- if (!fs_1.default.existsSync(sentioDir)) {
14
- fs_1.default.mkdirSync(sentioDir, { recursive: true });
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import os from 'os';
4
+ const homeDir = os.homedir();
5
+ const sentioDir = path.join(homeDir, '.sentio');
6
+ const configFile = path.join(sentioDir, 'config.json');
7
+ export function WriteKey(host, api_key) {
8
+ const sentioDir = path.join(homeDir, '.sentio');
9
+ if (!fs.existsSync(sentioDir)) {
10
+ fs.mkdirSync(sentioDir, { recursive: true });
15
11
  }
16
12
  let config = {};
17
- if (fs_1.default.existsSync(configFile)) {
18
- const content = fs_1.default.readFileSync(configFile, 'utf8');
13
+ if (fs.existsSync(configFile)) {
14
+ const content = fs.readFileSync(configFile, 'utf8');
19
15
  config = JSON.parse(content);
20
16
  }
21
17
  const hostConfig = config[host] || { api_keys: {} };
22
18
  hostConfig.api_keys = api_key;
23
19
  config[host] = hostConfig;
24
- fs_1.default.writeFileSync(configFile, JSON.stringify(config, null, 2));
20
+ fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
25
21
  }
26
- exports.WriteKey = WriteKey;
27
- function ReadKey(host) {
28
- if (!fs_1.default.existsSync(sentioDir)) {
22
+ export function ReadKey(host) {
23
+ if (!fs.existsSync(sentioDir)) {
29
24
  return undefined;
30
25
  }
31
- const configFile = path_1.default.join(sentioDir, 'config.json');
32
- if (fs_1.default.existsSync(configFile)) {
33
- const content = fs_1.default.readFileSync(configFile, 'utf8');
26
+ const configFile = path.join(sentioDir, 'config.json');
27
+ if (fs.existsSync(configFile)) {
28
+ const content = fs.readFileSync(configFile, 'utf8');
34
29
  const config = JSON.parse(content);
35
30
  return config[host]?.api_keys;
36
31
  }
@@ -38,5 +33,4 @@ function ReadKey(host) {
38
33
  return undefined;
39
34
  }
40
35
  }
41
- exports.ReadKey = ReadKey;
42
36
  //# sourceMappingURL=key.js.map
package/lib/key.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"key.js","sourceRoot":"","sources":["../src/key.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AACvB,oDAAmB;AACnB,oDAAmB;AAEnB,MAAM,OAAO,GAAG,YAAE,CAAC,OAAO,EAAE,CAAA;AAC5B,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAC/C,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;AAQtD,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAe;IACpD,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC/C,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,YAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;KAC7C;IACD,IAAI,MAAM,GAAoB,EAAE,CAAA;IAChC,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC7B,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QACnD,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;KAC7B;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;IACnD,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAA;IAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAA;IACzB,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AAC/D,CAAC;AAdD,4BAcC;AAED,SAAgB,OAAO,CAAC,IAAY;IAClC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IACtD,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC7B,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;KAC9B;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AAZD,0BAYC","sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport os from 'os'\n\nconst homeDir = os.homedir()\nconst sentioDir = path.join(homeDir, '.sentio')\nconst configFile = path.join(sentioDir, 'config.json')\n\ninterface SentioKeyConfig {\n [key: string]: {\n api_keys: string\n }\n}\n\nexport function WriteKey(host: string, api_key: string) {\n const sentioDir = path.join(homeDir, '.sentio')\n if (!fs.existsSync(sentioDir)) {\n fs.mkdirSync(sentioDir, { recursive: true })\n }\n let config: SentioKeyConfig = {}\n if (fs.existsSync(configFile)) {\n const content = fs.readFileSync(configFile, 'utf8')\n config = JSON.parse(content)\n }\n const hostConfig = config[host] || { api_keys: {} }\n hostConfig.api_keys = api_key\n config[host] = hostConfig\n fs.writeFileSync(configFile, JSON.stringify(config, null, 2))\n}\n\nexport function ReadKey(host: string): string | undefined {\n if (!fs.existsSync(sentioDir)) {\n return undefined\n }\n const configFile = path.join(sentioDir, 'config.json')\n if (fs.existsSync(configFile)) {\n const content = fs.readFileSync(configFile, 'utf8')\n const config = JSON.parse(content)\n return config[host]?.api_keys\n } else {\n return undefined\n }\n}\n"]}
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../src/key.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;AAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;AAQtD,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,OAAe;IACpD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;KAC7C;IACD,IAAI,MAAM,GAAoB,EAAE,CAAA;IAChC,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC7B,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QACnD,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;KAC7B;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;IACnD,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAA;IAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAA;IACzB,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AAC/D,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IACtD,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC7B,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;KAC9B;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC","sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport os from 'os'\n\nconst homeDir = os.homedir()\nconst sentioDir = path.join(homeDir, '.sentio')\nconst configFile = path.join(sentioDir, 'config.json')\n\ninterface SentioKeyConfig {\n [key: string]: {\n api_keys: string\n }\n}\n\nexport function WriteKey(host: string, api_key: string) {\n const sentioDir = path.join(homeDir, '.sentio')\n if (!fs.existsSync(sentioDir)) {\n fs.mkdirSync(sentioDir, { recursive: true })\n }\n let config: SentioKeyConfig = {}\n if (fs.existsSync(configFile)) {\n const content = fs.readFileSync(configFile, 'utf8')\n config = JSON.parse(content)\n }\n const hostConfig = config[host] || { api_keys: {} }\n hostConfig.api_keys = api_key\n config[host] = hostConfig\n fs.writeFileSync(configFile, JSON.stringify(config, null, 2))\n}\n\nexport function ReadKey(host: string): string | undefined {\n if (!fs.existsSync(sentioDir)) {\n return undefined\n }\n const configFile = path.join(sentioDir, 'config.json')\n if (fs.existsSync(configFile)) {\n const content = fs.readFileSync(configFile, 'utf8')\n const config = JSON.parse(content)\n return config[host]?.api_keys\n } else {\n return undefined\n }\n}\n"]}
package/lib/utils.js CHANGED
@@ -1,20 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSdkVersion = exports.getCliVersion = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- function getCliVersion() {
8
- const packageJsonPath = path_1.default.resolve(__dirname, '../package.json');
9
- const packageJsonContent = fs_extra_1.default.readFileSync(packageJsonPath, 'utf-8');
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ export function getCliVersion() {
4
+ const packageJsonPath = path.resolve(__dirname, '../package.json');
5
+ const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8');
10
6
  const packageJson = JSON.parse(packageJsonContent);
11
7
  return packageJson.version;
12
8
  }
13
- exports.getCliVersion = getCliVersion;
14
- function getSdkVersion() {
9
+ export function getSdkVersion() {
15
10
  try {
16
11
  const packageJsonPath = require.resolve('@sentio/sdk/package.json');
17
- const packageJsonContent = fs_extra_1.default.readFileSync(packageJsonPath, 'utf-8');
12
+ const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8');
18
13
  const packageJson = JSON.parse(packageJsonContent);
19
14
  return packageJson.version;
20
15
  }
@@ -22,5 +17,4 @@ function getSdkVersion() {
22
17
  return undefined;
23
18
  }
24
19
  }
25
- exports.getSdkVersion = getSdkVersion;
26
20
  //# 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,gEAAyB;AACzB,wDAAuB;AAEvB,SAAgB,aAAa;IAC3B,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAA;IAClE,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,IAAI;QACF,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAA;QACnE,MAAM,kBAAkB,GAAG,kBAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;QACpE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAClD,OAAO,WAAW,CAAC,OAAO,CAAA;KAC3B;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AATD,sCASC","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 try {\n const packageJsonPath = require.resolve('@sentio/sdk/package.json')\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(packageJsonContent)\n return packageJson.version\n } catch (e) {\n return undefined\n }\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,UAAU,aAAa;IAC3B,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAA;IAClE,MAAM,kBAAkB,GAAG,EAAE,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;AAED,MAAM,UAAU,aAAa;IAC3B,IAAI;QACF,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAA;QACnE,MAAM,kBAAkB,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;QACpE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAClD,OAAO,WAAW,CAAC,OAAO,CAAA;KAC3B;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,SAAS,CAAA;KACjB;AACH,CAAC","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 try {\n const packageJsonPath = require.resolve('@sentio/sdk/package.json')\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8')\n const packageJson = JSON.parse(packageJsonContent)\n return packageJson.version\n } catch (e) {\n return undefined\n }\n}\n"]}
package/package.json CHANGED
@@ -2,12 +2,13 @@
2
2
  "name": "@sentio/cli",
3
3
  "license": "Apache-2.0",
4
4
  "private": false,
5
- "version": "2.0.0-rc.1",
5
+ "type": "module",
6
+ "version": "2.0.0-rc.2",
6
7
  "scripts": {
7
- "compile": "tsc -p . && cp src/webpack.config.js lib/",
8
+ "compile": "tsc -p .",
8
9
  "build": "yarn compile",
9
10
  "postbuild": "../../scripts/link-bin.sh",
10
- "cli": "ts-node src/cli.ts",
11
+ "cli": "ts-node-esm src/cli.ts",
11
12
  "test": "jest",
12
13
  "pub": "yarn build && yarn publish --no-git-tag-version"
13
14
  },
@@ -18,13 +19,11 @@
18
19
  "form-data": "^4.0.0",
19
20
  "fs-extra": "^11.0.0",
20
21
  "js-yaml": "^4.1.0",
21
- "latest-version": "^5.1.0",
22
- "node-fetch": "2",
22
+ "latest-version": "^7.0.0",
23
+ "node-fetch": "^3.3.0",
23
24
  "open": "^8.4.0",
24
- "ts-loader": "^9.3.0",
25
- "webpack": "^5.72.1",
26
- "webpack-cli": "^5.0.0",
27
- "chalk": "^4.1.0"
25
+ "tsup": "^6.5.0",
26
+ "chalk": "^5.2.0"
28
27
  },
29
28
  "devDependencies": {
30
29
  "@types/command-line-args": "^5.2.0",
package/src/build.ts CHANGED
@@ -2,6 +2,20 @@ import chalk from 'chalk'
2
2
  import path from 'path'
3
3
  import fs from 'fs'
4
4
  import { exec } from 'child_process'
5
+ import * as process from 'process'
6
+ import { createRequire } from 'module'
7
+ const require = createRequire(import.meta.url)
8
+
9
+ function getPackageRoot(pkgId: string): string {
10
+ const m = require.resolve(pkgId)
11
+
12
+ let dir = path.dirname(m)
13
+ while (!fs.existsSync(path.join(dir, 'package.json'))) {
14
+ dir = path.dirname(dir)
15
+ }
16
+
17
+ return dir
18
+ }
5
19
 
6
20
  export async function buildProcessor(onlyGen: boolean) {
7
21
  if (!onlyGen) {
@@ -16,13 +30,13 @@ export async function buildProcessor(onlyGen: boolean) {
16
30
  if (!onlyGen) {
17
31
  let WEBPACK_CONFIG: string
18
32
  try {
19
- WEBPACK_CONFIG = require.resolve('@sentio/sdk/lib/webpack.config.js')
33
+ WEBPACK_CONFIG = path.resolve(getPackageRoot('@sentio/sdk'), 'lib/tsup.config.ts')
20
34
  } catch (e) {
21
- // In the future this should not need unless using very old sdk
22
- WEBPACK_CONFIG = path.join(__dirname, 'webpack.config.js')
35
+ console.error(chalk.red("Wrong CLI version for sdk, can't find tsup.config.ts"))
36
+ process.exit(1)
23
37
  }
24
38
  await execStep('yarn tsc -p .', 'Compile')
25
- await execStep('yarn webpack --config=' + WEBPACK_CONFIG, 'Packaging')
39
+ await execStep('yarn tsup --config=' + WEBPACK_CONFIG, 'Packaging')
26
40
  }
27
41
  }
28
42
 
@@ -30,15 +44,15 @@ async function buildProcessorForTarget(onlyGen: boolean) {
30
44
  await codeGenEthersProcessor(path.join('abis', 'evm'))
31
45
 
32
46
  try {
33
- // eslint-disable-next-line @typescript-eslint/no-var-requires
34
- const solanaModule = require('@sentio/sdk-solana/lib/codegen/codegen')
35
- solanaModule.codeGenSolanaProcessor(path.join('abis', 'solana'))
47
+ // @ts-ignore dynamic import
48
+ const codegen = await import('@sentio/sdk-solana/codegen')
49
+ codegen.codeGenSolanaProcessor(path.join('abis', 'solana'))
36
50
  } catch (e) {}
37
51
 
38
52
  try {
39
- // eslint-disable-next-line @typescript-eslint/no-var-requires
40
- const aptosModuole = require('@sentio/sdk-aptos/lib/codegen/codegen')
41
- aptosModuole.codeGenAptosProcessor(path.join('abis', 'aptos'))
53
+ // @ts-ignore dynamic import
54
+ const codegen = await import('@sentio/sdk-aptos/codegen')
55
+ codegen.codeGenAptosProcessor(path.join('abis', 'aptos'))
42
56
  } catch (e) {}
43
57
 
44
58
  if (onlyGen) {
@@ -52,7 +66,7 @@ async function installDeps() {
52
66
 
53
67
  export async function codeGenEthersProcessor(
54
68
  abisDir: string,
55
- ETHERS_TARGET = path.dirname(require.resolve('@sentio/sdk/lib/target-ethers-sentio')),
69
+ ETHERS_TARGET = path.resolve(getPackageRoot('@sentio/sdk'), 'lib/target-ethers-sentio/index.cjs'),
56
70
  outDir = 'src/types/internal'
57
71
  ) {
58
72
  if (!fs.existsSync(abisDir)) {
package/src/cli.ts CHANGED
@@ -6,13 +6,13 @@ import fs from 'fs'
6
6
  import path from 'path'
7
7
 
8
8
  import yaml from 'js-yaml'
9
- import { SentioProjectConfig } from './config'
9
+ import { SentioProjectConfig } from './config.js'
10
10
  import chalk from 'chalk'
11
- import { buildProcessor } from './build'
12
- import { runCreate } from './commands/run-create'
13
- import { runVersion } from './commands/run-version'
14
- import { runLogin } from './commands/run-login'
15
- import { runUpload } from './commands/run-upload'
11
+ import { buildProcessor } from './build.js'
12
+ import { runCreate } from './commands/run-create.js'
13
+ import { runVersion } from './commands/run-version.js'
14
+ import { runLogin } from './commands/run-login.js'
15
+ import { runUpload } from './commands/run-upload.js'
16
16
 
17
17
  const mainDefinitions = [{ name: 'command', defaultOption: true }]
18
18
  const mainOptions = commandLineArgs(mainDefinitions, {
@@ -1,9 +1,9 @@
1
1
  import express from 'express'
2
- import { getAuthConfig, getFinalizedHost } from '../config'
2
+ import { getAuthConfig, getFinalizedHost } from '../config.js'
3
3
  import url, { URL } from 'url'
4
4
  import fetch from 'node-fetch'
5
- import { getCliVersion } from '../utils'
6
- import { WriteKey } from '../key'
5
+ import { getCliVersion } from '../utils.js'
6
+ import { WriteKey } from '../key.js'
7
7
  import chalk from 'chalk'
8
8
  import http from 'http'
9
9
  import os from 'os'
@@ -26,7 +26,7 @@ export function startServer(params: AuthParams) {
26
26
  }
27
27
 
28
28
  app.get('/callback', async (req, res) => {
29
- const fail = function(...args: any[]) {
29
+ const fail = function (...args: any[]) {
30
30
  console.error(chalk.red(args))
31
31
  res.end(args.toString())
32
32
  server.close()
@@ -45,8 +45,8 @@ app.get('/callback', async (req, res) => {
45
45
  fail(`Failed to get access token: ${tokenResRaw.status} ${tokenResRaw.statusText}`)
46
46
  return
47
47
  }
48
- const tokenRes = await tokenResRaw.json()
49
- const accessToken = tokenRes['access_token']
48
+ const tokenRes = (await tokenResRaw.json()) as { access_token: string }
49
+ const accessToken = tokenRes.access_token
50
50
 
51
51
  // check if the account is ready
52
52
  const userResRaw = await getUser(host, accessToken)
@@ -58,7 +58,7 @@ app.get('/callback', async (req, res) => {
58
58
  }
59
59
  return
60
60
  }
61
- const userRes = await userResRaw.json()
61
+ const userRes = (await userResRaw.json()) as { emailVerified: boolean }
62
62
  if (!userRes.emailVerified) {
63
63
  fail('Your account is not verified, please verify your email first')
64
64
  return
@@ -71,11 +71,11 @@ app.get('/callback', async (req, res) => {
71
71
  fail(`Failed to create API key: ${createApiKeyResRaw.status} ${createApiKeyResRaw.statusText}`)
72
72
  return
73
73
  }
74
- const createApiKeyRes = await createApiKeyResRaw.json()
75
- const apiKey = createApiKeyRes['key']
74
+ const createApiKeyRes = (await createApiKeyResRaw.json()) as { key: string }
75
+ const apiKey = createApiKeyRes.key
76
76
  WriteKey(host, apiKey)
77
77
 
78
- res.end("Login success, please go back to CLI to continue")
78
+ res.end('Login success, please go back to CLI to continue')
79
79
  console.log(chalk.green('Login success, new API key: ' + apiKey))
80
80
 
81
81
  server.close()
@@ -101,7 +101,7 @@ async function getToken(host: string, code: string) {
101
101
 
102
102
  async function createApiKey(host: string, name: string, source: string, accessToken: string) {
103
103
  const createApiKeyUrl = new URL('/api/v1/keys', host)
104
- return fetch(createApiKeyUrl, {
104
+ return fetch(createApiKeyUrl.href, {
105
105
  method: 'POST',
106
106
  headers: {
107
107
  Authorization: 'Bearer ' + accessToken,
@@ -117,7 +117,7 @@ async function createApiKey(host: string, name: string, source: string, accessTo
117
117
 
118
118
  async function getUser(host: string, accessToken: string) {
119
119
  const getUserUrl = new URL('/api/v1/users', host)
120
- return fetch(getUserUrl, {
120
+ return fetch(getUserUrl.href, {
121
121
  method: 'GET',
122
122
  headers: {
123
123
  Authorization: 'Bearer ' + accessToken,
@@ -1,11 +1,11 @@
1
1
  import commandLineArgs from 'command-line-args'
2
2
  import commandLineUsage from 'command-line-usage'
3
- import { getAuthConfig, getFinalizedHost } from '../config'
4
- import { startServer } from './login-server'
3
+ import { getAuthConfig, getFinalizedHost } from '../config.js'
4
+ import { startServer } from './login-server.js'
5
5
  import url, { URL } from 'url'
6
6
  import * as crypto from 'crypto'
7
7
  import chalk from 'chalk'
8
- import { WriteKey } from '../key'
8
+ import { WriteKey } from '../key.js'
9
9
  import fetch from 'node-fetch'
10
10
  import open from 'open'
11
11
 
@@ -102,7 +102,7 @@ function sha256(str: string) {
102
102
 
103
103
  async function checkKey(host: string, apiKey: string) {
104
104
  const checkApiKeyUrl = new URL('/api/v1/processors/check_key', host)
105
- return fetch(checkApiKeyUrl, {
105
+ return fetch(checkApiKeyUrl.href, {
106
106
  method: 'GET',
107
107
  headers: {
108
108
  'api-key': apiKey,
@@ -1,16 +1,16 @@
1
1
  import commandLineArgs from 'command-line-args'
2
2
  import commandLineUsage from 'command-line-usage'
3
- import { finalizeHost, FinalizeProjectName, SentioProjectConfig } from '../config'
3
+ import { finalizeHost, FinalizeProjectName, SentioProjectConfig } from '../config.js'
4
4
  import { URL } from 'url'
5
5
  import fetch from 'node-fetch'
6
- import { buildProcessor } from '../build'
6
+ import { buildProcessor } from '../build.js'
7
7
  import chalk from 'chalk'
8
8
  import path from 'path'
9
- import { ReadKey } from '../key'
9
+ import { ReadKey } from '../key.js'
10
10
  import fs from 'fs'
11
11
  import { createHash } from 'crypto'
12
12
  import { execSync } from 'child_process'
13
- import { getSdkVersion } from '../utils'
13
+ import { getSdkVersion } from '../utils.js'
14
14
  import readline from 'readline'
15
15
 
16
16
  export async function runUpload(processorConfig: SentioProjectConfig, argv: string[]) {
@@ -85,7 +85,7 @@ export async function runUpload(processorConfig: SentioProjectConfig, argv: stri
85
85
  async function createProject(options: SentioProjectConfig, apiKey: string) {
86
86
  const url = new URL('/api/v1/projects', options.host)
87
87
  const [ownerName, slug] = options.project.includes('/') ? options.project.split('/') : [undefined, options.project]
88
- return fetch(url, {
88
+ return fetch(url.href, {
89
89
  method: 'POST',
90
90
  headers: {
91
91
  'api-key': apiKey,
@@ -144,8 +144,8 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
144
144
  // get gcs upload url
145
145
  const initUploadResRaw = await initUpload(options.host, apiKey, options.project, getSdkVersion())
146
146
  if (!initUploadResRaw.ok) {
147
- console.error(chalk.red('Failed to get upload url'))
148
- console.error(chalk.red((await initUploadResRaw.json()).message))
147
+ // console.error(chalk.red('Failed to get upload url'))
148
+ console.error(chalk.red(((await initUploadResRaw.json()) as { message: string }).message))
149
149
 
150
150
  if (initUploadResRaw.status === 404) {
151
151
  // create project if not exist
@@ -162,7 +162,7 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
162
162
  const res = await createProject(options, apiKey)
163
163
  if (!res.ok) {
164
164
  console.error(chalk.red('Create Project Failed'))
165
- console.error(chalk.red((await res.json()).message))
165
+ console.error(chalk.red(((await res.json()) as { message: string }).message))
166
166
  return
167
167
  }
168
168
  console.log(chalk.green('Project created'))
@@ -177,8 +177,8 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
177
177
  }
178
178
  return
179
179
  }
180
- const initUploadRes = await initUploadResRaw.json()
181
- const uploadUrl = initUploadRes['url'] as string
180
+ const initUploadRes = (await initUploadResRaw.json()) as { url: string }
181
+ const uploadUrl = initUploadRes.url
182
182
 
183
183
  // do actual uploading
184
184
  const file = fs.createReadStream(PROCESSOR_FILE)
@@ -217,7 +217,10 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
217
217
  if (commitSha) {
218
218
  console.log('\t', chalk.blue('Git commit SHA:'), commitSha)
219
219
  }
220
- const { projectFullSlug, version } = await finishUploadResRaw.json()
220
+ const { projectFullSlug, version } = (await finishUploadResRaw.json()) as {
221
+ projectFullSlug: string
222
+ version: string
223
+ }
221
224
  console.log('\t', chalk.blue('Check status:'), `${options.host}/${projectFullSlug}/datasource`)
222
225
  console.log('\t', chalk.blue('Version:'), version)
223
226
  }
@@ -246,7 +249,7 @@ export async function uploadFile(options: SentioProjectConfig, apiKeyOverride: s
246
249
 
247
250
  async function initUpload(host: string, apiKey: string, projectSlug: string, sdkVersion: string) {
248
251
  const initUploadUrl = new URL(`/api/v1/processors/init_upload`, host)
249
- return fetch(initUploadUrl, {
252
+ return fetch(initUploadUrl.href, {
250
253
  method: 'POST',
251
254
  headers: {
252
255
  'api-key': apiKey,
@@ -269,7 +272,7 @@ async function finishUpload(
269
272
  debug: boolean
270
273
  ) {
271
274
  const finishUploadUrl = new URL(`/api/v1/processors/finish_upload`, host)
272
- return fetch(finishUploadUrl, {
275
+ return fetch(finishUploadUrl.href, {
273
276
  method: 'POST',
274
277
  headers: {
275
278
  'api-key': apiKey,
@@ -1,6 +1,6 @@
1
1
  import commandLineArgs from 'command-line-args'
2
2
  import commandLineUsage from 'command-line-usage'
3
- import { getCliVersion, getSdkVersion } from '../utils'
3
+ import { getCliVersion, getSdkVersion } from '../utils.js'
4
4
  import * as console from 'console'
5
5
 
6
6
  export function runVersion(argv: string[]) {
@@ -0,0 +1,8 @@
1
+ /** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
2
+ export default {
3
+ preset: 'ts-jest/presets/default-esm',
4
+ modulePathIgnorePatterns: ['<rootDir>/dist/'],
5
+ moduleNameMapper: {
6
+ '^(\\.{1,2}/.*)\\.js$': '$1',
7
+ },
8
+ }
@@ -2,6 +2,7 @@
2
2
  "name": "template-aptos",
3
3
  "private": true,
4
4
  "version": "1.0.0",
5
+ "type": "module",
5
6
  "scripts": {
6
7
  "test": "jest",
7
8
  "gen": "sentio gen",
@@ -1,13 +1,13 @@
1
- import { SouffleChefCampaign, CandyMachine } from './types/aptos/souffle'
1
+ import { SouffleChefCampaign, CandyMachine } from './types/aptos/souffle.js'
2
2
 
3
3
  SouffleChefCampaign.bind()
4
4
  .onEntryPullTokenV2((call, ctx) => {
5
- ctx.meter.Counter('pulled').add(call.arguments_typed[3])
5
+ ctx.meter.Counter('pulled').add(call.arguments_decoded[3])
6
6
  })
7
7
  .onEventBurnEnjoyEvent((evt, ctx) => {
8
8
  ctx.meter.Counter('burned').add(1)
9
9
  })
10
10
 
11
11
  CandyMachine.bind().onEntryPullToken((call, ctx) => {
12
- ctx.meter.Counter('pulled').add(call.arguments_typed[2], { coin: call.type_arguments[0] })
12
+ ctx.meter.Counter('pulled').add(call.arguments_decoded[2], { coin: call.type_arguments[0] })
13
13
  })
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "importHelpers": true,
3
4
  "alwaysStrict": true,
4
5
  "sourceMap": true,
5
6
  "target": "esnext",
@@ -7,7 +8,7 @@
7
8
  "noImplicitReturns": true,
8
9
  "noImplicitAny": true,
9
10
  "module": "esnext",
10
- "moduleResolution": "node16",
11
+ "moduleResolution": "nodenext",
11
12
  "strictNullChecks": true,
12
13
  "stripInternal": true,
13
14
  "noFallthroughCasesInSwitch": true,
@@ -16,5 +17,5 @@
16
17
  "rootDir": "./src",
17
18
  "skipLibCheck": true
18
19
  },
19
- "exclude": ["dist"]
20
+ "exclude": ["dist", "jest.config.ts"]
20
21
  }
@@ -0,0 +1,8 @@
1
+ /** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
2
+ export default {
3
+ preset: 'ts-jest/presets/default-esm',
4
+ modulePathIgnorePatterns: ['<rootDir>/dist/'],
5
+ moduleNameMapper: {
6
+ '^(\\.{1,2}/.*)\\.js$': '$1',
7
+ },
8
+ }
@@ -2,6 +2,7 @@
2
2
  "name": "template-evm",
3
3
  "private": true,
4
4
  "version": "1.0.0",
5
+ "type": "module",
5
6
  "scripts": {
6
7
  "test": "jest",
7
8
  "gen": "sentio gen",
@@ -1,7 +1,7 @@
1
1
  import { Counter, Gauge } from '@sentio/sdk'
2
- import { token } from '@sentio/sdk/lib/utils'
3
- import { ERC20Processor } from '@sentio/sdk/lib/builtin/erc20'
4
- import { X2y2Processor } from './types/x2y2'
2
+ import { token } from '@sentio/sdk/utils'
3
+ import { ERC20Processor } from '@sentio/sdk/builtin'
4
+ import { X2y2Processor } from './types/x2y2/index.js'
5
5
 
6
6
  const rewardPerBlock = Gauge.register('reward_per_block', {
7
7
  description: 'rewards for each block grouped by phase',
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "importHelpers": true,
3
4
  "alwaysStrict": true,
4
5
  "sourceMap": true,
5
6
  "target": "esnext",
@@ -7,7 +8,7 @@
7
8
  "noImplicitReturns": true,
8
9
  "noImplicitAny": true,
9
10
  "module": "esnext",
10
- "moduleResolution": "node16",
11
+ "moduleResolution": "nodenext",
11
12
  "strictNullChecks": true,
12
13
  "stripInternal": true,
13
14
  "noFallthroughCasesInSwitch": true,
@@ -16,5 +17,5 @@
16
17
  "rootDir": "./src",
17
18
  "skipLibCheck": true
18
19
  },
19
- "exclude": ["dist"]
20
+ "exclude": ["dist", "jest.config.ts"]
20
21
  }
@@ -0,0 +1,8 @@
1
+ /** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
2
+ export default {
3
+ preset: 'ts-jest/presets/default-esm',
4
+ modulePathIgnorePatterns: ['<rootDir>/dist/'],
5
+ moduleNameMapper: {
6
+ '^(\\.{1,2}/.*)\\.js$': '$1',
7
+ },
8
+ }
@@ -2,6 +2,7 @@
2
2
  "name": "template-raw",
3
3
  "private": true,
4
4
  "version": "1.0.0",
5
+ "type": "module",
5
6
  "scripts": {
6
7
  "test": "jest",
7
8
  "gen": "sentio gen",
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "importHelpers": true,
3
4
  "alwaysStrict": true,
4
5
  "sourceMap": true,
5
6
  "target": "esnext",
@@ -7,7 +8,7 @@
7
8
  "noImplicitReturns": true,
8
9
  "noImplicitAny": true,
9
10
  "module": "esnext",
10
- "moduleResolution": "node16",
11
+ "moduleResolution": "nodenext",
11
12
  "strictNullChecks": true,
12
13
  "stripInternal": true,
13
14
  "noFallthroughCasesInSwitch": true,
@@ -16,5 +17,5 @@
16
17
  "rootDir": "./src",
17
18
  "skipLibCheck": true
18
19
  },
19
- "exclude": ["dist"]
20
+ "exclude": ["dist", "jest.config.ts"]
20
21
  }
@@ -0,0 +1,8 @@
1
+ /** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
2
+ export default {
3
+ preset: 'ts-jest/presets/default-esm',
4
+ modulePathIgnorePatterns: ['<rootDir>/dist/'],
5
+ moduleNameMapper: {
6
+ '^(\\.{1,2}/.*)\\.js$': '$1',
7
+ },
8
+ }
@@ -2,6 +2,7 @@
2
2
  "name": "template-solana",
3
3
  "private": true,
4
4
  "version": "1.0.0",
5
+ "type": "module",
5
6
  "scripts": {
6
7
  "test": "jest",
7
8
  "gen": "sentio gen",
@@ -1,4 +1,4 @@
1
- import { SPLTokenProcessor } from '@sentio/sdk-solana/lib/builtin'
1
+ import { SPLTokenProcessor } from '@sentio/sdk-solana/builtin'
2
2
 
3
3
  SPLTokenProcessor.bind({
4
4
  address: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',