diff --git a/apps/docs/src/app/sdk-core/cancel-collection-offer/page.mdx b/apps/docs/src/app/sdk-core/cancel-collection-offer/page.mdx deleted file mode 100644 index d9dc5b48..00000000 --- a/apps/docs/src/app/sdk-core/cancel-collection-offer/page.mdx +++ /dev/null @@ -1,46 +0,0 @@ -export const metadata = { - title: 'cancelOrder', - description: 'Action for cancelling a collection offer.', -} - -# cancelCollectionOffer - -Action for cancelling a collection offer. - -## Import - -```typescript -import { cancelCollectionOffer } from '@arkproject/core' -``` - -## Usage - -```typescript -import { cancelCollectionOffer } from '@arkproject/core' -import { config, parameters } from './config' - -await cancelCollectionOffer(config, { - starknetAccount: sellerAccount, - cancelInfo: { - orderHash: '0x...', - tokenAddress: '0x...', - }, -}) -``` - -## Parameters - -### starknetAccount - -`AccountInterface` - -The Starknet account used for the transaction. - -### cancelInfo - -`CancelInfo` - -Informations about the order to cancel, includes : - -- `orderHash: bigint` -- `tokenAddress: string` diff --git a/apps/docs/src/app/sdk-core/cancel-order/page.mdx b/apps/docs/src/app/sdk-core/cancel-order/page.mdx index e03f7685..750a25bb 100644 --- a/apps/docs/src/app/sdk-core/cancel-order/page.mdx +++ b/apps/docs/src/app/sdk-core/cancel-order/page.mdx @@ -15,38 +15,69 @@ import { cancelOrder } from '@arkproject/core' ## Usage -```typescript -import { cancelOrder } from '@arkproject/core' -import { config, parameters } from './config' - -await cancelOrder(config, { - starknetAccount: sellerAccount, - cancelInfo: { - orderHash: '0x...', - tokenAddress: '0x...', - tokenId: BigInt(1), - }, + + +```ts {{ title: "example.ts" }} +import { cancel } from '@arkproject/core' +import { config, buyer, brokerAddress } from './config' + +const { orderHash } = await createOffer(config, { + account: buyer, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(10), +}) + +const { transactionHash } = await cancelOrder(config, { + account: buyer, + orderHash, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), }) ``` -## Parameters +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -### starknetAccount +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -`AccountInterface` +const buyer = new Account(config.starknetProvider, '0x', '0x') -The Starknet account used for the transaction. +export const brokerAddress = '0x' +``` -### cancelInfo + -`CancelInfo` +## Returns -Informations about the order to cancel, includes : +[`CancelOrderResult`](https://github.com/ArkProjectNFTs/ark-project/core/src/actions/order/cancel.ts) -- `orderHash: bigint` -- `tokenAddress: string` -- `tokenId: bigint` +The result of the cancel order action. -## Function Description +## Parameters -`cancelOrder` begins by extracting details from the provided parameters, including Starknet and Arkchain accounts, and cancellation information. It then compiles the cancellation details into a `FullCancelInfo` object, compiles and signs the order data, and constructs the calldata for the cancellation. The function executes the transaction and waits for its completion. An error is thrown if the contract ABI is not found or the transaction fails. + + + The account responsible for executing the transaction. + + + The `orderHash` of the order. + + + The contract address of the token. + + + The ID of the token. + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/configuration/page.mdx b/apps/docs/src/app/sdk-core/configuration/page.mdx index 700ddd31..f5d6d452 100644 --- a/apps/docs/src/app/sdk-core/configuration/page.mdx +++ b/apps/docs/src/app/sdk-core/configuration/page.mdx @@ -19,28 +19,25 @@ import { createConfig } from '@arkproject/core' ## Usage -Create a mainnet configuration using [pre-deployed contracts](https://github.com/ArkProjectNFTs/ark-project?tab=readme-ov-file#networks). +Create a configuration using mainnet [pre-deployed contracts](https://github.com/ArkProjectNFTs/ark-project?tab=readme-ov-file#networks). ```typescript import { createConfig, networks } from '@arkproject/core' export const config = createConfig({ - starknetNetwork: networks.mainnet, - arkchainNetwork: networks.mainnet, + network: networks.mainnet, }) ``` -Create a local configuration with development contracts. See [development quickstart](https://github.com/ArkProjectNFTs/ark-project) for more information. +Create a configuration with local contracts, see [development quickstart](https://github.com/ArkProjectNFTs/ark-project). ```typescript import { createConfig, networks } from '@arkproject/core' export const config = createConfig({ - starknetNetwork: networks.dev, - starknetExecutorContract: '0x0', - starknetCurrencyContract: '0x0', - arkchainNetwork: networks.dev, - arkchainOrderbookContract: '0x0', + network: networks.dev, + executorContract: '0x0', + currencyContract: '0x0', }) ``` @@ -50,65 +47,35 @@ export const config = createConfig({ import { type ConfigParameters } from '@arkproject/core' ``` -### starknetNetwork +### network `mainnet | sepolia | dev` Specifies the Starknet network to be used. -### starknetRpcUrl +### rpcUrl (optional) -`string | undefined` - -Custom RPC URL for the Starknet network. If not provided, a default URL based on the specified `starknetNetwork` is used. - -### starknetProvider - -`ProviderInterface | undefined` - -The provider interface for Starknet. If not provided, a new `RpcProvider` instance is created using the `starknetRpcUrl`. - -### arkchainNetwork - -`mainnet | sepolia | dev` - -Specifies Arkchain network to be used. - -### arkchainRpcUrl - -`string | undefined` - -Custom RPC URL for the Arkchain network. If not provided, a default URL based on the specified `arkchainNetwork` is used. - -### arkProvider - -`ProviderInterface | undefined` - -The provider interface for Arkchain. If not provided, a new `RpcProvider` instance is created using the `arkchainRpcUrl`. - -### starknetExecutorContract - -`string | undefined` +`string` -The address of the Starknet executor contract. If not provided, a default contract address based on the `starknetNetwork` is used. +Custom RPC URL for the Starknet network. If not provided, a default URL based on the specified `network` is used. -### starknetCurrencyContract +### provider (optional) -`string | undefined` +`ProviderInterface` -The address of the Starknet currency contract. If not provided, a default contract address based on the `starknetNetwork` is used. +The provider interface for Starknet. If not provided, a new `RpcProvider` instance is created using the `rpcUrl`. -### starknetCurrencyAddress +### executorContract (optional) -`string | undefined` +`string` -The address of the currency contract on Starknet. If not provided, defaults to a eth address. +The address of the Starknet executor contract. If not provided, a default contract address based on the `network` is used. -### arkchainOrderbookContract +### currencyContract (optional) -`string | undefined` +`string` -The address of the Arkchain orderbook contract. If not provided, a default contract address based on the `arkchainNetwork` is used. +The address of the Starknet currency contract. If not provided, a default contract address based on the `network` is used. ## Return Type @@ -124,56 +91,32 @@ Object responsible for managing the configuration of the SDK. import { type Config } from '@arkproject/core' ``` -### starknetNetwork +### network `mainnet | sepolia | dev` `Network` passed to `createConfig`. -### starknetRpcUrl +### rpcUrl `string` Current Starknet RPC url. -### starknetProvider +### provider `ProviderInterface` Current Starknet Provider. -### arkchainNetwork - -`mainnet | sepolia | dev` - -Current arkchain network. - -### arkchainRpcUrl - -`string` - -Current Arkchain RPC url. - -### arkProvider - -`ProviderInterface` - -Current Arkchain Provider. - -### starknetExecutorContract +### executorContract `string` Current Starknet executor contract address. -### starknetCurrencyContract +### currencyContract `string` Current Starknet currency contract address. - -### arkchainOrderbookContract - -`string` - -Current Arkchain orderbook contract address. diff --git a/apps/docs/src/app/sdk-core/create-auction/page.mdx b/apps/docs/src/app/sdk-core/create-auction/page.mdx index 635cc5a2..64255720 100644 --- a/apps/docs/src/app/sdk-core/create-auction/page.mdx +++ b/apps/docs/src/app/sdk-core/create-auction/page.mdx @@ -15,51 +15,72 @@ import { createAuction } from '@arkproject/core' ## Usage -```typescript + + +```ts {{ title: "example.ts" }} import { createAuction } from '@arkproject/core' -import { config, parameters } from './config' - -await createAuction(config, { - starknetAccount: '0x0...', - order: { - brokerId: '0x...', - tokenAddress: '0x0...', - tokenId: BigInt(1), - startAmount: BigInt(1000), - endAmount: BigInt(10000), - }, - approveInfo: { - tokenAddress: '0x0...', - tokenId: BigInt(1), - }, +import { config, account, brokerAddress } from './config' + +const { orderHash } = await createAuction(config, { + account, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + startAmount: BigInt(1000), + endAmount: BigInt(10000), }) ``` -## Parameters - -### starknetAccount - -`AccountInterface` +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -The Starknet account used for the transaction. - -### order +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -`AuctionV1` +export const brokerAddress = '0x' +``` -The base order details for the listing, includes: + -- `tokenAddress: string` -- `tokenId: bigint` -- `brokerId: string` -- `startAmount: bigint` -- `endAmount: bigint` +## Returns -### approveInfo +[`CreateAuctionResult`](https://github.com/ArkProjectNFTs/ark-project/core/src/actions/order/createAuction.ts) -`ApproveErc721Info` +The result of the create auction action. -Informations about the ERC721 token to approve, includes : +## Parameters -- `tokenAddress: string` -- `tokenId: bigint` + + + The account responsible for executing the transaction. + + + The address of the broker. + + + The contract address of the token. + + + The ID of the token. + + + The starting amount of the auction. + + + The end amount (reserve price) of the auction. + + + The start date of the auction. + + + The end date of the auction. + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/create-collection-offer/page.mdx b/apps/docs/src/app/sdk-core/create-collection-offer/page.mdx index 659e380d..43e2a75f 100644 --- a/apps/docs/src/app/sdk-core/create-collection-offer/page.mdx +++ b/apps/docs/src/app/sdk-core/create-collection-offer/page.mdx @@ -15,48 +15,70 @@ import { createCollectionOffer } from '@arkproject/core' ## Usage -```typescript + + +```ts {{ title: "example.ts" }} import { createCollectionOffer } from '@arkproject/core' -import { config } from './config' - -await createCollectionOffer(config, { - starknetAccount: '0x0...', - offer: { - brokerId: '0x...', - tokenAddress: '0x0...', - startAmount: BigInt(1000), - }, - approveInfo: { - currencyAddress: '0x...', - amount: BigInt(1000), - }, +import { config, account, brokerAddress } from './config' + +const { offerHash } = await createCollectionOffer(config, { + account, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + amount: BigInt(1000), }) ``` -## Parameters - -### starknetAccount +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -`AccountInterface` - -The Starknet account used for the transaction. +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -### offer +export const account = new Account(config.starknetProvider, '0x', '0x') -`OfferV1` +export const brokerAddress = '0x' +``` -The base order details for the offer. `OfferV1` includes: + -- `orderHash: bigint` -- `tokenAddress: string` -- `tokenId: bigint` -- `brokerId: string` +## Returns -### approveInfo +[`CreateCollectionOfferResult`](https://github.com/ArkProjectNFTs/ark-project/core/src/actions/order/createCollectionOffer.ts) -`ApproveErc20Info` +The result of the create collection offer action, including the offer hash. -Informations about the ERC20 token to approve, includes : +## Parameters -- `currencyAddress: string` currency address -- `amount: bigint` amount to approve + + + The account responsible for executing the transaction. + + + The address of the broker contract. + + + The contract address of the token. + + + The currency address for the offer. Defaults to + [ETH](https://starkscan.co/token/0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7). + + + The amount of the offer. + + + The start date of the auction. + + + The end date of the auction. + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/create-listing/page.mdx b/apps/docs/src/app/sdk-core/create-listing/page.mdx index 0082fdb5..de0bea32 100644 --- a/apps/docs/src/app/sdk-core/create-listing/page.mdx +++ b/apps/docs/src/app/sdk-core/create-listing/page.mdx @@ -1,11 +1,12 @@ export const metadata = { - title: 'Create Listing', - description: - 'Creates a listing on the Arkchain by building and executing a transaction using specified Starknet and Arkchain accounts.', + title: 'createListing', + description: 'Action for creating a listing on the Arkchain.', } # createListing +Action for creating a listing on the Arkchain. + ## Import ```typescript @@ -14,53 +15,70 @@ import { createListing } from '@arkproject/core' ## Usage -```typescript + + +```ts {{ title: "example.ts" }} import { createListing } from '@arkproject/core' -import { config, parameters } from './config' - -await createListing(config, { - starknetAccount: '0x0...', - order: { - brokerId: '0x...', - tokenAddress: '0x0...', - tokenId: BigInt(1), - startAmount: BigInt(1000), - }, - approveInfo: { - tokenAddress: '0x0...', - tokenId: BigInt(1), - }, +import { config, account, brokerAddress } from './config' + +const { orderHash } = await createListing(config, { + account, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(1000), }) ``` -## Parameters - -### starknetAccount - -`AccountInterface` +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -The Starknet account used for the transaction. - -### order - -`ListingV1` +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -The base order details for the listing, includes: +export const account = new Account(config.starknetProvider, '0x', '0x') -- `orderHash: bigint` -- `tokenAddress: string` -- `tokenId: bigint` -- `brokerId: string` +export const brokerAddress = '0x' +``` -### approveInfo + -`ApproveErc721Info` +## Returns -Informations about the ERC721 token to approve, includes : +[`CreateListingResult`](https://github.com/ArkProjectNFTs/ark-project/core/src/actions/order/createListing.ts) -- `tokenAddress: string` -- `tokenId: bigint` +The result of the create listing action. -## Function Description +## Parameters -`createListing` starts by extracting details from the provided parameters, including Starknet account, Arkchain account, base order, and an optional owner. It then sets default values for unspecified fields in the order, retrieves the chain ID, and constructs a complete `OrderV1` object. The function then calls internal function `createOrder` to compile, sign, and execute the transaction. Finally, it returns the hash of the created order, encapsulated in a promise. + + + The account responsible for executing the transaction. + + + The address of the broker contract. + + + The currency address to be used for the offer. Defaults to ETH. + + + The address of the token contract. + + + The ID of the token. + + + The start date of the offer. Defaults to the current date. + + + The end date of the offer. Defaults to 1 week from the start date. + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/create-offer/page.mdx b/apps/docs/src/app/sdk-core/create-offer/page.mdx index 73970a7a..3e8abd80 100644 --- a/apps/docs/src/app/sdk-core/create-offer/page.mdx +++ b/apps/docs/src/app/sdk-core/create-offer/page.mdx @@ -15,53 +15,64 @@ import { createOffer } from '@arkproject/core' ## Usage -```typescript -import { createOffer } from '@arkproject/core' -import { config, parameters } from './config' + -await createOffer(config, { - starknetAccount: '0x0...', - offer: { - brokerId: '0x...', - tokenAddress: '0x0...', - tokenId: BigInt(1), - startAmount: BigInt(1000), - }, - approveInfo: { - currencyAddress: '0x...', - amount: BigInt(1000), - }, +```ts {{ title: "example.ts" }} +import { createOffer } from '@arkproject/core' +import { config, buyer, brokerAddress } from './config' + +const { orderHash } = await createOffer(config, { + account: buyer, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(1000), }) ``` -## Parameters - -### starknetAccount - -`AccountInterface` - -The Starknet account used for the transaction. +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -### offer - -`OfferV1` - -The base order details for the offer. `OfferV1` includes: - -- `orderHash: bigint` -- `tokenAddress: string` -- `tokenId: bigint` -- `brokerId: string` - -### approveInfo +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -`ApproveErc20Info` +export const buyer = new Account(config.starknetProvider, '0x', '0x') -Informations about the ERC20 token to approve, includes : +export const brokerAddress = '0x' +``` -- `currencyAddress: string` -- `amount: bigint` + -## Function Description +## Parameters -`createOffer` starts by extracting details from the provided parameters, including Starknet and Arkchain accounts, and the base offer. It sets default values for unspecified fields in the offer, retrieves the chain ID, and constructs a complete `OrderV1` object. The function then calls `createOrder` to compile, sign, and execute the transaction. Finally, it returns the hash of the created offer, encapsulated in a promise. + + + The account responsible for executing the transaction. + + + The address of the broker contract. + + + The address of the token contract. + + + The ID of the token. + + + The amount of the offer. + + + The start date of the offer. Defaults to the current date. + + + The end date of the offer. Defaults to 1 week from the start date. + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/fulfill-auction/page.mdx b/apps/docs/src/app/sdk-core/fulfill-auction/page.mdx index 400ec9a0..ed43f06b 100644 --- a/apps/docs/src/app/sdk-core/fulfill-auction/page.mdx +++ b/apps/docs/src/app/sdk-core/fulfill-auction/page.mdx @@ -8,7 +8,7 @@ export const metadata = { Action for fulfilling an auction. -## import +## Import ```typescript import { fulfillAuction } from '@arkproject/core' @@ -16,39 +16,92 @@ import { fulfillAuction } from '@arkproject/core' ## Usage -```typescript -import { fulfillAuction } from '@arkproject/core' -import { config } from './config' - -await fulfillListing(config, { - starknetAccount: '0x0...', - fulfillAuctionInfo: { - orderHash: BigInt(0x0), - relatedOrderHash: BigInt(0x0), - tokenAddress: '0x0...', - tokenId: BigInt(1), - brokerId: '0x...', - }, + + +```ts {{ title: "example.ts" }} +import { createAuction, createOffer, fulfillAuction } from '@arkproject/core' +import { config, buyer, seller, brokerAddress } from './config' + +const auction = await createAuction(config, { + account: seller, + brokerAddress, + tokenAddress + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(1000), +}) + +const offer = await createOffer(config, { + account: buyer, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(1000), +}) + +const { transactionHash } = await fulfillAuction(config, { + account: seller, + brokerAddress, + orderHash: auction.orderHash, + relatedOrderHash: offer.orderHash, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), }) ``` -## Parameters +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -### starknetAccount +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -`AccountInterface` +export const buyer = new Account(config.starknetProvider, '0x', '0x') -The Starknet account used for the transaction. +export const seller = new Account(config.starknetProvider, '0x', '0x') -### fulfillAuctionInfo +export const brokerAddress = '0x' +``` -`FulfillAuctionInfo` + -Informations about the listing to fulfill, includes : +## Returns -- `orderHash: bigint` Auction order hash. +[`FulfillAuctionResult`](https://github.com/ArkProjectNFTs/ark-project/core/src/actions/order/fulfillAuction.ts) + +The result of the fulfill auction action, including the transaction hash. + +## Parameters -- `relatedOrderHash: bigint` Offer order hash. -- `tokenAddress: string` Token address. -- `tokenId: bigint` Token ID. -- `brokerId: string` Broker ID. + + + The account responsible for executing the transaction. + + + The address of the broker contract. + + + The hash of the auction order. + + + The hash of the related offer order. + + + The address of the token contract. + + + The ID of the token. + + + The currency address for the offer. Defaults to + [ETH](https://starkscan.co/token/0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7). + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/fulfill-collection-offer/page.mdx b/apps/docs/src/app/sdk-core/fulfill-collection-offer/page.mdx index c355fbd5..aa41d7fd 100644 --- a/apps/docs/src/app/sdk-core/fulfill-collection-offer/page.mdx +++ b/apps/docs/src/app/sdk-core/fulfill-collection-offer/page.mdx @@ -3,7 +3,7 @@ export const metadata = { description: 'Action for fulfilling a collection offer.', } -# fulfillOffer +# fulfillCollectionOffer Action for fulfilling a collection offer. @@ -15,51 +15,74 @@ import { fulfillCollectionOffer } from '@arkproject/core' ## Usage -```typescript -import { fulfillCollectionOffer } from '@arkproject/core' -import { config } from './config' - -await fulfillCollectionOffer(config, { - starknetAccount: '0x0...', - fulfillOfferInfo: { - orderHash: '0x...', - tokenAddress: - '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', - tokenId: BigInt(1), - brokerId: '0x...', - }, - approveInfo: { - tokenAddress: - '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', - tokenId: BigInt(1), - }, + + +```ts {{ title: "example.ts" }} +import { createCollectionOffer, fulfillCollectionOffer } from '@arkproject/core' +import { config, buyer, seller, brokerAddress } from './config' + +const offer = await createCollectionOffer(config, { + account: buyer, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + amount: BigInt(1000), }) -``` -## Parameters +const { transactionHash } = await fulfillCollectionOffer(config, { + account: seller, + brokerAddress, + orderHash: offer.orderHash, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), +}) +``` -### starknetAccount +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -`AccountInterface` +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -The Starknet account used for the transaction. +export const buyer = new Account(config.starknetProvider, '0x', '0x') -### fulfillCollectionOfferInfo +export const seller = new Account(config.starknetProvider, '0x', '0x') -`FulfillCollectionOfferInfo` +export const brokerAddress = '0x' +``` -Informations about the collection offer to fulfill, includes : + -- `orderHash: bigint` -- `tokenAddress: string` -- `tokenId: bigint` -- `brokerId: string` +## Returns -### approveInfo +[`FulfillCollectionOfferResult`](https://github.com/ArkProjectNFTs/ark-project/core/src/actions/order/fulfillCollectionOffer.ts) -`ApproveErc721Info` +The result of the fulfill collection offer action, including the transaction hash. -Informations about the ERC721 token to approve, includes : +## Parameters -- `tokenAddress: string` -- `tokenId: bigint` + + + The account responsible for executing the transaction. + + + The address of the broker contract. + + + The hash of the collection offer order. + + + The address of the token contract. + + + The ID of the token. + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/fulfill-listing/page.mdx b/apps/docs/src/app/sdk-core/fulfill-listing/page.mdx index 3ad04473..8326c6b2 100644 --- a/apps/docs/src/app/sdk-core/fulfill-listing/page.mdx +++ b/apps/docs/src/app/sdk-core/fulfill-listing/page.mdx @@ -8,7 +8,7 @@ export const metadata = { Action for fulfilling a listing. -## import +## Import ```typescript import { fulfillListing } from '@arkproject/core' @@ -16,54 +16,76 @@ import { fulfillListing } from '@arkproject/core' ## Usage -```typescript -import { fulfillListing } from '@arkproject/core' -import { config } from './config' - -await fulfillListing(config, { - starknetAccount: '0x0...', - fulfillListingInfo: { - orderHash: '0x...', - tokenAddress: - '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', - tokenId: BigInt(1), - brokerId: '0x...', - }, - approveInfo: { - currencyAddress: '0x...', - amount: BigInt(1000), - }, -}) -``` + -## Parameters +```ts {{ title: "example.ts" }} +import { createListing, fulfillListing } from '@arkproject/core' +import { config, buyer, seller, brokerAddress } from './config' -### starknetAccount +const listing = await createListing(config, { + account: seller, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(1000), +}) -`AccountInterface` +const { transactionHash } = await fulfillListing(config, { + account: buyer, + brokerAddress, + orderHash: listing.orderHash, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(1000), +}) +``` -The Starknet account used for the transaction. +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -### fulfillListingInfo +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -`FulfillListingInfo` +export const buyer = new Account(config.starknetProvider, '0x', '0x') -Informations about the listing to fulfill, includes : +export const seller = new Account(config.starknetProvider, '0x', '0x') -- `orderHash: bigint` -- `tokenAddress: string` -- `tokenId: bigint` -- `brokerId: string` +export const brokerAddress = '0x' +``` -### approveInfo + -`ApproveErc20Info` +## Returns -Informations about the ERC20 token to approve, includes : +[`FulfillListingResult`](https://github.com/ArkProjectNFTs/ark-project/core/src/actions/order/fulfillListing.ts) -- `currencyAddress: string` -- `amount: bigint` +The result of the fulfill listing action, including the transaction hash. -## Function Description +## Parameters -`fulfillListing` starts by extracting details from the provided parameters, including Starknet and Arkchain accounts, and information about the listing to be fulfilled. It retrieves the chain ID and constructs a `FulfillInfo` object with the necessary data. The function then calls `_fulfillOrder` to execute the transaction, completing the fulfillment process of the listing. + + + The account responsible for executing the transaction. + + + The address of the broker contract. + + + The hash of the listing order. + + + The address of the token contract. + + + The ID of the token. + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/fulfill-offer/page.mdx b/apps/docs/src/app/sdk-core/fulfill-offer/page.mdx index 55ebb0f6..d25250a0 100644 --- a/apps/docs/src/app/sdk-core/fulfill-offer/page.mdx +++ b/apps/docs/src/app/sdk-core/fulfill-offer/page.mdx @@ -15,55 +15,75 @@ import { fulfillOffer } from '@arkproject/core' ## Usage -```typescript -import { fulfillOffer } from '@arkproject/core' -import { config, parameters } from './config' - -await fulfillOffer(config, { - starknetAccount: '0x0...', - fulfillOfferInfo: { - orderHash: '0x...', - tokenAddress: - '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', - tokenId: BigInt(1), - brokerId: '0x...', - }, - approveInfo: { - tokenAddress: - '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', - tokenId: BigInt(1), - }, + + +```ts {{ title: "example.ts" }} +import { createOffer, fulfillOffer } from '@arkproject/core' +import { config, buyer, seller, brokerAddress } from './config' + +const offer = await createOffer(config, { + account: buyer, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(10), }) -``` - -## Parameters - -### starknetAccount -`AccountInterface` +const { transactionHash } = await fulfillOffer(config, { + account: seller, + brokerAddress, + orderHash: offer.orderHash, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), +}) +``` -The Starknet account used for the transaction. +```ts {{ title: 'config.ts' }} +import { createConfig, networks, contracts } from '@arkproject/core' -### fulfillOfferInfo +export const config = createConfig({ + starknetNetwork: networks.mainnet, + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, +}) -`FulfillOfferInfo` +export const buyer = new Account(config.starknetProvider, '0x', '0x') -Informations about the offer to fulfill, includes : +export const seller = new Account(config.starknetProvider, '0x', '0x') -- `orderHash: bigint` -- `tokenAddress: string` -- `tokenId: bigint` -- `brokerId: string` +export const brokerAddress = '0x' +``` -### approveInfo + -`ApproveErc721Info` +## Returns -Informations about the ERC721 token to approve, includes : +[`FulfillOfferResult`](https://github.com/ArkProjectNFTs/ark-project/core/src/actions/order/fulfillOffer.ts) -- `tokenAddress: string` -- `tokenId: bigint` +The result of the fulfill offer action, including the transaction hash. -## Function Description +## Parameters -`fulfillOffer` begins by extracting necessary details from the provided parameters, including Starknet and Arkchain accounts, and information about the offer to be fulfilled. It retrieves the chain ID and constructs a `FulfillInfo` object with the relevant data. The function then calls `_fulfillOrder` to execute the transaction, thereby completing the fulfillment process of the offer. + + + The account responsible for executing the transaction. + + + The address of the broker contract. + + + The hash of the offer order. + + + The address of the token contract. + + + The ID of the token. + + + If `false`, the function will return immediately after sending the + transaction. Defaults to `true`. + + diff --git a/apps/docs/src/app/sdk-core/getting-started/page.mdx b/apps/docs/src/app/sdk-core/getting-started/page.mdx index 12658228..ae7b9e8d 100644 --- a/apps/docs/src/app/sdk-core/getting-started/page.mdx +++ b/apps/docs/src/app/sdk-core/getting-started/page.mdx @@ -40,10 +40,10 @@ Create and export a new ArkProject config using [createConfig](/sdk-core/configu ```typescript import { createConfig, networks } from '@arkproject/core' -// Create the Ark SDK configuration export const config = createConfig({ - starknetNetwork: networks.mainnet, - arkchainNetwork: Network.mainnet, + starknetNetwork: 'dev', + starknetExecutorContract: contracts.executor, + starknetCurrencyContract: contracts.eth, }) ``` @@ -53,7 +53,14 @@ Now that everything is set up, you can pass the `config` to use actions. ```typescript import { createOffer } from '@arkproject/core' -import { config } from './config' - -const orderHash = await createOffer(config, parameters) +import { config, account, brokerAddress } from './config' + +const { orderHash } = await createOffer(config, { + account, + brokerAddress, + tokenAddress: + '0x02acee8c430f62333cf0e0e7a94b2347b5513b4c25f699461dd8d7b23c072478', + tokenId: BigInt(1), + amount: BigInt(1000), +}) ``` diff --git a/apps/docs/src/app/sdk-react/getting-started/page.mdx b/apps/docs/src/app/sdk-react/getting-started/page.mdx index 7a14942f..74cdac5f 100644 --- a/apps/docs/src/app/sdk-react/getting-started/page.mdx +++ b/apps/docs/src/app/sdk-react/getting-started/page.mdx @@ -26,7 +26,7 @@ Before using the `ArkProvider`, you need to create a Starknet provider. For deta Integrate the ArkProvider and StarknetProvider into your application like so: -```jsx +```tsx import { StarknetProvider } from '@/components/starknet-provider' // Ensure you have a StarknetProvider component import { networks } from '@ark-project/core' import { ArkProvider } from '@ark-project/react' @@ -34,7 +34,6 @@ import { ArkProvider } from '@ark-project/react' export default function Layout({ children }) { const config = { starknetNetwork: networks.mainnet, - arkchainNetwork: networks.mainnet, } return ( diff --git a/apps/docs/src/app/sdk-react/introduction/page.mdx b/apps/docs/src/app/sdk-react/introduction/page.mdx index 7f210db8..aca72074 100644 --- a/apps/docs/src/app/sdk-react/introduction/page.mdx +++ b/apps/docs/src/app/sdk-react/introduction/page.mdx @@ -24,20 +24,12 @@ pnpm add @arkproject/core Create and export a new ArkProject config using createConfig. ```typescript -import { createConfig, Network } from '@arkproject/core' +import { createConfig, networks } from '@arkproject/core' import { ProviderInterface, RpcProvider } from 'starknet' -// Initialize a RPC provider with your Starknet node URL using starknet.js -const starknetProvider = new RpcProvider({ - nodeUrl: process.env.STARKNET_RPC_URL ?? 'localhost:5050', -}) as ProviderInterface - // Create the Ark SDK configuration export const config = createConfig({ - starknetProvider: starknetProvider, - starknetNetwork: Network.goerli, - arkchainNetwork: Network.goerli, - arkchainRpcUrl: 'https://staging.solis.arkproject.dev', + starknetNetwork: networks.mainnet, }) ``` diff --git a/apps/docs/src/app/sdk-react/use-cancel-collection-offer/page.mdx b/apps/docs/src/app/sdk-react/use-cancel-collection-offer/page.mdx deleted file mode 100644 index 94fab77c..00000000 --- a/apps/docs/src/app/sdk-react/use-cancel-collection-offer/page.mdx +++ /dev/null @@ -1,65 +0,0 @@ -export const metadata = { - title: 'useCancelCollectionOffer', - description: 'A hook for canceling a collection offer.', -} - -# useCancel - -A hook for canceling collection offer. - -## Import - -```typescript -import useCancelCollection from '@ark-project/react' -``` - -## Usage - -```typescript -import { useAccount } from '@starknet-react/core' -import { useCancelCollectionOffer } from '@ark-project/react' - -const CancelCollectionOffer = ({ orderHash, tokenAddress, tokenId }) => { - const { account } = useAccount() - const { cancelCollectionOffer, status } = useCancelCollectionOffer() - - return ( - <> - - {status === 'loading' &&

