Skip to content

Commit

Permalink
update build tx
Browse files Browse the repository at this point in the history
  • Loading branch information
m1n999999 committed Aug 3, 2024
1 parent f7584f8 commit cb6915b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/build-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export type BuildCreateTreasuryOptions = {
validFrom: UnixTime;
validTo: UnixTime;
extraDatum?: Datum; // the datum of treasuryDatum.receiverDatum
extraUtxo?: UTxO;
};

export type BuildAddSellersOptions = {
Expand Down Expand Up @@ -154,6 +155,7 @@ export type BuildUpdateLBEOptions = {
reserveBase?: bigint;
revocable?: boolean;
penaltyConfig?: { penaltyStartTime: bigint; percent: bigint };
extraInput?: UTxO;
};

export type BuildCancelLBEOptions = {
Expand Down Expand Up @@ -369,6 +371,7 @@ export class WarehouseBuilder {
validTo,
extraDatum,
sellerAmount,
extraUtxo,
} = options;
const managerDatum: ManagerDatum = {
factoryPolicyId: this.factoryHash,
Expand Down Expand Up @@ -439,8 +442,8 @@ export class WarehouseBuilder {
if ("VerificationKeyCredential" in owner.paymentCredential) {
this.tx.addSigner(plutusAddress2Address("Preprod", owner));
} else {
// TODO: support cript hash
throw Error("Do not support Script owner")
invariant(extraUtxo);
this.tx.collectFrom([extraUtxo]);
}
},
);
Expand Down Expand Up @@ -585,14 +588,16 @@ export class WarehouseBuilder {
reserveBase,
revocable,
penaltyConfig,
extraInput,
} = options;
invariant(treasuryInput.datum);
const inDatum = this.fromDatumTreasury(treasuryInput.datum);
const updatedOwner = owner ? address2PlutusAddress(owner) : inDatum.owner;
const treasuryOutDatum: TreasuryDatum = {
...inDatum,
startTime: startTime ?? inDatum.startTime,
endTime: endTime ?? inDatum.endTime,
owner: owner ? address2PlutusAddress(owner) : inDatum.owner,
owner: updatedOwner,
minimumOrderRaise: minimumOrderRaise ?? inDatum.minimumOrderRaise,
minimumRaise: minimumRaise ?? inDatum.minimumRaise,
maximumRaise: maximumRaise ?? inDatum.maximumRaise,
Expand All @@ -617,6 +622,14 @@ export class WarehouseBuilder {
() => {
this.tx.validFrom(validFrom).validTo(validTo);
},
() => {
if ("VerificationKeyCredential" in updatedOwner.paymentCredential) {
this.tx.addSigner(plutusAddress2Address("Preprod", updatedOwner));
} else {
invariant(extraInput);
this.tx.collectFrom([extraInput]);
}
},
);
return this;
}
Expand Down

0 comments on commit cb6915b

Please sign in to comment.