Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add external flag to external contracts #647

Merged
merged 10 commits into from Dec 27, 2023

Conversation

sverps
Copy link
Collaborator

@sverps sverps commented Dec 6, 2023

Fixes #636

During the contracts deepMerge we can add { external: true } to contracts that are declared in the externalContracts.ts file.

This can be used to make UI modifications based on this flag (UI part is WIP)

@technophile-04
Copy link
Collaborator

Tysm @sverps, I think the approach makes sense I also tried dry running through merge logic, and looks good to me !


Regarding displaying on UI what if we do this :
Screenshot 2023-12-16 at 1 37 26 PM

Just add (external) beside the contract name

@technophile-04 technophile-04 marked this pull request as ready for review December 22, 2023 09:58
@technophile-04
Copy link
Collaborator

technophile-04 commented Dec 22, 2023

Just updated it to show an Icon beside contractNames tab so that its easily distinguishable (lol not sure if the icon makes sense) but here it is :
Screenshot 2023-12-22 at 3 28 27 PM

To test :

1. copy this in `externalContractsData` :
import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";

const externalContracts = {
  11155111: {
    MyContract: {
      address: "0xd7036EDDDA3743Aa577DC24ca817f3F85099bDbD",
      abi: [
        {
          inputs: [
            {
              internalType: "address",
              name: "_owner",
              type: "address",
            },
          ],
          stateMutability: "nonpayable",
          type: "constructor",
        },
        {
          anonymous: false,
          inputs: [
            {
              indexed: true,
              internalType: "address",
              name: "previousOwner",
              type: "address",
            },
            {
              indexed: true,
              internalType: "address",
              name: "newOwner",
              type: "address",
            },
          ],
          name: "OwnershipTransferred",
          type: "event",
        },
        {
          inputs: [],
          name: "increaseCounter",
          outputs: [],
          stateMutability: "payable",
          type: "function",
        },
        {
          inputs: [],
          name: "owner",
          outputs: [
            {
              internalType: "address",
              name: "",
              type: "address",
            },
          ],
          stateMutability: "view",
          type: "function",
        },
        {
          inputs: [],
          name: "renounceOwnership",
          outputs: [],
          stateMutability: "nonpayable",
          type: "function",
        },
        {
          inputs: [],
          name: "totalCounter",
          outputs: [
            {
              internalType: "uint256",
              name: "",
              type: "uint256",
            },
          ],
          stateMutability: "view",
          type: "function",
        },
        {
          inputs: [
            {
              internalType: "address",
              name: "newOwner",
              type: "address",
            },
          ],
          name: "transferOwnership",
          outputs: [],
          stateMutability: "nonpayable",
          type: "function",
        },
        {
          inputs: [
            {
              internalType: "address",
              name: "",
              type: "address",
            },
          ],
          name: "userGreetingCounter",
          outputs: [
            {
              internalType: "uint256",
              name: "",
              type: "uint256",
            },
          ],
          stateMutability: "view",
          type: "function",
        },
        {
          inputs: [],
          name: "withdraw",
          outputs: [],
          stateMutability: "nonpayable",
          type: "function",
        },
        {
          stateMutability: "payable",
          type: "receive",
        },
      ],
      inheritedFunctions: {
        owner: "@openzeppelin/contracts/access/Ownable.sol",
        renounceOwnership: "@openzeppelin/contracts/access/Ownable.sol",
        transferOwnership: "@openzeppelin/contracts/access/Ownable.sol",
      },
    },
  },
} as const;

export default externalContracts satisfies GenericContractsDeclaration;
2. Copy this in `deployedContracts.ts` :
/**
 * This file is autogenerated by Scaffold-ETH.
 * You should not edit it manually or your changes might be overwritten.
 */
import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";

const deployedContracts = {
  11155111: {
    YourContract: {
      address: "0x56742C343AF8f8EA0DDd3A59b6b4B087229c6563",
      abi: [
        {
          inputs: [
            {
              internalType: "address",
              name: "_owner",
              type: "address",
            },
          ],
          stateMutability: "nonpayable",
          type: "constructor",
        },
        {
          anonymous: false,
          inputs: [
            {
              indexed: true,
              internalType: "address",
              name: "greetingSetter",
              type: "address",
            },
            {
              indexed: false,
              internalType: "string",
              name: "newGreeting",
              type: "string",
            },
            {
              indexed: false,
              internalType: "bool",
              name: "premium",
              type: "bool",
            },
            {
              indexed: false,
              internalType: "uint256",
              name: "value",
              type: "uint256",
            },
          ],
          name: "GreetingChange",
          type: "event",
        },
        {
          inputs: [],
          name: "greeting",
          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: "premium",
          outputs: [
            {
              internalType: "bool",
              name: "",
              type: "bool",
            },
          ],
          stateMutability: "view",
          type: "function",
        },
        {
          inputs: [
            {
              internalType: "string",
              name: "_newGreeting",
              type: "string",
            },
          ],
          name: "setGreeting",
          outputs: [],
          stateMutability: "payable",
          type: "function",
        },
        {
          inputs: [],
          name: "totalCounter",
          outputs: [
            {
              internalType: "uint256",
              name: "",
              type: "uint256",
            },
          ],
          stateMutability: "view",
          type: "function",
        },
        {
          inputs: [
            {
              internalType: "address",
              name: "",
              type: "address",
            },
          ],
          name: "userGreetingCounter",
          outputs: [
            {
              internalType: "uint256",
              name: "",
              type: "uint256",
            },
          ],
          stateMutability: "view",
          type: "function",
        },
        {
          inputs: [],
          name: "withdraw",
          outputs: [],
          stateMutability: "nonpayable",
          type: "function",
        },
        {
          stateMutability: "payable",
          type: "receive",
        },
      ],
      inheritedFunctions: {},
    },
  },
} as const;

export default deployedContracts satisfies GenericContractsDeclaration;
  1. Update targetNetworks with [chains.sepolia]

@rin-st
Copy link
Collaborator

rin-st commented Dec 22, 2023

Just updated it to show an Icon beside contractNames tab so that its easily distinguishable (lol not sure if the icon makes sense)

Thinking about exclamation icons
image
These icons are a bit aggressive, but at least familiar and they force user to hover what it is.

But your option is looking nice too 🙂

Copy link
Collaborator

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BarsArrowUpIcon ExclamationCircle
292459920-003fb458-80ea-439e-ae70-8631cbdb162a Screenshot 2023-12-27 at 12 46 45 PM

Yeah the ExclamationCircle looks a bit too aggressive / kind of give the warning sense not to interact with that contract 😅, especially in light mode. BarsArrowUpIcon seems more subtle and decent.

Keeping it BarsArrowUpIcon for now but we can always change it later if ExclamationCircle make more sense or we find something better 🙌

Merging this tysm all 🙌 !!

@technophile-04 technophile-04 merged commit 2dfe898 into main Dec 27, 2023
1 check passed
@technophile-04 technophile-04 deleted the feature/636-external-contract-flag branch December 27, 2023 07:44
@github-actions github-actions bot mentioned this pull request Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show «external» indicator on Contracts
3 participants