Skip to content

Commit

Permalink
Remove MenuItem, uncomment refetch and add modify contactsData
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadai2010 committed Aug 10, 2024
1 parent a13379c commit 41953c7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
29 changes: 0 additions & 29 deletions packages/nextjs/components/MenuItem/MenuItem.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export const useScaffoldReadContract = <
...(readConfig as any),
}) as Omit<ReturnType<typeof useContractRead>, "data" | "refetch"> & {
data: AbiFunctionOutputs<ContractAbi, TFunctionName> | undefined;
// refetch: (options?: {
// throwOnError: boolean;
// cancelRefetch: boolean;
// }) => Promise<AbiFunctionOutputs<ContractAbi, TFunctionName>>;
refetch: (options?: {
throwOnError: boolean;
cancelRefetch: boolean;
}) => Promise<AbiFunctionOutputs<ContractAbi, TFunctionName>>;
};
};
24 changes: 24 additions & 0 deletions packages/nextjs/utils/scaffold-stark/contractsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,27 @@ export function getAllContracts() {
const contractsData = contracts?.[scaffoldConfig.targetNetworks[0].network];
return contractsData ? contractsData : {};
}

function bigIntToHex(bigInt: bigint) {
return bigInt.toString(16);
}

function hexToUtf8(hexStr: string) {
let bytes = [];
for (let i = 0; i < hexStr.length; i += 2) {
bytes.push(parseInt(hexStr.substring(i, i + 2), 16));
}
try {
return new TextDecoder("utf-8").decode(new Uint8Array(bytes));
} catch (e) {
console.error("Failed to decode:", e);
return "";
}
}

export function decodeBigIntArrayToText(byteArray: string[]) {
return byteArray
.map((bigInt) => bigIntToHex(BigInt(bigInt))) // Convert each BigInt to hexadecimal
.map((hex) => hexToUtf8(hex)) // Decode each hexadecimal to text
.join(""); // Join all texts into a single string
}

0 comments on commit 41953c7

Please sign in to comment.