Skip to content

Commit

Permalink
updates after trying with my-counter-contract
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfschoen committed Nov 3, 2024
1 parent 812394c commit b7fc6e8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
21 changes: 16 additions & 5 deletions _SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,25 @@ docker rmi sco

* [Compile](https://docs.scrt.network/secret-network-documentation/development/readme-1/compile-and-deploy#compile-the-code). Note: Outputs contract.wasm and contract.wasm.gz file in the root directory of the secret-contracts/nunya-contract folder. Using `make build-mainnet-reproducible` will remove contract.wasm so only the optimised contract.wasm.gz remains. Warning: If you only run `make build-mainnet` then you will get this error https://github.com/svub/nunya/issues/8 when deploying.

```
cd packages/secret-contracts/nunya-contract
make build-mainnet-reproducible
```
* Nunya Contract
```
cd packages/secret-contracts/nunya-contract
make build-mainnet-reproducible
```
OR
* My Counter Contract (Example only)
```
cd packages/secret-contracts/my-counter-contract
make build-mainnet-reproducible
```
* Upload and Instantiate
> IMPORTANT: Currently unable to deploy due to this TNLS error https://github.com/svub/nunya/issues/8
> IMPORTANT: Prior to Upload step it is necessary to configure the wallet, network, and endpoint to use either Local or Testnet, and to specify what project's compiled smart contract WASM file to use and whether to use the optimized build (e.g. ./nunya-contract/optimized-wasm/secret_evm_storage.wasm.gz or ./nunya-contract/contract.wasm.gz) in the script ./packages/secret-contracts-scripts/src/index.ts
> IMPORTANT: Prior to Instantiation step it is necessary to deploy the EVM Gateway
```
yarn run secret:clean:uploadContract
Expand Down
4 changes: 3 additions & 1 deletion packages/secret-contracts-scripts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ console.log('wallet address: ', wallet.address);
const rootPath = path.resolve(__dirname, '../../../'); // relative to ./dist
console.log('rootPath', rootPath)
// const contract_wasm: any = fs.readFileSync(`${rootPath}/packages/secret-contracts/nunya-contract/contract.wasm.gz`);
// Optimised
// // Optimised my-counter-contract
// const contract_wasm: any = fs.readFileSync(`${rootPath}/packages/secret-contracts/my-counter-contract/optimized-wasm/secret_contract_example.wasm.gz`);
// Optimised nunya-contract
const contract_wasm: any = fs.readFileSync(`${rootPath}/packages/secret-contracts/nunya-contract/optimized-wasm/secret_evm_storage.wasm.gz`);

// Secret Testnet
Expand Down
1 change: 1 addition & 0 deletions packages/secret-contracts/my-counter-contract/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build results
/target
/optimized-wasm
Cargo.lock
contract.wasm*

Expand Down
14 changes: 9 additions & 5 deletions packages/secret-contracts/my-counter-contract/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ _build-mainnet:
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown

# like build-mainnet, but slower and more deterministic
.PHONY: build-mainnet-reproducible
build-mainnet-reproducible:
# https://hub.docker.com/r/enigmampc/secret-contract-optimizer/tags
.PHONY: build-mainnet-reproducible _build-mainnet-reproducible
build-mainnet-reproducible: _build-mainnet-reproducible
_build-mainnet-reproducible:
cargo clean && AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang RUSTFLAGS='-C link-arg=-s' && \
docker buildx build --label "sco" --tag "sco" -f "../../../docker/secret-contract-optimizer.Dockerfile" . && \
docker run --rm -v "$$(pwd)":/contract \
--mount type=volume,source="$$(basename "$$(pwd)")_cache",target=/contract/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
ghcr.io/scrtlabs/localsecret:v1.6.0-rc.3
--mount type=volume,source="$$(basename "$$(pwd)")_cache",target=/contract/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
sco:latest

.PHONY: compress-wasm
compress-wasm:
Expand Down

0 comments on commit b7fc6e8

Please sign in to comment.