diff --git a/src/limit-order/limit-order.ts b/src/limit-order/limit-order.ts index f5c4a55..0d6908b 100644 --- a/src/limit-order/limit-order.ts +++ b/src/limit-order/limit-order.ts @@ -12,8 +12,6 @@ import {MakerTraits} from './maker-traits' import {Extension} from './extension' import {Address} from '../address' -const ZeroAddressHalf = '0'.repeat(20) - export class LimitOrder { private static readonly Web3Type = `tuple(${[ 'uint256 salt', @@ -142,7 +140,10 @@ export class LimitOrder { return getOrderHash(this.getTypedData(getLimitOrderV4Domain(chainId))) } + /** + * Returns true if only a specific address can fill order + */ public isPrivate(): boolean { - return this.makerTraits.allowedSender() !== ZeroAddressHalf + return this.makerTraits.isPrivate() } } diff --git a/src/limit-order/maker-traits.ts b/src/limit-order/maker-traits.ts index 9a2451f..8fe2777 100644 --- a/src/limit-order/maker-traits.ts +++ b/src/limit-order/maker-traits.ts @@ -67,6 +67,10 @@ export class MakerTraits { .padStart(20, '0') } + public isPrivate(): boolean { + return this.value.getMask(MakerTraits.ALLOWED_SENDER_MASK).value !== 0n + } + public withAllowedSender(sender: Address): this { assert(!sender.isZero(), 'Use withAnySender() to remove sender check')