Skip to content

Commit

Permalink
Merge branch 'main' into 230907-client-boilerplate-comments
Browse files Browse the repository at this point in the history
  • Loading branch information
qbzzt authored Sep 12, 2023
2 parents 6078400 + 2ca75f9 commit 51243a1
Show file tree
Hide file tree
Showing 39 changed files with 1,771 additions and 103 deletions.
22 changes: 22 additions & 0 deletions .changeset/pink-tips-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"@latticexyz/world": major
---

The World now maintains a balance per namespace.
When a system is called with value, the value stored in the World contract and credited to the system's namespace.

Previously, the World contract did not store value, but passed it on to the system contracts.
However, as systems are expected to be stateless (reading/writing state only via the calling World) and can be registered in multiple Worlds, this could have led to exploits.

Any address with access to a namespace can use the balance of that namespace.
This allows all systems registered in the same namespace to work with the same balance.

There are two new World methods to transfer balance between namespaces (`transferBalanceToNamespace`) or to an address (`transferBalanceToAddress`).

```solidity
interface IBaseWorld {
function transferBalanceToNamespace(bytes16 fromNamespace, bytes16 toNamespace, uint256 amount) external;
function transferBalanceToAddress(bytes16 fromNamespace, address toAddress, uint256 amount) external;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
[
{
"inputs": [
{
"internalType": "string",
"name": "resource",
"type": "string"
},
{
"internalType": "address",
"name": "caller",
"type": "address"
}
],
"name": "AccessDenied",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "delegator",
"type": "address"
},
{
"internalType": "address",
"name": "delegatee",
"type": "address"
}
],
"name": "DelegationNotFound",
"type": "error"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "functionSelector",
"type": "bytes4"
}
],
"name": "FunctionSelectorExists",
"type": "error"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "functionSelector",
"type": "bytes4"
}
],
"name": "FunctionSelectorNotFound",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "InsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "string",
"name": "resource",
"type": "string"
}
],
"name": "InvalidSelector",
"type": "error"
},
{
"inputs": [
{
"internalType": "string",
"name": "module",
"type": "string"
}
],
"name": "ModuleAlreadyInstalled",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "length",
"type": "uint256"
}
],
"name": "PackedCounter_InvalidLength",
"type": "error"
},
{
"inputs": [
{
"internalType": "string",
"name": "resource",
"type": "string"
}
],
"name": "ResourceExists",
"type": "error"
},
{
"inputs": [
{
"internalType": "string",
"name": "resource",
"type": "string"
}
],
"name": "ResourceNotFound",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "length",
"type": "uint256"
}
],
"name": "SchemaLib_InvalidLength",
"type": "error"
},
{
"inputs": [],
"name": "SchemaLib_StaticTypeAfterDynamicType",
"type": "error"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
},
{
"internalType": "uint256",
"name": "start",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "end",
"type": "uint256"
}
],
"name": "Slice_OutOfBounds",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "expected",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "received",
"type": "uint256"
}
],
"name": "StoreCore_InvalidDataLength",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "system",
"type": "address"
}
],
"name": "SystemExists",
"type": "error"
},
{
"inputs": [
{
"internalType": "bytes16",
"name": "fromNamespace",
"type": "bytes16"
},
{
"internalType": "address",
"name": "toAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transferBalanceToAddress",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes16",
"name": "fromNamespace",
"type": "bytes16"
},
{
"internalType": "bytes16",
"name": "toNamespace",
"type": "bytes16"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transferBalanceToNamespace",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
Loading

0 comments on commit 51243a1

Please sign in to comment.