diff --git a/contracts/TalentLayerService.sol b/contracts/TalentLayerService.sol index 7fb880fb..259cf1ca 100644 --- a/contracts/TalentLayerService.sol +++ b/contracts/TalentLayerService.sol @@ -121,9 +121,10 @@ contract TalentLayerService is Initializable, ERC2771RecipientUpgradeable, UUPSU * @notice Emit when data is updated for a Service * @param id The service ID * @param dataUri New service Data URI + * @param rateToken token address to be used for the service's payments * @param referralAmount New referral amount */ - event ServiceUpdated(uint256 id, string dataUri, uint256 referralAmount); + event ServiceUpdated(uint256 id, string dataUri, address rateToken, uint256 referralAmount); /** * @notice Emitted after a new proposal is created @@ -353,12 +354,14 @@ contract TalentLayerService is Initializable, ERC2771RecipientUpgradeable, UUPSU * @notice Update Service URI data * @param _profileId The TalentLayer ID of the user, owner of the service * @param _serviceId, Service ID to update + * @param _rateToken token address to be used for the service's payments * @param _referralAmount, New referral amount * @param _dataUri New IPFS URI */ function updateService( uint256 _profileId, uint256 _serviceId, + address _rateToken, uint256 _referralAmount, string calldata _dataUri ) public onlyOwnerOrDelegate(_profileId) { @@ -366,12 +369,14 @@ contract TalentLayerService is Initializable, ERC2771RecipientUpgradeable, UUPSU require(service.ownerId == _profileId, "Not the owner"); require(service.status == Status.Opened, "status must be opened"); require(bytes(_dataUri).length == 46, "Invalid cid"); + require(allowedTokenList[_rateToken].isWhitelisted, "Token not allowed"); require(_referralAmount >= service.referralAmount, "Can't reduce referral amount"); service.dataUri = _dataUri; service.referralAmount = _referralAmount; + service.rateToken = _rateToken; - emit ServiceUpdated(_serviceId, _dataUri, _referralAmount); + emit ServiceUpdated(_serviceId, _dataUri, _rateToken, _referralAmount); } /** diff --git a/test/batch/delegationSystem.ts b/test/batch/delegationSystem.ts index 1ec120ef..38504ee1 100644 --- a/test/batch/delegationSystem.ts +++ b/test/batch/delegationSystem.ts @@ -144,7 +144,7 @@ describe('Delegation System', function () { }) it('Dave can update service data on behalf of Alice', async function () { - const tx = await talentLayerService.connect(dave).updateService(aliceTlId, serviceId, 0, cid) + const tx = await talentLayerService.connect(dave).updateService(aliceTlId, serviceId, ethers.constants.AddressZero, referralAmount, cid) await expect(tx).to.not.be.reverted }) diff --git a/test/batch/fullWorkflow.ts b/test/batch/fullWorkflow.ts index c76084e4..59ce2ac3 100644 --- a/test/batch/fullWorkflow.ts +++ b/test/batch/fullWorkflow.ts @@ -859,6 +859,7 @@ describe('TalentLayer protocol global testing', function () { expect(service1Data.dataUri).to.be.equal(cid) expect(service1Data.platformId).to.be.equal(1) expect(service1Data.referralAmount).to.be.equal(0) + expect(service1Data.rateToken).to.be.equal(token.address) expect(tx) .to.emit(talentLayerService, 'ServiceCreated') .withArgs(5, aliceTlId, alicePlatformId, cid, token.address, 0) @@ -930,25 +931,29 @@ describe('TalentLayer protocol global testing', function () { }) it('Alice can update her service data', async function () { - await talentLayerService.connect(alice).updateService(aliceTlId, 1, referralAmount, cid2) + await talentLayerService.connect(alice).updateService(aliceTlId, 1, ethers.constants.AddressZero, referralAmount, cid2) const serviceData = await talentLayerService.services(1) expect(serviceData.dataUri).to.be.equal(cid2) + expect(serviceData.rateToken).to.be.equal(ethers.constants.AddressZero) + // Revert update + await talentLayerService.connect(alice).updateService(aliceTlId, 1, token.address, referralAmount, cid2) + const newReferralAmount = 40000 const tx = await talentLayerService .connect(alice) - .updateService(aliceTlId, 6, newReferralAmount, cid2) + .updateService(aliceTlId, 6, ethers.constants.AddressZero, newReferralAmount, cid2) const service6Data = await talentLayerService.services(6) expect(tx) .to.emit(talentLayerService, 'ServiceUpdated') - .withArgs(6, cid2, newReferralAmount, ethers.constants.AddressZero) + .withArgs(6, cid2, ethers.constants.AddressZero, newReferralAmount) expect(service6Data.referralAmount).to.be.equal(newReferralAmount) }) it('Alice cannot update her service with an inferior referral amount', async function () { await expect( - talentLayerService.connect(alice).updateService(aliceTlId, 1, referralAmount - 1, cid2), + talentLayerService.connect(alice).updateService(aliceTlId, 1, token.address, referralAmount - 1, cid2), ).to.be.revertedWith("Can't reduce referral amount") }) @@ -1536,7 +1541,7 @@ describe('TalentLayer protocol global testing', function () { it('Alice cannot update her service data after it is confirmed', async function () { const tx = talentLayerService .connect(alice) - .updateService(aliceTlId, serviceId, referralAmount, cid2) + .updateService(aliceTlId, serviceId, ethers.constants.AddressZero, referralAmount, cid2) await expect(tx).to.be.revertedWith('status must be opened') })