generated from nation3/nation3-template
-
Notifications
You must be signed in to change notification settings - Fork 4
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
1ff7220
commit fe5dd7a
Showing
3 changed files
with
284 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,219 @@ | ||
{ | ||
"abi": [ | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "passportUtils_", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "illegalAlien", | ||
"type": "address" | ||
} | ||
], | ||
"name": "NotPassportOwner", | ||
"type": "error" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "citizen", | ||
"type": "address" | ||
} | ||
], | ||
"name": "PassportExpired", | ||
"type": "error" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "uint8", | ||
"name": "rating", | ||
"type": "uint8" | ||
} | ||
], | ||
"name": "RatingValueError", | ||
"type": "error" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "address", | ||
"name": "developer", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint8", | ||
"name": "rating", | ||
"type": "uint8" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "address", | ||
"name": "citizen", | ||
"type": "address" | ||
} | ||
], | ||
"name": "Rated", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "VERSION", | ||
"outputs": [ | ||
{ | ||
"internalType": "string", | ||
"name": "", | ||
"type": "string" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "owner", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "passportUtils", | ||
"outputs": [ | ||
{ | ||
"internalType": "contract IPassportUtils", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "developer", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint8", | ||
"name": "rating", | ||
"type": "uint8" | ||
} | ||
], | ||
"name": "rate", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "owner_", | ||
"type": "address" | ||
} | ||
], | ||
"name": "setOwner", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "passportUtils_", | ||
"type": "address" | ||
} | ||
], | ||
"name": "setPassportUtils", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"name": "skillLevelAverages", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"name": "skillLevelRatings", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint8", | ||
"name": "", | ||
"type": "uint8" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"name": "skillLevelRatingsCount", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint8", | ||
"name": "", | ||
"type": "uint8" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { useContractRead } from "wagmi" | ||
import LoadingIndicator from "./LoadingIndicator" | ||
import DeveloperSkillLevels from "../../abis/DeveloperSkillLevels.json" | ||
import { useIsMounted } from "@/hooks/useIsMounted" | ||
import Link from "next/link" | ||
import { formatEther } from "viem" | ||
|
||
export default function ProfileDetailsDevSkillRating({ citizen }: any) { | ||
console.info('ProfileDetailsDevSkillRating') | ||
|
||
const { data, isError, isLoading } = useContractRead({ | ||
address: '0x4E8231B8374DBd70E8BDD7c7779BEa457318a21c', | ||
abi: DeveloperSkillLevels.abi, | ||
functionName: 'skillLevelAverages', | ||
args: [citizen.ownerAddress] | ||
}) | ||
console.info('data:', data) | ||
console.info('isError:', isError) | ||
console.info('isLoading:', isLoading) | ||
|
||
if (!useIsMounted() || isLoading) { | ||
return <LoadingIndicator /> | ||
} else { | ||
let skillLevelAverage: any = null | ||
if (data) { | ||
skillLevelAverage = data | ||
} | ||
console.info('skillLevelAverage:', skillLevelAverage) | ||
if (!skillLevelAverage) { | ||
return ( | ||
<div> | ||
<Link href={`https://etherscan.io/address/0x4e8231b8374dbd70e8bdd7c7779bea457318a21c#writeContract#F1`} target="_blank" className="float-right border rounded-full px-2 ml-8 font-bold text-transparent bg-clip-text bg-gradient-to-br from-sky-400 to-green-400"> | ||
Rate 🔗 | ||
</Link> | ||
<code>Not rated</code> | ||
</div> | ||
) | ||
} else { | ||
const skillLevelAverageEther: number = Number(formatEther(skillLevelAverage)) | ||
console.info('skillLevelAverageEther:', skillLevelAverageEther) | ||
const skillLevelAverageRounded: number = Math.round(skillLevelAverageEther) | ||
console.info('skillLevelAverageRounded:', skillLevelAverageRounded) | ||
const ratingValues = ['★☆☆☆☆ 1/5', '★★☆☆☆ 2/5', '★★★☆☆ 3/5', '★★★★☆ 4/5', '★★★★★ 5/5'] | ||
const ratingTextColors = ['text-orange-400', 'text-amber-400', 'text-lime-400', 'text-emerald-400', 'text-cyan-400' ] | ||
return ( | ||
<> | ||
<Link href={`https://etherscan.io/address/0x4e8231b8374dbd70e8bdd7c7779bea457318a21c#writeContract#F1`} target="_blank" className="float-right border rounded-full px-2 ml-8 font-bold text-transparent bg-clip-text bg-gradient-to-br from-sky-400 to-green-400"> | ||
Rate 🔗 | ||
</Link> | ||
<span className={`font-bold ${ratingTextColors[skillLevelAverageRounded - 1]}`}>{ratingValues[skillLevelAverageRounded - 1]}</span> | ||
</> | ||
) | ||
} | ||
} | ||
} |
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