Skip to content

Commit

Permalink
fix: script addresses were using wrong encoding in the datum
Browse files Browse the repository at this point in the history
  • Loading branch information
cjkoepke committed Dec 18, 2024
1 parent 4a619e0 commit f2b83b4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
14 changes: 9 additions & 5 deletions docs/typescript/core/Blaze/classes/BlazeHelper.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Helper function to parse addresses hashes from a Bech32 encoded address.

> `optional` **stakeCredentials**: `string`
##### type

> **type**: `AddressType`
#### Defined in

[packages/core/src/Utilities/BlazeHelper.class.ts:28](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L28)
Expand All @@ -69,7 +73,7 @@ The Bech32 encoded address.

#### Defined in

[packages/core/src/Utilities/BlazeHelper.class.ts:137](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L137)
[packages/core/src/Utilities/BlazeHelper.class.ts:140](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L140)

***

Expand All @@ -93,7 +97,7 @@ Throws a useful error if the address, network, and instance network are on the w

#### Defined in

[packages/core/src/Utilities/BlazeHelper.class.ts:183](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L183)
[packages/core/src/Utilities/BlazeHelper.class.ts:186](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L186)

***

Expand All @@ -115,7 +119,7 @@ Throws an error describing the address and contextual information.

#### Defined in

[packages/core/src/Utilities/BlazeHelper.class.ts:210](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L210)
[packages/core/src/Utilities/BlazeHelper.class.ts:213](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L213)

***

Expand All @@ -142,7 +146,7 @@ and that the address is on the correct network.

#### Defined in

[packages/core/src/Utilities/BlazeHelper.class.ts:80](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L80)
[packages/core/src/Utilities/BlazeHelper.class.ts:83](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L83)

***

Expand All @@ -164,4 +168,4 @@ Validates that an address matches the provided network.

#### Defined in

[packages/core/src/Utilities/BlazeHelper.class.ts:151](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L151)
[packages/core/src/Utilities/BlazeHelper.class.ts:154](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/Utilities/BlazeHelper.class.ts#L154)
12 changes: 6 additions & 6 deletions docs/typescript/core/Blaze/classes/DatumBuilderBlazeV3.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ The UTxO txHash and index.

#### Defined in

[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:516](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L516)
[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:527](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L527)

***

Expand All @@ -389,7 +389,7 @@ The hex encoded pool ident.

#### Defined in

[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:492](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L492)
[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:503](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L503)

***

Expand All @@ -411,7 +411,7 @@ The hex encoded pool ident.

#### Defined in

[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:480](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L480)
[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:491](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L491)

***

Expand All @@ -433,7 +433,7 @@ The hex encoded pool ident.

#### Defined in

[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:504](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L504)
[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:515](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L515)

***

Expand Down Expand Up @@ -471,7 +471,7 @@ An object containing the staking and
#### Defined in

[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:547](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L547)
[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:558](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L558)

***

Expand Down Expand Up @@ -500,4 +500,4 @@ The signing key associated with the owner, extracted from the datum. This key is

#### Defined in

[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:589](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L589)
[packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts:600](https://github.com/SundaeSwap-finance/sundae-sdk/blob/main/packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts#L600)
19 changes: 15 additions & 4 deletions packages/core/src/DatumBuilders/DatumBuilder.Blaze.V3.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,22 @@ export class DatumBuilderBlazeV3 implements DatumBuilder {

public buildOwnerDatum(main: string): TDatumResult<V3Types.TMultiSigScript> {
BlazeHelper.validateAddressNetwork(main, this.network);
const { stakeCredentials, paymentCredentials } =
const { stakeCredentials, paymentCredentials, type } =
BlazeHelper.getAddressHashes(main);
const ownerDatum: V3Types.TMultiSigScript = {
Address: { hex: stakeCredentials || paymentCredentials },
};

let ownerDatum: V3Types.TMultiSigScript;
if (
type === Core.AddressType.BasePaymentScriptStakeKey ||
type === Core.AddressType.BasePaymentScriptStakeScript
) {
ownerDatum = {
Script: { hex: stakeCredentials || paymentCredentials },
};
} else {
ownerDatum = {
Address: { hex: stakeCredentials || paymentCredentials },
};
}

const data = Data.to(ownerDatum, V3Types.MultiSigScript);

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/Utilities/BlazeHelper.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class BlazeHelper {
static getAddressHashes(address: string): {
paymentCredentials: Core.Hash28ByteBase16;
stakeCredentials?: string;
type: Core.AddressType;
} {
const details = Core.Address.fromBech32(address);
const addressType = details.getType();
Expand All @@ -46,6 +47,7 @@ export class BlazeHelper {
return {
paymentCredentials,
stakeCredentials: details.asBase()?.getStakeCredential()?.hash,
type: addressType,
};
}
case Core.AddressType.EnterpriseKey:
Expand All @@ -59,6 +61,7 @@ export class BlazeHelper {

return {
paymentCredentials,
type: addressType,
};
}

Expand Down

0 comments on commit f2b83b4

Please sign in to comment.