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

encodeOrderParams function bug? #61

@jusonalien

Description

@jusonalien

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) };
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions