|
9 | 9 | encodeDelegate,
|
10 | 10 | CALL_TYPE_CALL,
|
11 | 11 | CALL_TYPE_BATCH,
|
| 12 | + CALL_TYPE_DELEGATE, |
12 | 13 | encodeMode,
|
13 | 14 | } = require('../../helpers/erc7579');
|
14 | 15 | const { selector } = require('../../helpers/methods');
|
@@ -54,6 +55,18 @@ describe('ERC7579Utils', function () {
|
54 | 55 | await expect(ethers.provider.getBalance(this.target)).to.eventually.equal(value);
|
55 | 56 | });
|
56 | 57 |
|
| 58 | + it('default to calling self is target is address(0) (ERC-7821 calldata compression)', async function () { |
| 59 | + const data = encodeSingle( |
| 60 | + ethers.ZeroAddress, // address(0) |
| 61 | + 0, |
| 62 | + this.utils.interface.encodeFunctionData('$CALLTYPE_SINGLE', []), |
| 63 | + ); |
| 64 | + |
| 65 | + await expect(this.utils.$execSingle(data, EXEC_TYPE_DEFAULT)) |
| 66 | + .to.emit(this.utils, 'return$execSingle') |
| 67 | + .withArgs([ethers.zeroPadBytes(CALL_TYPE_CALL, 32)]); |
| 68 | + }); |
| 69 | + |
57 | 70 | it('reverts when target reverts in default ExecType', async function () {
|
58 | 71 | const value = 0x012;
|
59 | 72 | const data = encodeSingle(
|
@@ -131,6 +144,17 @@ describe('ERC7579Utils', function () {
|
131 | 144 | await expect(ethers.provider.getBalance(this.anotherTarget)).to.eventually.equal(value2);
|
132 | 145 | });
|
133 | 146 |
|
| 147 | + it('default to calling self is target is address(0) (ERC-7821 calldata compression)', async function () { |
| 148 | + const data = encodeBatch( |
| 149 | + [ethers.ZeroAddress, 0, this.utils.interface.encodeFunctionData('$CALLTYPE_SINGLE', [])], |
| 150 | + [ethers.ZeroAddress, 0, this.utils.interface.encodeFunctionData('$CALLTYPE_BATCH', [])], |
| 151 | + ); |
| 152 | + |
| 153 | + await expect(this.utils.$execBatch(data, EXEC_TYPE_DEFAULT)) |
| 154 | + .to.emit(this.utils, 'return$execBatch') |
| 155 | + .withArgs([ethers.zeroPadBytes(CALL_TYPE_CALL, 32), ethers.zeroPadBytes(CALL_TYPE_BATCH, 32)]); |
| 156 | + }); |
| 157 | + |
134 | 158 | it('reverts when any target reverts in default ExecType', async function () {
|
135 | 159 | const value1 = 0x012;
|
136 | 160 | const value2 = 0x234;
|
@@ -193,6 +217,17 @@ describe('ERC7579Utils', function () {
|
193 | 217 | await expect(ethers.provider.getStorage(this.utils.target, slot)).to.eventually.equal(value);
|
194 | 218 | });
|
195 | 219 |
|
| 220 | + it('default to calling self is target is address(0) (ERC-7821 calldata compression)', async function () { |
| 221 | + const data = encodeDelegate( |
| 222 | + ethers.ZeroAddress, |
| 223 | + this.utils.interface.encodeFunctionData('$CALLTYPE_DELEGATECALL', []), |
| 224 | + ); |
| 225 | + |
| 226 | + await expect(this.utils.$execDelegateCall(data, EXEC_TYPE_DEFAULT)) |
| 227 | + .to.emit(this.utils, 'return$execDelegateCall') |
| 228 | + .withArgs([ethers.zeroPadBytes(CALL_TYPE_DELEGATE, 32)]); |
| 229 | + }); |
| 230 | + |
196 | 231 | it('reverts when target reverts in default ExecType', async function () {
|
197 | 232 | const data = encodeDelegate(this.target, this.target.interface.encodeFunctionData('mockFunctionRevertsReason'));
|
198 | 233 | await expect(this.utils.$execDelegateCall(data, EXEC_TYPE_DEFAULT)).to.be.revertedWith(
|
|
0 commit comments