amount added to LockReleased event
This commit is contained in:
parent
ffa0fe22e3
commit
cb93b4db4b
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -254,6 +254,12 @@
|
|||||||
"internalType": "bytes32",
|
"internalType": "bytes32",
|
||||||
"name": "lockId",
|
"name": "lockId",
|
||||||
"type": "bytes32"
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "amount",
|
||||||
|
"type": "uint256"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "LockReleased",
|
"name": "LockReleased",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/916d546d680bb337e1c490eb628d93df.json"
|
"buildInfo": "../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/948b888bf726ea051449ea823f31e46a.json"
|
"buildInfo": "../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -28,7 +28,8 @@ interface EventAndErrors {
|
|||||||
);
|
);
|
||||||
event LockReleased(
|
event LockReleased(
|
||||||
address indexed buyer,
|
address indexed buyer,
|
||||||
bytes32 lockId
|
bytes32 lockId,
|
||||||
|
uint256 amount
|
||||||
);
|
);
|
||||||
event LockReturned(
|
event LockReturned(
|
||||||
address indexed buyer,
|
address indexed buyer,
|
||||||
|
@ -34,11 +34,10 @@ contract P2PIX is
|
|||||||
IReputation public reputation;
|
IReputation public reputation;
|
||||||
Counters.Counter public depositCount;
|
Counters.Counter public depositCount;
|
||||||
|
|
||||||
|
|
||||||
/// @dev Default blocks that lock will hold tokens.
|
/// @dev Default blocks that lock will hold tokens.
|
||||||
uint256 public defaultLockBlocks;
|
uint256 public defaultLockBlocks;
|
||||||
/// @dev The scalar of BRZ token.
|
/// @dev The scalar of BRZ token.
|
||||||
uint256 constant public WAD = 1e18;
|
uint256 public constant WAD = 1e18;
|
||||||
|
|
||||||
/// @dev Stores an relayer's last computed credit.
|
/// @dev Stores an relayer's last computed credit.
|
||||||
mapping(uint256 => uint256) public userRecord;
|
mapping(uint256 => uint256) public userRecord;
|
||||||
@ -213,8 +212,10 @@ contract P2PIX is
|
|||||||
uint256 spendLimit;
|
uint256 spendLimit;
|
||||||
(spendLimit) = _limiter(userCredit / WAD);
|
(spendLimit) = _limiter(userCredit / WAD);
|
||||||
|
|
||||||
if (l.amount > (spendLimit * WAD) || l.amount > 1e6 ether)
|
if (
|
||||||
revert AmountNotAllowed();
|
l.amount > (spendLimit * WAD) ||
|
||||||
|
l.amount > 1e6 ether
|
||||||
|
) revert AmountNotAllowed();
|
||||||
|
|
||||||
_addLock(lockID, l, d);
|
_addLock(lockID, l, d);
|
||||||
// Halt execution and output `lockID`.
|
// Halt execution and output `lockID`.
|
||||||
@ -324,7 +325,7 @@ contract P2PIX is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit LockReleased(l.buyerAddress, lockID);
|
emit LockReleased(l.buyerAddress, lockID, lockAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Unlocks expired locks.
|
/// @notice Unlocks expired locks.
|
||||||
@ -333,9 +334,9 @@ contract P2PIX is
|
|||||||
/// @dev For each successfull unexpired lock recovered,
|
/// @dev For each successfull unexpired lock recovered,
|
||||||
/// `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.
|
/// `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.
|
||||||
/// @dev Function sighash: 0x8e2749d6.
|
/// @dev Function sighash: 0x8e2749d6.
|
||||||
function unlockExpired(
|
function unlockExpired(bytes32[] calldata lockIDs)
|
||||||
bytes32[] calldata lockIDs
|
public
|
||||||
) public {
|
{
|
||||||
uint256 i;
|
uint256 i;
|
||||||
uint256 locksSize = lockIDs.length;
|
uint256 locksSize = lockIDs.length;
|
||||||
|
|
||||||
@ -403,10 +404,9 @@ contract P2PIX is
|
|||||||
emit DepositWithdrawn(msg.sender, depositID, amount);
|
emit DepositWithdrawn(msg.sender, depositID, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRoot(
|
function setRoot(address addr, bytes32 merkleroot)
|
||||||
address addr,
|
public
|
||||||
bytes32 merkleroot
|
{
|
||||||
) public {
|
|
||||||
if (addr == msg.sender) {
|
if (addr == msg.sender) {
|
||||||
sellerAllowList[
|
sellerAllowList[
|
||||||
_castAddrToKey(addr)
|
_castAddrToKey(addr)
|
||||||
@ -425,27 +425,30 @@ contract P2PIX is
|
|||||||
emit FundsWithdrawn(msg.sender, balance);
|
emit FundsWithdrawn(msg.sender, balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setReputation(
|
function setReputation(IReputation _reputation)
|
||||||
IReputation _reputation
|
public
|
||||||
) public onlyOwner {
|
onlyOwner
|
||||||
|
{
|
||||||
assembly {
|
assembly {
|
||||||
sstore(reputation.slot, _reputation)
|
sstore(reputation.slot, _reputation)
|
||||||
}
|
}
|
||||||
emit ReputationUpdated(address(_reputation));
|
emit ReputationUpdated(address(_reputation));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefaultLockBlocks(
|
function setDefaultLockBlocks(uint256 _blocks)
|
||||||
uint256 _blocks
|
public
|
||||||
) public onlyOwner {
|
onlyOwner
|
||||||
|
{
|
||||||
assembly {
|
assembly {
|
||||||
sstore(defaultLockBlocks.slot, _blocks)
|
sstore(defaultLockBlocks.slot, _blocks)
|
||||||
}
|
}
|
||||||
emit LockBlocksUpdated(_blocks);
|
emit LockBlocksUpdated(_blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setValidSigners(
|
function setValidSigners(address[] memory _validSigners)
|
||||||
address[] memory _validSigners
|
public
|
||||||
) public onlyOwner {
|
onlyOwner
|
||||||
|
{
|
||||||
unchecked {
|
unchecked {
|
||||||
uint256 i;
|
uint256 i;
|
||||||
uint256 len = _validSigners.length;
|
uint256 len = _validSigners.length;
|
||||||
@ -589,9 +592,11 @@ contract P2PIX is
|
|||||||
) revert AddressDenied();
|
) revert AddressDenied();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _limiter(
|
function _limiter(uint256 _userCredit)
|
||||||
uint256 _userCredit
|
internal
|
||||||
) internal view returns (uint256 _spendLimit) {
|
view
|
||||||
|
returns (uint256 _spendLimit)
|
||||||
|
{
|
||||||
// enconde the fx sighash and args
|
// enconde the fx sighash and args
|
||||||
bytes memory encodedParams = abi.encodeWithSelector(
|
bytes memory encodedParams = abi.encodeWithSelector(
|
||||||
IReputation.limiter.selector,
|
IReputation.limiter.selector,
|
||||||
@ -631,9 +636,11 @@ contract P2PIX is
|
|||||||
/// @notice Public method that handles `address`
|
/// @notice Public method that handles `address`
|
||||||
/// to `uint256` safe type casting.
|
/// to `uint256` safe type casting.
|
||||||
/// @dev Function sighash: 0x4b2ae980.
|
/// @dev Function sighash: 0x4b2ae980.
|
||||||
function _castAddrToKey(
|
function _castAddrToKey(address _addr)
|
||||||
address _addr
|
public
|
||||||
) public pure returns (uint256 _key) {
|
pure
|
||||||
|
returns (uint256 _key)
|
||||||
|
{
|
||||||
_key = uint256(uint160(address(_addr))) << 12;
|
_key = uint256(uint160(address(_addr))) << 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export interface EventAndErrorsInterface extends utils.Interface {
|
|||||||
"FundsWithdrawn(address,uint256)": EventFragment;
|
"FundsWithdrawn(address,uint256)": EventFragment;
|
||||||
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
||||||
"LockBlocksUpdated(uint256)": EventFragment;
|
"LockBlocksUpdated(uint256)": EventFragment;
|
||||||
"LockReleased(address,bytes32)": EventFragment;
|
"LockReleased(address,bytes32,uint256)": EventFragment;
|
||||||
"LockReturned(address,bytes32)": EventFragment;
|
"LockReturned(address,bytes32)": EventFragment;
|
||||||
"ReputationUpdated(address)": EventFragment;
|
"ReputationUpdated(address)": EventFragment;
|
||||||
"RootUpdated(address,bytes32)": EventFragment;
|
"RootUpdated(address,bytes32)": EventFragment;
|
||||||
@ -131,9 +131,10 @@ export type LockBlocksUpdatedEventFilter =
|
|||||||
export interface LockReleasedEventObject {
|
export interface LockReleasedEventObject {
|
||||||
buyer: string;
|
buyer: string;
|
||||||
lockId: string;
|
lockId: string;
|
||||||
|
amount: BigNumber;
|
||||||
}
|
}
|
||||||
export type LockReleasedEvent = TypedEvent<
|
export type LockReleasedEvent = TypedEvent<
|
||||||
[string, string],
|
[string, string, BigNumber],
|
||||||
LockReleasedEventObject
|
LockReleasedEventObject
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@ -278,13 +279,15 @@ export interface EventAndErrors extends BaseContract {
|
|||||||
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||||
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||||
|
|
||||||
"LockReleased(address,bytes32)"(
|
"LockReleased(address,bytes32,uint256)"(
|
||||||
buyer?: PromiseOrValue<string> | null,
|
buyer?: PromiseOrValue<string> | null,
|
||||||
lockId?: null
|
lockId?: null,
|
||||||
|
amount?: null
|
||||||
): LockReleasedEventFilter;
|
): LockReleasedEventFilter;
|
||||||
LockReleased(
|
LockReleased(
|
||||||
buyer?: PromiseOrValue<string> | null,
|
buyer?: PromiseOrValue<string> | null,
|
||||||
lockId?: null
|
lockId?: null,
|
||||||
|
amount?: null
|
||||||
): LockReleasedEventFilter;
|
): LockReleasedEventFilter;
|
||||||
|
|
||||||
"LockReturned(address,bytes32)"(
|
"LockReturned(address,bytes32)"(
|
||||||
|
@ -262,6 +262,12 @@ const _abi = [
|
|||||||
name: "lockId",
|
name: "lockId",
|
||||||
type: "bytes32",
|
type: "bytes32",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
indexed: false,
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "amount",
|
||||||
|
type: "uint256",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
name: "LockReleased",
|
name: "LockReleased",
|
||||||
type: "event",
|
type: "event",
|
||||||
|
File diff suppressed because one or more lines are too long
@ -286,7 +286,7 @@ export interface P2PIXInterface extends utils.Interface {
|
|||||||
"FundsWithdrawn(address,uint256)": EventFragment;
|
"FundsWithdrawn(address,uint256)": EventFragment;
|
||||||
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
||||||
"LockBlocksUpdated(uint256)": EventFragment;
|
"LockBlocksUpdated(uint256)": EventFragment;
|
||||||
"LockReleased(address,bytes32)": EventFragment;
|
"LockReleased(address,bytes32,uint256)": EventFragment;
|
||||||
"LockReturned(address,bytes32)": EventFragment;
|
"LockReturned(address,bytes32)": EventFragment;
|
||||||
"OwnerUpdated(address,address)": EventFragment;
|
"OwnerUpdated(address,address)": EventFragment;
|
||||||
"ReputationUpdated(address)": EventFragment;
|
"ReputationUpdated(address)": EventFragment;
|
||||||
@ -396,9 +396,10 @@ export type LockBlocksUpdatedEventFilter =
|
|||||||
export interface LockReleasedEventObject {
|
export interface LockReleasedEventObject {
|
||||||
buyer: string;
|
buyer: string;
|
||||||
lockId: string;
|
lockId: string;
|
||||||
|
amount: BigNumber;
|
||||||
}
|
}
|
||||||
export type LockReleasedEvent = TypedEvent<
|
export type LockReleasedEvent = TypedEvent<
|
||||||
[string, string],
|
[string, string, BigNumber],
|
||||||
LockReleasedEventObject
|
LockReleasedEventObject
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@ -1001,13 +1002,15 @@ export interface P2PIX extends BaseContract {
|
|||||||
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||||
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||||
|
|
||||||
"LockReleased(address,bytes32)"(
|
"LockReleased(address,bytes32,uint256)"(
|
||||||
buyer?: PromiseOrValue<string> | null,
|
buyer?: PromiseOrValue<string> | null,
|
||||||
lockId?: null
|
lockId?: null,
|
||||||
|
amount?: null
|
||||||
): LockReleasedEventFilter;
|
): LockReleasedEventFilter;
|
||||||
LockReleased(
|
LockReleased(
|
||||||
buyer?: PromiseOrValue<string> | null,
|
buyer?: PromiseOrValue<string> | null,
|
||||||
lockId?: null
|
lockId?: null,
|
||||||
|
amount?: null
|
||||||
): LockReleasedEventFilter;
|
): LockReleasedEventFilter;
|
||||||
|
|
||||||
"LockReturned(address,bytes32)"(
|
"LockReturned(address,bytes32)"(
|
||||||
|
@ -1251,7 +1251,7 @@ describe("P2PIX", () => {
|
|||||||
expect(tx).to.be.ok;
|
expect(tx).to.be.ok;
|
||||||
await expect(tx)
|
await expect(tx)
|
||||||
.to.emit(p2pix, "LockReleased")
|
.to.emit(p2pix, "LockReleased")
|
||||||
.withArgs(acc02.address, lockID);
|
.withArgs(acc02.address, lockID, storage1.amount);
|
||||||
expect(storage1.expirationBlock).to.eq(
|
expect(storage1.expirationBlock).to.eq(
|
||||||
ethers.BigNumber.from(16),
|
ethers.BigNumber.from(16),
|
||||||
);
|
);
|
||||||
@ -1358,6 +1358,11 @@ describe("P2PIX", () => {
|
|||||||
["uint256", "uint256", "address"],
|
["uint256", "uint256", "address"],
|
||||||
[0, 25, acc02.address],
|
[0, 25, acc02.address],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const storage1: Lock = await p2pix.callStatic.mapLocks(lockID);
|
||||||
|
const storage2: Lock = await p2pix.callStatic.mapLocks(lockID2);
|
||||||
|
const storage3: Lock = await p2pix.callStatic.mapLocks(lockID3);
|
||||||
|
|
||||||
// relayerPremium == 0
|
// relayerPremium == 0
|
||||||
const tx = await p2pix
|
const tx = await p2pix
|
||||||
.connect(acc01)
|
.connect(acc01)
|
||||||
@ -1412,13 +1417,13 @@ describe("P2PIX", () => {
|
|||||||
expect(tx2).to.be.ok;
|
expect(tx2).to.be.ok;
|
||||||
await expect(tx)
|
await expect(tx)
|
||||||
.to.emit(p2pix, "LockReleased")
|
.to.emit(p2pix, "LockReleased")
|
||||||
.withArgs(acc02.address, lockID);
|
.withArgs(acc02.address, lockID, storage1.amount);
|
||||||
await expect(tx1)
|
await expect(tx1)
|
||||||
.to.emit(p2pix, "LockReleased")
|
.to.emit(p2pix, "LockReleased")
|
||||||
.withArgs(acc02.address, lockID2);
|
.withArgs(acc02.address, lockID2, storage2.amount);
|
||||||
await expect(tx2)
|
await expect(tx2)
|
||||||
.to.emit(p2pix, "LockReleased")
|
.to.emit(p2pix, "LockReleased")
|
||||||
.withArgs(acc02.address, lockID3);
|
.withArgs(acc02.address, lockID3, storage3.amount);
|
||||||
expect(used1).to.eq(true);
|
expect(used1).to.eq(true);
|
||||||
expect(used2).to.eq(true);
|
expect(used2).to.eq(true);
|
||||||
expect(used3).to.eq(true);
|
expect(used3).to.eq(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user