Skip to content

Commit 03dfa17

Browse files
committed
rename struct property
1 parent 2b887d8 commit 03dfa17

File tree

3 files changed

+53
-41
lines changed

3 files changed

+53
-41
lines changed

contracts/interface/ITransferHistory.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ interface ITransferHistory {
77
address to;
88
address from;
99
uint256 amount;
10-
uint256 sourceOfRecipient;
11-
uint256 sourceOfSender;
12-
bool fill;
10+
uint256 recipientBalanceBeforeTx;
11+
uint256 senderBalanceBeforeTx;
12+
bool filled;
1313
uint256 blockNumber;
1414
}
1515

contracts/src/withdraw/Withdraw.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ contract Withdraw is InitializableUsingRegistry, IWithdraw, ITransferHistory {
206206
hId - 1
207207
];
208208
lastHistory.amount =
209-
lastHistory.sourceOfSender -
209+
lastHistory.senderBalanceBeforeTx -
210210
_property.balanceOf(lastHistory.from);
211-
lastHistory.fill = true;
211+
lastHistory.filled = true;
212212
}
213213
}
214214

test/withdraw/withdraw.ts

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -354,27 +354,27 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
354354
to: string
355355
from: string
356356
amount: BigNumber
357-
sourceOfRecipient: BigNumber
358-
sourceOfSender: BigNumber
359-
fill: boolean
357+
recipientBalanceBeforeTx: BigNumber
358+
senderBalanceBeforeTx: BigNumber
359+
filled: boolean
360360
blockNumber: BigNumber
361361
} => {
362362
const [
363363
to,
364364
from,
365365
amount,
366-
sourceOfRecipient,
367-
sourceOfSender,
368-
fill,
366+
recipientBalanceBeforeTx,
367+
senderBalanceBeforeTx,
368+
filled,
369369
blockNumber,
370370
] = src
371371
return {
372372
to,
373373
from,
374374
amount: toBigNumber(amount),
375-
sourceOfRecipient: toBigNumber(sourceOfRecipient),
376-
sourceOfSender: toBigNumber(sourceOfSender),
377-
fill,
375+
recipientBalanceBeforeTx: toBigNumber(recipientBalanceBeforeTx),
376+
senderBalanceBeforeTx: toBigNumber(senderBalanceBeforeTx),
377+
filled,
378378
blockNumber: toBigNumber(blockNumber),
379379
}
380380
}
@@ -383,12 +383,12 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
383383
const data = await dev.withdraw.transferHistory(property.address, 0)
384384
const res = toStruct(data)
385385
expect(res.amount.toNumber()).to.be.equal(0)
386-
expect(res.sourceOfSender.toNumber()).to.be.equal(0)
387-
expect(res.sourceOfRecipient.toNumber()).to.be.equal(0)
386+
expect(res.senderBalanceBeforeTx.toNumber()).to.be.equal(0)
387+
expect(res.recipientBalanceBeforeTx.toNumber()).to.be.equal(0)
388388
expect(res.blockNumber.toNumber()).to.be.equal(0)
389389
expect(res.to).to.be.equal(DEFAULT_ADDRESS)
390390
expect(res.from).to.be.equal(DEFAULT_ADDRESS)
391-
expect(res.fill).to.be.equal(false)
391+
expect(res.filled).to.be.equal(false)
392392
})
393393
it('should create new TransferHistory each transfer', async () => {
394394
const balance1 = await property.balanceOf(Alice).then(toBigNumber)
@@ -408,38 +408,46 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
408408

409409
const res1 = toStruct(data1)
410410
expect(res1.amount.toNumber()).to.be.equal(0) // Initially, it's 0
411-
expect(res1.sourceOfSender.toFixed()).to.be.equal(balance1.toFixed())
412-
expect(res1.sourceOfRecipient.toFixed()).to.be.equal(balance2.toFixed())
411+
expect(res1.senderBalanceBeforeTx.toFixed()).to.be.equal(
412+
balance1.toFixed()
413+
)
414+
expect(res1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
415+
balance2.toFixed()
416+
)
413417
expect(res1.blockNumber.toNumber()).to.be.equal(block1)
414418
expect(res1.to).to.be.equal(Bob)
415419
expect(res1.from).to.be.equal(Alice)
416-
expect(res1.fill).to.be.equal(false)
420+
expect(res1.filled).to.be.equal(false)
417421

418422
const res2 = toStruct(data2)
419423
expect(res2.amount.toNumber()).to.be.equal(0) // Initially, it's 0
420-
expect(res2.sourceOfSender.toFixed()).to.be.equal(balance3.toFixed())
421-
expect(res2.sourceOfRecipient.toFixed()).to.be.equal(balance4.toFixed())
424+
expect(res2.senderBalanceBeforeTx.toFixed()).to.be.equal(
425+
balance3.toFixed()
426+
)
427+
expect(res2.recipientBalanceBeforeTx.toFixed()).to.be.equal(
428+
balance4.toFixed()
429+
)
422430
expect(res2.blockNumber.toNumber()).to.be.equal(block2)
423431
expect(res2.to).to.be.equal(Carol)
424432
expect(res2.from).to.be.equal(Bob)
425-
expect(res2.fill).to.be.equal(false)
433+
expect(res2.filled).to.be.equal(false)
426434
})
427-
it('should update `amount` and `fill` of the last one TransferHistory', async () => {
435+
it('should update `amount` and `filled` of the last one TransferHistory', async () => {
428436
await property.transfer(Bob, '1000000', {
429437
from: Alice,
430438
})
431439
const d1 = await dev.withdraw.transferHistory(property.address, 0)
432440
const r1 = toStruct(d1)
433441
expect(r1.amount.toFixed()).to.be.equal('0')
434-
expect(r1.fill).to.be.equal(false)
442+
expect(r1.filled).to.be.equal(false)
435443

436444
await property.transfer(Carol, '500000', {
437445
from: Bob,
438446
})
439447
const d2 = await dev.withdraw.transferHistory(property.address, 0)
440448
const r2 = toStruct(d2)
441449
expect(r2.amount.toFixed()).to.be.equal('1000000')
442-
expect(r2.fill).to.be.equal(true)
450+
expect(r2.filled).to.be.equal(true)
443451
})
444452
it('should increase trasnferHistoryLength each transfer', async () => {
445453
expect(
@@ -711,13 +719,13 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
711719
expect(r1.from).to.be.equal(Alice)
712720
expect(r1.to).to.be.equal(Bob)
713721
expect(r1.amount.toFixed()).to.be.equal('0')
714-
expect(r1.sourceOfSender.toFixed()).to.be.equal(
722+
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
715723
balanceAlice.toFixed()
716724
)
717-
expect(r1.sourceOfRecipient.toFixed()).to.be.equal(
725+
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
718726
balanceBob.toFixed()
719727
)
720-
expect(r1.fill).to.be.equal(false)
728+
expect(r1.filled).to.be.equal(false)
721729
expect(r1.blockNumber.toNumber()).to.be.equal(blockNumber)
722730
})
723731
})
@@ -805,11 +813,13 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
805813
expect(r1.from).to.be.equal(Bob)
806814
expect(r1.to).to.be.equal(Carol)
807815
expect(r1.amount.toFixed()).to.be.equal('0')
808-
expect(r1.sourceOfSender.toFixed()).to.be.equal(balanceBob.toFixed())
809-
expect(r1.sourceOfRecipient.toFixed()).to.be.equal(
816+
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
817+
balanceBob.toFixed()
818+
)
819+
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
810820
balanceCarol.toFixed()
811821
)
812-
expect(r1.fill).to.be.equal(false)
822+
expect(r1.filled).to.be.equal(false)
813823
expect(r1.blockNumber.toNumber()).to.be.equal(blockNumber)
814824
})
815825
})
@@ -891,26 +901,28 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
891901
expect(r1.from).to.be.equal(Bob)
892902
expect(r1.to).to.be.equal(Carol)
893903
expect(r1.amount.toFixed()).to.be.equal('0')
894-
expect(r1.sourceOfSender.toFixed()).to.be.equal(balanceBob.toFixed())
895-
expect(r1.sourceOfRecipient.toFixed()).to.be.equal(
904+
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
905+
balanceBob.toFixed()
906+
)
907+
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
896908
balanceCarol.toFixed()
897909
)
898-
expect(r1.fill).to.be.equal(false)
910+
expect(r1.fillededed).to.be.equal(false)
899911
expect(r1.blockNumber.toNumber()).to.be.equal(blockNumber)
900912
})
901913
it('transferHistory for Prop1 #0 has updated', async () => {
902914
const [r1] = await Promise.all([
903915
withdraw.transferHistory(Prop1.address, 0).then(toStruct),
904916
])
905917
expect(r1.amount.toFixed()).to.be.equal('100000')
906-
expect(r1.fill).to.be.equal(true)
918+
expect(r1.filled).to.be.equal(true)
907919

908920
expect(r1.from).to.be.equal(Alice)
909921
expect(r1.to).to.be.equal(Bob)
910-
expect(r1.sourceOfSender.toFixed()).to.be.equal(
922+
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
911923
balanceAliceProp1$1.toFixed()
912924
)
913-
expect(r1.sourceOfRecipient.toFixed()).to.be.equal(
925+
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
914926
balanceBobProp1$1.toFixed()
915927
)
916928
expect(r1.blockNumber.toNumber()).to.be.equal(blockNumberProp1$1)
@@ -920,14 +932,14 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
920932
withdraw.transferHistory(Prop2.address, 0).then(toStruct),
921933
])
922934
expect(r1.amount.toFixed()).to.be.equal('0')
923-
expect(r1.fill).to.be.equal(false)
935+
expect(r1.filled).to.be.equal(false)
924936

925937
expect(r1.from).to.be.equal(Bob)
926938
expect(r1.to).to.be.equal(Carol)
927-
expect(r1.sourceOfSender.toFixed()).to.be.equal(
939+
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
928940
balanceBobProp2$1.toFixed()
929941
)
930-
expect(r1.sourceOfRecipient.toFixed()).to.be.equal(
942+
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
931943
balanceCarolProp2$1.toFixed()
932944
)
933945
expect(r1.blockNumber.toNumber()).to.be.equal(blockNumberProp2$1)

0 commit comments

Comments
 (0)