@sentio/cli 1.0.0-development

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 (61) hide show
  1. package/lib/build.d.ts +2 -0
  2. package/lib/build.js +82 -0
  3. package/lib/build.js.map +1 -0
  4. package/lib/cli.d.ts +2 -0
  5. package/lib/cli.js +186 -0
  6. package/lib/cli.js.map +1 -0
  7. package/lib/commands/login-server.d.ts +7 -0
  8. package/lib/commands/login-server.js +133 -0
  9. package/lib/commands/login-server.js.map +1 -0
  10. package/lib/commands/run-create.d.ts +1 -0
  11. package/lib/commands/run-create.js +112 -0
  12. package/lib/commands/run-create.js.map +1 -0
  13. package/lib/commands/run-login.d.ts +1 -0
  14. package/lib/commands/run-login.js +136 -0
  15. package/lib/commands/run-login.js.map +1 -0
  16. package/lib/commands/run-version.d.ts +1 -0
  17. package/lib/commands/run-version.js +39 -0
  18. package/lib/commands/run-version.js.map +1 -0
  19. package/lib/config.d.ts +14 -0
  20. package/lib/config.js +64 -0
  21. package/lib/config.js.map +1 -0
  22. package/lib/key.d.ts +2 -0
  23. package/lib/key.js +44 -0
  24. package/lib/key.js.map +1 -0
  25. package/lib/upload.d.ts +2 -0
  26. package/lib/upload.js +189 -0
  27. package/lib/upload.js.map +1 -0
  28. package/lib/utils.d.ts +1 -0
  29. package/lib/utils.js +16 -0
  30. package/lib/utils.js.map +1 -0
  31. package/lib/webpack.config.js +47 -0
  32. package/package.json +63 -0
  33. package/src/build.ts +96 -0
  34. package/src/cli.ts +184 -0
  35. package/src/commands/login-server.ts +119 -0
  36. package/src/commands/run-create.ts +116 -0
  37. package/src/commands/run-login.ts +111 -0
  38. package/src/commands/run-version.ts +32 -0
  39. package/src/config.ts +72 -0
  40. package/src/key.ts +43 -0
  41. package/src/upload.ts +214 -0
  42. package/src/utils.ts +10 -0
  43. package/src/webpack.config.js +47 -0
  44. package/templates/aptos/abis/aptos/souffle.json +389 -0
  45. package/templates/aptos/jest.config.js +7 -0
  46. package/templates/aptos/package.json +20 -0
  47. package/templates/aptos/sentio.yaml +1 -0
  48. package/templates/aptos/src/processor.ts +13 -0
  49. package/templates/aptos/tsconfig.json +20 -0
  50. package/templates/evm/abis/evm/x2y2.json +296 -0
  51. package/templates/evm/jest.config.js +7 -0
  52. package/templates/evm/package.json +20 -0
  53. package/templates/evm/sentio.yaml +3 -0
  54. package/templates/evm/src/processor.ts +29 -0
  55. package/templates/evm/tsconfig.json +20 -0
  56. package/templates/raw/jest.config.js +7 -0
  57. package/templates/raw/package.json +20 -0
  58. package/templates/raw/sentio.yaml +3 -0
  59. package/templates/raw/src/processor.ts +0 -0
  60. package/templates/raw/tsconfig.json +20 -0
  61. package/templates/raw/yarn.lock +4095 -0
