From 862862bd451f537496bfe0f3a061057a1240a570 Mon Sep 17 00:00:00 2001 From: Marc Doerflinger Date: Fri, 30 Aug 2024 12:20:02 +0000 Subject: [PATCH] restructure IDistribution.ReferralInfo (#650) --- README.md | 1 + .../distribution/DistributionService.sol | 20 +++++++++---------- contracts/instance/module/IDistribution.sol | 8 ++++++-- contracts/instance/module/IRisk.sol | 2 ++ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 31ed9a7a7..7ddb46a20 100644 --- a/README.md +++ b/README.md @@ -574,6 +574,7 @@ New structs must be added to `MockStorageLayout` to be included in analysis. | uint256 | 32 bytes | | uint128 | 16 bytes | | uint160 | 20 bytes | +| uint32 | 4 bytes | | uint16 | 2 bytes | | string | 32 bytes | | bytes | 32 bytes | diff --git a/contracts/distribution/DistributionService.sol b/contracts/distribution/DistributionService.sol index 614f629f3..5a0d22202 100644 --- a/contracts/distribution/DistributionService.sol +++ b/contracts/distribution/DistributionService.sol @@ -208,16 +208,16 @@ contract DistributionService is { referralId = ReferralLib.toReferralId(distributionNftId, code); - IDistribution.ReferralInfo memory info = IDistribution.ReferralInfo( - distributionNftId, - distributorNftId, - code, - discountPercentage, - maxReferrals, - 0, // used referrals - expiryAt, - data - ); + IDistribution.ReferralInfo memory info = IDistribution.ReferralInfo({ + distributionNftId: distributionNftId, + distributorNftId: distributorNftId, + referralCode: code, + discountPercentage: discountPercentage, + maxReferrals: maxReferrals, + usedReferrals: 0, + expiryAt: expiryAt, + data: data + }); instance.getInstanceStore().createReferral(referralId, info); } diff --git a/contracts/instance/module/IDistribution.sol b/contracts/instance/module/IDistribution.sol index 6ea419ceb..9f8701333 100644 --- a/contracts/instance/module/IDistribution.sol +++ b/contracts/instance/module/IDistribution.sol @@ -37,13 +37,17 @@ interface IDistribution { } struct ReferralInfo { + // slot 0 NftId distributionNftId; NftId distributorNftId; - string referralCode; - UFixed discountPercentage; uint32 maxReferrals; uint32 usedReferrals; + // slot 1 + UFixed discountPercentage; Timestamp expiryAt; + // slot 2 + string referralCode; + // slot 3 bytes data; } diff --git a/contracts/instance/module/IRisk.sol b/contracts/instance/module/IRisk.sol index 8717c391c..8f1ec37f2 100644 --- a/contracts/instance/module/IRisk.sol +++ b/contracts/instance/module/IRisk.sol @@ -7,8 +7,10 @@ import {Timestamp} from "../../type/Timestamp.sol"; interface IRisk { struct RiskInfo { + // slot 0 NftId productNftId; Timestamp createdAt; + // slot 1 bytes data; } }