Skip to content

Commit

Permalink
fix: attempt to resolve a private class instance error
Browse files Browse the repository at this point in the history
  • Loading branch information
cjkoepke committed Aug 29, 2024
1 parent 81273d7 commit 7146d41
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
30 changes: 15 additions & 15 deletions docs/typescript/core/classes/Blaze.TxBuilderBlazeV3.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ TxBuilderV3.cancel

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:811](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L811)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:813](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L813)

___

Expand Down Expand Up @@ -110,7 +110,7 @@ TxBuilderV3.deposit

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1005](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1005)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1007](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1007)

___

Expand All @@ -135,7 +135,7 @@ The generated Bech32 address.

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1266](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1266)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1268](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1268)

___

Expand All @@ -159,15 +159,15 @@ ___

### getAllSettingsUtxos

**getAllSettingsUtxos**(): `Promise`\<`TransactionUnspentOutput`[]\>
**getAllSettingsUtxos**(): `Promise`\<`TransactionUnspentOutput`\>

Gets the settings UTxOs based on the transaction data
stored in the settings scripts of the protocol parameters
using the Blaze provider.

#### Returns

`Promise`\<`TransactionUnspentOutput`[]\>
`Promise`\<`TransactionUnspentOutput`\>

#### Defined in

Expand All @@ -191,7 +191,7 @@ The maxScooperFee as defined by the settings UTXO.

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:235](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L235)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:237](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L237)

___

Expand Down Expand Up @@ -257,7 +257,7 @@ Throws an error if the retrieval of UTXOs fails or if no UTXOs are available.

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1315](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1315)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1317](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1317)

___

Expand All @@ -281,7 +281,7 @@ before returning a response.

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:255](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L255)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:257](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L257)

___

Expand Down Expand Up @@ -315,7 +315,7 @@ TxBuilderV3.mintPool

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:338](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L338)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:340](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L340)

___

Expand All @@ -341,7 +341,7 @@ Returns a new Tx instance from Blaze. Throws an error if not ready.

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:275](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L275)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:277](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L277)

___

Expand Down Expand Up @@ -371,7 +371,7 @@ TxBuilderV3.orderRouteSwap

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:657](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L657)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:659](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L659)

___

Expand Down Expand Up @@ -401,7 +401,7 @@ TxBuilderV3.swap

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:568](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L568)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:570](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L570)

___

Expand Down Expand Up @@ -433,7 +433,7 @@ TxBuilderV3.update

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:909](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L909)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:911](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L911)

___

Expand Down Expand Up @@ -463,7 +463,7 @@ TxBuilderV3.withdraw

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1059](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1059)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1061](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1061)

___

Expand Down Expand Up @@ -493,4 +493,4 @@ TxBuilderV3.zap

#### Defined in

[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1112](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1112)
[packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts:1114](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts#L1114)
32 changes: 17 additions & 15 deletions packages/core/src/TxBuilders/TxBuilder.Blaze.V3.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class TxBuilderBlazeV3 extends TxBuilderV3 {
network: TSupportedNetworks;
protocolParams: ISundaeProtocolParamsFull | undefined;
referenceUtxos: Core.TransactionUnspentOutput[] | undefined;
settingsUtxos: Core.TransactionUnspentOutput[] | undefined;
settingsUtxo: Core.TransactionUnspentOutput | undefined;
validatorScripts: Record<string, ISundaeProtocolValidatorFull> = {};

static MIN_ADA_POOL_MINT_ERROR =
Expand Down Expand Up @@ -210,19 +210,21 @@ export class TxBuilderBlazeV3 extends TxBuilderV3 {
* stored in the settings scripts of the protocol parameters
* using the Blaze provider.
*
* @returns {Promise<Core.TransactionUnspentOutput[]>}
* @returns {Promise<Core.TransactionUnspentOutput>}
*/
public async getAllSettingsUtxos(): Promise<Core.TransactionUnspentOutput[]> {
if (!this.settingsUtxos) {
public async getAllSettingsUtxos(): Promise<Core.TransactionUnspentOutput> {
if (!this.settingsUtxo) {
const { hash } = await this.getValidatorScript("settings.mint");
this.settingsUtxos = [
await this.blaze.provider.getUnspentOutputByNFT(
Core.AssetId(`${hash}${this.SETTINGS_NFT_NAME}`)
),
];
const instance = await this.blaze.provider.getUnspentOutputByNFT(
Core.AssetId(`${hash}${this.SETTINGS_NFT_NAME}`)
);
// Required or it will sometimes throw a private method error.
instance.output.bind(instance);

this.settingsUtxo = instance;
}

return this.settingsUtxos;
return this.settingsUtxo;
}

/**
Expand All @@ -234,7 +236,7 @@ export class TxBuilderBlazeV3 extends TxBuilderV3 {
*/
public async getMaxScooperFeeAmount(): Promise<bigint> {
const settings = await this.getAllSettingsUtxos();
const datum = settings[0].output().datum()?.asInlineData();
const datum = settings.output().datum()?.asInlineData();
if (!datum) {
return 1_000_000n;
}
Expand Down Expand Up @@ -416,9 +418,9 @@ export class TxBuilderBlazeV3 extends TxBuilderV3 {
poolOutput: 0n,
});

let settingsDatum = settings[0].output().datum()?.asInlineData();
let settingsDatum = settings.output().datum()?.asInlineData();
if (!settingsDatum) {
const hash = settings[0].output().datum()?.asDataHash();
const hash = settings.output().datum()?.asDataHash();
settingsDatum = hash
? await this.blaze.provider.resolveDatum(Core.DatumHash(hash))
: undefined;
Expand Down Expand Up @@ -466,7 +468,7 @@ export class TxBuilderBlazeV3 extends TxBuilderV3 {
mints.set(Core.AssetName(refAssetName), 1n);
mints.set(Core.AssetName(poolLqAssetName), circulatingLp);

[...references, ...settings].forEach((utxo) => {
[...references, settings].forEach((utxo) => {
tx.addReferenceInput(utxo);
});
userUtxos.forEach((utxo) => tx.addInput(utxo));
Expand Down Expand Up @@ -496,7 +498,7 @@ export class TxBuilderBlazeV3 extends TxBuilderV3 {
);

if (donateToTreasury) {
const settingsDatum = settings[0].output().datum()?.asInlineData();
const settingsDatum = settings.output().datum()?.asInlineData();
if (!settingsDatum) {
throw new Error("Could not retrieve datum from settings UTXO.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jest
.mockResolvedValue(params);
jest
.spyOn(TxBuilderBlazeV3.prototype, "getAllSettingsUtxos")
.mockResolvedValue(settingsUtxosBlaze);
.mockResolvedValue(settingsUtxosBlaze[0]);

describe("TxBuilderBlazeV1", () => {
it("should have the correct settings", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jest

jest
.spyOn(TxBuilderBlazeV3.prototype, "getAllSettingsUtxos")
.mockResolvedValue(settingsUtxosBlaze);
.mockResolvedValue(settingsUtxosBlaze[0]);

jest
.spyOn(TxBuilderBlazeV3.prototype, "getAllReferenceUtxos")
Expand Down

0 comments on commit 7146d41

Please sign in to comment.