@sentio/cli 2.0.0-rc.1 → 2.0.0-rc.10
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.d.ts +0 -1
- package/lib/build.js +62 -50
- package/lib/build.js.map +1 -1
- package/lib/cli.js +30 -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 -39
- 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-test.d.ts +1 -0
- package/lib/commands/run-test.js +10 -0
- package/lib/commands/run-test.js.map +1 -0
- 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/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/key.js +18 -24
- package/lib/key.js.map +1 -1
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +20 -14
- package/lib/utils.js.map +1 -1
- package/package.json +17 -12
- package/src/build.ts +56 -45
- package/src/cli.ts +14 -10
- package/src/commands/login-server.ts +12 -12
- package/src/commands/run-create.ts +0 -12
- package/src/commands/run-login.ts +4 -4
- package/src/commands/run-test.ts +10 -0
- package/src/commands/run-upload.ts +16 -13
- package/src/commands/run-version.ts +1 -1
- package/src/index.ts +1 -0
- package/src/utils.ts +18 -3
- package/templates/aptos/jest.config.ts +8 -0
- package/templates/aptos/package.json +3 -6
- package/templates/aptos/src/processor.ts +3 -3
- package/templates/aptos/tsconfig.json +4 -3
- package/templates/evm/jest.config.ts +8 -0
- package/templates/evm/package.json +2 -4
- package/templates/evm/src/processor.ts +4 -5
- package/templates/evm/tsconfig.json +4 -3
- package/templates/raw/jest.config.ts +8 -0
- package/templates/raw/package.json +2 -4
- package/templates/raw/tsconfig.json +4 -3
- package/templates/solana/jest.config.ts +8 -0
- package/templates/solana/package.json +3 -6
- package/templates/solana/src/processor.ts +3 -3
- package/templates/solana/tsconfig.json +4 -3
- 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
|
@@ -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,
|
|
@@ -109,16 +109,6 @@ export async function runCreate(argv: string[]) {
|
|
|
109
109
|
const sdkVersion = '^' + (await latestVersion('@sentio/sdk'))
|
|
110
110
|
packageJson.dependencies['@sentio/sdk'] = sdkVersion
|
|
111
111
|
|
|
112
|
-
switch (chainType) {
|
|
113
|
-
case 'aptos':
|
|
114
|
-
packageJson.dependencies['@sentio/sdk-aptos'] = sdkVersion
|
|
115
|
-
break
|
|
116
|
-
case 'solana':
|
|
117
|
-
packageJson.dependencies['@sentio/sdk-solana'] = sdkVersion
|
|
118
|
-
break
|
|
119
|
-
default:
|
|
120
|
-
}
|
|
121
|
-
|
|
122
112
|
const cliVersion = '^' + (await latestVersion('@sentio/cli'))
|
|
123
113
|
packageJson.devDependencies['@sentio/cli'] = cliVersion
|
|
124
114
|
packageJson.name = projectName
|
|
@@ -126,8 +116,6 @@ export async function runCreate(argv: string[]) {
|
|
|
126
116
|
if (options.subproject) {
|
|
127
117
|
delete packageJson.dependencies['@sentio/sdk']
|
|
128
118
|
delete packageJson.devDependencies['@sentio/cli']
|
|
129
|
-
delete packageJson.dependencies['@sentio/sdk-aptos']
|
|
130
|
-
delete packageJson.dependencies['@sentio/sdk-solana']
|
|
131
119
|
}
|
|
132
120
|
|
|
133
121
|
// Don't add directly to avoid deps issue
|
|
@@ -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,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { execSync } from 'child_process'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { getPackageRoot } from '../utils.js'
|
|
4
|
+
|
|
5
|
+
export function runTest(argv: string[]) {
|
|
6
|
+
const defaultJestConfig = path.resolve(getPackageRoot('@sentio/sdk'), 'lib', 'jest.config.js')
|
|
7
|
+
// if config not existed copy that
|
|
8
|
+
const jest = path.resolve(getPackageRoot('jest'), 'bin', 'jest')
|
|
9
|
+
execSync(`NODE_OPTIONS=--experimental-vm-modules node ${jest} ${argv.join(' ')}`, { stdio: 'inherit' })
|
|
10
|
+
}
|
|
@@ -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[]) {
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/src/utils.ts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import fs from 'fs-extra'
|
|
2
2
|
import path from 'path'
|
|
3
|
+
import { createRequire } from 'module'
|
|
4
|
+
import url from 'url'
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url)
|
|
7
|
+
const PACKAGE_JSON = 'package.json'
|
|
8
|
+
|
|
9
|
+
export 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
|
+
return dir
|
|
17
|
+
}
|
|
3
18
|
|
|
4
19
|
export function getCliVersion() {
|
|
5
|
-
const packageJsonPath =
|
|
20
|
+
const packageJsonPath = url.fileURLToPath(new URL('../' + PACKAGE_JSON, import.meta.url))
|
|
6
21
|
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8')
|
|
7
22
|
const packageJson = JSON.parse(packageJsonContent)
|
|
8
23
|
|
|
@@ -11,8 +26,8 @@ export function getCliVersion() {
|
|
|
11
26
|
|
|
12
27
|
export function getSdkVersion() {
|
|
13
28
|
try {
|
|
14
|
-
const packageJsonPath =
|
|
15
|
-
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8')
|
|
29
|
+
const packageJsonPath = getPackageRoot('@sentio/sdk')
|
|
30
|
+
const packageJsonContent = fs.readFileSync(path.join(packageJsonPath, PACKAGE_JSON), 'utf-8')
|
|
16
31
|
const packageJson = JSON.parse(packageJsonContent)
|
|
17
32
|
return packageJson.version
|
|
18
33
|
} catch (e) {
|
|
@@ -2,20 +2,17 @@
|
|
|
2
2
|
"name": "template-aptos",
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"test": "
|
|
7
|
+
"test": "sentio test",
|
|
7
8
|
"gen": "sentio gen",
|
|
8
9
|
"build": "sentio build",
|
|
9
10
|
"upload": "sentio upload"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
|
-
"@sentio/sdk": "^2.0.0-development"
|
|
13
|
-
"@sentio/sdk-aptos": "^2.0.0-development"
|
|
13
|
+
"@sentio/sdk": "^2.0.0-development"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/jest": "^29.0.0",
|
|
17
|
-
"jest": "^29.0.0",
|
|
18
|
-
"ts-jest": "^29.0.0",
|
|
19
16
|
"typescript": "^4.9.0"
|
|
20
17
|
}
|
|
21
18
|
}
|
|
@@ -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,14 +8,14 @@
|
|
|
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,
|
|
14
15
|
"noEmitOnError": true,
|
|
15
|
-
"outDir": "dist",
|
|
16
16
|
"rootDir": "./src",
|
|
17
|
+
"outDir": "./dist",
|
|
17
18
|
"skipLibCheck": true
|
|
18
19
|
},
|
|
19
|
-
"exclude": ["dist"]
|
|
20
|
+
"exclude": ["dist", "jest.config.ts"]
|
|
20
21
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"name": "template-evm",
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"test": "
|
|
7
|
+
"test": "sentio test",
|
|
7
8
|
"gen": "sentio gen",
|
|
8
9
|
"build": "sentio build",
|
|
9
10
|
"upload": "sentio upload"
|
|
@@ -12,9 +13,6 @@
|
|
|
12
13
|
"@sentio/sdk": "^2.0.0-development"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
|
-
"@types/jest": "^29.0.0",
|
|
16
|
-
"jest": "^29.0.0",
|
|
17
|
-
"ts-jest": "^29.0.0",
|
|
18
16
|
"typescript": "^4.9.0"
|
|
19
17
|
}
|
|
20
18
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Counter, Gauge } from '@sentio/sdk'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { X2y2Processor } from './types/x2y2'
|
|
2
|
+
import { ERC20Processor } from '@sentio/sdk/eth/builtin'
|
|
3
|
+
import { X2y2Processor } from './types/x2y2/index.js'
|
|
5
4
|
|
|
6
5
|
const rewardPerBlock = Gauge.register('reward_per_block', {
|
|
7
6
|
description: 'rewards for each block grouped by phase',
|
|
@@ -11,7 +10,7 @@ const tokenCounter = Counter.register('token')
|
|
|
11
10
|
|
|
12
11
|
X2y2Processor.bind({ address: '0xB329e39Ebefd16f40d38f07643652cE17Ca5Bac1' }).onBlockInterval(async (_, ctx) => {
|
|
13
12
|
const phase = (await ctx.contract.currentPhase()).toString()
|
|
14
|
-
const reward =
|
|
13
|
+
const reward = (await ctx.contract.rewardPerBlockForStaking()).scaleDown(18)
|
|
15
14
|
rewardPerBlock.record(ctx, reward, { phase })
|
|
16
15
|
})
|
|
17
16
|
|
|
@@ -22,7 +21,7 @@ const filter = ERC20Processor.filters.Transfer(
|
|
|
22
21
|
|
|
23
22
|
ERC20Processor.bind({ address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9' }).onEventTransfer(
|
|
24
23
|
async (event, ctx) => {
|
|
25
|
-
const val =
|
|
24
|
+
const val = event.args.value.scaleDown(18)
|
|
26
25
|
tokenCounter.add(ctx, val)
|
|
27
26
|
},
|
|
28
27
|
filter // filter is an optional parameter
|
|
@@ -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,14 +8,14 @@
|
|
|
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,
|
|
14
15
|
"noEmitOnError": true,
|
|
15
|
-
"outDir": "dist",
|
|
16
16
|
"rootDir": "./src",
|
|
17
|
+
"outDir": "./dist",
|
|
17
18
|
"skipLibCheck": true
|
|
18
19
|
},
|
|
19
|
-
"exclude": ["dist"]
|
|
20
|
+
"exclude": ["dist", "jest.config.ts"]
|
|
20
21
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"name": "template-raw",
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"test": "
|
|
7
|
+
"test": "sentio test",
|
|
7
8
|
"gen": "sentio gen",
|
|
8
9
|
"build": "sentio build",
|
|
9
10
|
"upload": "sentio upload"
|
|
@@ -12,9 +13,6 @@
|
|
|
12
13
|
"@sentio/sdk": "^2.0.0-development"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
|
-
"@types/jest": "^29.0.0",
|
|
16
|
-
"jest": "^29.0.0",
|
|
17
|
-
"ts-jest": "^29.0.0",
|
|
18
16
|
"typescript": "^4.9.0"
|
|
19
17
|
}
|
|
20
18
|
}
|
|
@@ -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,14 +8,14 @@
|
|
|
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,
|
|
14
15
|
"noEmitOnError": true,
|
|
15
|
-
"outDir": "dist",
|
|
16
16
|
"rootDir": "./src",
|
|
17
|
+
"outDir": "./dist",
|
|
17
18
|
"skipLibCheck": true
|
|
18
19
|
},
|
|
19
|
-
"exclude": ["dist"]
|
|
20
|
+
"exclude": ["dist", "jest.config.ts"]
|
|
20
21
|
}
|
|
@@ -2,20 +2,17 @@
|
|
|
2
2
|
"name": "template-solana",
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"test": "
|
|
7
|
+
"test": "sentio test",
|
|
7
8
|
"gen": "sentio gen",
|
|
8
9
|
"build": "sentio build",
|
|
9
10
|
"upload": "sentio upload"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
|
-
"@sentio/sdk": "^2.0.0-development"
|
|
13
|
-
"@sentio/sdk-solana": "^2.0.0-development"
|
|
13
|
+
"@sentio/sdk": "^2.0.0-development"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/jest": "^29.0.0",
|
|
17
|
-
"jest": "^29.0.0",
|
|
18
|
-
"ts-jest": "^29.0.0",
|
|
19
16
|
"typescript": "^4.9.0"
|
|
20
17
|
}
|
|
21
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SPLTokenProcessor } from '@sentio/sdk
|
|
1
|
+
import { SPLTokenProcessor } from '@sentio/sdk/solana/builtin'
|
|
2
2
|
|
|
3
3
|
SPLTokenProcessor.bind({
|
|
4
4
|
address: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',
|
|
@@ -6,11 +6,11 @@ SPLTokenProcessor.bind({
|
|
|
6
6
|
})
|
|
7
7
|
.onMintTo((data, ctx) => {
|
|
8
8
|
if (data.mint === '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs') {
|
|
9
|
-
ctx.meter.Counter('totalWeth_supply').add(data.amount
|
|
9
|
+
ctx.meter.Counter('totalWeth_supply').add(data.amount)
|
|
10
10
|
}
|
|
11
11
|
})
|
|
12
12
|
.onBurn((data, ctx) => {
|
|
13
13
|
if (data.mint === '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs') {
|
|
14
|
-
ctx.meter.Counter('totalWeth_supply').sub(data.amount
|
|
14
|
+
ctx.meter.Counter('totalWeth_supply').sub(data.amount)
|
|
15
15
|
}
|
|
16
16
|
})
|
|
@@ -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,14 +8,14 @@
|
|
|
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,
|
|
14
15
|
"noEmitOnError": true,
|
|
15
|
-
"outDir": "dist",
|
|
16
16
|
"rootDir": "./src",
|
|
17
|
+
"outDir": "./dist",
|
|
17
18
|
"skipLibCheck": true
|
|
18
19
|
},
|
|
19
|
-
"exclude": ["dist"]
|
|
20
|
+
"exclude": ["dist", "jest.config.ts"]
|
|
20
21
|
}
|
package/lib/webpack.config.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
entry: {
|
|
6
|
-
lib: './src/processor.ts',
|
|
7
|
-
},
|
|
8
|
-
devtool: 'inline-source-map',
|
|
9
|
-
module: {
|
|
10
|
-
rules: [
|
|
11
|
-
{
|
|
12
|
-
test: /\.tsx?$/,
|
|
13
|
-
use: 'ts-loader',
|
|
14
|
-
exclude: /node_modules/,
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
resolve: {
|
|
19
|
-
extensions: ['.ts', '.js'],
|
|
20
|
-
},
|
|
21
|
-
output: {
|
|
22
|
-
filename: '[name].js',
|
|
23
|
-
path: path.resolve(process.cwd(), 'dist'),
|
|
24
|
-
},
|
|
25
|
-
target: 'node',
|
|
26
|
-
mode: 'production',
|
|
27
|
-
externals: [
|
|
28
|
-
{
|
|
29
|
-
protobufjs: 'commonjs2 protobufjs',
|
|
30
|
-
aptos: 'commonjs2 aptos-sdk',
|
|
31
|
-
ethers: 'commonjs2 ethers',
|
|
32
|
-
bs58: 'commonjs2 bs58',
|
|
33
|
-
"bignumber.js": 'commonjs2 bignumber.js',
|
|
34
|
-
'bn.js': 'commonjs2 bn.js',
|
|
35
|
-
'csv-parse': 'commonjs2 csv-parse',
|
|
36
|
-
},
|
|
37
|
-
function ({ context, request }, callback) {
|
|
38
|
-
if (/^@(ethersproject|solana|project-serum|nice-grpc).*$/.test(request)) {
|
|
39
|
-
return callback(null, 'commonjs ' + request)
|
|
40
|
-
}
|
|
41
|
-
if (/^nice-grpc.*$/.test(request)) {
|
|
42
|
-
return callback(null, 'commonjs ' + request)
|
|
43
|
-
}
|
|
44
|
-
if (/^@sentio\/(sdk|runtime|base|protos|bigdecimal).*$/.test(request)) {
|
|
45
|
-
return callback(null, 'commonjs ' + request)
|
|
46
|
-
}
|
|
47
|
-
callback()
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
}
|