Skip to content

Commit

Permalink
Add callAsRoot and callAsRootFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
vdrg committed Nov 22, 2024
1 parent 18987ea commit d3b592b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
8 changes: 6 additions & 2 deletions packages/world/ts/node/render-solidity/renderSystemLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ export function renderSystemLibrary(options: RenderSystemLibraryOptions) {
return CallWrapper(self.toResourceId(), from);
}
function asRoot(${userTypeName} self) internal pure returns (RootCallWrapper memory) {
return RootCallWrapper(self.toResourceId(), address(0));
function callAsRoot(${userTypeName} self) internal view returns (RootCallWrapper memory) {
return RootCallWrapper(self.toResourceId(), msg.sender);
}
function callAsRootFrom(${userTypeName} self, address from) internal pure returns (RootCallWrapper memory) {
return RootCallWrapper(self.toResourceId(), from);
}
function toResourceId(${userTypeName} self) internal pure returns (ResourceId) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/system-libraries/src/namespaces/root/RootSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import { aSystem } from "../a/codegen/libraries/ASystemLib.sol";

contract RootSystem is System {
function setValueInA(uint256 value) external {
aSystem.asRoot().setValue(value);
aSystem.callAsRoot().setValue(value);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d3b592b

Please sign in to comment.