{
  "contractName": "DiamondCutFacet",
  "abi": [
    {
      "anonymous": false,
      "inputs": [
        {
          "components": [
            {
              "internalType": "address",
              "name": "facetAddress",
              "type": "address"
            },
            {
              "internalType": "bytes4[]",
              "name": "functionSelectors",
              "type": "bytes4[]"
            }
          ],
          "indexed": false,
          "internalType": "struct IDiamondCut.Facet[]",
          "name": "_diamondCut",
          "type": "tuple[]"
        },
        {
          "indexed": false,
          "internalType": "address",
          "name": "_init",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "bytes",
          "name": "_calldata",
          "type": "bytes"
        }
      ],
      "name": "DiamondCut",
      "type": "event"
    },
    {
      "inputs": [
        {
          "components": [
            {
              "internalType": "address",
              "name": "facetAddress",
              "type": "address"
            },
            {
              "internalType": "bytes4[]",
              "name": "functionSelectors",
              "type": "bytes4[]"
            }
          ],
          "internalType": "struct IDiamondCut.Facet[]",
          "name": "_diamondCut",
          "type": "tuple[]"
        },
        {
          "internalType": "address",
          "name": "_init",
          "type": "address"
        },
        {
          "internalType": "bytes",
          "name": "_calldata",
          "type": "bytes"
        }
      ],
      "name": "diamondCut",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ],
  "bytecode": "0x608060405234801561001057600080fd5b50610f3c806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e712b4e114610030575b600080fd5b61004361003e366004610a05565b610045565b005b61004f85856101c2565b7f39725dd03d877043d78fdfe186295e46e6277eb0a3498f2adb51071f42a2bdcb8585858585604051610086959493929190610b83565b60405180910390a16001600160a01b0383166100c85780156100c35760405162461bcd60e51b81526004016100ba90610cea565b60405180910390fd5b6101bb565b806100e55760405162461bcd60e51b81526004016100ba90610d47565b6001600160a01b038316301461011757610117836040518060600160405280602a8152602001610eb7602a91396104b6565b60006060846001600160a01b03168484604051610135929190610b73565b600060405180830381855af49150503d8060008114610170576040519150601f19603f3d011682016040523d82523d6000602084013e610175565b606091505b5091509150816101b8578051156101a0578060405162461bcd60e51b81526004016100ba9190610c60565b60405162461bcd60e51b81526004016100ba90610da4565b50505b5050505050565b60006101cc6104d7565b80549091506001600160a01b031633146101f85760405162461bcd60e51b81526004016100ba90610cb3565b60005b828110156104b057600084848381811061021157fe5b90506020028101906102239190610e4f565b6102319060208101906109e3565b90506001600160a01b03811615610412576001600160a01b038116600090815260028401602052604090206001015461ffff168015801561028a57506001600160a01b0382166000908152600285016020526040902054155b15610314576102b182604051806060016040528060268152602001610ee1602691396104b6565b5060038301805460018082018355600092835260208084208301805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03871690811790915584526002870190526040909220909101805461ffff191661ffff83161790555b60005b86868581811061032357fe5b90506020028101906103359190610e4f565b610343906020810190610e01565b905081101561040b57600087878681811061035a57fe5b905060200281019061036c9190610e4f565b61037a906020810190610e01565b8381811061038457fe5b90506020020160208101906103999190610ad8565b6001600160e01b0319811660009081526001880160205260409020549091506001600160a01b0316806103d5576103d085836104fb565b610401565b846001600160a01b0316816001600160a01b031614610401576103f7826105db565b61040185836104fb565b5050600101610317565b50506104a7565b60005b85858481811061042157fe5b90506020028101906104339190610e4f565b610441906020810190610e01565b90508110156104a55761049d86868581811061045957fe5b905060200281019061046b9190610e4f565b610479906020810190610e01565b8381811061048357fe5b90506020020160208101906104989190610ad8565b6105db565b600101610415565b505b506001016101fb565b50505050565b813b81816104b05760405162461bcd60e51b81526004016100ba9190610c60565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c90565b60006105056104d7565b6001600160a01b03909316600081815260028501602090815260408083208054600180820183559185528385206008820401805460e08a901c600460078516026101000a90810263ffffffff909102199091161790556001600160e01b03199097168452909601905293909320805461ffff90931674010000000000000000000000000000000000000000027fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff73ffffffffffffffffffffffffffffffffffffffff199094169094179290921692909217905550565b60006105e56104d7565b6001600160e01b0319831660009081526001820160205260409020549091506001600160a01b031680610619575050610972565b6001600160e01b0319831660009081526001830160209081526040808320546001600160a01b038516845260028601909252822080547401000000000000000000000000000000000000000090920461ffff16926000198301929091908390811061068057fe5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146107a6576001600160a01b0384166000908152600286016020526040902080548291908590811061071357fe5b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c929092029390931790556001600160e01b031983168152600187019091526040902080547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8616021790555b6001600160a01b038416600090815260028601602052604090208054806107c957fe5b60008281526020808220600860001990940193840401805463ffffffff600460078716026101000a0219169055919092556001600160e01b0319881682526001870190526040902080547fffffffffffffffffffff000000000000000000000000000000000000000000001690558161096c576003850180546000198101916000918390811061085557fe5b60009182526020808320909101546001600160a01b0389811680855260028c019093526040909320600101549216925061ffff9091169082146108fa57818860030182815481106108a257fe5b6000918252602080832091909101805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03948516179055918416815260028a0190915260409020600101805461ffff191661ffff83161790555b8760030180548061090757fe5b600082815260208082208301600019908101805473ffffffffffffffffffffffffffffffffffffffff191690559092019092556001600160a01b038916825260028a019052604081209061095b8282610975565b50600101805461ffff191690555050505b50505050505b50565b50805460008255600701600890049060005260206000209081019061097291905b808211156109aa5760008155600101610996565b5090565b80356001600160a01b03811681146109c557600080fd5b92915050565b80356001600160e01b0319811681146109c557600080fd5b6000602082840312156109f4578081fd5b6109fe83836109ae565b9392505050565b600080600080600060608688031215610a1c578081fd5b853567ffffffffffffffff80821115610a33578283fd5b818801915088601f830112610a46578283fd5b813581811115610a54578384fd5b60208a818284028601011115610a68578485fd5b8084019850819750610a7c8b828c016109ae565b965060408a0135935082841115610a91578485fd5b838a0193508a601f850112610aa4578485fd5b8335915082821115610ab4578485fd5b8a81838601011115610ac4578485fd5b979a96995094975050909401935090919050565b600060208284031215610ae9578081fd5b6109fe83836109cb565b6001600160a01b03169052565b60008284526020808501945082825b85811015610b3e578282016001600160e01b0319610b2d82856109cb565b168852968301969150600101610b0f565b509495945050505050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b6000828483379101908152919050565b606080825281018590526000602060808084019082890285010189845b8a811015610c31577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808784030184528135603e198d3603018112610be2578687fd5b8c016040868201610bfc86610bf783866109ae565b610af3565b610c068184610e6e565b935090508188870152610c1c8287018483610b00565b96880196955050509185019150600101610ba0565b5050610c3f83860189610af3565b8481036040860152610c52818789610b49565b9a9950505050505050505050565b6000602080835283518082850152825b81811015610c8c57858101830151858201604001528201610c70565b81811115610c9d5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526016908201527f4d757374206f776e2074686520636f6e74726163742e00000000000000000000604082015260600190565b6020808252603e908201527f4469616d6f6e6443757446616365743a205f696e69742069732061646472657360408201527f73283029206275745f63616c6c64617461206973206e6f7420656d7074790000606082015260800190565b6020808252603f908201527f4469616d6f6e6443757446616365743a205f63616c6c6461746120697320656d60408201527f70747920627574205f696e6974206973206e6f74206164647265737328302900606082015260800190565b60208082526028908201527f4469616d6f6e6443757446616365743a205f696e69742066756e6374696f6e2060408201527f7265766572746564000000000000000000000000000000000000000000000000606082015260800190565b6000808335601e19843603018112610e17578283fd5b83018035915067ffffffffffffffff821115610e31578283fd5b6020908101925081023603821315610e4857600080fd5b9250929050565b60008235603e19833603018112610e64578182fd5b9190910192915050565b6000808335601e19843603018112610e84578283fd5b830160208101925035905067ffffffffffffffff811115610ea457600080fd5b602081023603831315610e4857600080fdfe4469616d6f6e6443757446616365743a205f696e6974206164647265737320686173206e6f20636f64654469616d6f6e6443757446616365743a204e657720666163657420686173206e6f20636f6465a2646970667358221220d549925be7f162ad8bee0e5faaf2f9a9e548ed65080d804fbd4dcdb3aa77977264736f6c63430007010033",
  "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e712b4e114610030575b600080fd5b61004361003e366004610a05565b610045565b005b61004f85856101c2565b7f39725dd03d877043d78fdfe186295e46e6277eb0a3498f2adb51071f42a2bdcb8585858585604051610086959493929190610b83565b60405180910390a16001600160a01b0383166100c85780156100c35760405162461bcd60e51b81526004016100ba90610cea565b60405180910390fd5b6101bb565b806100e55760405162461bcd60e51b81526004016100ba90610d47565b6001600160a01b038316301461011757610117836040518060600160405280602a8152602001610eb7602a91396104b6565b60006060846001600160a01b03168484604051610135929190610b73565b600060405180830381855af49150503d8060008114610170576040519150601f19603f3d011682016040523d82523d6000602084013e610175565b606091505b5091509150816101b8578051156101a0578060405162461bcd60e51b81526004016100ba9190610c60565b60405162461bcd60e51b81526004016100ba90610da4565b50505b5050505050565b60006101cc6104d7565b80549091506001600160a01b031633146101f85760405162461bcd60e51b81526004016100ba90610cb3565b60005b828110156104b057600084848381811061021157fe5b90506020028101906102239190610e4f565b6102319060208101906109e3565b90506001600160a01b03811615610412576001600160a01b038116600090815260028401602052604090206001015461ffff168015801561028a57506001600160a01b0382166000908152600285016020526040902054155b15610314576102b182604051806060016040528060268152602001610ee1602691396104b6565b5060038301805460018082018355600092835260208084208301805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03871690811790915584526002870190526040909220909101805461ffff191661ffff83161790555b60005b86868581811061032357fe5b90506020028101906103359190610e4f565b610343906020810190610e01565b905081101561040b57600087878681811061035a57fe5b905060200281019061036c9190610e4f565b61037a906020810190610e01565b8381811061038457fe5b90506020020160208101906103999190610ad8565b6001600160e01b0319811660009081526001880160205260409020549091506001600160a01b0316806103d5576103d085836104fb565b610401565b846001600160a01b0316816001600160a01b031614610401576103f7826105db565b61040185836104fb565b5050600101610317565b50506104a7565b60005b85858481811061042157fe5b90506020028101906104339190610e4f565b610441906020810190610e01565b90508110156104a55761049d86868581811061045957fe5b905060200281019061046b9190610e4f565b610479906020810190610e01565b8381811061048357fe5b90506020020160208101906104989190610ad8565b6105db565b600101610415565b505b506001016101fb565b50505050565b813b81816104b05760405162461bcd60e51b81526004016100ba9190610c60565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c90565b60006105056104d7565b6001600160a01b03909316600081815260028501602090815260408083208054600180820183559185528385206008820401805460e08a901c600460078516026101000a90810263ffffffff909102199091161790556001600160e01b03199097168452909601905293909320805461ffff90931674010000000000000000000000000000000000000000027fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff73ffffffffffffffffffffffffffffffffffffffff199094169094179290921692909217905550565b60006105e56104d7565b6001600160e01b0319831660009081526001820160205260409020549091506001600160a01b031680610619575050610972565b6001600160e01b0319831660009081526001830160209081526040808320546001600160a01b038516845260028601909252822080547401000000000000000000000000000000000000000090920461ffff16926000198301929091908390811061068057fe5b90600052602060002090600891828204019190066004029054906101000a900460e01b9050857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146107a6576001600160a01b0384166000908152600286016020526040902080548291908590811061071357fe5b600091825260208083206008830401805463ffffffff60079094166004026101000a938402191660e09590951c929092029390931790556001600160e01b031983168152600187019091526040902080547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8616021790555b6001600160a01b038416600090815260028601602052604090208054806107c957fe5b60008281526020808220600860001990940193840401805463ffffffff600460078716026101000a0219169055919092556001600160e01b0319881682526001870190526040902080547fffffffffffffffffffff000000000000000000000000000000000000000000001690558161096c576003850180546000198101916000918390811061085557fe5b60009182526020808320909101546001600160a01b0389811680855260028c019093526040909320600101549216925061ffff9091169082146108fa57818860030182815481106108a257fe5b6000918252602080832091909101805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03948516179055918416815260028a0190915260409020600101805461ffff191661ffff83161790555b8760030180548061090757fe5b600082815260208082208301600019908101805473ffffffffffffffffffffffffffffffffffffffff191690559092019092556001600160a01b038916825260028a019052604081209061095b8282610975565b50600101805461ffff191690555050505b50505050505b50565b50805460008255600701600890049060005260206000209081019061097291905b808211156109aa5760008155600101610996565b5090565b80356001600160a01b03811681146109c557600080fd5b92915050565b80356001600160e01b0319811681146109c557600080fd5b6000602082840312156109f4578081fd5b6109fe83836109ae565b9392505050565b600080600080600060608688031215610a1c578081fd5b853567ffffffffffffffff80821115610a33578283fd5b818801915088601f830112610a46578283fd5b813581811115610a54578384fd5b60208a818284028601011115610a68578485fd5b8084019850819750610a7c8b828c016109ae565b965060408a0135935082841115610a91578485fd5b838a0193508a601f850112610aa4578485fd5b8335915082821115610ab4578485fd5b8a81838601011115610ac4578485fd5b979a96995094975050909401935090919050565b600060208284031215610ae9578081fd5b6109fe83836109cb565b6001600160a01b03169052565b60008284526020808501945082825b85811015610b3e578282016001600160e01b0319610b2d82856109cb565b168852968301969150600101610b0f565b509495945050505050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b6000828483379101908152919050565b606080825281018590526000602060808084019082890285010189845b8a811015610c31577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808784030184528135603e198d3603018112610be2578687fd5b8c016040868201610bfc86610bf783866109ae565b610af3565b610c068184610e6e565b935090508188870152610c1c8287018483610b00565b96880196955050509185019150600101610ba0565b5050610c3f83860189610af3565b8481036040860152610c52818789610b49565b9a9950505050505050505050565b6000602080835283518082850152825b81811015610c8c57858101830151858201604001528201610c70565b81811115610c9d5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526016908201527f4d757374206f776e2074686520636f6e74726163742e00000000000000000000604082015260600190565b6020808252603e908201527f4469616d6f6e6443757446616365743a205f696e69742069732061646472657360408201527f73283029206275745f63616c6c64617461206973206e6f7420656d7074790000606082015260800190565b6020808252603f908201527f4469616d6f6e6443757446616365743a205f63616c6c6461746120697320656d60408201527f70747920627574205f696e6974206973206e6f74206164647265737328302900606082015260800190565b60208082526028908201527f4469616d6f6e6443757446616365743a205f696e69742066756e6374696f6e2060408201527f7265766572746564000000000000000000000000000000000000000000000000606082015260800190565b6000808335601e19843603018112610e17578283fd5b83018035915067ffffffffffffffff821115610e31578283fd5b6020908101925081023603821315610e4857600080fd5b9250929050565b60008235603e19833603018112610e64578182fd5b9190910192915050565b6000808335601e19843603018112610e84578283fd5b830160208101925035905067ffffffffffffffff811115610ea457600080fd5b602081023603831315610e4857600080fdfe4469616d6f6e6443757446616365743a205f696e6974206164647265737320686173206e6f20636f64654469616d6f6e6443757446616365743a204e657720666163657420686173206e6f20636f6465a2646970667358221220d549925be7f162ad8bee0e5faaf2f9a9e548ed65080d804fbd4dcdb3aa77977264736f6c63430007010033",
  "linkReferences": {},
  "deployedLinkReferences": {},
  "metadata": "{\"compiler\":{\"version\":\"0.7.1+commit.f4a555be\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"indexed\":false,\"internalType\":\"struct IDiamondCut.Facet[]\",\"name\":\"_diamondCut\",\"type\":\"tuple[]\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_init\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_calldata\",\"type\":\"bytes\"}],\"name\":\"DiamondCut\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"internalType\":\"struct IDiamondCut.Facet[]\",\"name\":\"_diamondCut\",\"type\":\"tuple[]\"},{\"internalType\":\"address\",\"name\":\"_init\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_calldata\",\"type\":\"bytes\"}],\"name\":\"diamondCut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"diamondCut((address,bytes4[])[],address,bytes)\":{\"params\":{\"_calldata\":\"A function call, including function selector and arguments                  _calldata is executed with delegatecall on _init\",\"_diamondCut\":\"Contains the facet addresses and function selectors\",\"_init\":\"The address of the contract or facet to execute _calldata\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"diamondCut((address,bytes4[])[],address,bytes)\":{\"notice\":\"Add/replace/remove any number of functions and optionally execute         a function with delegatecall\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.7/diamond/facets/DiamondCutFacet.sol\":\"DiamondCutFacet\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":2000},\"remappings\":[]},\"sources\":{\"solc_0.7/diamond/facets/DiamondCutFacet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.7.1;\\npragma experimental ABIEncoderV2;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen)\\n*\\n* Implementation of diamondCut external function.\\n/******************************************************************************/\\n\\nimport \\\"../libraries/LibDiamondStorage.sol\\\";\\nimport \\\"../interfaces/IDiamondCut.sol\\\";\\nimport \\\"../libraries/LibDiamondCut.sol\\\";\\n\\ncontract DiamondCutFacet is IDiamondCut {\\n    // Standard diamondCut external function\\n    /// @notice Add/replace/remove any number of functions and optionally execute\\n    ///         a function with delegatecall\\n    /// @param _diamondCut Contains the facet addresses and function selectors\\n    /// @param _init The address of the contract or facet to execute _calldata\\n    /// @param _calldata A function call, including function selector and arguments\\n    ///                  _calldata is executed with delegatecall on _init\\n    function diamondCut(\\n        Facet[] calldata _diamondCut,\\n        address _init,\\n        bytes calldata _calldata\\n    ) external override {\\n        externalCut(_diamondCut);\\n        emit DiamondCut(_diamondCut, _init, _calldata);\\n        if (_init == address(0)) {\\n            require(_calldata.length == 0, \\\"DiamondCutFacet: _init is address(0) but_calldata is not empty\\\");\\n        } else {\\n            require(_calldata.length > 0, \\\"DiamondCutFacet: _calldata is empty but _init is not address(0)\\\");\\n            if (_init != address(this)) {\\n                LibDiamondCut.hasContractCode(_init, \\\"DiamondCutFacet: _init address has no code\\\");\\n            }\\n            (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n            if (!success) {\\n                if (error.length > 0) {\\n                    // bubble up the error\\n                    revert(string(error));\\n                } else {\\n                    revert(\\\"DiamondCutFacet: _init function reverted\\\");\\n                }\\n            }\\n        }\\n    }\\n\\n    // diamondCut helper function\\n    // This code is almost the same as the internal diamondCut function,\\n    // except it is using 'Facets[] calldata _diamondCut' instead of\\n    // 'Facet[] memory _diamondCut', and it does not issue the DiamondCut event.\\n    // The code is duplicated to prevent copying calldata to memory which\\n    // causes a Solidity error for two dimensional arrays.\\n    function externalCut(Facet[] calldata _diamondCut) internal {\\n        LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage();\\n        require(msg.sender == ds.contractOwner, \\\"Must own the contract.\\\");\\n        for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\\n            address newFacetAddress = _diamondCut[facetIndex].facetAddress;\\n            // add or replace function\\n            if (newFacetAddress != address(0)) {\\n                uint256 facetAddressPosition = ds.facetFunctionSelectors[newFacetAddress].facetAddressPosition;\\n                // add new facet address if it does not exist\\n                if (facetAddressPosition == 0 && ds.facetFunctionSelectors[newFacetAddress].functionSelectors.length == 0) {\\n                    LibDiamondCut.hasContractCode(newFacetAddress, \\\"DiamondCutFacet: New facet has no code\\\");\\n                    facetAddressPosition = ds.facetAddresses.length;\\n                    ds.facetAddresses.push(newFacetAddress);\\n                    ds.facetFunctionSelectors[newFacetAddress].facetAddressPosition = uint16(facetAddressPosition);\\n                }\\n                // add or replace selectors\\n                for (uint256 selectorIndex; selectorIndex < _diamondCut[facetIndex].functionSelectors.length; selectorIndex++) {\\n                    bytes4 selector = _diamondCut[facetIndex].functionSelectors[selectorIndex];\\n                    address oldFacet = ds.selectorToFacetAndPosition[selector].facetAddress;\\n                    // add\\n                    if (oldFacet == address(0)) {\\n                        LibDiamondCut.addSelector(newFacetAddress, selector);\\n                    } else {\\n                        // replace\\n                        if (oldFacet != newFacetAddress) {\\n                            LibDiamondCut.removeSelector(selector);\\n                            LibDiamondCut.addSelector(newFacetAddress, selector);\\n                        }\\n                    }\\n                }\\n            } else {\\n                // remove selectors\\n                for (uint256 selectorIndex; selectorIndex < _diamondCut[facetIndex].functionSelectors.length; selectorIndex++) {\\n                    LibDiamondCut.removeSelector(_diamondCut[facetIndex].functionSelectors[selectorIndex]);\\n                }\\n            }\\n        }\\n    }\\n}\\n\",\"keccak256\":\"0xe5cefda560bdf00d7e412ef747e28f2076d07b32221ccdfaa607aaab0ca30029\",\"license\":\"MIT\"},\"solc_0.7/diamond/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.7.1;\\npragma experimental ABIEncoderV2;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen)\\n/******************************************************************************/\\n\\ninterface IDiamondCut {\\n    struct Facet {\\n        address facetAddress;\\n        bytes4[] functionSelectors;\\n    }\\n\\n    /// @notice Add/replace/remove any number of functions and optionally execute\\n    ///         a function with delegatecall\\n    /// @param _diamondCut Contains the facet addresses and function selectors\\n    /// @param _init The address of the contract or facet to execute _calldata\\n    /// @param _calldata A function call, including function selector and arguments\\n    ///                  _calldata is executed with delegatecall on _init\\n    function diamondCut(\\n        Facet[] calldata _diamondCut,\\n        address _init,\\n        bytes calldata _calldata\\n    ) external;\\n\\n    event DiamondCut(Facet[] _diamondCut, address _init, bytes _calldata);\\n}\\n\",\"keccak256\":\"0xba9cbedda8b486e17512639ee5ca6a4de1638b55c26b130e61cbbaa632acdef5\",\"license\":\"MIT\"},\"solc_0.7/diamond/libraries/LibDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.7.1;\\npragma experimental ABIEncoderV2;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen)\\n*\\n* Implementation of internal diamondCut function.\\n/******************************************************************************/\\n\\nimport \\\"./LibDiamondStorage.sol\\\";\\nimport \\\"../interfaces/IDiamondCut.sol\\\";\\n\\nlibrary LibDiamondCut {\\n    event DiamondCut(IDiamondCut.Facet[] _diamondCut, address _init, bytes _calldata);\\n\\n    // Non-standard internal function version of diamondCut\\n    // This code is almost the same as externalCut, except it is using\\n    // 'Facet[] memory _diamondCut' instead of 'Facet[] calldata _diamondCut'\\n    // and it DOES issue the DiamondCut event\\n    // The code is duplicated to prevent copying calldata to memory which\\n    // causes a Solidity error for a two dimensional array.\\n    function diamondCut(IDiamondCut.Facet[] memory _diamondCut) internal {\\n        LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage();\\n        for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {\\n            address newFacetAddress = _diamondCut[facetIndex].facetAddress;\\n            // add or replace function\\n            if (newFacetAddress != address(0)) {\\n                uint256 facetAddressPosition = ds.facetFunctionSelectors[newFacetAddress].facetAddressPosition;\\n                // add new facet address if it does not exist\\n                if (facetAddressPosition == 0 && ds.facetFunctionSelectors[newFacetAddress].functionSelectors.length == 0) {\\n                    hasContractCode(newFacetAddress, \\\"LibDiamondCut: New facet has no code\\\");\\n                    facetAddressPosition = ds.facetAddresses.length;\\n                    ds.facetAddresses.push(newFacetAddress);\\n                    ds.facetFunctionSelectors[newFacetAddress].facetAddressPosition = uint16(facetAddressPosition);\\n                }\\n                // add or replace selectors\\n                for (uint256 selectorIndex; selectorIndex < _diamondCut[facetIndex].functionSelectors.length; selectorIndex++) {\\n                    bytes4 selector = _diamondCut[facetIndex].functionSelectors[selectorIndex];\\n                    address oldFacet = ds.selectorToFacetAndPosition[selector].facetAddress;\\n                    // add\\n                    if (oldFacet == address(0)) {\\n                        addSelector(newFacetAddress, selector);\\n                    } else {\\n                        // replace\\n                        if (oldFacet != newFacetAddress) {\\n                            removeSelector(selector);\\n                            addSelector(newFacetAddress, selector);\\n                        }\\n                    }\\n                }\\n            } else {\\n                // remove selectors\\n                for (uint256 selectorIndex; selectorIndex < _diamondCut[facetIndex].functionSelectors.length; selectorIndex++) {\\n                    removeSelector(_diamondCut[facetIndex].functionSelectors[selectorIndex]);\\n                }\\n            }\\n        }\\n        emit DiamondCut(_diamondCut, address(0), new bytes(0));\\n    }\\n\\n    function addSelector(address _newFacet, bytes4 _selector) internal {\\n        LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage();\\n        uint256 selectorPosition = ds.facetFunctionSelectors[_newFacet].functionSelectors.length;\\n        ds.facetFunctionSelectors[_newFacet].functionSelectors.push(_selector);\\n        ds.selectorToFacetAndPosition[_selector].facetAddress = _newFacet;\\n        ds.selectorToFacetAndPosition[_selector].functionSelectorPosition = uint16(selectorPosition);\\n    }\\n\\n    function removeSelector(bytes4 _selector) internal {\\n        LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage();\\n        address oldFacet = ds.selectorToFacetAndPosition[_selector].facetAddress;\\n        // if function does not exist then do nothing and return\\n        if (oldFacet == address(0)) {\\n            return;\\n        }\\n        // replace selector with last selector, then delete last selector\\n        uint256 selectorPosition = ds.selectorToFacetAndPosition[_selector].functionSelectorPosition;\\n        uint256 lastSelectorPosition = ds.facetFunctionSelectors[oldFacet].functionSelectors.length - 1;\\n        bytes4 lastSelector = ds.facetFunctionSelectors[oldFacet].functionSelectors[lastSelectorPosition];\\n        // if not the same then replace _selector with lastSelector\\n        if (lastSelector != _selector) {\\n            ds.facetFunctionSelectors[oldFacet].functionSelectors[selectorPosition] = lastSelector;\\n            ds.selectorToFacetAndPosition[lastSelector].functionSelectorPosition = uint16(selectorPosition);\\n        }\\n        // delete the last selector\\n        ds.facetFunctionSelectors[oldFacet].functionSelectors.pop();\\n        delete ds.selectorToFacetAndPosition[_selector];\\n\\n        // if no more selectors for facet address then delete the facet address\\n        if (lastSelectorPosition == 0) {\\n            // replace facet address with last facet address and delete last facet address\\n            uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1;\\n            address lastFacetAddress = ds.facetAddresses[lastFacetAddressPosition];\\n            uint256 facetAddressPosition = ds.facetFunctionSelectors[oldFacet].facetAddressPosition;\\n            if (oldFacet != lastFacetAddress) {\\n                ds.facetAddresses[facetAddressPosition] = lastFacetAddress;\\n                ds.facetFunctionSelectors[lastFacetAddress].facetAddressPosition = uint16(facetAddressPosition);\\n            }\\n            ds.facetAddresses.pop();\\n            delete ds.facetFunctionSelectors[oldFacet];\\n        }\\n    }\\n\\n    function hasContractCode(address _contract, string memory _errorMessage) internal view {\\n        uint256 contractSize;\\n        assembly {\\n            contractSize := extcodesize(_contract)\\n        }\\n        require(contractSize > 0, _errorMessage);\\n    }\\n}\\n\",\"keccak256\":\"0x2b0552b7626a43189f62e6b8e7ac6e257a0d6ebe6f03a44d2da12c931a96155b\",\"license\":\"MIT\"},\"solc_0.7/diamond/libraries/LibDiamondStorage.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.7.1;\\npragma experimental ABIEncoderV2;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen)\\n/******************************************************************************/\\n\\nlibrary LibDiamondStorage {\\n    bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n    struct FacetAddressAndPosition {\\n        address facetAddress;\\n        uint16 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array\\n    }\\n\\n    struct FacetFunctionSelectors {\\n        bytes4[] functionSelectors;\\n        uint16 facetAddressPosition; // position of facetAddress in facetAddresses array\\n    }\\n\\n    struct DiamondStorage {\\n        // owner of the contract\\n        address contractOwner;\\n        // maps function selector to the facet address and        \\n        // the position of the selector in the facetFunctionSelectors.selectors array\\n        mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;\\n        // maps facet addresses to function selectors\\n        mapping(address => FacetFunctionSelectors) facetFunctionSelectors;\\n        // facet addresses\\n        address[] facetAddresses;\\n        // Used to query if a contract implements an interface.\\n        // Used to implement ERC-165.\\n        mapping(bytes4 => bool) supportedInterfaces;\\n    }\\n\\n    function diamondStorage() internal pure returns (DiamondStorage storage ds) {\\n        bytes32 position = DIAMOND_STORAGE_POSITION;\\n        assembly {\\n            ds.slot := position\\n        }\\n    }\\n}\\n\",\"keccak256\":\"0xe775d2cb83a52f9bc6341b6331acd86527a7870dca3193cfcad3db6206017ed2\",\"license\":\"MIT\"}},\"version\":1}",
  "contractFilepath": "solc_0.7/diamond/facets/DiamondCutFacet.sol",
  "methodIdentifiers": {
    "diamondCut((address,bytes4[])[],address,bytes)": "e712b4e1"
  },
  "gasEstimates": {
    "creation": {
      "codeDepositCost": "780000",
      "executionCost": "812",
      "totalCost": "780812"
    },
    "external": {
      "diamondCut((address,bytes4[])[],address,bytes)": "infinite"
    },
    "internal": {
      "externalCut(struct IDiamondCut.Facet calldata[] calldata)": "infinite"
    }
  },
  "storageLayout": {
    "storage": [],
    "types": null
  },
  "userdoc": {
    "kind": "user",
    "methods": {
      "diamondCut((address,bytes4[])[],address,bytes)": {
        "notice": "Add/replace/remove any number of functions and optionally execute         a function with delegatecall"
      }
    },
    "version": 1
  },
  "devdoc": {
    "kind": "dev",
    "methods": {
      "diamondCut((address,bytes4[])[],address,bytes)": {
        "params": {
          "_calldata": "A function call, including function selector and arguments                  _calldata is executed with delegatecall on _init",
          "_diamondCut": "Contains the facet addresses and function selectors",
          "_init": "The address of the contract or facet to execute _calldata"
        }
      }
    },
    "version": 1
  }
}