@0xsequence/checkout 5.0.2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/data.d.ts +10 -0
- package/dist/cjs/api/data.d.ts.map +1 -1
- package/dist/cjs/api/data.js +19 -1
- package/dist/cjs/api/data.js.map +1 -1
- package/dist/cjs/components/SequenceCheckoutProvider/SequenceCheckoutProvider.d.ts.map +1 -1
- package/dist/cjs/components/SequenceCheckoutProvider/SequenceCheckoutProvider.js +2 -1
- package/dist/cjs/components/SequenceCheckoutProvider/SequenceCheckoutProvider.js.map +1 -1
- package/dist/cjs/contexts/AddFundsModal.d.ts +3 -0
- package/dist/cjs/contexts/AddFundsModal.d.ts.map +1 -1
- package/dist/cjs/contexts/AddFundsModal.js.map +1 -1
- package/dist/cjs/contexts/Environment.d.ts +2 -1
- package/dist/cjs/contexts/Environment.d.ts.map +1 -1
- package/dist/cjs/contexts/Environment.js.map +1 -1
- package/dist/cjs/contexts/SelectPaymentModal.d.ts +2 -0
- package/dist/cjs/contexts/SelectPaymentModal.d.ts.map +1 -1
- package/dist/cjs/contexts/SelectPaymentModal.js.map +1 -1
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useAddFundsModal.d.ts +51 -3
- package/dist/cjs/hooks/useAddFundsModal.d.ts.map +1 -1
- package/dist/cjs/hooks/useAddFundsModal.js +38 -0
- package/dist/cjs/hooks/useAddFundsModal.js.map +1 -1
- package/dist/cjs/hooks/useCheckoutModal.d.ts +80 -3
- package/dist/cjs/hooks/useCheckoutModal.d.ts.map +1 -1
- package/dist/cjs/hooks/useCheckoutModal.js +67 -0
- package/dist/cjs/hooks/useCheckoutModal.js.map +1 -1
- package/dist/cjs/hooks/useERC1155SaleContractCheckout.d.ts +73 -3
- package/dist/cjs/hooks/useERC1155SaleContractCheckout.d.ts.map +1 -1
- package/dist/cjs/hooks/useERC1155SaleContractCheckout.js +62 -0
- package/dist/cjs/hooks/useERC1155SaleContractCheckout.js.map +1 -1
- package/dist/cjs/hooks/useSardineOnRampLink.d.ts +3 -0
- package/dist/cjs/hooks/useSardineOnRampLink.d.ts.map +1 -0
- package/dist/cjs/hooks/useSardineOnRampLink.js +20 -0
- package/dist/cjs/hooks/useSardineOnRampLink.js.map +1 -0
- package/dist/cjs/hooks/useSelectPaymentModal.d.ts +106 -3
- package/dist/cjs/hooks/useSelectPaymentModal.d.ts.map +1 -1
- package/dist/cjs/hooks/useSelectPaymentModal.js +93 -0
- package/dist/cjs/hooks/useSelectPaymentModal.js.map +1 -1
- package/dist/cjs/hooks/useSwapModal.d.ts +72 -3
- package/dist/cjs/hooks/useSwapModal.d.ts.map +1 -1
- package/dist/cjs/hooks/useSwapModal.js +59 -0
- package/dist/cjs/hooks/useSwapModal.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/views/AddFunds.d.ts +2 -0
- package/dist/cjs/views/AddFunds.d.ts.map +1 -1
- package/dist/cjs/views/AddFunds.js +74 -5
- package/dist/cjs/views/AddFunds.js.map +1 -1
- package/dist/cjs/views/PaymentSelection/FundWithFiat.d.ts +10 -0
- package/dist/cjs/views/PaymentSelection/FundWithFiat.d.ts.map +1 -0
- package/dist/cjs/views/PaymentSelection/FundWithFiat.js +27 -0
- package/dist/cjs/views/PaymentSelection/FundWithFiat.js.map +1 -0
- package/dist/cjs/views/PaymentSelection/PayWithCrypto/index.d.ts.map +1 -1
- package/dist/cjs/views/PaymentSelection/PayWithCrypto/index.js +4 -1
- package/dist/cjs/views/PaymentSelection/PayWithCrypto/index.js.map +1 -1
- package/dist/cjs/views/PaymentSelection/index.d.ts.map +1 -1
- package/dist/cjs/views/PaymentSelection/index.js +4 -2
- package/dist/cjs/views/PaymentSelection/index.js.map +1 -1
- package/dist/cjs/views/PendingCreditCardTransaction.js +3 -3
- package/dist/cjs/views/PendingCreditCardTransaction.js.map +1 -1
- package/dist/esm/api/data.d.ts +10 -0
- package/dist/esm/api/data.d.ts.map +1 -1
- package/dist/esm/api/data.js +17 -0
- package/dist/esm/api/data.js.map +1 -1
- package/dist/esm/components/SequenceCheckoutProvider/SequenceCheckoutProvider.d.ts.map +1 -1
- package/dist/esm/components/SequenceCheckoutProvider/SequenceCheckoutProvider.js +2 -1
- package/dist/esm/components/SequenceCheckoutProvider/SequenceCheckoutProvider.js.map +1 -1
- package/dist/esm/contexts/AddFundsModal.d.ts +3 -0
- package/dist/esm/contexts/AddFundsModal.d.ts.map +1 -1
- package/dist/esm/contexts/AddFundsModal.js.map +1 -1
- package/dist/esm/contexts/Environment.d.ts +2 -1
- package/dist/esm/contexts/Environment.d.ts.map +1 -1
- package/dist/esm/contexts/Environment.js.map +1 -1
- package/dist/esm/contexts/SelectPaymentModal.d.ts +2 -0
- package/dist/esm/contexts/SelectPaymentModal.d.ts.map +1 -1
- package/dist/esm/contexts/SelectPaymentModal.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useAddFundsModal.d.ts +51 -3
- package/dist/esm/hooks/useAddFundsModal.d.ts.map +1 -1
- package/dist/esm/hooks/useAddFundsModal.js +38 -0
- package/dist/esm/hooks/useAddFundsModal.js.map +1 -1
- package/dist/esm/hooks/useCheckoutModal.d.ts +80 -3
- package/dist/esm/hooks/useCheckoutModal.d.ts.map +1 -1
- package/dist/esm/hooks/useCheckoutModal.js +67 -0
- package/dist/esm/hooks/useCheckoutModal.js.map +1 -1
- package/dist/esm/hooks/useERC1155SaleContractCheckout.d.ts +73 -3
- package/dist/esm/hooks/useERC1155SaleContractCheckout.d.ts.map +1 -1
- package/dist/esm/hooks/useERC1155SaleContractCheckout.js +62 -0
- package/dist/esm/hooks/useERC1155SaleContractCheckout.js.map +1 -1
- package/dist/esm/hooks/useSardineOnRampLink.d.ts +3 -0
- package/dist/esm/hooks/useSardineOnRampLink.d.ts.map +1 -0
- package/dist/esm/hooks/useSardineOnRampLink.js +16 -0
- package/dist/esm/hooks/useSardineOnRampLink.js.map +1 -0
- package/dist/esm/hooks/useSelectPaymentModal.d.ts +106 -3
- package/dist/esm/hooks/useSelectPaymentModal.d.ts.map +1 -1
- package/dist/esm/hooks/useSelectPaymentModal.js +93 -0
- package/dist/esm/hooks/useSelectPaymentModal.js.map +1 -1
- package/dist/esm/hooks/useSwapModal.d.ts +72 -3
- package/dist/esm/hooks/useSwapModal.d.ts.map +1 -1
- package/dist/esm/hooks/useSwapModal.js +59 -0
- package/dist/esm/hooks/useSwapModal.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/views/AddFunds.d.ts +2 -0
- package/dist/esm/views/AddFunds.d.ts.map +1 -1
- package/dist/esm/views/AddFunds.js +69 -2
- package/dist/esm/views/AddFunds.js.map +1 -1
- package/dist/esm/views/PaymentSelection/FundWithFiat.d.ts +10 -0
- package/dist/esm/views/PaymentSelection/FundWithFiat.d.ts.map +1 -0
- package/dist/esm/views/PaymentSelection/FundWithFiat.js +23 -0
- package/dist/esm/views/PaymentSelection/FundWithFiat.js.map +1 -0
- package/dist/esm/views/PaymentSelection/PayWithCrypto/index.d.ts.map +1 -1
- package/dist/esm/views/PaymentSelection/PayWithCrypto/index.js +4 -1
- package/dist/esm/views/PaymentSelection/PayWithCrypto/index.js.map +1 -1
- package/dist/esm/views/PaymentSelection/index.d.ts.map +1 -1
- package/dist/esm/views/PaymentSelection/index.js +5 -3
- package/dist/esm/views/PaymentSelection/index.js.map +1 -1
- package/dist/esm/views/PendingCreditCardTransaction.js +3 -3
- package/dist/esm/views/PendingCreditCardTransaction.js.map +1 -1
- package/package.json +5 -5
|
@@ -35,6 +35,67 @@ const getERC1155SaleContractConfig = ({ chain, price, currencyAddress = viem_1.z
|
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
exports.getERC1155SaleContractConfig = getERC1155SaleContractConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Hook for enabling ERC-1155 NFT purchases using a standard sale contract.
|
|
40
|
+
*
|
|
41
|
+
* This hook simplifies the process of purchasing ERC-1155 tokens by automatically:
|
|
42
|
+
* - Fetching price information from the sale contract
|
|
43
|
+
* - Determining payment options (crypto, credit card, etc.)
|
|
44
|
+
* - Generating the proper transaction data
|
|
45
|
+
* - Opening and managing the checkout modal
|
|
46
|
+
*
|
|
47
|
+
* @see {@link https://docs.sequence.xyz/sdk/web/hooks/useERC1155SaleContractCheckout} for more detailed documentation.
|
|
48
|
+
*
|
|
49
|
+
* @param {object} params - Configuration options for the ERC-1155 sale contract checkout
|
|
50
|
+
* @param {number} params.chain - Chain ID where the sale contract is deployed
|
|
51
|
+
* @param {string} params.contractAddress - Address of the ERC-1155 sale contract
|
|
52
|
+
* @param {string} params.wallet - Address of the wallet that will receive the NFTs
|
|
53
|
+
* @param {string} params.collectionAddress - Address of the ERC-1155 token contract
|
|
54
|
+
* @param {Array<{tokenId: string, quantity: string}>} params.items - Array of token IDs and quantities to purchase
|
|
55
|
+
* @param {function} [params.onSuccess] - Callback function when the transaction is successful
|
|
56
|
+
* @param {function} [params.onError] - Callback function when an error occurs
|
|
57
|
+
* @param {function} [params.onClose] - Callback function when the modal is closed
|
|
58
|
+
*
|
|
59
|
+
* @returns Object containing functions to control the checkout modal and state {@link UseERC1155SaleContractCheckoutReturnType}
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* import { useERC1155SaleContractCheckout } from "@0xsequence/checkout";
|
|
64
|
+
* import { useAccount } from "wagmi";
|
|
65
|
+
*
|
|
66
|
+
* const MyComponent = () => {
|
|
67
|
+
* const { address: userAddress } = useAccount();
|
|
68
|
+
* const { openCheckoutModal } = useERC1155SaleContractCheckout({
|
|
69
|
+
* chain: 80001, // chainId of the chain the collectible is on
|
|
70
|
+
* contractAddress: "0x0327b2f274e04d292e74a06809bcd687c63a4ba4", // address of the contract handling the minting function
|
|
71
|
+
* wallet: userAddress!, // address of the recipient
|
|
72
|
+
* collectionAddress: "0x888a322db4b8033bac3ff84412738c096f87f9d0", // address of the collection contract
|
|
73
|
+
* items: [
|
|
74
|
+
* // array of collectibles to purchase
|
|
75
|
+
* {
|
|
76
|
+
* tokenId: "0",
|
|
77
|
+
* quantity: "1",
|
|
78
|
+
* },
|
|
79
|
+
* ],
|
|
80
|
+
* onSuccess: (txnHash: string) => {
|
|
81
|
+
* console.log("success!", txnHash);
|
|
82
|
+
* },
|
|
83
|
+
* onError: (error: Error) => {
|
|
84
|
+
* console.error(error);
|
|
85
|
+
* },
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* const onClick = () => {
|
|
89
|
+
* if (!userAddress) {
|
|
90
|
+
* return;
|
|
91
|
+
* }
|
|
92
|
+
* openCheckoutModal();
|
|
93
|
+
* };
|
|
94
|
+
*
|
|
95
|
+
* return <button onClick={onClick}>Buy ERC-1155 collectible!</button>;
|
|
96
|
+
* };
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
38
99
|
const useERC1155SaleContractCheckout = ({ chain, contractAddress, wallet, collectionAddress, items, ...restArgs }) => {
|
|
39
100
|
const { openSelectPaymentModal, closeSelectPaymentModal, selectPaymentSettings } = (0, useSelectPaymentModal_1.useSelectPaymentModal)();
|
|
40
101
|
const { data: checkoutOptions, isLoading: isLoadingCheckoutOptions, isError: isErrorCheckoutOptions } = (0, useCheckoutOptionsSalesContract_1.useCheckoutOptionsSalesContract)(chain, {
|
|
@@ -72,6 +133,7 @@ const useERC1155SaleContractCheckout = ({ chain, contractAddress, wallet, collec
|
|
|
72
133
|
enableMainCurrencyPayment: true,
|
|
73
134
|
enableSwapPayments: checkoutOptions?.options?.swap?.includes(marketplace_1.TransactionSwapProvider.zerox) || false,
|
|
74
135
|
creditCardProviders: checkoutOptions?.options.nftCheckout || [],
|
|
136
|
+
onRampProvider: checkoutOptions?.options.onRamp?.[0],
|
|
75
137
|
...restArgs
|
|
76
138
|
}));
|
|
77
139
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useERC1155SaleContractCheckout.js","sourceRoot":"","sources":["../../../src/hooks/useERC1155SaleContractCheckout.ts"],"names":[],"mappings":";;;AAAA,yDAAmG;AACnG,iDAA0D;AAC1D,+BAAuE;AACvE,iCAAyD;AAEzD,0CAAyD;AAGzD,uFAAmF;AACnF,mEAA+D;
|
|
1
|
+
{"version":3,"file":"useERC1155SaleContractCheckout.js","sourceRoot":"","sources":["../../../src/hooks/useERC1155SaleContractCheckout.ts"],"names":[],"mappings":";;;AAAA,yDAAmG;AACnG,iDAA0D;AAC1D,+BAAuE;AACvE,iCAAyD;AAEzD,0CAAyD;AAGzD,uFAAmF;AACnF,mEAA+D;AAwBxD,MAAM,4BAA4B,GAAG,CAAC,EAC3C,KAAK,EACL,KAAK,EACL,eAAe,GAAG,kBAAW,EAC7B,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,GAAG,SAAS,EAC0B,EAAyB,EAAE;IACjE,MAAM,uBAAuB,GAAG,IAAA,yBAAkB,EAAC;QACjD,GAAG,EAAE,4BAAsB;QAC3B,YAAY,EAAE,MAAM;QACpB,uEAAuE;QACvE,IAAI,EAAE;YACJ,gBAAgB;YAChB,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACxC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YACzC,IAAA,YAA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AC,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;aACnE,CAAA;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,SAAS,CAAA;IAClB,CAAC,CAAA;IAED,OAAO;QACL,IAAI,EAAE;YACJ,eAAe,EAAE,mBAA6B;YAC9C,WAAW,EAAE,cAAc,EAAE;SAC9B;QACD,SAAS,EAAE,gBAAgB;QAC3B,OAAO,EAAE,cAAc;KACxB,CAAA;AACH,CAAC,CAAA;AApGY,QAAA,qBAAqB,yBAoGjC;AAED;;GAEG;AACU,QAAA,kCAAkC,GAAG,sCAA8B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSardineOnRampLink.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSardineOnRampLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAA0B,MAAM,aAAa,CAAA;AAE3E,eAAO,MAAM,oBAAoB,GAAI,MAAM,qBAAqB,EAAE,WAAW,OAAO,kEAanF,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSardineOnRampLink = void 0;
|
|
4
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
+
const data_1 = require("../api/data");
|
|
6
|
+
const useSardineOnRampLink = (args, disabled) => {
|
|
7
|
+
return (0, react_query_1.useQuery)({
|
|
8
|
+
queryKey: ['useSardineOnRampLink', args],
|
|
9
|
+
queryFn: async () => {
|
|
10
|
+
const res = await (0, data_1.fetchSardineOnRampLink)(args);
|
|
11
|
+
return res;
|
|
12
|
+
},
|
|
13
|
+
retry: false,
|
|
14
|
+
staleTime: 0,
|
|
15
|
+
enabled: !disabled,
|
|
16
|
+
refetchOnWindowFocus: false
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.useSardineOnRampLink = useSardineOnRampLink;
|
|
20
|
+
//# sourceMappingURL=useSardineOnRampLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSardineOnRampLink.js","sourceRoot":"","sources":["../../../src/hooks/useSardineOnRampLink.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD,sCAA2E;AAEpE,MAAM,oBAAoB,GAAG,CAAC,IAA2B,EAAE,QAAkB,EAAE,EAAE;IACtF,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,sBAAsB,EAAE,IAAI,CAAC;QACxC,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,GAAG,GAAG,MAAM,IAAA,6BAAsB,EAAC,IAAI,CAAC,CAAA;YAE9C,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC,QAAQ;QAClB,oBAAoB,EAAE,KAAK;KAC5B,CAAC,CAAA;AACJ,CAAC,CAAA;AAbY,QAAA,oBAAoB,wBAahC"}
|
|
@@ -1,6 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { SelectPaymentSettings } from '../contexts/SelectPaymentModal';
|
|
2
|
+
/**
|
|
3
|
+
* Return type for the useSelectPaymentModal hook.
|
|
4
|
+
*
|
|
5
|
+
* @property {function(settings: SelectPaymentSettings): void} openSelectPaymentModal - Function to open the Payment Selection modal
|
|
6
|
+
* @property {function(): void} closeSelectPaymentModal - Function to close the Payment Selection modal
|
|
7
|
+
* @property {SelectPaymentSettings|undefined} selectPaymentSettings - Current settings for the Payment Selection modal
|
|
8
|
+
*/
|
|
9
|
+
type UseSelectPaymentModalReturnType = {
|
|
10
|
+
openSelectPaymentModal: (settings: SelectPaymentSettings) => void;
|
|
3
11
|
closeSelectPaymentModal: () => void;
|
|
4
|
-
selectPaymentSettings:
|
|
12
|
+
selectPaymentSettings: SelectPaymentSettings | undefined;
|
|
5
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Hook to manage the Payment Selection modal that allows users to purchase digital assets with multiple payment options.
|
|
16
|
+
*
|
|
17
|
+
* This hook provides methods to open and close the payment selection modal, and access its current settings.
|
|
18
|
+
* The Payment Selection modal offers various payment methods including:
|
|
19
|
+
* - Pay with cryptocurrency from the user's wallet
|
|
20
|
+
* - Swap tokens to pay with a different cryptocurrency
|
|
21
|
+
* - Pay with credit/debit card
|
|
22
|
+
* - Receive funds from another wallet
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://docs.sequence.xyz/sdk/web/hooks/useSelectPaymentModal} for more detailed documentation.
|
|
25
|
+
*
|
|
26
|
+
* @returns An object containing functions to control the Payment Selection modal and its state {@link UseSelectPaymentModalReturnType}
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { useSelectPaymentModal } from '@0xsequence/checkout'
|
|
31
|
+
* import { encodeFunctionData, toHex } from 'viem'
|
|
32
|
+
* import { useAccount } from 'wagmi'
|
|
33
|
+
*
|
|
34
|
+
* const YourComponent = () => {
|
|
35
|
+
* const { address } = useAccount()
|
|
36
|
+
* const { openSelectPaymentModal } = useSelectPaymentModal()
|
|
37
|
+
*
|
|
38
|
+
* const handleCheckout = () => {
|
|
39
|
+
* if (!address) return
|
|
40
|
+
*
|
|
41
|
+
* // ERC-20 payment settings
|
|
42
|
+
* const currencyAddress = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' // USDC on Polygon
|
|
43
|
+
* const salesContractAddress = '0xe65b75eb7c58ffc0bf0e671d64d0e1c6cd0d3e5b'
|
|
44
|
+
* const collectionAddress = '0xdeb398f41ccd290ee5114df7e498cf04fac916cb'
|
|
45
|
+
* const price = '20000' // Price in smallest unit (0.02 USDC)
|
|
46
|
+
* const chainId = 137 // Polygon
|
|
47
|
+
*
|
|
48
|
+
* // NFT details
|
|
49
|
+
* const collectibles = [
|
|
50
|
+
* {
|
|
51
|
+
* tokenId: '1',
|
|
52
|
+
* quantity: '1'
|
|
53
|
+
* }
|
|
54
|
+
* ]
|
|
55
|
+
*
|
|
56
|
+
* // Transaction data for the ERC-1155 mint function
|
|
57
|
+
* const purchaseTransactionData = encodeFunctionData({
|
|
58
|
+
* abi: ERC_1155_SALE_CONTRACT, // Your contract ABI
|
|
59
|
+
* functionName: 'mint',
|
|
60
|
+
* args: [
|
|
61
|
+
* address,
|
|
62
|
+
* collectibles.map(c => BigInt(c.tokenId)),
|
|
63
|
+
* collectibles.map(c => BigInt(c.quantity)),
|
|
64
|
+
* toHex(0),
|
|
65
|
+
* currencyAddress,
|
|
66
|
+
* price,
|
|
67
|
+
* [toHex(0, { size: 32 })]
|
|
68
|
+
* ]
|
|
69
|
+
* })
|
|
70
|
+
*
|
|
71
|
+
* // Open the payment selection modal
|
|
72
|
+
* openSelectPaymentModal({
|
|
73
|
+
* collectibles,
|
|
74
|
+
* chain: chainId,
|
|
75
|
+
* price,
|
|
76
|
+
* targetContractAddress: salesContractAddress,
|
|
77
|
+
* recipientAddress: address,
|
|
78
|
+
* currencyAddress,
|
|
79
|
+
* collectionAddress,
|
|
80
|
+
* creditCardProviders: ['sardine', 'transak'],
|
|
81
|
+
* transakConfig: {
|
|
82
|
+
* contractId: 'your-contract-id',
|
|
83
|
+
* apiKey: 'your-api-key'
|
|
84
|
+
* },
|
|
85
|
+
* copyrightText: 'ⓒ2024 Your Company',
|
|
86
|
+
* onSuccess: (txnHash: string) => {
|
|
87
|
+
* console.log('success!', txnHash)
|
|
88
|
+
* },
|
|
89
|
+
* onError: (error: Error) => {
|
|
90
|
+
* console.error(error)
|
|
91
|
+
* },
|
|
92
|
+
* onClose: () => {
|
|
93
|
+
* console.log('modal closed!')
|
|
94
|
+
* },
|
|
95
|
+
* txData: purchaseTransactionData
|
|
96
|
+
* })
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* return (
|
|
100
|
+
* <button onClick={handleCheckout}>
|
|
101
|
+
* Buy NFT with multiple payment options
|
|
102
|
+
* </button>
|
|
103
|
+
* )
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare const useSelectPaymentModal: () => UseSelectPaymentModalReturnType;
|
|
108
|
+
export {};
|
|
6
109
|
//# sourceMappingURL=useSelectPaymentModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectPaymentModal.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSelectPaymentModal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSelectPaymentModal.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSelectPaymentModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA2B,MAAM,gCAAgC,CAAA;AAE/F;;;;;;GAMG;AACH,KAAK,+BAA+B,GAAG;IACrC,sBAAsB,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAA;IACjE,uBAAuB,EAAE,MAAM,IAAI,CAAA;IACnC,qBAAqB,EAAE,qBAAqB,GAAG,SAAS,CAAA;CACzD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACH,eAAO,MAAM,qBAAqB,QAAO,+BAIxC,CAAA"}
|
|
@@ -2,6 +2,99 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSelectPaymentModal = void 0;
|
|
4
4
|
const SelectPaymentModal_1 = require("../contexts/SelectPaymentModal");
|
|
5
|
+
/**
|
|
6
|
+
* Hook to manage the Payment Selection modal that allows users to purchase digital assets with multiple payment options.
|
|
7
|
+
*
|
|
8
|
+
* This hook provides methods to open and close the payment selection modal, and access its current settings.
|
|
9
|
+
* The Payment Selection modal offers various payment methods including:
|
|
10
|
+
* - Pay with cryptocurrency from the user's wallet
|
|
11
|
+
* - Swap tokens to pay with a different cryptocurrency
|
|
12
|
+
* - Pay with credit/debit card
|
|
13
|
+
* - Receive funds from another wallet
|
|
14
|
+
*
|
|
15
|
+
* @see {@link https://docs.sequence.xyz/sdk/web/hooks/useSelectPaymentModal} for more detailed documentation.
|
|
16
|
+
*
|
|
17
|
+
* @returns An object containing functions to control the Payment Selection modal and its state {@link UseSelectPaymentModalReturnType}
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { useSelectPaymentModal } from '@0xsequence/checkout'
|
|
22
|
+
* import { encodeFunctionData, toHex } from 'viem'
|
|
23
|
+
* import { useAccount } from 'wagmi'
|
|
24
|
+
*
|
|
25
|
+
* const YourComponent = () => {
|
|
26
|
+
* const { address } = useAccount()
|
|
27
|
+
* const { openSelectPaymentModal } = useSelectPaymentModal()
|
|
28
|
+
*
|
|
29
|
+
* const handleCheckout = () => {
|
|
30
|
+
* if (!address) return
|
|
31
|
+
*
|
|
32
|
+
* // ERC-20 payment settings
|
|
33
|
+
* const currencyAddress = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' // USDC on Polygon
|
|
34
|
+
* const salesContractAddress = '0xe65b75eb7c58ffc0bf0e671d64d0e1c6cd0d3e5b'
|
|
35
|
+
* const collectionAddress = '0xdeb398f41ccd290ee5114df7e498cf04fac916cb'
|
|
36
|
+
* const price = '20000' // Price in smallest unit (0.02 USDC)
|
|
37
|
+
* const chainId = 137 // Polygon
|
|
38
|
+
*
|
|
39
|
+
* // NFT details
|
|
40
|
+
* const collectibles = [
|
|
41
|
+
* {
|
|
42
|
+
* tokenId: '1',
|
|
43
|
+
* quantity: '1'
|
|
44
|
+
* }
|
|
45
|
+
* ]
|
|
46
|
+
*
|
|
47
|
+
* // Transaction data for the ERC-1155 mint function
|
|
48
|
+
* const purchaseTransactionData = encodeFunctionData({
|
|
49
|
+
* abi: ERC_1155_SALE_CONTRACT, // Your contract ABI
|
|
50
|
+
* functionName: 'mint',
|
|
51
|
+
* args: [
|
|
52
|
+
* address,
|
|
53
|
+
* collectibles.map(c => BigInt(c.tokenId)),
|
|
54
|
+
* collectibles.map(c => BigInt(c.quantity)),
|
|
55
|
+
* toHex(0),
|
|
56
|
+
* currencyAddress,
|
|
57
|
+
* price,
|
|
58
|
+
* [toHex(0, { size: 32 })]
|
|
59
|
+
* ]
|
|
60
|
+
* })
|
|
61
|
+
*
|
|
62
|
+
* // Open the payment selection modal
|
|
63
|
+
* openSelectPaymentModal({
|
|
64
|
+
* collectibles,
|
|
65
|
+
* chain: chainId,
|
|
66
|
+
* price,
|
|
67
|
+
* targetContractAddress: salesContractAddress,
|
|
68
|
+
* recipientAddress: address,
|
|
69
|
+
* currencyAddress,
|
|
70
|
+
* collectionAddress,
|
|
71
|
+
* creditCardProviders: ['sardine', 'transak'],
|
|
72
|
+
* transakConfig: {
|
|
73
|
+
* contractId: 'your-contract-id',
|
|
74
|
+
* apiKey: 'your-api-key'
|
|
75
|
+
* },
|
|
76
|
+
* copyrightText: 'ⓒ2024 Your Company',
|
|
77
|
+
* onSuccess: (txnHash: string) => {
|
|
78
|
+
* console.log('success!', txnHash)
|
|
79
|
+
* },
|
|
80
|
+
* onError: (error: Error) => {
|
|
81
|
+
* console.error(error)
|
|
82
|
+
* },
|
|
83
|
+
* onClose: () => {
|
|
84
|
+
* console.log('modal closed!')
|
|
85
|
+
* },
|
|
86
|
+
* txData: purchaseTransactionData
|
|
87
|
+
* })
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* return (
|
|
91
|
+
* <button onClick={handleCheckout}>
|
|
92
|
+
* Buy NFT with multiple payment options
|
|
93
|
+
* </button>
|
|
94
|
+
* )
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
5
98
|
const useSelectPaymentModal = () => {
|
|
6
99
|
const { openSelectPaymentModal, closeSelectPaymentModal, selectPaymentSettings } = (0, SelectPaymentModal_1.useSelectPaymentContext)();
|
|
7
100
|
return { openSelectPaymentModal, closeSelectPaymentModal, selectPaymentSettings };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectPaymentModal.js","sourceRoot":"","sources":["../../../src/hooks/useSelectPaymentModal.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"useSelectPaymentModal.js","sourceRoot":"","sources":["../../../src/hooks/useSelectPaymentModal.ts"],"names":[],"mappings":";;;AAAA,uEAA+F;AAe/F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACI,MAAM,qBAAqB,GAAG,GAAoC,EAAE;IACzE,MAAM,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,GAAG,IAAA,4CAAuB,GAAE,CAAA;IAE5G,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,CAAA;AACnF,CAAC,CAAA;AAJY,QAAA,qBAAqB,yBAIjC"}
|
|
@@ -1,6 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { SwapModalSettings } from '../contexts/SwapModal';
|
|
2
|
+
/**
|
|
3
|
+
* Return type for the useSwapModal hook.
|
|
4
|
+
*
|
|
5
|
+
* @property {function(settings: SwapModalSettings): void} openSwapModal - Function to open the Swap modal
|
|
6
|
+
* @property {function(): void} closeSwapModal - Function to close the Swap modal
|
|
7
|
+
* @property {SwapModalSettings|undefined} swapModalSettings - Current settings for the Swap modal
|
|
8
|
+
*/
|
|
9
|
+
type UseSwapModalReturnType = {
|
|
10
|
+
openSwapModal: (settings: SwapModalSettings) => void;
|
|
3
11
|
closeSwapModal: () => void;
|
|
4
|
-
swapModalSettings:
|
|
12
|
+
swapModalSettings: SwapModalSettings | undefined;
|
|
5
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Hook to manage the Swap modal that allows users to swap tokens in their wallet to a target currency.
|
|
16
|
+
*
|
|
17
|
+
* This hook provides methods to open and close the swap modal, and access its current settings.
|
|
18
|
+
* The Swap modal allows users to select tokens from their wallet to swap to a specified target token,
|
|
19
|
+
* with the option to execute additional transactions after the swap completes.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link https://docs.sequence.xyz/sdk/web/hooks/useSwapModal} for more detailed documentation.
|
|
22
|
+
*
|
|
23
|
+
* @returns An object containing functions to control the Swap modal and its state {@link UseSwapModalReturnType}
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import { useSwapModal } from '@0xsequence/checkout'
|
|
28
|
+
* import { encodeFunctionData, parseAbi } from 'viem'
|
|
29
|
+
*
|
|
30
|
+
* const YourComponent = () => {
|
|
31
|
+
* const { openSwapModal } = useSwapModal()
|
|
32
|
+
*
|
|
33
|
+
* const handleSwap = () => {
|
|
34
|
+
* // Target token information
|
|
35
|
+
* const chainId = 137 // Polygon
|
|
36
|
+
* const currencyAddress = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' // USDC on Polygon
|
|
37
|
+
* const currencyAmount = '20000' // 0.02 USDC (in smallest units)
|
|
38
|
+
*
|
|
39
|
+
* // Optional: Transaction to execute after swap is completed
|
|
40
|
+
* const data = encodeFunctionData({
|
|
41
|
+
* abi: parseAbi(['function demo()']),
|
|
42
|
+
* functionName: 'demo',
|
|
43
|
+
* args: []
|
|
44
|
+
* })
|
|
45
|
+
*
|
|
46
|
+
* // Open the swap modal
|
|
47
|
+
* openSwapModal({
|
|
48
|
+
* onSuccess: () => {
|
|
49
|
+
* console.log('swap successful!')
|
|
50
|
+
* },
|
|
51
|
+
* chainId,
|
|
52
|
+
* currencyAddress,
|
|
53
|
+
* currencyAmount,
|
|
54
|
+
* postSwapTransactions: [
|
|
55
|
+
* {
|
|
56
|
+
* to: '0x37470dac8a0255141745906c972e414b1409b470',
|
|
57
|
+
* data
|
|
58
|
+
* }
|
|
59
|
+
* ],
|
|
60
|
+
* title: 'Swap and Pay',
|
|
61
|
+
* description: 'Select a token in your wallet to swap to 0.2 USDC.'
|
|
62
|
+
* })
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* return (
|
|
66
|
+
* <button onClick={handleSwap}>
|
|
67
|
+
* Swap with Sequence Pay
|
|
68
|
+
* </button>
|
|
69
|
+
* )
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare const useSwapModal: () => UseSwapModalReturnType;
|
|
74
|
+
export {};
|
|
6
75
|
//# sourceMappingURL=useSwapModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSwapModal.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSwapModal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSwapModal.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSwapModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,uBAAuB,CAAA;AAE9E;;;;;;GAMG;AACH,KAAK,sBAAsB,GAAG;IAC5B,aAAa,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACpD,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,iBAAiB,EAAE,iBAAiB,GAAG,SAAS,CAAA;CACjD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,eAAO,MAAM,YAAY,QAAO,sBAI/B,CAAA"}
|
|
@@ -2,6 +2,65 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSwapModal = void 0;
|
|
4
4
|
const SwapModal_1 = require("../contexts/SwapModal");
|
|
5
|
+
/**
|
|
6
|
+
* Hook to manage the Swap modal that allows users to swap tokens in their wallet to a target currency.
|
|
7
|
+
*
|
|
8
|
+
* This hook provides methods to open and close the swap modal, and access its current settings.
|
|
9
|
+
* The Swap modal allows users to select tokens from their wallet to swap to a specified target token,
|
|
10
|
+
* with the option to execute additional transactions after the swap completes.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://docs.sequence.xyz/sdk/web/hooks/useSwapModal} for more detailed documentation.
|
|
13
|
+
*
|
|
14
|
+
* @returns An object containing functions to control the Swap modal and its state {@link UseSwapModalReturnType}
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useSwapModal } from '@0xsequence/checkout'
|
|
19
|
+
* import { encodeFunctionData, parseAbi } from 'viem'
|
|
20
|
+
*
|
|
21
|
+
* const YourComponent = () => {
|
|
22
|
+
* const { openSwapModal } = useSwapModal()
|
|
23
|
+
*
|
|
24
|
+
* const handleSwap = () => {
|
|
25
|
+
* // Target token information
|
|
26
|
+
* const chainId = 137 // Polygon
|
|
27
|
+
* const currencyAddress = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' // USDC on Polygon
|
|
28
|
+
* const currencyAmount = '20000' // 0.02 USDC (in smallest units)
|
|
29
|
+
*
|
|
30
|
+
* // Optional: Transaction to execute after swap is completed
|
|
31
|
+
* const data = encodeFunctionData({
|
|
32
|
+
* abi: parseAbi(['function demo()']),
|
|
33
|
+
* functionName: 'demo',
|
|
34
|
+
* args: []
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* // Open the swap modal
|
|
38
|
+
* openSwapModal({
|
|
39
|
+
* onSuccess: () => {
|
|
40
|
+
* console.log('swap successful!')
|
|
41
|
+
* },
|
|
42
|
+
* chainId,
|
|
43
|
+
* currencyAddress,
|
|
44
|
+
* currencyAmount,
|
|
45
|
+
* postSwapTransactions: [
|
|
46
|
+
* {
|
|
47
|
+
* to: '0x37470dac8a0255141745906c972e414b1409b470',
|
|
48
|
+
* data
|
|
49
|
+
* }
|
|
50
|
+
* ],
|
|
51
|
+
* title: 'Swap and Pay',
|
|
52
|
+
* description: 'Select a token in your wallet to swap to 0.2 USDC.'
|
|
53
|
+
* })
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* return (
|
|
57
|
+
* <button onClick={handleSwap}>
|
|
58
|
+
* Swap with Sequence Pay
|
|
59
|
+
* </button>
|
|
60
|
+
* )
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
5
64
|
const useSwapModal = () => {
|
|
6
65
|
const { openSwapModal, closeSwapModal, swapModalSettings } = (0, SwapModal_1.useSwapModalContext)();
|
|
7
66
|
return { openSwapModal, closeSwapModal, swapModalSettings };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSwapModal.js","sourceRoot":"","sources":["../../../src/hooks/useSwapModal.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"useSwapModal.js","sourceRoot":"","sources":["../../../src/hooks/useSwapModal.ts"],"names":[],"mappings":";;;AAAA,qDAA8E;AAe9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACI,MAAM,YAAY,GAAG,GAA2B,EAAE;IACvD,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,IAAA,+BAAmB,GAAE,CAAA;IAElF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAA;AAC7D,CAAC,CAAA;AAJY,QAAA,YAAY,gBAIxB"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export { type AddFundsSettings } from './contexts/AddFundsModal';
|
|
|
11
11
|
export { type SelectPaymentSettings } from './contexts/SelectPaymentModal';
|
|
12
12
|
export { type SwapModalSettings } from './contexts/SwapModal';
|
|
13
13
|
export { fetchTransakSupportedCountries, getTransakLink } from './utils/transak';
|
|
14
|
+
export { TransactionOnRampProvider } from '@0xsequence/marketplace';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAG7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,8BAA8B,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAA;AAE3H,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAG7D,OAAO,EAAE,8BAA8B,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAG7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,8BAA8B,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAA;AAE3H,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAG7D,OAAO,EAAE,8BAA8B,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGhF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTransakLink = exports.fetchTransakSupportedCountries = exports.useERC1155SaleContractPaymentModal = exports.useERC1155SaleContractCheckout = exports.useSwapModal = exports.useCheckoutWhitelistStatus = exports.useTransferFundsModal = exports.useSelectPaymentModal = exports.useAddFundsModal = exports.useCheckoutModal = exports.SequenceCheckoutProvider = void 0;
|
|
3
|
+
exports.TransactionOnRampProvider = exports.getTransakLink = exports.fetchTransakSupportedCountries = exports.useERC1155SaleContractPaymentModal = exports.useERC1155SaleContractCheckout = exports.useSwapModal = exports.useCheckoutWhitelistStatus = exports.useTransferFundsModal = exports.useSelectPaymentModal = exports.useAddFundsModal = exports.useCheckoutModal = exports.SequenceCheckoutProvider = void 0;
|
|
4
4
|
// Provider
|
|
5
5
|
var SequenceCheckoutProvider_1 = require("./components/SequenceCheckoutProvider");
|
|
6
6
|
Object.defineProperty(exports, "SequenceCheckoutProvider", { enumerable: true, get: function () { return SequenceCheckoutProvider_1.SequenceCheckoutProvider; } });
|
|
@@ -24,4 +24,7 @@ Object.defineProperty(exports, "useERC1155SaleContractPaymentModal", { enumerabl
|
|
|
24
24
|
var transak_1 = require("./utils/transak");
|
|
25
25
|
Object.defineProperty(exports, "fetchTransakSupportedCountries", { enumerable: true, get: function () { return transak_1.fetchTransakSupportedCountries; } });
|
|
26
26
|
Object.defineProperty(exports, "getTransakLink", { enumerable: true, get: function () { return transak_1.getTransakLink; } });
|
|
27
|
+
// OnRampProvider
|
|
28
|
+
var marketplace_1 = require("@0xsequence/marketplace");
|
|
29
|
+
Object.defineProperty(exports, "TransactionOnRampProvider", { enumerable: true, get: function () { return marketplace_1.TransactionOnRampProvider; } });
|
|
27
30
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,WAAW;AACX,kFAA6G;AAApG,oIAAA,wBAAwB,OAAA;AAEjC,QAAQ;AACR,6DAA2D;AAAlD,oHAAA,gBAAgB,OAAA;AACzB,6DAA2D;AAAlD,oHAAA,gBAAgB,OAAA;AACzB,uEAAqE;AAA5D,8HAAA,qBAAqB,OAAA;AAC9B,uEAAqE;AAA5D,8HAAA,qBAAqB,OAAA;AAC9B,iFAA+E;AAAtE,wIAAA,0BAA0B,OAAA;AACnC,qDAAmD;AAA1C,4GAAA,YAAY,OAAA;AACrB,yFAA2H;AAAlH,gJAAA,8BAA8B,OAAA;AAAE,oJAAA,kCAAkC,OAAA;AAO3E,QAAQ;AACR,2CAAgF;AAAvE,yHAAA,8BAA8B,OAAA;AAAE,yGAAA,cAAc,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,WAAW;AACX,kFAA6G;AAApG,oIAAA,wBAAwB,OAAA;AAEjC,QAAQ;AACR,6DAA2D;AAAlD,oHAAA,gBAAgB,OAAA;AACzB,6DAA2D;AAAlD,oHAAA,gBAAgB,OAAA;AACzB,uEAAqE;AAA5D,8HAAA,qBAAqB,OAAA;AAC9B,uEAAqE;AAA5D,8HAAA,qBAAqB,OAAA;AAC9B,iFAA+E;AAAtE,wIAAA,0BAA0B,OAAA;AACnC,qDAAmD;AAA1C,4GAAA,YAAY,OAAA;AACrB,yFAA2H;AAAlH,gJAAA,8BAA8B,OAAA;AAAE,oJAAA,kCAAkC,OAAA;AAO3E,QAAQ;AACR,2CAAgF;AAAvE,yHAAA,8BAA8B,OAAA;AAAE,yGAAA,cAAc,OAAA;AAEvD,iBAAiB;AACjB,uDAAmE;AAA1D,wHAAA,yBAAyB,OAAA"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare const AddFundsContent: () => import("react/jsx-runtime").JSX.Element | undefined;
|
|
2
|
+
export declare const AddFundsContentSardine: () => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const AddFundsContentTransak: () => import("react/jsx-runtime").JSX.Element | undefined;
|
|
2
4
|
//# sourceMappingURL=AddFunds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddFunds.d.ts","sourceRoot":"","sources":["../../../src/views/AddFunds.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AddFunds.d.ts","sourceRoot":"","sources":["../../../src/views/AddFunds.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,eAAe,2DAa3B,CAAA;AAED,eAAO,MAAM,sBAAsB,+CAiFlC,CAAA;AAED,eAAO,MAAM,sBAAsB,2DAkDlC,CAAA"}
|