@latticexyz/world-module-erc20 2.2.20-b774ab28b3de6cefcbfce5e1bb6fcb68b9374abf → 2.2.20-b7901812d4035faa3ec9bb75f31ffe7af398bdf2
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.
- package/README.md +39 -11
- package/out/AccessControl.sol/AccessControl.json +1 -1
- package/out/AccessManagementSystem.sol/AccessManagementSystem.abi.json +1 -1
- package/out/AccessManagementSystem.sol/AccessManagementSystem.abi.json.d.ts +1 -1
- package/out/AccessManagementSystem.sol/AccessManagementSystem.json +1 -1
- package/out/Allowances.sol/Allowances.json +1 -1
- package/out/BalanceTransferSystem.sol/BalanceTransferSystem.abi.json +1 -1
- package/out/BalanceTransferSystem.sol/BalanceTransferSystem.abi.json.d.ts +1 -1
- package/out/BalanceTransferSystem.sol/BalanceTransferSystem.json +1 -1
- package/out/Balances.sol/Balances.json +1 -1
- package/out/Base.sol/CommonBase.json +1 -1
- package/out/Base.sol/ScriptBase.json +1 -1
- package/out/Base.sol/TestBase.json +1 -1
- package/out/BatchCallSystem.sol/BatchCallSystem.abi.json +1 -1
- package/out/BatchCallSystem.sol/BatchCallSystem.abi.json.d.ts +1 -1
- package/out/BatchCallSystem.sol/BatchCallSystem.json +1 -1
- package/out/Bytes.sol/Bytes.json +1 -1
- package/out/Constants.sol/ERC20TableNames.json +1 -1
- package/out/Constants.sol/ModuleConstants.json +1 -1
- package/out/Constants.sol/OwnableTableNames.json +1 -1
- package/out/Constants.sol/PausableTableNames.json +1 -1
- package/out/Context.sol/Context.abi.json +15 -0
- package/out/Context.sol/Context.abi.json.d.ts +17 -0
- package/out/Context.sol/Context.json +1 -0
- package/out/DecodeSlice.sol/DecodeSlice.json +1 -1
- package/out/Delegation.sol/Delegation.json +1 -1
- package/out/ERC165Checker.sol/ERC165Checker.json +1 -1
- package/out/ERC20BaseTest.t.sol/ERC20BehaviorTest.abi.json +0 -7
- package/out/ERC20BaseTest.t.sol/ERC20BehaviorTest.abi.json.d.ts +0 -7
- package/out/ERC20BaseTest.t.sol/ERC20BehaviorTest.json +1 -1
- package/out/ERC20BaseTest.t.sol/ERC20WithInternalStoreBehaviorTest.abi.json +949 -0
- package/out/ERC20BaseTest.t.sol/ERC20WithInternalStoreBehaviorTest.abi.json.d.ts +951 -0
- package/out/ERC20BaseTest.t.sol/ERC20WithInternalStoreBehaviorTest.json +1 -0
- package/out/ERC20BaseTest.t.sol/ERC20WithInternalStoreTest.abi.json +949 -0
- package/out/ERC20BaseTest.t.sol/ERC20WithInternalStoreTest.abi.json.d.ts +951 -0
- package/out/ERC20BaseTest.t.sol/ERC20WithInternalStoreTest.json +1 -0
- package/out/ERC20BaseTest.t.sol/ERC20WithWorldBehaviorTest.json +1 -0
- package/out/ERC20BaseTest.t.sol/ERC20WithWorldTest.abi.json +956 -0
- package/out/ERC20BaseTest.t.sol/ERC20WithWorldTest.abi.json.d.ts +958 -0
- package/out/ERC20BaseTest.t.sol/{ERC20Test.json → ERC20WithWorldTest.json} +1 -1
- package/out/ERC20BaseTest.t.sol/MockERC20Base.abi.json +6 -160
- package/out/ERC20BaseTest.t.sol/MockERC20Base.abi.json.d.ts +6 -160
- package/out/ERC20BaseTest.t.sol/MockERC20Base.json +1 -1
- package/out/ERC20BaseTest.t.sol/MockERC20WithInternalStore.abi.json +696 -0
- package/out/ERC20BaseTest.t.sol/MockERC20WithInternalStore.abi.json.d.ts +698 -0
- package/out/ERC20BaseTest.t.sol/MockERC20WithInternalStore.json +1 -0
- package/out/ERC20BaseTest.t.sol/MockERC20WithWorld.abi.json +839 -0
- package/out/ERC20BaseTest.t.sol/MockERC20WithWorld.abi.json.d.ts +841 -0
- package/out/ERC20BaseTest.t.sol/MockERC20WithWorld.json +1 -0
- package/out/ERC20BaseTest.t.sol/TestConstants.json +1 -1
- package/out/ERC20Burnable.sol/ERC20Burnable.abi.json +6 -155
- package/out/ERC20Burnable.sol/ERC20Burnable.abi.json.d.ts +6 -155
- package/out/ERC20Burnable.sol/ERC20Burnable.json +1 -1
- package/out/ERC20Burnable.t.sol/ERC20BurnableTest.abi.json +0 -7
- package/out/ERC20Burnable.t.sol/ERC20BurnableTest.abi.json.d.ts +0 -7
- package/out/ERC20Burnable.t.sol/ERC20BurnableTest.json +1 -1
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithInternalStoreTest.abi.json +956 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithInternalStoreTest.abi.json.d.ts +958 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithInternalStoreTest.json +1 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithWorldTest.abi.json +963 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithWorldTest.abi.json.d.ts +965 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithWorldTest.json +1 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.abi.json +727 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.abi.json.d.ts +729 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.json +1 -0
- package/out/ERC20Burnable.t.sol/{MockERC20Burnable.abi.json → MockERC20WithWorldBurnable.abi.json} +42 -53
- package/out/ERC20Burnable.t.sol/{MockERC20Burnable.abi.json.d.ts → MockERC20WithWorldBurnable.abi.json.d.ts} +42 -53
- package/out/ERC20Burnable.t.sol/MockERC20WithWorldBurnable.json +1 -0
- package/out/ERC20Metadata.sol/ERC20Metadata.json +1 -1
- package/out/ERC20Module.sol/ERC20Module.abi.json +3 -3
- package/out/ERC20Module.sol/ERC20Module.abi.json.d.ts +3 -3
- package/out/ERC20Module.sol/ERC20Module.json +1 -1
- package/out/ERC20Module.sol/ERC20RegistryLib.json +1 -1
- package/out/ERC20Module.t.sol/ERC20ModuleTest.json +1 -1
- package/out/ERC20Module.t.sol/TestConstants.json +1 -1
- package/out/ERC20Pausable.sol/ERC20Pausable.abi.json +6 -155
- package/out/ERC20Pausable.sol/ERC20Pausable.abi.json.d.ts +6 -155
- package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -1
- package/out/ERC20Pausable.t.sol/ERC20PausableBehaviorTest.abi.json +0 -7
- package/out/ERC20Pausable.t.sol/ERC20PausableBehaviorTest.abi.json.d.ts +0 -7
- package/out/ERC20Pausable.t.sol/ERC20PausableBehaviorTest.json +1 -1
- package/out/ERC20Pausable.t.sol/ERC20PausableWithInternalStoreTest.abi.json +956 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithInternalStoreTest.abi.json.d.ts +958 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithInternalStoreTest.json +1 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithWorldTest.abi.json +963 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithWorldTest.abi.json.d.ts +965 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithWorldTest.json +1 -0
- package/out/ERC20Pausable.t.sol/MockERC20Pausable.abi.json +6 -191
- package/out/ERC20Pausable.t.sol/MockERC20Pausable.abi.json.d.ts +6 -191
- package/out/ERC20Pausable.t.sol/MockERC20Pausable.json +1 -1
- package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.abi.json +759 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.abi.json.d.ts +761 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.json +1 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.abi.json +897 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.abi.json.d.ts +899 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.json +1 -0
- package/out/ERC20Registry.sol/ERC20Registry.json +1 -1
- package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.abi.json +851 -0
- package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.abi.json.d.ts +853 -0
- package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.json +1 -0
- package/out/{ERC20PausableBurnable.sol/ERC20PausableBurnable.abi.json → ERC20WithWorld.sol/ERC20WithWorld.abi.json} +46 -57
- package/out/{ERC20PausableBurnable.sol/ERC20PausableBurnable.abi.json.d.ts → ERC20WithWorld.sol/ERC20WithWorld.abi.json.d.ts} +46 -57
- package/out/ERC20WithWorld.sol/ERC20WithWorld.json +1 -0
- package/out/EncodeArray.sol/EncodeArray.json +1 -1
- package/out/EncodedLengths.sol/EncodedLengthsInstance.json +1 -1
- package/out/EncodedLengths.sol/EncodedLengthsLib.json +1 -1
- package/out/FieldLayout.sol/FieldLayoutInstance.json +1 -1
- package/out/FieldLayout.sol/FieldLayoutLib.json +1 -1
- package/out/FunctionSelectors.sol/FunctionSelectors.json +1 -1
- package/out/FunctionSignatures.sol/FunctionSignatures.json +1 -1
- package/out/GasReporter.sol/GasReporter.json +1 -1
- package/out/Hook.sol/HookInstance.json +1 -1
- package/out/Hook.sol/HookLib.json +1 -1
- package/out/Hooks.sol/Hooks.json +1 -1
- package/out/IAccessManagementSystem.sol/IAccessManagementSystem.json +1 -1
- package/out/IBalanceTransferSystem.sol/IBalanceTransferSystem.json +1 -1
- package/out/IBaseWorld.sol/IBaseWorld.json +1 -1
- package/out/IBatchCallSystem.sol/IBatchCallSystem.json +1 -1
- package/out/IDelegationControl.sol/IDelegationControl.json +1 -1
- package/out/IERC165.sol/IERC165.json +1 -1
- package/out/IERC20.sol/IERC20.json +1 -1
- package/out/IERC20Errors.sol/IERC20Errors.json +1 -1
- package/out/IERC20Events.sol/IERC20Events.json +1 -1
- package/out/IERC20Metadata.sol/IERC20Metadata.json +1 -1
- package/out/IEncodedLengthsErrors.sol/IEncodedLengthsErrors.json +1 -1
- package/out/IFieldLayoutErrors.sol/IFieldLayoutErrors.json +1 -1
- package/out/IModule.sol/IModule.json +1 -1
- package/out/IModuleErrors.sol/IModuleErrors.json +1 -1
- package/out/IModuleInstallationSystem.sol/IModuleInstallationSystem.json +1 -1
- package/out/IMulticall3.sol/IMulticall3.json +1 -1
- package/out/IRegistrationSystem.sol/IRegistrationSystem.json +1 -1
- package/out/ISchemaErrors.sol/ISchemaErrors.json +1 -1
- package/out/ISliceErrors.sol/ISliceErrors.json +1 -1
- package/out/IStore.sol/IStore.json +1 -1
- package/out/IStoreErrors.sol/IStoreErrors.json +1 -1
- package/out/IStoreEvents.sol/IStoreEvents.json +1 -1
- package/out/IStoreHook.sol/IStoreHook.json +1 -1
- package/out/IStoreKernel.sol/IStoreKernel.json +1 -1
- package/out/IStoreRead.sol/IStoreRead.json +1 -1
- package/out/IStoreRegistration.sol/IStoreRegistration.json +1 -1
- package/out/IStoreWrite.sol/IStoreWrite.json +1 -1
- package/out/ISystemHook.sol/ISystemHook.json +1 -1
- package/out/IWorldContextConsumer.sol/IWorldContextConsumer.json +1 -1
- package/out/IWorldErrors.sol/IWorldErrors.json +1 -1
- package/out/IWorldEvents.sol/IWorldEvents.json +1 -1
- package/out/IWorldKernel.sol/IWorldCall.json +1 -1
- package/out/IWorldKernel.sol/IWorldKernel.json +1 -1
- package/out/IWorldKernel.sol/IWorldModuleInstallation.json +1 -1
- package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.json +1 -1
- package/out/InitModule.sol/InitModule.abi.json +3 -3
- package/out/InitModule.sol/InitModule.abi.json.d.ts +3 -3
- package/out/InitModule.sol/InitModule.json +1 -1
- package/out/InitModuleAddress.sol/InitModuleAddress.json +1 -1
- package/out/InstalledModules.sol/InstalledModules.json +1 -1
- package/out/LimitedCallContext.sol/LimitedCallContext.json +1 -1
- package/out/MUDERC20.sol/MUDERC20.abi.json +6 -155
- package/out/MUDERC20.sol/MUDERC20.abi.json.d.ts +6 -155
- package/out/MUDERC20.sol/MUDERC20.json +1 -1
- package/out/Memory.sol/Memory.json +1 -1
- package/out/Module.sol/Module.abi.json +1 -1
- package/out/Module.sol/Module.abi.json.d.ts +1 -1
- package/out/Module.sol/Module.json +1 -1
- package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.abi.json +1 -1
- package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.abi.json.d.ts +1 -1
- package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.json +1 -1
- package/out/NamespaceDelegationControl.sol/NamespaceDelegationControl.json +1 -1
- package/out/NamespaceOwner.sol/NamespaceOwner.json +1 -1
- package/out/Ownable.sol/Ownable.abi.json +426 -0
- package/out/Ownable.sol/Ownable.abi.json.d.ts +428 -0
- package/out/Ownable.sol/Ownable.json +1 -0
- package/out/Owner.sol/Owner.json +1 -1
- package/out/Pausable.sol/Pausable.abi.json +2 -151
- package/out/Pausable.sol/Pausable.abi.json.d.ts +2 -151
- package/out/Pausable.sol/Pausable.json +1 -1
- package/out/Paused.sol/Paused.json +1 -1
- package/out/RegistrationSystem.sol/RegistrationSystem.abi.json +1 -1
- package/out/RegistrationSystem.sol/RegistrationSystem.abi.json.d.ts +1 -1
- package/out/RegistrationSystem.sol/RegistrationSystem.json +1 -1
- package/out/ResourceAccess.sol/ResourceAccess.json +1 -1
- package/out/ResourceId.sol/ResourceIdInstance.json +1 -1
- package/out/ResourceId.sol/ResourceIdLib.json +1 -1
- package/out/ResourceIds.sol/ResourceIds.json +1 -1
- package/out/Schema.sol/SchemaInstance.json +1 -1
- package/out/Schema.sol/SchemaLib.json +1 -1
- package/out/Slice.sol/SliceInstance.json +1 -1
- package/out/Slice.sol/SliceLib.json +1 -1
- package/out/StdAssertions.sol/StdAssertions.json +1 -1
- package/out/StdChains.sol/StdChains.json +1 -1
- package/out/StdCheats.sol/StdCheats.json +1 -1
- package/out/StdCheats.sol/StdCheatsSafe.json +1 -1
- package/out/StdError.sol/stdError.json +1 -1
- package/out/StdInvariant.sol/StdInvariant.json +1 -1
- package/out/StdJson.sol/stdJson.json +1 -1
- package/out/StdMath.sol/stdMath.json +1 -1
- package/out/StdStorage.sol/stdStorage.json +1 -1
- package/out/StdStorage.sol/stdStorageSafe.json +1 -1
- package/out/StdStyle.sol/StdStyle.json +1 -1
- package/out/StdUtils.sol/StdUtils.json +1 -1
- package/out/Storage.sol/Storage.json +1 -1
- package/out/Store.sol/Store.abi.json +1261 -0
- package/out/Store.sol/Store.abi.json.d.ts +1263 -0
- package/out/Store.sol/Store.json +1 -0
- package/out/StoreConsumer.sol/StoreConsumer.abi.json +15 -0
- package/out/StoreConsumer.sol/StoreConsumer.abi.json.d.ts +17 -0
- package/out/StoreConsumer.sol/StoreConsumer.json +1 -0
- package/out/StoreCore.sol/StoreCore.json +1 -1
- package/out/StoreCore.sol/StoreCoreInternal.json +1 -1
- package/out/StoreHooks.sol/StoreHooks.json +1 -1
- package/out/StoreKernel.sol/StoreKernel.json +1 -1
- package/out/StoreRead.sol/StoreRead.json +1 -1
- package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.abi.json +1 -1
- package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.abi.json.d.ts +1 -1
- package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.json +1 -1
- package/out/StoreSwitch.sol/StoreSwitch.json +1 -1
- package/out/System.sol/System.abi.json +1 -1
- package/out/System.sol/System.abi.json.d.ts +1 -1
- package/out/System.sol/System.json +1 -1
- package/out/SystemCall.sol/SystemCall.json +1 -1
- package/out/SystemHooks.sol/SystemHooks.json +1 -1
- package/out/SystemRegistry.sol/SystemRegistry.json +1 -1
- package/out/Systems.sol/Systems.json +1 -1
- package/out/Tables.sol/Tables.json +1 -1
- package/out/Test.sol/Test.json +1 -1
- package/out/TightCoder.sol/TightCoder.json +1 -1
- package/out/TotalSupply.sol/TotalSupply.json +1 -1
- package/out/UserDelegationControl.sol/UserDelegationControl.json +1 -1
- package/out/Vm.sol/Vm.json +1 -1
- package/out/Vm.sol/VmSafe.json +1 -1
- package/out/WithStore.sol/WithStore.abi.json +352 -0
- package/out/WithStore.sol/WithStore.abi.json.d.ts +354 -0
- package/out/WithStore.sol/WithStore.json +1 -0
- package/out/WithWorld.sol/WithWorld.abi.json +490 -0
- package/out/WithWorld.sol/WithWorld.abi.json.d.ts +492 -0
- package/out/WithWorld.sol/WithWorld.json +1 -0
- package/out/World.sol/World.json +1 -1
- package/out/WorldContext.sol/WorldContextConsumer.abi.json +1 -1
- package/out/WorldContext.sol/WorldContextConsumer.abi.json.d.ts +1 -1
- package/out/WorldContext.sol/WorldContextConsumer.json +1 -1
- package/out/WorldContext.sol/WorldContextConsumerLib.json +1 -1
- package/out/WorldContext.sol/WorldContextProviderLib.json +1 -1
- package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.abi.json +1 -1
- package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.abi.json.d.ts +1 -1
- package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.json +1 -1
- package/out/WorldResourceId.sol/WorldResourceIdInstance.json +1 -1
- package/out/WorldResourceId.sol/WorldResourceIdLib.json +1 -1
- package/out/build-info/60c60a9593fdb00b3264c36836a28f39.json +1 -0
- package/out/console.sol/console.json +1 -1
- package/out/console2.sol/console2.json +1 -1
- package/out/constants.sol/LayoutOffsets.json +1 -1
- package/out/safeconsole.sol/safeconsole.json +1 -1
- package/out/src/IERC165.sol/IERC165.json +1 -1
- package/out/tables/Balances.sol/Balances.json +1 -1
- package/out/test.sol/DSTest.json +1 -1
- package/package.json +8 -8
- package/src/examples/ERC20WithInternalStore.sol +32 -0
- package/src/examples/{ERC20PausableBurnable.sol → ERC20WithWorld.sol} +9 -4
- package/src/experimental/ERC20Module.sol +7 -3
- package/src/experimental/MUDERC20.sol +7 -8
- package/src/experimental/Ownable.sol +110 -0
- package/src/experimental/Pausable.sol +4 -5
- package/out/ERC20Burnable.t.sol/MockERC20Burnable.json +0 -1
- package/out/ERC20PausableBurnable.sol/ERC20PausableBurnable.json +0 -1
- package/out/WorldConsumer.sol/WorldConsumer.abi.json +0 -177
- package/out/WorldConsumer.sol/WorldConsumer.abi.json.d.ts +0 -179
- package/out/WorldConsumer.sol/WorldConsumer.json +0 -1
- package/out/build-info/3a51d1e90905a7ef4d37017d85f9a6c1.json +0 -1
- /package/out/ERC20BaseTest.t.sol/{ERC20Test.abi.json → ERC20WithWorldBehaviorTest.abi.json} +0 -0
- /package/out/ERC20BaseTest.t.sol/{ERC20Test.abi.json.d.ts → ERC20WithWorldBehaviorTest.abi.json.d.ts} +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.24;
|
|
3
|
+
|
|
4
|
+
// Adapted example from OpenZeppelin's Contract Wizard: https://wizard.openzeppelin.com/
|
|
5
|
+
|
|
6
|
+
import { WithStore } from "@latticexyz/store-consumer/src/experimental/WithStore.sol";
|
|
7
|
+
import { Ownable } from "../experimental/Ownable.sol";
|
|
8
|
+
import { ERC20Pausable } from "../experimental/ERC20Pausable.sol";
|
|
9
|
+
import { ERC20Burnable } from "../experimental/ERC20Burnable.sol";
|
|
10
|
+
import { MUDERC20 } from "../experimental/MUDERC20.sol";
|
|
11
|
+
|
|
12
|
+
contract ERC20WithInternalStore is WithStore(address(this)), MUDERC20, ERC20Pausable, ERC20Burnable, Ownable {
|
|
13
|
+
constructor() MUDERC20("MyERC20", "MTK") Ownable(_msgSender()) {}
|
|
14
|
+
|
|
15
|
+
function mint(address to, uint256 value) public onlyOwner {
|
|
16
|
+
_mint(to, value);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function pause() public onlyOwner {
|
|
20
|
+
_pause();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function unpause() public onlyOwner {
|
|
24
|
+
_unpause();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// The following functions are overrides required by Solidity.
|
|
28
|
+
|
|
29
|
+
function _update(address from, address to, uint256 value) internal override(MUDERC20, ERC20Pausable) {
|
|
30
|
+
super._update(from, to, value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -5,21 +5,22 @@ pragma solidity >=0.8.24;
|
|
|
5
5
|
|
|
6
6
|
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
|
|
7
7
|
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
|
|
8
|
-
import {
|
|
8
|
+
import { WithWorld } from "@latticexyz/store-consumer/src/experimental/WithWorld.sol";
|
|
9
|
+
import { Context } from "@latticexyz/store-consumer/src/experimental/Context.sol";
|
|
9
10
|
|
|
10
11
|
import { ERC20Pausable } from "../experimental/ERC20Pausable.sol";
|
|
11
12
|
import { ERC20Burnable } from "../experimental/ERC20Burnable.sol";
|
|
12
13
|
import { MUDERC20 } from "../experimental/MUDERC20.sol";
|
|
13
14
|
|
|
14
|
-
contract
|
|
15
|
+
contract ERC20WithWorld is WithWorld, MUDERC20, ERC20Pausable, ERC20Burnable {
|
|
15
16
|
constructor(
|
|
16
17
|
IBaseWorld world,
|
|
17
18
|
bytes14 namespace,
|
|
18
19
|
string memory name,
|
|
19
20
|
string memory symbol
|
|
20
|
-
)
|
|
21
|
+
) WithWorld(world, namespace, true) MUDERC20(name, symbol) {
|
|
21
22
|
// Transfer namespace ownership to the creator
|
|
22
|
-
world.transferOwnership(
|
|
23
|
+
world.transferOwnership(getNamespaceId(), _msgSender());
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
function mint(address to, uint256 value) public onlyNamespace {
|
|
@@ -36,6 +37,10 @@ contract ERC20PausableBurnable is MUDERC20, ERC20Pausable, ERC20Burnable {
|
|
|
36
37
|
|
|
37
38
|
// The following functions are overrides required by Solidity.
|
|
38
39
|
|
|
40
|
+
function _msgSender() public view override(Context, WithWorld) returns (address sender) {
|
|
41
|
+
return WithWorld._msgSender();
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
function _update(address from, address to, uint256 value) internal override(MUDERC20, ERC20Pausable) {
|
|
40
45
|
super._update(from, to, value);
|
|
41
46
|
}
|
|
@@ -11,14 +11,14 @@ import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.
|
|
|
11
11
|
import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol";
|
|
12
12
|
|
|
13
13
|
import { ERC20Registry } from "../codegen/tables/ERC20Registry.sol";
|
|
14
|
-
import {
|
|
14
|
+
import { ERC20WithWorld } from "../examples/ERC20WithWorld.sol";
|
|
15
15
|
import { ModuleConstants } from "./Constants.sol";
|
|
16
16
|
|
|
17
17
|
contract ERC20Module is Module {
|
|
18
18
|
error ERC20Module_InvalidNamespace(bytes14 namespace);
|
|
19
19
|
error ERC20Module_NamespaceAlreadyExists(bytes14 namespace);
|
|
20
20
|
|
|
21
|
-
function install(bytes memory encodedArgs) public
|
|
21
|
+
function install(bytes memory encodedArgs) public {
|
|
22
22
|
// TODO: we should probably check just for namespace, not for all args
|
|
23
23
|
requireNotInstalled(__self, encodedArgs);
|
|
24
24
|
|
|
@@ -39,7 +39,7 @@ contract ERC20Module is Module {
|
|
|
39
39
|
|
|
40
40
|
IBaseWorld world = IBaseWorld(_world());
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
ERC20WithWorld token = new ERC20WithWorld(world, namespace, name, symbol);
|
|
43
43
|
|
|
44
44
|
// Grant access to the token so it can write to tables after transferring ownership
|
|
45
45
|
world.grantAccess(namespaceId, address(token));
|
|
@@ -52,6 +52,10 @@ contract ERC20Module is Module {
|
|
|
52
52
|
|
|
53
53
|
ERC20RegistryLib.register(world, namespaceId, address(token));
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
function installRoot(bytes memory) public pure {
|
|
57
|
+
revert Module_RootInstallNotSupported();
|
|
58
|
+
}
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
library ERC20RegistryLib {
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
pragma solidity >=0.8.24;
|
|
4
4
|
|
|
5
5
|
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { RESOURCE_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol";
|
|
6
|
+
import { StoreConsumer } from "@latticexyz/store-consumer/src/experimental/StoreConsumer.sol";
|
|
7
|
+
import { Context } from "@latticexyz/store-consumer/src/experimental/Context.sol";
|
|
9
8
|
|
|
10
9
|
import { ERC20Metadata, ERC20MetadataData } from "../codegen/tables/ERC20Metadata.sol";
|
|
11
10
|
import { TotalSupply } from "../codegen/tables/TotalSupply.sol";
|
|
@@ -18,7 +17,7 @@ import { IERC20Errors } from "../interfaces/IERC20Errors.sol";
|
|
|
18
17
|
|
|
19
18
|
import { ERC20TableNames } from "./Constants.sol";
|
|
20
19
|
|
|
21
|
-
abstract contract MUDERC20 is IERC20, IERC20Metadata, IERC20Errors,
|
|
20
|
+
abstract contract MUDERC20 is Context, IERC20, IERC20Metadata, IERC20Errors, StoreConsumer {
|
|
22
21
|
ResourceId internal immutable totalSupplyId;
|
|
23
22
|
ResourceId internal immutable balancesId;
|
|
24
23
|
ResourceId internal immutable allowancesId;
|
|
@@ -26,10 +25,10 @@ abstract contract MUDERC20 is IERC20, IERC20Metadata, IERC20Errors, WorldConsume
|
|
|
26
25
|
|
|
27
26
|
constructor(string memory _name, string memory _symbol) {
|
|
28
27
|
// Needs to be inlined in the constructor
|
|
29
|
-
totalSupplyId =
|
|
30
|
-
balancesId =
|
|
31
|
-
allowancesId =
|
|
32
|
-
metadataId =
|
|
28
|
+
totalSupplyId = _encodeTableId(ERC20TableNames.TOTAL_SUPPLY);
|
|
29
|
+
balancesId = _encodeTableId(ERC20TableNames.BALANCES);
|
|
30
|
+
allowancesId = _encodeTableId(ERC20TableNames.ALLOWANCES);
|
|
31
|
+
metadataId = _encodeTableId(ERC20TableNames.METADATA);
|
|
33
32
|
|
|
34
33
|
// Register each table
|
|
35
34
|
TotalSupply.register(totalSupplyId);
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Adapted from OpenZeppelin Contracts [access/Ownable.sol](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/f989fff93168606c726bc5e831ef50dd6e543f45/contracts/access/Ownable.sol)
|
|
3
|
+
pragma solidity >=0.8.24;
|
|
4
|
+
|
|
5
|
+
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
|
|
6
|
+
import { StoreConsumer } from "@latticexyz/store-consumer/src/experimental/StoreConsumer.sol";
|
|
7
|
+
import { Context } from "@latticexyz/store-consumer/src/experimental/Context.sol";
|
|
8
|
+
|
|
9
|
+
import { Owner } from "../codegen/tables/Owner.sol";
|
|
10
|
+
import { OwnableTableNames } from "./Constants.sol";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @dev Contract module which provides a basic access control mechanism, where
|
|
14
|
+
* there is an account (an owner) that can be granted exclusive access to
|
|
15
|
+
* specific functions.
|
|
16
|
+
*
|
|
17
|
+
* The initial owner is set to the address provided by the deployer. This can
|
|
18
|
+
* later be changed with {transferOwnership}.
|
|
19
|
+
*
|
|
20
|
+
* This module is used through inheritance. It will make available the modifier
|
|
21
|
+
* `onlyOwner`, which can be applied to your functions to restrict their use to
|
|
22
|
+
* the owner.
|
|
23
|
+
*/
|
|
24
|
+
abstract contract Ownable is Context, StoreConsumer {
|
|
25
|
+
ResourceId internal immutable ownerId;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @dev The caller account is not authorized to perform an operation.
|
|
29
|
+
*/
|
|
30
|
+
error OwnableUnauthorizedAccount(address account);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @dev The owner is not a valid owner account. (eg. `address(0)`)
|
|
34
|
+
*/
|
|
35
|
+
error OwnableInvalidOwner(address owner);
|
|
36
|
+
|
|
37
|
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
|
|
41
|
+
*/
|
|
42
|
+
constructor(address initialOwner) {
|
|
43
|
+
if (initialOwner == address(0)) {
|
|
44
|
+
revert OwnableInvalidOwner(address(0));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ownerId = _encodeTableId(OwnableTableNames.OWNER);
|
|
48
|
+
|
|
49
|
+
// Register table
|
|
50
|
+
Owner.register(ownerId);
|
|
51
|
+
|
|
52
|
+
_transferOwnership(initialOwner);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @dev Throws if called by any account other than the owner.
|
|
57
|
+
*/
|
|
58
|
+
modifier onlyOwner() {
|
|
59
|
+
_checkOwner();
|
|
60
|
+
_;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @dev Returns the address of the current owner.
|
|
65
|
+
*/
|
|
66
|
+
function owner() public view virtual returns (address) {
|
|
67
|
+
return Owner.get(ownerId);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @dev Throws if the sender is not the owner.
|
|
72
|
+
*/
|
|
73
|
+
function _checkOwner() internal view virtual {
|
|
74
|
+
if (owner() != _msgSender()) {
|
|
75
|
+
revert OwnableUnauthorizedAccount(_msgSender());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @dev Leaves the contract without owner. It will not be possible to call
|
|
81
|
+
* `onlyOwner` functions. Can only be called by the current owner.
|
|
82
|
+
*
|
|
83
|
+
* NOTE: Renouncing ownership will leave the contract without an owner,
|
|
84
|
+
* thereby disabling any functionality that is only available to the owner.
|
|
85
|
+
*/
|
|
86
|
+
function renounceOwnership() public virtual onlyOwner {
|
|
87
|
+
_transferOwnership(address(0));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
|
92
|
+
* Can only be called by the current owner.
|
|
93
|
+
*/
|
|
94
|
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
|
95
|
+
if (newOwner == address(0)) {
|
|
96
|
+
revert OwnableInvalidOwner(address(0));
|
|
97
|
+
}
|
|
98
|
+
_transferOwnership(newOwner);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
|
103
|
+
* Internal function without access restriction.
|
|
104
|
+
*/
|
|
105
|
+
function _transferOwnership(address newOwner) internal virtual {
|
|
106
|
+
address oldOwner = owner();
|
|
107
|
+
Owner.set(ownerId, newOwner);
|
|
108
|
+
emit OwnershipTransferred(oldOwner, newOwner);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
// Adapted from OpenZeppelin Contracts [utils/Pausable.sol](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/f989fff93168606c726bc5e831ef50dd6e543f45/contracts/utils/Pausable.sol)
|
|
3
3
|
pragma solidity >=0.8.24;
|
|
4
4
|
|
|
5
|
-
import { RESOURCE_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol";
|
|
6
5
|
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { StoreConsumer } from "@latticexyz/store-consumer/src/experimental/StoreConsumer.sol";
|
|
7
|
+
import { Context } from "@latticexyz/store-consumer/src/experimental/Context.sol";
|
|
9
8
|
|
|
10
9
|
import { Paused as PausedTable } from "../codegen/tables/Paused.sol";
|
|
11
10
|
import { PausableTableNames } from "./Constants.sol";
|
|
@@ -19,7 +18,7 @@ import { PausableTableNames } from "./Constants.sol";
|
|
|
19
18
|
* the functions of your contract. Note that they will not be pausable by
|
|
20
19
|
* simply including this module, only once the modifiers are put in place.
|
|
21
20
|
*/
|
|
22
|
-
abstract contract Pausable is
|
|
21
|
+
abstract contract Pausable is Context, StoreConsumer {
|
|
23
22
|
ResourceId internal immutable pausedId;
|
|
24
23
|
|
|
25
24
|
/**
|
|
@@ -46,7 +45,7 @@ abstract contract Pausable is WorldConsumer {
|
|
|
46
45
|
* @dev Initializes the contract in unpaused state.
|
|
47
46
|
*/
|
|
48
47
|
constructor() {
|
|
49
|
-
pausedId =
|
|
48
|
+
pausedId = _encodeTableId(PausableTableNames.PAUSED);
|
|
50
49
|
PausedTable.register(pausedId);
|
|
51
50
|
PausedTable.set(pausedId, false);
|
|
52
51
|
}
|