Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions es/sdk/web/checkout-sdk/hooks/useERC1155SaleContractCheckout.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
title: useERC1155SaleContractCheckout
description: Hook para gestionar el checkout del contrato de venta ERC-1155
sidebarTitle: useERC1155SaleContractCheckout
---

## Importar

```tsx
import { useERC1155SaleContractCheckout } from '@0xsequence/checkout'
```

## Uso

```tsx
import { useERC1155SaleContractCheckout } from "@0xsequence/checkout"
import { useAccount } from "wagmi"

function App() {
const { address: userAddress } = useAccount()
const { openCheckoutModal } = useERC1155SaleContractCheckout({
chain: 80001, // chainId of the chain the collectible is on
contractAddress: "0x0327b2f274e04d292e74a06809bcd687c63a4ba4", // address of the contract handling the minting function
wallet: userAddress!, // address of the recipient
collectionAddress: "0x888a322db4b8033bac3ff84412738c096f87f9d0", // address of the collection contract
items: [
// array of collectibles to purchase
{
tokenId: "0",
quantity: "1",
},
],
onSuccess: (txnHash: string) => {
console.log("success!", txnHash)
},
onError: (error: Error) => {
console.error(error)
},
})

const onClick = () => {
if (!userAddress) {
return
}
openCheckoutModal()
}

return <button onClick={onClick}>Buy ERC-1155 collectible!</button>
}
```

## Tipo de retorno: `UseERC1155SaleContractCheckoutReturnType`
El hook retorna un objeto con las siguientes propiedades:

```tsx
interface UseERC1155SaleContractCheckoutReturnType {
openCheckoutModal: () => void
closeCheckoutModal: () => void
selectPaymentSettings?: SelectPaymentSettings
isLoading: boolean
isError: boolean
}
```

### Propiedades

#### openCheckoutModal
`() => void`

Función para abrir el modal de checkout con la compra ERC-1155 configurada.

#### closeCheckoutModal
`() => void`

Función para cerrar el modal de checkout.

#### selectPaymentSettings
`SelectPaymentSettings | undefined`

```tsx
export interface SelectPaymentSettings {
collectibles: Collectible[]
chain: number | string
currencyAddress: string | Hex
price: string
targetContractAddress: string | Hex
txData: Hex
collectionAddress: string | Hex
recipientAddress: string | Hex
approvedSpenderAddress?: string
transactionConfirmations?: number
onSuccess?: (txHash: string) => void
onError?: (error: Error) => void
onClose?: () => void
enableMainCurrencyPayment?: boolean
enableSwapPayments?: boolean
enableTransferFunds?: boolean
creditCardProviders?: string[]
copyrightText?: string
customProviderCallback?: (onSuccess: (txHash: string) => void, onError: (error: Error) => void, onClose: () => void) => void
supplementaryAnalyticsInfo?: SupplementaryAnalyticsInfo
}
```

La configuración actual de pago para el modal.

#### isLoading
`boolean`

Indica si los datos del contrato aún se están cargando.

#### isError
`boolean`

Indica si hubo un error al cargar los datos del contrato.

## Parámetros
El hook acepta un objeto de configuración con las siguientes propiedades:

| Parámetro | Tipo | Descripción |
| ------------------- | -------------------------------------------- | ------------------------------------------------------------ |
| `chain` | `number` | ID de cadena donde está desplegado el contrato de venta |
| `contractAddress` | `string` | Dirección del contrato de venta ERC-1155 |
| `wallet` | `string` | Dirección del wallet que recibirá los NFTs |
| `collectionAddress` | `string` | Dirección del contrato de token ERC-1155 |
| `items` | `Array<{tokenId: string, quantity: string}>` | Lista de IDs de token y cantidades a comprar |
| `onSuccess` | `(txnHash: string) => void` | (Opcional) Función callback cuando la transacción es exitosa |
| `onError` | `(error: Error) => void` | (Opcional) Función callback cuando ocurre un error |
| `onClose` | `() => void` | (Opcional) Función callback cuando se cierra el modal |

## Notas
Este hook simplifica el proceso de compra de tokens ERC-1155 al realizar automáticamente las siguientes acciones:
- Obtener información de precios desde el contrato de venta
- Determinar opciones de pago (cripto, tarjeta de crédito, etc.)
- Generar los datos de transacción adecuados
- Abrir y gestionar el modal de checkout

## Aviso de Deprecación

