diff --git a/contracts/TalentLayerEscrow.sol b/contracts/TalentLayerEscrow.sol index a3ac1f70..f5642850 100644 --- a/contracts/TalentLayerEscrow.sol +++ b/contracts/TalentLayerEscrow.sol @@ -134,8 +134,9 @@ contract TalentLayerEscrow is /** * @notice Emitted after the total amount of a transaction has been paid. At this moment the service is considered finished. * @param _serviceId The service ID + * @param _transactionId The id of the transaction. */ - event PaymentCompleted(uint256 _serviceId); + event PaymentCompleted(uint256 _serviceId, uint256 _transactionId); /** * @notice Emitted after the protocol fee was updated @@ -993,7 +994,7 @@ contract TalentLayerEscrow is if (transaction.amount == 0) { talentLayerServiceContract.afterFullPayment(transaction.serviceId, transaction.releasedAmount); - emit PaymentCompleted(transaction.serviceId); + emit PaymentCompleted(transaction.serviceId, transaction.id); } } diff --git a/scripts/playground/3-make-proposal.ts b/scripts/playground/3-make-proposal.ts index 4417c69b..70218fc0 100644 --- a/scripts/playground/3-make-proposal.ts +++ b/scripts/playground/3-make-proposal.ts @@ -91,7 +91,7 @@ async function main() { /* --------- Proposal creation --------- */ - // Bob create a proposal #2 for Alice's service #1 on Dave's platform #1 (id : 1-2 in GraphQL) + // Bob creates a proposal #2 for Alice's service #1 on Dave's platform #1 (id : 1-2 in GraphQL) const signatureBobProposal = await getSignatureForProposal(dave, bobTlId, 1, bobUri) diff --git a/scripts/playground/7-payETH.ts b/scripts/playground/7-payETH.ts index e53858f3..e2c04b9c 100644 --- a/scripts/playground/7-payETH.ts +++ b/scripts/playground/7-payETH.ts @@ -3,6 +3,7 @@ import { DeploymentProperty, getDeploymentProperty } from '../../.deployment/dep import hre = require('hardhat') const aliceTlId = 1 +const carolTlId = 3 /* In this script Alice releases 3/4 of the escrow & Carol reimburses the remaining 1/4 to Alice @@ -11,11 +12,6 @@ async function main() { const network = hre.network.name console.log(network) - const talentLayerService = await ethers.getContractAt( - 'TalentLayerService', - getDeploymentProperty(network, DeploymentProperty.TalentLayerService), - ) - const [alice, bob, carol, dave] = await ethers.getSigners() const talentLayerEscrow = await ethers.getContractAt( @@ -25,16 +21,15 @@ async function main() { const rateAmount = ethers.utils.parseUnits('0.002', 18) + // Alice releases an amount too low for the service to be considered finished const firstRelease = await talentLayerEscrow .connect(alice) - .release(aliceTlId, 0, rateAmount.div(2)) + .release(aliceTlId, 1, rateAmount.mul(20).div(100)) await firstRelease.wait() const secondRelease = await talentLayerEscrow - .connect(alice) - .release(aliceTlId, 0, rateAmount.div(2)) + .connect(carol) + .reimburse(carolTlId, 1, rateAmount.mul(80).div(100)) await secondRelease.wait() - // const reimburse = await talentLayerEscrow.connect(carol).reimburse(0, rateAmount.div(4)) - // reimburse.wait() } // We recommend this pattern to be able to use async/await everywhere diff --git a/scripts/playground/7-payToken.ts b/scripts/playground/7-payToken.ts index 0f72143f..6ba67e8a 100644 --- a/scripts/playground/7-payToken.ts +++ b/scripts/playground/7-payToken.ts @@ -19,7 +19,7 @@ async function main() { ) const rateAmount = ethers.utils.parseUnits('0.003', 18) - const release = await talentLayerEscrow.connect(alice).release(aliceTlId, 1, rateAmount) + const release = await talentLayerEscrow.connect(alice).release(aliceTlId, 2, rateAmount) await release.wait() } diff --git a/test/batch/fullWorkflow.ts b/test/batch/fullWorkflow.ts index 87921140..11f69c4e 100644 --- a/test/batch/fullWorkflow.ts +++ b/test/batch/fullWorkflow.ts @@ -1599,7 +1599,7 @@ describe('TalentLayer protocol global testing', function () { serviceId, transactionDetailsBefore.proposalId, ) - await expect(transaction).to.emit(talentLayerEscrow, 'PaymentCompleted').withArgs(serviceId) + await expect(transaction).to.emit(talentLayerEscrow, 'PaymentCompleted').withArgs(serviceId, transactionId) // Check transaction data has been updated correctly const transactionDetailsAfter = await talentLayerEscrow @@ -1901,7 +1901,7 @@ describe('TalentLayer protocol global testing', function () { [talentLayerEscrow.address, alice, bob], [-totalAmount / 4, totalAmount / 4, 0], ) - await expect(transaction).to.emit(talentLayerEscrow, 'PaymentCompleted').withArgs(serviceId) + await expect(transaction).to.emit(talentLayerEscrow, 'PaymentCompleted').withArgs(serviceId, transactionId) }) it('Alice can not release escrow because there is none left.', async function () {