From e12521a00641ef526a845cbdf30e643ebf53a96e Mon Sep 17 00:00:00 2001 From: Jie Hui Tan Date: Mon, 16 Jan 2023 15:03:24 +0900 Subject: [PATCH] Add get mint and list mints examples --- examples/README.md | 16 ++++++++++++++++ examples/getMint.ts | 21 +++++++++++++++++++++ examples/listMints.ts | 36 ++++++++++++++++++++++++++++++++++++ examples/package.json | 2 ++ 4 files changed, 75 insertions(+) create mode 100644 examples/getMint.ts create mode 100644 examples/listMints.ts diff --git a/examples/README.md b/examples/README.md index 1e1710b4..6eef68e1 100644 --- a/examples/README.md +++ b/examples/README.md @@ -86,6 +86,22 @@ Update [mint.ts](./mint.ts#L9) with your minting details then run yarn mint ``` +## List mints + +Update [listMints.ts](./listMints.ts#L13) with your mint query details then run + +```sh +yarn list-mints +``` + +## Get mint + +Update [getMint.ts](./getMint.ts#L13) with your mint id then run + +```sh +yarn get-mint +``` + ## Create order Update [createOrder.ts](./createOrder.ts#L9) with your order details then run diff --git a/examples/getMint.ts b/examples/getMint.ts new file mode 100644 index 00000000..00434416 --- /dev/null +++ b/examples/getMint.ts @@ -0,0 +1,21 @@ +import { Config, ImmutableX } from '@imtbl/core-sdk'; +import { generateWalletConnection } from './libs/walletConnection'; + +(async () => { + try { + const walletConnection = await generateWalletConnection('goerli'); + + // IMX class client + const client = new ImmutableX(Config.SANDBOX); + + // Get details of a mint with the mint ID (transaction_id returned from listMints) + const getMintResponse = await client.getMint({ + id: '' + }); + + console.log('getMintResponse', JSON.stringify(getMintResponse)); + } catch (err) { + console.error(err); + process.exit(1); + } +})(); \ No newline at end of file diff --git a/examples/listMints.ts b/examples/listMints.ts new file mode 100644 index 00000000..332dc485 --- /dev/null +++ b/examples/listMints.ts @@ -0,0 +1,36 @@ +import { Config, ImmutableX } from '@imtbl/core-sdk'; +import { generateWalletConnection } from './libs/walletConnection'; + +(async () => { + try { + const walletConnection = await generateWalletConnection('goerli'); + + // IMX class client + const client = new ImmutableX(Config.SANDBOX); + + // Get a list of mints + const listMintsResponse = await client.listMints({ + //pageSize: 100, + //cursor: '', + //orderBy: '', + //direction: '', + //user: '', + //status: '', + //minTimestamp: '', + //maxTimestamp: '', + //tokenType: '', + //tokenId: '', + //assetId: '', + //tokenName: '', + //tokenAddress: '', + //minQuantity: '', + //maxQuantity: '', + //metadata: '' + }); + + console.log('listMintsResponse', JSON.stringify(listMintsResponse)); + } catch (err) { + console.error(err); + process.exit(1); + } +})(); \ No newline at end of file diff --git a/examples/package.json b/examples/package.json index 24a68c48..6da4e436 100644 --- a/examples/package.json +++ b/examples/package.json @@ -16,6 +16,8 @@ "create-project": "ts-node -r dotenv/config createProject.ts", "create-collection": "ts-node -r dotenv/config createCollection.ts", "mint": "ts-node -r dotenv/config mint.ts", + "list-mints": "ts-node -r dotenv/config listMints.ts", + "get-mint": "ts-node -r dotenv/config getMint.ts", "transfer-nfts": "ts-node -r dotenv/config transferNfts.ts", "transfer-eth": "ts-node -r dotenv/config transferEth.ts", "transfer-erc20": "ts-node -r dotenv/config transferErc20.ts"