Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"vote-for-proposal-drep-script-example" : "ts-node src/vote-for-proposal-drep-script-example.ts"
},
"dependencies": {
"@biglup/cometa": "^1.0.101",
"@biglup/cometa": "^1.0.111",
"chalk": "4.1.2",
"cli-spinners": "^2.9.0",
"dotenv": "^17.2.1",
Expand Down
3 changes: 3 additions & 0 deletions examples/src/donate-to-treasury-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ const donateLovelace = async () => {
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/drep-pubkey-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
4 changes: 4 additions & 0 deletions examples/src/drep-script-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');

const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);

Expand Down
3 changes: 3 additions & 0 deletions examples/src/mint-burn-native-script-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/mint-burn-plutus-script-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/propose-treasury-withdrawal-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ const example = async () => {
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/reward-account-pubkey-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/reward-account-script-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/send-lovelace-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ const sendLovelaceExample = async () => {
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/spend-from-native-script-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/spend-from-plutus-script-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/vote-for-proposal-drep-pubkey-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
3 changes: 3 additions & 0 deletions examples/src/vote-for-proposal-drep-script-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const signAndSubmit = async (wallet: Cometa.Wallet, provider: Cometa.Provider, u
const witnessSet = await wallet.signTransaction(unsignedTx, true);
const signedTx = Cometa.applyVkeyWitnessSet(unsignedTx, witnessSet);

monitor.logInfo('Signed transaction:');
monitor.logInfo(JSON.stringify(Cometa.inspectTx(signedTx), null, 2));

monitor.startTask('Submitting transaction...');
const txId = await wallet.submitTransaction(signedTx);
monitor.endTask(`Transaction submitted successfully with ID: ${txId}`, TaskResult.Success);
Expand Down
8 changes: 4 additions & 4 deletions examples/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@
"@babel/helper-string-parser" "^7.27.1"
"@babel/helper-validator-identifier" "^7.27.1"

"@biglup/cometa@^1.0.900":
version "1.0.7006"
resolved "https://registry.yarnpkg.com/@biglup/cometa/-/cometa-1.0.7006.tgz#0696f11ff9c0250a8aff74e5fc9f0dc33512a407"
integrity sha512-sFvjb5XFWWiYgsxijZ6wyPRU8VQMZ5HZ06vLSOaV6PUcZ5hYMVKbsFyyS5O3dWr/L5NwcTRi5GgP5gKuuBXvUw==
"@biglup/cometa@^1.0.111":
version "1.0.111"
resolved "https://registry.yarnpkg.com/@biglup/cometa/-/cometa-1.0.111.tgz#d2387608bcb57148a0eb62c497266e7298aa4edd"
integrity sha512-vr8fuII1uj+Ts1fK4zJxCmX4gEcjo+kCF4Lrlob/zCk/ujYEixu/YHO3kjDcrGMa0GTypQ5eIwEHPQV2hWKuew==

"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"
Expand Down
2 changes: 1 addition & 1 deletion libcardano-c/cardano_c.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@biglup/cometa",
"version": "1.1.102",
"version": "1.0.111",
"description": "Cometa JS is a lightweight and high performance library designed to streamline transaction building and smart contract interactions on the Cardano blockchain",
"engines": {
"node": ">=16.0.0",
Expand Down
40 changes: 40 additions & 0 deletions src/marshaling/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,43 @@ export const getUniqueSigners = (transactionCbor: string, utxos: UTxO[]): string
module._free(signersSetPtrPtr);
}
};

/**
* @brief Inspects a Cardano transaction CBOR string and converts it into a structured JavaScript object (JSON).
*
* This function takes a hexadecimal CBOR representation of a Cardano transaction and then serializes it
* into a CIP-116 compliant JSON string. Finally, it parses the JSON string into a native JavaScript object.
*
* @param {string} transactionCbor The hexadecimal string representation of the Cardano transaction CBOR.
* @returns {any} A JavaScript object representing the decoded Cardano transaction structure (CIP-116 JSON format).
* @throws {Error} If CBOR reading fails, JSON encoding fails, or memory allocation fails.
*/
export const inspectTx = (transactionCbor: string): any => {
let txPtr = 0;
let jsonWriter = 0;
let jsonPtr = 0;
try {
txPtr = readTransactionFromCbor(transactionCbor);
jsonWriter = getModule().json_writer_new(0); // CARDANO_JSON_FORMAT_COMPACT

getModule().transaction_to_cip116_json(txPtr, jsonWriter);

const jsonSize = getModule().json_writer_get_encoded_size(jsonWriter);
jsonPtr = getModule()._malloc(jsonSize ? jsonSize : 1);

if (jsonSize !== 0) {
const result = getModule().json_writer_encode(jsonWriter, jsonPtr, jsonSize);
assertSuccess(result, 'Failed to encode transaction JSON');
} else {
getModule().HEAPU8[jsonPtr] = 0;
}

const jsonString = getModule().UTF8ToString(jsonPtr);

return JSON.parse(jsonString);
} finally {
unrefObject(txPtr);
unrefObject(jsonWriter);
getModule()._free(jsonPtr);
}
};
6 changes: 3 additions & 3 deletions src/txBuilder/coinSelection/CoinSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* IMPORTS ********************************************************************/

import { UTxO } from '../../common';
import { UTxO, Value } from '../../common';

/* DEFINITIONS ****************************************************************/

Expand Down Expand Up @@ -50,9 +50,9 @@ export interface CoinSelectorParams {
availableUtxo: UTxO[];

/**
* The target amount of lovelace that the selection must cover.
* The target value that the selection must cover.
*/
targetValue: bigint;
targetValue: Value;
}

/**
Expand Down
Loading