Skip to content

Commit fba2092

Browse files
authored
chore: Allow ImmutableSeaport and ImmutableSignedZone ownership configurable through constructor (#157)
1 parent c932e3f commit fba2092

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

contracts/trading/seaport/ImmutableSeaport.sol

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
OrderComponents
1515
} from "seaport-types/src/lib/ConsiderationStructs.sol";
1616
import { OrderType } from "seaport-types/src/lib/ConsiderationEnums.sol";
17-
import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";
17+
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
1818
import {
1919
ImmutableSeaportEvents
2020
} from "./interfaces/ImmutableSeaportEvents.sol";
@@ -31,7 +31,7 @@ import {
3131
*/
3232
contract ImmutableSeaport is
3333
Consideration,
34-
Ownable2Step,
34+
Ownable,
3535
ImmutableSeaportEvents
3636
{
3737
// Mapping to store valid ImmutableZones - this allows for multiple Zones
@@ -48,10 +48,16 @@ contract ImmutableSeaport is
4848
* @param conduitController A contract that deploys conduits, or proxies
4949
* that may optionally be used to transfer approved
5050
* ERC20/721/1155 tokens.
51+
* @param owner The address of the owner of this contract. Specified in the
52+
* constructor to be CREATE2 / CREATE3 compatible.
5153
*/
5254
constructor(
53-
address conduitController
54-
) Consideration(conduitController) Ownable2Step() {}
55+
address conduitController,
56+
address owner
57+
) Consideration(conduitController) Ownable() {
58+
// Transfer ownership to the address specified in the constructor
59+
_transferOwnership(owner);
60+
}
5561

5662
/**
5763
* @dev Set the validity of a zone for use during fulfillment.

contracts/trading/seaport/zones/ImmutableSignedZone.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { SIP7Interface } from "./interfaces/SIP7Interface.sol";
1212
import { SIP7EventsAndErrors } from "./interfaces/SIP7EventsAndErrors.sol";
1313
import { SIP6EventsAndErrors } from "./interfaces/SIP6EventsAndErrors.sol";
1414
import { SIP5Interface } from "./interfaces/SIP5Interface.sol";
15-
import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";
15+
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
1616
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
1717
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
1818
import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
@@ -40,7 +40,7 @@ contract ImmutableSignedZone is
4040
ZoneInterface,
4141
SIP5Interface,
4242
SIP7Interface,
43-
Ownable2Step
43+
Ownable
4444
{
4545
/// @dev The EIP-712 digest parameters.
4646
bytes32 internal immutable _VERSION_HASH = keccak256(bytes("1.0"));
@@ -115,11 +115,14 @@ contract ImmutableSignedZone is
115115
* @param apiEndpoint The API endpoint where orders for this zone can be
116116
* signed.
117117
* Request and response payloads are defined in SIP-7.
118+
* @param owner The address of the owner of this contract. Specified in the
119+
* constructor to be CREATE2 / CREATE3 compatible.
118120
*/
119121
constructor(
120122
string memory zoneName,
121123
string memory apiEndpoint,
122-
string memory documentationURI
124+
string memory documentationURI,
125+
address owner
123126
) {
124127
// Set the zone name.
125128
_ZONE_NAME = zoneName;
@@ -135,6 +138,9 @@ contract ImmutableSignedZone is
135138

136139
// Emit an event to signal a SIP-5 contract has been deployed.
137140
emit SeaportCompatibleContractDeployed();
141+
142+
// Transfer ownership to the address specified in the constructor
143+
_transferOwnership(owner);
138144
}
139145

140146
/**

test/seaport/immutablesignedzone.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,23 @@ describe("ImmutableSignedZone", function () {
3636
users = await ethers.getSigners();
3737
deployer = users[0];
3838
const factory = await ethers.getContractFactory("ImmutableSignedZone");
39-
const tx = await factory.connect(deployer).deploy("ImmutableSignedZone", "", "");
39+
const tx = await factory.connect(deployer).deploy("ImmutableSignedZone", "", "", deployer.address);
4040

4141
const address = (await tx.deployed()).address;
4242

4343
contract = ImmutableSignedZone__factory.connect(address, deployer);
4444
});
4545

4646
describe("Ownership", async function () {
47-
it("deployer beomces owner", async () => {
47+
it("deployer becomes owner", async () => {
4848
assert((await contract.owner()) === deployer.address);
4949
});
5050

51-
it("transferOwnership and acceptOwnership works", async () => {
51+
it("transferOwnership works", async () => {
5252
assert((await contract.owner()) === deployer.address);
5353
const transferTx = await contract.connect(deployer).transferOwnership(users[2].address);
5454
await transferTx.wait(1);
5555

56-
const acceptTx = await contract.connect(users[2]).acceptOwnership();
57-
await acceptTx.wait(1);
5856
assert((await contract.owner()) === users[2].address);
5957
});
6058

test/seaport/utils/deploy-immutable-contracts.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export async function deployImmutableContracts(serverSignerAddress: string): Pro
3131
const immutableSignedZoneContract = (await immutableSignedZoneFactory.deploy(
3232
"ImmutableSignedZone",
3333
"",
34-
""
34+
"",
35+
accounts[0].address
3536
)) as ImmutableSignedZone;
3637
await immutableSignedZoneContract.deployed();
3738

@@ -47,7 +48,8 @@ export async function deployImmutableContracts(serverSignerAddress: string): Pro
4748

4849
const seaportContractFactory = await hre.ethers.getContractFactory("ImmutableSeaport");
4950
const seaportContract = (await seaportContractFactory.deploy(
50-
seaportConduitControllerContract.address
51+
seaportConduitControllerContract.address,
52+
accounts[0].address
5153
)) as ImmutableSeaport;
5254
await seaportContract.deployed();
5355

0 commit comments

Comments
 (0)