@sentio/cli 4.0.1-rc.3 → 4.1.0-rc.1
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/dist/index.js +10291 -2372
- package/package.json +1 -1
- package/src/api.ts +28 -47
- package/src/commands/alert.ts +42 -51
- package/src/commands/build.ts +20 -3
- package/src/commands/dashboard.ts +35 -35
- package/src/commands/data.ts +59 -61
- package/src/commands/price.ts +36 -29
- package/src/commands/processor.ts +64 -55
- package/src/commands/simulation.ts +97 -97
- package/src/commands/upload.ts +1 -1
- package/src/utils.ts +50 -0
package/src/commands/price.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { PriceService } from '@sentio/api'
|
|
2
|
+
import {
|
|
3
|
+
BatchGetPricesRequestSchema,
|
|
4
|
+
BatchGetPricesResponseSchema,
|
|
5
|
+
CheckLatestPriceResponseSchema,
|
|
6
|
+
GetPriceResponseSchema,
|
|
7
|
+
ListCoinsResponseSchema
|
|
8
|
+
} from '@sentio/api/gen/service/price/protos/price_pb.js'
|
|
9
|
+
import { fromJson, toJson } from '@bufbuild/protobuf'
|
|
10
|
+
import { timestampFromDate } from '@bufbuild/protobuf/wkt'
|
|
2
11
|
import { Command, InvalidArgumentError } from '@commander-js/extra-typings'
|
|
3
12
|
import process from 'process'
|
|
4
13
|
import yaml from 'yaml'
|
|
5
|
-
import { CliError, createApiContext, handleCommandError, loadJsonInput
|
|
14
|
+
import { CliError, createApiContext, getServiceClient, handleCommandError, loadJsonInput } from '../api.js'
|
|
6
15
|
|
|
7
16
|
interface PriceOptions {
|
|
8
17
|
host?: string
|
|
@@ -133,20 +142,23 @@ function createPriceCheckLatestCommand() {
|
|
|
133
142
|
async function runPriceGet(options: PriceGetOptions) {
|
|
134
143
|
const context = createApiContext(options)
|
|
135
144
|
const coin = normalizeCoinInput(options)
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
const client = getServiceClient(PriceService, context)
|
|
146
|
+
const res = await client.getPrice({
|
|
147
|
+
timestamp: options.timestamp ? timestampFromDate(new Date(options.timestamp)) : undefined,
|
|
148
|
+
coinId: {
|
|
149
|
+
id: coin.symbol
|
|
150
|
+
? { case: 'symbol', value: coin.symbol }
|
|
151
|
+
: {
|
|
152
|
+
case: 'address',
|
|
153
|
+
value: { address: coin.address?.address ?? '', chain: coin.address?.chain ?? '' }
|
|
154
|
+
}
|
|
144
155
|
},
|
|
145
|
-
|
|
156
|
+
source: options.source,
|
|
157
|
+
experimentalFlag: options.enablePythSource ? { enablePythSource: options.enablePythSource } : undefined
|
|
146
158
|
})
|
|
147
159
|
printOutput(options, {
|
|
148
160
|
coinId: coin,
|
|
149
|
-
...(
|
|
161
|
+
...(toJson(GetPriceResponseSchema, res) as Record<string, unknown>)
|
|
150
162
|
})
|
|
151
163
|
}
|
|
152
164
|
|
|
@@ -156,33 +168,28 @@ async function runPriceBatch(options: PriceBatchOptions) {
|
|
|
156
168
|
if (!body) {
|
|
157
169
|
throw new CliError('Provide --file or --stdin for price batch.')
|
|
158
170
|
}
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})
|
|
163
|
-
printOutput(options, unwrapApiResult(response))
|
|
171
|
+
const client = getServiceClient(PriceService, context)
|
|
172
|
+
const res = await client.batchGetPrices(fromJson(BatchGetPricesRequestSchema, body as never))
|
|
173
|
+
printOutput(options, toJson(BatchGetPricesResponseSchema, res))
|
|
164
174
|
}
|
|
165
175
|
|
|
166
176
|
async function runPriceCoins(options: PriceCoinsOptions) {
|
|
167
177
|
const context = createApiContext(options)
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
headers: context.headers
|
|
178
|
+
const client = getServiceClient(PriceService, context)
|
|
179
|
+
const res = await client.listCoins({
|
|
180
|
+
limit: options.limit,
|
|
181
|
+
offset: options.offset,
|
|
182
|
+
searchQuery: options.searchQuery,
|
|
183
|
+
chain: options.chain
|
|
176
184
|
})
|
|
177
|
-
printOutput(options,
|
|
185
|
+
printOutput(options, toJson(ListCoinsResponseSchema, res))
|
|
178
186
|
}
|
|
179
187
|
|
|
180
188
|
async function runPriceCheckLatest(options: PriceOptions) {
|
|
181
189
|
const context = createApiContext(options)
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
printOutput(options, unwrapApiResult(response))
|
|
190
|
+
const client = getServiceClient(PriceService, context)
|
|
191
|
+
const res = await client.checkLatestPrice({})
|
|
192
|
+
printOutput(options, toJson(CheckLatestPriceResponseSchema, res))
|
|
186
193
|
}
|
|
187
194
|
|
|
188
195
|
function withAuthOptions<Args extends any[]>(command: Command<Args, any, any>) {
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProcessorService, ProcessorServiceExt } from '@sentio/api'
|
|
2
|
+
import {
|
|
3
|
+
ActivatePendingRequestSchema,
|
|
4
|
+
GetProcessorStatusRequestV2Schema,
|
|
5
|
+
GetProcessorStatusResponseSchema
|
|
6
|
+
} from '@sentio/api/gen/service/processor/protos/processor_service_pb.js'
|
|
7
|
+
import {
|
|
8
|
+
GetProcessorSourceFilesRequestSchema,
|
|
9
|
+
GetProcessorSourceFilesResponseSchema
|
|
10
|
+
} from '@sentio/api/gen/service/processor/ext_protos/processor_service_ext_pb.js'
|
|
11
|
+
import { fromJson, toJson } from '@bufbuild/protobuf'
|
|
12
|
+
import { EmptySchema } from '@bufbuild/protobuf/wkt'
|
|
2
13
|
import { Command, InvalidArgumentError } from '@commander-js/extra-typings'
|
|
3
14
|
import chalk from 'chalk'
|
|
4
15
|
import process from 'process'
|
|
@@ -6,9 +17,9 @@ import yaml from 'yaml'
|
|
|
6
17
|
import {
|
|
7
18
|
CliError,
|
|
8
19
|
createApiContext,
|
|
20
|
+
getServiceClient,
|
|
9
21
|
handleCommandError,
|
|
10
22
|
resolveProjectRef,
|
|
11
|
-
unwrapApiResult,
|
|
12
23
|
postApiJson,
|
|
13
24
|
putApiJson
|
|
14
25
|
} from '../api.js'
|
|
@@ -181,34 +192,30 @@ async function runProcessorStatus(options: ProcessorStatusOptions) {
|
|
|
181
192
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
182
193
|
const requestedVersion = normalizeVersionSelector(options.version)
|
|
183
194
|
const apiVersion = typeof requestedVersion === 'number' ? 'ALL' : (requestedVersion ?? 'ALL')
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
query: {
|
|
195
|
+
const client = getServiceClient(ProcessorService, context)
|
|
196
|
+
const res = await client.getProcessorStatusV2(
|
|
197
|
+
fromJson(GetProcessorStatusRequestV2Schema, {
|
|
198
|
+
projectOwner: project.owner,
|
|
199
|
+
projectSlug: project.slug,
|
|
190
200
|
version: apiVersion
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const data = unwrapApiResult(response)
|
|
201
|
+
})
|
|
202
|
+
)
|
|
203
|
+
const data = toJson(GetProcessorStatusResponseSchema, res)
|
|
195
204
|
printOutput(options, shapeProcessorStatusOutput(data, requestedVersion))
|
|
196
205
|
}
|
|
197
206
|
|
|
198
207
|
async function runProcessorSource(options: ProcessorSourceOptions) {
|
|
199
208
|
const context = createApiContext(options)
|
|
200
209
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
})
|
|
211
|
-
const data = unwrapApiResult(response)
|
|
210
|
+
const client = getServiceClient(ProcessorServiceExt, context)
|
|
211
|
+
const res = await client.getProcessorSourceFiles(
|
|
212
|
+
fromJson(GetProcessorSourceFilesRequestSchema, {
|
|
213
|
+
projectOwner: project.owner,
|
|
214
|
+
projectSlug: project.slug,
|
|
215
|
+
...(options.version !== undefined ? { version: options.version } : {})
|
|
216
|
+
})
|
|
217
|
+
)
|
|
218
|
+
const data = toJson(GetProcessorSourceFilesResponseSchema, res)
|
|
212
219
|
if (options.path && Array.isArray(data.sourceFiles)) {
|
|
213
220
|
const sourceFile = data.sourceFiles.find((entry) => entry.path === options.path)
|
|
214
221
|
if (!sourceFile) {
|
|
@@ -224,15 +231,15 @@ async function runActivatePending(options: ProcessorOptions & { yes?: boolean })
|
|
|
224
231
|
const context = createApiContext(options)
|
|
225
232
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
226
233
|
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const data =
|
|
234
|
+
const client = getServiceClient(ProcessorService, context)
|
|
235
|
+
const statusResponse = await client.getProcessorStatusV2(
|
|
236
|
+
fromJson(GetProcessorStatusRequestV2Schema, {
|
|
237
|
+
projectOwner: project.owner,
|
|
238
|
+
projectSlug: project.slug,
|
|
239
|
+
version: 'ALL'
|
|
240
|
+
})
|
|
241
|
+
)
|
|
242
|
+
const data = toJson(GetProcessorStatusResponseSchema, statusResponse)
|
|
236
243
|
const processors = Array.isArray(data.processors) ? data.processors : []
|
|
237
244
|
|
|
238
245
|
const activeProcessor = processors.find((p) => asString(p.versionState) === 'ACTIVE')
|
|
@@ -255,16 +262,15 @@ async function runActivatePending(options: ProcessorOptions & { yes?: boolean })
|
|
|
255
262
|
}
|
|
256
263
|
}
|
|
257
264
|
|
|
258
|
-
const response = await
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
})
|
|
265
|
+
const response = await client.activatePendingVersion(
|
|
266
|
+
fromJson(ActivatePendingRequestSchema, {
|
|
267
|
+
projectOwner: project.owner,
|
|
268
|
+
projectSlug: project.slug
|
|
269
|
+
})
|
|
270
|
+
)
|
|
265
271
|
printOutput(options, {
|
|
266
272
|
project: `${project.owner}/${project.slug}`,
|
|
267
|
-
...(
|
|
273
|
+
...(toJson(EmptySchema, response) as Record<string, unknown>)
|
|
268
274
|
})
|
|
269
275
|
}
|
|
270
276
|
|
|
@@ -279,15 +285,15 @@ async function resolveAndConfirmProcessor(
|
|
|
279
285
|
|
|
280
286
|
if (!resolvedProcessorId) {
|
|
281
287
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const data =
|
|
288
|
+
const client = getServiceClient(ProcessorService, context)
|
|
289
|
+
const statusResponse = await client.getProcessorStatusV2(
|
|
290
|
+
fromJson(GetProcessorStatusRequestV2Schema, {
|
|
291
|
+
projectOwner: project.owner,
|
|
292
|
+
projectSlug: project.slug,
|
|
293
|
+
version: 'ACTIVE'
|
|
294
|
+
})
|
|
295
|
+
)
|
|
296
|
+
const data = toJson(GetProcessorStatusResponseSchema, statusResponse)
|
|
291
297
|
const processors = Array.isArray(data.processors) ? data.processors : []
|
|
292
298
|
const activeProcessor = processors.find((p) => asString(p.versionState) === 'ACTIVE')
|
|
293
299
|
|
|
@@ -354,12 +360,15 @@ async function resolveProcessorId(processorId: string | undefined, options: Proc
|
|
|
354
360
|
if (processorId) return processorId
|
|
355
361
|
const context = createApiContext(options)
|
|
356
362
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
const client = getServiceClient(ProcessorService, context)
|
|
364
|
+
const statusResponse = await client.getProcessorStatusV2(
|
|
365
|
+
fromJson(GetProcessorStatusRequestV2Schema, {
|
|
366
|
+
projectOwner: project.owner,
|
|
367
|
+
projectSlug: project.slug,
|
|
368
|
+
version: 'ACTIVE'
|
|
369
|
+
})
|
|
370
|
+
)
|
|
371
|
+
const data = toJson(GetProcessorStatusResponseSchema, statusResponse)
|
|
363
372
|
const processors = Array.isArray(data.processors) ? data.processors : []
|
|
364
373
|
const activeProcessor = processors.find((p) => asString(p.versionState) === 'ACTIVE')
|
|
365
374
|
if (!activeProcessor || !activeProcessor.processorId) {
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import { Command, InvalidArgumentError } from '@commander-js/extra-typings'
|
|
2
2
|
import process from 'process'
|
|
3
3
|
import yaml from 'yaml'
|
|
4
|
-
import {
|
|
4
|
+
import { SolidityAPIService } from '@sentio/api'
|
|
5
|
+
import {
|
|
6
|
+
GetSimulationBundleInProjectRequestSchema,
|
|
7
|
+
GetSimulationInProjectRequestSchema,
|
|
8
|
+
GetSimulationsInProjectRequestSchema,
|
|
9
|
+
SimulateTransactionBundleInProjectRequestSchema,
|
|
10
|
+
SimulateTransactionInProjectRequestSchema
|
|
11
|
+
} from '@sentio/api/gen/service/solidity/protos/solidity_api_service_pb.js'
|
|
12
|
+
import {
|
|
13
|
+
GetSimulationBundleResponseSchema,
|
|
14
|
+
GetSimulationResponseSchema,
|
|
15
|
+
GetSimulationsResponseSchema,
|
|
16
|
+
SimulateTransactionBundleResponseSchema,
|
|
17
|
+
SimulateTransactionResponseSchema
|
|
18
|
+
} from '@sentio/api/gen/service/solidity/protos/solidity_service_pb.js'
|
|
19
|
+
import { fromJson, toJson } from '@bufbuild/protobuf'
|
|
5
20
|
import {
|
|
6
21
|
CliError,
|
|
7
22
|
createApiContext,
|
|
23
|
+
fetchApiJson,
|
|
24
|
+
getServiceClient,
|
|
8
25
|
handleCommandError,
|
|
9
26
|
loadJsonInput,
|
|
10
|
-
resolveProjectRef
|
|
11
|
-
unwrapApiResult
|
|
27
|
+
resolveProjectRef
|
|
12
28
|
} from '../api.js'
|
|
13
29
|
|
|
14
30
|
interface SimulationOptions {
|
|
@@ -213,47 +229,45 @@ function createSimulationTraceByTxCommand() {
|
|
|
213
229
|
async function runSimulationList(options: SimulationListOptions) {
|
|
214
230
|
const context = createApiContext(options)
|
|
215
231
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
})
|
|
228
|
-
printOutput(options, unwrapApiResult(response))
|
|
232
|
+
const client = getServiceClient(SolidityAPIService, context)
|
|
233
|
+
const res = await client.getSimulations(
|
|
234
|
+
fromJson(GetSimulationsInProjectRequestSchema, {
|
|
235
|
+
projectOwner: project.owner,
|
|
236
|
+
projectSlug: project.slug,
|
|
237
|
+
...(options.labelContains !== undefined ? { labelContains: options.labelContains } : {}),
|
|
238
|
+
...(options.page !== undefined ? { page: options.page } : {}),
|
|
239
|
+
...(options.pageSize !== undefined ? { pageSize: options.pageSize } : {})
|
|
240
|
+
})
|
|
241
|
+
)
|
|
242
|
+
printOutput(options, toJson(GetSimulationsResponseSchema, res))
|
|
229
243
|
}
|
|
230
244
|
|
|
231
245
|
async function runSimulationGet(simulationId: string, options: SimulationOptions) {
|
|
232
246
|
const context = createApiContext(options)
|
|
233
247
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
248
|
+
const client = getServiceClient(SolidityAPIService, context)
|
|
249
|
+
const res = await client.getSimulation(
|
|
250
|
+
fromJson(GetSimulationInProjectRequestSchema, {
|
|
251
|
+
projectOwner: project.owner,
|
|
252
|
+
projectSlug: project.slug,
|
|
238
253
|
simulationId
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
printOutput(options, unwrapApiResult(response))
|
|
254
|
+
})
|
|
255
|
+
)
|
|
256
|
+
printOutput(options, toJson(GetSimulationResponseSchema, res))
|
|
243
257
|
}
|
|
244
258
|
|
|
245
259
|
async function runSimulationBundleGet(bundleId: string, options: SimulationOptions) {
|
|
246
260
|
const context = createApiContext(options)
|
|
247
261
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
262
|
+
const client = getServiceClient(SolidityAPIService, context)
|
|
263
|
+
const res = await client.getSimulationBundleInProject(
|
|
264
|
+
fromJson(GetSimulationBundleInProjectRequestSchema, {
|
|
265
|
+
projectOwner: project.owner,
|
|
266
|
+
projectSlug: project.slug,
|
|
252
267
|
bundleId
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
printOutput(options, unwrapApiResult(response))
|
|
268
|
+
})
|
|
269
|
+
)
|
|
270
|
+
printOutput(options, toJson(GetSimulationBundleResponseSchema, res))
|
|
257
271
|
}
|
|
258
272
|
|
|
259
273
|
async function runSimulation(options: SimulationRunOptions) {
|
|
@@ -266,16 +280,22 @@ async function runSimulation(options: SimulationRunOptions) {
|
|
|
266
280
|
}
|
|
267
281
|
const context = createApiContext(options)
|
|
268
282
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
283
|
+
const client = getServiceClient(SolidityAPIService, context)
|
|
284
|
+
// 1.x body was { simulation: Simulation } and chainId rode in the URL path; in
|
|
285
|
+
// 2.x both live on the request message and chainId is a field of the simulation.
|
|
286
|
+
const bodyJson = body as Record<string, unknown>
|
|
287
|
+
const simulation = {
|
|
288
|
+
chainId: options.chainId,
|
|
289
|
+
...((bodyJson.simulation as Record<string, unknown> | undefined) ?? {})
|
|
290
|
+
}
|
|
291
|
+
const res = await client.simulateTransaction(
|
|
292
|
+
fromJson(SimulateTransactionInProjectRequestSchema, {
|
|
293
|
+
projectOwner: project.owner,
|
|
294
|
+
projectSlug: project.slug,
|
|
295
|
+
simulation
|
|
296
|
+
})
|
|
297
|
+
)
|
|
298
|
+
printOutput(options, toJson(SimulateTransactionResponseSchema, res))
|
|
279
299
|
}
|
|
280
300
|
|
|
281
301
|
async function runSimulationBundle(options: SimulationRunOptions) {
|
|
@@ -286,86 +306,66 @@ async function runSimulationBundle(options: SimulationRunOptions) {
|
|
|
286
306
|
if (!options.chainId) {
|
|
287
307
|
throw new CliError('Chain id is required. Use --chain-id <id>.')
|
|
288
308
|
}
|
|
309
|
+
const chainId = options.chainId
|
|
289
310
|
const context = createApiContext(options)
|
|
290
311
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
312
|
+
const client = getServiceClient(SolidityAPIService, context)
|
|
313
|
+
// 1.x body was { simulations: Simulation[] } and chainId rode in the URL path;
|
|
314
|
+
// in 2.x both live on the request message and chainId is a field of each simulation.
|
|
315
|
+
const bodyJson = body as Record<string, unknown>
|
|
316
|
+
const inputSimulations = Array.isArray(bodyJson.simulations)
|
|
317
|
+
? (bodyJson.simulations as Array<Record<string, unknown>>)
|
|
318
|
+
: []
|
|
319
|
+
const simulations = inputSimulations.map((simulation) => ({
|
|
320
|
+
chainId,
|
|
321
|
+
...simulation
|
|
322
|
+
}))
|
|
323
|
+
const res = await client.simulateTransactionBundle(
|
|
324
|
+
fromJson(SimulateTransactionBundleInProjectRequestSchema, {
|
|
325
|
+
projectOwner: project.owner,
|
|
326
|
+
projectSlug: project.slug,
|
|
327
|
+
simulations
|
|
328
|
+
})
|
|
329
|
+
)
|
|
330
|
+
printOutput(options, toJson(SimulateTransactionBundleResponseSchema, res))
|
|
301
331
|
}
|
|
302
332
|
|
|
303
333
|
async function runTraceBySimulation(simulationId: string, options: SimulationTraceOptions) {
|
|
304
|
-
await runTrace(
|
|
305
|
-
DebugAndSimulationService.getCallTraceBySimulation({
|
|
306
|
-
path: {
|
|
307
|
-
owner: project.owner,
|
|
308
|
-
slug: project.slug,
|
|
309
|
-
chainId: options.chainId!,
|
|
310
|
-
simulationId
|
|
311
|
-
},
|
|
312
|
-
query: buildTraceQuery(options),
|
|
313
|
-
headers: context.headers
|
|
314
|
-
})
|
|
315
|
-
)
|
|
334
|
+
await runTrace('simulation', simulationId, options)
|
|
316
335
|
}
|
|
317
336
|
|
|
318
337
|
async function runTraceByBundle(bundleId: string, options: SimulationTraceOptions) {
|
|
319
|
-
await runTrace(
|
|
320
|
-
DebugAndSimulationService.getCallTraceByBundle({
|
|
321
|
-
path: {
|
|
322
|
-
owner: project.owner,
|
|
323
|
-
slug: project.slug,
|
|
324
|
-
chainId: options.chainId!,
|
|
325
|
-
bundleId
|
|
326
|
-
},
|
|
327
|
-
query: buildTraceQuery(options),
|
|
328
|
-
headers: context.headers
|
|
329
|
-
})
|
|
330
|
-
)
|
|
338
|
+
await runTrace('bundle', bundleId, options)
|
|
331
339
|
}
|
|
332
340
|
|
|
333
341
|
async function runTraceByTransaction(txHash: string, options: SimulationTraceOptions) {
|
|
334
|
-
await runTrace(
|
|
335
|
-
DebugAndSimulationService.getCallTraceByTransaction({
|
|
336
|
-
path: {
|
|
337
|
-
owner: project.owner,
|
|
338
|
-
slug: project.slug,
|
|
339
|
-
chainId: options.chainId!,
|
|
340
|
-
txHash
|
|
341
|
-
},
|
|
342
|
-
query: buildTraceQuery(options),
|
|
343
|
-
headers: context.headers
|
|
344
|
-
})
|
|
345
|
-
)
|
|
342
|
+
await runTrace('transaction', txHash, options)
|
|
346
343
|
}
|
|
347
344
|
|
|
345
|
+
// The call-trace-by-id endpoints are keyed by chainId + the simulation/bundle/tx
|
|
346
|
+
// id, but the 2.x public proto (GetCallTraceInProjectRequest) does not carry those
|
|
347
|
+
// fields. Call the REST gateway route directly — the same dialect the connect
|
|
348
|
+
// client speaks — so the id and chainId can still be forwarded.
|
|
348
349
|
async function runTrace(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
context: ReturnType<typeof createApiContext>
|
|
353
|
-
) => Promise<unknown>
|
|
350
|
+
resource: 'simulation' | 'bundle' | 'transaction',
|
|
351
|
+
id: string,
|
|
352
|
+
options: SimulationTraceOptions
|
|
354
353
|
) {
|
|
355
354
|
if (!options.chainId) {
|
|
356
355
|
throw new CliError('Chain id is required. Use --chain-id <id>.')
|
|
357
356
|
}
|
|
358
357
|
const context = createApiContext(options)
|
|
359
358
|
const project = await resolveProjectRef(options, context, { ownerSlug: true })
|
|
360
|
-
const
|
|
359
|
+
const path = `/api/v1/solidity/${project.owner}/${project.slug}/${options.chainId}/${resource}/${encodeURIComponent(id)}/call_trace`
|
|
360
|
+
const data = await fetchApiJson<unknown>(path, context, buildTraceQuery(options))
|
|
361
361
|
printOutput(options, data)
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
function buildTraceQuery(options: SimulationTraceOptions) {
|
|
365
365
|
return {
|
|
366
|
-
withInternalCalls: options.withInternalCalls,
|
|
367
|
-
disableOptimizer: options.disableOptimizer,
|
|
368
|
-
ignoreGasCost: options.ignoreGasCost
|
|
366
|
+
...(options.withInternalCalls !== undefined ? { withInternalCalls: options.withInternalCalls } : {}),
|
|
367
|
+
...(options.disableOptimizer !== undefined ? { disableOptimizer: options.disableOptimizer } : {}),
|
|
368
|
+
...(options.ignoreGasCost !== undefined ? { ignoreGasCost: options.ignoreGasCost } : {})
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
|
package/src/commands/upload.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { CommonExecOptions, execFileSync } from 'child_process'
|
|
|
11
11
|
import { getApiUrl, getSdkVersion } from '../utils.js'
|
|
12
12
|
import readline from 'readline'
|
|
13
13
|
import JSZip from 'jszip'
|
|
14
|
-
import type { UserInfo } from '../../../protos/
|
|
14
|
+
import type { UserInfo } from '../../../protos/dist/service/common/protos/common_pb.js'
|
|
15
15
|
import { CommandOptionsType } from './types.js'
|
|
16
16
|
import {
|
|
17
17
|
getSentioNetworkConfig,
|
package/src/utils.ts
CHANGED
|
@@ -65,6 +65,56 @@ export async function printVersions() {
|
|
|
65
65
|
} catch (e) {}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
function majorVersion(version: string): number | undefined {
|
|
69
|
+
const major = Number.parseInt(version.split('.')[0], 10)
|
|
70
|
+
return Number.isNaN(major) ? undefined : major
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether the installed @sentio/sdk is compatible with the given @sentio/cli.
|
|
75
|
+
* @sentio/cli, @sentio/sdk and @sentio/runtime are released in lockstep, so they
|
|
76
|
+
* are only compatible when their major versions match — the CLI drives the SDK's
|
|
77
|
+
* build tooling (it runs the SDK's `dist/tsdown.config.js`), which changes across
|
|
78
|
+
* majors. Development builds and unparseable versions are treated as compatible so
|
|
79
|
+
* the local workspace and test flows are never blocked.
|
|
80
|
+
*/
|
|
81
|
+
export function isSdkVersionCompatible(cliVersion: string, sdkVersion: string): boolean {
|
|
82
|
+
if (cliVersion.endsWith('-development') || sdkVersion.endsWith('-development')) {
|
|
83
|
+
return true
|
|
84
|
+
}
|
|
85
|
+
const cliMajor = majorVersion(cliVersion)
|
|
86
|
+
const sdkMajor = majorVersion(sdkVersion)
|
|
87
|
+
if (cliMajor === undefined || sdkMajor === undefined) {
|
|
88
|
+
return true
|
|
89
|
+
}
|
|
90
|
+
return sdkMajor === cliMajor
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Fail fast with a clear message when the installed @sentio/sdk is too old for this
|
|
95
|
+
* CLI, instead of letting the build crash later with a cryptic packaging error.
|
|
96
|
+
*/
|
|
97
|
+
export function checkSdkCompatibility() {
|
|
98
|
+
const cliVersion = getCliVersion()
|
|
99
|
+
const sdkVersion = getSdkVersion()
|
|
100
|
+
// SDK is not installed (e.g. `sentio create` in a fresh dir): nothing to validate.
|
|
101
|
+
if (!sdkVersion) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
if (!isSdkVersionCompatible(cliVersion, sdkVersion)) {
|
|
105
|
+
const cliMajor = majorVersion(cliVersion)
|
|
106
|
+
const sdkMajor = majorVersion(sdkVersion)
|
|
107
|
+
console.error(
|
|
108
|
+
chalk.red(
|
|
109
|
+
`Version mismatch: @sentio/cli ${cliVersion} (v${cliMajor}) and @sentio/sdk ${sdkVersion} (v${sdkMajor}) ` +
|
|
110
|
+
`must share the same major version.\n` +
|
|
111
|
+
`Please align them, e.g. install @sentio/sdk@^${cliMajor} (or switch to @sentio/cli@^${sdkMajor} to match the installed SDK).`
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
process.exit(1)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
68
118
|
export function getApiUrl(apiPath: string, host: string) {
|
|
69
119
|
let apiHost = host
|
|
70
120
|
if (host.includes('sentio.xyz')) {
|