-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep only universal app examples (#199)
- Loading branch information
Showing
157 changed files
with
1,428 additions
and
93,839 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions
22
universal/hello/contracts/Hello.sol → examples/hello/contracts/Hello.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
import {RevertContext, RevertOptions} from "@zetachain/protocol-contracts/contracts/Revert.sol"; | ||
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/UniversalContract.sol"; | ||
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IGatewayZEVM.sol"; | ||
import "@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol"; | ||
|
||
contract Hello is UniversalContract { | ||
GatewayZEVM public gateway; | ||
|
||
event HelloEvent(string, string); | ||
event ContextDataRevert(RevertContext); | ||
event RevertEvent(string, RevertContext); | ||
|
||
address constant gatewayAddress = | ||
0x610178dA211FEF7D417bC0e6FeD39F05609AD788; | ||
constructor(address payable gatewayAddress) { | ||
gateway = GatewayZEVM(gatewayAddress); | ||
} | ||
|
||
function onCrossChainCall( | ||
zContext calldata context, | ||
address zrc20, | ||
uint256 amount, | ||
bytes calldata message | ||
) external override { | ||
string memory decodedMessage; | ||
if (message.length > 0) { | ||
decodedMessage = abi.decode(message, (string)); | ||
} | ||
emit HelloEvent("Hello from a universal app", decodedMessage); | ||
string memory name = abi.decode(message, (string)); | ||
emit HelloEvent("Hello on ZetaChain", name); | ||
} | ||
|
||
function onRevert(RevertContext calldata revertContext) external override { | ||
emit ContextDataRevert(revertContext); | ||
emit RevertEvent("Revert on ZetaChain", revertContext); | ||
} | ||
} |
13 changes: 5 additions & 8 deletions
13
...rsal/hello/contracts/ReceiverContract.sol → examples/hello/contracts/Revert.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
1 change: 1 addition & 0 deletions
1
universal/hello/hardhat.config.ts → examples/hello/hardhat.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"test": "echo \"Error: no test specified\" && exit 1", | ||
"lint:fix": "npx eslint . --ext .js,.ts --fix", | ||
"lint": "npx eslint . --ext .js,.ts", | ||
"deploy": "npx hardhat compile --force && npx hardhat deploy --network localhost" | ||
"deploy": "npx hardhat compile --force && npx hardhat deploy --network localhost && npx hardhat deploy-revert --network localhost" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
|
@@ -28,7 +28,7 @@ | |
"@types/node": ">=12.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.59.9", | ||
"@typescript-eslint/parser": "^5.59.9", | ||
"@zetachain/localnet": "3.0.2", | ||
"@zetachain/localnet": "3.0.3", | ||
"@zetachain/toolkit": "13.0.0-rc2", | ||
"axios": "^1.3.6", | ||
"chai": "^4.2.0", | ||
|
@@ -54,10 +54,9 @@ | |
"packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72", | ||
"dependencies": { | ||
"@coral-xyz/anchor": "0.30.0", | ||
"@openzeppelin/contracts": "^4.9.6", | ||
"@solana-developers/helpers": "^2.4.0", | ||
"@solana/spl-memo": "^0.2.5", | ||
"@solana/web3.js": "^1.95.2", | ||
"@zetachain/protocol-contracts": "10.0.0-rc10" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { task, types } from "hardhat/config"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
|
||
const main = async (args: any, hre: HardhatRuntimeEnvironment) => { | ||
const network = hre.network.name; | ||
|
||
const [signer] = await hre.ethers.getSigners(); | ||
if (signer === undefined) { | ||
throw new Error( | ||
`Wallet not found. Please, run "npx hardhat account --save" or set PRIVATE_KEY env variable (for example, in a .env file)` | ||
); | ||
} | ||
|
||
const factory = await hre.ethers.getContractFactory(args.name); | ||
const contract = await (factory as any).deploy(args.gatewayZetaChain); | ||
await contract.deployed(); | ||
|
||
if (args.json) { | ||
console.log(JSON.stringify(contract)); | ||
} else { | ||
console.log(`🔑 Using account: ${signer.address} | ||
🚀 Successfully deployed "${args.name}" contract on ${network}. | ||
📜 Contract address: ${contract.address} | ||
`); | ||
} | ||
}; | ||
|
||
task("deploy", "Deploy the contract", main) | ||
.addFlag("json", "Output in JSON") | ||
.addOptionalParam("name", "Contract to deploy", "Hello") | ||
.addOptionalParam( | ||
"gatewayZetaChain", | ||
"Gateway address", | ||
"0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2407,10 +2407,10 @@ | |
typescript "5.5.4" | ||
zod "3.22.4" | ||
|
||
"@zetachain/[email protected].2": | ||
version "3.0.2" | ||
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.0.2.tgz#4b9af86f8b0810a9a528073611c0e3a5ac49c28a" | ||
integrity sha512-nNBAOWWUuebUSuRMTwVnsF9V3W5HcWZ+vTiLSINMXBagbKyOJ4wQAK7nFBBB1UZBTnAcGPyMQVP+ymoEvEpn6g== | ||
"@zetachain/[email protected].3": | ||
version "3.0.3" | ||
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.0.3.tgz#2d822791c1814690971c35efc43be6b3743045e7" | ||
integrity sha512-s/DGVFzGwURwqw6krkU9jlMCUBYbwgOEQPpYbGwVqBHrMR4YB/EFur8FHz1Sc5VPMDV1VarbSsC253oI99Tulw== | ||
dependencies: | ||
"@inquirer/prompts" "^5.5.0" | ||
"@uniswap/v2-core" "^1.0.1" | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.