Skip to content

Commit e96b560

Browse files
authored
Merge pull request #22 from dev-protocol/feat-improvements
fix: add minor updates and improvements
2 parents e48b38c + 2ed65ba commit e96b560

File tree

8 files changed

+55
-21
lines changed

8 files changed

+55
-21
lines changed

contracts/SBT.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ contract SBT is ISBT, ERC721EnumerableUpgradeable {
5858
}
5959

6060
function initialize(
61+
string memory sbtName,
62+
string memory sbtSymbol,
6163
address minterUpdater,
6264
address[] memory minters
6365
) external initializer {
64-
__ERC721_init("Dev Protocol SBT V1", "DEV-SBT-V1");
66+
__ERC721_init(sbtName, sbtSymbol);
6567

6668
_minterUpdater = minterUpdater;
6769
for (uint256 i = 0; i < minters.length; i++) {

contracts/SBTFactory.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ contract SBTFactory is ISBTFactory, OwnableUpgradeable {
2121
}
2222

2323
function makeNewSBT(
24+
string memory sbtName,
25+
string memory sbtSymbol,
2426
address proxyAdmin,
2527
bytes memory proxyCallData,
2628
address minterUpdater,
2729
address[] calldata minters,
2830
bytes calldata identifier
29-
) external override onlyOwner returns (address) {
31+
) external override returns (address) {
3032
require(
3133
sbtProxyMapping[identifier] == address(0),
3234
"Identifier already used"
@@ -52,7 +54,7 @@ contract SBTFactory is ISBTFactory, OwnableUpgradeable {
5254
sbtProxyMapping[identifier] = address(proxy);
5355

5456
// Initialize the proxy.
55-
SBT(proxy).initialize(minterUpdater, minters);
57+
SBT(proxy).initialize(sbtName, sbtSymbol, minterUpdater, minters);
5658

5759
return address(proxy);
5860
}

contracts/interfaces/ISBTFactory.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ pragma solidity =0.8.9;
44
interface ISBTFactory {
55
/*
66
* @dev makes new SBT contract which is upgradeable.
7+
* @param sbtName The name of the SBT token to be created.
8+
* @param sbtSymbol The symbol of the SBT token to be created.
79
* @param proxyAdmin owner of the proxy contract which will be deployed.
810
* @param proxyCallData the data which denotes function calls, etc when deploying new proxy contract.
911
* @param minterUpdater the address which can add/remove minter access eoa.
@@ -12,6 +14,8 @@ interface ISBTFactory {
1214
* @return uint256[] token id list
1315
*/
1416
function makeNewSBT(
17+
string memory sbtName,
18+
string memory sbtSymbol,
1519
address proxyAdmin,
1620
bytes memory proxyCallData,
1721
address minterUpdater,

test/SBT.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('SBT', () => {
1111
const init = async (): Promise<Contract> => {
1212
const signers = await getSigners()
1313
const sbt = await deploy('SBT')
14-
await sbt.initialize(signers.minterUpdater.address, [
14+
await sbt.initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [
1515
signers.minterA.address,
1616
signers.minterB.address,
1717
])
@@ -22,7 +22,7 @@ describe('SBT', () => {
2222
it('The initialize function can only be executed once', async () => {
2323
const sbt = await init()
2424
await expect(
25-
sbt.initialize(constants.AddressZero, [
25+
sbt.initialize('Test SBT', 'TESTSBT', constants.AddressZero, [
2626
constants.AddressZero,
2727
constants.AddressZero,
2828
])

test/SBTFactory.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ describe('SBTFactory', () => {
4747
expect(await sbtFactory.sbtProxyMapping(identifier)).to.eq(ZERO_ADDRESS)
4848
await expect(
4949
sbtFactory.makeNewSBT(
50+
'Test SBT',
51+
'TESTSBT',
5052
signers.proxyAdmin.address,
5153
ethers.utils.arrayify('0x'),
5254
signers.minterUpdater.address,
@@ -72,6 +74,8 @@ describe('SBTFactory', () => {
7274
sbtFactory
7375
.connect(signers.deployer)
7476
.makeNewSBT(
77+
'Test SBT',
78+
'TESTSBT',
7579
signers.proxyAdmin.address,
7680
ethers.utils.arrayify('0x'),
7781
signers.minterUpdater.address,
@@ -87,7 +91,7 @@ describe('SBTFactory', () => {
8791
)
8892
})
8993

90-
it('The makeNewSBT function should not execute if called by non-owner', async () => {
94+
it('The makeNewSBT function should execute if called by non-owner', async () => {
9195
const signers = await getSigners()
9296
const sbtFactory = await init()
9397

@@ -97,15 +101,21 @@ describe('SBTFactory', () => {
97101
sbtFactory
98102
.connect(signers.minterA)
99103
.makeNewSBT(
104+
'Test SBT',
105+
'TESTSBT',
100106
signers.proxyAdmin.address,
101107
ethers.utils.arrayify('0x'),
102108
signers.minterUpdater.address,
103109
[signers.minterA.address, signers.minterB.address],
104110
identifier
105111
)
106-
).to.revertedWith('Ownable: caller is not the owner')
112+
)
113+
.to.emit(sbtFactory, 'SBTImplementationCreated')
114+
.emit(sbtFactory, 'SBTProxyCreated')
107115

108-
expect(await sbtFactory.sbtProxyMapping(identifier)).to.eq(ZERO_ADDRESS)
116+
expect(await sbtFactory.sbtProxyMapping(identifier)).to.not.eq(
117+
ZERO_ADDRESS
118+
)
109119
})
110120
})
111121

test/SBTFactoryProxy.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ describe('SBTFactoryProxy', () => {
489489
expect(await sbtFactory.sbtProxyMapping(identifier)).to.eq(ZERO_ADDRESS)
490490
await expect(
491491
sbtFactory.makeNewSBT(
492+
'Test SBT',
493+
'TESTSBT',
492494
signers.proxyAdmin.address,
493495
ethers.utils.arrayify('0x'),
494496
signers.minterUpdater.address,
@@ -514,6 +516,8 @@ describe('SBTFactoryProxy', () => {
514516
sbtFactory
515517
.connect(signers.deployer)
516518
.makeNewSBT(
519+
'Test SBT',
520+
'TESTSBT',
517521
signers.proxyAdmin.address,
518522
ethers.utils.arrayify('0x'),
519523
signers.minterUpdater.address,
@@ -529,7 +533,7 @@ describe('SBTFactoryProxy', () => {
529533
)
530534
})
531535

532-
it('The makeNewSBT function should not execute if called by non-owner', async () => {
536+
it('The makeNewSBT function should execute if called by non-owner', async () => {
533537
const signers = await getSigners()
534538
const { sbtFactory } = await init()
535539

@@ -539,15 +543,21 @@ describe('SBTFactoryProxy', () => {
539543
sbtFactory
540544
.connect(signers.minterA)
541545
.makeNewSBT(
546+
'Test SBT',
547+
'TESTSBT',
542548
signers.proxyAdmin.address,
543549
ethers.utils.arrayify('0x'),
544550
signers.minterUpdater.address,
545551
[signers.minterA.address, signers.minterB.address],
546552
identifier
547553
)
548-
).to.revertedWith('Ownable: caller is not the owner')
554+
)
555+
.to.emit(sbtFactory, 'SBTImplementationCreated')
556+
.emit(sbtFactory, 'SBTProxyCreated')
549557

550-
expect(await sbtFactory.sbtProxyMapping(identifier)).to.eq(ZERO_ADDRESS)
558+
expect(await sbtFactory.sbtProxyMapping(identifier)).to.not.eq(
559+
ZERO_ADDRESS
560+
)
551561
})
552562
})
553563

test/SBTProxy.test.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ describe('SBTProxy', () => {
3535
])
3636
const sbt = sbtImplementation.attach(sbtProxy.address)
3737
if (shouldAlsoInitializeProxy) {
38-
await sbt.initialize(signers.minterUpdater.address, [
39-
signers.minterA.address,
40-
signers.minterB.address,
41-
])
38+
await sbt.initialize(
39+
'Test SBT',
40+
'TESTSBT',
41+
signers.minterUpdater.address,
42+
[signers.minterA.address, signers.minterB.address]
43+
)
4244
}
4345

4446
return { sbt, sbtImplementation, sbtProxy, sbtImplementationB }
@@ -316,6 +318,8 @@ describe('SBTProxy', () => {
316318
const encodedData = sbtImplementationB
317319
.connect(signers.minterUpdater)
318320
.interface.encodeFunctionData('initialize', [
321+
'Test SBT',
322+
'TESTSBT',
319323
signers.minterUpdater.address,
320324
[signers.minterA.address, signers.minterB.address],
321325
])
@@ -330,7 +334,7 @@ describe('SBTProxy', () => {
330334
await expect(
331335
sbt
332336
.connect(signers.userA)
333-
.initialize(signers.minterUpdater.address, [
337+
.initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [
334338
signers.minterA.address,
335339
signers.minterB.address,
336340
])
@@ -353,6 +357,8 @@ describe('SBTProxy', () => {
353357
const encodedData = sbtImplementationB
354358
.connect(signers.minterUpdater)
355359
.interface.encodeFunctionData('initialize', [
360+
'Test SBT',
361+
'TESTSBT',
356362
signers.minterUpdater.address,
357363
[signers.minterA.address, signers.minterB.address],
358364
])
@@ -366,15 +372,15 @@ describe('SBTProxy', () => {
366372
await expect(
367373
sbt
368374
.connect(signers.userA)
369-
.initialize(signers.minterUpdater.address, [
375+
.initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [
370376
signers.minterA.address,
371377
signers.minterB.address,
372378
])
373379
).to.not.reverted
374380
await expect(
375381
sbt
376382
.connect(signers.userA)
377-
.initialize(signers.minterUpdater.address, [
383+
.initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [
378384
signers.minterA.address,
379385
signers.minterB.address,
380386
])
@@ -442,7 +448,7 @@ describe('SBTProxy', () => {
442448
await expect(
443449
sbt
444450
.connect(proxyAdmin)
445-
.initialize(constants.AddressZero, [
451+
.initialize('Test SBT', 'TESTSBT', constants.AddressZero, [
446452
constants.AddressZero,
447453
constants.AddressZero,
448454
])
@@ -454,7 +460,7 @@ describe('SBTProxy', () => {
454460
it('The initialize function can only be executed once', async () => {
455461
const { sbt } = await init()
456462
await expect(
457-
sbt.initialize(constants.AddressZero, [
463+
sbt.initialize('Test SBT', 'TESTSBT', constants.AddressZero, [
458464
constants.AddressZero,
459465
constants.AddressZero,
460466
])

test/SBTTokenURI.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('SBT', () => {
1313
const init = async (): Promise<Contract> => {
1414
const signers = await getSigners()
1515
const sbt = await deploy('SBT')
16-
await sbt.initialize(signers.minterUpdater.address, [
16+
await sbt.initialize('Test SBT', 'TESTSBT', signers.minterUpdater.address, [
1717
signers.minterA.address,
1818
signers.minterB.address,
1919
])

0 commit comments

Comments
 (0)