Skip to content

Commit

Permalink
v1.3-beta: fixes for getRecordEditor()
Browse files Browse the repository at this point in the history
  • Loading branch information
sshmatrix committed Jan 10, 2024
1 parent f7f56da commit 7ca6248
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1,056 deletions.
12 changes: 6 additions & 6 deletions components/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const Preview: React.FC<ModalProps> = ({
abi: ccip2Config.contractInterface,
functionName: "isApprovedSigner",
args: [
getManager(),
getRecordEditor(),
ethers.utils.namehash(ENS),
keypairSigner && keypairSigner[0]
? ethers.utils.computeAddress(`0x${keypairSigner[0]}`)
Expand All @@ -259,7 +259,7 @@ const Preview: React.FC<ModalProps> = ({
address: `0x${ccip2Config.addressOrName.slice(2)}`,
abi: ccip2Config.contractInterface,
functionName: "getRecordhash",
args: [ethers.utils.hexZeroPad(getManager(), 32).toLowerCase()],
args: [ethers.utils.hexZeroPad(getRecordEditor(), 32).toLowerCase()],
});
// Read Recordhash from CCIP2 Resolver
const { data: _Recordhash_ } = useContractRead({
Expand Down Expand Up @@ -892,7 +892,7 @@ const Preview: React.FC<ModalProps> = ({
}
}

// Returns Owner of Wrapped or Manager of Legacy ENS Domain
// Returns Account allowed to manage/edit NameSys records
function getRecordEditor() {
if (
_OwnerWrapped_ &&
Expand Down Expand Up @@ -1291,7 +1291,7 @@ const Preview: React.FC<ModalProps> = ({
let _Storage = await verifier.quickRecordhash(
_ENS,
ccip2Config,
getManager()
getRecordEditor()
);
let _IPFS: any;
if (_history.ownerstamp.length > 1) {
Expand Down Expand Up @@ -1779,7 +1779,7 @@ const Preview: React.FC<ModalProps> = ({
const request = {
type: "read",
ens: ENS,
controller: getManager(),
controller: getRecordEditor(),
recordsTypes: "all",
recordsValues: "all",
chain: chain,
Expand Down Expand Up @@ -2249,7 +2249,7 @@ const Preview: React.FC<ModalProps> = ({
if (sigSigner && !isSigner) {
// Set query for on-chain manager [v2]
setOnChainManagerQuery([
getManager(),
getRecordEditor(),
ethers.utils.namehash(ENS),
keypairSigner
? ethers.utils.computeAddress(`0x${keypairSigner[0]}`)
Expand Down
31 changes: 6 additions & 25 deletions components/Stealth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const Stealth: React.FC<ModalProps> = ({
abi: ccip2Config.contractInterface,
functionName: "isApprovedSigner",
args: [
getManager(),
getRecordEditor(),
ethers.utils.namehash(ENS),
keypairSigner && keypairSigner[0]
? ethers.utils.computeAddress(`0x${keypairSigner[0]}`)
Expand All @@ -244,7 +244,7 @@ const Stealth: React.FC<ModalProps> = ({
address: `0x${ccip2Config.addressOrName.slice(2)}`,
abi: ccip2Config.contractInterface,
functionName: "getRecordhash",
args: [ethers.utils.hexZeroPad(getManager(), 32).toLowerCase()],
args: [ethers.utils.hexZeroPad(getRecordEditor(), 32).toLowerCase()],
});
// Read Recordhash from CCIP2 Resolver
const { data: _Recordhash_ } = useContractRead({
Expand Down Expand Up @@ -500,26 +500,7 @@ const Stealth: React.FC<ModalProps> = ({
return _extradata;
}

// Returns Owner of Wrapped or Manager of Legacy ENS Domain
function getManager() {
if (_OwnerLegacy_ && _ManagerLegacy_) {
if (String(_OwnerLegacy_) === C.ensContracts[chain === "1" ? 7 : 3]) {
return _OwnerWrapped_ ? String(_OwnerWrapped_) : C.zeroAddress;
} else {
return String(_ManagerLegacy_);
}
} else {
if (
!_OwnerLegacy_ &&
String(_ManagerLegacy_) === C.ensContracts[chain === "1" ? 7 : 3]
) {
return String(_OwnerWrapped_);
}
return C.zeroAddress;
}
}

// Returns Owner of Wrapped or Manager of Legacy ENS Domain
// Returns Account allowed to manage/edit NameSys records
function getRecordEditor() {
if (
_OwnerWrapped_ &&
Expand Down Expand Up @@ -723,7 +704,7 @@ const Stealth: React.FC<ModalProps> = ({
let _Storage = await verifier.quickRecordhash(
_ENS,
ccip2Config,
getManager()
getRecordEditor()
);
let _IPFS: any;
if (_history.ownerstamp.length > 1) {
Expand Down Expand Up @@ -912,7 +893,7 @@ const Stealth: React.FC<ModalProps> = ({
const request = {
type: "read",
ens: ENS,
controller: getManager(),
controller: getRecordEditor(),
recordsTypes: ["stealth", "rsa", "revision", "version"],
recordsValues: "all",
chain: chain,
Expand Down Expand Up @@ -1545,7 +1526,7 @@ const Stealth: React.FC<ModalProps> = ({
if (sigSigner && !isSigner) {
// Set query for on-chain manager [v2]
setOnChainManagerQuery([
getManager(),
getRecordEditor(),
ethers.utils.namehash(ENS),
keypairSigner
? ethers.utils.computeAddress(`0x${keypairSigner[0]}`)
Expand Down
8 changes: 4 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ const Home: NextPage = () => {
const PORT = process.env.NEXT_PUBLIC_PORT;
const SERVER = process.env.NEXT_PUBLIC_SERVER;

// Get Owner with ethers.js
async function getManager(provider: any) {
// Get in-app account allowed to manage/edit NameSys records
async function getRecordEditor(provider: any) {
let _OwnerLegacy: string = "";
let _ManagerLegacy: string = "";
const contractLegacyRegistry = new ethers.Contract(
Expand Down Expand Up @@ -152,7 +152,7 @@ const Home: NextPage = () => {
return _recordhash;
}

// Get Ownerhash with ethers.js
// Get Ownerhash
async function getOwnerhash(provider: any, address: string) {
const contract = new ethers.Contract(
ccip2Config.addressOrName,
Expand Down Expand Up @@ -454,7 +454,7 @@ const Home: NextPage = () => {
React.useEffect(() => {
if (!_Wallet_ && tokenIDLegacy && tokenIDWrapper && query && query !== "") {
const _setOrigins = async () => {
let _Owner = await getManager(C.provider);
let _Owner = await getRecordEditor(C.provider);
let _Recordhash = await getRecordhash(C.provider, query);
let _Ownerhash = await getOwnerhash(C.provider, _Owner);
if (_Owner) {
Expand Down
Loading

0 comments on commit 7ca6248

Please sign in to comment.