Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: onchain crude matter #331

6 changes: 6 additions & 0 deletions mud-contracts/world-v2/.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ ERC20_INITIAL_SUPPLY=10000000000
EVE_TOKEN_NAMESPACE=test
EVE_TOKEN_ADMIN=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

CRUDE_TOKEN_NAME=CRUDE
CRUDE_TOKEN_SYMBOL=CRUDE
CRUDE_INITIAL_SUPPLY=10000000000
CRUDE_TOKEN_NAMESPACE=test
CRUDE_TOKEN_ADMIN=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

BASE_URI=https://devnet-data-ipfs-gateway.nursery.reitnorf.com/
93 changes: 93 additions & 0 deletions mud-contracts/world-v2/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,54 @@ export default defineWorld({
tableIdArgument: true,
},
},

/************************************************************************
*
* ERC20 MODULE
*
************************************************************************/
ERC20Metadata: {
schema: {
decimals: "uint8",
name: "string",
symbol: "string",
},
key: [],
codegen: {
tableIdArgument: true,
},
},
Allowances: {
schema: {
account: "address",
spender: "address",
value: "uint256",
},
key: ["account", "spender"],
codegen: {
tableIdArgument: true,
},
},
TotalSupply: {
schema: {
totalSupply: "uint256",
},
key: [],
codegen: {
tableIdArgument: true,
},
},
ERC20Registry: {
schema: {
namespaceId: "ResourceId",
tokenAddress: "address",
},
key: ["namespaceId"],
codegen: {
tableIdArgument: true,
},
},

/*******************
* LOCATION MODULE *
*******************/
Expand Down Expand Up @@ -362,6 +410,51 @@ export default defineWorld({
},
key: ["sourceGateId"],
},

/*************************
* SMART CRUDE LIFT MODULE *
*************************/

CrudeLift: {
schema: {
smartObjectId: "uint256",
lensId: "uint256",
startMiningTime: "uint256",
miningRiftId: "uint256",
miningRate: "uint256",
// Must commit to stop mining at a specific block number
// in order to seed the randomness of collapse
stopMiningBlockNumber: "uint256",
},
key: ["smartObjectId"],
},

Lens: {
schema: {
lensId: "uint256",
createdAt: "uint256",
durability: "uint256",
exhausted: "bool",
},
key: ["lensId"],
},

Rift: {
schema: {
riftId: "uint256",
createdAt: "uint256",
collapsedAt: "uint256",
miningCrudeLiftId: "uint256",
// 0-100_000, determines the amount of crude mined per second
// a percentage with 3 digits of precision
// i.e. 100_000 = 100%
richness: "uint256",
// 0-100_000, determines the chance of a rift collapsing
// i.e. 100_000 = 100% chance of collapse
stability: "uint256",
},
key: ["riftId"],
},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions mud-contracts/world-v2/script/PostDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ contract PostDeploy is Script {
console.log("amount: ", amount * 1 ether);
}

function _createCrudeToken(IBaseWorld world) internal {}

