1"use strict";(self.webpackChunkcompose_documentation=self.webpackChunkcompose_documentation||[]).push([["3010"],{20630(e,t,s){s.r(t),s.d(t,{metadata:()=>n,default:()=>y,frontMatter:()=>u,contentTitle:()=>x,toc:()=>g,assets:()=>j});var n=JSON.parse('{"id":"library/diamond/DiamondUpgradeMod","title":"Diamond Upgrade Module","description":"Upgrade diamond by adding, replacing, or removing facets","source":"@site/docs/library/diamond/DiamondUpgradeMod.mdx","sourceDirName":"library/diamond","slug":"/library/diamond/DiamondUpgradeMod","permalink":"/docs/library/diamond/DiamondUpgradeMod","draft":false,"unlisted":false,"editUrl":"https://github.com/Perfect-Abstractions/Compose/tree/main/website/docs/library/diamond/DiamondUpgradeMod.mdx","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{"sidebar_position":4,"title":"Diamond Upgrade Module","description":"Upgrade diamond by adding, replacing, or removing facets","sidebar_label":"Upgrade Module","gitSource":"https://github.com/Perfect-Abstractions/Compose/tree/main/src/diamond/DiamondUpgradeMod.sol"},"sidebar":"mainSidebar","previous":{"title":"Upgrade Facet","permalink":"/docs/library/diamond/DiamondUpgradeFacet"},"next":{"title":"Access Control","permalink":"/docs/library/access/"}}'),a=s(62540),r=s(43023),i=s(93571),d=s(92550),c=s(57458),o=s(72437),l=s(33061);s(18930);var h=s(17942),p=s(374),m=s(66379);let u={sidebar_position:4,title:"Diamond Upgrade Module",description:"Upgrade diamond by adding, replacing, or removing facets",sidebar_label:"Upgrade Module",gitSource:"https://github.com/Perfect-Abstractions/Compose/tree/main/src/diamond/DiamondUpgradeMod.sol"},x,j={},g=[{value:"Storage",id:"storage",level:2},{value:"State Variables",id:"state-variables",level:3},{value:"Diamond Storage",id:"diamond-storage",level:3},{value:"FacetReplacement",id:"facetreplacement",level:3},{value:"Functions",id:"functions",level:2},{value:"getDiamondStorage",id:"getdiamondstorage",level:3},{value:"upgradeDiamond",id:"upgradediamond",level:3},{value:"addFacets",id:"addfacets",level:3},{value:"removeFacets",id:"removefacets",level:3},{value:"replaceFacets",id:"replacefacets",level:3},{value:"importSelectors",id:"importselectors",level:3},{value:"at",id:"at",level:3},{value:"Events",id:"events",level:2},{value:"Errors",id:"errors",level:2},{value:"Best Practices",id:"best-practices",level:2},{value:"Security Considerations",id:"security-considerations",level:2},{value:"Integration Notes",id:"integration-notes",level:2}];function f(e){let t={a:"a",code:"code",h2:"h2",h3:"h3",hr:"hr",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.A,{}),"\n",(0,a.jsx)(i.A,{children:(0,a.jsx)(t.p,{children:"Module providing the internal functions to extend the diamond's upgrade functionality by adding, replacing, or removing facets."})}),"\n",(0,a.jsx)(d.A,{type:"info",title:"Key Features",children:(0,a.jsxs)(t.ul,{children:["\n",(0,a.jsx)(t.li,{children:"Manages facet lifecycle (add, replace, remove) within a diamond."}),"\n",(0,a.jsx)(t.li,{children:"Updates selector routing so subsequent calls dispatch to the new facet."}),"\n"]})}),"\n",(0,a.jsxs)(d.A,{type:"important",title:"Use this module in your project",children:[(0,a.jsx)(t.p,{children:"You can use modules to wrap around you own project logic while using the default Compose building blocks. Modules provides all the necessary internal helpers for maximum integration"}),(0,a.jsxs)(t.p,{children:["Storage follows the diamond slot layout in this file; any code using the same ",(0,a.jsx)(t.code,{children:"STORAGE_POSITION"})," or related positions reads and writes shared state."]}),(0,a.jsxs)(t.p,{children:["See ",(0,a.jsx)("a",{href:"/docs/foundations/facets-and-modules",children:"Facets & Modules"})," for more information."]})]}),"\n",(0,a.jsx)(t.h2,{id:"storage",children:"Storage"}),"\n",(0,a.jsx)(t.h3,{id:"state-variables",children:"State Variables"}),"\n",(0,a.jsx)(o.A,{properties:[{name:"DIAMOND_STORAGE_POSITION",type:"bytes32",description:'Diamond storage slot position for this module (Value: `keccak256("erc8153.diamond")`)'}],showRequired:!1}),"\n",(0,a.jsx)(t.hr,{}),"\n",(0,a.jsx)(t.h3,{id:"diamond-storage",children:"Diamond Storage"}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:15,title:"Definition",children:`/** storage-location: erc8042:erc8153.diamond */ 2struct DiamondStorage { 3 mapping(bytes4 functionSelector => FacetNode) facetNodes; 4 FacetList facetList; 5} 6 7struct FacetList { 8 bytes4 headFacetNodeId; 9 bytes4 tailFacetNodeId; 10 uint32 facetCount; 11 uint32 selectorCount; 12} 13 14struct FacetNode { 15 address facet; 16 bytes4 prevFacetNodeId; 17 bytes4 nextFacetNodeId; 18}`}),"\n",(0,a.jsx)(t.hr,{}),"\n",(0,a.jsx)(t.h3,{id:"facetreplacement",children:"FacetReplacement"}),"\n",(0,a.jsx)(t.p,{children:"This struct is used to replace old facets with new facets."}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:15,title:"Definition",children:`struct FacetReplacement { 19 address oldFacet; 20 address newFacet; 21}`}),"\n",(0,a.jsx)(t.h2,{id:"functions",children:"Functions"}),"\n",(0,a.jsx)(t.h3,{id:"getdiamondstorage",children:"getDiamondStorage"}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:8,children:"function getDiamondStorage() pure returns (DiamondStorage storage s);"}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Returns:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"s",type:"DiamondStorage",description:"The `DiamondStorage` struct in storage."}],showRequired:!1}),"\n",(0,a.jsx)(t.hr,{}),"\n",(0,a.jsx)(t.h3,{id:"upgradediamond",children:"upgradeDiamond"}),"\n",(0,a.jsx)(t.p,{children:"Upgrade the diamond by adding, replacing, and/or removing facets."}),"\n",(0,a.jsx)("b",{children:"Execution order:"}),"\n",(0,a.jsx)(p.A,{currentStep:-1,orientation:"vertical",steps:[{title:"Add Facets",description:"Attach new facet contracts and register their function selectors."},{title:"Replace Facets",description:"Swap existing selectors to point to updated facet implementations."},{title:"Remove Facets",description:"Unregister selectors that are no longer needed in the diamond."}]}),"\n",(0,a.jsxs)(t.p,{children:["Then, if ",(0,a.jsx)(t.code,{children:"_delegate != address(0)"}),", the diamond performs a ",(0,a.jsx)(t.code,{children:"delegatecall"})," with ",(0,a.jsx)(t.code,{children:"_delegateCalldata"})," and emits ",(0,a.jsx)(t.code,{children:"DiamondDelegateCall"}),"."]}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:10,children:`function upgradeDiamond( 22 address[] calldata _addFacets, 23 FacetReplacement[] calldata _replaceFacets, 24 address[] calldata _removeFacets, 25 address _delegate, 26 bytes calldata _delegateCalldata, 27 bytes32 _tag, 28 bytes calldata _metadata 29) external;`}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Parameters:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"_addFacets",type:"address[]",description:"Facet addresses to add"},{name:"_replaceFacets",type:"FacetReplacement[]",description:"`(oldFacet, newFacet)` pairs to replace"},{name:"_removeFacets",type:"address[]",description:"Facet addresses to remove"},{name:"_delegate",type:"address",description:"Optional contract to delegatecall (`address(0)` to skip)"},{name:"_delegateCalldata",type:"bytes",description:"Optional calldata to execute on `_delegate`"},{name:"_tag",type:"bytes32",description:"Optional arbitrary metadata, such as release version"},{name:"_metadata",type:"bytes",description:"Optional arbitrary metadata"}],showRequired:!1}),"\n",(0,a.jsxs)(d.A,{type:"important",title:"Facet Requirement",children:[(0,a.jsxs)(t.p,{children:["Facets must implement ",(0,a.jsx)(t.code,{children:"exportSelectors()"})," in order to make their selectors discoverable by diamonds.\n",(0,a.jsx)("b",{children:"Only the exported selectors will be added to the diamond."})]}),(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-solidity",children:"interface IFacet {\n function exportSelectors() external pure returns (bytes memory);\n}\n"})}),(0,a.jsxs)(t.p,{children:["See ",(0,a.jsxs)(t.a,{href:"https://eips.ethereum.org/EIPS/eip-8153",children:["Facet-Based Diamond ",(0,a.jsx)(t.code,{children:"EIP-8153"})]})," for more details."]})]}),"\n",(0,a.jsx)(t.hr,{}),"\n",(0,a.jsx)(t.h3,{id:"addfacets",children:"addFacets"}),"\n",(0,a.jsx)(t.p,{children:"Adds new facets to a diamond and maps their exported selectors to the facet address."}),"\n",(0,a.jsx)("b",{children:"Behavior:"}),"\n",(0,a.jsx)(p.A,{currentStep:-1,orientation:"vertical",steps:[{title:"Import selectors",description:(0,a.jsxs)(a.Fragment,{children:["Each facet in ",(0,a.jsx)(t.code,{children:"_facets"})," is queried via ",(0,a.jsx)(t.code,{children:"exportSelectors()"}),"."]})},{title:"Validate uniqueness",description:"All exported selectors must be new to the diamond."},{title:"Link facet node",description:"The first selector of each facet becomes the facet linked-list node id."},{title:"Emit event",description:(0,a.jsxs)(a.Fragment,{children:["Emits ",(0,a.jsx)(t.code,{children:"FacetAdded"})," once per successfully added facet."]})}]}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:8,children:"function addFacets(address[] calldata _facets);"}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Parameters:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"_facets",type:"address[]",description:"Facet addresses to add. Each facet must implement `exportSelectors()`."}],showRequired:!1}),"\n",(0,a.jsx)(t.hr,{}),"\n",(0,a.jsx)(t.h3,{id:"removefacets",children:"removeFacets"}),"\n",(0,a.jsx)(t.p,{children:"Removes facets from a diamond and unregisters the selectors they previously exported."}),"\n",(0,a.jsx)("b",{children:"Behavior:"}),"\n",(0,a.jsx)(p.A,{currentStep:-1,orientation:"vertical",steps:[{title:"Validate facet",description:"Checks the first exported selector currently maps to that facet."},{title:"Unlink facet",description:"Removes the facet from the facet linked list."},{title:"Delete selectors",description:"Deletes all selectors exported by the facet."},{title:"Emit event",description:(0,a.jsxs)(a.Fragment,{children:["Emits ",(0,a.jsx)(t.code,{children:"FacetRemoved"})," once per removed facet."]})}]}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:8,children:"function removeFacets(address[] calldata _facets);"}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Parameters:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"_facets",type:"address[]",description:"Facet addresses to remove."}],showRequired:!1}),"\n",(0,a.jsx)(t.hr,{}),"\n",(0,a.jsx)(t.h3,{id:"replacefacets",children:"replaceFacets"}),"\n",(0,a.jsxs)(t.p,{children:["Replaces facets in a diamond using ",(0,a.jsx)(t.code,{children:"(oldFacet, newFacet)"})," pairs."]}),"\n",(0,a.jsx)("b",{children:"Behavior:"}),"\n",(0,a.jsx)(p.A,{currentStep:-1,orientation:"vertical",steps:[{title:"Compare selector sets",description:"Replacement is selector-set based, not just an address swap."},{title:"Update shared selectors",description:(0,a.jsxs)(a.Fragment,{children:["Selectors present in both facets are re-routed to ",(0,a.jsx)(t.code,{children:"newFacet"}),"."]})},{title:"Add new selectors",description:(0,a.jsxs)(a.Fragment,{children:["Selectors present only in ",(0,a.jsx)(t.code,{children:"newFacet"})," are added."]})},{title:"Remove stale selectors",description:(0,a.jsxs)(a.Fragment,{children:["Selectors present only in ",(0,a.jsx)(t.code,{children:"oldFacet"})," are removed."]})},{title:"Emit event",description:(0,a.jsxs)(a.Fragment,{children:["Emits ",(0,a.jsx)(t.code,{children:"FacetReplaced(oldF
29acet, newFacet)"})," for each replacement pair."]})}]}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:8,children:"function replaceFacets(FacetReplacement[] calldata _replaceFacets);"}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Parameters:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"_replaceFacets",type:"FacetReplacement[]",description:"`(oldFacet, newFacet)` pairs to replace old with new."}],showRequired:!1}),"\n",(0,a.jsx)(t.hr,{}),"\n",(0,a.jsx)(t.h3,{id:"importselectors",children:"importSelectors"}),"\n",(0,a.jsxs)(t.p,{children:["Retrieves the function selectors exposed by a facet by calling its ",(0,a.jsx)(t.code,{children:"exportSelectors()"}),". Validates the returned ABI-encoded ",(0,a.jsx)(t.code,{children:"bytes"})," (offset, length, and that the payload length is a multiple of 4) and returns the packed selectors without copying (zero-copy decode)."]}),"\n",(0,a.jsxs)("b",{children:["Used internally by ",(0,a.jsx)(t.a,{href:"#addfacets",children:(0,a.jsx)(t.code,{children:"addFacets"})}),", ",(0,a.jsx)(t.a,{href:"#replacefacets",children:(0,a.jsx)(t.code,{children:"replaceFacets"})})," and ",(0,a.jsx)(t.a,{href:"#removefacets",children:(0,a.jsx)(t.code,{children:"removeFacets"})}),"."]}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:8,children:"function importSelectors(address _facet) view returns (bytes memory selectors);"}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Parameters:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"_facet",type:"address",description:"Contract address implementing `exportSelectors()` that returns ABI-encoded bytes of 4-byte function selectors."}],showRequired:!1}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Returns:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"selectors",type:"bytes",description:"Packed 4-byte function selectors (length is a multiple of 4). Same memory layout as returned by exportSelectors(); may point into the staticcall return buffer."}],showRequired:!1}),"\n",(0,a.jsx)(t.hr,{}),"\n",(0,a.jsx)(t.h3,{id:"at",children:"at"}),"\n",(0,a.jsxs)(t.p,{children:["Returns the 4-byte function selector at the given index in a packed ",(0,a.jsx)(t.code,{children:"bytes"})," array of selectors (e.g. from ",(0,a.jsx)(t.a,{href:"#importselectors",children:(0,a.jsx)(t.code,{children:"importSelectors"})})," or other selector packing)."]}),"\n",(0,a.jsx)(l.A,{language:"solidity",maxLines:8,children:"function at(bytes memory selectors, uint256 index) pure returns (bytes4 selector);"}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Parameters:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"selectors",type:"bytes",description:"Packed array of 4-byte function selectors (length must be a multiple of 4)."},{name:"index",type:"uint256",description:"Zero-based index of the selector to read (0 = first selector, 1 = second, etc.)."}],showRequired:!1}),"\n",(0,a.jsx)(t.p,{children:(0,a.jsx)(t.strong,{children:"Returns:"})}),"\n",(0,a.jsx)(o.A,{properties:[{name:"selector",type:"bytes4",description:"The function selector at the given index."}],showRequired:!1}),"\n",(0,a.jsx)(t.h2,{id:"events",children:"Events"}),"\n",(0,a.jsxs)(c._,{children:[(0,a.jsxs)(c.A,{title:"FacetAdded",defaultOpen:!1,children:[(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)(t.p,{children:"Emitted when a facet is added to a diamond."}),(0,a.jsxs)(t.p,{children:["The function selectors this facet handles can be retrieved by calling ",(0,a.jsx)(t.code,{children:"IFacet(_facet).exportSelectors()"})]})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:"event FacetAdded(address indexed _facet);"})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Parameters:"}),(0,a.jsx)(o.A,{properties:[{name:"_facet",type:"address",description:"The address of the facet that handles function calls to the diamond."}],showRequired:!1})]})]}),(0,a.jsxs)(c.A,{title:"FacetRemoved",defaultOpen:!1,children:[(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)(t.p,{children:"Emitted when a facet is removed from a diamond."}),(0,a.jsxs)(t.p,{children:["The function selectors this facet handles can be retrieved by calling ",(0,a.jsx)(t.code,{children:"IFacet(_facet).exportSelectors()"})]})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:"event FacetRemoved(address indexed _facet);"})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Parameters:"}),(0,a.jsx)(o.A,{properties:[{name:"_facet",type:"address",description:"The address of the facet that previously handled function calls to the diamond."}],showRequired:!1})]})]}),(0,a.jsxs)(c.A,{title:"FacetReplaced",defaultOpen:!1,children:[(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)(t.p,{children:"Emitted when an existing facet is replaced with a new facet."}),(0,a.jsxs)(t.ul,{children:["\n",(0,a.jsx)(t.li,{children:"Selectors that are present in the new facet but not in the old facet are added to the diamond."}),"\n",(0,a.jsx)(t.li,{children:"Selectors that are present in both the new and old facet are updated to use the new facet."}),"\n",(0,a.jsx)(t.li,{children:"Selectors that are not present in the new facet but are present in the old facet are removed from the diamond."}),"\n"]}),(0,a.jsx)(t.p,{children:"The function selectors handled by these facets can be retrieved by calling:"}),(0,a.jsxs)(t.ul,{children:["\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.code,{children:"IFacet(_oldFacet).exportSelectors()"})}),"\n",(0,a.jsx)(t.li,{children:(0,a.jsx)(t.code,{children:"IFacet(_newFacet).exportSelectors()"})}),"\n"]})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:"event FacetReplaced(address indexed _oldFacet, address indexed _newFacet);"})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Parameters:"}),(0,a.jsx)(o.A,{properties:[{name:"_oldFacet",type:"address",description:"The address of the facet that previously handled function calls to the diamond."},{name:"_newFacet",type:"address",description:"The address of the facet that now handles function calls to the diamond."}],showRequired:!1})]})]}),(0,a.jsxs)(c.A,{title:"DiamondDelegateCall",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Emitted when a diamond's constructor function or function from a facet makes a ",(0,a.jsx)(t.code,{children:"delegatecall"}),"."]})}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:"event DiamondDelegateCall(address indexed _delegate, bytes _delegateCalldata);"})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Parameters:"}),(0,a.jsx)(o.A,{properties:[{name:"_delegate",type:"address",description:"The contract that was delegatecalled."},{name:"_delegateCalldata",type:"bytes",description:"The function call, including function selector and any arguments."}],showRequired:!1})]})]}),(0,a.jsxs)(c.A,{title:"DiamondMetadata",defaultOpen:!1,children:[(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)(t.p,{children:"Emitted to record information about a diamond. This event records any arbitrary metadata."}),(0,a.jsxs)(t.p,{children:["The format of ",(0,a.jsx)(t.code,{children:"_tag"})," and ",(0,a.jsx)(t.code,{children:"_data"})," are not specified by the standard."]})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:"event DiamondMetadata(bytes32 indexed _tag, bytes _data);"})]}),(0,a.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,a.jsx)("strong",{children:"Parameters:"}),(0,a.jsx)(o.A,{properties:[{name:"_tag",type:"bytes32",description:"Arbitrary metadata, such as a release version."},{name:"_data",type:"bytes",description:"Arbitrary metadata."}],showRequired:!1})]})]})]}),"\n",(0,a.jsx)(t.h2,{id:"errors",children:"Errors"}),"\n",(0,a.jsxs)(c._,{children:[(0,a.jsxs)(c.A,{title:"CannotAddFunctionToDiamondThatAlreadyExists",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#addfacets",children:(0,a.jsx)("code",{children:"addFacets"})})," when a selector exported by a facet already exists in the diamond."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);"})})]})]}),(0,a.jsxs)(c.A,{title:"CannotRemoveFacetThatDoesNotExist",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#removefacets",children:(0,a.jsx)("code",{children:"removeFacets"})})," when the facet being removed is not currently part of the diamond."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error CannotRemoveFacetThatDoesNotExist(address _facet);"})})]})]}),(0,a.jsxs)(c.A,{title:"CannotReplaceFacetWithSameFacet",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#replacefacets",children:(0,a.jsx)("code",{children:"replaceFacets"})})," when a replacement pair provides the same address for both ",(0,a.jsx)("code",{children:"oldFacet"})," and ",(0,a.jsx)("code",{children:"newFacet"}),"."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error CannotReplaceFacetWithSameFacet(address _facet);"})})]})]}),(0,a.jsxs)(c.A,{title:"CannotReplaceFunctionFromNonReplacementFacet",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#replacefacets",children:(0,a.jsx)("code",{children:"replaceFacets"})})," when a selector in ",(0,a.jsx)("code",{children:"newFacet"})," is already owned by a facet other than the specified ",(0,a.jsx)("code",{children:"oldFacet"}),"."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error CannotReplaceFunctionFromNonReplacementFacet(bytes4 _selector);"})})]})]}),(0,a.jsxs)(c.A,{title:"FacetToReplaceDoesNotExist",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#replacefacets",children:(0,a.jsx)("code",{children:"replaceFacets"})})," when the provided ",(0,a.jsx)("code",{children:"oldFacet"})," does not match the facet currently registered in the diamond."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error FacetToReplaceDoesNotExist(address _oldFacet);"})})]})]}),(0,a.jsxs)(c.A,{title:"DelegateCallReverted",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#upgradediamond",children:(0,a.jsx)("code",{children:"upgradeDiamond"})})," when the optional post-upgrade ",(0,a.jsx)("code",{children:"delegatecall"})," fails without returning revert data."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error DelegateCallReverted(address _delegate, bytes _delegateCalldata);"})})]})]}),(0,a.jsxs)(c.A,{title:"ExportSelectorsCallFailed",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#importselectors",children:(0,a.jsx)("code",{children:"importSelectors"})})," when the staticcall to ",(0,a.jsx)("code",{children:"_facet.exportSelectors()"})," fails."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error ExportSelectorsCallFailed(address _facet);"})})]})]}),(0,a.jsxs)(c.A,{title:"IncorrectSelectorsEncoding",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#importselectors",children:(0,a.jsx)("code",{children:"importSelectors"})}
29)," when the facet returns data that is not valid ABI-encoded ",(0,a.jsx)("code",{children:"bytes"})," (e.g. wrong offset, length not a multiple of 4, or length exceeds payload)."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error IncorrectSelectorsEncoding(address _facet);"})})]})]}),(0,a.jsxs)(c.A,{title:"NoBytecodeAtAddress",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#importselectors",children:(0,a.jsx)("code",{children:"importSelectors"})})," when the facet address has no code (e.g. EOA or uninitialized contract)."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error NoBytecodeAtAddress(address _contractAddress);"})})]})]}),(0,a.jsxs)(c.A,{title:"NoSelectorsForFacet",defaultOpen:!1,children:[(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(t.p,{children:["Thrown by ",(0,a.jsx)(t.a,{href:"#importselectors",children:(0,a.jsx)("code",{children:"importSelectors"})})," when the facet returns fewer than 4 bytes of selectors (i.e. no valid selector)."]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Signature:"}),(0,a.jsx)(l.A,{language:"solidity",maxLines:5,children:(0,a.jsx)(t.p,{children:"error NoSelectorsForFacet(address _facet);"})})]})]})]}),"\n","\n",(0,a.jsx)(t.h2,{id:"best-practices",children:"Best Practices"}),"\n",(0,a.jsxs)(t.ul,{children:["\n",(0,a.jsx)(t.li,{children:"Ensure all diamond upgrade operations are performed by authorized wallet."}),"\n",(0,a.jsx)(t.li,{children:"Always verify facet logic contracts are immutable and trusted before using it inside a diamond."}),"\n",(0,a.jsxs)(t.li,{children:["Ensure each facet\u2019s ",(0,a.jsx)(t.code,{children:"exportSelectors()"})," returns a valid packed selector list in deterministic order."]}),"\n",(0,a.jsxs)(t.li,{children:["Carefully audit any optional post-upgrade ",(0,a.jsx)(t.code,{children:"delegatecall"})," (contract + calldata)."]}),"\n"]}),"\n",(0,a.jsx)(t.h2,{id:"security-considerations",children:"Security Considerations"}),"\n",(0,a.jsxs)(t.p,{children:["This module ",(0,a.jsx)("b",{children:"doesn't provide any access control logic"}),", when using it into your own facet, it is your responsibility to implement proper checks."]}),"\n",(0,a.jsxs)(t.p,{children:["The ",(0,a.jsx)(t.code,{children:"upgradeDiamond"})," function is critical: ",(0,a.jsx)("b",{children:"this function mutates the diamond\u2019s selector routing and facet list. "})]}),"\n",(0,a.jsxs)(t.p,{children:["That being said, ",(0,a.jsx)("b",{children:"make sure to provide verified and trusted contract addresses to avoid any unwanted changes or vulnerabilities"})]}),"\n",(0,a.jsx)(t.h2,{id:"integration-notes",children:"Integration Notes"}),"\n",(0,a.jsxs)(t.p,{children:["This module interacts directly with the diamond's shared storage at the ",(0,a.jsx)(t.code,{children:"DIAMOND_STORAGE_POSITION"}),", which is identified by ",(0,a.jsx)(t.code,{children:'keccak256("erc8153.diamond")'}),". All functions within this module read from and write to this shared storage."]}),"\n",(0,a.jsxs)(t.p,{children:["Changes made through ",(0,a.jsx)(t.code,{children:"upgradeDiamond"}),", ",(0,a.jsx)(t.code,{children:"addFacets"}),", ",(0,a.jsx)(t.code,{children:"replaceFacets"}),", and ",(0,a.jsx)(t.code,{children:"removeFacets"})," are immediately visible to the diamond and all facet that access the shared storage."]}),"\n",(0,a.jsx)(h.A,{date:"2026-03-13T01:49:54.798Z"})]})}function y(e={}){let{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(f,{...e})}):f(e)}},28908(e,t,s){s.d(t,{_:()=>d,u:()=>c});var n=s(62540),a=s(63696),r=s(47738);let i=a.createContext(null);function d({children:e,content:t}){let s=(0,a.useMemo)(()=>({metadata:t.metadata,frontMatter:t.frontMatter,assets:t.assets,contentTitle:t.contentTitle,toc:t.toc}),[t]);return(0,n.jsx)(i.Provider,{value:s,children:e})}function c(){let e=(0,a.useContext)(i);if(null===e)throw new r.dV("DocProvider");return e}},72437(e,t,s){s.d(t,{A:()=>r});var n=s(62540),a=s(63696);function r({properties:e=[],showRequired:t=!0,showTypes:s=!0,title:i}){return(0,n.jsxs)("div",{className:"propertyTable_hQUj",children:[i&&(0,n.jsx)("h3",{className:"tableTitle_TWK1",children:i}),(0,n.jsx)("div",{className:"tableWrapper_yEWV",children:(0,n.jsx)("div",{className:"tableContainer_u2JZ",children:(0,n.jsxs)("table",{className:"table_hICG",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"nameColumn_Gg8z",children:"Property"}),s&&(0,n.jsx)("th",{className:"typeColumn_lItm",children:"Type"}),t&&(0,n.jsx)("th",{className:"requiredColumn_iK7o",children:"Required"}),(0,n.jsx)("th",{className:"descriptionColumn_E7Ps",children:"Description"})]})}),(0,n.jsx)("tbody",{children:e.map((e,r)=>{var i;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"nameCell_hWh2",children:(0,n.jsx)("code",{className:"propertyName_VmHE",children:e.name})}),s&&(0,n.jsx)("td",{className:"typeCell_GEa2",children:(0,n.jsx)("code",{className:"typeValue_rCoV",children:e.type||"any"})}),t&&(0,n.jsx)("td",{className:"requiredCell_PYWJ",children:e.required?(0,n.jsx)("span",{className:"requiredBadge_PsMd",children:"Yes"}):(0,n.jsx)("span",{className:"optionalBadge_raTf",children:"No"})}),(0,n.jsxs)("td",{className:"descriptionCell_Am9o",children:[e.descriptionElement||((i=e.description||e.desc)&&"string"==typeof i?i.split(/(`[^`]+`)/g).map((e,t)=>{if(e.startsWith("`")&&e.endsWith("`")){let s=e.slice(1,-1);return(0,n.jsx)("code",{className:"inlineCode_xnr8",children:s},t)}return(0,n.jsx)(a.Fragment,{children:e},t)}):i)||"-",void 0!==e.default&&(0,n.jsxs)("div",{className:"defaultValue_COU2",children:["Default: ",(0,n.jsx)("code",{children:String(e.default)})]}),e.example&&(0,n.jsxs)("div",{className:"exampleValue_LsuJ",children:["Example: ",(0,n.jsx)("code",{children:String(e.example)})]})]})]},r)})})]})})})]})}},33061(e,t,s){s.d(t,{A:()=>c});var n=s(62540),a=s(63696),r=s(4259),i=s(21737),d=s(11750);function c({language:e="javascript",maxLines:t=10,title:s,children:o}){let[l,h]=(0,a.useState)(!1),[p,m]=(0,a.useState)(!1),u="string"==typeof o?o:o?.props?.children||"",x=(0,a.useMemo)(()=>u.split("\n").length,[u]);return(0,a.useEffect)(()=>{m(x>t)},[x,t]),(0,n.jsxs)("div",{className:"expandableCode_aykX",children:[s&&(0,n.jsx)("div",{className:"codeTitle_wT9c",children:s}),(0,n.jsxs)("div",{className:"codeWrapper_Ax0s",children:[(0,n.jsx)(r.A,{language:e,className:(0,d.A)("codeBlock_pYoZ",!l&&p&&"codeBlockCollapsed_BbBq"),style:{"--max-lines":t},children:u}),p&&(0,n.jsx)("button",{className:(0,d.A)("expandButton_LI8S",l&&"expandButtonExpanded_f3Av"),onClick:()=>h(!l),"aria-label":l?"Collapse code":"Expand code",children:l?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.A,{name:"chevron-up",size:16}),"Show Less"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.A,{name:"chevron-down",size:16}),"Show More (",x-t," more lines)"]})})]})]})}},93571(e,t,s){s.d(t,{A:()=>r});var n=s(62540);s(63696);var a=s(11750);function r({children:e,className:t}){return(0,n.jsx)("p",{className:(0,a.A)("subtitle_jrDb",t),children:e})}},17942(e,t,s){s.d(t,{A:()=>r});var n=s(62540);s(63696);var a=s(21737);function r({date:e,author:t,showAuthor:s=!1}){return e?(0,n.jsxs)("div",{className:"lastUpdated_hhBq",children:[(0,n.jsx)(a.A,{name:"clock-outline",size:16}),(0,n.jsx)("span",{className:"label_ZGd_",children:"Last updated:"}),(0,n.jsx)("time",{className:"date_OqLv",dateTime:new Date(e).toISOString(),children:new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}),s&&t&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"separator_WmF6",children:"\u2022"}),(0,n.jsxs)("span",{className:"author_Xhxh",children:["by ",t]})]})]}):null}},66379(e,t,s){s.d(t,{A:()=>i});var n=s(62540),a=s(63696),r=s(28908);function i(){let e,t,{frontMatter:s}
29=(0,r.u)(),i=s?.gitSource,[d,c]=(0,a.useState)(!1);if(!i)return null;let o=(e="/tree/main/src/",-1===(t=i.indexOf(e))?"":i.slice(t+e.length)),l=async()=>{try{await navigator.clipboard.writeText(`@perfect-abstractions/compose/${o}`),c(!0),setTimeout(()=>c(!1),2e3)}catch{}};return(0,n.jsxs)("div",{className:"packageImport_O1mz",children:[(0,n.jsx)("code",{className:"code_c1Eg",children:`@perfect-abstractions/compose/${o}`}),(0,n.jsx)("button",{className:"copyButton_V60D",onClick:l,"aria-label":"Copy import",title:"Copy import",children:d?"\u2713 Copied":"Copy"})]})}},374(e,t,s){s.d(t,{A:()=>d});var n=s(62540);s(63696);var a=s(11750),r=s(21737);let i={stepIndicator:"stepIndicator_J_kE","stepIndicator--horizontal":"stepIndicator--horizontal_w3qU",stepItem:"stepItem_dq5s",stepConnector:"stepConnector_huT0",stepLine:"stepLine_J9wL",stepLineCompleted:"stepLineCompleted_ef5k",stepContent:"stepContent_prit",stepNumber:"stepNumber_pOAn","stepNumber--completed":"stepNumber--completed_O_n3","stepNumber--active":"stepNumber--active_bBqb","stepNumber--pending":"stepNumber--pending_dMWp",stepText:"stepText_ka7i",stepTitle:"stepTitle_zGyY",stepTitleActive:"stepTitleActive_fQtS",stepDescription:"stepDescription_SbRZ"};function d({steps:e=[],currentStep:t=0,orientation:s="vertical"}){return(0,n.jsx)("div",{className:(0,a.A)(i.stepIndicator,i[`stepIndicator--${s}`]),children:e.map((s,d)=>{let c=s.status||(d<t?"completed":d===t?"active":"pending"),o=d===e.length-1;return(0,n.jsxs)("div",{className:i.stepItem,children:[(0,n.jsx)("div",{className:i.stepConnector,children:!o&&(0,n.jsx)("div",{className:(0,a.A)(i.stepLine,"completed"===c&&i.stepLineCompleted)})}),(0,n.jsxs)("div",{className:i.stepContent,children:[(0,n.jsx)("div",{className:(0,a.A)(i.stepNumber,i[`stepNumber--${c}`]),children:"completed"===c?(0,n.jsx)(r.A,{name:"checkmark-stroke",size:16}):(0,n.jsx)("span",{children:d+1})}),(0,n.jsxs)("div",{className:i.stepText,children:[(0,n.jsx)("div",{className:(0,a.A)(i.stepTitle,"active"===c&&i.stepTitleActive),children:s.title}),s.description&&(0,n.jsx)("div",{className:i.stepDescription,children:s.description})]})]})]},d)})})}},18930(e,t,s){s.d(t,{A:()=>A});var n=s(62540),a=s(63696),r=s(11750),i=s(34471),d=s(21737),c=s(75793);function o(e){(0,c.Tl)("docs_helpful_vote",(0,c.b6)({helpful:e.helpful,page_id:e.pageId,permalink:e.permalink,title:e.title,variant:e.variant??"card"}))}function l(e){(0,c.Tl)("docs_helpful_submit",(0,c.b6)({helpful:e.helpful,comment:e.comment,comment_length:e.comment.length,page_id:e.pageId,permalink:e.permalink,title:e.title,variant:e.variant??"card"}))}let h="thumbIcon_Yprl",p="thumbIconOnPrimary_xbYk",m="asideRoot_ClLe",u="asideRootWithEndSlot_Nswl",x="asideEndSlot_BHCU",j="asideBtn_WCqR",g="feedbackSubmittedAside_szkH",f="feedbackButton_kDWn",y="feedbackButtonActive_WjaZ",v="feedbackSubmitNo_R4YG",b="feedbackSubmitted_gXG3";function _({size:e=20,className:t}){return(0,n.jsx)("svg",{className:t,width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,children:(0,n.jsx)("path",{d:"M16.667 5L7.5 14.167 3.333 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function A({pageId:e,permalink:t,title:s,onSubmit:c,variant:w="card",asideEndSlot:F}){let{colorMode:N}=(0,i.G)(),[S,C]=(0,a.useState)(null),[T,k]=(0,a.useState)(""),[B,R]=(0,a.useState)(!1),D="dark"===N?"thumbs-up-dark":"thumbs-up",I="dark"===N?"thumbs-down-dark":"thumbs-down",E={pageId:e,permalink:t,title:s,variant:w},L=e=>{C(e),o({helpful:e,...E})};if(B){let e=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(_,{size:"aside"===w?18:20,className:"feedbackSubmittedCheck_YRcX"}),(0,n.jsx)("span",{children:"Thank you for your feedback!"})]});return"aside"===w&&F?(0,n.jsxs)("div",{className:(0,r.A)(m,u,"asideRootSubmittedAside_uykU"),children:[(0,n.jsx)("div",{className:(0,r.A)(b,g,"asideSubmittedMain_mJRN"),children:e}),(0,n.jsx)("div",{className:x,children:F})]}):(0,n.jsx)("div",{className:(0,r.A)(b,"aside"===w&&g),children:e})}if("aside"===w){let t=(0,n.jsxs)("div",{className:"asideButtons__hm1",children:[(0,n.jsxs)("button",{type:"button",className:j,onClick:()=>{l({helpful:"yes",comment:"",...E}),c&&c({pageId:e,feedback:"yes",comment:""}),R(!0)},"aria-label":"Yes, this was helpful",children:[(0,n.jsx)(d.A,{name:D,size:18,className:h}),"Yes"]}),(0,n.jsxs)("button",{type:"button",className:j,onClick:()=>{C("no"),o({helpful:"no",...E})},"aria-label":"No, this was not helpful",children:[(0,n.jsx)(d.A,{name:I,size:18,className:h}),"No"]})]});return(0,n.jsxs)("div",{className:(0,r.A)(m,F&&u,"no"===S&&"asideRootWithFollowup_ILrp"),children:[(0,n.jsx)("p",{className:"asideLabel_yKdX",children:"Was this helpful?"}),t,"no"===S&&(0,n.jsxs)("div",{className:"asideFollowup_vj8b",children:[(0,n.jsx)("textarea",{className:"asideTextarea_iziv",placeholder:"Tell us more (optional)...",value:T,onChange:e=>k(e.target.value),rows:2}),(0,n.jsx)("button",{type:"button",className:(0,r.A)("asideSubmit_xnWi",v),onClick:()=>{l({helpful:"no",comment:T.trim(),...E}),c&&c({pageId:e,feedback:"no",comment:T.trim()}),R(!0)},children:"Submit"})]}),F?(0,n.jsx)("div",{className:x,children:F}):null]})}return(0,n.jsxs)("div",{className:"wasThisHelpful_LFGY",children:[(0,n.jsxs)("div",{className:"feedbackPrompt_hLbD",children:[(0,n.jsx)("span",{className:"promptText_fpxS",children:"Was this helpful?"}),(0,n.jsxs)("div",{className:"feedbackButtons_VwXX",children:[(0,n.jsxs)("button",{type:"button",className:(0,r.A)(f,"yes"===S&&y),onClick:()=>L("yes"),"aria-label":"Yes, this was helpful",children:[(0,n.jsx)(d.A,{name:D,size:20,className:(0,r.A)(h,"yes"===S&&p)}),"Yes"]}),(0,n.jsxs)("button",{type:"button",className:(0,r.A)(f,"no"===S&&y),onClick:()=>L("no"),"aria-label":"No, this was not helpful",children:[(0,n.jsx)(d.A,{name:I,size:20,className:(0,r.A)(h,"no"===S&&p)}),"No"]})]})]}),S&&(0,n.jsxs)("div",{className:"feedbackForm_ERHR",children:[(0,n.jsx)("textarea",{className:"commentInput_zGC4",placeholder:"Tell us more (optional)...",value:T,onChange:e=>k(e.target.value),rows:3}),(0,n.jsx)("button",{type:"button",className:(0,r.A)("submitButton_Mcou","no"===S&&v),onClick:()=>{c&&c({pageId:e,feedback:S,comment:T}),S&&l({helpful:S,comment:T.trim(),...E}),R(!0)},children:"Submit Feedback"})]})]})}},57458(e,t,s){s.d(t,{A:()=>c,_:()=>
29o});var n=s(62540),a=s(63696),r=s(11750),i=s(21737);let d={accordion:"accordion_RgZt",accordionHeader:"accordionHeader_lElb",accordionHeaderOpen:"accordionHeaderOpen_ZAvw",accordionTitle:"accordionTitle_KZkk",accordionIcon:"accordionIcon_uuae",accordionIconOpen:"accordionIconOpen_bPA8",accordionContent:"accordionContent_znSG",accordionContentOpen:"accordionContentOpen_wx9i",accordionBody:"accordionBody_PoDw","accordion--bordered":"accordion--bordered_Eqiz",accordionGroup:"accordionGroup_GEK0"};function c({title:e,defaultOpen:t=!1,children:s,variant:o="default"}){let[l,h]=(0,a.useState)(t);return(0,n.jsxs)("div",{className:(0,r.A)(d.accordion,d[`accordion--${o}`]),children:[(0,n.jsxs)("button",{className:(0,r.A)(d.accordionHeader,l&&d.accordionHeaderOpen),onClick:()=>{h(!l)},"aria-expanded":l,"aria-controls":`accordion-content-${e?.replace(/\s+/g,"-").toLowerCase()}`,children:[(0,n.jsx)("span",{className:d.accordionTitle,children:e}),(0,n.jsx)(i.A,{name:"accordion-chevron",size:20,className:(0,r.A)(d.accordionIcon,l&&d.accordionIconOpen)})]}),(0,n.jsx)("div",{id:`accordion-content-${e?.replace(/\s+/g,"-").toLowerCase()}`,className:(0,r.A)(d.accordionContent,l&&d.accordionContentOpen),"aria-hidden":!l,children:(0,n.jsx)("div",{className:d.accordionBody,children:s})})]})}function o({children:e,className:t}){return(0,n.jsx)("div",{className:(0,r.A)(d.accordionGroup,t),children:e})}},92550(e,t,s){s.d(t,{A:()=>d});var n=s(62540);s(63696);var a=s(11750),r=s(21737);let i={callout:"callout_aeEX",calloutHeader:"calloutHeader_fXny",calloutIcon:"calloutIcon_vX9X",calloutTitle:"calloutTitle_kaV8",calloutContent:"calloutContent_Hl52","callout--info":"callout--info_TgTd","callout--warning":"callout--warning_ioY5","callout--danger":"callout--danger_OAha","callout--success":"callout--success_rrx_","callout--tip":"callout--tip_iqbU","callout--note":"callout--note_gJ54"};function d({type:e="info",title:t,children:s,icon:c=!0}){let o={info:"lightbulb",warning:"warning",danger:"no-entry",success:"checkmark",tip:"lightbulb",note:"memo"};return(0,n.jsxs)("div",{className:(0,a.A)(i.callout,i[`callout--${e}`]),children:[(0,n.jsxs)("div",{className:i.calloutHeader,children:[c&&(0,n.jsx)("span",{className:i.calloutIcon,children:(0,n.jsx)(r.A,{name:o[e]||o.info,size:24})}),t&&(0,n.jsx)("span",{className:i.calloutTitle,children:t})]}),(0,n.jsx)("div",{className:i.calloutContent,children:s})]})}},43562(e,t,s){s.d(t,{A:()=>m});var n=s(62540),a=s(63696),r=s(11750),i=s(69981),d=s(4209),c=s(96609),o=s(54767),l=s(52977),h=s(75793);let p={copyButtonCopied:"copyButtonCopied_KAEU",copyButtonIcons:"copyButtonIcons_CCmD",copyButtonIcon:"copyButtonIcon_cWY_",copyButtonSuccessIcon:"copyButtonSuccessIcon_YaqN"};function m({className:e}){let{copyCode:t,isCopied:s}=function(){let{metadata:{code:e}}=(0,d.Ph)(),[t,s]=(0,a.useState)(!1),n=(0,a.useRef)(void 0),r=(0,a.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{let t,a="npx @perfect-abstractions/compose-cli init"===(t="string"!=typeof e?"":e.trim().replace(/\r\n/g,"\n"))?"compose_cli_npx":t.startsWith("forge install Perfect-Abstractions/Compose@")?"foundry_forge":"npm install @perfect-abstractions/compose"===t?"hardhat_npm":null;a&&(0,h.Tl)("docs_install_command_copy",(0,h.b6)({install_command_kind:a})),s(!0),n.current=window.setTimeout(()=>{s(!1)},1e3)})},[e]);return(0,a.useEffect)(()=>()=>window.clearTimeout(n.current),[]),{copyCode:r,isCopied:t}}();return(0,n.jsx)(c.A,{"aria-label":s?(0,i.T)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,i.T)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for the copy code blocks button"}),title:(0,i.T)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,r.A)(e,p.copyButton,s&&p.copyButtonCopied),onClick:t,children:(0,n.jsxs)("span",{className:p.copyButtonIcons,"aria-hidden":"true",children:[(0,n.jsx)(o.A,{className:p.copyButtonIcon}),(0,n.jsx)(l.A,{className:p.copyButtonSuccessIcon})]})})}},75793(e,t,s){function n(e,t={}){let s=function(){if("u"<typeof window)return null;let e=window.posthog;return e&&"function"==typeof e.capture?e:null}();s&&s.capture(e,t)}function a(e={}){let t="u">typeof window?window.location?.pathname:void 0,s="u">typeof document?document.title:void 0;return{...e,permalink:e.permalink??t,title:e.title??s}}s.d(t,{Tl:()=>n,b6:()=>a})}
29,43023(e,t,s){s.d(t,{R:()=>i,x:()=>d});var n=s(63696);let a={},r=n.createContext(a);function i(e){let t=n.useContext(r);return n.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),n.createElement(r.Provider,{value:t},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.