Skip to content

Commit 19ed1d3

Browse files
committed
All test pass, several broken typings yet.
1 parent e70b541 commit 19ed1d3

23 files changed

+2257
-2123
lines changed

contracts/mocks/OwnableMintableERC721Mock.sol

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ pragma solidity ^0.8.21;
55
/// @dev This mock smart contract is intended to be used with `@defi-wonderland/smock` and doesn't need any business
66
/// logic.
77
contract OwnableMintableERC721Mock {
8-
function owner() public pure returns (address) {
9-
return address(0);
8+
9+
address private _mockOwner;
10+
address private _mockOwnerOf;
11+
12+
constructor (
13+
address mockOwner, address mockOwnerOf
14+
) {
15+
_mockOwner = mockOwner;
16+
_mockOwnerOf = mockOwnerOf;
17+
}
18+
19+
function owner() public view returns (address) {
20+
return _mockOwner;
1021
}
1122

12-
function ownerOf(uint256) public pure returns (address) {
13-
return address(0);
23+
function ownerOf(uint256) public view returns (address) {
24+
return _mockOwnerOf;
1425
}
1526
}

test/behavior/catalog.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ async function shouldBehaveLikeCatalog(contractName: string, metadataURI: string
1010
let addrs: SignerWithAddress[];
1111
const metadataUriDefault = 'src';
1212

13-
const noType = 0;
14-
const slotType = 1;
15-
const fixedType = 2;
13+
const noType = 0n;
14+
const slotType = 1n;
15+
const fixedType = 2n;
1616

1717
const sampleSlotPartData = {
1818
itemType: slotType,
@@ -64,13 +64,13 @@ async function shouldBehaveLikeCatalog(contractName: string, metadataURI: string
6464
const partId = 1;
6565

6666
await testCatalog.addPart({ partId: partId, part: sampleFixedPartData });
67-
expect(await testCatalog.getPart(partId)).to.eql([2, 0, [], metadataUriDefault]);
67+
expect(await testCatalog.getPart(partId)).to.eql([2n, 0n, [], metadataUriDefault]);
6868
});
6969

7070
it('can add slot part', async function () {
7171
const partId = 2;
7272
await testCatalog.addPart({ partId: partId, part: sampleSlotPartData });
73-
expect(await testCatalog.getPart(partId)).to.eql([1, 0, [], metadataUriDefault]);
73+
expect(await testCatalog.getPart(partId)).to.eql([1n, 0n, [], metadataUriDefault]);
7474
});
7575

7676
it('can add parts list', async function () {
@@ -93,8 +93,8 @@ async function shouldBehaveLikeCatalog(contractName: string, metadataURI: string
9393
{ partId: partId2, part: partData2 },
9494
]);
9595
expect(await testCatalog.getParts([partId, partId2])).to.eql([
96-
[slotType, 0, [], 'src1'],
97-
[fixedType, 1, [], 'src2'],
96+
[slotType, 0n, [], 'src1'],
97+
[fixedType, 1n, [], 'src2'],
9898
]);
9999
});
100100

@@ -249,7 +249,7 @@ async function shouldBehaveLikeCatalog(contractName: string, metadataURI: string
249249
await testCatalog.setEquippableToAll(partId);
250250

251251
// This should reset it:
252-
testCatalog.setEquippableAddresses(partId, [addrs[1].address]);
252+
await testCatalog.setEquippableAddresses(partId, [addrs[1].address]);
253253
expect(await testCatalog.checkIsEquippableToAll(partId)).to.eql(false);
254254
});
255255

test/behavior/equippableAssets.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ async function shouldBehaveLikeEquippableAssets(
338338
.withArgs(tokenId, resId2, resId);
339339

340340
expect(await chunkyEquip.getActiveAssets(tokenId)).to.be.eql([resId2]);
341-
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([bn(0)]);
341+
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([0n]);
342342

343343
// Replacements should be gone
344-
expect(await chunkyEquip.getAssetReplacements(tokenId, resId2)).to.eql(bn(0));
344+
expect(await chunkyEquip.getAssetReplacements(tokenId, resId2)).to.eql(0n);
345345
});
346346

347347
it('can replace non existing asset to token, it could have been deleted', async function () {
@@ -352,7 +352,7 @@ async function shouldBehaveLikeEquippableAssets(
352352
await chunkyEquip.acceptAsset(tokenId, 0, resId);
353353

354354
expect(await chunkyEquip.getActiveAssets(tokenId)).to.be.eql([resId]);
355-
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.eql([bn(0)]);
355+
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.eql([0n]);
356356
});
357357
});
358358

