diff --git a/src/fusion-order/fusion-extension.ts b/src/fusion-order/fusion-extension.ts index 3cb1bc2..05dffa4 100644 --- a/src/fusion-order/fusion-extension.ts +++ b/src/fusion-order/fusion-extension.ts @@ -40,6 +40,13 @@ export class FusionExtension { public static decode(bytes: string): FusionExtension { const extension = Extension.decode(bytes) + return FusionExtension.fromExtension(extension) + } + + /** + * Create `FusionExtension` from `Extension` + */ + public static fromExtension(extension: Extension): FusionExtension { const settlementContract = Address.fromFirstBytes( extension.makingAmountData ) diff --git a/src/fusion-order/fusion-order.ts b/src/fusion-order/fusion-order.ts index 6c93b0f..62f62ff 100644 --- a/src/fusion-order/fusion-order.ts +++ b/src/fusion-order/fusion-order.ts @@ -37,7 +37,7 @@ export class FusionOrder { private inner: LimitOrder - private constructor( + protected constructor( /** * Fusion extension address * @see https://github.com/1inch/limit-order-settlement @@ -72,7 +72,15 @@ export class FusionOrder { orderExpirationDelay?: bigint enablePermit2?: boolean source?: string - } = FusionOrder.defaultExtra + } = FusionOrder.defaultExtra, + extension = new FusionExtension( + settlementExtensionContract, + auctionDetails, + postInteractionData, + extra.permit + ? new Interaction(orderInfo.makerAsset, extra.permit) + : undefined + ) ) { const allowPartialFills = extra.allowPartialFills ?? @@ -88,8 +96,6 @@ export class FusionOrder { extra.orderExpirationDelay ?? FusionOrder.defaultExtra.orderExpirationDelay - const {nonce, permit} = extra - const deadline = auctionDetails.startTime + auctionDetails.duration + @@ -103,7 +109,7 @@ export class FusionOrder { if (makerTraits.isBitInvalidatorMode()) { assert( - nonce !== undefined, + extra.nonce !== undefined, 'Nonce required, when partial fill or multiple fill disallowed' ) } @@ -116,8 +122,8 @@ export class FusionOrder { makerTraits.enablePermit2() } - if (nonce !== undefined) { - makerTraits.withNonce(nonce) + if (extra.nonce !== undefined) { + makerTraits.withNonce(extra.nonce) } /** @@ -127,13 +133,6 @@ export class FusionOrder { ? settlementExtensionContract : orderInfo.receiver - const extension = new FusionExtension( - settlementExtensionContract, - auctionDetails, - postInteractionData, - permit ? new Interaction(orderInfo.makerAsset, permit) : undefined - ) - const builtExtension = extension.build() const salt = LimitOrder.buildSalt(builtExtension, orderInfo.salt) const saltWithInjectedTrackCode = orderInfo.salt @@ -220,6 +219,10 @@ export class FusionOrder { return this.inner.makerTraits.nonceOrEpoch() } + get salt(): bigint { + return this.inner.salt + } + static new( /** * Fusion extension address diff --git a/src/index.ts b/src/index.ts index aab0284..bcab889 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,10 @@ export { ExtensionBuilder, AmountMode, getLimitOrderV4Domain, - LimitOrderContract + LimitOrderContract, + OrderInfoData, + EIP712TypedData, + MakerTraits } from '@1inch/limit-order-sdk' export * from './fusion-order/index' export * from './auction-calculator/index' @@ -18,6 +21,7 @@ export * from './sdk/index' export * from './constants' export * from './utils' export * from './utils/amounts' +export * from './utils/time' export * from './validations' export * from './ws-api' export * from './errors'