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/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: [ [ 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());