<Warning>
El hook `useERC1155SaleContractPaymentModal` está obsoleto. Use `useERC1155SaleContractCheckout` en su lugar.
</Warning>
5 changes: 0 additions & 5 deletions es/sdk/web/checkout-sdk/hooks/useSelectPaymentModal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ function BuyNFT() {
currencyAddress,
collectionAddress,
creditCardProviders: ['transak'],
transakConfig: {
contractId: 'your-contract-id',
apiKey: 'your-api-key'
},
onSuccess: (txnHash: string) => {
console.log('success!', txnHash)
},
Expand Down Expand Up @@ -172,7 +168,6 @@ El objeto `settings` puede incluir las siguientes propiedades:
| `currencyAddress` | `string` | Dirección del contrato del token de la moneda |
| `collectionAddress` | `string` | Dirección del contrato de la colección NFT |
| `creditCardProviders` | `string[]` | Lista de proveedores de tarjetas de crédito compatibles (por ejemplo, 'transak') |
| `transakConfig` | `object` | Configuración para la integración con Transak |
| `copyrightText` | `string` | Texto de derechos de autor para mostrar en el modal |
| `onSuccess` | `(txnHash: string) => void` | Callback cuando la transacción es exitosa |
| `onError` | `(error: Error) => void` | Callback cuando ocurre un error |
Expand Down
142 changes: 142 additions & 0 deletions ja/sdk/web/checkout-sdk/hooks/useERC1155SaleContractCheckout.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
title: useERC1155SaleContractCheckout
description: ERC-1155販売コントラクトのチェックアウトを管理するためのフック
sidebarTitle: useERC1155SaleContractCheckout
---

## インポート

```tsx
import { useERC1155SaleContractCheckout } from '@0xsequence/checkout'
```

## 使い方

```tsx
import { useERC1155SaleContractCheckout } from "@0xsequence/checkout"
import { useAccount } from "wagmi"

function App() {
const { address: userAddress } = useAccount()
const { openCheckoutModal } = useERC1155SaleContractCheckout({
chain: 80001, // chainId of the chain the collectible is on
contractAddress: "0x0327b2f274e04d292e74a06809bcd687c63a4ba4", // address of the contract handling the minting function
wallet: userAddress!, // address of the recipient
collectionAddress: "0x888a322db4b8033bac3ff84412738c096f87f9d0", // address of the collection contract
items: [
// array of collectibles to purchase
{
tokenId: "0",
quantity: "1",
},
],
onSuccess: (txnHash: string) => {
console.log("success!", txnHash)
},
onError: (error: Error) => {
console.error(error)
},
})

const onClick = () => {
if (!userAddress) {
return
}
openCheckoutModal()
}

return <button onClick={onClick}>Buy ERC-1155 collectible!</button>
}
```

## 返り値の型: `UseERC1155SaleContractCheckoutReturnType`
このフックは以下のプロパティを持つオブジェクトを返します。

```tsx
interface UseERC1155SaleContractCheckoutReturnType {
openCheckoutModal: () => void
closeCheckoutModal: () => void
selectPaymentSettings?: SelectPaymentSettings
isLoading: boolean
isError: boolean
}
```

### プロパティ

#### openCheckoutModal
`() => void`

設定済みのERC-1155購入でチェックアウトモーダルを開く関数です。

#### closeCheckoutModal
`() => void`

チェックアウトモーダルを閉じる関数です。

#### selectPaymentSettings
`SelectPaymentSettings | undefined`

```tsx
export interface SelectPaymentSettings {
collectibles: Collectible[]
chain: number | string
currencyAddress: string | Hex
price: string
targetContractAddress: string | Hex
txData: Hex
collectionAddress: string | Hex
recipientAddress: string | Hex
approvedSpenderAddress?: string
transactionConfirmations?: number
onSuccess?: (txHash: string) => void
onError?: (error: Error) => void
onClose?: () => void
enableMainCurrencyPayment?: boolean
enableSwapPayments?: boolean
enableTransferFunds?: boolean
creditCardProviders?: string[]
copyrightText?: string
customProviderCallback?: (onSuccess: (txHash: string) => void, onError: (error: Error) => void, onClose: () => void) => void
supplementaryAnalyticsInfo?: SupplementaryAnalyticsInfo
}
```

モーダルの現在の支払い設定構成です。

#### isLoading
`boolean`

コントラクトデータがまだ読み込み中かどうか。

#### isError
`boolean`

コントラクトデータの読み込み時にエラーが発生したかどうか。

## パラメータ
このフックは、以下のプロパティを持つ設定オブジェクトを受け取ります:

| パラメータ | 型 | 説明 |
| ------------------- | -------------------------------------------- | ------------------------------ |
| `chain` | `number` | 販売コントラクトがデプロイされているチェーンID |
| `contractAddress` | `string` | ERC-1155販売コントラクトのアドレス |
| `wallet` | `string` | NFTを受け取るウォレットのアドレス |
| `collectionAddress` | `string` | ERC-1155トークンコントラクトのアドレス |
| `items` | `Array<{tokenId: string, quantity: string}>` | 購入するトークンIDと数量の配列。 |
| `onSuccess` | `(txnHash: string) => void` | (オプション)トランザクションが成功した際のコールバック関数 |
| `onError` | `(error: Error) => void` | (オプション)エラー発生時のコールバック関数 |
| `onClose` | `() => void` | (オプション)モーダルが閉じられた際のコールバック関数 |

## 補足
このフックは、ERC-1155トークンの購入プロセスを自動化し、以下の作業を簡単にします。
- 販売コントラクトから価格情報を取得。
- 支払いオプション(暗号資産、クレジットカードなど)を判定。
- 適切なトランザクションデータを生成。
- チェックアウトモーダルの表示と管理。

## 非推奨のお知らせ

<Warning>
`useERC1155SaleContractPaymentModal`フックは非推奨です。代わりに`useERC1155SaleContractCheckout`をご利用ください。
</Warning>
5 changes: 0 additions & 5 deletions ja/sdk/web/checkout-sdk/hooks/useSelectPaymentModal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ function BuyNFT() {
currencyAddress,
collectionAddress,
creditCardProviders: ['transak'],
transakConfig: {
contractId: 'your-contract-id',
apiKey: 'your-api-key'
},
onSuccess: (txnHash: string) => {
console.log('success!', txnHash)
},
Expand Down Expand Up @@ -172,7 +168,6 @@ type UseSelectPaymentModalReturnType = {
| `currencyAddress` | `string` | 通貨トークンコントラクトのアドレス |
| `collectionAddress` | `string` | NFTコレクションコントラクトのアドレス |
| `creditCardProviders` | `string[]` | 対応しているクレジットカードプロバイダー一覧(例:'transak') |
| `transakConfig` | `object` | Transak連携用の設定 |
| `copyrightText` | `string` | モーダル内に表示する著作権テキスト |
| `onSuccess` | `(txnHash: string) => void` | トランザクションが成功した際のコールバック |
| `onError` | `(error: Error) => void` | エラー発生時のコールバック |
Expand Down
1 change: 0 additions & 1 deletion ja/sdk/web/hooks/useERC1155SaleContractCheckout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export interface SelectPaymentSettings {
enableTransferFunds?: boolean
creditCardProviders?: string[]
copyrightText?: string
transakConfig?: TransakConfig
customProviderCallback?: (onSuccess: (txHash: string) => void, onError: (error: Error) => void, onClose: () => void) => void
supplementaryAnalyticsInfo?: SupplementaryAnalyticsInfo
}
Expand Down
5 changes: 0 additions & 5 deletions ja/sdk/web/hooks/useSelectPaymentModal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ function App() {
currencyAddress,
collectionAddress,
creditCardProviders: ['transak'],
transakConfig: {
contractId: 'your-contract-id',
apiKey: 'your-api-key'
},
copyrightText: 'ⓒ2024 Your Company',
onSuccess: (txnHash: string) => {
console.log('success!', txnHash)
Expand Down Expand Up @@ -122,7 +118,6 @@ type UseSelectPaymentModalReturnType = {
| `currencyAddress` | `string` | 通貨トークンコントラクトのアドレス |
| `collectionAddress` | `string` | NFTコレクションコントラクトのアドレス |
| `creditCardProviders` | `string[]` | 対応するクレジットカードプロバイダーのリスト(例: 'transak') |
| `transakConfig` | `object` | Transak連携用の設定 |
| `copyrightText` | `string` | モーダル内に表示する著作権テキスト |
| `onSuccess` | `(txnHash: string) => void` | トランザクションが成功した際のコールバック |
| `onError` | `(error: Error) => void` | エラー発生時のコールバック |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export interface SelectPaymentSettings {
enableTransferFunds?: boolean
creditCardProviders?: string[]
copyrightText?: string
transakConfig?: TransakConfig
customProviderCallback?: (onSuccess: (txHash: string) => void, onError: (error: Error) => void, onClose: () => void) => void
supplementaryAnalyticsInfo?: SupplementaryAnalyticsInfo
}
Expand Down
5 changes: 0 additions & 5 deletions sdk/web/checkout-sdk/hooks/useSelectPaymentModal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ function BuyNFT() {
currencyAddress,
collectionAddress,
creditCardProviders: ['transak'],
transakConfig: {
contractId: 'your-contract-id',
apiKey: 'your-api-key'
},
onSuccess: (txnHash: string) => {
console.log('success!', txnHash)
},
Expand Down Expand Up @@ -175,7 +171,6 @@ The `settings` object can include the following properties:
| `currencyAddress` | `string` | Address of the currency token contract |
| `collectionAddress` | `string` | Address of the NFT collection contract |
| `creditCardProviders` | `string[]` | List of supported credit card providers (e.g., 'transak') |
| `transakConfig` | `object` | Configuration for Transak integration |
| `copyrightText` | `string` | Copyright text to display in the modal |
| `onSuccess` | `(txnHash: string) => void` | Callback when transaction succeeds |
| `onError` | `(error: Error) => void` | Callback when an error occurs |
Expand Down