Skip to content

Commit

Permalink
Update TransferRestrictModule's moduleCheck to allow mint/burn when a…
Browse files Browse the repository at this point in the history
…ddress is null
  • Loading branch information
aliarbak committed Oct 18, 2024
1 parent f6b67a6 commit 59d2a32
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.
- Added **removeTimeTransferLimit** function to TimeTransferLimitsModule, allows removing time transfer limits for the given limitTime.
- Added **batchSetTimeTransferLimit** and **batchRemoveTimeTransferLimit** functions to TimeTransferLimitsModule, allows setting and removing multiple time transfer limits at once.

### Update

- Updated the **moduleCheck** function to directly allow transfers when the _from or _to address is the null address, enabling mint and burn operations without additional restrictions.

## [4.1.5]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ contract TransferRestrictModule is AbstractModuleUpgradeable {
uint256 /*_value*/,
address _compliance
) external view override returns (bool) {
if (_from == address(0) || _to == address(0)) {
return true;
}

if(_allowedUserAddresses[_compliance][_from]) {
return true;
}
Expand Down
32 changes: 32 additions & 0 deletions test/compliances/module-transfer-restrict.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,38 @@ describe('Compliance Module: TransferRestrict', () => {
expect(result).to.be.true;
});
});

describe('when sender is null address', () => {
it('should return true', async () => {
const context = await loadFixture(deployTransferRestrictFullSuite);
const to = context.accounts.anotherWallet.address;
const from = '0x0000000000000000000000000000000000000000';

await context.suite.compliance.callModuleFunction(
new ethers.utils.Interface(['function allowUser(address _userAddress)']).encodeFunctionData('allowUser', [from]),
context.suite.complianceModule.address,
);

const result = await context.suite.complianceModule.moduleCheck(from, to, 10, context.suite.compliance.address);
expect(result).to.be.true;
});
});

describe('when receiver is null address', () => {
it('should return true', async () => {
const context = await loadFixture(deployTransferRestrictFullSuite);
const to = '0x0000000000000000000000000000000000000000';
const from = context.accounts.anotherWallet.address;

await context.suite.compliance.callModuleFunction(
new ethers.utils.Interface(['function allowUser(address _userAddress)']).encodeFunctionData('allowUser', [from]),
context.suite.complianceModule.address,
);

const result = await context.suite.complianceModule.moduleCheck(from, to, 10, context.suite.compliance.address);
expect(result).to.be.true;
});
});
});

describe('.moduleMintAction', () => {
Expand Down

0 comments on commit 59d2a32

Please sign in to comment.