-
-
Save Timidan/91dcc6d3c6829e785d3790bcef2dedc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deploy DiamondCutFacet | |
const DiamondCut = cfx.Contract(getArtifacts("DiamondCutFacet")); | |
const txReceipt = await DiamondCut.constructor() | |
.sendTransaction({ from: acct }) | |
.executed(); | |
// deploy Diamond | |
const Diamond = cfx.Contract(getArtifacts("Diamond")); | |
const txReceipt2 = await Diamond.constructor( | |
acct.toString(), | |
txReceipt.contractCreated, | |
"DiamondToken", | |
"DMT" | |
) | |
.sendTransaction({ from: acct }) | |
.executed(); | |
DiamondAddress = txReceipt2.contractCreated; | |
//Deploy facets indiviually | |
const FacetNames = ["OwnershipFacet", "DiamondLoupeFacet", "DiamondToken"]; | |
const cut = []; | |
for (const FacetName of FacetNames) { | |
const Facet = cfx.Contract(getArtifacts(FacetName)); | |
const txReceipt = await Facet.constructor() | |
.sendTransaction({ from: acct }) | |
.executed(); | |
cut.push({ | |
facetAddress: txReceipt.contractCreated, | |
action: FacetCutAction.Add, | |
functionSelectors: await getSelectors(FacetName), | |
}); | |
} | |
// upgrade diamond with facets | |
const DiamondCutFacet = cfx.Contract({ | |
abi: getAbi("DiamondCutFacet"), | |
address: DiamondAddress, | |
}); | |
let tx; | |
//@ts-ignore | |
tx = await DiamondCutFacet.diamondCut( | |
cut, | |
ethers.constants.AddressZero, | |
"0x" | |
).sendTransaction({ from: acct }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment