@mutants/cardano
Advanced tools
Comparing version 1.13.0 to 1.14.0
import { Multiasset } from "../utils/assets"; | ||
import { MetadataMap } from "../utils/cbor/metadata"; | ||
import { ScriptData } from "../utils/scriptData"; | ||
@@ -11,3 +12,3 @@ import { CardanoUTXO, RequiredInputs, RequiredOutputs } from "../utils/utxos"; | ||
buildTransaction: (txBody: string, txWitnessSet: string, metadata?: string) => string; | ||
buildTransactionBody: (inputsUtxo: CardanoUTXO[], requiredInputs: RequiredInputs, requiredOutputs: RequiredOutputs, fee?: number, requiredSigners?: string, scriptHash?: string, collateral?: CardanoUTXO[]) => Promise<{ | ||
buildTransactionBody: (inputsUtxo: CardanoUTXO[], requiredInputs: RequiredInputs, requiredOutputs: RequiredOutputs, fee?: number, requiredSigners?: string, scriptHash?: string, collateral?: CardanoUTXO[], auxiliaryDataHash?: string) => Promise<{ | ||
encoded: string; | ||
@@ -19,2 +20,3 @@ length: number; | ||
buildTransactionWitness: (vkeywitness?: string, plutusScript?: string, redeemer?: string, plutusData?: ScriptData) => string; | ||
buildAuxiliaryDataHash: (map: MetadataMap) => string; | ||
buildRedeemer: (tag: string, index: string, plutusData: ScriptData, exUnits?: string) => string; | ||
@@ -21,0 +23,0 @@ buildScriptHash: (encodedRedeemer: string, plutusData: ScriptData, encodedCostModel: string) => string; |
@@ -83,3 +83,3 @@ "use strict"; | ||
}; | ||
var buildTransactionBody = function (inputsUtxo, requiredInputs, requiredOutputs, fee, requiredSigners, scriptHash, collateral) { return __awaiter(void 0, void 0, void 0, function () { | ||
var buildTransactionBody = function (inputsUtxo, requiredInputs, requiredOutputs, fee, requiredSigners, scriptHash, collateral, auxiliaryDataHash) { return __awaiter(void 0, void 0, void 0, function () { | ||
var outputs, transactionInputs, transactionOutputs, body; | ||
@@ -90,3 +90,3 @@ return __generator(this, function (_a) { | ||
transactionOutputs = exports.TransactionBuilder.buildTransactionOutputs(outputs); | ||
body = transaction_1.CborTransaction.encodeTransactionBody(transactionInputs, transactionOutputs, fee, requiredSigners, scriptHash, collateral); | ||
body = transaction_1.CborTransaction.encodeTransactionBody(transactionInputs, transactionOutputs, fee, requiredSigners, scriptHash, collateral, auxiliaryDataHash); | ||
return [2 /*return*/, body]; | ||
@@ -114,2 +114,5 @@ }); | ||
}; | ||
var buildAuxiliaryDataHash = function (map) { | ||
return hash_1.HashUtils.hexToHash(cbor_1.CborMetadata.encode(map)); | ||
}; | ||
exports.TransactionBuilder = { | ||
@@ -121,2 +124,3 @@ buildTransaction: buildTransaction, | ||
buildTransactionWitness: buildTransactionWitness, | ||
buildAuxiliaryDataHash: buildAuxiliaryDataHash, | ||
buildRedeemer: buildRedeemer, | ||
@@ -123,0 +127,0 @@ buildScriptHash: buildScriptHash, |
@@ -1,2 +0,2 @@ | ||
declare type MetadataMap = { | ||
export declare type MetadataMap = { | ||
[key: number]: string; | ||
@@ -7,2 +7,1 @@ }; | ||
}; | ||
export {}; |
@@ -5,3 +5,3 @@ import { CborEncoded } from "."; | ||
export declare const CborTransaction: { | ||
encodeTransactionBody: (encodedInputs: string, encodedOutputs: string, fee?: number, requiredSigners?: string, scriptHash?: string, collateral?: CardanoUTXO[]) => { | ||
encodeTransactionBody: (encodedInputs: string, encodedOutputs: string, fee?: number, requiredSigners?: string, scriptHash?: string, collateral?: CardanoUTXO[], auxiliaryDataHash?: string) => { | ||
encoded: string; | ||
@@ -8,0 +8,0 @@ length: number; |
@@ -9,3 +9,3 @@ "use strict"; | ||
var TRANSACTION_START = 4; | ||
var encodeTransactionBody = function (encodedInputs, encodedOutputs, fee, requiredSigners, scriptHash, collateral) { | ||
var encodeTransactionBody = function (encodedInputs, encodedOutputs, fee, requiredSigners, scriptHash, collateral, auxiliaryDataHash) { | ||
var mapSize = 2 + | ||
@@ -15,5 +15,7 @@ (fee ? 1 : 0) + | ||
(scriptHash ? 1 : 0) + | ||
(collateral ? 1 : 0); | ||
(collateral ? 1 : 0) + | ||
(auxiliaryDataHash ? 1 : 0); | ||
var mapValues = [ | ||
fee ? "02" + _1.CborUnsigned.encode(fee) : "", | ||
auxiliaryDataHash ? "07" + _1.CborByte.encode(auxiliaryDataHash) : "", | ||
scriptHash ? "0B" + _1.CborByte.encode(scriptHash) : "", | ||
@@ -20,0 +22,0 @@ collateral |
{ | ||
"name": "@mutants/cardano", | ||
"version": "1.13.0", | ||
"version": "1.14.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
import { Multiasset } from "../utils/assets"; | ||
import { Cbor } from "../utils/cbor"; | ||
import { Cbor, CborMetadata } from "../utils/cbor"; | ||
import { CborAddress } from "../utils/cbor/address"; | ||
import { CborArray } from "../utils/cbor/array"; | ||
import { MetadataMap } from "../utils/cbor/metadata"; | ||
import { CborScriptData } from "../utils/cbor/scriptData"; | ||
@@ -95,3 +96,4 @@ import { CborTransaction } from "../utils/cbor/transaction"; | ||
scriptHash?: string, | ||
collateral?: CardanoUTXO[] | ||
collateral?: CardanoUTXO[], | ||
auxiliaryDataHash?: string | ||
) => { | ||
@@ -116,3 +118,4 @@ const outputs = UTXOS.calculateOutputs( | ||
scriptHash, | ||
collateral | ||
collateral, | ||
auxiliaryDataHash | ||
); | ||
@@ -170,2 +173,6 @@ | ||
const buildAuxiliaryDataHash = (map: MetadataMap) => { | ||
return HashUtils.hexToHash(CborMetadata.encode(map)); | ||
}; | ||
export const TransactionBuilder = { | ||
@@ -177,2 +184,3 @@ buildTransaction, | ||
buildTransactionWitness, | ||
buildAuxiliaryDataHash, | ||
buildRedeemer, | ||
@@ -179,0 +187,0 @@ buildScriptHash, |
@@ -5,3 +5,3 @@ import { CborByte } from "./byte"; | ||
type MetadataMap = { | ||
export type MetadataMap = { | ||
[key: number]: string; | ||
@@ -8,0 +8,0 @@ }; |
@@ -16,3 +16,4 @@ import { Cbor, CborByte, CborEncoded, CborUnsigned } from "."; | ||
scriptHash?: string, | ||
collateral?: CardanoUTXO[] | ||
collateral?: CardanoUTXO[], | ||
auxiliaryDataHash?: string | ||
) => { | ||
@@ -24,6 +25,8 @@ const mapSize = | ||
(scriptHash ? 1 : 0) + | ||
(collateral ? 1 : 0); | ||
(collateral ? 1 : 0) + | ||
(auxiliaryDataHash ? 1 : 0); | ||
const mapValues = [ | ||
fee ? `02${CborUnsigned.encode(fee)}` : "", | ||
auxiliaryDataHash ? `07${CborByte.encode(auxiliaryDataHash)}` : "", | ||
scriptHash ? `0B${CborByte.encode(scriptHash)}` : "", | ||
@@ -30,0 +33,0 @@ collateral |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
688060
124
15069