From d0e8575ed0ad9070ab305b120973a6dc76d2da62 Mon Sep 17 00:00:00 2001 From: Jordan Frankfurt Date: Thu, 17 Oct 2024 10:12:06 -0500 Subject: [PATCH 1/2] add support for talent protocol discounts --- .../abis/TalentProtocolDiscountValidator.ts | 229 ++++++++++++++++++ apps/web/src/addresses/usernames.ts | 5 + .../images/TalentProtocol.svg | 16 ++ .../RegistrationLearnMoreModal/index.tsx | 36 ++- .../hooks/useAggregatedDiscountValidators.ts | 14 ++ apps/web/src/hooks/useAttestations.ts | 39 ++- apps/web/src/utils/usernames.ts | 1 + 7 files changed, 332 insertions(+), 8 deletions(-) create mode 100644 apps/web/src/abis/TalentProtocolDiscountValidator.ts create mode 100644 apps/web/src/components/Basenames/RegistrationLearnMoreModal/images/TalentProtocol.svg diff --git a/apps/web/src/abis/TalentProtocolDiscountValidator.ts b/apps/web/src/abis/TalentProtocolDiscountValidator.ts new file mode 100644 index 00000000000..f93b34ba393 --- /dev/null +++ b/apps/web/src/abis/TalentProtocolDiscountValidator.ts @@ -0,0 +1,229 @@ +export default [ + { + inputs: [ + { + internalType: 'address', + name: 'owner_', + type: 'address', + }, + { + internalType: 'address', + name: 'talentProtocol_', + type: 'address', + }, + { + internalType: 'uint256', + name: 'threshold_', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + type: 'error', + name: 'AlreadyInitialized', + }, + { + inputs: [], + type: 'error', + name: 'NewOwnerIsZeroAddress', + }, + { + inputs: [], + type: 'error', + name: 'NoHandoverRequest', + }, + { + inputs: [], + type: 'error', + name: 'NoZeroAddress', + }, + { + inputs: [], + type: 'error', + name: 'Unauthorized', + }, + { + inputs: [ + { + internalType: 'address', + name: 'pendingOwner', + type: 'address', + indexed: true, + }, + ], + type: 'event', + name: 'OwnershipHandoverCanceled', + anonymous: false, + }, + { + inputs: [ + { + internalType: 'address', + name: 'pendingOwner', + type: 'address', + indexed: true, + }, + ], + type: 'event', + name: 'OwnershipHandoverRequested', + anonymous: false, + }, + { + inputs: [ + { + internalType: 'address', + name: 'oldOwner', + type: 'address', + indexed: true, + }, + { + internalType: 'address', + name: 'newOwner', + type: 'address', + indexed: true, + }, + ], + type: 'event', + name: 'OwnershipTransferred', + anonymous: false, + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'newThreshold', + type: 'uint256', + indexed: false, + }, + ], + type: 'event', + name: 'ThresholdUpdated', + anonymous: false, + }, + { + inputs: [], + stateMutability: 'payable', + type: 'function', + name: 'cancelOwnershipHandover', + }, + { + inputs: [ + { + internalType: 'address', + name: 'pendingOwner', + type: 'address', + }, + ], + stateMutability: 'payable', + type: 'function', + name: 'completeOwnershipHandover', + }, + { + inputs: [ + { + internalType: 'address', + name: 'claimer', + type: 'address', + }, + { + internalType: 'bytes', + name: '', + type: 'bytes', + }, + ], + stateMutability: 'view', + type: 'function', + name: 'isValidDiscountRegistration', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'owner', + outputs: [ + { + internalType: 'address', + name: 'result', + type: 'address', + }, + ], + }, + { + inputs: [ + { + internalType: 'address', + name: 'pendingOwner', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + name: 'ownershipHandoverExpiresAt', + outputs: [ + { + internalType: 'uint256', + name: 'result', + type: 'uint256', + }, + ], + }, + { + inputs: [], + stateMutability: 'payable', + type: 'function', + name: 'renounceOwnership', + }, + { + inputs: [], + stateMutability: 'payable', + type: 'function', + name: 'requestOwnershipHandover', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'threshold_', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + name: 'setThreshold', + }, + { + inputs: [], + stateMutability: 'view', + type: 'function', + name: 'threshold', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + stateMutability: 'payable', + type: 'function', + name: 'transferOwnership', + }, +] as const; diff --git a/apps/web/src/addresses/usernames.ts b/apps/web/src/addresses/usernames.ts index 6755eb0ded5..0d793a2a980 100644 --- a/apps/web/src/addresses/usernames.ts +++ b/apps/web/src/addresses/usernames.ts @@ -63,6 +63,11 @@ export const USERNAME_1155_DISCOUNT_VALIDATORS: AddressMap = { [base.id]: '0x55246A2AE466257B2fB54d4BB881Fb3f17D8e03e', }; +export const TALENT_PROTOCOL_DISCOUNT_VALIDATORS: AddressMap = { + [baseSepolia.id]: '0x0', + [base.id]: '0x0', +}; + export const USERNAME_REVERSE_REGISTRAR_ADDRESSES: AddressMap = { [baseSepolia.id]: '0xa0A8401ECF248a9375a0a71C4dedc263dA18dCd7', [base.id]: '0x79ea96012eea67a83431f1701b3dff7e37f9e282', diff --git a/apps/web/src/components/Basenames/RegistrationLearnMoreModal/images/TalentProtocol.svg b/apps/web/src/components/Basenames/RegistrationLearnMoreModal/images/TalentProtocol.svg new file mode 100644 index 00000000000..5e8674abf66 --- /dev/null +++ b/apps/web/src/components/Basenames/RegistrationLearnMoreModal/images/TalentProtocol.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/apps/web/src/components/Basenames/RegistrationLearnMoreModal/index.tsx b/apps/web/src/components/Basenames/RegistrationLearnMoreModal/index.tsx index b4f3c5eccb0..22eb7ce1aa4 100644 --- a/apps/web/src/components/Basenames/RegistrationLearnMoreModal/index.tsx +++ b/apps/web/src/components/Basenames/RegistrationLearnMoreModal/index.tsx @@ -10,6 +10,7 @@ import summerPassLvl3 from './images/summer-pass-lvl-3.svg'; import cbidVerification from './images/cbid-verification.svg'; import BNSOwnership from './images/bns.jpg'; import BaseNFT from './images/base-nft.svg'; +import TalentProtocolIcon from './images/TalentProtocol.svg'; import coinbaseOneVerification from './images/coinbase-one-verification.svg'; import coinbaseVerification from './images/coinbase-verification.svg'; import { StaticImageData } from 'next/dist/shared/lib/get-img-props'; @@ -72,7 +73,7 @@ export default function RegistrationLearnMoreModal({
)} +
  • + +
    + +

    Builder score 50+

    + +
    +
    + {allActiveDiscounts.has(Discount.BASE_DOT_ETH_NFT) && ( +
    +

    Qualified

    +
    + )} +
  • { + if (!address) { + return {}; + } + return { + address: discountValidatorAddress, + abi: TalentProtocolDiscountValidatorABI, + functionName: 'isValidDiscountRegistration', + args: [address, '0x0'], + }; + }, [address, discountValidatorAddress]); + + const { data: isValid, isLoading, error } = useReadContract({ ...readContractArgs, query: {} }); + console.log(); + if (isValid && address) { + return { + data: { + discountValidatorAddress, + discount: Discount.TALENT_PROTOCOL, + validationData: '0x0' as `0x${string}`, + }, + loading: false, + error: null, + }; + } + return { data: null, loading: isLoading, error }; +} diff --git a/apps/web/src/utils/usernames.ts b/apps/web/src/utils/usernames.ts index 329dbc9b070..6b68fc7c8a5 100644 --- a/apps/web/src/utils/usernames.ts +++ b/apps/web/src/utils/usernames.ts @@ -371,6 +371,7 @@ export enum Discount { SUMMER_PASS_LVL_3 = 'SUMMER_PASS_LVL_3', BNS_NAME = 'BNS_NAME', BASE_DOT_ETH_NFT = 'BASE_DOT_ETH_NFT', + TALENT_PROTOCOL = 'TALENT_PROTOCOL', } export function isValidDiscount(key: string): key is keyof typeof Discount { From 46c5cc947beab08f83854c31edb52685867bc408 Mon Sep 17 00:00:00 2001 From: Jordan Frankfurt Date: Thu, 17 Oct 2024 15:24:01 -0500 Subject: [PATCH 2/2] add base sepolia address --- apps/web/src/addresses/usernames.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/addresses/usernames.ts b/apps/web/src/addresses/usernames.ts index 0d793a2a980..76409992f99 100644 --- a/apps/web/src/addresses/usernames.ts +++ b/apps/web/src/addresses/usernames.ts @@ -64,7 +64,7 @@ export const USERNAME_1155_DISCOUNT_VALIDATORS: AddressMap = { }; export const TALENT_PROTOCOL_DISCOUNT_VALIDATORS: AddressMap = { - [baseSepolia.id]: '0x0', + [baseSepolia.id]: '0x8b769A3fbC29AC02344218840602615B6c9200e7', [base.id]: '0x0', };