From 093d018383712739698f2f30d86297e085435ffb Mon Sep 17 00:00:00 2001 From: Leechael Yim Date: Wed, 21 Feb 2024 13:25:46 +0800 Subject: [PATCH] feat: save package info when upload --- src/commands/upload.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/commands/upload.ts b/src/commands/upload.ts index 7038dfd..953c30d 100644 --- a/src/commands/upload.ts +++ b/src/commands/upload.ts @@ -1,4 +1,5 @@ import fs from 'node:fs' +import upath from 'upath' import type { u16 } from '@polkadot/types' import { getContract, @@ -24,6 +25,13 @@ export default class Upload extends PhatBaseCommand { const rpc = this.parsedFlags.rpc || process.env.MUMBAI_RPC_URL || process.env.POLYGON_RPC_URL || (await this.promptRpc()) const consumerAddress = this.parsedFlags.consumerAddress || (await this.promptConsumerAddress()) + let derived = 'blank@0.0.0' + try { + const packageJson = JSON.parse(fs.readFileSync(upath.join(process.cwd(), 'package.json'), 'utf8')) + derived = `${packageJson.name}@${packageJson.version}` + } catch (err) { + } + const buildScriptPath = await this.buildOrGetScriptPath() // connect to the endpoint @@ -99,6 +107,7 @@ export default class Upload extends PhatBaseCommand { config: { codeHash: rollupAbi.info.source.wasmHash.toHex(), callee: contract.address.toHex(), + package: derived, selector, input: [], },