Skip to content

Commit 71f7d06

Browse files
committed
test: update integration tests to use WIP
1 parent d285560 commit 71f7d06

7 files changed

+108
-105
lines changed

test/integration/BaseIntegration.t.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pragma solidity 0.8.26;
66
import { console2 } from "forge-std/console2.sol";
77
import { Script } from "forge-std/Script.sol";
88
import { Test } from "forge-std/Test.sol";
9-
import { SUSD } from "@storyprotocol/test/mocks/token/SUSD.sol";
9+
import { WIP } from "@wip/WIP.sol";
1010
import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
1111
import { AccessPermission } from "@storyprotocol/core/lib/AccessPermission.sol";
1212
import { IAccessController } from "@storyprotocol/core/interfaces/access/IAccessController.sol";
@@ -59,8 +59,8 @@ contract BaseIntegration is Test, Script, StoryProtocolCoreAddressManager, Story
5959
RoyaltyWorkflows internal royaltyWorkflows;
6060
RoyaltyTokenDistributionWorkflows internal royaltyTokenDistributionWorkflows;
6161

62-
/// @dev Story USD
63-
SUSD internal StoryUSD = SUSD(0xF2104833d386a2734a4eB3B8ad6FC6812F29E38E);
62+
/// @dev Wrapped IP token
63+
WIP internal wrappedIP = WIP(payable(0x1514000000000000000000000000000000000000));
6464

