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: [], },