Skip to content

Commit

Permalink
Merge branch 'main' of github.com:svub/nunya
Browse files Browse the repository at this point in the history
  • Loading branch information
svub committed Oct 9, 2024
2 parents 6eb78cc + 94742de commit fc87e25
Show file tree
Hide file tree
Showing 28 changed files with 591 additions and 380 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Run smart contract test with `yarn hardhat:test`
* Install Rust
```
rustup update
rustup toolchain use stable
rustup default stable
rustup target add wasm32-unknown-unknown
source "$HOME/.cargo/env"
```
Expand Down Expand Up @@ -111,6 +111,18 @@ cd packages/secret-contracts/my-counter-contract
make build
```

* FIXME: attempt to fix on macOS hack https://github.com/briansmith/ring/issues/1824
```
cd packages/secret-contracts/nunya-contract
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install llvm
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown
make build
```

* OPTIONAL - optimize contract code

* Upload and Instantiate
Expand Down
30 changes: 30 additions & 0 deletions packages/hardhat/contracts/DummyGateway.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// TODO in production
import "hardhat/console.sol";

// Dummy Secret Network EVM Gateway contract (so we can use the contracts on devnet)

contract SecretContract {
function newSecretUser(uint256 secret) external returns (uint256) {
return 6;
}
function linkPaymentRef(uint256 secret, string calldata ref) external returns (uint256) {
return 5;
}
function pay(string calldata ref, uint256 amount) external returns (uint256) {
return 4;
}
function payWithReceipt(string calldata ref, uint256 amount, uint256 userPubkey) external returns (uint256) {
return 3;
}
function withdraw(string calldata secret, address withdrawalAddress) external returns (uint256){
return 2;
}

function retrievePubkey() external returns (uint256){
return 1;
}

}
2 changes: 2 additions & 0 deletions packages/hardhat/contracts/NunyaBusiness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ contract NunyaBusiness {
secretContract = SecretContract(_gateway);
fundGateway(msg.value);

// TODO: only uncomment when hardhat has gateway deployed
// secretContract.retrievePubkey();

// Lock secretContractPubkey to Owner. After it is set it cannot be reset.
secretContractPubkey = uint256(uint160(msg.sender));
}
Expand Down
16 changes: 14 additions & 2 deletions packages/hardhat/deploy/00_deploy_your_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const deployYourContract: DeployFunction = async function (hre: HardhatRuntimeEn
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;

await deploy("NunyaBusiness", {

const Gateway = await deploy("SecretContract", {
from: deployer,
// Contract constructor arguments
args: [deployer],
Expand All @@ -33,6 +34,17 @@ const deployYourContract: DeployFunction = async function (hre: HardhatRuntimeEn
autoMine: true,
});

await deploy("NunyaBusiness", {
from: deployer,
// Contract constructor arguments
args: [deployer, Gateway.address],
log: true,
gasLimit: 3000000,
// autoMine: can be passed to the deploy function to make the deployment process faster on local networks by
// automatically mining the contract deployment transaction. There is no effect on live networks.
autoMine: true,
});

// Get the deployed contract to interact with it after deploying.
const nunya = await hre.ethers.getContract<Contract>("NunyaBusiness", deployer);
console.log("👋 Nunya contract:", nunya, await nunya.getAddress());
Expand All @@ -42,4 +54,4 @@ export default deployYourContract;

// Tags are useful if you have multiple deploy files and only want to run one of them.
// e.g. yarn deploy --tags YourContract
deployYourContract.tags = ["NunyaBusiness"];
deployYourContract.tags = ["NunyaBusiness", "SecretContract"];
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ unit-test:
.PHONY: build _build
build: _build compress-wasm
_build:
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --features="debug-print"
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown
# RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --features="debug-print"

# This is a build suitable for uploading to mainnet.
# Calls to `debug_print` get removed by the compiler.
Expand Down Expand Up @@ -69,4 +70,4 @@ integration-test:
.PHONY: clean
clean:
cargo clean
-rm -f ./contract.wasm ./contract.wasm.gz
-rm -f ./contract.wasm ./contract.wasm.gz
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# FIXME - update these after deploying nunya-contract
MNEMONIC="shed clerk pray velvet flower tide bug idea private solar prize tackle"
CODE_HASH="e8d3f1c82b620fced20a7d8878ea81cd5af3de28ad7427246c3d7e93b2fa3c4f"
SECRET_ADDRESS="secret1m9d45wakl6vmshxc5kp6ztrf29uc3gzm8vpe47"
SECRET_ADDRESS="secret1m9d45wakl6vmshxc5kp6ztrf29uc3gzm8vpe47"
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ dotenv.config();

let query = async () => {
const secretjs = new SecretNetworkClient({
url: "https://lcd.testnet.secretsaturn.net",
url: "https://api.pulsar3.scrttestnet.com",
chainId: "pulsar-3",
});

const query_tx = await secretjs.query.compute.queryContract({
contract_address: process.env.SECRET_ADDRESS,
code_hash: process.env.CODE_HASH,
query: { retrieve_bids: { key: 1 } },
query: { retrieve_pubkey_query: { key: 1 } },
});
console.log(query_tx);
};
Expand Down
Loading

0 comments on commit fc87e25

Please sign in to comment.