function _createCharacterToken(IBaseWorld world) internal {
string memory baseURI = vm.envString("BASE_URI");

Expand Down
43 changes: 43 additions & 0 deletions mud-contracts/world-v2/src/codegen/world/ICrudeLiftSystem.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24;

/* Autogenerated file. Do not edit manually. */

import { EntityRecordData } from "../../namespaces/evefrontier/systems/entity-record/types.sol";
import { SmartObjectData } from "../../namespaces/evefrontier/systems/deployable/types.sol";
import { WorldPosition } from "../../namespaces/evefrontier/systems/location/types.sol";

/**
* @title ICrudeLiftSystem
* @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface ICrudeLiftSystem {
error LensNotInserted();
error LensExhausted();
error LensAlreadyInserted();
error CannotRemoveLensWhileMining();
error AlreadyMining();
error NotMining();
error RiftNotFoundOrDepleted();

function evefrontier__createAndAnchorCrudeLift(
uint256 smartObjectId,
EntityRecordData memory entityRecordData,
SmartObjectData memory smartObjectData,
WorldPosition memory worldPosition,
uint256 fuelUnitVolume,
uint256 fuelConsumptionIntervalInSeconds,
uint256 fuelMaxCapacity,
uint256 storageCapacity,
uint256 ephemeralStorageCapacity
) external;

function evefrontier__insertLens(uint256 smartObjectId, address player) external;

function evefrontier__startMining(uint256 smartObjectId, uint256 riftId) external;

function evefrontier__stopMining(uint256 smartObjectId) external;

function evefrontier__removeLens(uint256 smartObjectId, address receiver) external;
}
33 changes: 33 additions & 0 deletions mud-contracts/world-v2/src/codegen/world/IERC20System.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24;

/* Autogenerated file. Do not edit manually. */

/**
* @title IERC20System
* @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface IERC20System {
function evefrontier__name() external view returns (string memory);

function evefrontier__symbol() external view returns (string memory);

function evefrontier__decimals() external view returns (uint8);

function evefrontier__totalSupply() external view returns (uint256);

function evefrontier__balanceOf(address account) external view returns (uint256);

function evefrontier__allowance(address owner, address spender) external view returns (uint256);

function evefrontier__transfer(address to, uint256 value) external returns (bool);

function evefrontier__approve(address spender, uint256 value) external returns (bool);

function evefrontier__transferFrom(address from, address to, uint256 value) external returns (bool);

function evefrontier__mint(address account, uint256 value) external;

function evefrontier__burn(address account, uint256 value) external;
}
15 changes: 15 additions & 0 deletions mud-contracts/world-v2/src/codegen/world/IRiftSystem.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24;

/* Autogenerated file. Do not edit manually. */

/**
* @title IRiftSystem
* @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface IRiftSystem {
error RiftAlreadyExists();

function evefrontier__createRift(uint256 riftId, uint256 crudeAmount) external;
}
6 changes: 6 additions & 0 deletions mud-contracts/world-v2/src/codegen/world/IWorld.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ pragma solidity >=0.8.24;

import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
import { IEveSystem } from "./IEveSystem.sol";
import { ICrudeLiftSystem } from "./ICrudeLiftSystem.sol";
import { IDeployableSystem } from "./IDeployableSystem.sol";
import { IEntityRecordSystem } from "./IEntityRecordSystem.sol";
import { IERC20System } from "./IERC20System.sol";
import { IERC721System } from "./IERC721System.sol";
import { IFuelSystem } from "./IFuelSystem.sol";
import { IEphemeralInventorySystem } from "./IEphemeralInventorySystem.sol";
import { IInventoryInteractSystem } from "./IInventoryInteractSystem.sol";
import { IInventorySystem } from "./IInventorySystem.sol";
import { ILocationSystem } from "./ILocationSystem.sol";
import { IRiftSystem } from "./IRiftSystem.sol";
import { ISmartAssemblySystem } from "./ISmartAssemblySystem.sol";
import { ISmartCharacterSystem } from "./ISmartCharacterSystem.sol";
import { ISmartGateSystem } from "./ISmartGateSystem.sol";
Expand All @@ -30,14 +33,17 @@ import { IStaticDataSystem } from "./IStaticDataSystem.sol";
interface IWorld is
IBaseWorld,
IEveSystem,
ICrudeLiftSystem,
IDeployableSystem,
IEntityRecordSystem,
IERC20System,
IERC721System,
IFuelSystem,
IEphemeralInventorySystem,
IInventoryInteractSystem,
IInventorySystem,
ILocationSystem,
IRiftSystem,
ISmartAssemblySystem,
ISmartCharacterSystem,
ISmartGateSystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import { Owners } from "./tables/Owners.sol";
import { TokenApproval } from "./tables/TokenApproval.sol";
import { OperatorApproval } from "./tables/OperatorApproval.sol";
import { ERC721Registry } from "./tables/ERC721Registry.sol";
import { ERC20Metadata, ERC20MetadataData } from "./tables/ERC20Metadata.sol";
import { Allowances } from "./tables/Allowances.sol";
import { TotalSupply } from "./tables/TotalSupply.sol";
import { ERC20Registry } from "./tables/ERC20Registry.sol";
import { Location, LocationData } from "./tables/Location.sol";
import { GlobalDeployableState, GlobalDeployableStateData } from "./tables/GlobalDeployableState.sol";
import { DeployableState, DeployableStateData } from "./tables/DeployableState.sol";
Expand All @@ -32,3 +36,6 @@ import { ItemTransferOffchain, ItemTransferOffchainData } from "./tables/ItemTra
import { SmartTurretConfig } from "./tables/SmartTurretConfig.sol";
import { SmartGateConfig, SmartGateConfigData } from "./tables/SmartGateConfig.sol";
import { SmartGateLink, SmartGateLinkData } from "./tables/SmartGateLink.sol";
import { CrudeLift, CrudeLiftData } from "./tables/CrudeLift.sol";
import { Lens, LensData } from "./tables/Lens.sol";
import { Rift, RiftData } from "./tables/Rift.sol";
Loading