@@ -384,7 +384,7 @@ async function shouldBehaveLikeEquippableAssets(
384384
await chunkyEquip.addAssetToToken(tokenId, resId2, resId);
385385
await chunkyEquip.rejectAsset(tokenId, 0, resId2);
386386

387-
expect(await chunkyEquip.getAssetReplacements(tokenId, resId2)).to.eql(bn(0));
387+
expect(await chunkyEquip.getAssetReplacements(tokenId, resId2)).to.eql(0n);
388388
});
389389

390390
it('can reject asset if approved', async function () {
@@ -429,7 +429,7 @@ async function shouldBehaveLikeEquippableAssets(
429429
await chunkyEquip.addAssetToToken(tokenId, resId2, resId);
430430
await chunkyEquip.rejectAllAssets(tokenId, 1);
431431

432-
expect(await chunkyEquip.getAssetReplacements(tokenId, resId2)).to.eql(bn(0));
432+
expect(await chunkyEquip.getAssetReplacements(tokenId, resId2)).to.eql(0n);
433433
});
434434

435435
it('can reject all pending assets at max capacity', async function () {
@@ -446,7 +446,7 @@ async function shouldBehaveLikeEquippableAssets(
446446
}
447447
await chunkyEquip.rejectAllAssets(tokenId, 128);
448448

449-
expect(await chunkyEquip.getAssetReplacements(1, 2)).to.eql(bn(0));
449+
expect(await chunkyEquip.getAssetReplacements(1, 2)).to.eql(0n);
450450
});
451451

452452
it('can reject all assets if approved', async function () {
@@ -509,11 +509,11 @@ async function shouldBehaveLikeEquippableAssets(
509509
it('can set and get priorities', async function () {
510510
const tokenId = await addAssetsToToken();
511511

512-
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([bn(0), bn(1)]);
512+
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([0n, bn(1)]);
513513
await expect(chunkyEquip.setPriority(tokenId, [1, 0]))
514514
.to.emit(chunkyEquip, 'AssetPrioritySet')
515515
.withArgs(tokenId);
516-
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), bn(0)]);
516+
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), 0n]);
517517
});
518518

519519
it('can set and get priorities if approved', async function () {
@@ -522,11 +522,11 @@ async function shouldBehaveLikeEquippableAssets(
522522

523523
await chunkyEquip.approveForAssets(await approvedAddress.getAddress(), tokenId);
524524

525-
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([bn(0), bn(1)]);
525+
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([0n, bn(1)]);
526526
await expect(chunkyEquip.connect(approvedAddress).setPriority(tokenId, [1, 0]))
527527
.to.emit(chunkyEquip, 'AssetPrioritySet')
528528
.withArgs(tokenId);
529-
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), bn(0)]);
529+
expect(await chunkyEquip.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), 0n]);
530530
});
531531

