Skip to content

Commit

Permalink
Merge pull request #83 from cardano2vn/frontend/profile
Browse files Browse the repository at this point in the history
Frontend/profile
  • Loading branch information
independenceee authored Nov 15, 2024
2 parents d7fb030 + 3e832f6 commit 78ac3c9
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 380 deletions.
161 changes: 0 additions & 161 deletions contract/index.py

This file was deleted.

1 change: 1 addition & 0 deletions contract/script/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const MINT_REFERENCE_SCRIPT_HASH =
process.env.MINT_REFERENCE_SCRIPT_HASH || "";
export const STORE_REFERENCE_SCRIPT_HASH =
process.env.STORE_REFERENCE_SCRIPT_HASH || "";
export const EXCHANGE_FEE_PRICE = process.env.EXCHANGE_FEE_PRICE || "";

export const title = {
mint: "mint.mint.mint",
Expand Down
1 change: 1 addition & 0 deletions contract/script/interfaces/icip68.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class ICip68Contract {}
21 changes: 0 additions & 21 deletions contract/script/mesh/cip68.mesh.ts

This file was deleted.

66 changes: 2 additions & 64 deletions contract/script/txbuilder/cip68.txbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import {
} from "../constants";
import { Plutus } from "../types";
import { appNetworkId } from "@/constants";
import { ICip68Contract } from "../interfaces/icip68.interface";

export class Cip68Contract extends MeshAdapter {
export class Cip68Contract extends MeshAdapter implements ICip68Contract {
protected pubKeyExchange: string =
deserializeAddress(EXCHANGE_FEE_ADDRESS).pubKeyHash;
protected mintCompileCode: string = this.readValidator(
Expand Down Expand Up @@ -285,69 +286,6 @@ export class Cip68Contract extends MeshAdapter {
return unsignedTx.complete();
};

remove = async ({
assetName,
metadata,
txHash,
}: {
assetName: string;
metadata: AssetMetadata;
txHash: string;
}) => {
const { utxos, walletAddress, collateral } = await this.getWalletForTx();
const utxoRef: UTxO = await this.getUtxoForTx(
STORE_REFERENCE_SCRIPT_ADDRESS,
STORE_REFERENCE_SCRIPT_HASH,
);
const userUtxo = await this.getUtxoForTx(walletAddress, txHash);
const storeUtxo = await this.getUtxoForTx(this.storeAddress, txHash);
if (!userUtxo) throw new Error("User UTXO not found");
if (!storeUtxo) throw new Error("Store UTXO not found");

console.log(storeUtxo.output);
const unsignedTx = this.meshTxBuilder
.txIn(collateral.input.txHash, collateral.input.outputIndex)

.spendingPlutusScriptV3()
.txIn(storeUtxo.input.txHash, storeUtxo.input.outputIndex)
.txInInlineDatumPresent()
.txInScript(this.storeScriptCbor)
.txInRedeemerValue(mConStr1([]))
// .spendingTxInReference(utxoRef.input.txHash, utxoRef.input.outputIndex)

.txOut(walletAddress, [
{
unit: this.policyId + CIP68_100(stringToHex(assetName)),
quantity: "1",
},
])
.txOutInlineDatumValue(metadataToCip68(metadata))

.txOut(
"addr_test1qzwu6jcqk8f96fxq02pvq2h4a927ggn35f2gzdklfte4kwx0sd5zdvsat2chsyyjxkjxcg6uz2y46avd46mzqdgdy3dsckqxs4",
[
{
unit: "lovelace",
quantity: "1000000",
},
],
)
.requiredSignerHash(deserializeAddress(walletAddress).pubKeyHash)
.changeAddress(walletAddress)
.selectUtxosFrom(utxos)
.txInCollateral(
collateral.input.txHash,
collateral.input.outputIndex,
collateral.output.amount,
collateral.output.address,
);

// unsignedTx.removeDuplicateInputs();
// unsignedTx.addUtxosFromSelection();

return unsignedTx.complete();
};

/**
* @description Create reference script for mint transaction
*/
Expand Down
7 changes: 1 addition & 6 deletions contract/script/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
BlockfrostProvider,
stringToBSArray,
stringToHex,
UTxO,
} from "@meshsdk/core";
import { BlockfrostProvider, UTxO } from "@meshsdk/core";
import crypto from "crypto";
import plutus from "../../plutus.json";

Expand Down
78 changes: 27 additions & 51 deletions contract/tests/cip68.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
MeshTxBuilder,
MeshWallet,
} from "@meshsdk/core";
import { Cip68Contract } from "../script";

describe("Mint, Burn, Update, Remove Assets (NFT/TOKEN) CIP68", function () {
let txHashTemp: string;
Expand All @@ -33,31 +34,32 @@ describe("Mint, Burn, Update, Remove Assets (NFT/TOKEN) CIP68", function () {
});
});

// test("Mint", async function () {
// const cip68Contract: Cip68Contract = new Cip68Contract({
// fetcher: blockfrostProvider,
// wallet: wallet,
// meshTxBuilder: meshTxBuilder,
// });
test("Mint", async function () {
const cip68Contract: Cip68Contract = new Cip68Contract({
fetcher: blockfrostProvider,
wallet: wallet,
meshTxBuilder: meshTxBuilder,
});

// const unsignedTx: string = await cip68Contract.mint({
// assetName: "CIP68 Generators.",
// metadata: {
// name: "CIP68 Generators",
// image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
// mediaType: "image/jpg",
// description: "Open source dynamic assets (Token/NFT) generator (CIP68)",
// author: deserializeAddress(await wallet.getChangeAddress()).pubKeyHash,
// },
// quantity: "1",
// });
// const signedTx = await wallet.signTx(unsignedTx, true);
// const txHash = await wallet.submitTx(signedTx);
// console.log(txHash);
// txHashTemp = txHash;
// jest.setTimeout(20000);
// expect(txHash.length).toBe(64);
// });
const unsignedTx: string = await cip68Contract.mint({
assetName: "CIP68 Generators.",
metadata: {
name: "CIP68 Generators",
image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
mediaType: "image/jpg",
description: "Open source dynamic assets (Token/NFT) generator (CIP68)",
author: deserializeAddress(await wallet.getChangeAddress()).pubKeyHash,
},
quantity: "1",
});
const signedTx = await wallet.signTx(unsignedTx, true);
const txHash = await wallet.submitTx(signedTx);
console.log(txHash);
txHashTemp = txHash;
blockfrostProvider.onTxConfirmed(txHash, () => {
expect(txHash.length).toBe(64);
});
});

// test("Burn", async function () {
// const cip68Contract: Cip68Contract = new Cip68Contract({
Expand All @@ -69,7 +71,7 @@ describe("Mint, Burn, Update, Remove Assets (NFT/TOKEN) CIP68", function () {
// const unsignedTx: string = await cip68Contract.burn({
// assetName: "CIP68 Generators.",
// txHash:
// "1fdcf779767280d32aa488b45a49398d342470bdef5fcfe22f5c82ac06379b2b",
// "0249ca1df634c30e434f9f1e1b8f368ad06c51ac3e5e55e9869e1b321852c562",
// quantity: "-1",
// metadata: {
// name: "CIP68 Generators 01",
Expand Down Expand Up @@ -117,32 +119,6 @@ describe("Mint, Burn, Update, Remove Assets (NFT/TOKEN) CIP68", function () {
// expect(txHash.length).toBe(64);
// });

// test("Remove", async function () {
// const cip68Contract: Cip68Contract = new Cip68Contract({
// fetcher: blockfrostProvider,
// wallet: wallet,
// meshTxBuilder: meshTxBuilder,
// });

// const unsignedTx: string = await cip68Contract.remove({
// assetName: "CIP68 Generators",
// metadata: {
// name: "CIP68 Generators",
// image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
// mediaType: "image/jpg",
// description: "Open source dynamic assets (Token/NFT) generator (CIP68)",
// author: deserializeAddress(await wallet.getChangeAddress()).pubKeyHash,
// },
// txHash:
// "22faa1bc73a0c94e4e1f24727545ba3a7155b3ceadc69f2fd159209f88c8eff1",
// });
// const signedTx = await wallet.signTx(unsignedTx, true);
// const txHash = await wallet.submitTx(signedTx);
// console.log(txHash);
// jest.setTimeout(20000);
// expect(txHash.length).toBe(64);
// });

// test('Mint Reference Script', async function () {
// const cip68Contract: Cip68Contract = new Cip68Contract({
// fetcher: blockfrostProvider,
Expand Down
Empty file.
Loading

0 comments on commit 78ac3c9

Please sign in to comment.