@reality.eth/contracts 3.0.45 → 3.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/.prettierrc +16 -0
  2. package/abi/solc-0.8.20/RealityETH-4.0.abi.json +1 -0
  3. package/abi/solc-0.8.20/RealityETH_ERC20-4.0.abi.json +1 -0
  4. package/bytecode/Arbitrator.bin +1 -1
  5. package/bytecode/RealityETH-3.0.bin +1 -1
  6. package/bytecode/RealityETH-4.0.bin +1 -0
  7. package/bytecode/RealityETH_ERC20-3.0.bin +1 -1
  8. package/bytecode/RealityETH_ERC20-4.0.bin +1 -0
  9. package/chains/chainid.network.json +5033 -431
  10. package/chains/deployments/300/ETH/RealityETH-3.0.json +7 -0
  11. package/chains/supported.json +3 -0
  12. package/development/contracts/.solhint.json +9 -0
  13. package/development/contracts/Arbitrator.sol +32 -81
  14. package/development/contracts/BalanceHolder.sol +4 -10
  15. package/development/contracts/BalanceHolder_ERC20.sol +5 -11
  16. package/development/contracts/CallbackClient.sol +3 -10
  17. package/development/contracts/ERC20Token.sol +29 -30
  18. package/development/contracts/ExplodingCallbackClient.sol +1 -4
  19. package/development/contracts/IArbitrator.sol +23 -23
  20. package/development/contracts/IArbitratorCore.sol +14 -0
  21. package/development/contracts/IArbitratorCrowdFundable.sol +8 -0
  22. package/development/contracts/IArbitratorErrors.sol +10 -0
  23. package/development/contracts/IArbitratorForeignProxy.sol +15 -7
  24. package/development/contracts/IArbitratorLegacy.sol +9 -0
  25. package/development/contracts/IArbitratorManagement.sol +25 -0
  26. package/development/contracts/IBalanceHolder.sol +3 -3
  27. package/development/contracts/IBalanceHolder_ERC20.sol +5 -5
  28. package/development/contracts/IERC20.sol +4 -5
  29. package/development/contracts/IOwned.sol +3 -3
  30. package/development/contracts/IRealityETH.sol +5 -58
  31. package/development/contracts/IRealityETHCommitReveal.sol +17 -0
  32. package/development/contracts/IRealityETHCommitReveal_ERC20.sol +16 -0
  33. package/development/contracts/IRealityETHCore.sol +135 -0
  34. package/development/contracts/IRealityETHCore_ERC20.sol +149 -0
  35. package/development/contracts/IRealityETHErrors.sol +86 -0
  36. package/development/contracts/IRealityETHErrors_ERC20.sol +13 -0
  37. package/development/contracts/IRealityETH_ERC20.sol +5 -62
  38. package/development/contracts/Owned.sol +4 -6
  39. package/development/contracts/{RealityETH-3.0.sol → RealityETH-4.0.sol} +221 -383
  40. package/development/contracts/{RealityETH_ERC20-3.0.sol → RealityETH_ERC20-4.0.sol} +238 -474
  41. package/development/contracts/RealityETH_ERC20_Factory.sol +47 -42
  42. package/development/contracts/RegisteredWalletArbitrator.sol +8 -15
  43. package/development/contracts/compile.py +3 -0
  44. package/development/scripts/string_to_error.py +111 -0
  45. package/development/version_checksums/check_matches_flat.sh +20 -0
  46. package/development/version_checksums/check_matches_last.sh +37 -0
  47. package/development/version_checksums/log_bytecode_history.sh +41 -0
  48. package/generated/chains.json +33 -5
  49. package/generated/tokens.json +1 -0
  50. package/non_standard_deployments/zksync/LICENSE +21 -0
  51. package/non_standard_deployments/zksync/README.md +51 -0
  52. package/non_standard_deployments/zksync/deploy/deploy.ts +11 -0
  53. package/non_standard_deployments/zksync/deploy/utils.ts +168 -0
  54. package/non_standard_deployments/zksync/hardhat.config.ts +55 -0
  55. package/non_standard_deployments/zksync/package-lock.json +6295 -0
  56. package/non_standard_deployments/zksync/package.json +34 -0
  57. package/package.json +7 -3
  58. package/scripts/transfer_arbitrator.js +60 -0
  59. package/tests/python/requirements.txt +55 -54
  60. package/tests/python/test.py +150 -50
  61. package/tests/python/test_erc20.py +15 -14
  62. package/tokens/ETH.json +3 -2
  63. package/non_standard_deployments/zksync2/README +0 -21
  64. package/non_standard_deployments/zksync2/contracts/RealityETH_ERC20-3.0.sol +0 -1096
  65. package/non_standard_deployments/zksync2/deploy/deploy.ts +0 -62
  66. package/non_standard_deployments/zksync2/deploy/deploy_erc20.ts +0 -56
  67. package/non_standard_deployments/zksync2/deploy/deploy_mainnet.ts +0 -46
  68. package/non_standard_deployments/zksync2/hardhat.config.ts +0 -27
  69. package/non_standard_deployments/zksync2/package.json +0 -15
  70. package/non_standard_deployments/zksync2/yarn.lock +0 -2898
  71. /package/non_standard_deployments/{zksync2 → zksync}/contracts/RealityETH-3.0.sol +0 -0
