Skip to content

Commit

Permalink
Merge branch 'main' into docs/value-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglescode committed Aug 30, 2024
2 parents cd93bab + 55819e6 commit 0577bd2
Show file tree
Hide file tree
Showing 83 changed files with 3,995 additions and 933 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This configuration only applies to the package manager root.
/** @type {import("eslint").Linter.Config} */
module.exports = {
ignorePatterns: ["apps/**", "packages/**"],
ignorePatterns: ["apps/**", "packages/**", "scripts/**"],
extends: ["@meshsdk/configs/eslint/library.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
- name: Lint
run: npm run lint
- name: Build
run: npm run build:mesh && npm run build:docs && npm run build:apps
run: npm run build:mesh && npm run build:docs && npm run build:apps && npm run build:scripts
27 changes: 26 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Lint
run: npm run lint
- name: Build
run: npm run build:mesh && npm run build:docs && npm run build:apps
run: npm run build:mesh && npm run build:docs && npm run build:apps && npm run build:scripts

check-version:
runs-on: ubuntu-latest
Expand All @@ -40,6 +40,7 @@ jobs:
react-version-updated: ${{ steps.compare-versions.outputs.react-version-updated }}
transaction-version-updated: ${{ steps.compare-versions.outputs.transaction-version-updated }}
wallet-version-updated: ${{ steps.compare-versions.outputs.wallet-version-updated }}
cli-version-updated: ${{ steps.compare-versions.outputs.cli-version-updated }}
steps:
- name: Checkout main branch at commit before merge
uses: actions/checkout@v4
Expand All @@ -58,6 +59,7 @@ jobs:
REACT_PRE_MERGE_VERSION=$(node -p "require('./packages/mesh-react/package.json').version")
TRANSACTION_PRE_MERGE_VERSION=$(node -p "require('./packages/mesh-transaction/package.json').version")
WALLET_PRE_MERGE_VERSION=$(node -p "require('./packages/mesh-wallet/package.json').version")
CLI_PRE_MERGE_VERSION=$(node -p "require('./scripts/mesh-cli/package.json').version")
echo "common_pre_merge_version=$COMMON_PRE_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "contract_pre_merge_version=$CONTRACT_PRE_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "core_pre_merge_version=$CORE_PRE_MERGE_VERSION" >> "$GITHUB_OUTPUT"
Expand All @@ -67,6 +69,7 @@ jobs:
echo "react_pre_merge_version=$REACT_PRE_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "transaction_pre_merge_version=$TRANSACTION_PRE_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "wallet_pre_merge_version=$WALLET_PRE_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "cli_pre_merge_version=$CLI_PRE_MERGE_VERSION" >> "$GITHUB_OUTPUT"
- name: Checkout main branch at commit after merge
uses: actions/checkout@v4
Expand All @@ -85,6 +88,7 @@ jobs:
REACT_POST_MERGE_VERSION=$(node -p "require('./packages/mesh-react/package.json').version")
TRANSACTION_POST_MERGE_VERSION=$(node -p "require('./packages/mesh-transaction/package.json').version")
WALLET_POST_MERGE_VERSION=$(node -p "require('./packages/mesh-wallet/package.json').version")
CLI_POST_MERGE_VERSION=$(node -p "require('./scripts/mesh-cli/package.json').version")
echo "common_post_merge_version=$COMMON_POST_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "contract_post_merge_version=$CONTRACT_POST_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "core_post_merge_version=$CORE_POST_MERGE_VERSION" >> "$GITHUB_OUTPUT"
Expand All @@ -94,6 +98,7 @@ jobs:
echo "react_post_merge_version=$REACT_POST_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "transaction_post_merge_version=$TRANSACTION_POST_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "wallet_post_merge_version=$WALLET_POST_MERGE_VERSION" >> "$GITHUB_OUTPUT"
echo "cli_post_merge_version=$CLI_POST_MERGE_VERSION" >> "$GITHUB_OUTPUT"
- name: Compare versions
id: compare-versions
Expand Down Expand Up @@ -143,6 +148,11 @@ jobs:
else
echo "wallet-version-updated=false" >> "$GITHUB_OUTPUT"
fi
if [[ "${{ steps.pre-merge-version.outputs.cli_pre_merge_version }}" != "${{ steps.post-merge-version.outputs.cli_post_merge_version }}" ]]; then
echo "cli-version-updated=true" >> "$GITHUB_OUTPUT"
else
echo "cli-version-updated=false" >> "$GITHUB_OUTPUT"
fi
publish-meshsdk-common:
needs: [build, check-version]
Expand Down Expand Up @@ -278,3 +288,18 @@ jobs:
- run: cd packages/mesh-wallet && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-meshsdk-cli:
needs: [build, check-version]
if: needs.check-version.outputs.cli-version-updated == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm install && npm run build:scripts
- run: cd scripts/mesh-cli && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
4 changes: 2 additions & 2 deletions apps/playground/src/components/cardano/mint-mesh-token.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MeshWallet, ForgeScript, Mint, Transaction } from "@meshsdk/core";
import { ForgeScript, MeshWallet, Mint, Transaction } from "@meshsdk/core";
import { useWallet } from "@meshsdk/react";

import { demoAssetMetadata, demoMnemonic } from "~/data/cardano";
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function MintMeshToken() {
recipient: address,
};

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.mintAsset(forgingScript, asset);

const unsignedTx = await tx.build();
Expand Down
2 changes: 1 addition & 1 deletion apps/playground/src/pages/aiken/transactions/lock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function Right() {
fields: [hash],
};

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendLovelace(
{
address: scriptAddress,
Expand Down
1 change: 1 addition & 0 deletions apps/playground/src/pages/aiken/transactions/redeem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function Right() {
const redeemer = { data: { alternative: 0, fields: ["Hello, World!"] } };

const tx = new Transaction({ initiator: wallet })
.setNetwork("preprod")
.redeemValue({
value: assetUtxo,
script: script,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Right() {
const beginId = await provider.resolveAddress(handle);
const address = beginId.address;

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendLovelace(address, amount);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Right() {
);

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.setMetadata(674, {
msg: message.split("\n"),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Right() {
const blockchainprovider = getProvider("mainnet");
const address = await blockchainprovider.fetchHandleAddress(handle);

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendLovelace(address, amount);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function Right() {
recipient: address,
};

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork('preprod');
tx.mintAsset(forgingScript, asset);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Right() {
const [amount, setAmount] = useState<string>("1");

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendAssets({ address: address }, [
{
unit: asset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ function Right() {
const [amount, setAmount] = useState<string>("1000000");

async function runDemo() {
const tx = new Transaction({ initiator: wallet }).sendLovelace(
address,
amount,
);
const tx = new Transaction({
initiator: wallet,
verbose: true,
})
.setNetwork("preprod")
.sendLovelace(address, amount);

const unsignedTx = await tx.build();
const signedTx = await wallet.signTx(unsignedTx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Right() {
const utxo = utxos[0];

if (utxo) {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendValue(await wallet.getChangeAddress(), utxo);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Right() {
const utxo = (await wallet.getUtxos())[0];

if (utxo) {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.setCollateral([utxo]);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Right() {
);

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.setMetadata(0, message);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Right() {
const { wallet, connected } = useWallet();

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.setRequiredSigners(await wallet.getUsedAddresses());

const unsignedTx = await tx.build();
Expand Down
7 changes: 6 additions & 1 deletion apps/playground/src/pages/apis/transaction/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Codeblock from "~/components/text/codeblock";
export function Intro() {
let example = ``;
example += `import { Transaction } from '@meshsdk/core';\n\n`;
example += `const tx = new Transaction({ initiator: wallet });\n`;
example += `const tx = new Transaction({ initiator: wallet, verbose: false });\n`;
example += `tx.foo(...); // add transaction methods\n`;
example += `tx.bar(...); // add transaction methods\n\n`;
example += `const unsignedTx = await tx.build();\n`;
Expand All @@ -22,6 +22,11 @@ export function Intro() {
and returns the remaining assets to the change address. Use{" "}
<code>wallet.signTx()</code> to sign transaction CBOR.
</p>
<p>
The <code>verbose</code> is optional and set to <code>false</code> by
default, setting it to <code>true</code> will enable verbose logging for
the txBodyJson prior going into build.
</p>
<Codeblock data={example} />
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function Right(userInput: string, setUserInput: (value: string) => void) {
};

// create transaction
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.burnAsset(forgingScript, asset);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function Right() {
};

const tx = new Transaction({ initiator: wallet })
.setNetwork("preprod")
.setTxInputs([utxos[0]!])
.mintAsset(script, cip68Token, redeemer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function Right() {
recipient: address,
};

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.mintAsset(forgingScript, asset1);
tx.setTimeToExpire("99999999");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Link from "~/components/link";

import { AssetMetadata, ForgeScript, Mint, Transaction } from "@meshsdk/core";
import { useWallet } from "@meshsdk/react";

import Link from "~/components/link";
import LiveCodeDemo from "~/components/sections/live-code-demo";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
import Codeblock from "~/components/text/codeblock";
Expand Down Expand Up @@ -104,7 +103,7 @@ function Right() {
};

// create transaction
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.mintAsset(forgingScript, asset);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function Right(userInput: string, setUserInput: (value: string) => void) {
};

const tx = new Transaction({ initiator: wallet })
.setNetwork("preprod")
.mintAsset(script, asset, redeemer)
.setRequiredSigners([address]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function Right() {

const forgingScript = ForgeScript.withOneSignature(address);

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");

const _assetMetadata: RoyaltiesStandard = {
rate: userInput,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react";
import Link from "~/components/link";

import {
Asset,
Expand All @@ -10,6 +9,7 @@ import {
import { useWallet } from "@meshsdk/react";

import Input from "~/components/form/input";
import Link from "~/components/link";
import InputTable from "~/components/sections/input-table";
import LiveCodeDemo from "~/components/sections/live-code-demo";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
Expand Down Expand Up @@ -135,7 +135,7 @@ function Right() {
];

// transaction
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendAssets(
{
address: scriptAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ function Right() {
const address = await wallet.getChangeAddress();

const tx = new Transaction({ initiator: wallet })
.setNetwork("preprod")
.redeemValue({
value: assetUtxo,
script: script as PlutusScript,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Right() {
throw "No address found";
}

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.delegateStake(rewardAddress, userInput);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function Right() {
throw "No address found";
}

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.deregisterStake(rewardAddress);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function Right() {
throw "No address found";
}

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.registerStake(rewardAddress);
tx.delegateStake(rewardAddress, userInput);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Right() {
throw "No address found";
}

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.withdrawRewards(rewardAddress, userInput);

const unsignedTx = await tx.build();
Expand Down
5 changes: 3 additions & 2 deletions apps/playground/src/pages/apis/txbuilder/common.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { MeshTxBuilder } from "@meshsdk/core";
import { CSLSerializer } from "@meshsdk/core-csl";

import { getProvider } from "~/components/cardano/mesh-wallet";

export function getTxBuilder() {
const blockchainProvider = getProvider();
return new MeshTxBuilder({
const txBuilder = new MeshTxBuilder({
fetcher: blockchainProvider,
evaluator: blockchainProvider,
});
txBuilder.setNetwork("preprod");
return txBuilder;
}

export default function Placeholder() {}
Expand Down
Loading

0 comments on commit 0577bd2

Please sign in to comment.