From 18133a2f954548ecf3df2540d03a93b45e903489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Tue, 8 Oct 2024 04:51:04 -0300 Subject: [PATCH] Add local configuration --- .gitignore | 5 +++-- README.md | 13 ++++++++++++- nabla/config.json | 2 +- src/actions/compileContract.ts | 5 ++++- src/utils/localConfiguration.ts | 30 ++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 src/utils/localConfiguration.ts diff --git a/.gitignore b/.gitignore index 9503602..1850b48 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ debug-project debug-contracts target-debug solang-mac-arm - -.yarn \ No newline at end of file +.yarn +nabla/excluded +localConfig.json diff --git a/README.md b/README.md index bb50cab..c340970 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The `deploy` command takes two required arguments: - `mockTestnet`: described [on Notion](https://www.notion.so/satoshipay/24-09-30-Nabla-Foucoco-Paseo-Deployment-1118b1b29b2f804eababf94383a56f7b) - `slippageTest`: used for validating slippage calulcations, see [this page on Notion](https://www.notion.so/satoshipay/24-09-30-Public-Deployment-1118b1b29b2f807283dbd10e0a6ae8b9?pvs=4#1158b1b29b2f80bc8be8efb7bc5197b4) -# Required +# Setup ``` brew install binaryen @@ -31,6 +31,17 @@ brew install binaryen You can find the installation instructions for solang [here](https://solang.readthedocs.io/en/v0.3.3/installing.html). +## Setup local configuration + +Create a file `localConfig.json` in the root folder of this repository and add the following content: + +``` +{ + "solangPath": "path/to/your/solang/binary" +} + +``` + ### Build from source If you want to test a specific version, you can build solang from source. diff --git a/nabla/config.json b/nabla/config.json index 1193179..9e10094 100644 --- a/nabla/config.json +++ b/nabla/config.json @@ -69,7 +69,7 @@ "init": "npm" }, "pendulumWrappers": { - "git": "https://github.com/pendulum-chain/pendulum-ink-wrapper", + "git": "https://github.com/pendulum-chain/pendulum-solidity-wrapper", "branch": "master" } }, diff --git a/src/actions/compileContract.ts b/src/actions/compileContract.ts index 6d52b7b..751924c 100644 --- a/src/actions/compileContract.ts +++ b/src/actions/compileContract.ts @@ -6,6 +6,7 @@ import { runCommand } from "../utils/childProcess"; import { ContractSourcecodeId } from "../types"; import { ContractDeploymentState } from "../processScripts"; import { Project } from "../project"; +import { getLocalConfiguration } from "../utils/localConfiguration"; export async function compileContract( contractId: ContractSourcecodeId, @@ -72,9 +73,11 @@ async function actuallyCompileContract( return metadataFileName; } + const { solangPath } = await getLocalConfiguration(); + updateContractStatus("compiling"); const solangResult = await runCommand([ - "../clones/solang/target/release/solang", + solangPath, "compile", "--no-strength-reduce", // temporary fix for https://github.com/hyperledger/solang/issues/1507 "--target", diff --git a/src/utils/localConfiguration.ts b/src/utils/localConfiguration.ts new file mode 100644 index 0000000..4858ff5 --- /dev/null +++ b/src/utils/localConfiguration.ts @@ -0,0 +1,30 @@ +import { readFile } from "fs/promises"; +import { join } from "path"; + +export interface LocalConfiguration { + solangPath: string; +} + +const DEFAULT_LOCAL_CONFIGURATION: LocalConfiguration = { + solangPath: "solang", +}; + +let localConfiguration: LocalConfiguration | undefined = undefined; + +export async function getLocalConfiguration(): Promise { + if (localConfiguration !== undefined) { + return localConfiguration; + } + + const localConfigurationFile = join(import.meta.dirname, "../../localConfig.json"); + + try { + const localConfigurationContent = await readFile(localConfigurationFile, { encoding: "utf-8" }); + const parsedLocalConfiguration = JSON.parse(localConfigurationContent) as LocalConfiguration; + localConfiguration = { ...DEFAULT_LOCAL_CONFIGURATION, ...parsedLocalConfiguration }; + return localConfiguration; + } catch { + localConfiguration = DEFAULT_LOCAL_CONFIGURATION; + return localConfiguration; + } +}