From e39de6c6142d5b3baaf8fe266a842e7e19dcb884 Mon Sep 17 00:00:00 2001 From: goalongway Date: Sun, 29 Sep 2024 20:28:40 +0800 Subject: [PATCH] modify --- contracts/cache/solidity-files-cache.json | 4 +- contracts/cache/validations.json | 1182 +++++++++++++++++ .../contracts/business/tokenLocker/Lock.sol | 8 + contracts/scripts/lock/deploy.js | 28 + contracts/scripts/lock/grant_role.js | 54 + contracts/scripts/lock/lock.js | 46 + contracts/scripts/lock/set.js | 73 + contracts/scripts/lock/upgrade.js | 39 + contracts/scripts/message/grant_role.js | 3 +- contracts/scripts/message/set_weight.js | 3 +- contracts/scripts/token/approve.js | 30 + contracts/scripts/token/deploy.js | 26 + contracts/scripts/token/mint.js | 31 + 13 files changed, 1523 insertions(+), 4 deletions(-) create mode 100644 contracts/scripts/lock/deploy.js create mode 100644 contracts/scripts/lock/grant_role.js create mode 100644 contracts/scripts/lock/lock.js create mode 100644 contracts/scripts/lock/set.js create mode 100644 contracts/scripts/lock/upgrade.js create mode 100644 contracts/scripts/token/approve.js create mode 100644 contracts/scripts/token/deploy.js create mode 100644 contracts/scripts/token/mint.js diff --git a/contracts/cache/solidity-files-cache.json b/contracts/cache/solidity-files-cache.json index e35bf23a..8f9c7d88 100644 --- a/contracts/cache/solidity-files-cache.json +++ b/contracts/cache/solidity-files-cache.json @@ -1212,8 +1212,8 @@ ] }, "/Users/m/Workspaces/b2-network/b2-message-sharing/contracts/contracts/business/tokenLocker/Lock.sol": { - "lastModificationDate": 1727572796847, - "contentHash": "f34a857c9a2b8bbb2ce640f4e247025f", + "lastModificationDate": 1727611193601, + "contentHash": "3a1cb54ce50162160d831faeee75b660", "sourceName": "contracts/business/tokenLocker/Lock.sol", "solcConfig": { "version": "0.8.20", diff --git a/contracts/cache/validations.json b/contracts/cache/validations.json index 2930519e..0f4bb7a8 100644 --- a/contracts/cache/validations.json +++ b/contracts/cache/validations.json @@ -651,6 +651,1188 @@ }, "solcVersion": "0.8.20" }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20": { + "src": "@openzeppelin/contracts/token/ERC20/IERC20.sol:9", + "inherit": [], + "libraries": [], + "methods": [ + "totalSupply()", + "balanceOf(address)", + "transfer(address,uint256)", + "allowance(address,address)", + "approve(address,uint256)", + "transferFrom(address,address,uint256)" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol:IERC20Permit": { + "src": "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol:42", + "inherit": [], + "libraries": [], + "methods": [ + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)", + "nonces(address)", + "DOMAIN_SEPARATOR()" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol:SafeERC20": { + "src": "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol:19", + "version": { + "withMetadata": "43be31e1b7b09dd333d742d67f8c36495238ee6121d2c703f5ae412fad6ffd01", + "withoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db", + "linkedWithoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db" + }, + "inherit": [], + "libraries": [ + "@openzeppelin/contracts/utils/Address.sol:Address" + ], + "methods": [], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/utils/Address.sol:Address": { + "src": "@openzeppelin/contracts/utils/Address.sol:9", + "version": { + "withMetadata": "87fe4495dfc9354a67a3f830c1c6ae271f7d13aa51b702039300545894a3ef6b", + "withoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db", + "linkedWithoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db" + }, + "inherit": [], + "libraries": [], + "methods": [], + "linkReferences": [], + "errors": [ + { + "kind": "delegatecall", + "src": "@openzeppelin/contracts/utils/Address.sol:105" + } + ], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol:StorageSlot": { + "src": "@openzeppelin/contracts/utils/StorageSlot.sol:31", + "version": { + "withMetadata": "7265f6e3db839ed1e12b293fcc2217f69e669b109fb6d18bebad36e761707f76", + "withoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db", + "linkedWithoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db" + }, + "inherit": [], + "libraries": [], + "methods": [], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/utils/Strings.sol:Strings": { + "src": "@openzeppelin/contracts/utils/Strings.sol:12", + "version": { + "withMetadata": "1f077ab1d99a4eecbd37aee047bccfff460c6733303204c2caae630025da1b56", + "withoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db", + "linkedWithoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db" + }, + "inherit": [], + "libraries": [ + "@openzeppelin/contracts/utils/math/Math.sol:Math", + "@openzeppelin/contracts/utils/math/SignedMath.sol:SignedMath" + ], + "methods": [], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol:MessageHashUtils": { + "src": "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol:15", + "version": { + "withMetadata": "47db2b51fbc9919a71b07ceb1b01998df2a411f6e7e9090a303eca3b7fbe9697", + "withoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db", + "linkedWithoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db" + }, + "inherit": [], + "libraries": [ + "@openzeppelin/contracts/utils/Strings.sol:Strings" + ], + "methods": [], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol:IERC165": { + "src": "@openzeppelin/contracts/utils/introspection/IERC165.sol:15", + "inherit": [], + "libraries": [], + "methods": [ + "supportsInterface(bytes4)" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/utils/math/Math.sol:Math": { + "src": "@openzeppelin/contracts/utils/math/Math.sol:9", + "version": { + "withMetadata": "5fc8cf4b465bec2619d552a3c06f7fbe2ab2174de540f304fb55b0e888f55edd", + "withoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db", + "linkedWithoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db" + }, + "inherit": [], + "libraries": [], + "methods": [], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/utils/math/SignedMath.sol:SignedMath": { + "src": "@openzeppelin/contracts/utils/math/SignedMath.sol:9", + "version": { + "withMetadata": "12aecc6841d3169e665dbcd7653533b31894b634fefe854d71d51d046514f633", + "withoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db", + "linkedWithoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db" + }, + "inherit": [], + "libraries": [], + "methods": [], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "contracts/business/tokenLocker/Lock.sol:IB2MessageSharing": { + "src": "contracts/business/tokenLocker/Lock.sol:11", + "inherit": [], + "libraries": [], + "methods": [ + "call(uint256,address,bytes)" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "contracts/business/tokenLocker/Lock.sol:IBusinessContract": { + "src": "contracts/business/tokenLocker/Lock.sol:15", + "inherit": [], + "libraries": [], + "methods": [ + "send(uint256,uint256,address,bytes)" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "contracts/business/tokenLocker/Lock.sol:TokenLockerContract": { + "src": "contracts/business/tokenLocker/Lock.sol:20", + "version": { + "withMetadata": "5a18788c35cf00de0fd8869e2d604c74351c73fc309e0c6eb3b50cbe5bb3acfe", + "withoutMetadata": "c4e095f14de083d33ab35c55027b2a59a2d53c817aa426881717bb0c8867ee17", + "linkedWithoutMetadata": "c4e095f14de083d33ab35c55027b2a59a2d53c817aa426881717bb0c8867ee17" + }, + "inherit": [ + "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:AccessControlUpgradeable", + "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol:ERC165Upgradeable", + "@openzeppelin/contracts/utils/introspection/IERC165.sol:IERC165", + "@openzeppelin/contracts/access/IAccessControl.sol:IAccessControl", + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:ContextUpgradeable", + "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:EIP712Upgradeable", + "@openzeppelin/contracts/interfaces/IERC5267.sol:IERC5267", + "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol:UUPSUpgradeable", + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol:IERC1822Proxiable", + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:Initializable", + "contracts/business/tokenLocker/Lock.sol:IBusinessContract" + ], + "libraries": [ + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol:SafeERC20" + ], + "methods": [ + "initialize()", + "setB2MessageSharing(address)", + "setLocks(uint256,address)", + "setTokens(uint256,address,address)", + "send(uint256,uint256,address,bytes)", + "lock(address,uint256,uint256,address,address)", + "encodeLockData(address,address,address,uint256)", + "decodeLockData(bytes)" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [ + { + "label": "messageSharing", + "offset": 0, + "slot": "0", + "type": "t_contract(IB2MessageSharing)3945", + "contract": "TokenLockerContract", + "src": "contracts/business/tokenLocker/Lock.sol:28" + }, + { + "label": "locks", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_uint256,t_address)", + "contract": "TokenLockerContract", + "src": "contracts/business/tokenLocker/Lock.sol:58" + }, + { + "label": "ids", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_uint256,t_mapping(t_uint256,t_bool))", + "contract": "TokenLockerContract", + "src": "contracts/business/tokenLocker/Lock.sol:59" + }, + { + "label": "tokens", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_uint256,t_mapping(t_address,t_address))", + "contract": "TokenLockerContract", + "src": "contracts/business/tokenLocker/Lock.sol:60" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_struct(RoleData)25_storage)": { + "label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(AccessControlStorage)35_storage": { + "label": "struct AccessControlUpgradeable.AccessControlStorage", + "members": [ + { + "label": "_roles", + "type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)", + "offset": 0, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_struct(EIP712Storage)376_storage": { + "label": "struct EIP712Upgradeable.EIP712Storage", + "members": [ + { + "label": "_hashedName", + "type": "t_bytes32", + "offset": 0, + "slot": "0" + }, + { + "label": "_hashedVersion", + "type": "t_bytes32", + "offset": 0, + "slot": "1" + }, + { + "label": "_name", + "type": "t_string_storage", + "offset": 0, + "slot": "2" + }, + { + "label": "_version", + "type": "t_string_storage", + "offset": 0, + "slot": "3" + } + ], + "numberOfBytes": "128" + }, + "t_struct(InitializableStorage)174_storage": { + "label": "struct Initializable.InitializableStorage", + "members": [ + { + "label": "_initialized", + "type": "t_uint64", + "offset": 0, + "slot": "0" + }, + { + "label": "_initializing", + "type": "t_bool", + "offset": 8, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_struct(RoleData)25_storage": { + "label": "struct AccessControlUpgradeable.RoleData", + "members": [ + { + "label": "hasRole", + "type": "t_mapping(t_address,t_bool)", + "offset": 0, + "slot": "0" + }, + { + "label": "adminRole", + "type": "t_bytes32", + "offset": 0, + "slot": "1" + } + ], + "numberOfBytes": "64" + }, + "t_uint64": { + "label": "uint64", + "numberOfBytes": "8" + }, + "t_contract(IB2MessageSharing)3945": { + "label": "contract IB2MessageSharing", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_address)": { + "label": "mapping(address => address)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_address)": { + "label": "mapping(uint256 => address)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_bool)": { + "label": "mapping(uint256 => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_address))": { + "label": "mapping(uint256 => mapping(address => address))", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_mapping(t_uint256,t_bool))": { + "label": "mapping(uint256 => mapping(uint256 => bool))", + "numberOfBytes": "32" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + } + }, + "layoutVersion": "1.2", + "flat": true, + "namespaces": { + "erc7201:openzeppelin.storage.AccessControl": [ + { + "contract": "AccessControlUpgradeable", + "label": "_roles", + "type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:61", + "offset": 0, + "slot": "0" + } + ], + "erc7201:openzeppelin.storage.EIP712": [ + { + "contract": "EIP712Upgradeable", + "label": "_hashedName", + "type": "t_bytes32", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:39", + "offset": 0, + "slot": "0" + }, + { + "contract": "EIP712Upgradeable", + "label": "_hashedVersion", + "type": "t_bytes32", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:41", + "offset": 0, + "slot": "1" + }, + { + "contract": "EIP712Upgradeable", + "label": "_name", + "type": "t_string_storage", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:43", + "offset": 0, + "slot": "2" + }, + { + "contract": "EIP712Upgradeable", + "label": "_version", + "type": "t_string_storage", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:44", + "offset": 0, + "slot": "3" + } + ], + "erc7201:openzeppelin.storage.Initializable": [ + { + "contract": "Initializable", + "label": "_initialized", + "type": "t_uint64", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69", + "offset": 0, + "slot": "0" + }, + { + "contract": "Initializable", + "label": "_initializing", + "type": "t_bool", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73", + "offset": 8, + "slot": "0" + } + ] + } + }, + "solcVersion": "0.8.20" + } + }, + { + "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:AccessControlUpgradeable": { + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:50", + "inherit": [ + "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol:ERC165Upgradeable", + "@openzeppelin/contracts/utils/introspection/IERC165.sol:IERC165", + "@openzeppelin/contracts/access/IAccessControl.sol:IAccessControl", + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:ContextUpgradeable", + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:Initializable" + ], + "libraries": [], + "methods": [ + "supportsInterface(bytes4)", + "hasRole(bytes32,address)", + "getRoleAdmin(bytes32)", + "grantRole(bytes32,address)", + "revokeRole(bytes32,address)", + "renounceRole(bytes32,address)" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_struct(RoleData)25_storage)": { + "label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)", + "numberOfBytes": "32" + }, + "t_struct(AccessControlStorage)35_storage": { + "label": "struct AccessControlUpgradeable.AccessControlStorage", + "members": [ + { + "label": "_roles", + "type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)", + "offset": 0, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_struct(InitializableStorage)174_storage": { + "label": "struct Initializable.InitializableStorage", + "members": [ + { + "label": "_initialized", + "type": "t_uint64", + "offset": 0, + "slot": "0" + }, + { + "label": "_initializing", + "type": "t_bool", + "offset": 8, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_struct(RoleData)25_storage": { + "label": "struct AccessControlUpgradeable.RoleData", + "members": [ + { + "label": "hasRole", + "type": "t_mapping(t_address,t_bool)", + "offset": 0, + "slot": "0" + }, + { + "label": "adminRole", + "type": "t_bytes32", + "offset": 0, + "slot": "1" + } + ], + "numberOfBytes": "64" + }, + "t_uint64": { + "label": "uint64", + "numberOfBytes": "8" + } + }, + "layoutVersion": "1.2", + "flat": false, + "namespaces": { + "erc7201:openzeppelin.storage.AccessControl": [ + { + "contract": "AccessControlUpgradeable", + "label": "_roles", + "type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:61", + "offset": 0, + "slot": "0" + } + ], + "erc7201:openzeppelin.storage.Initializable": [ + { + "contract": "Initializable", + "label": "_initialized", + "type": "t_uint64", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69", + "offset": 0, + "slot": "0" + }, + { + "contract": "Initializable", + "label": "_initializing", + "type": "t_bool", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73", + "offset": 8, + "slot": "0" + } + ] + } + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:Initializable": { + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:56", + "inherit": [], + "libraries": [], + "methods": [], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": { + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_struct(InitializableStorage)174_storage": { + "label": "struct Initializable.InitializableStorage", + "members": [ + { + "label": "_initialized", + "type": "t_uint64", + "offset": 0, + "slot": "0" + }, + { + "label": "_initializing", + "type": "t_bool", + "offset": 8, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_uint64": { + "label": "uint64", + "numberOfBytes": "8" + } + }, + "layoutVersion": "1.2", + "flat": false, + "namespaces": { + "erc7201:openzeppelin.storage.Initializable": [ + { + "contract": "Initializable", + "label": "_initialized", + "type": "t_uint64", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69", + "offset": 0, + "slot": "0" + }, + { + "contract": "Initializable", + "label": "_initializing", + "type": "t_bool", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73", + "offset": 8, + "slot": "0" + } + ] + } + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol:UUPSUpgradeable": { + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol:20", + "inherit": [ + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol:IERC1822Proxiable", + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:Initializable" + ], + "libraries": [ + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol:ERC1967Utils" + ], + "methods": [ + "proxiableUUID()", + "upgradeToAndCall(address,bytes)" + ], + "linkReferences": [], + "errors": [ + { + "kind": "delegatecall", + "src": "@openzeppelin/contracts/utils/Address.sol:105" + } + ], + "layout": { + "storage": [], + "types": { + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_struct(InitializableStorage)174_storage": { + "label": "struct Initializable.InitializableStorage", + "members": [ + { + "label": "_initialized", + "type": "t_uint64", + "offset": 0, + "slot": "0" + }, + { + "label": "_initializing", + "type": "t_bool", + "offset": 8, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_uint64": { + "label": "uint64", + "numberOfBytes": "8" + } + }, + "layoutVersion": "1.2", + "flat": false, + "namespaces": { + "erc7201:openzeppelin.storage.Initializable": [ + { + "contract": "Initializable", + "label": "_initialized", + "type": "t_uint64", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69", + "offset": 0, + "slot": "0" + }, + { + "contract": "Initializable", + "label": "_initializing", + "type": "t_bool", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73", + "offset": 8, + "slot": "0" + } + ] + } + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:ContextUpgradeable": { + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:17", + "inherit": [ + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:Initializable" + ], + "libraries": [], + "methods": [], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": { + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_struct(InitializableStorage)174_storage": { + "label": "struct Initializable.InitializableStorage", + "members": [ + { + "label": "_initialized", + "type": "t_uint64", + "offset": 0, + "slot": "0" + }, + { + "label": "_initializing", + "type": "t_bool", + "offset": 8, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_uint64": { + "label": "uint64", + "numberOfBytes": "8" + } + }, + "layoutVersion": "1.2", + "flat": false, + "namespaces": { + "erc7201:openzeppelin.storage.Initializable": [ + { + "contract": "Initializable", + "label": "_initialized", + "type": "t_uint64", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69", + "offset": 0, + "slot": "0" + }, + { + "contract": "Initializable", + "label": "_initializing", + "type": "t_bool", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73", + "offset": 8, + "slot": "0" + } + ] + } + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:EIP712Upgradeable": { + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:32", + "inherit": [ + "@openzeppelin/contracts/interfaces/IERC5267.sol:IERC5267", + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:Initializable" + ], + "libraries": [ + "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol:MessageHashUtils" + ], + "methods": [ + "eip712Domain()" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": { + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(EIP712Storage)376_storage": { + "label": "struct EIP712Upgradeable.EIP712Storage", + "members": [ + { + "label": "_hashedName", + "type": "t_bytes32", + "offset": 0, + "slot": "0" + }, + { + "label": "_hashedVersion", + "type": "t_bytes32", + "offset": 0, + "slot": "1" + }, + { + "label": "_name", + "type": "t_string_storage", + "offset": 0, + "slot": "2" + }, + { + "label": "_version", + "type": "t_string_storage", + "offset": 0, + "slot": "3" + } + ], + "numberOfBytes": "128" + }, + "t_struct(InitializableStorage)174_storage": { + "label": "struct Initializable.InitializableStorage", + "members": [ + { + "label": "_initialized", + "type": "t_uint64", + "offset": 0, + "slot": "0" + }, + { + "label": "_initializing", + "type": "t_bool", + "offset": 8, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_uint64": { + "label": "uint64", + "numberOfBytes": "8" + } + }, + "layoutVersion": "1.2", + "flat": false, + "namespaces": { + "erc7201:openzeppelin.storage.EIP712": [ + { + "contract": "EIP712Upgradeable", + "label": "_hashedName", + "type": "t_bytes32", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:39", + "offset": 0, + "slot": "0" + }, + { + "contract": "EIP712Upgradeable", + "label": "_hashedVersion", + "type": "t_bytes32", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:41", + "offset": 0, + "slot": "1" + }, + { + "contract": "EIP712Upgradeable", + "label": "_name", + "type": "t_string_storage", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:43", + "offset": 0, + "slot": "2" + }, + { + "contract": "EIP712Upgradeable", + "label": "_version", + "type": "t_string_storage", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:44", + "offset": 0, + "slot": "3" + } + ], + "erc7201:openzeppelin.storage.Initializable": [ + { + "contract": "Initializable", + "label": "_initialized", + "type": "t_uint64", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69", + "offset": 0, + "slot": "0" + }, + { + "contract": "Initializable", + "label": "_initializing", + "type": "t_bool", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73", + "offset": 8, + "slot": "0" + } + ] + } + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol:ERC165Upgradeable": { + "src": "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol:21", + "inherit": [ + "@openzeppelin/contracts/utils/introspection/IERC165.sol:IERC165", + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:Initializable" + ], + "libraries": [], + "methods": [ + "supportsInterface(bytes4)" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": { + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_struct(InitializableStorage)174_storage": { + "label": "struct Initializable.InitializableStorage", + "members": [ + { + "label": "_initialized", + "type": "t_uint64", + "offset": 0, + "slot": "0" + }, + { + "label": "_initializing", + "type": "t_bool", + "offset": 8, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_uint64": { + "label": "uint64", + "numberOfBytes": "8" + } + }, + "layoutVersion": "1.2", + "flat": false, + "namespaces": { + "erc7201:openzeppelin.storage.Initializable": [ + { + "contract": "Initializable", + "label": "_initialized", + "type": "t_uint64", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69", + "offset": 0, + "slot": "0" + }, + { + "contract": "Initializable", + "label": "_initializing", + "type": "t_bool", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73", + "offset": 8, + "slot": "0" + } + ] + } + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/access/IAccessControl.sol:IAccessControl": { + "src": "@openzeppelin/contracts/access/IAccessControl.sol:9", + "inherit": [], + "libraries": [], + "methods": [ + "hasRole(bytes32,address)", + "getRoleAdmin(bytes32)", + "grantRole(bytes32,address)", + "revokeRole(bytes32,address)", + "renounceRole(bytes32,address)" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/interfaces/IERC5267.sol:IERC5267": { + "src": "@openzeppelin/contracts/interfaces/IERC5267.sol:6", + "inherit": [], + "libraries": [], + "methods": [ + "eip712Domain()" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol:IERC1822Proxiable": { + "src": "@openzeppelin/contracts/interfaces/draft-IERC1822.sol:10", + "inherit": [], + "libraries": [], + "methods": [ + "proxiableUUID()" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol:ERC1967Utils": { + "src": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol:14", + "version": { + "withMetadata": "da0ca15378c152c2e5da0d6bf0e27590374c4a5c250bc2a82167eedfe4c704bd", + "withoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db", + "linkedWithoutMetadata": "a64c6cf9c6ba9368f5132c93a0196b3204a7963dbb4dd05dfddb4ab23126b8db" + }, + "inherit": [], + "libraries": [ + "@openzeppelin/contracts/utils/StorageSlot.sol:StorageSlot", + "@openzeppelin/contracts/utils/Address.sol:Address" + ], + "methods": [], + "linkReferences": [], + "errors": [ + { + "kind": "delegatecall", + "src": "@openzeppelin/contracts/utils/Address.sol:105" + }, + { + "kind": "delegatecall", + "src": "@openzeppelin/contracts/utils/Address.sol:105" + } + ], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol:IBeacon": { + "src": "@openzeppelin/contracts/proxy/beacon/IBeacon.sol:9", + "inherit": [], + "libraries": [], + "methods": [ + "implementation()" + ], + "linkReferences": [], + "errors": [], + "layout": { + "storage": [], + "types": {}, + "layoutVersion": "1.2", + "flat": false, + "namespaces": {} + }, + "solcVersion": "0.8.20" + }, "@openzeppelin/contracts/utils/Address.sol:Address": { "src": "@openzeppelin/contracts/utils/Address.sol:9", "version": { diff --git a/contracts/contracts/business/tokenLocker/Lock.sol b/contracts/contracts/business/tokenLocker/Lock.sol index 9c0b1a3f..d30d3d48 100644 --- a/contracts/contracts/business/tokenLocker/Lock.sol +++ b/contracts/contracts/business/tokenLocker/Lock.sol @@ -47,6 +47,14 @@ contract TokenLockerContract is IBusinessContract, Initializable, UUPSUpgradeabl messageSharing = IB2MessageSharing(sharing_address); } + function setLocks(uint256 chain_id,address lock_address) external onlyRole(ADMIN_ROLE) { + locks[chain_id] = lock_address; + } + + function setTokens(uint256 chain_id, address token_address ,address to_token_address) external onlyRole(ADMIN_ROLE) { + tokens[chain_id][token_address] = to_token_address; + } + mapping (uint256 => address) public locks; mapping (uint256 => mapping (uint256 => bool)) public ids; mapping (uint256 => mapping (address => address)) public tokens; diff --git a/contracts/scripts/lock/deploy.js b/contracts/scripts/lock/deploy.js new file mode 100644 index 00000000..bc0b0c84 --- /dev/null +++ b/contracts/scripts/lock/deploy.js @@ -0,0 +1,28 @@ +const {ethers, upgrades, network} = require("hardhat"); + +async function main() { + /** + * # dev + * b2dev: yarn hardhat run scripts/lock/deploy.js --network b2dev + * asdev: yarn hardhat run scripts/lock/deploy.js --network asdev + * # pord + * as: yarn hardhat run scripts/lock/deploy.js --network as + * b2: yarn hardhat run scripts/lock/deploy.js --network b2 + */ + + const [owner] = await ethers.getSigners() + console.log("Owner Address:", owner.address); + + // deploy + const TokenLockerContract = await ethers.getContractFactory("TokenLockerContract"); + const instance = await upgrades.deployProxy(TokenLockerContract); + await instance.waitForDeployment(); + console.log("TokenLockerContract Address:", instance.target); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) \ No newline at end of file diff --git a/contracts/scripts/lock/grant_role.js b/contracts/scripts/lock/grant_role.js new file mode 100644 index 00000000..8d00415d --- /dev/null +++ b/contracts/scripts/lock/grant_role.js @@ -0,0 +1,54 @@ +const {ethers, run, network, upgrades} = require("hardhat") + +async function main() { + /** + * # dev + * b2dev: yarn hardhat run scripts/lock/grant_role.js --network b2dev + * asdev: yarn hardhat run scripts/lock/grant_role.js --network asdev + * # pord + * as: yarn hardhat run scripts/lock/grant_role.js --network as + * b2: yarn hardhat run scripts/lock/grant_role.js --network b2 + */ + + let businessAddress; + let senderAddress; + if (network.name == 'b2dev') { + businessAddress = "0x690bC18DfAA4C5f1cC67495781B90FC4D90cD78b"; + senderAddress = "0xDf5b12f094cf9b12eb2523cC43a62Dd6787D7AB8"; + } else if (network.name == 'asdev') { + businessAddress = "0x8Ac2C830532d7203a12C4C32C0BE4d3d15917534"; + senderAddress = "0x2A82058E46151E337Baba56620133FC39BD5B71F"; + } else if (network.name == 'as') { + businessAddress = ""; + senderAddress = ""; + } else if (network.name == 'b2') { + businessAddress = ""; + senderAddress = ""; + } + console.log("Business Address: ", businessAddress); + + const [owner] = await ethers.getSigners(); + console.log("Owner Address:", owner.address); + + const TokenLockerContract = await ethers.getContractFactory("TokenLockerContract"); + const instance = await TokenLockerContract.attach(businessAddress) + let role = await instance.SENDER_ROLE(); + console.log("role hash:", role); + + let has = await instance.hasRole(role, senderAddress) + console.log("has role:", has) + if (!has) { + const tx = await instance.grantRole(role, senderAddress); + const txReceipt = await tx.wait(1); + console.log(`tx hash: ${txReceipt.hash}`) + has = await instance.hasRole(role, senderAddress) + console.log("has role:", has) + } +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) \ No newline at end of file diff --git a/contracts/scripts/lock/lock.js b/contracts/scripts/lock/lock.js new file mode 100644 index 00000000..61c48428 --- /dev/null +++ b/contracts/scripts/lock/lock.js @@ -0,0 +1,46 @@ +const {ethers, run, network, upgrades} = require("hardhat") + +async function main() { + /** + * # dev + * b2dev: yarn hardhat run scripts/lock/lock.js --network b2dev + * asdev: yarn hardhat run scripts/lock/lock.js --network asdev + * # pord + * as: yarn hardhat run scripts/lock/lock.js --network as + * b2: yarn hardhat run scripts/lock/lock.js --network b2 + */ + + let businessAddress; + if (network.name == 'b2dev') { + businessAddress = "0x690bC18DfAA4C5f1cC67495781B90FC4D90cD78b"; + } else if (network.name == 'asdev') { + businessAddress = "0x8Ac2C830532d7203a12C4C32C0BE4d3d15917534"; + } else if (network.name == 'as') { + businessAddress = ""; + } else if (network.name == 'b2') { + businessAddress = ""; + } + console.log("Business Address: ", businessAddress); + + const [owner] = await ethers.getSigners(); + console.log("Owner Address:", owner.address); + + const TokenLockerContract = await ethers.getContractFactory("TokenLockerContract"); + const instance = await TokenLockerContract.attach(businessAddress) + + let token_address = '0xc810b0b75Af60D60De8451587DF9cb240BE22d9d'; + let amount = '1000'; + let to_chain_id = 1123; + let to_business_contract = '0x690bC18DfAA4C5f1cC67495781B90FC4D90cD78b'; + let to_address = '0x502FA825441D215EDECc54804d74f3FBFe20fb97'; + const tx = await instance.lock(token_address, amount, to_chain_id, to_business_contract, to_address); + const txReceipt = await tx.wait(1); + console.log(`tx hash: ${txReceipt.hash}`) +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) \ No newline at end of file diff --git a/contracts/scripts/lock/set.js b/contracts/scripts/lock/set.js new file mode 100644 index 00000000..b21a5976 --- /dev/null +++ b/contracts/scripts/lock/set.js @@ -0,0 +1,73 @@ +const {ethers, run, network, upgrades} = require("hardhat") + +async function main() { + /** + * # dev + * b2dev: yarn hardhat run scripts/lock/set.js --network b2dev + * asdev: yarn hardhat run scripts/lock/set.js --network asdev + * # pord + * as: yarn hardhat run scripts/lock/set.js --network as + * b2: yarn hardhat run scripts/lock/set.js --network b2 + */ + + let businessAddress; + let messageAddress; + if (network.name == 'b2dev') { + businessAddress = "0x690bC18DfAA4C5f1cC67495781B90FC4D90cD78b"; + messageAddress = "0xDf5b12f094cf9b12eb2523cC43a62Dd6787D7AB8"; + } else if (network.name == 'asdev') { + businessAddress = "0x8Ac2C830532d7203a12C4C32C0BE4d3d15917534"; + messageAddress = "0x2A82058E46151E337Baba56620133FC39BD5B71F"; + } else if (network.name == 'as') { + businessAddress = ""; + messageAddress = ""; + } else if (network.name == 'b2') { + businessAddress = ""; + messageAddress = ""; + } + console.log("Business Address: ", businessAddress); + + const [owner] = await ethers.getSigners(); + console.log("Owner Address:", owner.address); + + const TokenLockerContract = await ethers.getContractFactory("TokenLockerContract"); + const instance = await TokenLockerContract.attach(businessAddress) + let messageSharing = await instance.messageSharing(); + console.log("messageSharing address:", messageSharing); + + if (messageSharing != messageAddress) { + const tx = await instance.setB2MessageSharing(messageAddress); + const txReceipt = await tx.wait(1); + console.log(`tx hash: ${txReceipt.hash}`) + } + + let chain_id = 1123; + let locker = '0x690bC18DfAA4C5f1cC67495781B90FC4D90cD78b'; + + let _locker = await instance.locks(chain_id); + if (_locker != locker) { + const tx = await instance.setLocks(chain_id, locker); + const txReceipt = await tx.wait(1); + console.log(`tx hash: ${txReceipt.hash}`) + } + + let token_address = '0xc810b0b75Af60D60De8451587DF9cb240BE22d9d'; + let to_token_address = '0xc810b0b75Af60D60De8451587DF9cb240BE22d9d'; + + let _to_token_address = await instance.tokens(chain_id, token_address); + if (_to_token_address != to_token_address) { + const tx = await instance.setTokens(chain_id, token_address, to_token_address); + const txReceipt = await tx.wait(1); + console.log(`tx hash: ${txReceipt.hash}`) + } + + + +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) \ No newline at end of file diff --git a/contracts/scripts/lock/upgrade.js b/contracts/scripts/lock/upgrade.js new file mode 100644 index 00000000..372e4784 --- /dev/null +++ b/contracts/scripts/lock/upgrade.js @@ -0,0 +1,39 @@ +const {ethers, upgrades, network} = require("hardhat"); + +async function main() { + /** + * # dev + * b2dev: yarn hardhat run scripts/lock/upgrade.js --network b2dev + * asdev: yarn hardhat run scripts/lock/upgrade.js --network asdev + * # pord + * as: yarn hardhat run scripts/lock/upgrade.js --network as + * b2: yarn hardhat run scripts/lock/upgrade.js --network b2 + */ + + const [owner] = await ethers.getSigners() + console.log("Owner Address:", owner.address); + + let lockerAddress = ''; + if (network.name == 'b2dev') { + lockerAddress = "0x690bC18DfAA4C5f1cC67495781B90FC4D90cD78b"; + } else if (network.name == 'asdev') { + lockerAddress = ""; + } else if (network.name == 'b2') { + lockerAddress = ""; + } else if (network.name == 'as') { + lockerAddress = ""; + } + console.log("locker Address: ", lockerAddress); + + // Upgrading + const TokenLockerContract = await ethers.getContractFactory("TokenLockerContract"); + const upgraded = await upgrades.upgradeProxy(lockerAddress, TokenLockerContract); + console.log("TokenLockerContract upgraded:", upgraded.target); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) \ No newline at end of file diff --git a/contracts/scripts/message/grant_role.js b/contracts/scripts/message/grant_role.js index b4b308b4..fb84e810 100644 --- a/contracts/scripts/message/grant_role.js +++ b/contracts/scripts/message/grant_role.js @@ -30,7 +30,8 @@ async function main() { // let role = await instance.ADMIN_ROLE(); // admin role // let role = await instance.UPGRADE_ROLE(); // upgrade role // let chainId = 0; - let chainId = 421614; + // let chainId = 421614; + let chainId = 1123; let role = await instance.validatorRole(chainId); // validatorRole(uint256 chain_id) console.log("role hash: ", role); diff --git a/contracts/scripts/message/set_weight.js b/contracts/scripts/message/set_weight.js index 53a0ab47..3903ef97 100644 --- a/contracts/scripts/message/set_weight.js +++ b/contracts/scripts/message/set_weight.js @@ -29,7 +29,8 @@ async function main() { let _weight = 1; // let chainId = 0; - let chainId = 421614; + // let chainId = 421614; + let chainId = 1123; let weight = await instance.weights(chainId); console.log("weight: ", weight); diff --git a/contracts/scripts/token/approve.js b/contracts/scripts/token/approve.js new file mode 100644 index 00000000..49763319 --- /dev/null +++ b/contracts/scripts/token/approve.js @@ -0,0 +1,30 @@ +const {ethers, run, network} = require("hardhat") + +const tokenAddress = "0xc810b0b75Af60D60De8451587DF9cb240BE22d9d" +const toAccount = "0x690bC18DfAA4C5f1cC67495781B90FC4D90cD78b" +const approveAmount = "10000000000000000000000000000000000000000" + +async function main() { + /** + * b2dev: yarn hardhat run scripts/token/approve.js --network b2dev + * asdev: yarn hardhat run scripts/token/approve.js --network asdev + */ + + const [owner] = await ethers.getSigners() + + const MyERC20 = await ethers.getContractFactory('MyERC20'); + const token = MyERC20.attach(tokenAddress); + + const approveTx = await token.approve(toAccount, approveAmount) + const txReceipt = await approveTx.wait(1); + console.log(`tx hash: ${txReceipt.hash}`) + console.log("allowance:", await token.allowance(owner.address, toAccount)); + +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) \ No newline at end of file diff --git a/contracts/scripts/token/deploy.js b/contracts/scripts/token/deploy.js new file mode 100644 index 00000000..6dabc06f --- /dev/null +++ b/contracts/scripts/token/deploy.js @@ -0,0 +1,26 @@ +const {ethers, upgrades} = require("hardhat") + +const TokenName = "USDT" +const TokenSymbol = "USDT" +const decimals = 18 + +async function main() { + /** + * b2dev: yarn hardhat run scripts/token/deploy.js --network b2dev + * asdev: yarn hardhat run scripts/token/deploy.js --network asdev + */ + const [owner] = await ethers.getSigners(); + console.log(owner.address); + + const MyERC20 = await ethers.getContractFactory("MyERC20"); + const instance = await MyERC20.deploy(TokenName, TokenSymbol, decimals); + await instance.waitForDeployment(); + console.log("MyERC20 V1:", instance.target); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) \ No newline at end of file diff --git a/contracts/scripts/token/mint.js b/contracts/scripts/token/mint.js new file mode 100644 index 00000000..f67b7fd6 --- /dev/null +++ b/contracts/scripts/token/mint.js @@ -0,0 +1,31 @@ +const {ethers, run, network} = require("hardhat") + +const tokenAddress = "0xc810b0b75Af60D60De8451587DF9cb240BE22d9d" +const mintAmount = "100000000000000" + +async function main() { + /** + * b2dev: yarn hardhat run scripts/token/mint.js --network b2dev + * asdev: yarn hardhat run scripts/token/mint.js --network asdev + */ + + const [owner] = await ethers.getSigners() + let toAccount = "0x690bC18DfAA4C5f1cC67495781B90FC4D90cD78b" + toAccount = owner.address; + + const MyERC20 = await ethers.getContractFactory('MyERC20'); + const token = MyERC20.attach(tokenAddress); + + const mintTx = await token.mint(toAccount, mintAmount) + const txReceipt = await mintTx.wait(1); + console.log(`tx hash: ${txReceipt.hash}`) + console.log("balance of:", await token.balanceOf(toAccount)); + +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) \ No newline at end of file