Skip to content

Commit

Permalink
fix: Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfschoen committed Dec 2, 2024
1 parent 24647dc commit 38aae5c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 39 deletions.
2 changes: 0 additions & 2 deletions _DEMO_AND_VIDEO.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
* Video of Nunya.business compile, upload, and instantiate a SecretPath Public Gateway Contract to Sepolia Ethereum Testnet.
[YouTube Link](https://youtu.be/O0unCWsrKA4)
* It successfully also deploys NunyaBusiness contract since we added `secretContract = IGateway(gateway);` to use an interface based on Gateway.sol instead of the old DummyGatewayContract interface file.
* Note: The Gateway was deployed with tx: 0x848763e137d97ea53000f360fa27db943f47a13e4e03982320d72dec33478e36 to address 0x41E52332e76988AFBc38280583a7A02492177C65
* Note: The NunyaContract was deployed with tx:

* Video of Nunya.business frontend integration [video](./assets/demo.mp4)
61 changes: 37 additions & 24 deletions _SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,6 @@ yarn run secret:instantiate
* TODO: Add the ABI of the uploaded and instantiated EVM Gateway contract from ./nunya/packages/hardhat/artifacts/contracts/Gateway.sol/Gateway.json to ./nunya/packages/secret-contracts-scripts/src/config/abi.ts for use in submit.ts
* Query Pubkey
```
cd ../../../
yarn run secret:queryPubkey
```
* TODO: Transaction `secretContract.retrievePubkey`
```
yarn run secret:submit
```
* View logs at ./logs/instantiateOutput.log
* View on Secret Testnet block explorer at https://testnet.ping.pub/secret/
Expand All @@ -264,21 +255,43 @@ yarn run secret:requestValue
* Choose "File explorer" tab on the left
* Choose "Upload Folder" icon
* Choose the contracts folder ./svub/nunya/packages/hardhat/contracts containing the Solidity files
* Select Gateway.sol
* Click compile icon
* Choose "Solidity compiler" tab on the left
* Choose version 0.8.0
* Click "Compile Gateway.sol" and view the warnings by scrolling down
* Choose "Deploy and run transactions" tab on the left
* Click "Environment" and choose "Customize this list..."
* Select "Sepolia Testnet - Metamask"
* Click "Sepolia Testnet - Metamask" from the "Environment" drop-down list
* Allow Metamask to switch to Sepolia network in the popup that appears
* Open Metamask and click the Remix icon and choose to "Connect more accounts..." to remix.ethereum.org and connect the address associated with the DEPLOYER_ADDRESS used in the .env file
* Select "Account" to be that DEPLOYER_ADDRESS
* Enter the deployed Gateway EVM address on Sepolia Testnet (e.g. 0x8375b3D0555c818eF2e50823f8F1F4cdD0696c54) and click "At Address"
* Scroll down to the "Deployed Contracts" section that is autogenerated to interact with the deployed contract
* Click "secret_gateway_signer_address" to call the Gateway contract getter for that constant and return its value that should be shown as 0x2821E794B01ABF0cE2DA0ca171A1fAc68FaDCa06
* Gateway.sol
* Open Gateway.sol
* Click compile icon
* Choose "Solidity compiler" tab on the left
* Choose version 0.8.0
* Click "Compile Gateway.sol" and view the warnings by scrolling down
* Choose "Deploy and run transactions" tab on the left
* Click "Environment" and choose "Customize this list..."
* Select "Sepolia Testnet - Metamask"
* Click "Sepolia Testnet - Metamask" from the "Environment" drop-down list
* Allow Metamask to switch to Sepolia network in the popup that appears
* Open Metamask and click the Remix icon and choose to "Connect more accounts..." to remix.ethereum.org and connect the address associated with the DEPLOYER_ADDRESS used in the .env file
* Select "Account" to be that DEPLOYER_ADDRESS
* Enter the deployed Gateway EVM address on Sepolia Testnet (e.g. mentioned in ./nunya/packages/secret-contracts-scripts/src/config/deploy.ts) and click "At Address"
* Scroll down to the "Deployed Contracts" section that is autogenerated to interact with the deployed contract
* Click "secret_gateway_signer_address" to call the Gateway contract getter for that constant and return its value that should be shown as 0x2821E794B01ABF0cE2DA0ca171A1fAc68FaDCa06
* Click `setSecretContractInfo` to create a transaction after providing the following arguments `config.secret.testnet.contractCodeHash` and `config.secret.testnet.secretContractAddress` using values from ./nunya/packages/secret-contracts-scripts/src/config/deploy.ts
* Retrieve their values by clicking to calls `routing_info` and `routing_code_hash`
* NunyaBusiness.sol
* Repeat relevant initial steps above for NunyaBusiness.sol
* Enter the deployed NunyaBusiness EVM address on Sepolia Testnet (e.g. mentioned in ./nunya/packages/secret-contracts-scripts/src/config/deploy.ts) and click "At Address"
* Scroll down to the "Deployed Contracts" section that is autogenerated to interact with the deployed contract
* FIXME - Click "setGatewayAddress" to create a transaction after providing the following argument to call the NunyaBusiness contracts transaction using the latest value from ./nunya/packages/secret-contracts-scripts/src/config/deploy.ts
* FIXME - Retrieve its value by clicking to call `CustomGateway`
##### Unsorted
* Query Pubkey
```
cd ../../../
yarn run secret:queryPubkey
```
* TODO: Transaction `secretContract.retrievePubkey`
```
yarn run secret:submit
```
### About Custom Gateways and Relayers <a id="about-gateways-relayers"></a>
Expand Down
5 changes: 3 additions & 2 deletions packages/hardhat/contracts/NunyaBusiness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract NunyaBusiness is Ownable, Utils {
}

/// @notice CustomGateway stores address to the Gateway contract to call the Secret contract
address public payable CustomGateway;
address payable public CustomGateway;

IGateway secretContract;

Expand Down Expand Up @@ -111,7 +111,8 @@ contract NunyaBusiness is Ownable, Utils {
/// @notice Sets the address to the Gateway contract
/// @param _CustomGateway address of the gateway
function setGatewayAddress(address payable _CustomGateway) public payable onlyOwner {
CustomGateway = _CustomGateway;
// https://docs.soliditylang.org/en/latest/types.html#address
CustomGateway = payable(address(_CustomGateway));
fundGateway(0); // send all funds to the gateway
}

Expand Down
10 changes: 4 additions & 6 deletions packages/secret-contracts-scripts/src/requestValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const SECRET_ADDRESS = secretContractAddress;
const CONTRACT_CODE_HASH = contractCodeHash;

async function unsafeRequestValue() {
// TODO: Use the nunya and gateway address stored in deploy.ts
const gatewayAddressInstance = "0x5Be91fd4b49489bb3aEc8bE2F5Fa1d83FD8C5A1b";
const nunyaAddressInstance = "0x41E52332e76988AFBc38280583a7A02492177C65";
const ifaceGateway = new ethers.utils.Interface(gatewayAbi.abi);
const ifaceNunya = new ethers.utils.Interface(nunyaAbi.abi);

Expand Down Expand Up @@ -56,11 +53,11 @@ async function unsafeRequestValue() {
console.log("Current block number: ", blockNumber);

// TODO: Redeploy with `CustomGateway` publically accessible
const nunyaContract = new ethers.Contract(nunyaAddressInstance, ifaceNunya, managedSigner);
const nunyaContract = new ethers.Contract(nunyaBusinessContractAddress, ifaceNunya, managedSigner);
// const CustomGateway = await nunyaContract.CustomGateway();
// console.log("CustomGateway: ", CustomGateway);

const gatewayContract = new ethers.Contract(gatewayAddressInstance, ifaceGateway, managedSigner);
const gatewayContract = new ethers.Contract(gatewayContractAddress, ifaceGateway, managedSigner);
const taskDestinationNetwork = await gatewayContract.task_destination_network();
console.log("taskDestinationNetwork: ", taskDestinationNetwork);

Expand All @@ -69,7 +66,8 @@ async function unsafeRequestValue() {
console.log("responseSetUnsafeSetSecretContractInfo", txResponseSetUnsafeSetSecretContractInfo);
// wait() has the logic to return receipt once the transaction is mined
const receipt = await txResponseSetUnsafeSetSecretContractInfo.wait();
console.log("receipt: ", receipt);
console.log("Receipt: ", receipt);
console.log("Tx Hash: ", receipt.hash);
}

async function main() {
Expand Down
5 changes: 0 additions & 5 deletions packages/secret-contracts-scripts/src/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ function uint8ArrayToNumV2(arr: any) {
return num;
}

// relates to unsafeRequestSecretContractPubkey
async function unsafeRequestSecretContractPubkey() {
// // Ethereum Sepolia
// // IGNORE
// const gatewayAddressInstance = "0x5Be91fd4b49489bb3aEc8bE2F5Fa1d83FD8C5A1b";
// const nunyaAddressInstance = "0x41E52332e76988AFBc38280583a7A02492177C65";
const ifaceGateway = new ethers.utils.Interface(gatewayAbi.abi);
const ifaceNunya = new ethers.utils.Interface(nunyaAbi.abi);

Expand Down

0 comments on commit 38aae5c

Please sign in to comment.