File tree Expand file tree Collapse file tree 2 files changed +4
-23
lines changed Expand file tree Collapse file tree 2 files changed +4
-23
lines changed Original file line number Diff line number Diff line change @@ -41,20 +41,4 @@ library Memory {
41
41
function asPointer (bytes32 value ) internal pure returns (Pointer) {
42
42
return Pointer.wrap (value);
43
43
}
44
-
45
- /// @dev Returns a `Pointer` to the `value`'s header (i.e. includes the length word).
46
- function asPointer (bytes memory value ) internal pure returns (Pointer) {
47
- bytes32 ptr;
48
- assembly ("memory-safe" ) {
49
- ptr := value
50
- }
51
- return asPointer (ptr);
52
- }
53
-
54
- /// @dev `Pointer` to `bytes`. Expects a pointer to a properly ABI-encoded `bytes` object.
55
- function asBytes (Pointer ptr ) internal pure returns (bytes memory b ) {
56
- assembly ("memory-safe" ) {
57
- b := ptr
58
- }
59
- }
60
44
}
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
4
4
5
5
async function fixture ( ) {
6
6
const mock = await ethers . deployContract ( '$Memory' ) ;
7
-
8
7
return { mock } ;
9
8
}
10
9
@@ -27,16 +26,14 @@ describe('Memory', function () {
27
26
} ) ;
28
27
29
28
describe ( 'pointer conversions' , function ( ) {
30
- it ( 'asBytes32 / asPointer ' , async function ( ) {
29
+ it ( 'asBytes32' , async function ( ) {
31
30
const ptr = ethers . toBeHex ( '0x1234' , 32 ) ;
32
31
await expect ( this . mock . $asBytes32 ( ptr ) ) . to . eventually . equal ( ptr ) ;
33
- await expect ( this . mock . $asPointer ( ethers . Typed . bytes32 ( ptr ) ) ) . to . eventually . equal ( ptr ) ;
34
32
} ) ;
35
33
36
- it ( 'asBytes / asPointer' , async function ( ) {
37
- const ptr = await this . mock . $asPointer ( ethers . Typed . bytes ( ethers . toUtf8Bytes ( 'hello world' ) ) ) ;
38
- expect ( ptr ) . to . equal ( ethers . toBeHex ( 0x80 , 32 ) ) ; // Default free pointer
39
- await expect ( this . mock . $asBytes ( ptr ) ) . to . eventually . equal ( ethers . toBeHex ( 0x20 , 32 ) ) ;
34
+ it ( 'asPointer' , async function ( ) {
35
+ const ptr = ethers . toBeHex ( '0x1234' , 32 ) ;
36
+ await expect ( this . mock . $asPointer ( ptr ) ) . to . eventually . equal ( ptr ) ;
40
37
} ) ;
41
38
} ) ;
42
39
} ) ;
You can’t perform that action at this time.
0 commit comments