Cancelling...

} - {status === 'success' &&

Cancelled

} - - ) -} -``` - -## Return Type - -### cancelCollectionOffer - -`(variables: CancelCollectionOfferParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -### status - -`'idle' | 'loading' | 'success' | 'error'` - -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. - -## Actions - -- [cancelCollectionOffer](/sdk-core/cancel-collection-offer) diff --git a/apps/docs/src/app/sdk-react/use-cancel/page.mdx b/apps/docs/src/app/sdk-react/use-cancel/page.mdx index c2461066..5b13d2e9 100644 --- a/apps/docs/src/app/sdk-react/use-cancel/page.mdx +++ b/apps/docs/src/app/sdk-react/use-cancel/page.mdx @@ -15,30 +15,30 @@ import useCancel from '@ark-project/react' ## Usage -```typescript +```tsx import { useAccount } from '@starknet-react/core' import { useCancel } from '@ark-project/react' -function CancelListing({ orderHash, tokenAddress, tokenId }) { - const { cancel, status } = useCancel() +function App({ orderHash, tokenAddress, tokenId }) { const { account } = useAccount() + const { cancel, data, isLoading, isSuccess } = useCancel() return ( <> - {status === 'loading' &&

Cancelling...

} - {status === 'success' &&

Cancelled

} + {isLoading &&

Loading...

} + {isSuccess &&

{data.transactionHash}

} ) } @@ -46,20 +46,37 @@ function CancelListing({ orderHash, tokenAddress, tokenId }) { ## Return Type -### cancel +```ts +import { type UseCancelReturnType } from '@ark-project/react' +``` -`(variables: CancelParameters) => void` + + + Mutation to cancel the order. See [CancelParams](/sdk-core/cancel-order). + + + Async mutation to cancel the order. See + [CancelParams](/sdk-core/cancel-order). + + + The data returned from the mutation. + + + +## Parameters -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. +```typescript +import { type CancelParams } from '@ark-project/core' +``` -### status +### config (optional) -`'idle' | 'loading' | 'success' | 'error'` +`Config | undefined` -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. +Config to use instead of retrieving from the from nearest ArkProvider. ## Actions diff --git a/apps/docs/src/app/sdk-react/use-config/page.mdx b/apps/docs/src/app/sdk-react/use-config/page.mdx index 5d67c01b..2b21bfef 100644 --- a/apps/docs/src/app/sdk-react/use-config/page.mdx +++ b/apps/docs/src/app/sdk-react/use-config/page.mdx @@ -15,18 +15,12 @@ import { useConfig } from '@ark-project/react' ## Usage -```typescript +```tsx import React from 'react' import { useConfig } from '@ark-project/react' function App = () => { const config = useConfig() - - return ( -
- {config &&
{JSON.stringify(config, null, 2)}
} -
- ) } ``` @@ -34,4 +28,4 @@ function App = () => { `Config | undefined` -[Config](/sdk-core/configuration) or `undefined` if no provider found. +Config to use instead of retrieving from the from nearest ArkProvider. diff --git a/apps/docs/src/app/sdk-react/use-create-auction/page.mdx b/apps/docs/src/app/sdk-react/use-create-auction/page.mdx index c18c083d..094bc496 100644 --- a/apps/docs/src/app/sdk-react/use-create-auction/page.mdx +++ b/apps/docs/src/app/sdk-react/use-create-auction/page.mdx @@ -15,60 +15,66 @@ import { useCreateAuction } from '@ark-project/react' ## Usage -```typescript -import { useCreateAuction } from '@ark-project/react'; - -function CreateAuction({ tokenAddress, tokenId, startAmount }) { - const { createAuction, status, response } = useCreateAuction(); +```tsx +import { useCreateAuction } from '@ark-project/react' - const handleCreateAuction = async () => { - await createListing({ - starknetAccount: /* account info */, - tokenAddress: tokenAddress, - tokenId: tokenId, - startAmount: startAmount, - // Additional parameters... - }); - }; +function App({ tokenAddress, tokenId, startAmount }) { + const { createAuction, data, isLoading, isSuccess } = useCreateAuction() return ( <> - -
Status: {status}
- {response &&
Response: {response.toString()}
} + + {isLoading &&

Loading...

} + {isSuccess &&
{data.orderHash}
} - ); -}; + ) +} ``` ## Return Type -### createAuction - -`(variables: CreateAuctionParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -- variables - - `CreateAuctionParameters` - - The variables object to pass to the [createAuction](/sdk-core/create-auction#parameters) action. - -### status - -`'idle' | 'loading' | 'success' | 'error'` - -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. - -### response - -`BigNumber` +```ts +import { type UseCancelReturnType } from '@ark-project/react' +``` -Order hash of the listing creation order. + + + Mutation to create an auction. See + [CreateAuctionParams](/sdk-core/create-auction). + + + Async mutation to create an auction. See + [CreateAuctionParams](/sdk-core/create-auction). + + + The data returned from the mutation. + + + +## Parameters + + + + Config to use instead of retrieving from the from nearest ArkProvider. + + ## Actions diff --git a/apps/docs/src/app/sdk-react/use-create-collection-offer/page.mdx b/apps/docs/src/app/sdk-react/use-create-collection-offer/page.mdx index fbd37bc5..82d7b46c 100644 --- a/apps/docs/src/app/sdk-react/use-create-collection-offer/page.mdx +++ b/apps/docs/src/app/sdk-react/use-create-collection-offer/page.mdx @@ -3,7 +3,7 @@ export const metadata = { description: 'Hook for creating a collection offer.', } -# useCreateOffer +# useCreateCollectionOffer Hook for creating a collection offer. @@ -15,65 +15,68 @@ import { useCreateCollectionOffer } from '@ark-project/react' ## Usage -```typescript -import { useCreateCollectionOffer } from '@ark-project/react'; - -function CreateCollectionOfferComponent({ tokenAddress, tokenId, startAmount, brokerId, currencyAddress }) { - const { createCollectionOffer, status, response } = useCreateCollectionOffer(); - - const handleCreateOffer = async () => { - await createCollectionOffer({ - starknetAccount: /* account info */, - offer: { - brokerId, - tokenAddress: STARKNET_NFT_ADDRESS, - startAmount: BigInt(1) - }, - approveInfo: { - currencyAddress: '0x...', - amount: startAmount, - } - }); - }; +```tsx +import { useCreateCollectionOffer } from '@ark-project/react' +import { useAccount } from '@starknet-react/core' + +function App({ tokenAddress, startAmount, brokerId, currencyAddress }) { + const { account } = useAccount() + const { createCollectionOffer, data, isLoading, isSuccess } = + useCreateCollectionOffer() return ( -
- -
Status: {status}
- {response &&
Response: {response.toString()}
} -
- ); -}; + <> + + {isLoading &&

Loading...

} + {isSuccess &&
{data.orderHash}
} + + ) +} ``` ## Return Type -### createListing - -`(variables: CreateOfferParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -- variables - - `CreateOfferParameters` - - The variables object to pass to the [createAuction](/sdk-core/create-collection-offer#parameters) action. - -### status - -`'idle' | 'loading' | 'success' | 'error'` - -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. - -### response - -`BigNumber` +```tsx +import { type UseCreateCollectionOfferReturnType } from '@ark-project/react' +``` -Order hash of the created collection offer. + + + Mutation to create a collection offer. See + [CreateCollectionOfferParams](/sdk-core/create-collection-offer). + + + Async mutation to create a collection offer. See + [CreateCollectionOfferParams](/sdk-core/create-collection-offer). + + + The data returned from the mutation. + + + +## Parameters + + + + Config to use instead of retrieving from the nearest ArkProvider. + + ## Actions diff --git a/apps/docs/src/app/sdk-react/use-create-listing/page.mdx b/apps/docs/src/app/sdk-react/use-create-listing/page.mdx index d5cc3fe1..952f3996 100644 --- a/apps/docs/src/app/sdk-react/use-create-listing/page.mdx +++ b/apps/docs/src/app/sdk-react/use-create-listing/page.mdx @@ -16,24 +16,25 @@ import { useCreateListing } from '@ark-project/react' ## Usage ```typescript +import { useAccount } from '@starknet-react/core' import { useCreateListing } from '@ark-project/react'; -function CreateListing({ tokenAddress, tokenId, startAmount }) { - const { createListing, status, response } = useCreateListing(); +function App({ tokenAddress, tokenId, startAmount }) { + const { account } = useAccount(); + const { createListing, data, isLoading, isSuccess } = useCreateListing(); - const handleCreateListing = async () => { - await createListing({ - starknetAccount: /* account info */, - tokenAddress: tokenAddress, - tokenId: tokenId, - startAmount: startAmount, - // Additional parameters... - }); - }; - - return ( +return ( <> - +
Status: {status}
{response &&
Response: {response.toString()}
} @@ -43,32 +44,37 @@ function CreateListing({ tokenAddress, tokenId, startAmount }) { ## Return Type -### createListing - -`(variables: CreateListingParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -- variables - - `CreateListingParameters` - - The variables object to pass to the [createListing](/sdk-core/create-listing#parameters) action. - -### status - -`'idle' | 'loading' | 'success' | 'error'` - -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. - -### response - -`BigNumber` +```tsx +import { type useCreateListingReturnType } from '@ark-project/react' +``` -Order hash of the listing creation order. + + + Mutation to create a listing. See + [CreateListingParams](/sdk-core/create-listing). + + + Async mutation to create a listing. See + [CreateListingParams](/sdk-core/create-auction). + + + The data returned from the mutation. + + + +## Parameters + + + + Config to use instead of retrieving from the from nearest ArkProvider. + + ## Actions diff --git a/apps/docs/src/app/sdk-react/use-create-offer/page.mdx b/apps/docs/src/app/sdk-react/use-create-offer/page.mdx index 42718102..8c1f320b 100644 --- a/apps/docs/src/app/sdk-react/use-create-offer/page.mdx +++ b/apps/docs/src/app/sdk-react/use-create-offer/page.mdx @@ -15,64 +15,77 @@ import { useCreateOffer } from '@ark-project/react' ## Usage -```typescript -import { useCreateOffer } from '@ark-project/react'; - -const CreateOfferComponent = ({ tokenAddress, tokenId, startAmount, brokerId, currencyAddress, currencyChainId, startDate, endDate }) => { - const { createOffer, status, response } = useCreateOffer(); - - const handleCreateOffer = async () => { - await createOffer({ - starknetAccount: /* account info */, - startAmount: startAmount, - tokenAddress: tokenAddress, - tokenId: tokenId, - brokerId: brokerId, - currencyAddress: currencyAddress, - currencyChainId: currencyChainId, - startDate: startDate, - endDate: endDate - }); - }; +```tsx +import { useCreateOffer } from '@ark-project/react' +import { useAccount } from '@starknet-react/core' + +function App({ + tokenAddress, + tokenId, + amount, + brokerId, + currencyAddress, + currencyChainId, + startDate, + endDate, +}) { + const { account } = useAccount() + const { createOffer, data, isLoading, isSuccess } = useCreateOffer() return ( -
- -
Status: {status}
- {response &&
Response: {response.toString()}
} -
- ); -}; + <> + + {isLoading &&

Loading...

} + {isSuccess &&
{data.orderHash}
} + + ) +} ``` ## Return Type -### createListing - -`(variables: CreateOfferParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -- variables - - `CreateOfferParameters` - - The variables object to pass to the [createAuction](/sdk-core/create-offer#parameters) action. - -### status - -`'idle' | 'loading' | 'success' | 'error'` - -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. - -### response - -`BigNumber` +```ts +import { type useCreateOfferReturnType } from '@ark-project/react' +``` -Order hash of the created offer. + + + Mutation to create an offer. See + [CreateOfferParams](/sdk-core/create-offer). + + + Async mutation to create an offer. See + [CreateOfferParams](/sdk-core/create-offer). + + + The data returned from the mutation. + + + +## Parameters + + + + Config to use instead of retrieving from the nearest ArkProvider. + + ## Actions diff --git a/apps/docs/src/app/sdk-react/use-fulfill-auction/page.mdx b/apps/docs/src/app/sdk-react/use-fulfill-auction/page.mdx index 910fa806..a229b2ad 100644 --- a/apps/docs/src/app/sdk-react/use-fulfill-auction/page.mdx +++ b/apps/docs/src/app/sdk-react/use-fulfill-auction/page.mdx @@ -15,65 +15,72 @@ import { useFulfillAuction } from '@ark-project/react' ## Usage -```typescript -import React from 'react' +```tsx +import { useAccount } from '@starknet-react/core' import { useFulfillAuction } from '@ark-project/react' function FulfillAuction({ - starknetAccount, orderHash, + relatedOrderHash tokenAddress, tokenId, - brokerId, - startAmount, - currencyAddress, }) { - const { fulfillAuction, status } = useFulfillAuction() - - const handleFulfillAuction = async () => { - await fulfillAuction({ - starknetAccount: starknetAccount, - orderHash: orderHash, - tokenAddress: tokenAddress, - tokenId: tokenId, - brokerId: brokerId, - startAmount: startAmount, - currencyAddress: currencyAddress, - // Additional parameters... - }) - } + const { account } = useAccount(); + const { fulfillAuction, data, isLoading, isSuccess } = useFulfillAuction() return ( -
- -
Status: {status}
-
+ <> + + {isLoading &&

Loading...

} + {isSuccess &&
{data.transactionHash}
} + ) } ``` ## Return Type -### fulfillAuction - -`(variables: FulfillAuctionParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -- variables - - `FulfillAuctionParameters` - - The variables object to pass to the [fulfillAuction](/sdk-core/fulfill-auction#parameters) action. - -### status - -`'idle' | 'loading' | 'success' | 'error'` +```ts +import { type useFulfillAuctionReturnType } from '@ark-project/react' +``` -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. + + + Mutation to fulfill an auction. See + [FulfillAuctionParams](/sdk-core/fulfill-auction). + + + Async mutation to fulfill an auction. See + [FulfillAuctionParams](/sdk-core/fulfill-auction). + + + The data returned from the mutation. + + + +## Parameters + + + + Config to use instead of retrieving from the nearest ArkProvider. + + ## Actions diff --git a/apps/docs/src/app/sdk-react/use-fulfill-collection-offer/page.mdx b/apps/docs/src/app/sdk-react/use-fulfill-collection-offer/page.mdx deleted file mode 100644 index 7c16e241..00000000 --- a/apps/docs/src/app/sdk-react/use-fulfill-collection-offer/page.mdx +++ /dev/null @@ -1,84 +0,0 @@ -export const metadata = { - title: 'useFulfillCollectionOffer', - description: 'Hook for fulfilling collection offers.', -} - -# useFulfillCollectionOffer - -Hook for fulfilling collection offers. - -## Import - -```typescript -import { useFulfillCollectionOffer } from '@ark-project/react' -``` - -## Usage - -```typescript -import { useFulfillCollectionOffer } from '@ark-project/react' - -const FulfillOfferComponent = ({ - starknetAccount, - orderHash, - tokenAddress, - tokenId, - brokerId, -}) => { - const { fulfillCollectionOffer, status } = useFulfillCollectionOffer() - - return ( -
- -
Status: {status}
-
- ) -} -``` - -## Return Type - -### fulfillCollectionOffer - -`(variables: FulfillCollectionOfferParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -- variables - - `FulfillCollectionOfferParameters` - - The variables object to pass to the [fulfillCollectionOffer](/sdk-core/fulfill-collection-offer#parameters) action. - -### status - -`'idle' | 'loading' | 'success' | 'error'` - -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. - -## Actions - -- [fulfillCollectionOffer](/sdk-core/fulfill-collection-offer) - -[FulfillCollectionOfferParameters](/sdk-core/fulfill-collection-offer#parameters) and [FulfillCollectionOfferResponse](/sdk-core/fulfill-collection-offer#response) for more details. diff --git a/apps/docs/src/app/sdk-react/use-fulfill-listing/page.mdx b/apps/docs/src/app/sdk-react/use-fulfill-listing/page.mdx index ef281543..9e58fbfa 100644 --- a/apps/docs/src/app/sdk-react/use-fulfill-listing/page.mdx +++ b/apps/docs/src/app/sdk-react/use-fulfill-listing/page.mdx @@ -15,68 +15,80 @@ import { useFulfillListing } from '@ark-project/react' ## Usage -```typescript -import React from 'react' +```tsx +import { useAccount } from '@starknet-react/core' import { useFulfillListing } from '@ark-project/react' -const FulfillListingComponent = ({ - starknetAccount, +function FulfillListing({ orderHash, tokenAddress, tokenId, brokerId, startAmount, currencyAddress, -}) => { +}) { + const { account } = useAccount() const { fulfillListing, status } = useFulfillListing() - const handleFulfillListing = async () => { - await fulfillListing({ - starknetAccount: starknetAccount, - orderHash: orderHash, - tokenAddress: tokenAddress, - tokenId: tokenId, - brokerId: brokerId, - startAmount: startAmount, - currencyAddress: currencyAddress, - // Additional parameters... - }) - } - return ( -
- + <> +
Status: {status}
-
+ ) } ``` ## Return Type -### fulfillListing - -`(variables: FulfillListingParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -- variables - - `CreateOfferParameters` - - The variables object to pass to the [fulfillListing](/sdk-core/fulfill-listing#parameters) action. - -### status - -`'idle' | 'loading' | 'success' | 'error'` +```ts +import { type useFulfillListingReturnType } from '@ark-project/react' +``` -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. + + + Mutation to fulfill a listing. See + [FulfillListingParams](/sdk-core/fulfill-listing). + + + Async mutation to fulfill a listing. See + [FulfillListingParams](/sdk-core/fulfill-listing). + + + The data returned from the mutation. + + + +## Parameters + + + + Config to use instead of retrieving from the nearest ArkProvider. + + ## Actions - [fulfillListing](/sdk-core/fulfill-listing) -[CreateOfferParameters](/sdk-core/fulfill-listing#parameters) and [CreateOfferResponse](/sdk-core/fulfill-listing#response) for more details. +[FulfillListingParameters](/sdk-core/fulfill-listing#parameters) and [FulfillListingResponse](/sdk-core/fulfill-listing#response) for more details. diff --git a/apps/docs/src/app/sdk-react/use-fulfill-offer/page.mdx b/apps/docs/src/app/sdk-react/use-fulfill-offer/page.mdx index 68ab898f..1d481218 100644 --- a/apps/docs/src/app/sdk-react/use-fulfill-offer/page.mdx +++ b/apps/docs/src/app/sdk-react/use-fulfill-offer/page.mdx @@ -15,59 +15,74 @@ import { useFulfillOffer } from '@ark-project/react' ## Usage -```typescript +```tsx import { useFulfillOffer } from '@ark-project/react' +import { useAccount } from '@starknet-react/core' const FulfillOfferComponent = ({ - starknetAccount, orderHash, tokenAddress, tokenId, brokerId, }) => { - const { fulfillOffer, status } = useFulfillOffer() - - const handleFulfillOffer = async () => { - await fulfillOffer({ - starknetAccount: starknetAccount, - orderHash: orderHash, - tokenAddress: tokenAddress, - tokenId: tokenId, - brokerId: brokerId, - }) - } + const { account } = useAccount() + const { fulfillOffer, data, isLoading, isSuccess } = useFulfillOffer() return ( -
- -
Status: {status}
-
+ <> + + {isLoading &&

Loading...

} + {isSuccess &&
{data.transactionHash}
} + ) } ``` ## Return Type -### fulfillOffer - -`(variables: FulfillOfferParameters) => void` - -The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. - -- variables - - `FulfillOfferParameters` - - The variables object to pass to the [fulfillOffer](/sdk-core/fulfill-offer#parameters) action. - -### status - -`'idle' | 'loading' | 'success' | 'error'` +```ts +import { type useFulfillOfferReturnType } from '@ark-project/react' +``` -- `idle` if the mutation has not been executed yet. -- `loading` if the mutation is currently executing. -- `error` if the last mutation attempt resulted in an error. -- `success` if the last mutation attempt was successful. + + + Mutation to fulfill an offer. See + [FulfillOfferParams](/sdk-core/fulfill-offer). + + + Async mutation to fulfill an offer. See + [FulfillOfferParams](/sdk-core/fulfill-offer). + + + The data returned from the mutation. + + + +## Parameters + + + + Config to use instead of retrieving from the nearest ArkProvider. + + ## Actions diff --git a/apps/docs/src/components/Navigation.tsx b/apps/docs/src/components/Navigation.tsx index 7793c6a2..35d4d4b9 100644 --- a/apps/docs/src/components/Navigation.tsx +++ b/apps/docs/src/components/Navigation.tsx @@ -1,10 +1,10 @@ 'use client' -import { useRef } from 'react' -import Link from 'next/link' -import { usePathname } from 'next/navigation' import clsx from 'clsx' import { AnimatePresence, motion, useIsPresent } from 'framer-motion' +import Link from 'next/link' +import { usePathname } from 'next/navigation' +import { useRef } from 'react' import { Button } from '@/components/Button' import { useIsInsideMobileNavigation } from '@/components/MobileNavigation' @@ -303,10 +303,6 @@ export const navigation: Array = [ { title: 'Installation', href: '/sdk-core/installation' }, { title: 'Getting started', href: '/sdk-core/getting-started' }, { title: 'Configuration', href: '/sdk-core/configuration' }, - { - title: 'cancelCollectionOffer', - href: '/sdk-core/cancel-collection-offer', - }, { title: 'cancelOrder', href: '/sdk-core/cancel-order', @@ -374,10 +370,6 @@ export const navigation: Array = [ links: [ { title: 'Getting started', href: '/sdk-react/getting-started' }, { title: 'useCancel', href: '/sdk-react/use-cancel' }, - { - title: 'useCancelCollectionOffer', - href: '/sdk-react/use-cancel-collection-offer', - }, { title: 'useConfig', href: '/sdk-react/use-config' }, { title: 'useCreateAuction', href: '/sdk-react/use-create-auction' }, { title: 'useCreateListing', href: '/sdk-react/use-create-listing' }, @@ -387,31 +379,10 @@ export const navigation: Array = [ }, { title: 'useCreateOffer', href: '/sdk-react/use-create-offer' }, { title: 'useFulfillAuction', href: '/sdk-react/use-fulfill-auction' }, - { - title: 'useFulfillCollectionOffer', - href: '/sdk-react/use-fulfill-collection-offer', - }, { title: 'useFulfillListing', href: '/sdk-react/use-fulfill-listing' }, { title: 'useFulfillOffer', href: '/sdk-react/use-fulfill-offer' }, ], }, - - // { - // title: 'Trading API', - // links: [ - // { title: 'Introduction', href: '/tradingapi' }, - // ], - // }, - // { - // title: 'NFT Indexer', - // links: [{ title: 'Introduction', href: '/nftindexer' }], - // }, - // { - // title: 'NFT Bridge', - // links: [ - // { title: 'Introduction', href: '/nftbridge' }, - // ], - // }, ] export function Navigation(props: React.ComponentPropsWithoutRef<'nav'>) {