From 4ef4770588a908143c497eca3437ac32567f1844 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Fri, 27 Sep 2024 19:02:40 +1200 Subject: [PATCH] Support wasm url (#827) * 0.15.0 * wasm override support url --- executor/package.json | 2 +- packages/chopsticks/package.json | 2 +- packages/chopsticks/src/utils/override.ts | 11 +++++++++-- packages/core/package.json | 2 +- packages/db/package.json | 2 +- packages/testing/package.json | 2 +- packages/utils/package.json | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/executor/package.json b/executor/package.json index 0d27e314..ceda5d84 100644 --- a/executor/package.json +++ b/executor/package.json @@ -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": { diff --git a/packages/chopsticks/package.json b/packages/chopsticks/package.json index c5ae9578..dac76af0 100644 --- a/packages/chopsticks/package.json +++ b/packages/chopsticks/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks", - "version": "0.14.2-1", + "version": "0.15.0", "author": "Acala Developers ", "license": "Apache-2.0", "bin": "./chopsticks.cjs", diff --git a/packages/chopsticks/src/utils/override.ts b/packages/chopsticks/src/utils/override.ts index 34e4e5c1..914a8c6e 100644 --- a/packages/chopsticks/src/utils/override.ts +++ b/packages/chopsticks/src/utils/override.ts @@ -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' @@ -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 diff --git a/packages/core/package.json b/packages/core/package.json index 3f95b515..212d76b1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-core", - "version": "0.14.2-1", + "version": "0.15.0", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", diff --git a/packages/db/package.json b/packages/db/package.json index 4a7bee1b..f5ba8b8f 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-db", - "version": "0.14.2-1", + "version": "0.15.0", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", diff --git a/packages/testing/package.json b/packages/testing/package.json index b6b5a0b0..4e4f673f 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-testing", - "version": "0.14.2-1", + "version": "0.15.0", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module", diff --git a/packages/utils/package.json b/packages/utils/package.json index 281481d5..ac4a0212 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@acala-network/chopsticks-utils", - "version": "0.14.2-1", + "version": "0.15.0", "author": "Acala Developers ", "license": "Apache-2.0", "type": "module",