@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.
- package/lib/build.js +37 -32
- package/lib/build.js.map +1 -1
- package/lib/cli.js +25 -28
- package/lib/cli.js.map +1 -1
- package/lib/commands/login-server.js +31 -36
- package/lib/commands/login-server.js.map +1 -1
- package/lib/commands/run-create.js +23 -28
- package/lib/commands/run-create.js.map +1 -1
- package/lib/commands/run-login.js +28 -33
- package/lib/commands/run-login.js.map +1 -1
- package/lib/commands/run-upload.d.ts +1 -1
- package/lib/commands/run-upload.js +62 -68
- package/lib/commands/run-upload.js.map +1 -1
- package/lib/commands/run-version.js +9 -14
- package/lib/commands/run-version.js.map +1 -1
- package/lib/config.js +4 -11
- package/lib/config.js.map +1 -1
- package/lib/key.js +18 -24
- package/lib/key.js.map +1 -1
- package/lib/utils.js +7 -13
- package/lib/utils.js.map +1 -1
- package/package.json +8 -9
- package/src/build.ts +25 -11
- package/src/cli.ts +6 -6
- package/src/commands/login-server.ts +12 -12
- package/src/commands/run-login.ts +4 -4
- package/src/commands/run-upload.ts +16 -13
- package/src/commands/run-version.ts +1 -1
- package/templates/aptos/jest.config.ts +8 -0
- package/templates/aptos/package.json +1 -0
- package/templates/aptos/src/processor.ts +3 -3
- package/templates/aptos/tsconfig.json +3 -2
- package/templates/evm/jest.config.ts +8 -0
- package/templates/evm/package.json +1 -0
- package/templates/evm/src/processor.ts +3 -3
- package/templates/evm/tsconfig.json +3 -2
- package/templates/raw/jest.config.ts +8 -0
- package/templates/raw/package.json +1 -0
- package/templates/raw/tsconfig.json +3 -2
- package/templates/solana/jest.config.ts +8 -0
- package/templates/solana/package.json +1 -0
- package/templates/solana/src/processor.ts +1 -1
- package/templates/solana/tsconfig.json +3 -2
- package/lib/webpack.config.js +0 -50
- package/src/webpack.config.js +0 -50
- package/templates/aptos/jest.config.js +0 -7
- package/templates/evm/jest.config.js +0 -7
- package/templates/raw/jest.config.js +0 -7
- package/templates/raw/yarn.lock +0 -4095
- package/templates/solana/jest.config.js +0 -7
- package/templates/solana/yarn.lock +0 -4918
package/lib/key.js
CHANGED
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
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 (
|
|
18
|
-
const content =
|
|
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
|
-
|
|
20
|
+
fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
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 =
|
|
32
|
-
if (
|
|
33
|
-
const content =
|
|
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":"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
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
|
-
|
|
14
|
-
function getSdkVersion() {
|
|
9
|
+
export function getSdkVersion() {
|
|
15
10
|
try {
|
|
16
11
|
const packageJsonPath = require.resolve('@sentio/sdk/package.json');
|
|
17
|
-
const packageJsonContent =
|
|
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":"
|
|
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
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"version": "2.0.0-rc.2",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"compile": "tsc -p .
|
|
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": "^
|
|
22
|
-
"node-fetch": "
|
|
22
|
+
"latest-version": "^7.0.0",
|
|
23
|
+
"node-fetch": "^3.3.0",
|
|
23
24
|
"open": "^8.4.0",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
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 =
|
|
33
|
+
WEBPACK_CONFIG = path.resolve(getPackageRoot('@sentio/sdk'), 'lib/tsup.config.ts')
|
|
20
34
|
} catch (e) {
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
-
//
|
|
34
|
-
const
|
|
35
|
-
|
|
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
|
-
//
|
|
40
|
-
const
|
|
41
|
-
|
|
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.
|
|
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
|
|
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
|
|
74
|
+
const createApiKeyRes = (await createApiKeyResRaw.json()) as { key: string }
|
|
75
|
+
const apiKey = createApiKeyRes.key
|
|
76
76
|
WriteKey(host, apiKey)
|
|
77
77
|
|
|
78
|
-
res.end(
|
|
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
|
|
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[]) {
|
|
@@ -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.
|
|
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.
|
|
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": "
|
|
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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Counter, Gauge } from '@sentio/sdk'
|
|
2
|
-
import { token } from '@sentio/sdk/
|
|
3
|
-
import { ERC20Processor } from '@sentio/sdk/
|
|
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": "
|
|
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
|
}
|
|
@@ -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": "
|
|
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
|
}
|