Skip to content

Commit 05a2890

Browse files
committed
minimize
1 parent e5e9103 commit 05a2890

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

contracts/utils/Memory.sol

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,4 @@ library Memory {
4141
function asPointer(bytes32 value) internal pure returns (Pointer) {
4242
return Pointer.wrap(value);
4343
}
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-
}
6044
}

test/utils/Memory.test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
44

55
async function fixture() {
66
const mock = await ethers.deployContract('$Memory');
7-
87
return { mock };
98
}
109

@@ -27,16 +26,14 @@ describe('Memory', function () {
2726
});
2827

2928
describe('pointer conversions', function () {
30-
it('asBytes32 / asPointer', async function () {
29+
it('asBytes32', async function () {
3130
const ptr = ethers.toBeHex('0x1234', 32);
3231
await expect(this.mock.$asBytes32(ptr)).to.eventually.equal(ptr);
33-
await expect(this.mock.$asPointer(ethers.Typed.bytes32(ptr))).to.eventually.equal(ptr);
3432
});
3533

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);
4037
});
4138
});
4239
});

0 commit comments

Comments
 (0)