Skip to content

Commit

Permalink
fix bundle to include template (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci authored Jan 22, 2023
1 parent 325f6c1 commit 1e0b936
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/chopsticks",
"version": "0.3.3",
"version": "0.3.4",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"author": "Bryan Chen <[email protected]>",
Expand All @@ -16,7 +16,8 @@
"fix": "eslint . --ext .js,.ts --fix && prettier -w .",
"prepare": "husky install",
"start": "ts-node --transpile-only src/index.ts",
"build": "rm -rf dist && tsc -p tsconfig.prod.json",
"build": "rm -rf dist && tsc -p tsconfig.prod.json && yarn postbuild",
"postbuild": "cp -r template ./dist",
"build-wasm": "wasm-pack build executor --target nodejs --scope acala-network",
"build-wasm-logging": "yarn build-wasm --features=logging",
"check": "cd executor && cargo check --locked",
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/substrate/system.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Index } from '@polkadot/types/interfaces'
import { hexToU8a } from '@polkadot/util'
import { readFileSync } from 'node:fs'
import path from 'node:path'

import { Handlers } from '../shared'

Expand All @@ -15,7 +16,7 @@ const handlers: Handlers = {
return context.chain.api.getSystemName()
},
system_version: async (_context) => {
const { version } = JSON.parse(readFileSync('package.json', 'utf-8'))
const { version } = JSON.parse(readFileSync(path.join(__dirname, '../../../package.json'), 'utf-8'))
return `chopsticks-v${version}`
},
system_chainType: async (_context) => {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/generate-html-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { HexString } from '@polkadot/util/types'
import { decodeStorageDiff } from './decoder'
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
import { template } from 'lodash'
import path from 'node:path'

export const generateHtmlDiff = async (block: Block, diff: [HexString, HexString | null][]) => {
const [left, _right, delta] = await decodeStorageDiff(block, diff)
const htmlTemplate = readFileSync('./template/diff.html', 'utf-8')
const htmlTemplate = readFileSync(path.join(__dirname, '../../template/diff.html'), 'utf-8')
return template(htmlTemplate)({ left: JSON.stringify(left), delta: JSON.stringify(delta) })
}

Expand Down

0 comments on commit 1e0b936

Please sign in to comment.