-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1076eba
commit 916200a
Showing
3 changed files
with
280 additions
and
12 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,58 @@ | ||
import CustomTable, { AccessData, Platform } from '../../components/shared/CustomTable'; | ||
import { FaDiscord, FaTelegram, FaGoogle } from 'react-icons/fa'; | ||
import { useEffect, useState } from 'react'; | ||
import { FaDiscord, FaGoogle } from 'react-icons/fa'; | ||
import { useReadContract } from 'wagmi'; | ||
import { Address } from 'viem'; | ||
import sepoliaChain from '../../utils/contracts/app/sepoliaChain.json'; | ||
import CustomTable, { | ||
AccessData, | ||
Platform, | ||
} from '../../components/shared/CustomTable'; | ||
|
||
const xcolumns: Platform[] = [ | ||
{ name: 'Discord', icon: <FaDiscord /> }, | ||
{ name: 'Telegram', icon: <FaTelegram /> }, | ||
{ name: 'Google', icon: <FaGoogle /> }, | ||
]; | ||
|
||
const ycolumns: AccessData[] = [ | ||
{ application: 'TogetherCrew', Discord: true, Telegram: false, Google: true }, | ||
{ application: 'MeetWith', Discord: true, Telegram: true, Google: false }, | ||
{ application: 'Wallet', Discord: false, Telegram: true, Google: true }, | ||
]; | ||
export function Permissions() { | ||
const [applications, setApplications] = useState<AccessData[]>([]); | ||
|
||
const data: AccessData[] = ycolumns; | ||
const { | ||
data: contractData, | ||
isLoading, | ||
isError, | ||
} = useReadContract({ | ||
abi: sepoliaChain.appContractABI, | ||
address: sepoliaChain.appContractAddress as Address, | ||
functionName: 'getApplications', | ||
args: [0, 10], | ||
}); | ||
|
||
useEffect(() => { | ||
if (contractData) { | ||
console.log({ contractData }); | ||
|
||
// Map the contract data to match your AccessData structure | ||
const mappedApplications: AccessData[] = contractData.map( | ||
(app: { name: string; account: string }) => ({ | ||
application: app.name, | ||
Discord: false, | ||
Google: false, | ||
}) | ||
); | ||
setApplications(mappedApplications); | ||
} | ||
}, [contractData]); | ||
|
||
if (isLoading) return <div>Loading...</div>; | ||
if (isError) return <div>Error loading data</div>; | ||
|
||
export function Permissions() { | ||
return ( | ||
<div> | ||
<CustomTable xcolumns={xcolumns} ycolumns={ycolumns} data={data} /> | ||
<CustomTable | ||
xcolumns={xcolumns} | ||
ycolumns={applications} | ||
data={applications} | ||
/> | ||
</div> | ||
); | ||
} |
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,235 @@ | ||
{ | ||
"chainId": 11155111, | ||
"appContractAddress": "0xAA7f2BA598d4ac22ffdbf5DaE9be35C2e4264aE3", | ||
"appContractABI": [ | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "initialAuthority", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "authority", "type": "address" } | ||
], | ||
"name": "AccessManagedInvalidAuthority", | ||
"type": "error" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "caller", "type": "address" }, | ||
{ "internalType": "uint32", "name": "delay", "type": "uint32" } | ||
], | ||
"name": "AccessManagedRequiredDelay", | ||
"type": "error" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "caller", "type": "address" } | ||
], | ||
"name": "AccessManagedUnauthorized", | ||
"type": "error" | ||
}, | ||
{ "inputs": [], "name": "ReentrancyGuardReentrantCall", "type": "error" }, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "id", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"components": [ | ||
{ "internalType": "string", "name": "name", "type": "string" }, | ||
{ "internalType": "address", "name": "account", "type": "address" } | ||
], | ||
"indexed": false, | ||
"internalType": "struct IApplicationManager.Application", | ||
"name": "application", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "ApplicationCreated", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "id", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"components": [ | ||
{ "internalType": "string", "name": "name", "type": "string" }, | ||
{ "internalType": "address", "name": "account", "type": "address" } | ||
], | ||
"indexed": false, | ||
"internalType": "struct IApplicationManager.Application", | ||
"name": "application", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "ApplicationDeleted", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "id", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"components": [ | ||
{ "internalType": "string", "name": "name", "type": "string" }, | ||
{ "internalType": "address", "name": "account", "type": "address" } | ||
], | ||
"indexed": false, | ||
"internalType": "struct IApplicationManager.Application", | ||
"name": "application", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "ApplicationUpdated", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "address", | ||
"name": "authority", | ||
"type": "address" | ||
} | ||
], | ||
"name": "AuthorityUpdated", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "authority", | ||
"outputs": [{ "internalType": "address", "name": "", "type": "address" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ "internalType": "string", "name": "name", "type": "string" }, | ||
{ "internalType": "address", "name": "account", "type": "address" } | ||
], | ||
"internalType": "struct IApplicationManager.Application", | ||
"name": "newApplication", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "createApplication", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint256", "name": "id", "type": "uint256" } | ||
], | ||
"name": "deleteApplication", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint256", "name": "id", "type": "uint256" } | ||
], | ||
"name": "getApplication", | ||
"outputs": [ | ||
{ | ||
"components": [ | ||
{ "internalType": "string", "name": "name", "type": "string" }, | ||
{ "internalType": "address", "name": "account", "type": "address" } | ||
], | ||
"internalType": "struct IApplicationManager.Application", | ||
"name": "", | ||
"type": "tuple" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint256", "name": "start", "type": "uint256" }, | ||
{ "internalType": "uint256", "name": "limit", "type": "uint256" } | ||
], | ||
"name": "getApplications", | ||
"outputs": [ | ||
{ | ||
"components": [ | ||
{ "internalType": "string", "name": "name", "type": "string" }, | ||
{ "internalType": "address", "name": "account", "type": "address" } | ||
], | ||
"internalType": "struct IApplicationManager.Application[]", | ||
"name": "", | ||
"type": "tuple[]" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "getNextApplicationId", | ||
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "isConsumingScheduledOp", | ||
"outputs": [{ "internalType": "bytes4", "name": "", "type": "bytes4" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "newAuthority", "type": "address" } | ||
], | ||
"name": "setAuthority", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint256", "name": "id", "type": "uint256" }, | ||
{ | ||
"components": [ | ||
{ "internalType": "string", "name": "name", "type": "string" }, | ||
{ "internalType": "address", "name": "account", "type": "address" } | ||
], | ||
"internalType": "struct IApplicationManager.Application", | ||
"name": "updatedApplication", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "updateApplication", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] | ||
} |
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