From 8dcff448e50933bde1fa1624bbe33f478db17793 Mon Sep 17 00:00:00 2001 From: Calvin Koepke Date: Thu, 2 May 2024 11:35:18 -0600 Subject: [PATCH] chore: review comments --- .../core/classes/Lucid.TxBuilderLucidV3.md | 39 +++++++++--------- .../TxBuilders/TxBuilder.Lucid.V3.class.ts | 41 +++++++++++-------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/docs/typescript/core/classes/Lucid.TxBuilderLucidV3.md b/docs/typescript/core/classes/Lucid.TxBuilderLucidV3.md index cc80593e..69424f1f 100644 --- a/docs/typescript/core/classes/Lucid.TxBuilderLucidV3.md +++ b/docs/typescript/core/classes/Lucid.TxBuilderLucidV3.md @@ -38,7 +38,7 @@ TxBuilder.constructor #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:94](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L94) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:93](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L93) ## Properties @@ -54,7 +54,7 @@ TxBuilder.datumBuilder #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:96](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L96) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:95](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L95) ___ @@ -66,7 +66,7 @@ A configured Lucid instance to use. #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:95](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L95) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:94](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L94) ## Methods @@ -96,7 +96,7 @@ TxBuilder.cancel #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:521](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L521) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:526](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L526) ___ @@ -126,7 +126,7 @@ TxBuilder.deposit #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:669](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L669) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:674](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L674) ___ @@ -151,7 +151,7 @@ The generated Bech32 address. #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:900](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L900) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:905](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L905) ___ @@ -169,7 +169,7 @@ using the Lucid provider. #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:133](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L133) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:132](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L132) ___ @@ -187,7 +187,7 @@ using the Lucid provider. #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:170](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L170) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:169](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L169) ___ @@ -196,7 +196,8 @@ ___ ▸ **getMaxScooperFeeAmount**(): `Promise`\<`bigint`\> Utility function to get the max scooper fee amount, which is defined -in the settings UTXO datum. +in the settings UTXO datum. If no settings UTXO was found, due to a network +error or otherwise, we fallback to 1 ADA. #### Returns @@ -227,7 +228,7 @@ will re-populate with real data. #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:115](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L115) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:114](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L114) ___ @@ -247,7 +248,7 @@ ___ #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:151](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L151) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:150](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L150) ___ @@ -272,7 +273,7 @@ Throws an error if the retrieval of UTXOs fails or if no UTXOs are available. #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:943](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L943) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:948](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L948) ___ @@ -296,7 +297,7 @@ before returning a response. #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:214](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L214) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:219](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L219) ___ @@ -326,7 +327,7 @@ Throws an error if the transaction fails to build or submit. #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:284](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L284) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:289](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L289) ___ @@ -353,7 +354,7 @@ fee payment if a [ITxBuilderReferralFee](../interfaces/Core.ITxBuilderReferralFe #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:237](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L237) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:242](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L242) ___ @@ -383,7 +384,7 @@ TxBuilder.swap #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:467](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L467) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:472](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L472) ___ @@ -415,7 +416,7 @@ TxBuilder.update #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:583](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L583) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:588](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L588) ___ @@ -445,7 +446,7 @@ TxBuilder.withdraw #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:717](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L717) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:722](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L722) ___ @@ -475,4 +476,4 @@ TxBuilder.zap #### Defined in -[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:762](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L762) +[packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts:767](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts#L767) diff --git a/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts b/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts index 743180fb..ed45c3a0 100644 --- a/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts +++ b/packages/core/src/TxBuilders/TxBuilder.Lucid.V3.class.ts @@ -12,24 +12,23 @@ import { type TxComplete, } from "lucid-cardano"; -import { - EContractVersion, - EDatumType, - type ICancelConfigArgs, - type IComposedTx, - type IDepositConfigArgs, - type IMintV3PoolConfigArgs, - type ISundaeProtocolParamsFull, - type ISundaeProtocolReference, - type ISundaeProtocolValidatorFull, - type ISwapConfigArgs, - type ITxBuilderFees, - type ITxBuilderReferralFee, - type IWithdrawConfigArgs, - type IZapConfigArgs, - type TDepositMixed, - type TSupportedNetworks, +import type { + ICancelConfigArgs, + IComposedTx, + IDepositConfigArgs, + IMintV3PoolConfigArgs, + ISundaeProtocolParamsFull, + ISundaeProtocolReference, + ISundaeProtocolValidatorFull, + ISwapConfigArgs, + ITxBuilderFees, + ITxBuilderReferralFee, + IWithdrawConfigArgs, + IZapConfigArgs, + TDepositMixed, + TSupportedNetworks, } from "../@types/index.js"; +import { EContractVersion, EDatumType } from "../@types/index.js"; import { TxBuilder } from "../Abstracts/TxBuilder.abstract.class.js"; import { CancelConfig } from "../Configs/CancelConfig.class.js"; import { DepositConfig } from "../Configs/DepositConfig.class.js"; @@ -190,16 +189,22 @@ export class TxBuilderLucidV3 extends TxBuilder { /** * Utility function to get the max scooper fee amount, which is defined - * in the settings UTXO datum. + * in the settings UTXO datum. If no settings UTXO was found, due to a network + * error or otherwise, we fallback to 1 ADA. * * @returns {bigint} The maxScooperFee as defined by the settings UTXO. */ public async getMaxScooperFeeAmount(): Promise { const [settings] = await this.getAllSettingsUtxos(); + if (!settings) { + return 1_000_000n; + } + const { baseFee, simpleFee } = Data.from( settings.datum as string, SettingsDatum ); + return baseFee + simpleFee; }