Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

encodeOrderParams function bug? #61

Open
jusonalien opened this issue Jun 16, 2022 · 0 comments
Open

encodeOrderParams function bug? #61

jusonalien opened this issue Jun 16, 2022 · 0 comments

Comments

@jusonalien
Copy link

Describe the bug
The MakerOrder is defined here:

export interface MakerOrder {
  isOrderAsk: boolean; // true --> ask / false --> bid
  signer: string; // signer address of the maker order
  collection: string; // collection address
  price: BigNumberish;
  tokenId: BigNumberish; // id of the token
  amount: BigNumberish; // amount of tokens to sell/purchase (must be 1 for ERC721, 1+ for ERC1155)
  strategy: string; // strategy for trade execution (e.g., DutchAuction, StandardSaleForFixedPrice)
  currency: string; // currency address
  nonce: BigNumberish; // order nonce (must be unique unless new maker order is meant to override existing one e.g., lower ask price)
  startTime: BigNumberish; // startTime in timestamp
  endTime: BigNumberish; // endTime in timestamp
  minPercentageToAsk: BigNumberish;
  params: any[]; // params (e.g., price, target account for private sale)
}

But its encoder function seems to be implemented bugly

MISSING the type check of params: any[];

export const encodeOrderParams = (params?: any[] | null): { paramsTypes: SolidityType[]; encodedParams: BytesLike } => {
  const nonNullParams = params || [];
  const paramsTypes: SolidityType[] = nonNullParams.map((param): SolidityType => {
    if (utils.isAddress(param)) {
      return "address";
    }

    if (typeof param === "boolean") {
      return "bool";
    }

    try {
      BigNumber.from(param);
      return "uint256";
    } catch (error) {
      throw Error("Params have unsupported solidity types");
    }
  });

  return { paramsTypes, encodedParams: utils.defaultAbiCoder.encode(paramsTypes, nonNullParams) };
};
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant