Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
aggre committed Aug 13, 2024
1 parent 43310e3 commit 3ae5ed5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
4 changes: 2 additions & 2 deletions contracts/interface/ITransferHistory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ interface ITransferHistory {
address to;
address from;
uint256 amount;
uint256 recipientBalanceBeforeTx;
uint256 senderBalanceBeforeTx;
uint256 preBalanceOfRecipient;
uint256 preBalanceOfSender;
bool filled;
uint256 blockNumber;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/withdraw/Withdraw.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ contract Withdraw is InitializableUsingRegistry, IWithdraw, ITransferHistory {
hId - 1
];
lastHistory.amount =
lastHistory.senderBalanceBeforeTx -
lastHistory.preBalanceOfSender -
_property.balanceOf(lastHistory.from);
lastHistory.filled = true;
}
Expand Down
48 changes: 22 additions & 26 deletions test/withdraw/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,26 +354,26 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
to: string
from: string
amount: BigNumber
recipientBalanceBeforeTx: BigNumber
senderBalanceBeforeTx: BigNumber
preBalanceOfRecipient: BigNumber
preBalanceOfSender: BigNumber
filled: boolean
blockNumber: BigNumber
} => {
const [
to,
from,
amount,
recipientBalanceBeforeTx,
senderBalanceBeforeTx,
preBalanceOfRecipient,
preBalanceOfSender,
filled,
blockNumber,
] = src
return {
to,
from,
amount: toBigNumber(amount),
recipientBalanceBeforeTx: toBigNumber(recipientBalanceBeforeTx),
senderBalanceBeforeTx: toBigNumber(senderBalanceBeforeTx),
preBalanceOfRecipient: toBigNumber(preBalanceOfRecipient),
preBalanceOfSender: toBigNumber(preBalanceOfSender),
filled,
blockNumber: toBigNumber(blockNumber),
}
Expand All @@ -383,8 +383,8 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
const data = await dev.withdraw.transferHistory(property.address, 0)
const res = toStruct(data)
expect(res.amount.toNumber()).to.be.equal(0)
expect(res.senderBalanceBeforeTx.toNumber()).to.be.equal(0)
expect(res.recipientBalanceBeforeTx.toNumber()).to.be.equal(0)
expect(res.preBalanceOfSender.toNumber()).to.be.equal(0)
expect(res.preBalanceOfRecipient.toNumber()).to.be.equal(0)
expect(res.blockNumber.toNumber()).to.be.equal(0)
expect(res.to).to.be.equal(DEFAULT_ADDRESS)
expect(res.from).to.be.equal(DEFAULT_ADDRESS)
Expand All @@ -408,10 +408,8 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {

const res1 = toStruct(data1)
expect(res1.amount.toNumber()).to.be.equal(0) // Initially, it's 0
expect(res1.senderBalanceBeforeTx.toFixed()).to.be.equal(
balance1.toFixed()
)
expect(res1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
expect(res1.preBalanceOfSender.toFixed()).to.be.equal(balance1.toFixed())
expect(res1.preBalanceOfRecipient.toFixed()).to.be.equal(
balance2.toFixed()
)
expect(res1.blockNumber.toNumber()).to.be.equal(block1)
Expand All @@ -421,10 +419,8 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {

const res2 = toStruct(data2)
expect(res2.amount.toNumber()).to.be.equal(0) // Initially, it's 0
expect(res2.senderBalanceBeforeTx.toFixed()).to.be.equal(
balance3.toFixed()
)
expect(res2.recipientBalanceBeforeTx.toFixed()).to.be.equal(
expect(res2.preBalanceOfSender.toFixed()).to.be.equal(balance3.toFixed())
expect(res2.preBalanceOfRecipient.toFixed()).to.be.equal(
balance4.toFixed()
)
expect(res2.blockNumber.toNumber()).to.be.equal(block2)
Expand Down Expand Up @@ -719,10 +715,10 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
expect(r1.from).to.be.equal(Alice)
expect(r1.to).to.be.equal(Bob)
expect(r1.amount.toFixed()).to.be.equal('0')
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfSender.toFixed()).to.be.equal(
balanceAlice.toFixed()
)
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfRecipient.toFixed()).to.be.equal(
balanceBob.toFixed()
)
expect(r1.filled).to.be.equal(false)
Expand Down Expand Up @@ -813,10 +809,10 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
expect(r1.from).to.be.equal(Bob)
expect(r1.to).to.be.equal(Carol)
expect(r1.amount.toFixed()).to.be.equal('0')
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfSender.toFixed()).to.be.equal(
balanceBob.toFixed()
)
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfRecipient.toFixed()).to.be.equal(
balanceCarol.toFixed()
)
expect(r1.filled).to.be.equal(false)
Expand Down Expand Up @@ -901,10 +897,10 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {
expect(r1.from).to.be.equal(Bob)
expect(r1.to).to.be.equal(Carol)
expect(r1.amount.toFixed()).to.be.equal('0')
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfSender.toFixed()).to.be.equal(
balanceBob.toFixed()
)
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfRecipient.toFixed()).to.be.equal(
balanceCarol.toFixed()
)
expect(r1.filled).to.be.equal(false)
Expand All @@ -919,10 +915,10 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {

expect(r1.from).to.be.equal(Alice)
expect(r1.to).to.be.equal(Bob)
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfSender.toFixed()).to.be.equal(
balanceAliceProp1$1.toFixed()
)
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfRecipient.toFixed()).to.be.equal(
balanceBobProp1$1.toFixed()
)
expect(r1.blockNumber.toNumber()).to.be.equal(blockNumberProp1$1)
Expand All @@ -936,10 +932,10 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => {

expect(r1.from).to.be.equal(Bob)
expect(r1.to).to.be.equal(Carol)
expect(r1.senderBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfSender.toFixed()).to.be.equal(
balanceBobProp2$1.toFixed()
)
expect(r1.recipientBalanceBeforeTx.toFixed()).to.be.equal(
expect(r1.preBalanceOfRecipient.toFixed()).to.be.equal(
balanceCarolProp2$1.toFixed()
)
expect(r1.blockNumber.toNumber()).to.be.equal(blockNumberProp2$1)
Expand Down

0 comments on commit 3ae5ed5

Please sign in to comment.