diff --git a/contracts/SBT.sol b/contracts/SBT.sol index c25a482..f24df2a 100644 --- a/contracts/SBT.sol +++ b/contracts/SBT.sol @@ -58,10 +58,12 @@ contract SBT is ISBT, ERC721EnumerableUpgradeable { } function initialize( + string memory sbtName, + string memory sbtSymbol, address minterUpdater, address[] memory minters ) external initializer { - __ERC721_init("Dev Protocol SBT V1", "DEV-SBT-V1"); + __ERC721_init(sbtName, sbtSymbol); _minterUpdater = minterUpdater; for (uint256 i = 0; i < minters.length; i++) { diff --git a/contracts/SBTFactory.sol b/contracts/SBTFactory.sol index f2f30ee..ca275a7 100644 --- a/contracts/SBTFactory.sol +++ b/contracts/SBTFactory.sol @@ -21,12 +21,14 @@ contract SBTFactory is ISBTFactory, OwnableUpgradeable { } function makeNewSBT( + string memory sbtName, + string memory sbtSymbol, address proxyAdmin, bytes memory proxyCallData, address minterUpdater, address[] calldata minters, bytes calldata identifier - ) external override onlyOwner returns (address) { + ) external override returns (address) { require( sbtProxyMapping[identifier] == address(0), "Identifier already used" @@ -52,7 +54,7 @@ contract SBTFactory is ISBTFactory, OwnableUpgradeable { sbtProxyMapping[identifier] = address(proxy); // Initialize the proxy. - SBT(proxy).initialize(minterUpdater, minters); + SBT(proxy).initialize(sbtName, sbtSymbol, minterUpdater, minters); return address(proxy); } diff --git a/contracts/interfaces/ISBTFactory.sol b/contracts/interfaces/ISBTFactory.sol index 8597710..7e9b496 100644 --- a/contracts/interfaces/ISBTFactory.sol +++ b/contracts/interfaces/ISBTFactory.sol @@ -4,6 +4,8 @@ pragma solidity =0.8.9; interface ISBTFactory { /* * @dev makes new SBT contract which is upgradeable. + * @param sbtName The name of the SBT token to be created. + * @param sbtSymbol The symbol of the SBT token to be created. * @param proxyAdmin owner of the proxy contract which will be deployed. * @param proxyCallData the data which denotes function calls, etc when deploying new proxy contract. * @param minterUpdater the address which can add/remove minter access eoa. @@ -12,6 +14,8 @@ interface ISBTFactory { * @return uint256[] token id list */ function makeNewSBT( + string memory sbtName, + string memory sbtSymbol, address proxyAdmin, bytes memory proxyCallData, address minterUpdater, diff --git a/test/SBT.test.ts b/test/SBT.test.ts index e452af6..46c5f8e 100644 --- a/test/SBT.test.ts +++ b/test/SBT.test.ts @@ -11,7 +11,7 @@ describe('SBT', () => { const init = async (): Promise => { const signers = await getSigners() const sbt = await deploy('SBT') - await sbt.initialize(signers.minterUpdater.address, [ + await sbt.initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [ signers.minterA.address, signers.minterB.address, ]) @@ -22,7 +22,7 @@ describe('SBT', () => { it('The initialize function can only be executed once', async () => { const sbt = await init() await expect( - sbt.initialize(constants.AddressZero, [ + sbt.initialize('Test SBT', 'TESTSBT', constants.AddressZero, [ constants.AddressZero, constants.AddressZero, ]) diff --git a/test/SBTFactory.test.ts b/test/SBTFactory.test.ts index 7dbb36c..82261ae 100644 --- a/test/SBTFactory.test.ts +++ b/test/SBTFactory.test.ts @@ -47,6 +47,8 @@ describe('SBTFactory', () => { expect(await sbtFactory.sbtProxyMapping(identifier)).to.eq(ZERO_ADDRESS) await expect( sbtFactory.makeNewSBT( + 'Test SBT', + 'TESTSBT', signers.proxyAdmin.address, ethers.utils.arrayify('0x'), signers.minterUpdater.address, @@ -72,6 +74,8 @@ describe('SBTFactory', () => { sbtFactory .connect(signers.deployer) .makeNewSBT( + 'Test SBT', + 'TESTSBT', signers.proxyAdmin.address, ethers.utils.arrayify('0x'), signers.minterUpdater.address, @@ -87,7 +91,7 @@ describe('SBTFactory', () => { ) }) - it('The makeNewSBT function should not execute if called by non-owner', async () => { + it('The makeNewSBT function should execute if called by non-owner', async () => { const signers = await getSigners() const sbtFactory = await init() @@ -97,15 +101,21 @@ describe('SBTFactory', () => { sbtFactory .connect(signers.minterA) .makeNewSBT( + 'Test SBT', + 'TESTSBT', signers.proxyAdmin.address, ethers.utils.arrayify('0x'), signers.minterUpdater.address, [signers.minterA.address, signers.minterB.address], identifier ) - ).to.revertedWith('Ownable: caller is not the owner') + ) + .to.emit(sbtFactory, 'SBTImplementationCreated') + .emit(sbtFactory, 'SBTProxyCreated') - expect(await sbtFactory.sbtProxyMapping(identifier)).to.eq(ZERO_ADDRESS) + expect(await sbtFactory.sbtProxyMapping(identifier)).to.not.eq( + ZERO_ADDRESS + ) }) }) diff --git a/test/SBTFactoryProxy.test.ts b/test/SBTFactoryProxy.test.ts index c58ff7a..c496958 100644 --- a/test/SBTFactoryProxy.test.ts +++ b/test/SBTFactoryProxy.test.ts @@ -489,6 +489,8 @@ describe('SBTFactoryProxy', () => { expect(await sbtFactory.sbtProxyMapping(identifier)).to.eq(ZERO_ADDRESS) await expect( sbtFactory.makeNewSBT( + 'Test SBT', + 'TESTSBT', signers.proxyAdmin.address, ethers.utils.arrayify('0x'), signers.minterUpdater.address, @@ -514,6 +516,8 @@ describe('SBTFactoryProxy', () => { sbtFactory .connect(signers.deployer) .makeNewSBT( + 'Test SBT', + 'TESTSBT', signers.proxyAdmin.address, ethers.utils.arrayify('0x'), signers.minterUpdater.address, @@ -529,7 +533,7 @@ describe('SBTFactoryProxy', () => { ) }) - it('The makeNewSBT function should not execute if called by non-owner', async () => { + it('The makeNewSBT function should execute if called by non-owner', async () => { const signers = await getSigners() const { sbtFactory } = await init() @@ -539,15 +543,21 @@ describe('SBTFactoryProxy', () => { sbtFactory .connect(signers.minterA) .makeNewSBT( + 'Test SBT', + 'TESTSBT', signers.proxyAdmin.address, ethers.utils.arrayify('0x'), signers.minterUpdater.address, [signers.minterA.address, signers.minterB.address], identifier ) - ).to.revertedWith('Ownable: caller is not the owner') + ) + .to.emit(sbtFactory, 'SBTImplementationCreated') + .emit(sbtFactory, 'SBTProxyCreated') - expect(await sbtFactory.sbtProxyMapping(identifier)).to.eq(ZERO_ADDRESS) + expect(await sbtFactory.sbtProxyMapping(identifier)).to.not.eq( + ZERO_ADDRESS + ) }) }) diff --git a/test/SBTProxy.test.ts b/test/SBTProxy.test.ts index 64375eb..0c67564 100644 --- a/test/SBTProxy.test.ts +++ b/test/SBTProxy.test.ts @@ -35,10 +35,12 @@ describe('SBTProxy', () => { ]) const sbt = sbtImplementation.attach(sbtProxy.address) if (shouldAlsoInitializeProxy) { - await sbt.initialize(signers.minterUpdater.address, [ - signers.minterA.address, - signers.minterB.address, - ]) + await sbt.initialize( + 'Test SBT', + 'TESTSBT', + signers.minterUpdater.address, + [signers.minterA.address, signers.minterB.address] + ) } return { sbt, sbtImplementation, sbtProxy, sbtImplementationB } @@ -316,6 +318,8 @@ describe('SBTProxy', () => { const encodedData = sbtImplementationB .connect(signers.minterUpdater) .interface.encodeFunctionData('initialize', [ + 'Test SBT', + 'TESTSBT', signers.minterUpdater.address, [signers.minterA.address, signers.minterB.address], ]) @@ -330,7 +334,7 @@ describe('SBTProxy', () => { await expect( sbt .connect(signers.userA) - .initialize(signers.minterUpdater.address, [ + .initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [ signers.minterA.address, signers.minterB.address, ]) @@ -353,6 +357,8 @@ describe('SBTProxy', () => { const encodedData = sbtImplementationB .connect(signers.minterUpdater) .interface.encodeFunctionData('initialize', [ + 'Test SBT', + 'TESTSBT', signers.minterUpdater.address, [signers.minterA.address, signers.minterB.address], ]) @@ -366,7 +372,7 @@ describe('SBTProxy', () => { await expect( sbt .connect(signers.userA) - .initialize(signers.minterUpdater.address, [ + .initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [ signers.minterA.address, signers.minterB.address, ]) @@ -374,7 +380,7 @@ describe('SBTProxy', () => { await expect( sbt .connect(signers.userA) - .initialize(signers.minterUpdater.address, [ + .initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [ signers.minterA.address, signers.minterB.address, ]) @@ -442,7 +448,7 @@ describe('SBTProxy', () => { await expect( sbt .connect(proxyAdmin) - .initialize(constants.AddressZero, [ + .initialize('Test SBT', 'TESTSBT', constants.AddressZero, [ constants.AddressZero, constants.AddressZero, ]) @@ -454,7 +460,7 @@ describe('SBTProxy', () => { it('The initialize function can only be executed once', async () => { const { sbt } = await init() await expect( - sbt.initialize(constants.AddressZero, [ + sbt.initialize('Test SBT', 'TESTSBT', constants.AddressZero, [ constants.AddressZero, constants.AddressZero, ]) diff --git a/test/SBTTokenURI.test.ts b/test/SBTTokenURI.test.ts index 1e31fd7..24e49a7 100644 --- a/test/SBTTokenURI.test.ts +++ b/test/SBTTokenURI.test.ts @@ -13,7 +13,7 @@ describe('SBT', () => { const init = async (): Promise => { const signers = await getSigners() const sbt = await deploy('SBT') - await sbt.initialize(signers.minterUpdater.address, [ + await sbt.initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [ signers.minterA.address, signers.minterB.address, ])