Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(world): allow transferring ownership of namespaces #1274

Merged
merged 12 commits into from
Sep 1, 2023
15 changes: 15 additions & 0 deletions .changeset/rare-trainers-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@latticexyz/world": minor
---

It is now possible to transfer ownership of namespaces!

```solidity
// Register a new namespace
world.registerNamespace("namespace");
// It's owned by the caller of the function (address(this))

// Transfer ownership of the namespace to address(42)
world.transferOwnership("namespace", address(42));
// It's now owned by address(42)
```
40 changes: 40 additions & 0 deletions e2e/packages/contracts/types/ethers-contracts/IWorld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface IWorldInterface extends utils.Interface {
"setField(bytes32,bytes32[],uint8,bytes,bytes32)": FunctionFragment;
"setRecord(bytes32,bytes32[],bytes,bytes32)": FunctionFragment;
"stub(uint256)": FunctionFragment;
"transferOwnership(bytes16,address)": FunctionFragment;
"updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)": FunctionFragment;
};

Expand Down Expand Up @@ -93,6 +94,7 @@ export interface IWorldInterface extends utils.Interface {
| "setField"
| "setRecord"
| "stub"
| "transferOwnership"
| "updateInField"
): FunctionFragment;

Expand Down Expand Up @@ -280,6 +282,10 @@ export interface IWorldInterface extends utils.Interface {
functionFragment: "stub",
values: [PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "transferOwnership",
values: [PromiseOrValue<BytesLike>, PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "updateInField",
values: [
Expand Down Expand Up @@ -378,6 +384,10 @@ export interface IWorldInterface extends utils.Interface {
decodeFunctionResult(functionFragment: "setField", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "setRecord", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "stub", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "transferOwnership",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "updateInField",
data: BytesLike
Expand Down Expand Up @@ -675,6 +685,12 @@ export interface IWorld extends BaseContract {
overrides?: CallOverrides
): Promise<[BigNumber]>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down Expand Up @@ -881,6 +897,12 @@ export interface IWorld extends BaseContract {
overrides?: CallOverrides
): Promise<BigNumber>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down Expand Up @@ -1085,6 +1107,12 @@ export interface IWorld extends BaseContract {
overrides?: CallOverrides
): Promise<BigNumber>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<void>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down Expand Up @@ -1338,6 +1366,12 @@ export interface IWorld extends BaseContract {
overrides?: CallOverrides
): Promise<BigNumber>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down Expand Up @@ -1545,6 +1579,12 @@ export interface IWorld extends BaseContract {
overrides?: CallOverrides
): Promise<PopulatedTransaction>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,24 @@ const _abi = [
stateMutability: "pure",
type: "function",
},
{
inputs: [
{
internalType: "bytes16",
name: "namespace",
type: "bytes16",
},
{
internalType: "address",
name: "newOwner",
type: "address",
},
],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface IWorldInterface extends utils.Interface {
"setRecord(bytes32,bytes32[],bytes,bytes32)": FunctionFragment;
"staticArrayBytesStruct(tuple[1])": FunctionFragment;
"staticArrayStringStruct(tuple[1])": FunctionFragment;
"transferOwnership(bytes16,address)": FunctionFragment;
"updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)": FunctionFragment;
"willRevert()": FunctionFragment;
};
Expand Down Expand Up @@ -106,6 +107,7 @@ export interface IWorldInterface extends utils.Interface {
| "setRecord"
| "staticArrayBytesStruct"
| "staticArrayStringStruct"
| "transferOwnership"
| "updateInField"
| "willRevert"
): FunctionFragment;
Expand Down Expand Up @@ -302,6 +304,10 @@ export interface IWorldInterface extends utils.Interface {
functionFragment: "staticArrayStringStruct",
values: [[StringStructStruct]]
): string;
encodeFunctionData(
functionFragment: "transferOwnership",
values: [PromiseOrValue<BytesLike>, PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "updateInField",
values: [
Expand Down Expand Up @@ -421,6 +427,10 @@ export interface IWorldInterface extends utils.Interface {
functionFragment: "staticArrayStringStruct",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "transferOwnership",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "updateInField",
data: BytesLike
Expand Down Expand Up @@ -729,6 +739,12 @@ export interface IWorld extends BaseContract {
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down Expand Up @@ -949,6 +965,12 @@ export interface IWorld extends BaseContract {
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down Expand Up @@ -1167,6 +1189,12 @@ export interface IWorld extends BaseContract {
overrides?: CallOverrides
): Promise<void>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<void>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down Expand Up @@ -1432,6 +1460,12 @@ export interface IWorld extends BaseContract {
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down Expand Up @@ -1653,6 +1687,12 @@ export interface IWorld extends BaseContract {
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;

transferOwnership(
namespace: PromiseOrValue<BytesLike>,
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;

updateInField(
table: PromiseOrValue<BytesLike>,
key: PromiseOrValue<BytesLike>[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,24 @@ const _abi = [
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "bytes16",
name: "namespace",
type: "bytes16",
},
{
internalType: "address",
name: "newOwner",
type: "address",
},
],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,23 @@
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes16",
"name": "namespace",
"type": "bytes16"
},
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
18 changes: 18 additions & 0 deletions packages/world/abi/CoreSystem.sol/CoreSystem.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,5 +478,23 @@
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes16",
"name": "namespace",
"type": "bytes16"
},
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,23 @@
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes16",
"name": "namespace",
"type": "bytes16"
},
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
18 changes: 18 additions & 0 deletions packages/world/abi/IBaseWorld.sol/IBaseWorld.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes16",
"name": "namespace",
"type": "bytes16"
},
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
Loading