Skip to content

Commit 4639417

Browse files
authored
Merge pull request #17 from dev-protocol/feat-initial-sbtfactory
feat: initial sbt factory
2 parents 109b98d + 56b32b3 commit 4639417

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

contracts/SBTFactory.sol

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-License-Identifier: MPL-2.0
2+
pragma solidity =0.8.9;
3+
4+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
5+
6+
import {SBT} from "./SBT.sol";
7+
import {SBTProxy} from "./SBTProxy.sol";
8+
9+
contract SBTFactory is Ownable {
10+
mapping(bytes => address) public sbtProxyMapping;
11+
12+
event SBTProxyCreated(bytes indexed identifier, address sbtProxyAddress);
13+
event SBTImplementationCreated(
14+
bytes indexed identifier,
15+
address sbtProxyAddress
16+
);
17+
18+
constructor() {}
19+
20+
function makeNewSBT(
21+
address proxyAdmin,
22+
bytes memory proxyCallData,
23+
address minterUpdater,
24+
address[] calldata minters,
25+
bytes calldata identifier
26+
) external onlyOwner returns (address) {
27+
// Create the implementation.
28+
address implementation = address(
29+
new SBT{salt: keccak256(identifier)}()
30+
);
31+
emit SBTImplementationCreated(identifier, address(implementation));
32+
33+
// Create the proxy.
34+
address proxy = address(
35+
new SBTProxy{salt: keccak256(identifier)}(
36+
address(implementation),
37+
proxyAdmin,
38+
proxyCallData
39+
)
40+
);
41+
emit SBTProxyCreated(identifier, proxy);
42+
43+
// Save the proxy created in mapping.
44+
sbtProxyMapping[identifier] = address(proxy);
45+
46+
// Initialize the proxy.
47+
SBT(proxy).initialize(minterUpdater, minters);
48+
49+
return address(proxy);
50+
}
51+
}

0 commit comments

Comments
 (0)