Skip to content

Commit

Permalink
Merge pull request #33 from parv0888/dev/low-code-nft-marketplace
Browse files Browse the repository at this point in the history
Auto reformat & Deprecation changes for low-code-nft-marketplace
  • Loading branch information
abizjak authored Jan 28, 2024
2 parents 8d9b91b + 0483010 commit 9c821ee
Show file tree
Hide file tree
Showing 3 changed files with 308 additions and 321 deletions.
100 changes: 50 additions & 50 deletions low-code-nft-marketplace/common-ui/src/models/Cis2Client.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { SmartContractParameters, WalletApi } from "@concordium/browser-wallet-api-helpers";
import { CIS2, ContractAddress, TransactionSummary } from "@concordium/web-sdk";
import { BlockItemSummaryInBlock, CIS2, ContractAddress } from '@concordium/web-sdk';

import * as conClient from "./ConcordiumContractClient";
import * as conClient from './ConcordiumContractClient';

/**
* Structure of a JSON-formatted metadata.
*/
export interface Metadata {
name?: string;
description?: string;
display?: {
url: string;
};
unique?: boolean;
attributes?: Attribute[];
name?: string;
description?: string;
display?: {
url: string;
};
unique?: boolean;
attributes?: Attribute[];
}

export interface Attribute {
name: string;
type: string;
value: string;
name: string;
type: string;
value: string;
}

/**
Expand All @@ -31,48 +31,48 @@ export interface Attribute {
* @param tokenContractAddress Token contract address.
* @param contractInfo Contract info of CIS-2 contract.
* @param maxContractExecutionEnergy Max allowed energy ot Minting.
* @returns Transaction outcomes {@link Record<string, TransactionSummary>}
* @returns Transaction outcomes {@link BlockItemSummaryInBlock}
*/
export async function mint(
provider: WalletApi,
account: string,
tokens: { [tokenId: string]: [CIS2.MetadataUrl, string] },
tokenContractAddress: ContractAddress,
contractInfo: conClient.ContractInfo,
maxContractExecutionEnergy = BigInt(9999),
): Promise<Record<string, TransactionSummary>> {
const paramJson = {
owner: {
Account: [account],
},
tokens: Object.keys(tokens).map((tokenId) => [
tokenId,
{
metadata_url: {
url: tokens[tokenId][0].url,
hash: tokens[tokenId][0].hash
? {
Some: [tokens[tokenId][0].hash!],
}
: {
None: [],
},
provider: WalletApi,
account: string,
tokens: { [tokenId: string]: [CIS2.MetadataUrl, string] },
tokenContractAddress: ContractAddress,
contractInfo: conClient.ContractInfo,
maxContractExecutionEnergy = BigInt(9999)
): Promise<BlockItemSummaryInBlock> {
const paramJson = {
owner: {
Account: [account],
},
token_amount: tokens[tokenId][1],
},
]),
};
tokens: Object.keys(tokens).map((tokenId) => [
tokenId,
{
metadata_url: {
url: tokens[tokenId][0].url,
hash: tokens[tokenId][0].hash
? {
Some: [tokens[tokenId][0].hash!],
}
: {
None: [],
},
},
token_amount: tokens[tokenId][1],
},
]),
};

return conClient.updateContract(
provider,
contractInfo,
paramJson as SmartContractParameters,
account,
tokenContractAddress,
"mint",
maxContractExecutionEnergy,
BigInt(0),
);
return conClient.updateContract(
provider,
contractInfo,
paramJson as SmartContractParameters,
account,
tokenContractAddress,
'mint',
maxContractExecutionEnergy,
BigInt(0)
);
}

export const toTokenId = (integer: number, contractInfo: conClient.Cis2ContractInfo) => {
Expand Down
Loading

0 comments on commit 9c821ee

Please sign in to comment.