Skip to content

Commit

Permalink
develop: update condition burn and remove token using txbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
independenceee authored and tidvn committed Nov 14, 2024
1 parent da23efa commit b7faa39
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 37 deletions.
6 changes: 3 additions & 3 deletions contract/script/txbuilder/cip68.txbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import {

import { MeshAdapter } from "../adapters/mesh.adapter";
import plutus from "../../plutus.json";
import { title } from "../configs";
import {
EXCHANGE_FEE_ADDRESS,
MINT_REFERENCE_SCRIPT_HASH,
STORE_REFERENCE_SCRIPT_HASH,
MINT_REFERENCE_SCRIPT_ADDRESS,
STORE_REFERENCE_SCRIPT_ADDRESS,
APP_NETWORK,
title,
} from "../constants";
import { Plutus } from "../types";
import { appNetworkId } from "@/constants";

export class Cip68Contract extends MeshAdapter {
protected pubKeyExchange: string =
Expand All @@ -52,7 +52,7 @@ export class Cip68Contract extends MeshAdapter {
protected storeAddress = serializePlutusScript(
this.storeScript,
undefined,
APP_NETWORK,
appNetworkId,
false,
).address;

Expand Down
63 changes: 29 additions & 34 deletions contract/tests/cip68.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { apiKey, apiUrl } from "../src/configs";
/* eslint-disable @typescript-eslint/no-unused-vars */
import { blockfrostProvider } from "@/lib/cardano";
import { describe, test, expect, beforeEach, jest } from "@jest/globals";
import {
BlockfrostProvider,
Expand All @@ -9,17 +10,11 @@ import {
MeshWallet,
} from "@meshsdk/core";

import { Cip68Contract } from "../src";

describe("Mint, Burn, Update, Remove Assets (NFT/TOKEN) CIP68", function () {
let txHashTemp: string;
let meshTxBuilder: MeshTxBuilder;
let wallet: BrowserWallet | MeshWallet;
let blockfrostProvider: BlockfrostProvider | KoiosProvider;
let wallet: MeshWallet;
beforeEach(async function () {
blockfrostProvider = new BlockfrostProvider(
"preprodHXZNMTECARQ3jlUE0RvCBT2qOK6JRtQf",
);
wallet = new MeshWallet({
networkId: 0,
fetcher: blockfrostProvider,
Expand Down Expand Up @@ -64,33 +59,33 @@ describe("Mint, Burn, Update, Remove Assets (NFT/TOKEN) CIP68", function () {
// expect(txHash.length).toBe(64);
// });

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

const unsignedTx: string = await cip68Contract.burn({
assetName: "CIP68 Generators.",
txHash:
"1fdcf779767280d32aa488b45a49398d342470bdef5fcfe22f5c82ac06379b2b",
quantity: "-1",
metadata: {
name: "CIP68 Generators 01",
image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
mediaType: "image/jpg",
description: "Open source dynamic assets (Token/NFT) generator (CIP68)",
author: deserializeAddress(await wallet.getChangeAddress()).pubKeyHash,
},
});
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.burn({
// assetName: "CIP68 Generators.",
// txHash:
// "1fdcf779767280d32aa488b45a49398d342470bdef5fcfe22f5c82ac06379b2b",
// quantity: "-1",
// metadata: {
// name: "CIP68 Generators 01",
// image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
// mediaType: "image/jpg",
// description: "Open source dynamic assets (Token/NFT) generator (CIP68)",
// author: deserializeAddress(await wallet.getChangeAddress()).pubKeyHash,
// },
// });
// 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);
// });

// test("Update", async function () {
// const cip68Contract: Cip68Contract = new Cip68Contract({
Expand Down

0 comments on commit b7faa39

Please sign in to comment.