@@ -0,0 +1,296 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ { "internalType": "address", "name": "_x2y2Token", "type": "address" },
5
+ {
6
+ "internalType": "address",
7
+ "name": "_tokenSplitter",
8
+ "type": "address"
9
+ },
10
+ { "internalType": "uint256", "name": "_startBlock", "type": "uint256" },
11
+ {
12
+ "internalType": "uint256[]",
13
+ "name": "_rewardsPerBlockForStaking",
14
+ "type": "uint256[]"
15
+ },
16
+ {
17
+ "internalType": "uint256[]",
18
+ "name": "_rewardsPerBlockForOthers",
19
+ "type": "uint256[]"
20
+ },
21
+ {
22
+ "internalType": "uint256[]",
23
+ "name": "_periodLengthesInBlocks",
24
+ "type": "uint256[]"
25
+ },
26
+ { "internalType": "uint256", "name": "_numberPeriods", "type": "uint256" }
27
+ ],
28
+ "stateMutability": "nonpayable",
29
+ "type": "constructor"
30
+ },
31
+ {
32
+ "anonymous": false,
33
+ "inputs": [
34
+ {
35
+ "indexed": true,
36
+ "internalType": "address",
37
+ "name": "user",
38
+ "type": "address"
39
+ },
40
+ {
41
+ "indexed": false,
42
+ "internalType": "uint256",
43
+ "name": "harvestedAmount",
44
+ "type": "uint256"
45
+ }
46
+ ],
47
+ "name": "Compound",
48
+ "type": "event"
49
+ },
50
+ {
51
+ "anonymous": false,
52
+ "inputs": [
53
+ {
54
+ "indexed": true,
55
+ "internalType": "address",
56
+ "name": "user",
57
+ "type": "address"
58
+ },
59
+ {
60
+ "indexed": false,
61
+ "internalType": "uint256",
62
+ "name": "amount",
63
+ "type": "uint256"
64
+ },
65
+ {
66
+ "indexed": false,
67
+ "internalType": "uint256",
68
+ "name": "harvestedAmount",
69
+ "type": "uint256"
70
+ }
71
+ ],
72
+ "name": "Deposit",
73
+ "type": "event"
74
+ },
75
+ {
76
+ "anonymous": false,
77
+ "inputs": [
78
+ {
79
+ "indexed": true,
80
+ "internalType": "uint256",
81
+ "name": "currentPhase",
82
+ "type": "uint256"
83
+ },
84
+ {
85
+ "indexed": false,
86
+ "internalType": "uint256",
87
+ "name": "startBlock",
88
+ "type": "uint256"
89
+ },
90
+ {
91
+ "indexed": false,
92
+ "internalType": "uint256",
93
+ "name": "rewardPerBlockForStaking",
94
+ "type": "uint256"
95
+ },
96
+ {
97
+ "indexed": false,
98
+ "internalType": "uint256",
99
+ "name": "rewardPerBlockForOthers",
100
+ "type": "uint256"
101
+ }
102
+ ],
103
+ "name": "NewRewardsPerBlock",
104
+ "type": "event"
105
+ },
106
+ {
107
+ "anonymous": false,
108
+ "inputs": [
109
+ {
110
+ "indexed": true,
111
+ "internalType": "address",
112
+ "name": "user",
113
+ "type": "address"
114
+ },
115
+ {
116
+ "indexed": false,
117
+ "internalType": "uint256",
118
+ "name": "amount",
119
+ "type": "uint256"
120
+ },
121
+ {
122
+ "indexed": false,
123
+ "internalType": "uint256",
124
+ "name": "harvestedAmount",
125
+ "type": "uint256"
126
+ }
127
+ ],
128
+ "name": "Withdraw",
129
+ "type": "event"
130
+ },
131
+ {
132
+ "inputs": [],
133
+ "name": "NUMBER_PERIODS",
134
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
135
+ "stateMutability": "view",
136
+ "type": "function"
137
+ },
138
+ {
139
+ "inputs": [],
140
+ "name": "PRECISION_FACTOR",
141
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
142
+ "stateMutability": "view",
143
+ "type": "function"
144
+ },
145
+ {
146
+ "inputs": [],
147
+ "name": "START_BLOCK",
148
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
149
+ "stateMutability": "view",
150
+ "type": "function"
151
+ },
152
+ {
153
+ "inputs": [],
154
+ "name": "accTokenPerShare",
155
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
156
+ "stateMutability": "view",
157
+ "type": "function"
158
+ },
159
+ {
160
+ "inputs": [{ "internalType": "address", "name": "user", "type": "address" }],
161
+ "name": "calculatePendingRewards",
162
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
163
+ "stateMutability": "view",
164
+ "type": "function"
165
+ },
166
+ {
167
+ "inputs": [],
168
+ "name": "currentPhase",
169
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
170
+ "stateMutability": "view",
171
+ "type": "function"
172
+ },
173
+ {
174
+ "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
175
+ "name": "deposit",
176
+ "outputs": [],
177
+ "stateMutability": "nonpayable",
178
+ "type": "function"
179
+ },
180
+ {
181
+ "inputs": [],
182
+ "name": "endBlock",
183
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
184
+ "stateMutability": "view",
185
+ "type": "function"
186
+ },
187
+ {
188
+ "inputs": [],
189
+ "name": "harvestAndCompound",
190
+ "outputs": [],
191
+ "stateMutability": "nonpayable",
192
+ "type": "function"
193
+ },
194
+ {
195
+ "inputs": [],
196
+ "name": "lastRewardBlock",
197
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
198
+ "stateMutability": "view",
199
+ "type": "function"
200
+ },
201
+ {
202
+ "inputs": [],
203
+ "name": "rewardPerBlockForOthers",
204
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
205
+ "stateMutability": "view",
206
+ "type": "function"
207
+ },
208
+ {
209
+ "inputs": [],
210
+ "name": "rewardPerBlockForStaking",
211
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
212
+ "stateMutability": "view",
213
+ "type": "function"
214
+ },
215
+ {
216
+ "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
217
+ "name": "stakingPeriod",
218
+ "outputs": [
219
+ {
220
+ "internalType": "uint256",
221
+ "name": "rewardPerBlockForStaking",
222
+ "type": "uint256"
223
+ },
224
+ {
225
+ "internalType": "uint256",
226
+ "name": "rewardPerBlockForOthers",
227
+ "type": "uint256"
228
+ },
229
+ {
230
+ "internalType": "uint256",
231
+ "name": "periodLengthInBlock",
232
+ "type": "uint256"
233
+ }
234
+ ],
235
+ "stateMutability": "view",
236
+ "type": "function"
237
+ },
238
+ {
239
+ "inputs": [],
240
+ "name": "tokenSplitter",
241
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
242
+ "stateMutability": "view",
243
+ "type": "function"
244
+ },
245
+ {
246
+ "inputs": [],
247
+ "name": "totalAmountStaked",
248
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
249
+ "stateMutability": "view",
250
+ "type": "function"
251
+ },
252
+ {
253
+ "inputs": [],
254
+ "name": "updatePool",
255
+ "outputs": [],
256
+ "stateMutability": "nonpayable",
257
+ "type": "function"
258
+ },
259
+ {
260
+ "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
261
+ "name": "userInfo",
262
+ "outputs": [
263
+ { "internalType": "uint256", "name": "amount", "type": "uint256" },
264
+ { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" }
265
+ ],
266
+ "stateMutability": "view",
267
+ "type": "function"
268
+ },
269
+ {
270
+ "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
271
+ "name": "withdraw",
272
+ "outputs": [],
273
+ "stateMutability": "nonpayable",
274
+ "type": "function"
275
+ },
276
+ {
277
+ "inputs": [],
278
+ "name": "withdrawAll",
279
+ "outputs": [],
280
+ "stateMutability": "nonpayable",
281
+ "type": "function"
282
+ },
283
+ {
284
+ "inputs": [],
285
+ "name": "x2y2Token",
286
+ "outputs": [
287
+ {
288
+ "internalType": "contract IMintableERC20",
289
+ "name": "",
290
+ "type": "address"
291
+ }
292
+ ],
293
+ "stateMutability": "view",
294
+ "type": "function"
295
+ }
296
+ ]
@@ -0,0 +1,7 @@
1
+ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2
+
3
+ module.exports = {
4
+ preset: 'ts-jest',
5
+ testEnvironment: 'node',
6
+ modulePathIgnorePatterns: ["<rootDir>/dist/"]
7
+ };
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "template-evm",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "scripts": {
6
+ "test": "jest",
7
+ "gen": "sentio gen",
8
+ "build": "sentio build",
9
+ "upload": "sentio upload"
10
+ },
11
+ "dependencies": {
12
+ "@sentio/sdk": "^1.0.0-development"
13
+ },
14
+ "devDependencies": {
15
+ "@types/jest": "^29.0.0",
16
+ "jest": "^29.0.0",
17
+ "ts-jest": "^29.0.0",
18
+ "typescript": "^4.7.2"
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ # Project name could be $org_or_user/$project_name or $project_name
2
+ # If latter, will be treated the owner as api key's owner
3
+ project: default
@@ -0,0 +1,29 @@
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'
5
+
6
+ const rewardPerBlock = Gauge.register('reward_per_block', {
7
+ description: 'rewards for each block grouped by phase',
8
+ unit: 'x2y2',
9
+ })
10
+ const tokenCounter = Counter.register('token')
11
+
12
+ X2y2Processor.bind({ address: '0xB329e39Ebefd16f40d38f07643652cE17Ca5Bac1' }).onBlockInterval(async (_, ctx) => {
13
+ const phase = (await ctx.contract.currentPhase()).toString()
14
+ const reward = token.scaleDown(await ctx.contract.rewardPerBlockForStaking(), 18)
15
+ rewardPerBlock.record(ctx, reward, { phase })
16
+ })
17
+
18
+ const filter = ERC20Processor.filters.Transfer(
19
+ '0x0000000000000000000000000000000000000000',
20
+ '0xb329e39ebefd16f40d38f07643652ce17ca5bac1'
21
+ )
22
+
23
+ ERC20Processor.bind({ address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9' }).onEventTransfer(
24
+ async (event, ctx) => {
25
+ const val = token.scaleDown(event.args.value, 18)
26
+ tokenCounter.add(ctx, val)
27
+ },
28
+ filter // filter is an optional parameter
29
+ )
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "alwaysStrict": true,
4
+ "sourceMap": true,
5
+ "target": "esnext",
6
+ "esModuleInterop": true,
7
+ "noImplicitReturns": true,
8
+ "noImplicitAny": true,
9
+ "module": "commonjs",
10
+ "moduleResolution": "node",
11
+ "strictNullChecks": true,
12
+ "stripInternal": true,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "noEmitOnError": true,
15
+ "outDir": "dist",
16
+ "rootDir": "./src",
17
+ "skipLibCheck": true
18
+ },
19
+ "exclude": ["dist"]
20
+ }
@@ -0,0 +1,7 @@
1
+ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2
+
3
+ module.exports = {
4
+ preset: 'ts-jest',
5
+ testEnvironment: 'node',
6
+ modulePathIgnorePatterns: ["<rootDir>/dist/"]
7
+ };
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "template-raw",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "scripts": {
6
+ "test": "jest",
7
+ "gen": "sentio gen",
8
+ "build": "sentio build",
9
+ "upload": "sentio upload"
10
+ },
11
+ "dependencies": {
12
+ "@sentio/sdk": "^1.0.0-development"
13
+ },
14
+ "devDependencies": {
15
+ "@types/jest": "^29.0.0",
16
+ "jest": "^29.0.0",
17
+ "ts-jest": "^29.0.0",
18
+ "typescript": "^4.7.2"
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ # Project name could be $org_or_user/$project_name or $project_name
2
+ # If latter, will be treated the owner as api key's owner
3
+ project: default
File without changes
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "alwaysStrict": true,
4
+ "sourceMap": true,
5
+ "target": "esnext",
6
+ "esModuleInterop": true,
7
+ "noImplicitReturns": true,
8
+ "noImplicitAny": true,
9
+ "module": "commonjs",
10
+ "moduleResolution": "node",
11
+ "strictNullChecks": true,
12
+ "stripInternal": true,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "noEmitOnError": true,
15
+ "outDir": "dist",
16
+ "rootDir": "./src",
17
+ "skipLibCheck": true
18
+ },
19
+ "exclude": ["dist"]
20
+ }