Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
michele-nuzzi committed Oct 3, 2024
1 parent 380e836 commit 5fff1dc
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 58 deletions.
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@harmoniclabs/plu-ts",
"version": "0.8.1",
"version": "0.8.2-dev1",
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -71,13 +71,13 @@
"@harmoniclabs/bip32_ed25519": "^0.1.2",
"@harmoniclabs/bytestring": "^1.0.0",
"@harmoniclabs/cardano-costmodels-ts": "^1.2.0",
"@harmoniclabs/cardano-ledger-ts": "^0.2.3",
"@harmoniclabs/cardano-ledger-ts": "^0.2.4",
"@harmoniclabs/cbor": "^1.3.0",
"@harmoniclabs/crypto": "^0.2.4",
"@harmoniclabs/obj-utils": "^1.0.0",
"@harmoniclabs/pair": "^1.0.0",
"@harmoniclabs/plu-ts-offchain": "0.1.15",
"@harmoniclabs/plu-ts-onchain": "^0.3.1",
"@harmoniclabs/plu-ts-offchain": "0.1.16-dev1",
"@harmoniclabs/plu-ts-onchain": "^0.3.2-dev1",
"@harmoniclabs/plutus-data": "^1.2.4",
"@harmoniclabs/plutus-machine": "^2.0.1",
"@harmoniclabs/uint8array-utils": "^1.0.0",
Expand Down
20 changes: 10 additions & 10 deletions packages/offchain/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/offchain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@harmoniclabs/plu-ts-offchain",
"version": "0.1.15",
"version": "0.1.16-dev1",
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -62,7 +62,7 @@
"@harmoniclabs/bip32_ed25519": "^0.1.2",
"@harmoniclabs/bytestring": "^1.0.0",
"@harmoniclabs/cardano-costmodels-ts": "^1.2.0",
"@harmoniclabs/cardano-ledger-ts": "^0.2.3",
"@harmoniclabs/cardano-ledger-ts": "^0.2.4",
"@harmoniclabs/cbor": "^1.3.0",
"@harmoniclabs/pair": "^1.0.0",
"@harmoniclabs/plutus-data": "^1.2.4",
Expand Down
17 changes: 11 additions & 6 deletions packages/offchain/src/TxBuilder/TxBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fromHex, isUint8Array, lexCompare, toHex } from "@harmoniclabs/uint8array-utils";
import { keepRelevant } from "./keepRelevant";
import { GenesisInfos, NormalizedGenesisInfos, defaultMainnetGenesisInfos, defaultPreprodGenesisInfos, isGenesisInfos, isNormalizedGenesisInfos, normalizedGenesisInfos } from "./GenesisInfos";
import { isCostModelsV2, isCostModelsV1, costModelsToLanguageViewCbor, isCostModelsV3, defaultV3Costs } from "@harmoniclabs/cardano-costmodels-ts";
import { isCostModelsV2, isCostModelsV1, costModelsToLanguageViewCbor, isCostModelsV3, defaultV3Costs, CostModelsToLanguageViewCborOpts } from "@harmoniclabs/cardano-costmodels-ts";
import { Tx, Value, ValueUnits, TxOut, TxRedeemerTag, ScriptType, UTxO, VKeyWitness, Script, BootstrapWitness, TxRedeemer, Hash32, TxIn, Hash28, AuxiliaryData, TxWitnessSet, getNSignersNeeded, txRedeemerTagToString, ScriptDataHash, TxBody, CredentialType, canBeHash32, VotingProcedures, ProposalProcedure, InstantRewardsSource, LitteralScriptType, defaultProtocolParameters, ITxOut } from "@harmoniclabs/cardano-ledger-ts";
import { CborString, Cbor, CborArray, CanBeCborString, CborPositiveRational, CborMap, CborUInt } from "@harmoniclabs/cbor";
import { byte, blake2b_256 } from "@harmoniclabs/crypto";
Expand All @@ -20,6 +20,7 @@ import { TxBuilderProtocolParams, ValidatedTxBuilderProtocolParams, completeTxBu
import { ChangeInfos } from "../txBuild/ChangeInfos/ChangeInfos";
import { estimateMaxSignersNeeded, scriptTypeToDataVersion } from "./utils";
import { cborFromRational } from "../utils/Rational";
import { stringify } from "../utils/stringify";

type ScriptLike = {
hash: string,
Expand Down Expand Up @@ -277,7 +278,11 @@ export class TxBuilder
* 2) `tx.witnesses.redeemers`
* 3) `tx.witnesses.vkeyWitnesses` (empty)
*/
overrideTxRedeemers( tx: Tx, newRedeemers: TxRedeemer[] ): Tx
overrideTxRedeemers(
tx: Tx,
newRedeemers: TxRedeemer[],
opts: CostModelsToLanguageViewCborOpts = { mustHaveV3: true }
): Tx
{
// datums passed by hash
const datums = tx.witnesses.datums ?? [];
Expand All @@ -289,7 +294,7 @@ export class TxBuilder
tx.witnesses,
costModelsToLanguageViewCbor(
this.protocolParamters.costModels,
{ mustHaveV2: true, mustHaveV1: false }
opts
).toBuffer()
)
}),
Expand Down Expand Up @@ -604,7 +609,7 @@ export class TxBuilder
`protocol paramters "utxoCostPerByte": ${this.protocolParamters.utxoCostPerByte}\n` +
`minimum lovelaces required: ${minLovelaces.toString()}\n` +
`output lovelaces : ${out.value.lovelaces.toString()}\n` +
`tx output: ${JSON.stringify( out.toJson(), undefined, 2 )}`
`tx output: ${stringify( out.toJson(), undefined, 2 )}`
);
}
}
Expand Down Expand Up @@ -1292,7 +1297,7 @@ export class TxBuilder
if( !Value.isAdaOnly( realCollValue ) )
throw new Error(
`total collateral value was including non-ADA value;\n` +
`total collateral value was: ${JSON.stringify( realCollValue.toJson(), undef, 2 )}`
`total collateral value was: ${stringify( realCollValue.toJson(), undef, 2 )}`
);
}
}
Expand Down Expand Up @@ -1578,7 +1583,7 @@ function onEvaluationResult(
`failed with \n`+
`error message: ${(result as any).msg}\n`+
`additional infos: ${
JSON.stringify(
stringify(
(result as any).addInfos,
( k, v ) => {
if( isUint8Array( v ) )
Expand Down
49 changes: 49 additions & 0 deletions packages/offchain/src/utils/stringify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { isObject } from "@harmoniclabs/obj-utils";
import { toHex } from "@harmoniclabs/uint8array-utils";

export function mkReplacer(
replacer?: (key: string, value: any) => any | null,
map: WeakMap<any, string> = new WeakMap()
)
{
if( typeof replacer !== "function" ) replacer = ( k, v ) => v;
return function( key: string, value: any )
{
value = replacer!(key, value);
if( isObject( value ) )
{
if ( map.has(value) ) {
return map.get(value);
}
map.set(value, key);

if( typeof value.buffer === "object" && value.buffer instanceof ArrayBuffer )
{
value = new Uint8Array(value.buffer);
}
if( value instanceof Uint8Array)
{
value = toHex(value);
}
}
if( typeof value === "bigint" )
{
value = value.toString();
}

return value;
};
}

export function stringify(
value: any,
replacer?: (key: string, value: any) => any | null | (number | string)[],
space: string | number = 0
): string
{
if( replacer )
{
return JSON.stringify(value, replacer, space);
}
return JSON.stringify(value, mkReplacer( replacer, new WeakMap() ), space);
}
20 changes: 10 additions & 10 deletions packages/onchain/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/onchain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@harmoniclabs/plu-ts-onchain",
"version": "0.3.1",
"version": "0.3.2-dev1",
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -68,7 +68,7 @@
"@harmoniclabs/cardano-costmodels-ts": "^1.2.0",
"@harmoniclabs/plutus-machine": "^2.0.1",
"@harmoniclabs/uplc": "^1.2.4",
"@harmoniclabs/cardano-ledger-ts": "^0.2.3"
"@harmoniclabs/cardano-ledger-ts": "^0.2.4"
},
"devDependencies": {
"@babel/preset-env": "^7.18.6",
Expand Down
Loading

0 comments on commit 5fff1dc

Please sign in to comment.