Skip to content

Commit

Permalink
Merge pull request #373 from MeshJS/fix/preview-cost-models
Browse files Browse the repository at this point in the history
Fix/preview cost models
  • Loading branch information
jinglescode authored Nov 8, 2024
2 parents bcf93e5 + 0b5aa58 commit a749565
Show file tree
Hide file tree
Showing 21 changed files with 2,082 additions and 628 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[![Twitter/X](https://img.shields.io/badge/Follow%20us-@MeshJS-blue?logo=x&style=for-the-badge)](https://x.com/meshsdk)
[![NPM](https://img.shields.io/npm/v/%40meshsdk%2Fcore?style=for-the-badge)](https://www.npmjs.com/package/@meshsdk/core)

<strong>All-in-one web3 SDK for Cardano apps</strong>
<strong>All-in-one TypeScript SDK for Cardano apps</strong>

</div>

Expand Down
32 changes: 32 additions & 0 deletions awesome.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Awesome Mesh

<div align="center">

<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://meshjs.dev/logo-mesh/white/logo-mesh-white-512x512.png" width="200">
<source media="(prefers-color-scheme: light)" srcset="https://meshjs.dev/logo-mesh/black/logo-mesh-black-512x512.png" width="200">
<img alt="mesh logo" src="https://meshjs.dev/logo-mesh/mesh.png">
</picture>

<h1 style="border-bottom: none">Awesome <a href='https://meshjs.dev/'>Mesh</a></h1>
<strong>All-in-one TypeScript SDK for Cardano apps</strong>

</div>

<hr />

## Contents

- [Examples](#examples)
- [Tutorials](#tutorials)

## Examples

- [MeshJS/examples](https://github.com/MeshJS/examples) - repository contains examples of how to use the meshsdk package
- [Cardano HK Developer Series Student Examples](https://github.com/sidan-lab/hk-developer-series-student-examples) - repository for serving the student examples covered in the Cardano HK Developer Series

## Tutorials

- [meshjs.dev/guides](https://meshjs.dev/guides) - guides to help you get started
- [Cardano Dev Starter](https://www.andamio.io/course/hkdevstarter2024) - This course that introduces the basic of Cardano development to people new to Cardano.
- [DApp Project Based Learning](https://www.andamio.io/course/DAPPPBLHK) - Course covering DApp development on Cardano.
2,526 changes: 1,945 additions & 581 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/mesh-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/common",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/mesh-common/src/types/transaction-builder/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UtxoSelectionStrategy } from "../../utxo-selection";
import { Network } from "../network";
import { UTxO } from "../utxo";
import { Certificate } from "./certificate";
import { MintItem } from "./mint";
Expand Down Expand Up @@ -36,7 +37,7 @@ export type MeshTxBuilderBody = {
strategy: UtxoSelectionStrategy;
includeTxFees: boolean;
};
network: string;
network: Network | number[][];
};

export const emptyTxBuilderBody = (): MeshTxBuilderBody => ({
Expand Down
2 changes: 0 additions & 2 deletions packages/mesh-common/src/types/transaction-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ export type TransactionInfo = {
deposit: string;
invalidBefore: string;
invalidAfter: string;
blockHeight: number;
blockTime: number;
};
8 changes: 4 additions & 4 deletions packages/mesh-contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/contract",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -34,9 +34,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.12",
"@meshsdk/core": "1.7.12",
"@meshsdk/core-csl": "1.7.12"
"@meshsdk/common": "1.7.13",
"@meshsdk/core": "1.7.13",
"@meshsdk/core-csl": "1.7.13"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-core-csl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-csl",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down Expand Up @@ -38,9 +38,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.12",
"@sidan-lab/sidan-csl-rs-browser": "0.9.4",
"@sidan-lab/sidan-csl-rs-nodejs": "0.9.4",
"@meshsdk/common": "1.7.13",
"@sidan-lab/sidan-csl-rs-browser": "0.9.5",
"@sidan-lab/sidan-csl-rs-nodejs": "0.9.5",
"json-bigint": "^1.0.0"
},
"prettier": "@meshsdk/configs/prettier",
Expand Down
3 changes: 2 additions & 1 deletion packages/mesh-core-csl/src/core/adaptor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { outputToObj } from "./output";
import { collateralTxInToObj, txInToObj } from "./txIn";
import { voteToObj } from "./vote";
import { withdrawalToObj } from "./withdrawal";
import { networkToObj } from "./network";

export const meshTxBuilderBodyToObj = ({
inputs,
Expand Down Expand Up @@ -37,7 +38,7 @@ export const meshTxBuilderBodyToObj = ({
signingKey: signingKey,
withdrawals: withdrawals.map(withdrawalToObj),
votes: votes.map(voteToObj),
network,
network: networkToObj(network),
};
};

Expand Down
11 changes: 11 additions & 0 deletions packages/mesh-core-csl/src/core/adaptor/network.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Network } from "@meshsdk/common";

export const networkToObj = (network: Network | number[][]) => {
if ((typeof network) === "string") {
return network;
} else {
return {
custom: network,
};
}
};
4 changes: 2 additions & 2 deletions packages/mesh-core-cst/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-cst",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -42,7 +42,7 @@
"@harmoniclabs/cbor": "1.3.0",
"@harmoniclabs/plutus-data": "1.2.4",
"@harmoniclabs/uplc": "1.2.4",
"@meshsdk/common": "1.7.12",
"@meshsdk/common": "1.7.13",
"@stricahq/bip32ed25519": "^1.1.0",
"@stricahq/cbors": "^1.0.0",
"pbkdf2": "^3.1.2"
Expand Down
16 changes: 8 additions & 8 deletions packages/mesh-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -33,13 +33,13 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.12",
"@meshsdk/core-csl": "1.7.12",
"@meshsdk/core-cst": "1.7.12",
"@meshsdk/provider": "1.7.12",
"@meshsdk/react": "1.7.12",
"@meshsdk/transaction": "1.7.12",
"@meshsdk/wallet": "1.7.12"
"@meshsdk/common": "1.7.13",
"@meshsdk/core-csl": "1.7.13",
"@meshsdk/core-cst": "1.7.13",
"@meshsdk/provider": "1.7.13",
"@meshsdk/react": "1.7.13",
"@meshsdk/transaction": "1.7.13",
"@meshsdk/wallet": "1.7.13"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions packages/mesh-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/provider",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -34,8 +34,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.12",
"@meshsdk/core-cst": "1.7.12",
"@meshsdk/common": "1.7.13",
"@meshsdk/core-cst": "1.7.13",
"@utxorpc/sdk": "0.6.2",
"@utxorpc/spec": "0.10.1",
"axios": "^1.7.2"
Expand Down
2 changes: 0 additions & 2 deletions packages/mesh-provider/src/blockfrost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ export class BlockfrostProvider
if (status === 200 || status == 202) {
return data.map((tx: any) => {
return <TransactionInfo>{
blockHeight: tx.block_height,
blockTime: tx.block_time,
hash: tx.tx_hash,
index: tx.tx_index,
block: "",
Expand Down
2 changes: 0 additions & 2 deletions packages/mesh-provider/src/koios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ export class KoiosProvider implements IFetcher, IListener, ISubmitter {
if (status === 200 || status == 202) {
return data.map((tx: any) => {
return <TransactionInfo>{
blockHeight: tx.block_height,
blockTime: tx.block_time,
hash: tx.tx_hash,
index: 0,
block: "",
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/react",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -30,9 +30,9 @@
},
"dependencies": {
"react": "^18.2.0",
"@meshsdk/common": "1.7.12",
"@meshsdk/transaction": "1.7.12",
"@meshsdk/wallet": "1.7.12"
"@meshsdk/common": "1.7.13",
"@meshsdk/transaction": "1.7.13",
"@meshsdk/wallet": "1.7.13"
},
"devDependencies": {
"@meshsdk/configs": "*",
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-transaction/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/transaction",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,9 +35,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.12",
"@meshsdk/core-csl": "1.7.12",
"@meshsdk/core-cst": "1.7.12",
"@meshsdk/common": "1.7.13",
"@meshsdk/core-csl": "1.7.13",
"@meshsdk/core-cst": "1.7.13",
"json-bigint": "^1.0.0"
},
"prettier": "@meshsdk/configs/prettier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ export class MeshTxBuilderCore {
* @param network The specific network this transaction is being built for ("testnet" | "preview" | "preprod" | "mainnet")
* @returns The MeshTxBuilder instance
*/
setNetwork = (network: Network) => {
setNetwork = (network: Network | number[][]) => {
this.meshTxBuilderBody.network = network;
return this;
};
Expand Down
53 changes: 52 additions & 1 deletion packages/mesh-transaction/test/mesh-tx-builder/tx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
resolveScriptHash,
resolveScriptHashDRepId,
} from "@meshsdk/core";
import { applyCborEncoding } from "@meshsdk/core-csl";
import {
applyCborEncoding,
resolvePlutusScriptAddress,
} from "@meshsdk/core-csl";
import { MeshTxBuilder } from "@meshsdk/transaction";

describe("MeshTxBuilder transactions", () => {
Expand Down Expand Up @@ -511,4 +514,52 @@ describe("MeshTxBuilder transactions", () => {
console.log(txHex);
expect(txHex !== "").toBeTruthy();
});

it("Custom cost models", () => {
let mesh = new MeshTxBuilder();

let txHex = mesh
.spendingPlutusScriptV3()
.txIn(
"fc1c806abc9981f4bee2ce259f61578c3341012f3d04f22e82e7e40c7e7e3c3c",
0,
[
{
unit: "lovelace",
quantity: "9692479606",
},
],
resolvePlutusScriptAddress(
{
code: "58365834010100323232322533300232323232324a260106012004600e002600e004600a00260066ea8004526136565734aae795d0aba201",
version: "V3",
},
0,
),
)
.txInScript(
"58365834010100323232322533300232323232324a260106012004600e002600e004600a00260066ea8004526136565734aae795d0aba201",
)
.txInDatumValue(mConStr0([]))
.txInRedeemerValue(mConStr0([]), "Mesh", { mem: 100000, steps: 1000000 })
.setNetwork([[1], [1], [1]])
.changeAddress(
"addr_test1qpsmz8q2xj43wg597pnpp0ffnlvr8fpfydff0wcsyzqyrxguk5v6wzdvfjyy8q5ysrh8wdxg9h0u4ncse4cxhd7qhqjqk8pse6",
)
.txInCollateral(
"3fbdf2b0b4213855dd9b87f7c94a50cf352ba6edfdded85ecb22cf9ceb75f814",
7,
[
{
unit: "lovelace",
quantity: "10000000",
},
],
"addr_test1vpw22xesfv0hnkfw4k5vtrz386tfgkxu6f7wfadug7prl7s6gt89x",
)
.completeSync();

console.log(txHex);
expect(txHex !== "").toBeTruthy();
});
});
10 changes: 5 additions & 5 deletions packages/mesh-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/wallet",
"version": "1.7.12",
"version": "1.7.13",
"description": "",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,10 +35,10 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.12",
"@meshsdk/core-csl": "1.7.12",
"@meshsdk/core-cst": "1.7.12",
"@meshsdk/transaction": "1.7.12",
"@meshsdk/common": "1.7.13",
"@meshsdk/core-csl": "1.7.13",
"@meshsdk/core-cst": "1.7.13",
"@meshsdk/transaction": "1.7.13",
"@nufi/dapp-client-cardano": "0.3.5",
"@nufi/dapp-client-core": "0.3.5"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/mesh-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A quick and easy way to bootstrap your dApps on Cardano using Mesh.",
"homepage": "https://meshjs.dev",
"author": "MeshJS",
"version": "1.7.12",
"version": "1.7.13",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/index.cjs",
Expand Down

0 comments on commit a749565

Please sign in to comment.