Added support for flatsigs
This commit is contained in:
parent
26a495246e
commit
631c1d5dfb
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
"contractName": "DataTypes",
|
||||
"sourceName": "contracts/core/DataTypes.sol",
|
||||
"abi": [],
|
||||
"bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212201904685203adfcebeda9a1444d5381c24a37e2895e8a7dff26bd8d5af2fafcbc64736f6c63430008130033",
|
||||
"deployedBytecode": "0x600080fdfea26469706673582212201904685203adfcebeda9a1444d5381c24a37e2895e8a7dff26bd8d5af2fafcbc64736f6c63430008130033",
|
||||
"bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea2646970667358221220cd1f7ebb936fcf31afe01a797870de94db3214655afaa1cb621785aa86bd86e964736f6c63430008130033",
|
||||
"deployedBytecode": "0x600080fdfea2646970667358221220cd1f7ebb936fcf31afe01a797870de94db3214655afaa1cb621785aa86bd86e964736f6c63430008130033",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -9,8 +9,8 @@
|
||||
"type": "error"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212201f6fe8a460e1235bb7e19365d8e3cc56b718d44f5db82f5fa3c90d3c7da59ebf64736f6c63430008130033",
|
||||
"deployedBytecode": "0x600080fdfea26469706673582212201f6fe8a460e1235bb7e19365d8e3cc56b718d44f5db82f5fa3c90d3c7da59ebf64736f6c63430008130033",
|
||||
"bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212209602e77b0002730843efd4bf0aab444a6a8daeade7f7f10052351ae288f5aa5264736f6c63430008130033",
|
||||
"deployedBytecode": "0x600080fdfea26469706673582212209602e77b0002730843efd4bf0aab444a6a8daeade7f7f10052351ae288f5aa5264736f6c63430008130033",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/3d12978eb8a70621f317c36179381ad8.json"
|
||||
"buildInfo": "../../build-info/811e76435f5423608b4f8fda7811bf8e.json"
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -35,9 +35,7 @@ abstract contract BaseUtils is
|
||||
|
||||
function _signerCheck(
|
||||
bytes32 _message,
|
||||
bytes32 _r,
|
||||
bytes32 _s,
|
||||
uint8 _v
|
||||
bytes calldata _signature
|
||||
) internal view {
|
||||
if (usedTransactions(_message))
|
||||
revert TxAlreadyUsed();
|
||||
@ -45,13 +43,11 @@ abstract contract BaseUtils is
|
||||
if (
|
||||
!validBacenSigners(
|
||||
_castAddrToKey(
|
||||
ECDSA.recover(
|
||||
ECDSA.recoverCalldata(
|
||||
ECDSA.toEthSignedMessageHash(
|
||||
_message
|
||||
),
|
||||
_v,
|
||||
_r,
|
||||
_s
|
||||
_signature
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -20,6 +20,12 @@ library DataTypes {
|
||||
uint256[] expiredLocks;
|
||||
}
|
||||
|
||||
struct ReleaseArgs {
|
||||
uint256 lockID;
|
||||
bytes32 pixTimestamp;
|
||||
bytes signature;
|
||||
}
|
||||
|
||||
struct Lock {
|
||||
uint256 counter;
|
||||
uint256 expirationBlock;
|
||||
|
@ -218,7 +218,7 @@ abstract contract OwnerSettings is
|
||||
assembly {
|
||||
success := staticcall(
|
||||
// gas
|
||||
0x7530,
|
||||
gas(),
|
||||
// address
|
||||
sload(reputation.slot),
|
||||
// argsOffset
|
||||
|
@ -15,26 +15,43 @@ library ECDSA {
|
||||
0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0;
|
||||
|
||||
/// @dev Recovers the signer's address from a message digest `hash`,
|
||||
/// and the signature defined by `v`, `r`, `s`.
|
||||
function recover(
|
||||
/// and the `signature`.
|
||||
///
|
||||
/// This function does NOT accept EIP-2098 short form signatures.
|
||||
/// Use `recover(bytes32 hash, bytes32 r, bytes32 vs)` for EIP-2098
|
||||
/// short form signatures instead.
|
||||
function recoverCalldata(
|
||||
bytes32 hash,
|
||||
uint8 v,
|
||||
bytes32 r,
|
||||
bytes32 s
|
||||
bytes calldata signature
|
||||
) internal view returns (address result) {
|
||||
/// @solidity memory-safe-assembly
|
||||
assembly {
|
||||
// Copy the free memory pointer so that we can restore it later.
|
||||
let m := mload(0x40)
|
||||
// Directly copy `r` and `s` from the calldata.
|
||||
calldatacopy(0x40, signature.offset, 0x40)
|
||||
// Store the `hash` in the scratch space.
|
||||
mstore(0x00, hash)
|
||||
mstore(0x20, and(v, 0xff))
|
||||
mstore(0x40, r)
|
||||
mstore(0x60, s)
|
||||
// Compute `v` and store it in the scratch space.
|
||||
mstore(
|
||||
0x20,
|
||||
byte(
|
||||
0,
|
||||
calldataload(add(signature.offset, 0x40))
|
||||
)
|
||||
)
|
||||
pop(
|
||||
staticcall(
|
||||
gas(), // Amount of gas left for the transaction.
|
||||
and(
|
||||
// If the signature is exactly 65 bytes in length.
|
||||
eq(signature.length, 65),
|
||||
// If `s` in lower half order, such that the signature is not malleable.
|
||||
lt(s, add(_MALLEABILITY_THRESHOLD, 1)), // Address of `ecrecover`.
|
||||
lt(
|
||||
mload(0x60),
|
||||
add(_MALLEABILITY_THRESHOLD, 1)
|
||||
)
|
||||
), // Address of `ecrecover`.
|
||||
0x00, // Start of input.
|
||||
0x80, // Size of input.
|
||||
0x00, // Start of output.
|
||||
|
@ -20,6 +20,7 @@ contract P2PIX is BaseUtils {
|
||||
|
||||
using DT for DT.DepositArgs;
|
||||
using DT for DT.LockArgs;
|
||||
using DT for DT.ReleaseArgs;
|
||||
using DT for DT.Lock;
|
||||
using DT for DT.LockStatus;
|
||||
|
||||
@ -206,13 +207,9 @@ contract P2PIX is BaseUtils {
|
||||
/// - `release` caller gets accrued with `l.relayerPremium` as userRecord credit;
|
||||
/// @dev Function sighash: 0x4e1389ed.
|
||||
function release(
|
||||
uint256 lockID,
|
||||
bytes32 pixTimestamp,
|
||||
bytes32 r,
|
||||
bytes32 s,
|
||||
uint8 v
|
||||
DT.ReleaseArgs calldata args
|
||||
) public nonReentrant {
|
||||
DT.Lock storage l = mapLocks[lockID];
|
||||
DT.Lock storage l = mapLocks[args.lockID];
|
||||
|
||||
if (l.amount == 0) revert AlreadyReleased();
|
||||
if (l.expirationBlock < block.number)
|
||||
@ -222,11 +219,11 @@ contract P2PIX is BaseUtils {
|
||||
abi.encodePacked(
|
||||
l.pixTarget,
|
||||
l.amount,
|
||||
pixTimestamp
|
||||
args.pixTimestamp
|
||||
)
|
||||
);
|
||||
|
||||
_signerCheck(message, r, s, v);
|
||||
_signerCheck(message, args.signature);
|
||||
|
||||
ERC20 t = ERC20(l.token);
|
||||
|
||||
@ -254,7 +251,7 @@ contract P2PIX is BaseUtils {
|
||||
lockAmount
|
||||
);
|
||||
|
||||
emit LockReleased(l.buyerAddress, lockID, lockAmount);
|
||||
emit LockReleased(l.buyerAddress, args.lockID, lockAmount);
|
||||
}
|
||||
|
||||
/// @notice Unlocks expired locks.
|
||||
|
@ -15,7 +15,7 @@ const _abi = [
|
||||
];
|
||||
|
||||
const _bytecode =
|
||||
"0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212201f6fe8a460e1235bb7e19365d8e3cc56b718d44f5db82f5fa3c90d3c7da59ebf64736f6c63430008130033";
|
||||
"0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212209602e77b0002730843efd4bf0aab444a6a8daeade7f7f10052351ae288f5aa5264736f6c63430008130033";
|
||||
|
||||
type ECDSAConstructorParams =
|
||||
| [signer?: Signer]
|
||||
|
File diff suppressed because one or more lines are too long
@ -71,6 +71,18 @@ export declare namespace DataTypes {
|
||||
merkleProof: string[];
|
||||
expiredLocks: BigNumber[];
|
||||
};
|
||||
|
||||
export type ReleaseArgsStruct = {
|
||||
lockID: PromiseOrValue<BigNumberish>;
|
||||
pixTimestamp: PromiseOrValue<BytesLike>;
|
||||
signature: PromiseOrValue<BytesLike>;
|
||||
};
|
||||
|
||||
export type ReleaseArgsStructOutput = [BigNumber, string, string] & {
|
||||
lockID: BigNumber;
|
||||
pixTimestamp: string;
|
||||
signature: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface P2PIXInterface extends utils.Interface {
|
||||
@ -92,7 +104,7 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
"lockCounter()": FunctionFragment;
|
||||
"mapLocks(uint256)": FunctionFragment;
|
||||
"owner()": FunctionFragment;
|
||||
"release(uint256,bytes32,bytes32,bytes32,uint8)": FunctionFragment;
|
||||
"release((uint256,bytes32,bytes))": FunctionFragment;
|
||||
"reputation()": FunctionFragment;
|
||||
"sellerAllowList(address)": FunctionFragment;
|
||||
"setDefaultLockBlocks(uint256)": FunctionFragment;
|
||||
@ -216,13 +228,7 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "release",
|
||||
values: [
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<BytesLike>,
|
||||
PromiseOrValue<BytesLike>,
|
||||
PromiseOrValue<BytesLike>,
|
||||
PromiseOrValue<BigNumberish>
|
||||
]
|
||||
values: [DataTypes.ReleaseArgsStruct]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "reputation",
|
||||
@ -706,11 +712,7 @@ export interface P2PIX extends BaseContract {
|
||||
owner(overrides?: CallOverrides): Promise<[string]>;
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BigNumberish>,
|
||||
pixTimestamp: PromiseOrValue<BytesLike>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
v: PromiseOrValue<BigNumberish>,
|
||||
args: DataTypes.ReleaseArgsStruct,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
@ -889,11 +891,7 @@ export interface P2PIX extends BaseContract {
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BigNumberish>,
|
||||
pixTimestamp: PromiseOrValue<BytesLike>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
v: PromiseOrValue<BigNumberish>,
|
||||
args: DataTypes.ReleaseArgsStruct,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
@ -1072,11 +1070,7 @@ export interface P2PIX extends BaseContract {
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BigNumberish>,
|
||||
pixTimestamp: PromiseOrValue<BytesLike>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
v: PromiseOrValue<BigNumberish>,
|
||||
args: DataTypes.ReleaseArgsStruct,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
@ -1367,11 +1361,7 @@ export interface P2PIX extends BaseContract {
|
||||
owner(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BigNumberish>,
|
||||
pixTimestamp: PromiseOrValue<BytesLike>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
v: PromiseOrValue<BigNumberish>,
|
||||
args: DataTypes.ReleaseArgsStruct,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
@ -1541,11 +1531,7 @@ export interface P2PIX extends BaseContract {
|
||||
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BigNumberish>,
|
||||
pixTimestamp: PromiseOrValue<BytesLike>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
v: PromiseOrValue<BigNumberish>,
|
||||
args: DataTypes.ReleaseArgsStruct,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
|
@ -39,6 +39,7 @@ import {
|
||||
randomSigners,
|
||||
createDepositArgs,
|
||||
createLockArgs,
|
||||
createReleaseArgs
|
||||
} from "./utils/fixtures";
|
||||
|
||||
describe("P2PIX", () => {
|
||||
@ -869,7 +870,7 @@ describe("P2PIX", () => {
|
||||
const flatSig = await acc01.signMessage(
|
||||
messageHashBytes,
|
||||
);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
await erc20.approve(p2pix.address, newPrice);
|
||||
await p2pix.deposit(
|
||||
createDepositArgs(
|
||||
@ -894,11 +895,11 @@ describe("P2PIX", () => {
|
||||
await p2pix
|
||||
.connect(acc01)
|
||||
.release(
|
||||
1,
|
||||
createReleaseArgs(
|
||||
ethers.constants.One,
|
||||
endtoendID,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig
|
||||
),
|
||||
);
|
||||
const tx = await p2pix
|
||||
.connect(acc01)
|
||||
@ -1267,7 +1268,7 @@ describe("P2PIX", () => {
|
||||
const flatSig = await acc01.signMessage(
|
||||
ethers.utils.arrayify(messageToSign),
|
||||
);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
await erc20.approve(p2pix.address, price);
|
||||
await p2pix.deposit(
|
||||
createDepositArgs(
|
||||
@ -1292,11 +1293,11 @@ describe("P2PIX", () => {
|
||||
const lockID = ethers.constants.One;
|
||||
await mine(13);
|
||||
const fail = p2pix.release(
|
||||
createReleaseArgs(
|
||||
lockID,
|
||||
ethers.constants.HashZero,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig,
|
||||
),
|
||||
);
|
||||
|
||||
await expect(fail).to.be.revertedWithCustomError(
|
||||
@ -1314,7 +1315,7 @@ describe("P2PIX", () => {
|
||||
const flatSig = await acc01.signMessage(
|
||||
ethers.utils.arrayify(messageToSign),
|
||||
);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
await erc20.approve(p2pix.address, price);
|
||||
await p2pix.deposit(
|
||||
createDepositArgs(
|
||||
@ -1338,18 +1339,18 @@ describe("P2PIX", () => {
|
||||
);
|
||||
const lockID = ethers.constants.One;
|
||||
await p2pix.release(
|
||||
createReleaseArgs(
|
||||
lockID,
|
||||
ethers.constants.HashZero,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig
|
||||
),
|
||||
);
|
||||
const fail = p2pix.release(
|
||||
createReleaseArgs(
|
||||
lockID,
|
||||
ethers.constants.HashZero,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig,
|
||||
),
|
||||
);
|
||||
|
||||
await expect(fail).to.be.revertedWithCustomError(
|
||||
@ -1366,7 +1367,7 @@ describe("P2PIX", () => {
|
||||
const flatSig = await owner.signMessage(
|
||||
ethers.utils.arrayify(messageToSign),
|
||||
);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
await erc20.approve(p2pix.address, price);
|
||||
await p2pix.deposit(
|
||||
createDepositArgs(
|
||||
@ -1392,11 +1393,11 @@ describe("P2PIX", () => {
|
||||
await p2pix
|
||||
.connect(acc01)
|
||||
.release(
|
||||
1,
|
||||
createReleaseArgs(
|
||||
ethers.constants.One,
|
||||
ethers.constants.HashZero,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig,
|
||||
),
|
||||
);
|
||||
await p2pix
|
||||
.connect(acc03)
|
||||
@ -1412,11 +1413,11 @@ describe("P2PIX", () => {
|
||||
const fail = p2pix
|
||||
.connect(acc01)
|
||||
.release(
|
||||
2,
|
||||
createReleaseArgs(
|
||||
ethers.constants.Two,
|
||||
ethers.constants.HashZero,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig,
|
||||
),
|
||||
);
|
||||
|
||||
await expect(fail).to.be.revertedWithCustomError(
|
||||
@ -1433,7 +1434,7 @@ describe("P2PIX", () => {
|
||||
const flatSig = await acc03.signMessage(
|
||||
ethers.utils.arrayify(messageToSign),
|
||||
);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
|
||||
await erc20.approve(p2pix.address, price);
|
||||
await p2pix.deposit(
|
||||
@ -1459,11 +1460,11 @@ describe("P2PIX", () => {
|
||||
const fail = p2pix
|
||||
.connect(acc01)
|
||||
.release(
|
||||
1,
|
||||
createReleaseArgs(
|
||||
ethers.constants.One,
|
||||
ethers.constants.HashZero,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig,
|
||||
),
|
||||
);
|
||||
|
||||
await expect(fail).to.be.revertedWithCustomError(
|
||||
@ -1494,7 +1495,7 @@ describe("P2PIX", () => {
|
||||
const flatSig = await acc01.signMessage(
|
||||
messageHashBytes,
|
||||
);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
const root = ethers.constants.HashZero;
|
||||
|
||||
await erc20.approve(p2pix.address, price);
|
||||
@ -1536,11 +1537,11 @@ describe("P2PIX", () => {
|
||||
const tx = await p2pix
|
||||
.connect(acc01)
|
||||
.release(
|
||||
1,
|
||||
createReleaseArgs(
|
||||
ethers.constants.One,
|
||||
endtoendID,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig,
|
||||
),
|
||||
);
|
||||
|
||||
const lockStatus1 =
|
||||
@ -1650,7 +1651,7 @@ describe("P2PIX", () => {
|
||||
const flatSig1 = await owner.signMessage(
|
||||
ethers.utils.arrayify(messageToSign1),
|
||||
);
|
||||
const sig1 = ethers.utils.splitSignature(flatSig1);
|
||||
// const sig1 = ethers.utils.splitSignature(flatSig1);
|
||||
const messageToSign2 = ethers.utils.solidityKeccak256(
|
||||
["bytes32", "uint80", "bytes32"],
|
||||
[await p2pix.callStatic.getStr(pixTarget), 50, endtoendID],
|
||||
@ -1658,7 +1659,7 @@ describe("P2PIX", () => {
|
||||
const flatSig2 = await owner.signMessage(
|
||||
ethers.utils.arrayify(messageToSign2),
|
||||
);
|
||||
const sig2 = ethers.utils.splitSignature(flatSig2);
|
||||
// const sig2 = ethers.utils.splitSignature(flatSig2);
|
||||
const messageToSign3 = ethers.utils.solidityKeccak256(
|
||||
["bytes32", "uint80", "bytes32"],
|
||||
[await p2pix.callStatic.getStr(pixTarget), 25, endtoendID],
|
||||
@ -1666,7 +1667,7 @@ describe("P2PIX", () => {
|
||||
const flatSig3 = await owner.signMessage(
|
||||
ethers.utils.arrayify(messageToSign3),
|
||||
);
|
||||
const sig3 = ethers.utils.splitSignature(flatSig3);
|
||||
// const sig3 = ethers.utils.splitSignature(flatSig3);
|
||||
await erc20.approve(p2pix.address, price);
|
||||
await p2pix.deposit(
|
||||
createDepositArgs(
|
||||
@ -1739,33 +1740,33 @@ describe("P2PIX", () => {
|
||||
const tx = await p2pix
|
||||
.connect(acc01)
|
||||
.release(
|
||||
createReleaseArgs(
|
||||
lockID,
|
||||
endtoendID,
|
||||
sig1.r,
|
||||
sig1.s,
|
||||
sig1.v,
|
||||
flatSig1,
|
||||
),
|
||||
);
|
||||
// relayerPremium != 0 &&
|
||||
// lock's msg.sender != release's msg.sender
|
||||
const tx1 = await p2pix
|
||||
.connect(acc01)
|
||||
.release(
|
||||
createReleaseArgs(
|
||||
lockID2,
|
||||
endtoendID,
|
||||
sig2.r,
|
||||
sig2.s,
|
||||
sig2.v,
|
||||
flatSig2,
|
||||
),
|
||||
);
|
||||
// relayerPremium != 0 &&
|
||||
// lock's msg.sender == release's msg.sender
|
||||
const tx2 = await p2pix
|
||||
.connect(acc03)
|
||||
.release(
|
||||
createReleaseArgs(
|
||||
lockID3,
|
||||
endtoendID,
|
||||
sig3.r,
|
||||
sig3.s,
|
||||
sig3.v,
|
||||
flatSig3,
|
||||
),
|
||||
);
|
||||
const used1 = await p2pix.callStatic.usedTransactions(
|
||||
ethers.utils.arrayify(messageToSign1),
|
||||
@ -1909,7 +1910,7 @@ describe("P2PIX", () => {
|
||||
const flatSig = await acc01.signMessage(
|
||||
messageHashBytes,
|
||||
);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
await erc20.approve(p2pix.address, price);
|
||||
await p2pix.deposit(
|
||||
createDepositArgs(
|
||||
@ -1934,11 +1935,11 @@ describe("P2PIX", () => {
|
||||
const lockID = ethers.constants.One;
|
||||
// await mine(10);
|
||||
await p2pix.release(
|
||||
createReleaseArgs(
|
||||
lockID,
|
||||
endtoendID,
|
||||
sig.r,
|
||||
sig.s,
|
||||
sig.v,
|
||||
flatSig,
|
||||
),
|
||||
);
|
||||
const fail = p2pix.unlockExpired([lockID]);
|
||||
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
Reputation,
|
||||
} from "../../src/types";
|
||||
|
||||
import { Call, RepFixture, P2PixAndReputation, DepositArgs, LockArgs } from "./interfaces";
|
||||
import { Call, RepFixture, P2PixAndReputation, DepositArgs, LockArgs, ReleaseArgs } from "./interfaces";
|
||||
|
||||
|
||||
// exported constants
|
||||
@ -32,6 +32,12 @@ export const createLockArgs = (seller: string, token: string, amount: BigNumber,
|
||||
expiredLocks,
|
||||
});
|
||||
|
||||
export const createReleaseArgs = (lockID: BigNumber, pixTimestamp: string, signature: string): ReleaseArgs => ({
|
||||
lockID,
|
||||
pixTimestamp,
|
||||
signature,
|
||||
});
|
||||
|
||||
export const getSignerAddrs = (
|
||||
amount: number,
|
||||
addrs: SignerWithAddress[],
|
||||
|
@ -31,6 +31,12 @@ export interface LockArgs {
|
||||
expiredLocks: BigNumber[];
|
||||
}
|
||||
|
||||
export interface ReleaseArgs {
|
||||
lockID: BigNumber;
|
||||
pixTimestamp: string;
|
||||
signature: string;
|
||||
}
|
||||
|
||||
export interface Lock {
|
||||
counter: BigNumber;
|
||||
expirationBlock: BigNumber;
|
||||
|
Loading…
x
Reference in New Issue
Block a user