Skip to content

Commit

Permalink
integrate example my-counter-contract and upload and instantiate cont…
Browse files Browse the repository at this point in the history
…racts
  • Loading branch information
ltfschoen committed Oct 5, 2024
1 parent ffed8a2 commit 1150574
Show file tree
Hide file tree
Showing 54 changed files with 7,650 additions and 5,620 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ node_modules
.idea

# cli
dist
dist

**/node_modules/
**/yarn-error.log
**/.env
.DS_Store
.nx/cache
tsconfig.tsbuildinfo
.env
packages/secret-upload-contract/.env
packages/secret-instantiate-contract/.env
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/hydrogen
541 changes: 0 additions & 541 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

783 changes: 0 additions & 783 deletions .yarn/releases/yarn-3.2.3.cjs

This file was deleted.

894 changes: 894 additions & 0 deletions .yarn/releases/yarn-4.2.2.cjs

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
compressionLevel: mixed

enableColors: true

enableGlobalCache: false

nmHoistingLimits: workspaces

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.2.3.cjs
yarnPath: .yarn/releases/yarn-4.2.2.cjs
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,60 @@ Run smart contract test with `yarn hardhat:test`
- Edit your frontend homepage at `packages/nextjs/app/page.tsx`. For guidance on [routing](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation.
- Edit your deployment scripts in `packages/hardhat/deploy`

### Secret Network

#### Setup

* Reference https://docs.scrt.network/secret-network-documentation/development/readme-1

* Install Git and Make - https://docs.scrt.network/secret-network-documentation/development/readme-1/setting-up-your-environment#install-requirements

* Install Rust
```
rustup update
rustup toolchain use stable
rustup target add wasm32-unknown-unknown
source "$HOME/.cargo/env"
```
* Install Cargo Generate
```
cargo install cargo-generate --features vendored-openssl
```

* Install dependencies
```
nvm use
npm install --global lerna
yarn set version 4.2.2
corepack enable
corepack prepare [email protected] --activate
```

#### Create, Compile and Deploy Contract (Example: Counter)

* Reference https://docs.scrt.network/secret-network-documentation/development/readme-1/compile-and-deploy

```
mkdir -p packages/secret-contracts && cd packages/secret-contracts
cargo generate --git https://github.com/scrtlabs/secret-template.git --name my-counter-contract
```

* Compile. Note: Outputs contract.wasm and contract.wasm.gz file in the root directory of the secret-contracts/my-counter-contract folder

```
cd packages/secret-contracts/my-counter-contract
make build
```

* OPTIONAL - optimize contract code

```
yarn run secret:clean:uploadContract
yarn run secret:start:uploadContract
yarn run secret:clean:instantiateContract
yarn run secret:start:instantiateContract
```

## Documentation

Expand All @@ -77,4 +131,4 @@ To know more about its features, check out our [website](https://scaffoldeth.io)

We welcome contributions to Scaffold-ETH 2!

Please see [CONTRIBUTING.MD](https://github.com/scaffold-eth/scaffold-eth-2/blob/main/CONTRIBUTING.md) for more information and guidelines for contributing to Scaffold-ETH 2.
Please see [CONTRIBUTING.MD](https://github.com/scaffold-eth/scaffold-eth-2/blob/main/CONTRIBUTING.md) for more information and guidelines for contributing to Scaffold-ETH 2.
11 changes: 11 additions & 0 deletions dotenv.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const dotenv = require("dotenv")
const path = require("path")
if (process.env.NODE_ENV === "production") {
dotenv.config({
path: path.resolve(__dirname, `./.env.production`),
})
} else {
dotenv.config({
path: path.resolve(__dirname, "./.env"),
})
}
8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.0.0",
"packages": [
"packages/*"
],
"npmClient": "yarn"
}
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "se-2",
"version": "0.0.1",
"private": true,
"workspaces": {
"packages": [
"packages/*"
]
"workspaces": [
"packages/*"
],
"devDependencies": {
"husky": "~8.0.3",
"lint-staged": "~13.2.2"
},
"scripts": {
"account": "yarn workspace @se-2/hardhat account",
Expand All @@ -32,13 +34,13 @@
"test": "yarn hardhat:test",
"vercel": "yarn workspace @se-2/nextjs vercel",
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo",
"verify": "yarn workspace @se-2/hardhat verify"
},
"devDependencies": {
"husky": "~8.0.3",
"lint-staged": "~13.2.2"
"verify": "yarn workspace @se-2/hardhat verify",
"secret:clean:uploadContract": "yarn workspace secret-upload-contract clean",
"secret:start:uploadContract": "yarn workspace secret-upload-contract start",
"secret:clean:instantiateContract": "yarn workspace secret-instantiate-contract clean",
"secret:start:instantiateContract": "yarn workspace secret-instantiate-contract start"
},
"packageManager": "yarn@3.2.3",
"packageManager": "yarn@4.2.2",
"engines": {
"node": ">=18.18.0"
}
Expand Down
7 changes: 7 additions & 0 deletions packages/secret-contracts/my-counter-contract/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[alias]
# Temporarily removed the backtraces feature from the unit-test run due to compilation errors in
# the cosmwasm-std package:
# cosmwasm-std = { git = "https://github.com/scrtlabs/cosmwasm", branch = "secret" }
# unit-test = "test --lib --features backtraces"
unit-test = "test --lib"
schema = "run --bin schema --features schema"
11 changes: 11 additions & 0 deletions packages/secret-contracts/my-counter-contract/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.rs]
indent_size = 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# install-rust

A small github action to install `rustup` and a Rust toolchain. This is
generally expressed inline, but it was repeated enough in this repository it
seemed worthwhile to extract.

Some gotchas:

- Can't `--self-update` on Windows due to permission errors (a bug in Github
Actions)
- `rustup` isn't installed on macOS (a bug in Github Actions)

When the above are fixed we should delete this action and just use this inline:

```yml
- run: rustup update $toolchain && rustup default $toolchain
shell: bash
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Install Rust toolchain"
description: "Install both `rustup` and a Rust toolchain"

inputs:
toolchain:
description: "Default toolchain to install"
required: false
default: "stable"

runs:
using: node16
main: "main.js"
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const child_process = require('child_process');
const toolchain = process.env.INPUT_TOOLCHAIN;
const fs = require('fs');

function set_env(name, val) {
fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`)
}

