@sentio/cli 3.5.1-rc.1 → 3.5.1-rc.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/cli",
3
- "version": "3.5.1-rc.1",
3
+ "version": "3.5.1-rc.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
package/src/abi.ts CHANGED
@@ -3,7 +3,7 @@ import process from 'process'
3
3
  import path from 'path'
4
4
  import fs from 'fs-extra'
5
5
  import fetch from 'node-fetch'
6
- import { AptosChainId, ChainId, StarknetChainId, SuiChainId } from '@sentio/chain'
6
+ import { AptosChainId, ChainId, SuiChainId } from '@sentio/chain'
7
7
 
8
8
  import type { Aptos } from '@aptos-labs/ts-sdk'
9
9
  import type { IotaClient } from '@iota/iota-sdk/client'
@@ -11,7 +11,6 @@ import type { SuiJsonRpcClient } from '@mysten/sui/jsonRpc'
11
11
  import { ReadKey } from './key.js'
12
12
  import { Auth } from './commands/upload.js'
13
13
  import { getApiUrl } from './utils.js'
14
- import type { RpcProvider as Starknet } from 'starknet'
15
14
 
16
15
  export async function getABI(
17
16
  chain: ChainId,
@@ -135,30 +134,6 @@ export async function getABI(
135
134
  console.log('aptos module not loaded')
136
135
  }
137
136
 
138
- // starknet
139
- try {
140
- const Starknet = (await import('starknet')).RpcProvider
141
- let starknetClient: Starknet | undefined
142
-
143
- switch (chain) {
144
- case StarknetChainId.STARKNET_MAINNET:
145
- starknetClient = new Starknet({
146
- nodeUrl: 'https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_8/8sD5yitBslIYCPFzSq_Q1ObJHqPlZxFw'
147
- })
148
- break
149
- case StarknetChainId.STARKNET_SEPOLIA:
150
- starknetClient = new Starknet({
151
- nodeUrl: 'https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/v0_8/8sD5yitBslIYCPFzSq_Q1ObJHqPlZxFw'
152
- })
153
- break
154
- }
155
- if (starknetClient) {
156
- const clazz = await starknetClient.getClassAt(address, 'latest')
157
- return { abi: clazz.abi, name }
158
- }
159
- } catch (e) {
160
- console.log('starknet module not loaded')
161
- }
162
137
 
163
138
  // ethereum
164
139
  try {
@@ -206,7 +181,7 @@ export async function getABI(
206
181
 
207
182
  export function getABIFilePath(chain: string, name: string, address?: string, folder?: string): string {
208
183
  let subpath
209
- let filename = name ?? address
184
+ const filename = name ?? address
210
185
  switch (chain) {
211
186
  case AptosChainId.APTOS_MAINNET:
212
187
  subpath = 'aptos'
@@ -235,14 +210,6 @@ export function getABIFilePath(chain: string, name: string, address?: string, fo
235
210
  case SuiChainId.IOTA_TESTNET:
236
211
  subpath = 'iota/testnet'
237
212
  break
238
- case StarknetChainId.STARKNET_MAINNET:
239
- subpath = 'starknet'
240
- filename = name && address ? `${name}-${address}` : (name ?? address)
241
- break
242
- case StarknetChainId.STARKNET_SEPOLIA:
243
- subpath = 'starknet/sepolia'
244
- filename = name && address ? `${name}-${address}` : (name ?? address)
245
- break
246
213
  default:
247
214
  subpath = 'eth'
248
215
  }
@@ -13,7 +13,7 @@ import readline from 'readline'
13
13
  import JSZip from 'jszip'
14
14
  import { UserInfo } from '../../../protos/lib/service/common/protos/common.js'
15
15
  import { CommandOptionsType } from './types.js'
16
- import { Auth, DefaultBatchUploader, IPFSBatchUploader, WalrusBatchUploader } from '../uploader.js'
16
+ import { Auth, DefaultBatchUploader, FileType, IPFSBatchUploader, WalrusBatchUploader } from '../uploader.js'
17
17
  export { type Auth } from '../uploader.js'
18
18
 
19
19
  function myParseInt(value: string, dummyPrevious: number): number {
@@ -322,6 +322,15 @@ async function checkOrCreateProject(options: YamlProjectConfig, auth: Auth) {
322
322
  )
323
323
  process.exit(1)
324
324
  }
325
+ if (!options.sentioNetwork && project.sentioNetwork === true) {
326
+ console.error(
327
+ chalk.red(
328
+ `Project ${project?.slug} is a Sentio Network project. Please add the --sentio-network flag when uploading.\n` +
329
+ `Example: sentio upload --sentio-network testnet`
330
+ )
331
+ )
332
+ process.exit(1)
333
+ }
325
334
  return project?.id
326
335
  }
327
336
 
@@ -421,6 +430,26 @@ export async function uploadFile(
421
430
  ? new IPFSBatchUploader(config, auth)
422
431
  : new DefaultBatchUploader(config, auth)
423
432
 
433
+ // Initialize upload and handle confirmation
434
+ const fileTypes: Record<string, number> = {
435
+ source: FileType.SOURCE,
436
+ code: FileType.PROCESSOR
437
+ }
438
+ const initResponse = await uploader.initUpload(fileTypes)
439
+
440
+ if (initResponse.warning) {
441
+ console.log(chalk.yellow(initResponse.warning))
442
+ }
443
+
444
+ if (initResponse.replacing_version && !config.silentOverwrite) {
445
+ const confirmed = await confirm(
446
+ `This will replace processor version ${initResponse.replacing_version}. Continue?`
447
+ )
448
+ if (!confirmed) {
449
+ process.exit(0)
450
+ }
451
+ }
452
+
424
453
  // Handle variables update if needed
425
454
  if (config.variables && config.variables.length > 0) {
426
455
  const ret = await updateVariables(projectId, config, auth)
@@ -439,7 +468,8 @@ export async function uploadFile(
439
468
  config.debug || options.debug,
440
469
  continueFrom,
441
470
  config.networkOverrides,
442
- rollbackMap
471
+ rollbackMap,
472
+ initResponse
443
473
  )
444
474
 
445
475
  console.log(chalk.green('Upload success: '))
package/src/config.ts CHANGED
@@ -10,7 +10,7 @@ const HostMap: { [host: string]: string } = {
10
10
  prod: 'https://app.sentio.xyz'
11
11
  }
12
12
 
13
- export const CHAIN_TYPES = ['eth', 'solana', 'aptos', 'sui', 'iota', 'fuel', 'starknet']
13
+ export const CHAIN_TYPES = ['eth', 'solana', 'aptos', 'sui', 'iota', 'fuel']
14
14
 
15
15
  export interface YamlContractConfig {
16
16
  address: string
package/src/uploader.ts CHANGED
@@ -89,7 +89,8 @@ export abstract class BatchUploader {
89
89
  debug?: boolean,
90
90
  continueFrom?: number,
91
91
  networkOverrides?: NetworkOverride[],
92
- rollback?: Record<string, number>
92
+ rollback?: Record<string, number>,
93
+ initResponse?: InitBatchUploadResponse
93
94
  ): Promise<FinishBatchUploadResponse>
94
95
 
95
96
  async initUpload(fileTypes?: Record<string, FileType>): Promise<InitBatchUploadResponse> {
@@ -184,16 +185,18 @@ export class DefaultBatchUploader extends BatchUploader {
184
185
  debug?: boolean,
185
186
  continueFrom?: number,
186
187
  networkOverrides?: NetworkOverride[],
187
- rollback?: Record<string, number>
188
+ rollback?: Record<string, number>,
189
+ initResponse?: InitBatchUploadResponse
188
190
  ): Promise<FinishBatchUploadResponse> {
189
- // Step 1: Initialize upload with file types
190
- const fileTypes: Record<string, FileType> = {
191
- source: FileType.SOURCE,
192
- code: FileType.PROCESSOR
191
+ // Step 1: Initialize upload with file types (if not already done)
192
+ if (!initResponse) {
193
+ const fileTypes: Record<string, FileType> = {
194
+ source: FileType.SOURCE,
195
+ code: FileType.PROCESSOR
196
+ }
197
+ initResponse = await this.initUpload(fileTypes)
193
198
  }
194
199
 
195
- const initResponse = await this.initUpload(fileTypes)
196
-
197
200
  // Step 3: Upload files to S3 using presigned URLs
198
201
  for (const [fileKey, payload] of Object.entries(initResponse.payloads)) {
199
202
  if (!payload?.object?.putUrl) {
@@ -235,7 +238,7 @@ export class DefaultBatchUploader extends BatchUploader {
235
238
 
236
239
  export class IPFSBatchUploader extends BatchUploader {
237
240
  constructor(options: YamlProjectConfig, auth: Auth) {
238
- super(StorageEngine.DEFAULT, options, auth)
241
+ super(StorageEngine.IPFS, options, auth)
239
242
  }
240
243
 
241
244
  async upload(
@@ -245,15 +248,17 @@ export class IPFSBatchUploader extends BatchUploader {
245
248
  debug?: boolean,
246
249
  continueFrom?: number,
247
250
  networkOverrides?: NetworkOverride[],
248
- rollback?: Record<string, number>
251
+ rollback?: Record<string, number>,
252
+ initResponse?: InitBatchUploadResponse
249
253
  ): Promise<FinishBatchUploadResponse> {
250
- const fileTypes: Record<string, FileType> = {
251
- source: FileType.SOURCE,
252
- code: FileType.PROCESSOR
254
+ if (!initResponse) {
255
+ const fileTypes: Record<string, FileType> = {
256
+ source: FileType.SOURCE,
257
+ code: FileType.PROCESSOR
258
+ }
259
+ initResponse = await this.initUpload(fileTypes)
253
260
  }
254
261
 
255
- const initResponse = await this.initUpload(fileTypes)
256
-
257
262
  for (const [fileKey, payload] of Object.entries(initResponse.payloads)) {
258
263
  const putUrl = payload.object?.putUrl || payload.ipfs?.putUrl
259
264
  if (!putUrl) {
@@ -334,16 +339,18 @@ export class WalrusBatchUploader extends BatchUploader {
334
339
  debug?: boolean,
335
340
  continueFrom?: number,
336
341
  networkOverrides?: NetworkOverride[],
337
- rollback?: Record<string, number>
342
+ rollback?: Record<string, number>,
343
+ initResponse?: InitBatchUploadResponse
338
344
  ): Promise<FinishBatchUploadResponse> {
339
- // Step 1: Initialize upload with file types
340
- const fileTypes: Record<string, FileType> = {
341
- source: FileType.SOURCE,
342
- code: FileType.PROCESSOR
345
+ // Step 1: Initialize upload with file types (if not already done)
346
+ if (!initResponse) {
347
+ const fileTypes: Record<string, FileType> = {
348
+ source: FileType.SOURCE,
349
+ code: FileType.PROCESSOR
350
+ }
351
+ initResponse = await this.initUpload(fileTypes)
343
352
  }
344
353
 
345
- const initResponse = await this.initUpload(fileTypes)
346
-
347
354
  // Step 2: Create quilt multipart form data for all files
348
355
  const formData = this.createQuiltMultipartFormData(files)
349
356
 
@@ -1,65 +0,0 @@
1
- [
2
- {
3
- "type": "impl",
4
- "name": "VotingContractImpl",
5
- "interface_name": "contracts::IVotingContract"
6
- },
7
- {
8
- "type": "interface",
9
- "name": "contracts::IVotingContract",
10
- "items": [
11
- {
12
- "type": "function",
13
- "name": "vote",
14
- "inputs": [
15
- {
16
- "name": "vote",
17
- "type": "core::felt252"
18
- }
19
- ],
20
- "outputs": [],
21
- "state_mutability": "external"
22
- },
23
- {
24
- "type": "function",
25
- "name": "get_votes",
26
- "inputs": [],
27
- "outputs": [
28
- {
29
- "type": "(core::felt252, core::felt252)"
30
- }
31
- ],
32
- "state_mutability": "view"
33
- }
34
- ]
35
- },
36
- {
37
- "type": "event",
38
- "name": "contracts::VotingContract::VoteEvent",
39
- "kind": "struct",
40
- "members": [
41
- {
42
- "name": "voter",
43
- "type": "core::starknet::contract_address::ContractAddress",
44
- "kind": "key"
45
- },
46
- {
47
- "name": "vote",
48
- "type": "core::felt252",
49
- "kind": "data"
50
- }
51
- ]
52
- },
53
- {
54
- "type": "event",
55
- "name": "contracts::VotingContract::Event",
56
- "kind": "enum",
57
- "variants": [
58
- {
59
- "name": "VoteEvent",
60
- "type": "contracts::VotingContract::VoteEvent",
61
- "kind": "nested"
62
- }
63
- ]
64
- }
65
- ]
@@ -1,19 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "template-starknet",
4
- "version": "1.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "build": "sentio build",
8
- "gen": "sentio gen",
9
- "test": "sentio test",
10
- "upload": "sentio upload"
11
- },
12
- "dependencies": {
13
- "@sentio/sdk": "workspace:*"
14
- },
15
- "devDependencies": {
16
- "@sentio/cli": "workspace:*",
17
- "typescript": "^5.5.2"
18
- }
19
- }
@@ -1,6 +0,0 @@
1
- project: starknet-example
2
- host: local
3
- contracts:
4
- - name: VoteContract
5
- address: '0x00cf88f7ecf1bf36e9262333879e2937611cd81758db64a169776a2710464391'
6
- chain: starknet_sepolia
@@ -1,5 +0,0 @@
1
- import { VoteContractProcessor } from './types/starknet/VoteContract-processor.js'
2
-
3
- VoteContractProcessor.bind({}).onVoteEvent(async (event, ctx) => {
4
- const votes = await ctx.getContract().get_votes()
5
- })
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "importHelpers": true,
4
- "alwaysStrict": true,
5
- "sourceMap": true,
6
- "target": "esnext",
7
- "esModuleInterop": true,
8
- "noImplicitReturns": true,
9
- "noImplicitAny": true,
10
- "module": "nodenext",
11
- "moduleResolution": "nodenext",
12
- "strictNullChecks": true,
13
- "stripInternal": true,
14
- "noFallthroughCasesInSwitch": true,
15
- "noEmitOnError": false,
16
- "rootDir": "./src",
17
- "outDir": "./dist",
18
- "skipLibCheck": true,
19
- "resolveJsonModule": true,
20
- "experimentalDecorators": true,
21
- "emitDecoratorMetadata": true
22
- },
23
- "exclude": ["dist"]
24
- }