6565
/// @dev Test data
6666
string internal testCollectionName;
@@ -116,8 +116,8 @@ contract BaseIntegration is Test, Script, StoryProtocolCoreAddressManager, Story
116116
testBaseURI = "https://test.com/";
117117
testContractURI = "https://test-contract-uri.com/";
118118
testMaxSupply = 100_000;
119-
testMintFee = 10 * 10 ** StoryUSD.decimals(); // 10 SUSD
120-
testMintFeeToken = address(StoryUSD);
119+
testMintFee = 1 * 10 ** wrappedIP.decimals(); // 1 WIP
120+
testMintFeeToken = address(wrappedIP);
121121
testIpMetadata = WorkflowStructs.IPMetadata({
122122
ipMetadataURI: "test-ip-uri",
123123
ipMetadataHash: "test-ip-hash",

test/integration/workflows/DerivativeIntegration.t.sol

+20-20
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ contract DerivativeIntegration is BaseIntegration {
4545
private
4646
logTest("test_DerivativeIntegration_mintAndRegisterIpAndMakeDerivative")
4747
{
48-
StoryUSD.mint(testSender, testMintFee * 2);
49-
StoryUSD.approve(address(spgNftContract), testMintFee); // for nft minting fee
50-
StoryUSD.approve(derivativeWorkflowsAddr, testMintFee); // for derivative minting fee
48+
wrappedIP.deposit{ value: testMintFee * 2 }(); // wrapping native IP
49+
wrappedIP.approve(address(spgNftContract), testMintFee); // for nft minting fee
50+
wrappedIP.approve(derivativeWorkflowsAddr, testMintFee); // for derivative minting fee
5151
(address childIpId, uint256 childTokenId) = derivativeWorkflows.mintAndRegisterIpAndMakeDerivative({
5252
spgNftContract: address(spgNftContract),
5353
derivData: WorkflowStructs.MakeDerivative({
@@ -87,8 +87,8 @@ contract DerivativeIntegration is BaseIntegration {
8787
private
8888
logTest("test_DerivativeIntegration_registerIpAndMakeDerivative")
8989
{
90-
StoryUSD.mint(testSender, testMintFee);
91-
StoryUSD.approve(address(spgNftContract), testMintFee); // for nft minting fee
90+
wrappedIP.deposit{ value: testMintFee }();
91+
wrappedIP.approve(address(spgNftContract), testMintFee); // for nft minting fee
9292

9393
uint256 childTokenId = spgNftContract.mint({
9494
to: testSender,
@@ -112,8 +112,8 @@ contract DerivativeIntegration is BaseIntegration {
112112
signerSk: testSenderSk
113113
});
114114

115-
StoryUSD.mint(testSender, testMintFee);
116-
StoryUSD.approve(derivativeWorkflowsAddr, testMintFee); // for derivative minting fee
115+
wrappedIP.deposit{ value: testMintFee }();
116+
wrappedIP.approve(derivativeWorkflowsAddr, testMintFee); // for derivative minting fee
117117
derivativeWorkflows.registerIpAndMakeDerivative({
118118
nftContract: address(spgNftContract),
119119
tokenId: childTokenId,
@@ -157,8 +157,8 @@ contract DerivativeIntegration is BaseIntegration {
157157
private
158158
logTest("test_DerivativeIntegration_mintAndRegisterIpAndMakeDerivativeWithLicenseTokens")
159159
{
160-
StoryUSD.mint(testSender, testMintFee);
161-
StoryUSD.approve(royaltyModuleAddr, testMintFee); // for license token minting fee
160+
wrappedIP.deposit{ value: testMintFee }();
161+
wrappedIP.approve(royaltyModuleAddr, testMintFee); // for license token minting fee
162162
uint256 startLicenseTokenId = licensingModule.mintLicenseTokens({
163163
licensorIpId: parentIpIds[0],
164164
licenseTemplate: parentLicenseTemplate,
@@ -176,8 +176,8 @@ contract DerivativeIntegration is BaseIntegration {
176176
uint256[] memory licenseTokenIds = new uint256[](1);
177177
licenseTokenIds[0] = startLicenseTokenId;
178178

179-
StoryUSD.mint(testSender, testMintFee);
180-
StoryUSD.approve(address(spgNftContract), testMintFee); // for nft minting fee
179+
wrappedIP.deposit{ value: testMintFee }();
180+
wrappedIP.approve(address(spgNftContract), testMintFee); // for nft minting fee
181181
(address childIpId, uint256 childTokenId) = derivativeWorkflows
182182
.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens({
183183
spgNftContract: address(spgNftContract),
@@ -213,8 +213,8 @@ contract DerivativeIntegration is BaseIntegration {
213213
private
214214
logTest("test_DerivativeIntegration_registerIpAndMakeDerivativeWithLicenseTokens")
215215
{
216-
StoryUSD.mint(testSender, testMintFee);
217-
StoryUSD.approve(address(spgNftContract), testMintFee); // for nft minting fee
216+
wrappedIP.deposit{ value: testMintFee }();
217+
wrappedIP.approve(address(spgNftContract), testMintFee); // for nft minting fee
218218
uint256 childTokenId = spgNftContract.mint({
219219
to: testSender,
220220
nftMetadataURI: testIpMetadata.nftMetadataURI,
@@ -225,8 +225,8 @@ contract DerivativeIntegration is BaseIntegration {
225225

226226
uint256 deadline = block.timestamp + 1000;
227227

228-
StoryUSD.mint(testSender, testMintFee);
229-
StoryUSD.approve(royaltyModuleAddr, testMintFee); // for license token minting fee
228+
wrappedIP.deposit{ value: testMintFee }();
229+
wrappedIP.approve(royaltyModuleAddr, testMintFee); // for license token minting fee
230230
uint256 startLicenseTokenId = licensingModule.mintLicenseTokens({
231231
licensorIpId: parentIpIds[0],
232232
licenseTemplate: parentLicenseTemplate,
@@ -315,9 +315,9 @@ contract DerivativeIntegration is BaseIntegration {
315315
);
316316
}
317317

318-
StoryUSD.mint(testSender, testMintFee * numCalls * 2);
319-
StoryUSD.approve(address(spgNftContract), testMintFee * numCalls);
320-
StoryUSD.approve(derivativeWorkflowsAddr, testMintFee * numCalls);
318+
wrappedIP.deposit{ value: testMintFee * numCalls * 2 }();
319+
wrappedIP.approve(address(spgNftContract), testMintFee * numCalls);
320+
wrappedIP.approve(derivativeWorkflowsAddr, testMintFee * numCalls);
321321

322322
bytes[] memory results = derivativeWorkflows.multicall(data);
323323

@@ -385,8 +385,8 @@ contract DerivativeIntegration is BaseIntegration {
385385
})
386386
);
387387

388-
StoryUSD.mint(testSender, testMintFee);
389-
StoryUSD.approve(address(spgNftContract), testMintFee);
388+
wrappedIP.deposit{ value: testMintFee }();
389+
wrappedIP.approve(address(spgNftContract), testMintFee);
390390
address parentIpId;
391391
(parentIpId, , parentLicenseTermIds) = licenseAttachmentWorkflows.mintAndRegisterIpAndAttachPILTerms({
392392
spgNftContract: address(spgNftContract),

test/integration/workflows/GroupingIntegration.t.sol

+30-27
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ contract GroupingIntegration is BaseIntegration {
6666
signerSk: testSenderSk
6767
});
6868

69-
StoryUSD.mint(testSender, testMintFee);
70-
StoryUSD.approve(address(spgNftContract), testMintFee);
69+
wrappedIP.deposit{ value: testMintFee }();
70+
wrappedIP.approve(address(spgNftContract), testMintFee);
7171
(address ipId, uint256 tokenId) = groupingWorkflows.mintAndRegisterIpAndAttachLicenseAndAddToGroup({
7272
spgNftContract: address(spgNftContract),
7373
groupId: groupId,
@@ -99,8 +99,8 @@ contract GroupingIntegration is BaseIntegration {
9999
private
100100
logTest("test_GroupingIntegration_registerIpAndAttachLicenseAndAddToGroup")
101101
{
102-
StoryUSD.mint(testSender, testMintFee);
103-
StoryUSD.approve(address(spgNftContract), testMintFee);
102+
wrappedIP.deposit{ value: testMintFee }();
103+
wrappedIP.approve(address(spgNftContract), testMintFee);
104104
uint256 tokenId = spgNftContract.mint({
105105
to: testSender,
106106
nftMetadataURI: testIpMetadata.nftMetadataURI,
@@ -228,8 +228,8 @@ contract GroupingIntegration is BaseIntegration {
228228
uint256[] memory licenseTermsIds = new uint256[](1);
229229
licenseTermsIds[0] = testLicensesData[0].licenseTermsId;
230230

231-
StoryUSD.mint(testSender, testMintFee);
232-
StoryUSD.approve(address(spgNftContract), testMintFee);
231+
wrappedIP.deposit{ value: testMintFee }();
232+
wrappedIP.approve(address(spgNftContract), testMintFee);
233233
(address ipId1, ) = derivativeWorkflows.mintAndRegisterIpAndMakeDerivative({
234234
spgNftContract: address(spgNftContract),
235235
derivData: WorkflowStructs.MakeDerivative({
@@ -246,8 +246,8 @@ contract GroupingIntegration is BaseIntegration {
246246
allowDuplicates: true
247247
});
248248

249-
StoryUSD.mint(testSender, testMintFee);
250-
StoryUSD.approve(address(spgNftContract), testMintFee);
249+
wrappedIP.deposit{ value: testMintFee }();
250+
wrappedIP.approve(address(spgNftContract), testMintFee);
251251
(address ipId2, ) = derivativeWorkflows.mintAndRegisterIpAndMakeDerivative({
252252
spgNftContract: address(spgNftContract),
253253
derivData: WorkflowStructs.MakeDerivative({
@@ -264,20 +264,20 @@ contract GroupingIntegration is BaseIntegration {
264264
allowDuplicates: true
265265
});
266266

267-
uint256 amount1 = 1_000 * 10 ** StoryUSD.decimals(); // 1,000 tokens
268-
StoryUSD.mint(testSender, amount1);
269-
StoryUSD.approve(address(royaltyModule), amount1);
270-
royaltyModule.payRoyaltyOnBehalf(ipId1, testSender, address(StoryUSD), amount1);
271-
IGraphAwareRoyaltyPolicy(royaltyPolicyLRPAddr).transferToVault(ipId1, newGroupId, address(StoryUSD));
267+
uint256 amount1 = 1 * 10 ** wrappedIP.decimals(); // 1 token
268+
wrappedIP.deposit{ value: amount1 }();
269+
wrappedIP.approve(address(royaltyModule), amount1);
270+
royaltyModule.payRoyaltyOnBehalf(ipId1, testSender, address(wrappedIP), amount1);
271+
IGraphAwareRoyaltyPolicy(royaltyPolicyLRPAddr).transferToVault(ipId1, newGroupId, address(wrappedIP));
272272

273-
uint256 amount2 = 10_000 * 10 ** StoryUSD.decimals(); // 10,000 tokens
274-
StoryUSD.mint(testSender, amount2);
275-
StoryUSD.approve(address(royaltyModule), amount2);
276-
royaltyModule.payRoyaltyOnBehalf(ipId2, testSender, address(StoryUSD), amount2);
277-
IGraphAwareRoyaltyPolicy(royaltyPolicyLRPAddr).transferToVault(ipId2, newGroupId, address(StoryUSD));
273+
uint256 amount2 = 2 * 10 ** wrappedIP.decimals(); // 2 tokens
274+
wrappedIP.deposit{ value: amount2 }();
275+
wrappedIP.approve(address(royaltyModule), amount2);
276+
royaltyModule.payRoyaltyOnBehalf(ipId2, testSender, address(wrappedIP), amount2);
277+
IGraphAwareRoyaltyPolicy(royaltyPolicyLRPAddr).transferToVault(ipId2, newGroupId, address(wrappedIP));
278278

279279
address[] memory royaltyTokens = new address[](1);
280-
royaltyTokens[0] = address(StoryUSD);
280+
royaltyTokens[0] = address(wrappedIP);
281281

282282
uint256[] memory collectedRoyalties = groupingWorkflows.collectRoyaltiesAndClaimReward(
283283
newGroupId,
@@ -293,7 +293,10 @@ contract GroupingIntegration is BaseIntegration {
293293

294294
// check each member IP received the reward in their IP royalty vault
295295
for (uint256 i = 0; i < ipIds.length; i++) {
296-
assertEq(StoryUSD.balanceOf(royaltyModule.ipRoyaltyVaults(ipIds[i])), collectedRoyalties[0] / ipIds.length);
296+
assertEq(
297+
wrappedIP.balanceOf(royaltyModule.ipRoyaltyVaults(ipIds[i])),
298+
collectedRoyalties[0] / ipIds.length
299+
);
297300
}
298301
}
299302

@@ -338,8 +341,8 @@ contract GroupingIntegration is BaseIntegration {
338341
);
339342
}
340343

341-
StoryUSD.mint(testSender, testMintFee * numCalls);
342-
StoryUSD.approve(address(spgNftContract), testMintFee * numCalls);
344+
wrappedIP.deposit{ value: testMintFee * numCalls }();
345+
wrappedIP.approve(address(spgNftContract), testMintFee * numCalls);
343346

344347
// batch call `mintAndRegisterIpAndAttachLicenseAndAddToGroup`
345348
bytes[] memory results = groupingWorkflows.multicall(data);
@@ -367,8 +370,8 @@ contract GroupingIntegration is BaseIntegration {
367370
{
368371
uint256 numCalls = 10;
369372

370-
StoryUSD.mint(testSender, testMintFee * numCalls);
371-
StoryUSD.approve(address(spgNftContract), testMintFee * numCalls);
373+
wrappedIP.deposit{ value: testMintFee * numCalls }();
374+
wrappedIP.approve(address(spgNftContract), testMintFee * numCalls);
372375
// mint a NFT from the spgNftContract
373376
uint256[] memory tokenIds = new uint256[](numCalls);
374377
for (uint256 i = 0; i < numCalls; i++) {
@@ -474,7 +477,7 @@ contract GroupingIntegration is BaseIntegration {
474477
mintingFee: 0,
475478
commercialRevShare: revShare,
476479
royaltyPolicy: royaltyPolicyLRPAddr,
477-
currencyToken: address(StoryUSD)
480+
currencyToken: address(wrappedIP)
478481
})
479482
),
480483
licensingConfig: Licensing.LicensingConfig({
@@ -549,8 +552,8 @@ contract GroupingIntegration is BaseIntegration {
549552
);
550553
}
551554

552-
StoryUSD.mint(testSender, testMintFee * numIps);
553-
StoryUSD.approve(address(spgNftContract), testMintFee * numIps);
555+
wrappedIP.deposit{ value: testMintFee * numIps }();
556+
wrappedIP.approve(address(spgNftContract), testMintFee * numIps);
554557

555558
// batch call `mintAndRegisterIp`
556559
bytes[] memory results = registrationWorkflows.multicall(data);

test/integration/workflows/LicenseAttachmentIntegration.t.sol

+12-12
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ contract LicenseAttachmentIntegration is BaseIntegration {
3939
private
4040
logTest("test_LicenseAttachmentIntegration_registerPILTermsAndAttach")
4141
{
42-
StoryUSD.mint(testSender, testMintFee);
43-
StoryUSD.approve(address(spgNftContract), testMintFee);
42+
wrappedIP.deposit{ value: testMintFee }();
43+
wrappedIP.approve(address(spgNftContract), testMintFee);
4444

4545
(address ipId, ) = registrationWorkflows.mintAndRegisterIp({
4646
spgNftContract: address(spgNftContract),
@@ -79,8 +79,8 @@ contract LicenseAttachmentIntegration is BaseIntegration {
7979
{
8080
// IP 1
8181
{
82-
StoryUSD.mint(testSender, testMintFee);
83-
StoryUSD.approve(address(spgNftContract), testMintFee);
82+
wrappedIP.deposit{ value: testMintFee }();
83+
wrappedIP.approve(address(spgNftContract), testMintFee);
8484

8585
(address ipId1, uint256 tokenId1, uint256[] memory licenseTermsIds1) = licenseAttachmentWorkflows
8686
.mintAndRegisterIpAndAttachPILTerms({
@@ -104,8 +104,8 @@ contract LicenseAttachmentIntegration is BaseIntegration {
104104

105105
// IP 2
106106
{
107-
StoryUSD.mint(testSender, testMintFee);
108-
StoryUSD.approve(address(spgNftContract), testMintFee);
107+
wrappedIP.deposit{ value: testMintFee }();
108+
wrappedIP.approve(address(spgNftContract), testMintFee);
109109

110110
(address ipId2, uint256 tokenId2, uint256[] memory licenseTermsIds2) = licenseAttachmentWorkflows
111111
.mintAndRegisterIpAndAttachPILTerms({
@@ -132,8 +132,8 @@ contract LicenseAttachmentIntegration is BaseIntegration {
132132
private
133133
logTest("test_LicenseAttachmentIntegration_registerIpAndAttachPILTerms")
134134
{
135-
StoryUSD.mint(testSender, testMintFee);
136-
StoryUSD.approve(address(spgNftContract), testMintFee);
135+
wrappedIP.deposit{ value: testMintFee }();
136+
wrappedIP.approve(address(spgNftContract), testMintFee);
137137

138138
uint256 tokenId = spgNftContract.mint({
139139
to: testSender,
@@ -186,8 +186,8 @@ contract LicenseAttachmentIntegration is BaseIntegration {
186186
private
187187
logTest("test_LicenseAttachmentWorkflows_mintAndRegisterIpAndAttachDefaultTerms")
188188
{
189-
StoryUSD.mint(testSender, testMintFee);
190-
StoryUSD.approve(address(spgNftContract), testMintFee);
189+
wrappedIP.deposit{ value: testMintFee }();
190+
wrappedIP.approve(address(spgNftContract), testMintFee);
191191

192192
(address ipId1, uint256 tokenId1) = licenseAttachmentWorkflows.mintAndRegisterIpAndAttachDefaultTerms({
193193
spgNftContract: address(spgNftContract),
@@ -210,8 +210,8 @@ contract LicenseAttachmentIntegration is BaseIntegration {
210210
private
211211
logTest("test_LicenseAttachmentWorkflows_registerIpAndAttachDefaultTerms")
212212
{
213-
StoryUSD.mint(testSender, testMintFee);
214-
StoryUSD.approve(address(spgNftContract), testMintFee);
213+
wrappedIP.deposit{ value: testMintFee }();
214+
wrappedIP.approve(address(spgNftContract), testMintFee);
215215

216216
uint256 tokenId = spgNftContract.mint({
217217
to: testSender,

test/integration/workflows/RegistrationIntegration.t.sol

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ contract RegistrationIntegration is BaseIntegration {
7474
private
7575
logTest("test_RegistrationIntegration_mintAndRegisterIp")
7676
{
77-
StoryUSD.mint(testSender, testMintFee);
78-
StoryUSD.approve(address(spgNftContract), testMintFee);
77+
wrappedIP.deposit{ value: testMintFee }();
78+
wrappedIP.approve(address(spgNftContract), testMintFee);
7979
(address ipId, uint256 tokenId) = registrationWorkflows.mintAndRegisterIp({
8080
spgNftContract: address(spgNftContract),
8181
recipient: testSender,
@@ -90,8 +90,8 @@ contract RegistrationIntegration is BaseIntegration {
9090
}
9191

9292
function _test_RegistrationIntegration_registerIp() private logTest("test_RegistrationIntegration_registerIp") {
93-
StoryUSD.mint(testSender, testMintFee);
94-
StoryUSD.approve(address(spgNftContract), testMintFee);
93+
wrappedIP.deposit{ value: testMintFee }();
94+
wrappedIP.approve(address(spgNftContract), testMintFee);
9595
uint256 tokenId = spgNftContract.mint(testSender, "", bytes32(0), true);
9696

9797
// get signature for setting IP metadata
@@ -176,8 +176,8 @@ contract RegistrationIntegration is BaseIntegration {
176176
logTest("test_RegistrationIntegration_multicall_mintAndRegisterIp")
177177
{
178178
uint256 totalIps = 10;
179-
StoryUSD.mint(testSender, testMintFee * totalIps);
180-
StoryUSD.approve(address(spgNftContract), testMintFee * totalIps);
179+
wrappedIP.deposit{ value: testMintFee * totalIps }();
180+
wrappedIP.approve(address(spgNftContract), testMintFee * totalIps);
181181

182182
bytes[] memory data = new bytes[](totalIps);
183183
for (uint256 i = 0; i < totalIps; i++) {

0 commit comments

Comments
 (0)