diff --git a/contracts/domain/BosonConstants.sol b/contracts/domain/BosonConstants.sol index 0d842dabc..a756e9fe5 100644 --- a/contracts/domain/BosonConstants.sol +++ b/contracts/domain/BosonConstants.sol @@ -171,6 +171,7 @@ string constant ESCALATION_NOT_ALLOWED = "Disputes without dispute resolver cann // Revert Reasons: Config related string constant FEE_PERCENTAGE_INVALID = "Percentage representation must be less than 10000"; string constant VALUE_ZERO_NOT_ALLOWED = "Value must be greater than 0"; +bytes32 constant VOUCHER_PROXY_SALT = keccak256(abi.encodePacked("BosonVoucherProxy")); // EIP712Lib string constant PROTOCOL_NAME = "Boson Protocol"; diff --git a/contracts/protocol/bases/SellerBase.sol b/contracts/protocol/bases/SellerBase.sol index e0a23ba15..c4a69ae13 100644 --- a/contracts/protocol/bases/SellerBase.sol +++ b/contracts/protocol/bases/SellerBase.sol @@ -99,14 +99,7 @@ contract SellerBase is ProtocolBase, IBosonAccountEvents { storeSeller(_seller, _authToken, lookups); // Create clone and store its address cloneAddress - address voucherCloneAddress = cloneBosonVoucher( - sellerId, - 0, - _seller.admin, - _seller.assistant, - _voucherInitValues, - "" - ); + address voucherCloneAddress = cloneBosonVoucher(sellerId, 0, sender, _seller.assistant, _voucherInitValues, ""); lookups.cloneAddress[sellerId] = voucherCloneAddress; // Notify watchers of state change diff --git a/contracts/protocol/facets/ConfigHandlerFacet.sol b/contracts/protocol/facets/ConfigHandlerFacet.sol index 1a0ab5d07..6c06d5cfa 100644 --- a/contracts/protocol/facets/ConfigHandlerFacet.sol +++ b/contracts/protocol/facets/ConfigHandlerFacet.sol @@ -8,6 +8,7 @@ import { DiamondLib } from "../../diamond/DiamondLib.sol"; import { ProtocolBase } from "../bases/ProtocolBase.sol"; import { ProtocolLib } from "../libs/ProtocolLib.sol"; import { EIP712Lib } from "../libs/EIP712Lib.sol"; +import { BeaconClientProxy } from "../../protocol/clients/proxy/BeaconClientProxy.sol"; /** * @title ConfigHandlerFacet @@ -32,10 +33,10 @@ contract ConfigHandlerFacet is IBosonConfigHandler, ProtocolBase { DiamondLib.addSupportedInterface(type(IBosonConfigHandler).interfaceId); // Initialize protocol config params + // _addresses.beaconProxy is ignored, since it's deployed later in this function setTokenAddress(_addresses.token); setTreasuryAddress(_addresses.treasury); setVoucherBeaconAddress(_addresses.voucherBeacon); - setBeaconProxyAddress(_addresses.beaconProxy); setProtocolFeePercentage(_fees.percentage); setProtocolFeeFlatBoson(_fees.flatBoson); setMaxExchangesPerBatch(_limits.maxExchangesPerBatch); @@ -71,6 +72,10 @@ contract ConfigHandlerFacet is IBosonConfigHandler, ProtocolBase { ProtocolLib.ProtocolMetaTxInfo storage pmti = protocolMetaTxInfo(); pmti.domainSeparator = EIP712Lib.buildDomainSeparator(PROTOCOL_NAME, PROTOCOL_VERSION); pmti.cachedChainId = block.chainid; + + // Deploy Boson Voucher proxy contract + address beaconProxy = address(new BeaconClientProxy{ salt: VOUCHER_PROXY_SALT }()); + setBeaconProxyAddress(beaconProxy); } /** diff --git a/contracts/protocol/facets/ProtocolInitializationHandlerFacet.sol b/contracts/protocol/facets/ProtocolInitializationHandlerFacet.sol index c6179deaf..3b7922575 100644 --- a/contracts/protocol/facets/ProtocolInitializationHandlerFacet.sol +++ b/contracts/protocol/facets/ProtocolInitializationHandlerFacet.sol @@ -6,6 +6,7 @@ import { IBosonProtocolInitializationHandler } from "../../interfaces/handlers/I import { ProtocolLib } from "../libs/ProtocolLib.sol"; import { ProtocolBase } from "../bases/ProtocolBase.sol"; import { DiamondLib } from "../../diamond/DiamondLib.sol"; +import { BeaconClientProxy } from "../../protocol/clients/proxy/BeaconClientProxy.sol"; /** * @title BosonProtocolInitializationHandler @@ -153,6 +154,9 @@ contract ProtocolInitializationHandlerFacet is IBosonProtocolInitializationHandl lookups.sellerCreator[sellerIds[i]] = sellerCreators[i]; } + + // Deploy a new voucher proxy + protocolAddresses().beaconProxy = address(new BeaconClientProxy{ salt: VOUCHER_PROXY_SALT }()); } /** diff --git a/scripts/deploy-suite.js b/scripts/deploy-suite.js index b24551b69..e22c51902 100644 --- a/scripts/deploy-suite.js +++ b/scripts/deploy-suite.js @@ -161,12 +161,6 @@ async function main(env, facetConfig) { ); await transactionResponse.wait(confirmations); - transactionResponse = await bosonConfigHandler.setBeaconProxyAddress( - bosonVoucherProxy.address, - await getFees(maxPriorityFeePerGas) - ); - await transactionResponse.wait(confirmations); - // Add NFT auth token addresses to protocol config // LENS transactionResponse = await bosonConfigHandler.setAuthTokenContract( diff --git a/scripts/util/deploy-protocol-clients.js b/scripts/util/deploy-protocol-clients.js index c1e69ba11..81c316b71 100644 --- a/scripts/util/deploy-protocol-clients.js +++ b/scripts/util/deploy-protocol-clients.js @@ -40,7 +40,7 @@ async function deployProtocolClients( // Deploy Protocol Client proxy contracts const protocolClientProxies = await deployProtocolClientProxies(protocolClientBeacons, maxPriorityFeePerGas); - // Cast the proxies to their implementation interfaces + // Cast the proxies to their implementation interfaces ?? ToDo: what is this even needed? const protocolClients = await castProtocolClientProxies(protocolClientProxies); return [protocolClientImpls, protocolClientBeacons, protocolClientProxies, protocolClients]; diff --git a/test/integration/01-update-account-roles-addresses.js b/test/integration/01-update-account-roles-addresses.js index 1e63dc960..811686fc6 100644 --- a/test/integration/01-update-account-roles-addresses.js +++ b/test/integration/01-update-account-roles-addresses.js @@ -18,6 +18,7 @@ const { oneMonth } = require("../util/constants"); const { setNextBlockTimestamp, calculateCloneAddress, + calculateBosonProxyAddress, prepareDataSignatureParameters, applyPercentage, setupTestEnvironment, @@ -48,19 +49,21 @@ describe("[@skip-on-coverage] Update account roles addresses", function () { disputeHandler: "IBosonDisputeHandler", }; + let protocolDiamondAddress; ({ + diamondAddress: protocolDiamondAddress, signers: [admin, treasury, buyer, rando, adminDR, treasuryDR, agent], contractInstances: { accountHandler, offerHandler, exchangeHandler, fundsHandler, disputeHandler }, protocolConfig: [, , { buyerEscalationDepositPercentage }], - extraReturnValues: { - proxy: { address: beaconProxyAddress }, - }, } = await setupTestEnvironment(contracts)); // make all account the same assistant = clerk = admin; assistantDR = clerkDR = adminDR; + // Get the beacon proxy address + beaconProxyAddress = await calculateBosonProxyAddress(protocolDiamondAddress); + // Get snapshot id snapshotId = await getSnapshot(); }); diff --git a/test/integration/04-DR-removes-fees.js b/test/integration/04-DR-removes-fees.js index a7c93d8be..dbda82da2 100644 --- a/test/integration/04-DR-removes-fees.js +++ b/test/integration/04-DR-removes-fees.js @@ -16,6 +16,7 @@ const { DisputeResolverFee } = require("../../scripts/domain/DisputeResolverFee" const { setNextBlockTimestamp, calculateCloneAddress, + calculateBosonProxyAddress, applyPercentage, setupTestEnvironment, getSnapshot, @@ -35,7 +36,6 @@ describe("[@skip-on-coverage] DR removes fee", function () { let exchangeId; let disputeResolverFeeNative; let snapshotId; - let beaconProxyAddress; before(async function () { accountId.next(true); @@ -49,19 +49,19 @@ describe("[@skip-on-coverage] DR removes fee", function () { disputeHandler: "IBosonDisputeHandler", }; + let protocolDiamondAddress; ({ + diamondAddress: protocolDiamondAddress, signers: [admin, treasury, buyer, adminDR, treasuryDR], contractInstances: { accountHandler, offerHandler, exchangeHandler, fundsHandler, disputeHandler }, protocolConfig: [, , { buyerEscalationDepositPercentage }], - extraReturnValues: { - proxy: { address: beaconProxyAddress }, - }, } = await setupTestEnvironment(contracts)); // make all account the same assistant = clerk = admin; assistantDR = clerkDR = adminDR; + const beaconProxyAddress = await calculateBosonProxyAddress(protocolDiamondAddress); expectedCloneAddress = calculateCloneAddress(accountHandler.address, beaconProxyAddress, admin.address, ""); emptyAuthToken = mockAuthToken(); expect(emptyAuthToken.isValid()).is.true; diff --git a/test/protocol/BuyerHandlerTest.js b/test/protocol/BuyerHandlerTest.js index d22a898e3..ad1b01ac8 100644 --- a/test/protocol/BuyerHandlerTest.js +++ b/test/protocol/BuyerHandlerTest.js @@ -5,7 +5,13 @@ const Buyer = require("../../scripts/domain/Buyer"); const { DisputeResolverFee } = require("../../scripts/domain/DisputeResolverFee"); const PausableRegion = require("../../scripts/domain/PausableRegion.js"); const { RevertReasons } = require("../../scripts/config/revert-reasons.js"); -const { calculateCloneAddress, setupTestEnvironment, getSnapshot, revertToSnapshot } = require("../util/utils.js"); +const { + calculateCloneAddress, + calculateBosonProxyAddress, + setupTestEnvironment, + getSnapshot, + revertToSnapshot, +} = require("../util/utils.js"); const { mockOffer, mockSeller, @@ -34,7 +40,6 @@ describe("BuyerHandler", function () { let bosonVoucher; let voucherInitValues; let snapshotId; - let beaconProxyAddress; before(async function () { accountId.next(true); @@ -51,9 +56,6 @@ describe("BuyerHandler", function () { ({ signers: [pauser, admin, treasury, rando, other1, other2, other3, other4], contractInstances: { accountHandler, offerHandler, exchangeHandler, fundsHandler, pauseHandler }, - extraReturnValues: { - proxy: { address: beaconProxyAddress }, - }, } = await setupTestEnvironment(contracts)); // make all account the same @@ -395,6 +397,7 @@ describe("BuyerHandler", function () { //Commit to offer await exchangeHandler.connect(other1).commitToOffer(other1.address, offerId, { value: offer.price }); + const beaconProxyAddress = await calculateBosonProxyAddress(accountHandler.address); const bosonVoucherCloneAddress = calculateCloneAddress( accountHandler.address, beaconProxyAddress, diff --git a/test/protocol/ConfigHandlerTest.js b/test/protocol/ConfigHandlerTest.js index fe6705d91..4b59ff644 100644 --- a/test/protocol/ConfigHandlerTest.js +++ b/test/protocol/ConfigHandlerTest.js @@ -7,7 +7,7 @@ const { RevertReasons } = require("../../scripts/config/revert-reasons.js"); const { deployProtocolDiamond } = require("../../scripts/util/deploy-protocol-diamond.js"); const { oneWeek, oneMonth, maxPriorityFeePerGas } = require("../util/constants"); const AuthTokenType = require("../../scripts/domain/AuthTokenType"); -const { getFacetsWithArgs, getSnapshot, revertToSnapshot } = require("../util/utils"); +const { getFacetsWithArgs, getSnapshot, revertToSnapshot, calculateBosonProxyAddress } = require("../util/utils"); const { deployAndCutFacets } = require("../../scripts/util/deploy-protocol-handler-facets.js"); /** @@ -16,7 +16,7 @@ const { deployAndCutFacets } = require("../../scripts/util/deploy-protocol-handl describe("IBosonConfigHandler", function () { // Common vars let InterfaceIds, support; - let accounts, deployer, rando, token, treasury, beacon, proxy; + let accounts, deployer, rando, token, treasury, beacon; let maxOffersPerGroup, maxTwinsPerBundle, maxOffersPerBundle, @@ -43,7 +43,7 @@ describe("IBosonConfigHandler", function () { // Make accounts available accounts = await ethers.getSigners(); - [deployer, rando, token, treasury, beacon, proxy] = accounts; + [deployer, rando, token, treasury, beacon] = accounts; // Deploy the Protocol Diamond [protocolDiamond, , , , accessController] = await deployProtocolDiamond(maxPriorityFeePerGas); @@ -89,13 +89,15 @@ describe("IBosonConfigHandler", function () { describe("Deploy tests", async function () { context("📋 Initializer", async function () { it("should initialize the config handler and emit set events", async function () { + const proxyAddress = await calculateBosonProxyAddress(protocolDiamond.address); + const protocolConfig = [ // Protocol addresses { token: token.address, treasury: treasury.address, voucherBeacon: beacon.address, - beaconProxy: proxy.address, + beaconProxy: ethers.constants.AddressZero, }, // Protocol limits { @@ -148,7 +150,7 @@ describe("IBosonConfigHandler", function () { await expect(cutTransaction) .to.emit(configHandler, "BeaconProxyAddressChanged") - .withArgs(proxy.address, deployer.address); + .withArgs(proxyAddress, deployer.address); await expect(cutTransaction) .to.emit(configHandler, "ProtocolFeePercentageChanged") @@ -230,7 +232,7 @@ describe("IBosonConfigHandler", function () { treasury: treasury.address, token: token.address, voucherBeacon: beacon.address, - beaconProxy: proxy.address, + beaconProxy: ethers.constants.AddressZero, }, // Protocol limits { @@ -607,7 +609,7 @@ describe("IBosonConfigHandler", function () { proxy = accounts[9]; }); - it("should emit a VoucherAddressChanged event", async function () { + it("should emit a BeaconProxyAddressChanged event", async function () { // Set new proxy address, testing for the event await expect(configHandler.connect(deployer).setBeaconProxyAddress(proxy.address)) .to.emit(configHandler, "BeaconProxyAddressChanged") @@ -1269,11 +1271,13 @@ describe("IBosonConfigHandler", function () { expect(await configHandler.connect(rando).getTokenAddress()).to.equal(token.address, "Invalid token address"); expect(await configHandler.connect(rando).getVoucherBeaconAddress()).to.equal( beacon.address, - "Invalid voucher address" + "Invalid voucher beacon address" ); + + const proxyAddress = await calculateBosonProxyAddress(protocolDiamond.address); expect(await configHandler.connect(rando).getBeaconProxyAddress()).to.equal( - proxy.address, - "Invalid voucher address" + proxyAddress, + "Invalid voucher proxy address" ); expect(await configHandler.connect(rando).getProtocolFeePercentage()).to.equal( protocolFeePercentage, diff --git a/test/protocol/ExchangeHandlerTest.js b/test/protocol/ExchangeHandlerTest.js index 667eaa067..1fe49a0b7 100644 --- a/test/protocol/ExchangeHandlerTest.js +++ b/test/protocol/ExchangeHandlerTest.js @@ -38,6 +38,7 @@ const { calculateVoucherExpiry, prepareDataSignatureParameters, calculateCloneAddress, + calculateBosonProxyAddress, applyPercentage, deriveTokenId, setupTestEnvironment, @@ -145,12 +146,7 @@ describe("IBosonExchangeHandler", function () { configHandler, }, protocolConfig: [, , { percentage: protocolFeePercentage }], - extraReturnValues: { - bosonVoucher, - voucherImplementation, - accessController, - proxy: { address: beaconProxyAddress }, - }, + extraReturnValues: { bosonVoucher, voucherImplementation, accessController }, diamondAddress: protocolDiamondAddress, } = await setupTestEnvironment(contracts)); @@ -163,6 +159,9 @@ describe("IBosonExchangeHandler", function () { // Deploy the mock tokens [foreign20, foreign721, foreign1155] = await deployMockTokens(["Foreign20", "Foreign721", "Foreign1155"]); + // Get the beacon proxy address + beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address); + // Get snapshot id snapshotId = await getSnapshot(); }); diff --git a/test/protocol/FundsHandlerTest.js b/test/protocol/FundsHandlerTest.js index cf19522af..95593dd2f 100644 --- a/test/protocol/FundsHandlerTest.js +++ b/test/protocol/FundsHandlerTest.js @@ -14,6 +14,7 @@ const { prepareDataSignatureParameters, applyPercentage, calculateCloneAddress, + calculateBosonProxyAddress, setupTestEnvironment, getSnapshot, revertToSnapshot, @@ -130,10 +131,7 @@ describe("IBosonFundsHandler", function () { }, protocolConfig: [, , { percentage: protocolFeePercentage, buyerEscalationDepositPercentage }], diamondAddress: protocolDiamondAddress, - extraReturnValues: { - accessController, - proxy: { address: beaconProxyAddress }, - }, + extraReturnValues: { accessController }, } = await setupTestEnvironment(contracts)); // make all account the same @@ -145,6 +143,9 @@ describe("IBosonFundsHandler", function () { // Deploy the mock token [mockToken] = await deployMockTokens(["Foreign20"]); + // Get the beacon proxy address + beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address); + // Get snapshot id snapshotId = await getSnapshot(); }); diff --git a/test/protocol/OfferHandlerTest.js b/test/protocol/OfferHandlerTest.js index d18f3c519..5a3db4637 100644 --- a/test/protocol/OfferHandlerTest.js +++ b/test/protocol/OfferHandlerTest.js @@ -16,6 +16,7 @@ const { deployMockTokens } = require("../../scripts/util/deploy-mock-tokens"); const { applyPercentage, calculateCloneAddress, + calculateBosonProxyAddress, setupTestEnvironment, getSnapshot, revertToSnapshot, @@ -126,9 +127,6 @@ describe("IBosonOfferHandler", function () { , { percentage: protocolFeePercentage, flatBoson: protocolFeeFlatBoson, buyerEscalationDepositPercentage }, ], - extraReturnValues: { - proxy: { address: beaconProxyAddress }, - }, } = await setupTestEnvironment(contracts, { bosonTokenAddress: bosonToken.address })); // make all account the same @@ -136,6 +134,9 @@ describe("IBosonOfferHandler", function () { assistantDR = clerkDR = adminDR; [deployer] = await ethers.getSigners(); + // Get the beacon proxy address + beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address); + // Get snapshot id snapshotId = await getSnapshot(); }); diff --git a/test/protocol/OrchestrationHandlerTest.js b/test/protocol/OrchestrationHandlerTest.js index 34932bb55..749802094 100644 --- a/test/protocol/OrchestrationHandlerTest.js +++ b/test/protocol/OrchestrationHandlerTest.js @@ -23,6 +23,7 @@ const { getEvent, applyPercentage, calculateCloneAddress, + calculateBosonProxyAddress, setupTestEnvironment, getSnapshot, revertToSnapshot, @@ -161,9 +162,6 @@ describe("IBosonOrchestrationHandler", function () { { percentage: protocolFeePercentage, flatBoson: protocolFeeFlatBoson, buyerEscalationDepositPercentage }, ], diamondAddress: protocolDiamondAddress, - extraReturnValues: { - proxy: { address: beaconProxyAddress }, - }, } = await setupTestEnvironment(contracts, { bosonTokenAddress: bosonToken.address })); // make all account the same @@ -172,6 +170,9 @@ describe("IBosonOrchestrationHandler", function () { [deployer] = await ethers.getSigners(); + // Get the beacon proxy address + beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address); + // Get snapshot id snapshotId = await getSnapshot(); }); diff --git a/test/protocol/ProtocolInitializationHandlerTest.js b/test/protocol/ProtocolInitializationHandlerTest.js index 16ba4cb19..668837744 100644 --- a/test/protocol/ProtocolInitializationHandlerTest.js +++ b/test/protocol/ProtocolInitializationHandlerTest.js @@ -260,7 +260,7 @@ describe("ProtocolInitializationHandler", async function () { const configHandlerInterface = InterfaceIds[interfaceImplementers["ConfigHandlerFacet"]]; const accountInterface = InterfaceIds[interfaceImplementers["AccountHandlerFacet"]]; - version = ethers.utils.formatBytes32String("2.3.0"); + version = ethers.utils.formatBytes32String("0.0.0"); const calldataProtocolInitialization = deployedProtocolInitializationHandlerFacet.contract.interface.encodeFunctionData("initialize", [ version, @@ -302,7 +302,7 @@ describe("ProtocolInitializationHandler", async function () { const calldataTestFacet = testFacet.interface.encodeFunctionData("initialize", [rando.address]); - version = ethers.utils.formatBytes32String("2.3.0"); + version = ethers.utils.formatBytes32String("0.0.0"); const calldataProtocolInitialization = deployedProtocolInitializationHandlerFacet.contract.interface.encodeFunctionData("initialize", [ version, @@ -582,7 +582,7 @@ describe("ProtocolInitializationHandler", async function () { context("💔 Revert Reasons", async function () { it("Current version is not 2.2.0", async () => { // Deploy higher version - const wrongVersion = "2.3.0"; + const wrongVersion = "0.0.0"; // Prepare calldata const calldataProtocolInitializationWrong = diff --git a/test/protocol/SellerHandlerTest.js b/test/protocol/SellerHandlerTest.js index 2e18f75e6..93f5a156d 100644 --- a/test/protocol/SellerHandlerTest.js +++ b/test/protocol/SellerHandlerTest.js @@ -6,7 +6,13 @@ const AuthTokenType = require("../../scripts/domain/AuthTokenType"); const SellerUpdateFields = require("../../scripts/domain/SellerUpdateFields"); const PausableRegion = require("../../scripts/domain/PausableRegion.js"); const { RevertReasons } = require("../../scripts/config/revert-reasons.js"); -const { calculateCloneAddress, setupTestEnvironment, getSnapshot, revertToSnapshot } = require("../util/utils.js"); +const { + calculateCloneAddress, + calculateBosonProxyAddress, + setupTestEnvironment, + getSnapshot, + revertToSnapshot, +} = require("../util/utils.js"); const { VOUCHER_NAME, VOUCHER_SYMBOL } = require("../util/constants"); const { deployMockTokens } = require("../../scripts/util/deploy-mock-tokens"); const { mockSeller, mockAuthToken, mockVoucherInitValues, accountId } = require("../util/mock"); @@ -68,9 +74,6 @@ describe("SellerHandler", function () { ({ signers: [pauser, admin, treasury, rando, other1, other2, other3, other4, other5, other6, other7, other8], contractInstances: { accountHandler, exchangeHandler, pauseHandler, configHandler }, - extraReturnValues: { - proxy: { address: beaconProxyAddress }, - }, } = await setupTestEnvironment(contracts)); // make all account the same @@ -94,6 +97,9 @@ describe("SellerHandler", function () { await mockAuthERC721Contract.connect(authTokenOwner).mint(8400, 1); + // Get the beacon proxy address + beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address); + // Get snapshot id snapshotId = await getSnapshot(); }); diff --git a/test/protocol/clients/BosonVoucherTest.js b/test/protocol/clients/BosonVoucherTest.js index 0550d6b43..3011e376d 100644 --- a/test/protocol/clients/BosonVoucherTest.js +++ b/test/protocol/clients/BosonVoucherTest.js @@ -22,6 +22,7 @@ const { const { applyPercentage, calculateCloneAddress, + calculateBosonProxyAddress, calculateVoucherExpiry, setNextBlockTimestamp, setupTestEnvironment, @@ -87,12 +88,7 @@ describe("IBosonVoucher", function () { ({ signers: [protocol, buyer, rando, rando2, admin, treasury, adminDR, treasuryDR], contractInstances: { accountHandler, offerHandler, exchangeHandler, fundsHandler, configHandler }, - extraReturnValues: { - bosonVoucher, - beacon, - accessController, - proxy: { address: beaconProxyAddress }, - }, + extraReturnValues: { bosonVoucher, beacon, accessController }, } = await setupTestEnvironment(contracts, { forwarderAddress: [forwarder.address], })); @@ -116,6 +112,9 @@ describe("IBosonVoucher", function () { [foreign20] = await deployMockTokens(["Foreign20", "BosonToken"]); + // Get the beacon proxy address + beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address); + // Get snapshot id snapshotId = await getSnapshot(); }); diff --git a/test/util/utils.js b/test/util/utils.js index 4d578045c..978b16b25 100644 --- a/test/util/utils.js +++ b/test/util/utils.js @@ -261,6 +261,13 @@ function calculateCloneAddress(voucherCreator, beaconProxyAddress, sellerAddress return calculateContractAddress2(voucherCreator, cloneByteCodeHash, salt); } +async function calculateBosonProxyAddress(proxyCreator) { + const salt = utils.solidityKeccak256(["string"], ["BosonVoucherProxy"]); + const { bytecode } = await ethers.getContractFactory("BeaconClientProxy"); + const byteCodeHash = keccak256(bytecode); + return calculateContractAddress2(proxyCreator, byteCodeHash, salt); +} + const paddingType = { NONE: 0, START: 1, @@ -359,13 +366,12 @@ async function setupTestEnvironment(contracts, { bosonTokenAddress, forwarderAdd // Deploy the Protocol client implementation/proxy pairs (currently just the Boson Voucher) const protocolClientArgs = [protocolDiamond.address]; - const [implementations, beacons, proxies, clients] = await deployProtocolClients( + const [implementations, beacons, , clients] = await deployProtocolClients( protocolClientArgs, maxPriorityFeePerGas, forwarderAddress ); const [beacon] = beacons; - const [proxy] = proxies; const [bosonVoucher] = clients; const [voucherImplementation] = implementations; @@ -381,7 +387,7 @@ async function setupTestEnvironment(contracts, { bosonTokenAddress, forwarderAdd treasury: protocolTreasury.address, token: bosonTokenAddress || bosonToken.address, voucherBeacon: beacon.address, - beaconProxy: proxy.address, + beaconProxy: ethers.constants.AddressZero, }, // Protocol limits { @@ -419,7 +425,7 @@ async function setupTestEnvironment(contracts, { bosonTokenAddress, forwarderAdd contractInstances[contract] = await ethers.getContractAt(contracts[contract], protocolDiamond.address); } - const extraReturnValues = { accessController, bosonVoucher, voucherImplementation, beacon, proxy }; + const extraReturnValues = { accessController, bosonVoucher, voucherImplementation, beacon }; return { signers: signers.slice(3), @@ -449,6 +455,7 @@ exports.prepareDataSignatureParameters = prepareDataSignatureParameters; exports.calculateVoucherExpiry = calculateVoucherExpiry; exports.calculateContractAddress = calculateContractAddress; exports.calculateCloneAddress = calculateCloneAddress; +exports.calculateBosonProxyAddress = calculateBosonProxyAddress; exports.applyPercentage = applyPercentage; exports.getMappingStoragePosition = getMappingStoragePosition; exports.paddingType = paddingType;