🩹 getBalances Fix
This commit is contained in:
parent
6fe1e794d0
commit
bb10cf953f
14
README.md
14
README.md
@ -50,16 +50,18 @@
|
|||||||
### V2
|
### V2
|
||||||
| Testnet | Token Address | P2pix Address | Reputation Address |
|
| Testnet | Token Address | P2pix Address | Reputation Address |
|
||||||
|--------- |-------------------------------------------- |-------------------------------------------- |-------------------------------------------- |
|
|--------- |-------------------------------------------- |-------------------------------------------- |-------------------------------------------- |
|
||||||
| Goerli | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x2a54667b566B1Aa3779828720E6696AC18ae3f1b | 0x7c4010CFe2B5446f0c9dcc5e9B596534b2D2eB44 |
|
| Goerli | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0xefa5cE4351cda51192509cf8De7d8881ADAE95DD | 0x939d3c357dc7017cDbDE681BF8e552b54595318A |
|
||||||
| Mumbai | 0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29 | 0x7F4680D114B43c4434FB604c7Bc6306125D32f28 | 0xD38D6367f452D097ccBfDe4490b7de570B6A72Db |
|
| Mumbai | 0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29 | 0xA9258eBb157E4cf5e756b77FDD0DF09C2F73240b | 0x1fd30b94f20d2f73e9630261342ba68f244da92b |
|
||||||
|
|
||||||
<!-- All contracts deployed by 0x8dC06F985C131166570825F52447E8c88d64aE20 -->
|
<!-- All contracts deployed by 0x8dC06F985C131166570825F52447E8c88d64aE20 -->
|
||||||
<!-- https://goerli.etherscan.io/address/0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00#code -->
|
<!-- https://goerli.etherscan.io/address/0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00#code -->
|
||||||
<!-- https://goerli.etherscan.io/address/0x2a54667b566B1Aa3779828720E6696AC18ae3f1b#code -->
|
<!-- https://goerli.etherscan.io/address/0xefa5cE4351cda51192509cf8De7d8881ADAE95DD#code -->
|
||||||
<!-- https://goerli.etherscan.io/address/0x7c4010CFe2B5446f0c9dcc5e9B596534b2D2eB44#code -->
|
<!-- https://goerli.etherscan.io/address/0x939d3c357dc7017cDbDE681BF8e552b54595318A#code -->
|
||||||
|
|
||||||
<!-- https://mumbai.polygonscan.com/address/0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29#code -->
|
<!-- https://mumbai.polygonscan.com/address/0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29#code -->
|
||||||
<!-- https://mumbai.polygonscan.com/address/0x7F4680D114B43c4434FB604c7Bc6306125D32f28#code -->
|
<!-- https://mumbai.polygonscan.com/address/0xA9258eBb157E4cf5e756b77FDD0DF09C2F73240b#code -->
|
||||||
<!-- https://mumbai.polygonscan.com/address/0xD38D6367f452D097ccBfDe4490b7de570B6A72Db#code -->
|
<!-- https://mumbai.polygonscan.com/address/0x1fd30b94f20d2f73e9630261342ba68f244da92b#code -->
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Pre Requisites
|
### Pre Requisites
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/6801f23dfb2a9667d9e89d4173ae1ee7.json"
|
"buildInfo": "../../build-info/6e32e8b8339868a5a7b642cfedb2d144.json"
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -332,7 +332,7 @@ contract P2PIX is
|
|||||||
/// In case of they differing:
|
/// In case of they differing:
|
||||||
/// - `lock` caller gets accrued with `l.amount` as userRecord credit;
|
/// - `lock` caller gets accrued with `l.amount` as userRecord credit;
|
||||||
/// - `release` caller gets accrued with `l.relayerPremium` as userRecord credit;
|
/// - `release` caller gets accrued with `l.relayerPremium` as userRecord credit;
|
||||||
/// @param _relayerTarget Target address entitled to the `relayerPremim`.
|
/// @param _relayerTarget Target address entitled to the `relayerPremium`.
|
||||||
/// @dev Function sighash: 0x4e1389ed.
|
/// @dev Function sighash: 0x4e1389ed.
|
||||||
function release(
|
function release(
|
||||||
uint256 lockID,
|
uint256 lockID,
|
||||||
@ -852,17 +852,21 @@ contract P2PIX is
|
|||||||
)
|
)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
returns(uint256[] memory balances)
|
returns(uint256[] memory)
|
||||||
{
|
{
|
||||||
if(address(token) == address(0x0))
|
|
||||||
revert NoTokens();
|
|
||||||
if(sellers.length == 0)
|
|
||||||
revert LengthMismatch();
|
|
||||||
|
|
||||||
uint256 j;
|
uint256 j;
|
||||||
uint256 len = sellers.length;
|
uint256 len =
|
||||||
while (j < len) { balances[j] =
|
sellers.length;
|
||||||
getBalance(sellers[j], token);
|
uint256[] memory balances =
|
||||||
|
new uint256[](len);
|
||||||
|
while (j < len) {
|
||||||
|
uint256 bal =
|
||||||
|
getBalance(
|
||||||
|
sellers[j],
|
||||||
|
token
|
||||||
|
);
|
||||||
|
balances[j] = bal;
|
||||||
|
unchecked { ++j; }
|
||||||
}
|
}
|
||||||
|
|
||||||
return balances;
|
return balances;
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
||||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
||||||
],
|
],
|
||||||
"p2pix": "0x2a54667b566B1Aa3779828720E6696AC18ae3f1b",
|
"p2pix": "0xefa5cE4351cda51192509cf8De7d8881ADAE95DD",
|
||||||
"token": "0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00"
|
"token": "0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00"
|
||||||
}
|
}
|
@ -3,6 +3,6 @@
|
|||||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
||||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
||||||
],
|
],
|
||||||
"p2pix": "0x7F4680D114B43c4434FB604c7Bc6306125D32f28",
|
"p2pix": "0xA9258eBb157E4cf5e756b77FDD0DF09C2F73240b",
|
||||||
"token": "0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29"
|
"token": "0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29"
|
||||||
}
|
}
|
File diff suppressed because one or more lines are too long
@ -575,7 +575,7 @@ export interface P2PIX extends BaseContract {
|
|||||||
sellers: PromiseOrValue<string>[],
|
sellers: PromiseOrValue<string>[],
|
||||||
token: PromiseOrValue<string>,
|
token: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
): Promise<[BigNumber[]] & { balances: BigNumber[] }>;
|
): Promise<[BigNumber[]]>;
|
||||||
|
|
||||||
getPixTarget(
|
getPixTarget(
|
||||||
seller: PromiseOrValue<string>,
|
seller: PromiseOrValue<string>,
|
||||||
|
@ -284,7 +284,6 @@ describe("P2PIX", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
it("should revert if pixTarget is empty", async () => {
|
it("should revert if pixTarget is empty", async () => {
|
||||||
// const pTarget = ethers.BigNumber.from(7331);
|
|
||||||
const root = ethers.utils.keccak256(
|
const root = ethers.utils.keccak256(
|
||||||
ethers.utils.toUtf8Bytes("root"),
|
ethers.utils.toUtf8Bytes("root"),
|
||||||
);
|
);
|
||||||
@ -338,6 +337,10 @@ describe("P2PIX", () => {
|
|||||||
owner.address,
|
owner.address,
|
||||||
);
|
);
|
||||||
const allowList = await p2pix.sellerAllowList(ownerKey);
|
const allowList = await p2pix.sellerAllowList(ownerKey);
|
||||||
|
const balances = await p2pix.callStatic.getBalances(
|
||||||
|
[owner.address, acc01.address],
|
||||||
|
erc20.address,
|
||||||
|
);
|
||||||
|
|
||||||
expect(tx).to.be.ok;
|
expect(tx).to.be.ok;
|
||||||
await expect(tx)
|
await expect(tx)
|
||||||
@ -352,6 +355,8 @@ describe("P2PIX", () => {
|
|||||||
expect(pixTarget).to.eq(pTarget);
|
expect(pixTarget).to.eq(pTarget);
|
||||||
expect(valid).to.eq(true);
|
expect(valid).to.eq(true);
|
||||||
expect(allowList).to.eq(root);
|
expect(allowList).to.eq(root);
|
||||||
|
expect(balances[0]).to.eq(price);
|
||||||
|
expect(balances[1]).to.eq(zero);
|
||||||
});
|
});
|
||||||
// edge case test
|
// edge case test
|
||||||
it("should create multiple deposits", async () => {
|
it("should create multiple deposits", async () => {
|
||||||
@ -380,6 +385,7 @@ describe("P2PIX", () => {
|
|||||||
const price2 = price.mul(ethers.BigNumber.from(2));
|
const price2 = price.mul(ethers.BigNumber.from(2));
|
||||||
const price3 = price.mul(ethers.BigNumber.from(3));
|
const price3 = price.mul(ethers.BigNumber.from(3));
|
||||||
const price4 = price.mul(ethers.BigNumber.from(4));
|
const price4 = price.mul(ethers.BigNumber.from(4));
|
||||||
|
const prices:BigNumber[] = [price, price2, price3, price4];
|
||||||
await erc20.mint(
|
await erc20.mint(
|
||||||
getSignerAddrs(4, await ethers.getSigners()),
|
getSignerAddrs(4, await ethers.getSigners()),
|
||||||
price4,
|
price4,
|
||||||
@ -410,6 +416,9 @@ describe("P2PIX", () => {
|
|||||||
.connect(acc03)
|
.connect(acc03)
|
||||||
.deposit(erc20.address, price4, pTarget, false, nullRoot);
|
.deposit(erc20.address, price4, pTarget, false, nullRoot);
|
||||||
|
|
||||||
|
const balances = await p2pix.callStatic.getBalances(
|
||||||
|
[owner.address, acc01.address, acc02.address, acc03.address], erc20.address);
|
||||||
|
|
||||||
const storage1 = await p2pix.callStatic.getBalance(owner.address, erc20.address);
|
const storage1 = await p2pix.callStatic.getBalance(owner.address, erc20.address);
|
||||||
const storage2 = await p2pix.callStatic.getBalance(acc01.address, erc20.address);
|
const storage2 = await p2pix.callStatic.getBalance(acc01.address, erc20.address);
|
||||||
const storage3 = await p2pix.callStatic.getBalance(acc02.address, erc20.address);
|
const storage3 = await p2pix.callStatic.getBalance(acc02.address, erc20.address);
|
||||||
@ -478,6 +487,11 @@ describe("P2PIX", () => {
|
|||||||
[acc03.address, p2pix.address],
|
[acc03.address, p2pix.address],
|
||||||
["-400000000000000000000", price4],
|
["-400000000000000000000", price4],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(prices[0]).to.eq(balances[0]);
|
||||||
|
expect(prices[1]).to.eq(balances[1]);
|
||||||
|
expect(prices[2]).to.eq(balances[2]);
|
||||||
|
expect(prices[3]).to.eq(balances[3]);
|
||||||
|
|
||||||
expect(storage1).to.eq(price);
|
expect(storage1).to.eq(price);
|
||||||
expect(pixTarget1).to.eq(pTarget);
|
expect(pixTarget1).to.eq(pTarget);
|
||||||
@ -685,35 +699,35 @@ describe("P2PIX", () => {
|
|||||||
proof,
|
proof,
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
// const storage: Lock = await p2pix.callStatic.mapLocks(1);
|
const storage: Lock = await p2pix.callStatic.mapLocks(1);
|
||||||
|
|
||||||
// const rc: ContractReceipt = await tx.wait();
|
const rc: ContractReceipt = await tx.wait();
|
||||||
// const expiration = rc.blockNumber + 10;
|
const expiration = rc.blockNumber + 10;
|
||||||
// const key = await p2pix.callStatic._castAddrToKey(owner.address);
|
const key = await p2pix.callStatic._castAddrToKey(owner.address);
|
||||||
|
|
||||||
// await expect(tx)
|
await expect(tx)
|
||||||
// .to.emit(p2pix, "LockAdded")
|
.to.emit(p2pix, "LockAdded")
|
||||||
// .withArgs(
|
.withArgs(
|
||||||
// acc02.address,
|
acc02.address,
|
||||||
// ethers.constants.One,
|
ethers.constants.One,
|
||||||
// key,
|
key,
|
||||||
// price,
|
price,
|
||||||
// );
|
);
|
||||||
// expect(tx).to.be.ok;
|
expect(tx).to.be.ok;
|
||||||
// expect(storage.sellerKey).to.eq(key);
|
expect(storage.sellerKey).to.eq(key);
|
||||||
// expect(storage.counter).to.eq(1);
|
expect(storage.counter).to.eq(1);
|
||||||
// expect(storage.relayerPremium).to.eq(
|
expect(storage.relayerPremium).to.eq(
|
||||||
// ethers.constants.Zero,
|
ethers.constants.Zero,
|
||||||
// );
|
);
|
||||||
// expect(storage.amount).to.eq(price);
|
expect(storage.amount).to.eq(price);
|
||||||
// expect(storage.expirationBlock).to.eq(expiration);
|
expect(storage.expirationBlock).to.eq(expiration);
|
||||||
// expect(storage.pixTarget).to.eq(target);
|
expect(storage.pixTarget).to.eq(target);
|
||||||
// expect(storage.buyerAddress).to.eq(acc02.address);
|
expect(storage.buyerAddress).to.eq(acc02.address);
|
||||||
// expect(storage.relayerTarget).to.eq(acc03.address);
|
expect(storage.relayerTarget).to.eq(acc03.address);
|
||||||
// expect(storage.relayerAddress).to.eq(acc01.address);
|
expect(storage.relayerAddress).to.eq(acc01.address);
|
||||||
// expect(storage.token).to.eq(erc20.address);
|
expect(storage.token).to.eq(erc20.address);
|
||||||
});
|
});
|
||||||
it("should create a lock, update storage and emit events via the reputation path", async () => {
|
it("should create a lock, update storage and emit events via the reputation path 1", async () => {
|
||||||
const root = ethers.constants.HashZero;
|
const root = ethers.constants.HashZero;
|
||||||
const target = ethers.BigNumber.from(101);
|
const target = ethers.BigNumber.from(101);
|
||||||
await erc20.approve(p2pix.address, price);
|
await erc20.approve(p2pix.address, price);
|
||||||
@ -741,8 +755,10 @@ describe("P2PIX", () => {
|
|||||||
const rc: ContractReceipt = await tx.wait();
|
const rc: ContractReceipt = await tx.wait();
|
||||||
const expiration = rc.blockNumber + 10;
|
const expiration = rc.blockNumber + 10;
|
||||||
const key = await p2pix.callStatic._castAddrToKey(owner.address);
|
const key = await p2pix.callStatic._castAddrToKey(owner.address);
|
||||||
|
const castBack = await p2pix.callStatic._castKeyToAddr(key);
|
||||||
|
|
||||||
expect(tx).to.be.ok;
|
expect(tx).to.be.ok;
|
||||||
|
expect(castBack).to.eq(owner.address);
|
||||||
expect(storage.sellerKey).to.eq(key);
|
expect(storage.sellerKey).to.eq(key);
|
||||||
expect(storage.counter).to.eq(1);
|
expect(storage.counter).to.eq(1);
|
||||||
expect(storage.relayerPremium).to.eq(
|
expect(storage.relayerPremium).to.eq(
|
||||||
@ -765,6 +781,94 @@ describe("P2PIX", () => {
|
|||||||
storage.amount,
|
storage.amount,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it("should create a lock, update storage and emit events via the reputation path 2", async () => {
|
||||||
|
const root = ethers.constants.HashZero;
|
||||||
|
const newPrice = price.mul(ethers.constants.Two).add(ethers.constants.One);
|
||||||
|
const endtoendID = ethers.constants.HashZero;
|
||||||
|
const target = ethers.BigNumber.from(101);
|
||||||
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
|
["uint160", "uint256", "bytes32"],
|
||||||
|
[target, price, endtoendID],
|
||||||
|
);
|
||||||
|
const messageHashBytes =
|
||||||
|
ethers.utils.arrayify(messageToSign);
|
||||||
|
const flatSig = await acc01.signMessage(
|
||||||
|
messageHashBytes,
|
||||||
|
);
|
||||||
|
const sig = ethers.utils.splitSignature(flatSig);
|
||||||
|
await erc20.approve(p2pix.address, newPrice);
|
||||||
|
await p2pix.deposit(
|
||||||
|
erc20.address,
|
||||||
|
newPrice,
|
||||||
|
target,
|
||||||
|
true,
|
||||||
|
root,
|
||||||
|
);
|
||||||
|
await p2pix
|
||||||
|
.connect(acc01)
|
||||||
|
.lock(
|
||||||
|
owner.address,
|
||||||
|
erc20.address,
|
||||||
|
acc02.address,
|
||||||
|
acc03.address,
|
||||||
|
price,
|
||||||
|
price,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
await p2pix
|
||||||
|
.connect(acc01)
|
||||||
|
.release(
|
||||||
|
1,
|
||||||
|
acc02.address,
|
||||||
|
endtoendID,
|
||||||
|
sig.r,
|
||||||
|
sig.s,
|
||||||
|
sig.v,
|
||||||
|
);
|
||||||
|
const tx = await p2pix
|
||||||
|
.connect(acc01)
|
||||||
|
.lock(
|
||||||
|
owner.address,
|
||||||
|
erc20.address,
|
||||||
|
acc02.address,
|
||||||
|
acc03.address,
|
||||||
|
0,
|
||||||
|
price.add(ethers.constants.One),
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
const storage: Lock = await p2pix.callStatic.mapLocks(2);
|
||||||
|
|
||||||
|
const rc: ContractReceipt = await tx.wait();
|
||||||
|
const expiration = rc.blockNumber + 10;
|
||||||
|
const key = await p2pix.callStatic._castAddrToKey(owner.address);
|
||||||
|
const castBack = await p2pix.callStatic._castKeyToAddr(key);
|
||||||
|
|
||||||
|
expect(tx).to.be.ok;
|
||||||
|
expect(castBack).to.eq(owner.address);
|
||||||
|
expect(storage.sellerKey).to.eq(key);
|
||||||
|
expect(storage.counter).to.eq(2);
|
||||||
|
expect(storage.relayerPremium).to.eq(
|
||||||
|
ethers.constants.Zero,
|
||||||
|
);
|
||||||
|
expect(storage.amount).to.eq(price.add(ethers.constants.One));
|
||||||
|
expect(storage.expirationBlock).to.eq(expiration);
|
||||||
|
expect(storage.pixTarget).to.eq(target);
|
||||||
|
expect(storage.buyerAddress).to.eq(acc02.address);
|
||||||
|
expect(storage.relayerTarget).to.eq(acc03.address);
|
||||||
|
expect(storage.relayerAddress).to.eq(acc01.address);
|
||||||
|
expect(storage.token).to.eq(erc20.address);
|
||||||
|
|
||||||
|
await expect(tx)
|
||||||
|
.to.emit(p2pix, "LockAdded")
|
||||||
|
.withArgs(
|
||||||
|
acc02.address,
|
||||||
|
2,
|
||||||
|
key,
|
||||||
|
storage.amount,
|
||||||
|
);
|
||||||
|
});
|
||||||
// edge case test
|
// edge case test
|
||||||
it("should create multiple locks", async () => {
|
it("should create multiple locks", async () => {
|
||||||
const newPrice = price.div(ethers.BigNumber.from(2));
|
const newPrice = price.div(ethers.BigNumber.from(2));
|
||||||
@ -912,14 +1016,8 @@ describe("P2PIX", () => {
|
|||||||
});
|
});
|
||||||
describe("Set sellerBalance Valid State", async () => {
|
describe("Set sellerBalance Valid State", async () => {
|
||||||
it("should revert if sellerBalance hasn't been initialized", async () => {
|
it("should revert if sellerBalance hasn't been initialized", async () => {
|
||||||
// await erc20.approve(p2pix.address, price);
|
|
||||||
// await p2pix.deposit(
|
|
||||||
// erc20.address,
|
|
||||||
// price,
|
|
||||||
// "pixTarget",
|
|
||||||
// merkleRoot,
|
|
||||||
// );
|
|
||||||
const fail = p2pix.setValidState(erc20.address,false);
|
const fail = p2pix.setValidState(erc20.address,false);
|
||||||
|
|
||||||
await expect(fail).to.be.revertedWithCustomError(
|
await expect(fail).to.be.revertedWithCustomError(
|
||||||
p2pix,
|
p2pix,
|
||||||
P2PixErrors.NotInitialized,
|
P2PixErrors.NotInitialized,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user