-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: refactor result module to use pointer type * style: run forge fmt * chore: implement LibPointer * refactor: use pointers on decode * style: run forge fmt * chore: rename `asPointer` -> `toPointer`
- Loading branch information
Showing
7 changed files
with
269 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.13 <0.9.0; | ||
|
||
type Pointer is bytes32; | ||
|
||
library LibPointer { | ||
function asBytes32(Pointer self) internal pure returns (bytes32) { | ||
return Pointer.unwrap(self); | ||
} | ||
|
||
function asString(Pointer self) internal pure returns (string memory val) { | ||
bytes32 memoryAddr = self.asBytes32(); | ||
|
||
assembly { | ||
val := memoryAddr | ||
} | ||
} | ||
|
||
function asBytes(Pointer self) internal pure returns (bytes memory val) { | ||
bytes32 memoryAddr = self.asBytes32(); | ||
|
||
assembly { | ||
val := memoryAddr | ||
} | ||
} | ||
|
||
function asBool(Pointer self) internal pure returns (bool val) { | ||
bytes32 memoryAddr = self.asBytes32(); | ||
|
||
assembly { | ||
val := memoryAddr | ||
} | ||
} | ||
|
||
function asUint256(Pointer self) internal pure returns (uint256 val) { | ||
bytes32 memoryAddr = self.asBytes32(); | ||
|
||
assembly { | ||
val := memoryAddr | ||
} | ||
} | ||
} | ||
|
||
using LibPointer for Pointer global; |
Oops, something went wrong.