Skip to content

Commit

Permalink
Support wasm url (#827)
Browse files Browse the repository at this point in the history
* 0.15.0

* wasm override support url
  • Loading branch information
xlc authored Sep 27, 2024
1 parent dd53c92 commit 4ef4770
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion executor/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@acala-network/chopsticks-executor",
"description": "Chopsticks executor",
"version": "0.14.2-1",
"version": "0.15.0",
"license": "Apache-2.0",
"type": "module",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/chopsticks",
"version": "0.14.2-1",
"version": "0.15.0",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
"bin": "./chopsticks.cjs",
Expand Down
11 changes: 9 additions & 2 deletions packages/chopsticks/src/utils/override.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Blockchain, StorageValues, setStorage } from '@acala-network/chopsticks-core'
import { Blockchain, StorageValues, isUrl, setStorage } from '@acala-network/chopsticks-core'
import { HexString } from '@polkadot/util/types'
import { existsSync, readFileSync } from 'node:fs'
import axios from 'axios'
import yaml from 'js-yaml'

import { defaultLogger } from '../logger.js'
Expand All @@ -24,7 +25,13 @@ export const overrideWasm = async (chain: Blockchain, wasmPath?: string, at?: He
if (wasmPath == null) {
return
}
const wasm = readFileSync(wasmPath)
let wasm: Buffer
if (isUrl(wasmPath)) {
const res = await axios.get(wasmPath, { responseType: 'arraybuffer' })
wasm = res.data
} else {
wasm = readFileSync(wasmPath)
}
let wasmHex: string
if (wasm.at(0) === 0x30 && wasm.at(1) === 0x78) {
// starts with 0x
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/chopsticks-core",
"version": "0.14.2-1",
"version": "0.15.0",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/chopsticks-db",
"version": "0.14.2-1",
"version": "0.15.0",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/chopsticks-testing",
"version": "0.14.2-1",
"version": "0.15.0",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/chopsticks-utils",
"version": "0.14.2-1",
"version": "0.15.0",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
"type": "module",
Expand Down

0 comments on commit 4ef4770

Please sign in to comment.