532532
it('cannot set priorities for non owned token', async function () {

test/behavior/equippableParts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async function shouldBehaveLikeEquippableWithParts() {
131131
);
132132
expect(allAssets).to.eql([
133133
'ipfs:neonRes/1', // metadataURI
134-
bn(0), // equippableGroupId
134+
0n, // equippableGroupId
135135
await catalogContract.getAddress(), // catalogAddress,
136136
expectedFixedParts,
137137
expectedSlotParts,

test/behavior/equippableSlots.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async function shouldBehaveLikeEquippableWithSlots(
237237
});
238238

239239
it('cannot set a valid equippable group with part id 0', async function () {
240-
const equippableGroupId = 1;
240+
const equippableGroupId = 1n;
241241
const partId = 0;
242242
// The malicious child indicates it can be equipped into soldier:
243243
await expect(
@@ -610,15 +610,15 @@ async function shouldBehaveLikeEquippableWithSlots(
610610
const expectedFixedParts = [
611611
[
612612
bn(partIdForBody), // partId
613-
1, // z
613+
1n, // z
614614
'genericBody.png', // metadataURI
615615
],
616616
];
617617
const expectedSlotParts = [
618618
[
619619
bn(partIdForWeapon), // partId
620620
bn(weaponAssetsEquip[0]), // childAssetId
621-
2, // z
621+
2n, // z
622622
await weapon.getAddress(), // childAddress
623623
weaponsIds[0], // childTokenId
624624
'ipfs:weapon/equip/5', // childAssetMetadata
@@ -627,10 +627,10 @@ async function shouldBehaveLikeEquippableWithSlots(
627627
[
628628
// Nothing on equipped on background slot:
629629
bn(partIdForBackground), // partId
630-
bn(0), // childAssetId
631-
0, // z
630+
0n, // childAssetId
631+
0n, // z
632632
ethers.ZeroAddress, // childAddress
633-
bn(0), // childTokenId
633+
0n, // childTokenId
634634
'', // childAssetMetadata
635635
'noBackground.png', // partMetadata
636636
],
@@ -642,7 +642,7 @@ async function shouldBehaveLikeEquippableWithSlots(
642642
);
643643
expect(allAssets).to.eql([
644644
'ipfs:soldier/', // metadataURI
645-
bn(0), // equippableGroupId
645+
0n, // equippableGroupId
646646
await catalog.getAddress(), // catalogAddress
647647
expectedFixedParts,
648648
expectedSlotParts,
@@ -683,8 +683,8 @@ async function shouldBehaveLikeEquippableWithSlots(
683683
[
684684
expectedSlots,
685685
[
686-
[bn(0), bn(0), bn(0), ethers.ZeroAddress],
687-
[bn(0), bn(0), bn(0), ethers.ZeroAddress],
686+
[0n, 0n, 0n, ethers.ZeroAddress],
687+
[0n, 0n, 0n, ethers.ZeroAddress],
688688
],
689689
['', ''],
690690
],
@@ -708,7 +708,7 @@ async function shouldBehaveLikeEquippableWithSlots(
708708
// If a slot has nothing equipped, it returns an empty equip:
709709
const expectedEquips = [
710710
[bn(soldierResId), bn(weaponResId), weaponsIds[0], await weapon.getAddress()],
711-
[bn(0), bn(0), bn(0), ethers.ZeroAddress],
711+
[0n, 0n, 0n, ethers.ZeroAddress],
712712
];
713713
const expectedMetadata = ['ipfs:weapon/equip/5', ''];
714714
expect(await view.getEquipped(await soldier.getAddress(), soldiersIds[0], soldierResId)).to.eql(
@@ -736,8 +736,8 @@ async function shouldBehaveLikeEquippableWithSlots(
736736
const expectedSlots = [bn(partIdForWeapon), bn(partIdForBackground)];
737737
// If a slot has nothing equipped, it returns an empty equip:
738738
const expectedEquips = [
739-
[bn(0), bn(0), bn(0), ethers.ZeroAddress],
740-
[bn(0), bn(0), bn(0), ethers.ZeroAddress],
739+
[0n, 0n, 0n, ethers.ZeroAddress],
740+
[0n, 0n, 0n, ethers.ZeroAddress],
741741
];
742742
const expectedMetadata = ['', ''];
743743
expect(await view.getEquipped(await soldier.getAddress(), soldiersIds[0], soldierResId)).to.eql(

test/behavior/erc721.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ethers } from 'hardhat';
33
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers';
44
import { Contract, ContractTransaction } from 'ethers';
55
import { bn } from '../utils';
6+
import { RMRKNestableLazyMintErc20 } from '../../typechain-types';
67

78
// Based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/test/token/ERC721/ERC721.behavior.js
89

@@ -58,7 +59,7 @@ async function shouldBehaveLikeERC721(name: string, symbol: string) {
5859

5960
context('when the given address does not own any tokens', function () {
6061
it('returns 0', async function () {
61-
expect(await this.token.balanceOf(others[0].address)).to.eql(bn(0));
62+
expect(await this.token.balanceOf(others[0].address)).to.eql(0n);
6263
});
6364
});
6465

@@ -225,7 +226,7 @@ async function shouldBehaveLikeERC721(name: string, symbol: string) {
225226
context('when the sender is not authorized for the token id', function () {
226227
it('reverts', async function () {
227228
// Standard ERC721 will use the latter. Every Nestable would have it defined and use it instead
228-
const error = this.token.interface.errors['RMRKNotApprovedOrDirectOwner()']
229+
const error = this.token.interface.getError('RMRKNotApprovedOrDirectOwner()')
229230
? 'RMRKNotApprovedOrDirectOwner'
230231
: 'ERC721NotApprovedOrOwner';
231232
await expect(

test/behavior/mintingImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function shouldControlValidMinting(): Promise<void> {
1212
});
1313

1414
it('cannot mint under price', async function () {
15-
const HALF_ETH = ethers.parseEther('0.05');
15+
const HALF_ETH = ONE_ETH / 2n;
1616
await expect(
1717
this.token.mint(addrs[0].address, 1, { value: HALF_ETH }),
1818
).to.be.revertedWithCustomError(this.token, 'RMRKWrongValueSent');

test/behavior/multiasset.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ async function shouldBehaveLikeMultiAsset(
145145
.withArgs(tokenId, resId3, resId2);
146146

147147
expect(await this.token.getActiveAssets(tokenId)).to.be.eql([resId, resId3]);
148-
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(0), bn(1)]);
148+
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([0n, bn(1)]);
149149

150150
// Replacements should be gone
151-
expect(await this.token.getAssetReplacements(tokenId, resId3)).to.eql(bn(0));
151+
expect(await this.token.getAssetReplacements(tokenId, resId3)).to.eql(0n);
152152
});
153153

154154
it('can replace non existing asset to token, it could have been deleted', async function () {
@@ -158,7 +158,7 @@ async function shouldBehaveLikeMultiAsset(
158158
await this.token.connect(tokenOwner).acceptAsset(tokenId, 0, resId);
159159

160160
expect(await this.token.getActiveAssets(tokenId)).to.be.eql([resId]);
161-
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(0)]);
161+
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([0n]);
162162
});
163163

164164
it('can reject asset and replacements are cleared', async function () {
@@ -170,7 +170,7 @@ async function shouldBehaveLikeMultiAsset(
170170
await addAssetToTokenFunc(this.token, tokenId, resId2, resId);
171171
await this.token.connect(tokenOwner).rejectAsset(tokenId, 0, resId2);
172172

173-
expect(await this.token.getAssetReplacements(tokenId, resId2)).to.eql(bn(0));
173+
expect(await this.token.getAssetReplacements(tokenId, resId2)).to.eql(0n);
174174
});
175175

176176
it('can reject all assets and replacements are cleared', async function () {
@@ -182,7 +182,7 @@ async function shouldBehaveLikeMultiAsset(
182182
await addAssetToTokenFunc(this.token, tokenId, resId2, resId);
183183
await this.token.connect(tokenOwner).rejectAllAssets(tokenId, 1);
184184

185-
expect(await this.token.getAssetReplacements(tokenId, resId2)).to.eql(bn(0));
185+
expect(await this.token.getAssetReplacements(tokenId, resId2)).to.eql(0n);
186186
});
187187
});
188188
});
@@ -207,8 +207,8 @@ async function shouldBehaveLikeMultiAsset(
207207
expect(
208208
await this.renderUtils.getPendingAssets(await this.token.getAddress(), tokenId),
209209
).to.eql([
210-
[resId1, bn(0), bn(0), resData1],
211-
[resId2, bn(1), bn(0), resData2],
210+
[resId1, 0n, 0n, resData1],
211+
[resId2, bn(1), 0n, resData2],
212212
]);
213213

214214
await expect(this.token.connect(tokenOwner).acceptAsset(tokenId, 0, resId1))
@@ -217,7 +217,7 @@ async function shouldBehaveLikeMultiAsset(
217217

218218
expect(
219219
await this.renderUtils.getPendingAssets(await this.token.getAddress(), tokenId),
220-
).to.eql([[resId2, bn(0), bn(0), resData2]]);
220+
).to.eql([[resId2, 0n, 0n, resData2]]);
221221
expect(await this.token.getActiveAssets(tokenId)).to.be.eql([resId1]);
222222
expect(await this.token.getAssetMetadata(tokenId, resId1)).equal(resData1);
223223
});
@@ -384,12 +384,12 @@ async function shouldBehaveLikeMultiAsset(
384384

385385
describe('Priorities', async function () {
386386
it('can set and get priorities', async function () {
387-
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(0), bn(1)]);
387+
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([0n, bn(1)]);
388388

389389
await expect(this.token.connect(tokenOwner).setPriority(tokenId, [1, 0]))
390390
.to.emit(this.token, 'AssetPrioritySet')
391391
.withArgs(tokenId);
392-
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), bn(0)]);
392+
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), 0n]);
393393
});
394394

395395
it('can set and get priorities if approved', async function () {
@@ -400,19 +400,19 @@ async function shouldBehaveLikeMultiAsset(
400400
await expect(this.token.connect(approved).setPriority(tokenId, [1, 0]))
401401
.to.emit(this.token, 'AssetPrioritySet')
402402
.withArgs(tokenId);
403-
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), bn(0)]);
403+
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), 0n]);
404404
});
405405

406406
it('can set and get priorities if approved for all', async function () {
407407
await this.token
408408
.connect(tokenOwner)
409409
.setApprovalForAllForAssets(await operator.getAddress(), true);
410410

411-
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(0), bn(1)]);
411+
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([0n, bn(1)]);
412412
await expect(this.token.connect(operator).setPriority(tokenId, [1, 0]))
413413
.to.emit(this.token, 'AssetPrioritySet')
414414
.withArgs(tokenId);
415-
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), bn(0)]);
415+
expect(await this.token.getActiveAssetPriorities(tokenId)).to.be.eql([bn(1), 0n]);
416416
});
417417

418418
it('cannot set priorities for non owned token', async function () {

0 commit comments

Comments
 (0)