From 2893e30651fa01e57b3d4a34b9d3ed92a0ce329b Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 12 Feb 2024 13:39:30 -0800 Subject: [PATCH 1/2] added NFT purchase example --- docs/docs/how-to/nft/purchase.md | 27 ++++++++++++++++++++ docs/sidebars.js | 1 + packages/sdk/examples/nft/otr/purchase.ts | 30 +++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 docs/docs/how-to/nft/purchase.md create mode 100644 packages/sdk/examples/nft/otr/purchase.ts diff --git a/docs/docs/how-to/nft/purchase.md b/docs/docs/how-to/nft/purchase.md new file mode 100644 index 0000000000..35c3eda2dd --- /dev/null +++ b/docs/docs/how-to/nft/purchase.md @@ -0,0 +1,27 @@ +--- +title: Purchase NFT +tags: + - how-to + - purchase + - nft + - otr +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import DeepLink from '../../_admonitions/_deep_link.md' + + + + To purchase NFT, you must call [`purchase`](../../reference-api/classes/NftOtrDataset.md#purchase) on `dataset(Dataset.NFT)`. + [`purchase`](../../reference-api/classes/NftOtrDataset.md#purchase) takes an object of type [`NftPurchaseTangleRequest`](../../reference-api/interfaces/NftPurchaseTangleRequest.md) as parameter. + + ```tsx file=../../../../packages/sdk/examples/nft/otr/purchase.ts#L4-L27 + ``` + + + + + TODO + + diff --git a/docs/sidebars.js b/docs/sidebars.js index 124af39bbc..a37ea5f3eb 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -57,6 +57,7 @@ const sidebars = { { 'NFT API': [ 'how-to/nft/create-collection', + 'how-to/nft/purchase', 'how-to/nft/bulk-purchase', 'how-to/nft/create-metadata', 'how-to/nft/transfer', diff --git a/packages/sdk/examples/nft/otr/purchase.ts b/packages/sdk/examples/nft/otr/purchase.ts new file mode 100644 index 0000000000..43fee324ef --- /dev/null +++ b/packages/sdk/examples/nft/otr/purchase.ts @@ -0,0 +1,30 @@ +import { Dataset } from '@build-5/interfaces'; +import { Build5, Build5OtrAddress, https, otr, SoonaverseApiKey } from '@build-5/sdk'; + +const collectionId = 'build5collectionid1'; +const nftId = 'build5nftid1'; + +const origin = Build5.TEST; +// @ts-ignore +const otrAddress = Build5OtrAddress[origin]; + +async function main() { + const otrRequest = otr(otrAddress) + .dataset(Dataset.NFT) + .purchase({ collection: collectionId, nft: nftId }); + + const fireflyDeeplink = otrRequest.getFireflyDeepLink(); + console.log('Firefly Deeplink: ', fireflyDeeplink); + + console.log('\n'); + console.log( + 'Sending correct will cause NFT purchase and goes back to buyers wallet. Invalid amount will be refunded.', + ); + + const tag = otrRequest.getTag(fireflyDeeplink); + const obs = https(Build5.TEST).project(SoonaverseApiKey[Build5.TEST]).trackByTag(tag); + console.log('Listen to payment progress:'); + obs.subscribe((n) => console.log('- update: ', n)); +} + +main().then(() => process.exit()); From 7045b1e4b0cae771fb1dd1bcbd58f51af3edfd21 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 12 Feb 2024 13:44:58 -0800 Subject: [PATCH 2/2] changed onBrokenAnchors to warn --- docs/docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 3d28760e36..f8b7c58e7c 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -18,7 +18,7 @@ const config = { // For GitHub pages deployment, it is often '//' baseUrl: '/', onBrokenLinks: 'throw', - onBrokenAnchors: 'throw', + onBrokenAnchors: 'warn', onBrokenMarkdownLinks: 'throw', plugins: [ [