This repository was archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
encodeOrderParams function bug? #61
Copy link
Copy link
Open
Description
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) };
};Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels