From a72212888ea0a5f11152cb6c339cf839bf1e10ae Mon Sep 17 00:00:00 2001 From: Sluder Date: Thu, 14 Dec 2023 11:59:30 -0500 Subject: [PATCH] Inline datum support --- src/dex/minswap.ts | 2 ++ src/dex/muesliswap.ts | 2 ++ src/dex/sundaeswap.ts | 2 ++ src/dex/teddyswap.ts | 1 + src/dex/vyfinance.ts | 2 ++ src/dex/wingriders.ts | 2 ++ src/providers/wallet/lucid-provider.ts | 8 ++++++-- src/types.ts | 1 + 8 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/dex/minswap.ts b/src/dex/minswap.ts index eeac4f5..549ed62 100644 --- a/src/dex/minswap.ts +++ b/src/dex/minswap.ts @@ -210,6 +210,7 @@ export class Minswap extends BaseDex { }, ], datum: datumBuilder.getCbor(), + isInlineDatum: false, spendUtxos: spendUtxos, } ) @@ -230,6 +231,7 @@ export class Minswap extends BaseDex { address: returnAddress, addressType: AddressType.Base, assetBalances: relevantUtxo.assetBalances, + isInlineDatum: false, spendUtxos: [relevantUtxo], } ]; diff --git a/src/dex/muesliswap.ts b/src/dex/muesliswap.ts index d910020..b8e7983 100644 --- a/src/dex/muesliswap.ts +++ b/src/dex/muesliswap.ts @@ -202,6 +202,7 @@ export class MuesliSwap extends BaseDex { }, ], datum: datumBuilder.getCbor(), + isInlineDatum: false, spendUtxos: spendUtxos, } ) @@ -222,6 +223,7 @@ export class MuesliSwap extends BaseDex { address: returnAddress, addressType: AddressType.Base, assetBalances: relevantUtxo.assetBalances, + isInlineDatum: false, spendUtxos: [relevantUtxo], } ]; diff --git a/src/dex/sundaeswap.ts b/src/dex/sundaeswap.ts index 5df6d65..1416f4c 100644 --- a/src/dex/sundaeswap.ts +++ b/src/dex/sundaeswap.ts @@ -185,6 +185,7 @@ export class SundaeSwap extends BaseDex { }, ], datum: datumBuilder.getCbor(), + isInlineDatum: false, spendUtxos: spendUtxos, } ) @@ -205,6 +206,7 @@ export class SundaeSwap extends BaseDex { address: returnAddress, addressType: AddressType.Base, assetBalances: relevantUtxo.assetBalances, + isInlineDatum: false, spendUtxos: [relevantUtxo], } ]; diff --git a/src/dex/teddyswap.ts b/src/dex/teddyswap.ts index 960b00d..b8d48fa 100644 --- a/src/dex/teddyswap.ts +++ b/src/dex/teddyswap.ts @@ -210,6 +210,7 @@ export class TeddySwap extends BaseDex { }, ], datum: datumBuilder.getCbor(), + isInlineDatum: true, spendUtxos: spendUtxos, }), ]; diff --git a/src/dex/vyfinance.ts b/src/dex/vyfinance.ts index f3af38a..c416e08 100644 --- a/src/dex/vyfinance.ts +++ b/src/dex/vyfinance.ts @@ -103,6 +103,7 @@ export class VyFinance extends BaseDex { }, ], datum: datumBuilder.getCbor(), + isInlineDatum: false, spendUtxos: spendUtxos, } ) @@ -123,6 +124,7 @@ export class VyFinance extends BaseDex { address: returnAddress, addressType: AddressType.Base, assetBalances: relevantUtxo.assetBalances, + isInlineDatum: false, spendUtxos: [relevantUtxo], } ]; diff --git a/src/dex/wingriders.ts b/src/dex/wingriders.ts index 3521799..c0a51e6 100644 --- a/src/dex/wingriders.ts +++ b/src/dex/wingriders.ts @@ -245,6 +245,7 @@ export class WingRiders extends BaseDex { }, ], datum: datumBuilder.getCbor(), + isInlineDatum: false, spendUtxos: spendUtxos, } ) @@ -265,6 +266,7 @@ export class WingRiders extends BaseDex { address: returnAddress, addressType: AddressType.Base, assetBalances: relevantUtxo.assetBalances, + isInlineDatum: false, spendUtxos: [relevantUtxo], } ]; diff --git a/src/providers/wallet/lucid-provider.ts b/src/providers/wallet/lucid-provider.ts index 229f75a..ec52543 100644 --- a/src/providers/wallet/lucid-provider.ts +++ b/src/providers/wallet/lucid-provider.ts @@ -7,7 +7,7 @@ import { Assets, Blockfrost, Datum, Kupmios, - Lucid, + Lucid, OutputData, TxComplete, TxHash, TxSigned, @@ -108,7 +108,11 @@ export class LucidProvider extends BaseWalletProvider { case AddressType.Contract: transaction.providerData.tx.payToContract( payToAddress.address, - payToAddress.datum as Datum, + payToAddress.isInlineDatum + ? { + inline: payToAddress.datum as Datum, + } + : payToAddress.datum as Datum, payment, ); break; diff --git a/src/types.ts b/src/types.ts index 2f30afb..7cd05b2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -88,6 +88,7 @@ export type PayToAddress = { assetBalances: AssetBalance[], spendUtxos?: UTxO[], datum?: string, + isInlineDatum: boolean, }; export type SwapFee = {