Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: save package info when upload #35

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/commands/upload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs'
import upath from 'upath'
import type { u16 } from '@polkadot/types'
import {
getContract,
Expand All @@ -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 = '[email protected]'
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
Expand Down Expand Up @@ -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: [],
},
Expand Down
Loading