// Needed for now to get 1.24.2 which fixes a bug in 1.24.1 that causes issues
// on Windows.
if (process.platform === 'win32') {
child_process.execFileSync('rustup', ['self', 'update']);
}

child_process.execFileSync('rustup', ['set', 'profile', 'minimal']);
child_process.execFileSync('rustup', ['update', toolchain, '--no-self-update']);
child_process.execFileSync('rustup', ['default', toolchain]);

// Deny warnings on CI to keep our code warning-free as it lands in-tree. Don't
// do this on nightly though since there's a fair amount of warning churn there.
// RUSTIX: Disable this so that it doesn't overwrite RUSTFLAGS for setting
// "--cfg rustix_use_libc". We re-add it manually in the workflow.
//if (!toolchain.startsWith('nightly')) {
// set_env("RUSTFLAGS", "-D warnings");
//}

// Save disk space by avoiding incremental compilation, and also we don't use
// any caching so incremental wouldn't help anyway.
set_env("CARGO_INCREMENTAL", "0");

// Turn down debuginfo from 2 to 1 to help save disk space
set_env("CARGO_PROFILE_DEV_DEBUG", "1");
set_env("CARGO_PROFILE_TEST_DEBUG", "1");

if (process.platform === 'darwin') {
set_env("CARGO_PROFILE_DEV_SPLIT_DEBUGINFO", "unpacked");
set_env("CARGO_PROFILE_TEST_SPLIT_DEBUGINFO", "unpacked");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Integration Tests

on: [push, pull_request]

jobs:
tests:
name: ${{ matrix.make.name }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust: [1.63.0]
make:
- name: Run integration tests # Integration tests
task: "npx ts-node tests/integration.ts"
include:
- os: ubuntu-latest
sccache-path: /home/runner/.cache/sccache

env:
RUST_BACKTRACE: full
RUSTC_WRAPPER: sccache
RUSTV: ${{ matrix.rust }}
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ matrix.sccache-path }}
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out

# Service containers to run with `container-job`
services:
# Label used to access the service container
secret:
# Docker Hub image
image: ghcr.io/scrtlabs/localsecret:v1.6.0-rc.3
ports:
# Opens tcp port
- 5000:5000
- 9091:9091
- 1317:1317

steps:
- uses: actions/checkout@v3
- name: Install sccache
env:
LINK: https://github.com/mozilla/sccache/releases/download
SCCACHE_VERSION: v0.2.15
run: |
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
mkdir -p $HOME/.local/bin
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
chmod +x $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: npm --prefix tests/ install # Install dependencies
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}
- name: Add wasm toolchain
run: |
rustup target add wasm32-unknown-unknown
- name: Cache cargo registry
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Save sccache
uses: actions/cache@v2
continue-on-error: false
with:
path: ${{ matrix.sccache-path }}
key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-sccache-
- name: Start sccache server
run: sccache --start-server
- name: Compile code
run: make build
- name: ${{ matrix.make.name }}
run: ${{ matrix.make.task }}
- name: Print sccache stats
run: sccache --show-stats
- name: Stop sccache server
run: sccache --stop-server || true
Loading

0 comments on commit 1150574

Please sign in to comment.