Skip to content

Commit

Permalink
Merge pull request #80 from cardano2vn/do-mint
Browse files Browse the repository at this point in the history
Do mint
  • Loading branch information
tidvn authored Nov 14, 2024
2 parents f6a5a7d + b7faa39 commit d7fb030
Show file tree
Hide file tree
Showing 35 changed files with 785 additions and 502 deletions.
1 change: 1 addition & 0 deletions contract/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./script";
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const BLOCKFROST_API_KEY = process.env.BLOCKFROST_API_KEY || "";
export const APP_NETWORK = parseInt(process.env.APP_NETWORK || "1") as 0 | 1;
export const EXCHANGE_FEE_ADDRESS = process.env.EXCHANGE_FEE_ADDRESS || "";
export const MINT_REFERENCE_SCRIPT_ADDRESS =
process.env.MINT_REFERENCE_SCRIPT_ADDRESS || "";
Expand All @@ -9,3 +7,8 @@ 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 title = {
mint: "mint.mint.mint",
store: "store.store.spend",
};
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
import { MeshAdapter } from "../adapters/mesh.adapter";
import cbor from "cbor";
import { readValidator, getUniqueAssetName } from "../utils";
import { title } from "../configs";
import { applyParamsToScript } from "@meshsdk/core-csl";

export class Cip68Contract extends MeshAdapter {}
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
File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions contract/src/configs/index.ts

This file was deleted.

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
16 changes: 10 additions & 6 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** @type {import('next').NextConfig} */
const nextConfig = {

const IPFS_GATEWAY = new URL(
process.env.NEXT_PUBLIC_IPFS_GATEWAY || "https://ipfs.io/",
);

const nextConfig = () => ({
serverExternalPackages: [
"@meshsdk/core",
"@meshsdk/core-cst",
Expand All @@ -14,14 +19,13 @@ const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "ipfs.io",
protocol: IPFS_GATEWAY.protocol.slice(0, -1), // Remove trailing colon
hostname: IPFS_GATEWAY.hostname,
pathname: "/**",
},
],
},

// output: "standalone",
output: "standalone",
reactStrictMode: true,
webpack: function (config) {
config.experiments = {
Expand All @@ -30,6 +34,6 @@ const nextConfig = {
};
return config;
},
};
});

export default nextConfig;
Loading

0 comments on commit d7fb030

Please sign in to comment.