-
Notifications
You must be signed in to change notification settings - Fork 14
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
CCP Red Dragon/Turret Whitelist Example + Smart Gate Corp Whitelist #52
Draft
CCP-Red-Dragon
wants to merge
22
commits into
develop
Choose a base branch
from
ccp-red-dragon/turret-whitelist
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
88a69fb
Turret Whitelist
CCP-Red-Dragon 135360a
Whitelisting
CCP-Red-Dragon 6e408f2
Alterations
CCP-Red-Dragon e454387
Execute update
CCP-Red-Dragon 276b211
Further development
CCP-Red-Dragon ca6ab36
Changes
CCP-Red-Dragon 6507de2
Upgrading
CCP-Red-Dragon da1558b
Client
CCP-Red-Dragon e3c7c4e
DApp
CCP-Red-Dragon 6ff11cc
Fixes
CCP-Red-Dragon e585dce
Removing
CCP-Red-Dragon 853c83c
Remove fix
CCP-Red-Dragon 89933aa
Linked to environment variables
CCP-Red-Dragon c869e7f
Fetch fixes
CCP-Red-Dragon 9f48065
Alterations
CCP-Red-Dragon 63bd4ab
Further client and contract development work
CCP-Red-Dragon 4508be6
Smart Gate Corp Whitelist + Further Turret work
CCP-Red-Dragon 4b0a41d
Performance change
CCP-Red-Dragon 79754b8
Fixed small console error
CCP-Red-Dragon e06952a
MUD Table Filter
CCP-Red-Dragon ac92369
Quick fixes
CCP-Red-Dragon a331d7c
Client Changes
CCP-Red-Dragon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import { defineWorld } from "@latticexyz/world"; | ||
|
||
export default defineWorld({ | ||
namespace: "test", | ||
namespace: "dapp_dev2", | ||
tables: { | ||
GateAccess: { | ||
schema: { | ||
smartObjectId: "uint256", | ||
corp: "uint256" | ||
}, | ||
key: ["smartObjectId"], | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
VITE_CHAIN_ID=31337 | ||
|
||
# This .env file is for demonstration purposes only. | ||
# | ||
# This should usually be excluded via .gitignore and the env vars attached to | ||
# your deployment environment, but we're including this here for ease of local | ||
# development. Please do not commit changes to this file! | ||
# | ||
# Enable debug logs for MUD CLI | ||
DEBUG=mud:* | ||
# | ||
# Anvil default private key: | ||
VITE_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
VITE_WORLD_ADDRESS=0x8a791620dd6260079bf849dc5567adc3f2fdc318 | ||
VITE_PLAYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
|
||
#Local RPC | ||
VITE_RPC_URL="http://127.0.0.1:8545" | ||
|
||
|
||
# SMART TURRET CONFIG | ||
# Copy this info from in game smart turret | ||
VITE_SMART_TURRET_ID=9640513001323359261895106592991319872122110296371423549860904054745193604808 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,154 @@ | ||
//Import packages | ||
import { useMUD } from "./MUDContext"; | ||
import React, { useEffect, useState, useRef } from "react"; | ||
|
||
const styleUnset = { all: "unset" } as const; | ||
//Import EVE Frontier Packages | ||
import { EveButton, EveInput, EveScroll } from "@eveworld/ui-components"; | ||
|
||
//Import CSS | ||
import "./styles.css"; | ||
import "./styles-ui.css"; | ||
|
||
//Import components | ||
import WhitelistEntry from './components/WhitelistEntry' | ||
import AppContainer from './components/AppContainer' | ||
import Title from './components/Title' | ||
import ContentContainer from './components/ContentContainer' | ||
import Section from './components/Section' | ||
|
||
export const App = () => { | ||
const { | ||
network: { tables, useStore } | ||
} = useMUD(); | ||
|
||
const tasks = useStore((state) => { | ||
const records = Object.values(state.getRecords(tables.Tasks)); | ||
records.sort((a, b) => Number(a.value.createdAt - b.value.createdAt)); | ||
return records; | ||
}); | ||
|
||
return ( | ||
<> | ||
|
||
</> | ||
); | ||
}; | ||
const { | ||
systemCalls: { | ||
getWhitelist, | ||
addToWhitelist, | ||
removeFromWhitelist | ||
}, | ||
} = useMUD(); | ||
|
||
//Character name input value | ||
const characterNameInputRef = useRef(0); | ||
|
||
//Pre-populate the UI list | ||
const [whitelist, setWhitelist] = useState(<WhitelistEntry id={"LOADING...."}></WhitelistEntry>); | ||
const [addErrorVar, setAddErrorVar] = useState(""); | ||
|
||
//Edit character name | ||
const handleEdit = ( | ||
refString: React.MutableRefObject<number>, | ||
eventString: number | ||
): void => { | ||
refString.current = eventString; | ||
}; | ||
|
||
//Initial load | ||
useEffect(() => { | ||
setTimeout(function(){ | ||
fetchWhitelist(null); | ||
}, 1000) | ||
}, []) | ||
|
||
//Remove from the whitelist | ||
const remove = async (id) => { | ||
const whitelist = await removeFromWhitelist(id); | ||
|
||
loadWhitelist(whitelist); | ||
} | ||
|
||
//Fetch the whitelist data | ||
async function fetchWhitelist(event){ | ||
if(event) event.preventDefault(); | ||
const whitelist = await getWhitelist(); | ||
loadWhitelist(whitelist); | ||
} | ||
|
||
//Load the whitelist UI | ||
async function loadWhitelist(result){ | ||
if(result == null) return; | ||
|
||
var newArray = result.whitelist.map((value) => <WhitelistEntry key={value.toString()} id={value.toString()} handleClick={remove}>{value}</WhitelistEntry>) | ||
setWhitelist(newArray); | ||
} | ||
|
||
//Add to the whitelist | ||
async function addToWhitelistButton (){ | ||
//Check there is a name | ||
if(characterNameInputRef.current == ""){ | ||
setAddErrorVar("- NO INPUT"); | ||
return; | ||
} | ||
|
||
//Fetch the world API data | ||
const response = await fetch(`https://blockchain-gateway-nova.nursery.reitnorf.com/smartcharacters`); | ||
const data = await response.json(); | ||
|
||
var address = null; | ||
|
||
//Check to see if the address exists | ||
for(var i = 0; i < data.length; i++){ | ||
if(data[i].name == characterNameInputRef.current){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you go by characterId address instead of name ? Or possibly enter characterName or characterId or characterAddress |
||
address = data[i].address; | ||
} | ||
} | ||
|
||
//If an address wasn't found, exit | ||
if(address == null){ | ||
setAddErrorVar("- CHARACTER NOT FOUND"); | ||
return; | ||
} | ||
|
||
//Clear the error message | ||
setAddErrorVar(""); | ||
|
||
//Add to whitelist | ||
const whitelist = await addToWhitelist(address); | ||
|
||
//Load whitelist if not null | ||
if(whitelist != null) loadWhitelist(whitelist); | ||
} | ||
|
||
return ( | ||
<AppContainer> | ||
<Title> | ||
SMART TURRET WHITELISTING | ||
</Title> | ||
<ContentContainer> | ||
<Section> | ||
<div className="grid grid-cols-1 rows-2 gap-1"> | ||
<EveInput | ||
inputType="string" | ||
defaultValue="" | ||
fieldName={`Character Name ${addErrorVar}`} | ||
onChange={(str) => handleEdit(characterNameInputRef, str as number)} | ||
/> | ||
<EveButton | ||
typeClass="primary" | ||
onClick={addToWhitelistButton} | ||
className="primary-sm"> | ||
Add to Whitelist | ||
</EveButton> | ||
</div> | ||
</Section> | ||
<Section> | ||
<EveButton | ||
typeClass="primary" | ||
onClick={(event) => fetchWhitelist(event)} | ||
className="primary-sm"> | ||
Fetch Whitelist | ||
</EveButton> | ||
</Section> | ||
<Section> | ||
<div className="w-full items-center py-1"> | ||
Whitelist | ||
</div> | ||
|
||
<EveScroll | ||
maxHeight="200px" | ||
classStyles="h-full" | ||
> | ||
{whitelist} | ||
</EveScroll> | ||
</Section> | ||
</ContentContainer> | ||
</AppContainer> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions
13
smart-turret/packages/client/src/components/AppContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from "react"; | ||
|
||
const AppContainer = ({children}) => { | ||
return( | ||
<div className="bg-crude-5 w-screen min-h-screen"> | ||
<div className="flex flex-col align-center max-w-[560px] mx-auto pb-6 min-h-screen h-full"> | ||
{children} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default AppContainer; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we bring the character id from .env ?