@@ -0,0 +1,168 @@
1
+ import { Provider, Wallet } from "zksync-ethers";
2
+ import * as hre from "hardhat";
3
+ import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
4
+ import dotenv from "dotenv";
5
+ import { ethers } from "ethers";
6
+
7
+ import "@matterlabs/hardhat-zksync-node/dist/type-extensions";
8
+ import "@matterlabs/hardhat-zksync-verify/dist/src/type-extensions";
9
+
10
+ // Load env file
11
+ dotenv.config();
12
+
13
+ export const getProvider = () => {
14
+ const rpcUrl = hre.network.config.url;
15
+ if (!rpcUrl) throw `⛔️ RPC URL wasn't found in "${hre.network.name}"! Please add a "url" field to the network config in hardhat.config.ts`;
16
+
17
+ // Initialize zkSync Provider
18
+ const provider = new Provider(rpcUrl);
19
+
20
+ return provider;
21
+ }
22
+
23
+ export const getWallet = (privateKey?: string) => {
24
+ if (!privateKey) {
25
+ // Get wallet private key from .env file
26
+ if (!process.env.WALLET_PRIVATE_KEY) throw "⛔️ Wallet private key wasn't found in .env file!";
27
+ }
28
+
29
+ const provider = getProvider();
30
+
31
+ // Initialize zkSync Wallet
32
+ const wallet = new Wallet(privateKey ?? process.env.WALLET_PRIVATE_KEY!, provider);
33
+
34
+ return wallet;
35
+ }
36
+
37
+ export const verifyEnoughBalance = async (wallet: Wallet, amount: bigint) => {
38
+ // Check if the wallet has enough balance
39
+ const balance = await wallet.getBalance();
40
+ if (balance < amount) throw `⛔️ Wallet balance is too low! Required ${ethers.formatEther(amount)} ETH, but current ${wallet.address} balance is ${ethers.formatEther(balance)} ETH`;
41
+ }
42
+
43
+ /**
44
+ * @param {string} data.contract The contract's path and name. E.g., "contracts/Greeter.sol:Greeter"
45
+ */
46
+ export const verifyContract = async (data: {
47
+ address: string,
48
+ contract: string,
49
+ constructorArguments: string,
50
+ bytecode: string
51
+ }) => {
52
+ const verificationRequestId: number = await hre.run("verify:verify", {
53
+ ...data,
54
+ noCompile: true,
55
+ });
56
+ return verificationRequestId;
57
+ }
58
+
59
+ type DeployContractOptions = {
60
+ /**
61
+ * If true, the deployment process will not print any logs
62
+ */
63
+ silent?: boolean
64
+ /**
65
+ * If true, the contract will not be verified on Block Explorer
66
+ */
67
+ noVerify?: boolean
68
+ /**
69
+ * If specified, the contract will be deployed using this wallet
70
+ */
71
+ wallet?: Wallet
72
+ }
73
+ export const deployContract = async (contractArtifactName: string, constructorArguments?: any[], options?: DeployContractOptions) => {
74
+ const log = (message: string) => {
75
+ if (!options?.silent) console.log(message);
76
+ }
77
+
78
+ log(`\nStarting deployment process of "${contractArtifactName}"...`);
79
+
80
+ const wallet = options?.wallet ?? getWallet();
81
+ const deployer = new Deployer(hre, wallet);
82
+ const artifact = await deployer.loadArtifact(contractArtifactName).catch((error) => {
83
+ if (error?.message?.includes(`Artifact for contract "${contractArtifactName}" not found.`)) {
84
+ console.error(error.message);
85
+ throw `⛔️ Please make sure you have compiled your contracts or specified the correct contract name!`;
86
+ } else {
87
+ throw error;
88
+ }
89
+ });
90
+
91
+ // Estimate contract deployment fee
92
+ const deploymentFee = await deployer.estimateDeployFee(artifact, constructorArguments || []);
93
+ log(`Estimated deployment cost: ${ethers.formatEther(deploymentFee)} ETH`);
94
+
95
+ // Check if the wallet has enough balance
96
+ await verifyEnoughBalance(wallet, deploymentFee);
97
+
98
+ // Deploy the contract to zkSync
99
+ const contract = await deployer.deploy(artifact, constructorArguments);
100
+ const address = await contract.getAddress();
101
+ const constructorArgs = contract.interface.encodeDeploy(constructorArguments);
102
+ const fullContractSource = `${artifact.sourceName}:${artifact.contractName}`;
103
+
104
+ // Display contract deployment info
105
+ log(`\n"${artifact.contractName}" was successfully deployed:`);
106
+ log(` - Contract address: ${address}`);
107
+ log(` - Contract source: ${fullContractSource}`);
108
+ log(` - Encoded constructor arguments: ${constructorArgs}\n`);
109
+
110
+ if (!options?.noVerify && hre.network.config.verifyURL) {
111
+ log(`Requesting contract verification...`);
112
+ await verifyContract({
113
+ address,
114
+ contract: fullContractSource,
115
+ constructorArguments: constructorArgs,
116
+ bytecode: artifact.bytecode,
117
+ });
118
+ }
119
+
120
+ return contract;
121
+ }
122
+
123
+ /**
124
+ * Rich wallets can be used for testing purposes.
125
+ * Available on zkSync In-memory node and Dockerized node.
126
+ */
127
+ export const LOCAL_RICH_WALLETS = [
128
+ {
129
+ address: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049",
130
+ privateKey: "0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110"
131
+ },
132
+ {
133
+ address: "0xa61464658AfeAf65CccaaFD3a512b69A83B77618",
134
+ privateKey: "0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3"
135
+ },
136
+ {
137
+ address: "0x0D43eB5B8a47bA8900d84AA36656c92024e9772e",
138
+ privateKey: "0xd293c684d884d56f8d6abd64fc76757d3664904e309a0645baf8522ab6366d9e"
139
+ },
140
+ {
141
+ address: "0xA13c10C0D5bd6f79041B9835c63f91de35A15883",
142
+ privateKey: "0x850683b40d4a740aa6e745f889a6fdc8327be76e122f5aba645a5b02d0248db8"
143
+ },
144
+ {
145
+ address: "0x8002cD98Cfb563492A6fB3E7C8243b7B9Ad4cc92",
146
+ privateKey: "0xf12e28c0eb1ef4ff90478f6805b68d63737b7f33abfa091601140805da450d93"
147
+ },
148
+ {
149
+ address: "0x4F9133D1d3F50011A6859807C837bdCB31Aaab13",
150
+ privateKey: "0xe667e57a9b8aaa6709e51ff7d093f1c5b73b63f9987e4ab4aa9a5c699e024ee8"
151
+ },
152
+ {
153
+ address: "0xbd29A1B981925B94eEc5c4F1125AF02a2Ec4d1cA",
154
+ privateKey: "0x28a574ab2de8a00364d5dd4b07c4f2f574ef7fcc2a86a197f65abaec836d1959"
155
+ },
156
+ {
157
+ address: "0xedB6F5B4aab3dD95C7806Af42881FF12BE7e9daa",
158
+ privateKey: "0x74d8b3a188f7260f67698eb44da07397a298df5427df681ef68c45b34b61f998"
159
+ },
160
+ {
161
+ address: "0xe706e60ab5Dc512C36A4646D719b889F398cbBcB",
162
+ privateKey: "0xbe79721778b48bcc679b78edac0ce48306a8578186ffcb9f2ee455ae6efeace1"
163
+ },
164
+ {
165
+ address: "0xE90E12261CCb0F3F7976Ae611A29e84a6A85f424",
166
+ privateKey: "0x3eb15da85647edd9a1159a4a13b9e7c56877c4eb33f614546d4db06a51868b1c"
167
+ }
168
+ ]
@@ -0,0 +1,55 @@
1
+ import { HardhatUserConfig } from "hardhat/config";
2
+
3
+ import "@matterlabs/hardhat-zksync-node";
4
+ import "@matterlabs/hardhat-zksync-deploy";
5
+ import "@matterlabs/hardhat-zksync-solc";
6
+ import "@matterlabs/hardhat-zksync-verify";
7
+
8
+ const config: HardhatUserConfig = {
9
+ defaultNetwork: "zkSyncSepoliaTestnet",
10
+ networks: {
11
+ zkSyncSepoliaTestnet: {
12
+ url: "https://sepolia.era.zksync.dev",
13
+ ethNetwork: "sepolia",
14
+ zksync: true,
15
+ verifyURL: "https://explorer.sepolia.era.zksync.dev/contract_verification",
16
+ },
17
+ zkSyncMainnet: {
18
+ url: "https://mainnet.era.zksync.io",
19
+ ethNetwork: "mainnet",
20
+ zksync: true,
21
+ verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
22
+ },
23
+ zkSyncGoerliTestnet: { // deprecated network
24
+ url: "https://testnet.era.zksync.dev",
25
+ ethNetwork: "goerli",
26
+ zksync: true,
27
+ verifyURL: "https://zksync2-testnet-explorer.zksync.dev/contract_verification",
28
+ },
29
+ dockerizedNode: {
30
+ url: "http://localhost:3050",
31
+ ethNetwork: "http://localhost:8545",
32
+ zksync: true,
33
+ },
34
+ inMemoryNode: {
35
+ url: "http://127.0.0.1:8011",
36
+ ethNetwork: "", // in-memory node doesn't support eth node; removing this line will cause an error
37
+ zksync: true,
38
+ },
39
+ hardhat: {
40
+ zksync: true,
41
+ },
42
+ },
43
+ zksolc: {
44
+ version: "latest",
45
+ settings: {
46
+ // find all available options in the official documentation
47
+ // https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-solc.html#configuration
48
+ },
49
+ },
50
+ solidity: {
51
+ version: "0.8.17",
52
+ },
53
+ };
54
+
55
+ export default config;