@imtbl/checkout-sdk 2.0.0-alpha.0
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/LICENSE.md +176 -0
- package/README.md +58 -0
- package/dist/browser/index.js +6566 -0
- package/dist/node/index.cjs +6566 -0
- package/dist/node/index.js +6566 -0
- package/dist/types/api/blockscout/blockscout.d.ts +53 -0
- package/dist/types/api/blockscout/blockscout.test.d.ts +1 -0
- package/dist/types/api/blockscout/blockscoutType.d.ts +33 -0
- package/dist/types/api/blockscout/index.d.ts +2 -0
- package/dist/types/api/http/httpClient.d.ts +14 -0
- package/dist/types/api/http/httpClient.test.d.ts +1 -0
- package/dist/types/api/http/index.d.ts +1 -0
- package/dist/types/availability/availability.d.ts +6 -0
- package/dist/types/availability/availability.test.d.ts +1 -0
- package/dist/types/availability/index.d.ts +1 -0
- package/dist/types/balances/balances.d.ts +9 -0
- package/dist/types/balances/balances.test.d.ts +1 -0
- package/dist/types/balances/index.d.ts +1 -0
- package/dist/types/blockExplorer/blockExplorer.d.ts +9 -0
- package/dist/types/blockExplorer/blockExplorer.test.d.ts +1 -0
- package/dist/types/blockExplorer/index.d.ts +1 -0
- package/dist/types/config/config.d.ts +26 -0
- package/dist/types/config/config.test.d.ts +1 -0
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/config/remoteConfigFetcher.d.ts +19 -0
- package/dist/types/config/remoteConfigFetcher.test.d.ts +1 -0
- package/dist/types/config/tokensFetcher.d.ts +23 -0
- package/dist/types/config/tokensFetcher.test.d.ts +1 -0
- package/dist/types/connect/connect.d.ts +4 -0
- package/dist/types/connect/connect.test.d.ts +1 -0
- package/dist/types/connect/index.d.ts +1 -0
- package/dist/types/env/constants.d.ts +150 -0
- package/dist/types/env/env.d.ts +3 -0
- package/dist/types/env/env.test.d.ts +1 -0
- package/dist/types/env/index.d.ts +2 -0
- package/dist/types/errors/checkoutError.d.ts +80 -0
- package/dist/types/errors/checkoutError.test.d.ts +1 -0
- package/dist/types/errors/index.d.ts +1 -0
- package/dist/types/fiatRamp/fiatRamp.d.ts +23 -0
- package/dist/types/fiatRamp/fiatRamp.test.d.ts +1 -0
- package/dist/types/fiatRamp/index.d.ts +1 -0
- package/dist/types/gasEstimate/bridgeGasEstimate.d.ts +4 -0
- package/dist/types/gasEstimate/bridgeGasEstimate.test.d.ts +1 -0
- package/dist/types/gasEstimate/bridgeGasEstimateType.d.ts +5 -0
- package/dist/types/gasEstimate/gasEstimator.d.ts +4 -0
- package/dist/types/gasEstimate/gasEstimator.test.d.ts +1 -0
- package/dist/types/gasEstimate/gasPriceInWei.d.ts +2 -0
- package/dist/types/gasEstimate/gasPriceInWei.test.d.ts +1 -0
- package/dist/types/gasEstimate/index.d.ts +3 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/instance/contract.d.ts +2 -0
- package/dist/types/instance/index.d.ts +2 -0
- package/dist/types/instance/instance.d.ts +11 -0
- package/dist/types/instance/instance.test.d.ts +1 -0
- package/dist/types/logger/debugLogger.d.ts +3 -0
- package/dist/types/logger/debugLogger.test.d.ts +1 -0
- package/dist/types/network/index.d.ts +1 -0
- package/dist/types/network/network.d.ts +7 -0
- package/dist/types/network/network.test.d.ts +1 -0
- package/dist/types/provider/getUnderlyingProvider.d.ts +8 -0
- package/dist/types/provider/getUnderlyingProvider.test.d.ts +1 -0
- package/dist/types/provider/index.d.ts +4 -0
- package/dist/types/provider/injected/index.d.ts +3 -0
- package/dist/types/provider/injected/index.test.d.ts +1 -0
- package/dist/types/provider/injected/register.d.ts +20 -0
- package/dist/types/provider/injected/store.d.ts +42 -0
- package/dist/types/provider/injected/utils.d.ts +19 -0
- package/dist/types/provider/injected/window.d.ts +8 -0
- package/dist/types/provider/injectedProvidersManager.d.ts +19 -0
- package/dist/types/provider/provider.d.ts +3 -0
- package/dist/types/provider/provider.test.d.ts +1 -0
- package/dist/types/provider/providerDetail.d.ts +5 -0
- package/dist/types/provider/validateProvider.d.ts +5 -0
- package/dist/types/provider/validateProvider.test.d.ts +1 -0
- package/dist/types/readOnlyProviders/readOnlyProvider.d.ts +4 -0
- package/dist/types/readOnlyProviders/readOnlyProviders.test.d.ts +1 -0
- package/dist/types/riskAssessment/index.d.ts +1 -0
- package/dist/types/riskAssessment/riskAssessment.d.ts +14 -0
- package/dist/types/riskAssessment/riskAssessment.test.d.ts +1 -0
- package/dist/types/sdk.d.ts +216 -0
- package/dist/types/sdk.test.d.ts +1 -0
- package/dist/types/smartCheckout/actions/getUnsignedActions.d.ts +7 -0
- package/dist/types/smartCheckout/actions/getUnsignedActions.test.d.ts +1 -0
- package/dist/types/smartCheckout/actions/index.d.ts +2 -0
- package/dist/types/smartCheckout/actions/signActions.d.ts +6 -0
- package/dist/types/smartCheckout/actions/signActions.test.d.ts +1 -0
- package/dist/types/smartCheckout/actions/types.d.ts +32 -0
- package/dist/types/smartCheckout/aggregators/allowanceAggregator.d.ts +2 -0
- package/dist/types/smartCheckout/aggregators/allowanceAggregator.test.d.ts +1 -0
- package/dist/types/smartCheckout/aggregators/balanceAggregator.d.ts +5 -0
- package/dist/types/smartCheckout/aggregators/balanceAggregator.test.d.ts +1 -0
- package/dist/types/smartCheckout/aggregators/index.d.ts +2 -0
- package/dist/types/smartCheckout/aggregators/itemAggregator.d.ts +6 -0
- package/dist/types/smartCheckout/aggregators/itemAggregator.test.d.ts +1 -0
- package/dist/types/smartCheckout/allowList/allowListCheck.d.ts +11 -0
- package/dist/types/smartCheckout/allowList/allowListCheck.test.d.ts +1 -0
- package/dist/types/smartCheckout/allowList/index.d.ts +1 -0
- package/dist/types/smartCheckout/allowList/types.d.ts +6 -0
- package/dist/types/smartCheckout/allowance/erc1155.d.ts +9 -0
- package/dist/types/smartCheckout/allowance/erc1155.test.d.ts +1 -0
- package/dist/types/smartCheckout/allowance/erc20.d.ts +9 -0
- package/dist/types/smartCheckout/allowance/erc20.test.d.ts +1 -0
- package/dist/types/smartCheckout/allowance/erc721.d.ts +12 -0
- package/dist/types/smartCheckout/allowance/erc721.test.d.ts +1 -0
- package/dist/types/smartCheckout/allowance/index.d.ts +3 -0
- package/dist/types/smartCheckout/allowance/types.d.ts +30 -0
- package/dist/types/smartCheckout/balanceCheck/balanceCheck.d.ts +7 -0
- package/dist/types/smartCheckout/balanceCheck/balanceCheck.test.d.ts +1 -0
- package/dist/types/smartCheckout/balanceCheck/balanceRequirement.d.ts +17 -0
- package/dist/types/smartCheckout/balanceCheck/balanceRequirement.test.d.ts +1 -0
- package/dist/types/smartCheckout/balanceCheck/index.d.ts +1 -0
- package/dist/types/smartCheckout/balanceCheck/types.d.ts +30 -0
- package/dist/types/smartCheckout/buy/buy.d.ts +7 -0
- package/dist/types/smartCheckout/buy/buy.test.d.ts +1 -0
- package/dist/types/smartCheckout/buy/index.d.ts +1 -0
- package/dist/types/smartCheckout/cancel/cancel.d.ts +3 -0
- package/dist/types/smartCheckout/cancel/cancel.test.d.ts +1 -0
- package/dist/types/smartCheckout/cancel/index.d.ts +1 -0
- package/dist/types/smartCheckout/fees/fees.d.ts +5 -0
- package/dist/types/smartCheckout/fees/fees.test.d.ts +1 -0
- package/dist/types/smartCheckout/gas/gasCalculator.d.ts +6 -0
- package/dist/types/smartCheckout/gas/gasCalculator.test.d.ts +1 -0
- package/dist/types/smartCheckout/gas/index.d.ts +1 -0
- package/dist/types/smartCheckout/index.d.ts +1 -0
- package/dist/types/smartCheckout/itemRequirements/index.d.ts +1 -0
- package/dist/types/smartCheckout/itemRequirements/itemRequirements.d.ts +2 -0
- package/dist/types/smartCheckout/itemRequirements/itemRequirements.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/bridge/bridgeRoute.d.ts +11 -0
- package/dist/types/smartCheckout/routing/bridge/bridgeRoute.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/bridge/getBridgeFeeEstimate.d.ts +7 -0
- package/dist/types/smartCheckout/routing/bridge/getBridgeFeeEstimate.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/bridge/getEthBalance.d.ts +2 -0
- package/dist/types/smartCheckout/routing/bridge/getEthBalance.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/bridgeAndSwapRoute.d.ts +15 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/bridgeAndSwapRoute.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/constructBridgeRequirements.d.ts +9 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/constructBridgeRequirements.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/fetchL1ToL2Mapping.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/fetchL1ToL2Mappings.d.ts +4 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/getBalancesByChain.d.ts +7 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/getBalancesByChain.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/getDexQuotes.d.ts +5 -0
- package/dist/types/smartCheckout/routing/bridgeAndSwap/getDexQuotes.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/geoBlocking.d.ts +3 -0
- package/dist/types/smartCheckout/routing/geoBlocking.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/index.d.ts +1 -0
- package/dist/types/smartCheckout/routing/indexer/fetchL1Representation.d.ts +9 -0
- package/dist/types/smartCheckout/routing/indexer/fetchL1Representation.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/onRamp/index.d.ts +1 -0
- package/dist/types/smartCheckout/routing/onRamp/onRampRoute.d.ts +4 -0
- package/dist/types/smartCheckout/routing/onRamp/onRampRoute.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/routingCalculator.d.ts +13 -0
- package/dist/types/smartCheckout/routing/routingCalculator.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/routingOptions.d.ts +7 -0
- package/dist/types/smartCheckout/routing/routingOptions.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/swap/quoteFetcher.d.ts +7 -0
- package/dist/types/smartCheckout/routing/swap/quoteFetcher.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/swap/swapRoute.d.ts +24 -0
- package/dist/types/smartCheckout/routing/swap/swapRoute.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/tokenBalances.d.ts +5 -0
- package/dist/types/smartCheckout/routing/tokenBalances.test.d.ts +1 -0
- package/dist/types/smartCheckout/routing/types.d.ts +15 -0
- package/dist/types/smartCheckout/sell/index.d.ts +1 -0
- package/dist/types/smartCheckout/sell/sell.d.ts +7 -0
- package/dist/types/smartCheckout/sell/sell.test.d.ts +1 -0
- package/dist/types/smartCheckout/smartCheckout.d.ts +6 -0
- package/dist/types/smartCheckout/smartCheckout.test.d.ts +1 -0
- package/dist/types/swap/index.d.ts +1 -0
- package/dist/types/swap/swap.d.ts +7 -0
- package/dist/types/swap/swap.test.d.ts +1 -0
- package/dist/types/tokens/index.d.ts +1 -0
- package/dist/types/tokens/tokens.d.ts +12 -0
- package/dist/types/tokens/tokens.test.d.ts +1 -0
- package/dist/types/transaction/index.d.ts +1 -0
- package/dist/types/transaction/transaction.d.ts +21 -0
- package/dist/types/transaction/transaction.test.d.ts +1 -0
- package/dist/types/types/balances.d.ts +52 -0
- package/dist/types/types/buy.d.ts +15 -0
- package/dist/types/types/cancel.d.ts +15 -0
- package/dist/types/types/chains.d.ts +48 -0
- package/dist/types/types/config.d.ts +265 -0
- package/dist/types/types/connect.d.ts +34 -0
- package/dist/types/types/eip1193.d.ts +47 -0
- package/dist/types/types/eip6963.d.ts +29 -0
- package/dist/types/types/fees.d.ts +10 -0
- package/dist/types/types/fiatRamp.d.ts +25 -0
- package/dist/types/types/gasEstimate.d.ts +64 -0
- package/dist/types/types/index.d.ts +20 -0
- package/dist/types/types/network.d.ts +77 -0
- package/dist/types/types/networkInfo.d.ts +15 -0
- package/dist/types/types/provider.d.ts +45 -0
- package/dist/types/types/sell.d.ts +13 -0
- package/dist/types/types/smartCheckout.d.ts +918 -0
- package/dist/types/types/swap.d.ts +47 -0
- package/dist/types/types/token.d.ts +40 -0
- package/dist/types/types/tokenInfo.d.ts +27 -0
- package/dist/types/types/transaction.d.ts +18 -0
- package/dist/types/types/wallet.d.ts +49 -0
- package/dist/types/types/widgets.d.ts +11 -0
- package/dist/types/utils/utils.d.ts +11 -0
- package/dist/types/utils/utils.test.d.ts +1 -0
- package/dist/types/wallet/index.d.ts +1 -0
- package/dist/types/wallet/wallet.d.ts +2 -0
- package/dist/types/wallet/wallet.test.d.ts +1 -0
- package/dist/types/widgets/definitions/configurations/addTokens.d.ts +5 -0
- package/dist/types/widgets/definitions/configurations/bridge.d.ts +5 -0
- package/dist/types/widgets/definitions/configurations/commerce.d.ts +17 -0
- package/dist/types/widgets/definitions/configurations/connect.d.ts +5 -0
- package/dist/types/widgets/definitions/configurations/index.d.ts +11 -0
- package/dist/types/widgets/definitions/configurations/onramp.d.ts +5 -0
- package/dist/types/widgets/definitions/configurations/purchase.d.ts +2 -0
- package/dist/types/widgets/definitions/configurations/sale.d.ts +8 -0
- package/dist/types/widgets/definitions/configurations/swap.d.ts +5 -0
- package/dist/types/widgets/definitions/configurations/theme.d.ts +7 -0
- package/dist/types/widgets/definitions/configurations/wallet.d.ts +12 -0
- package/dist/types/widgets/definitions/configurations/widget.d.ts +31 -0
- package/dist/types/widgets/definitions/events/addTokens.d.ts +41 -0
- package/dist/types/widgets/definitions/events/bridge.d.ts +52 -0
- package/dist/types/widgets/definitions/events/commerce.d.ts +134 -0
- package/dist/types/widgets/definitions/events/connect.d.ts +47 -0
- package/dist/types/widgets/definitions/events/index.d.ts +11 -0
- package/dist/types/widgets/definitions/events/onramp.d.ts +28 -0
- package/dist/types/widgets/definitions/events/orchestration.d.ts +84 -0
- package/dist/types/widgets/definitions/events/purchase.d.ts +30 -0
- package/dist/types/widgets/definitions/events/sale.d.ts +103 -0
- package/dist/types/widgets/definitions/events/swap.d.ts +40 -0
- package/dist/types/widgets/definitions/events/wallet.d.ts +28 -0
- package/dist/types/widgets/definitions/events/widgets.d.ts +35 -0
- package/dist/types/widgets/definitions/global.d.ts +73 -0
- package/dist/types/widgets/definitions/parameters/addTokens.d.ts +20 -0
- package/dist/types/widgets/definitions/parameters/bridge.d.ts +20 -0
- package/dist/types/widgets/definitions/parameters/commerce.d.ts +44 -0
- package/dist/types/widgets/definitions/parameters/connect.d.ts +16 -0
- package/dist/types/widgets/definitions/parameters/index.d.ts +9 -0
- package/dist/types/widgets/definitions/parameters/onramp.d.ts +20 -0
- package/dist/types/widgets/definitions/parameters/purchase.d.ts +18 -0
- package/dist/types/widgets/definitions/parameters/sale.d.ts +50 -0
- package/dist/types/widgets/definitions/parameters/swap.d.ts +31 -0
- package/dist/types/widgets/definitions/parameters/wallet.d.ts +12 -0
- package/dist/types/widgets/definitions/types.d.ts +282 -0
- package/dist/types/widgets/load.d.ts +2 -0
- package/dist/types/widgets/load.test.d.ts +1 -0
- package/dist/types/widgets/version.d.ts +23 -0
- package/dist/types/widgets/version.test.d.ts +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,918 @@
|
|
|
1
|
+
import { TransactionRequest, TransactionResponse, Eip1193Provider } from 'ethers';
|
|
2
|
+
import { TokenInfo } from './tokenInfo';
|
|
3
|
+
import { OrderFee } from './fees';
|
|
4
|
+
import { WrappedBrowserProvider } from './provider';
|
|
5
|
+
export type BuyResult = BuyResultSuccess | BuyResultFailed | BuyResultFulfillmentsUnsettled | BuyResultInsufficientFunds;
|
|
6
|
+
/**
|
|
7
|
+
* Represents the result of {@link Checkout.buy}
|
|
8
|
+
* @property {CheckoutStatus.SUCCESS} status
|
|
9
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
10
|
+
*/
|
|
11
|
+
export type BuyResultSuccess = {
|
|
12
|
+
/** The status to indicate success */
|
|
13
|
+
status: CheckoutStatus.SUCCESS;
|
|
14
|
+
/** The sufficient result of smart checkout */
|
|
15
|
+
smartCheckoutResult: SmartCheckoutSufficient;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Represents the result of {@link Checkout.buy}
|
|
19
|
+
* @property {CheckoutStatus.FAILED} status
|
|
20
|
+
* @property {string} transactionHash
|
|
21
|
+
* @property {string} reason
|
|
22
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
23
|
+
*/
|
|
24
|
+
export type BuyResultFailed = {
|
|
25
|
+
/** The status to indicate failure */
|
|
26
|
+
status: CheckoutStatus.FAILED;
|
|
27
|
+
/** The transaction hash of the failed transaction */
|
|
28
|
+
transactionHash: string;
|
|
29
|
+
/** The reason for the failure */
|
|
30
|
+
reason: string;
|
|
31
|
+
/** The sufficient result of smart checkout */
|
|
32
|
+
smartCheckoutResult: SmartCheckoutSufficient;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Represents the result of {@link Checkout.buy}
|
|
36
|
+
* @property {CheckoutStatus.FULFILLMENTS_UNSETTLED} status
|
|
37
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
38
|
+
* @property {SendTransactionResult[]} transactions
|
|
39
|
+
*/
|
|
40
|
+
export type BuyResultFulfillmentsUnsettled = {
|
|
41
|
+
/** The status to indicate success */
|
|
42
|
+
status: CheckoutStatus.FULFILLMENTS_UNSETTLED;
|
|
43
|
+
/** The sufficient result of smart checkout */
|
|
44
|
+
smartCheckoutResult: SmartCheckoutSufficient;
|
|
45
|
+
/** Array of transaction results */
|
|
46
|
+
transactions: TransactionResponse[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Represents the result of {@link Checkout.buy}
|
|
50
|
+
* @property {CheckoutStatus.INSUFFICIENT_FUNDS} status
|
|
51
|
+
* @property {SmartCheckoutInsufficient} smartCheckoutResult
|
|
52
|
+
*/
|
|
53
|
+
export type BuyResultInsufficientFunds = {
|
|
54
|
+
/** The status to indicate insufficient funds */
|
|
55
|
+
status: CheckoutStatus.INSUFFICIENT_FUNDS;
|
|
56
|
+
/** The insufficient result of smart checkout */
|
|
57
|
+
smartCheckoutResult: SmartCheckoutInsufficient;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Represents the overrides available for {@link Checkout.buy}
|
|
61
|
+
* @property {boolean} waitFulfillmentSettlements
|
|
62
|
+
*/
|
|
63
|
+
export type BuyOverrides = {
|
|
64
|
+
/** If the buy should wait for the fulfillment transactions to settle */
|
|
65
|
+
waitFulfillmentSettlements?: boolean;
|
|
66
|
+
};
|
|
67
|
+
export type SellResult = SellResultSuccess | SellResultFailed | SellResultInsufficientFunds;
|
|
68
|
+
/**
|
|
69
|
+
* Represents the result of {@link Checkout.sell}
|
|
70
|
+
* @property {CheckoutStatus.SUCCESS} status
|
|
71
|
+
* @property {string[]} orderIds
|
|
72
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
73
|
+
*/
|
|
74
|
+
export type SellResultSuccess = {
|
|
75
|
+
/** The status to indicate success */
|
|
76
|
+
status: CheckoutStatus.SUCCESS;
|
|
77
|
+
/** The orders' ids */
|
|
78
|
+
orderIds: string[];
|
|
79
|
+
/** The sufficient result of smart checkout */
|
|
80
|
+
smartCheckoutResult: SmartCheckoutSufficient;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Represents the result of {@link Checkout.sell}
|
|
84
|
+
* @property {CheckoutStatus.FAILED} status
|
|
85
|
+
* @property {string} transactionHash
|
|
86
|
+
* @property {string} reason
|
|
87
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
88
|
+
*/
|
|
89
|
+
export type SellResultFailed = {
|
|
90
|
+
/** The status to indicate failure */
|
|
91
|
+
status: CheckoutStatus.FAILED;
|
|
92
|
+
/** The transaction hash of the failed transaction */
|
|
93
|
+
transactionHash: string;
|
|
94
|
+
/** The reason for the failure */
|
|
95
|
+
reason: string;
|
|
96
|
+
/** The sufficient result of smart checkout */
|
|
97
|
+
smartCheckoutResult: SmartCheckoutSufficient;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Represents the result of {@link Checkout.sell}
|
|
101
|
+
* @property {CheckoutStatus.INSUFFICIENT_FUNDS} status
|
|
102
|
+
* @property {SmartCheckoutInsufficient} smartCheckoutResult
|
|
103
|
+
*/
|
|
104
|
+
export type SellResultInsufficientFunds = {
|
|
105
|
+
/** The status to indicate insufficient funds */
|
|
106
|
+
status: CheckoutStatus.INSUFFICIENT_FUNDS;
|
|
107
|
+
/** The insufficient result of smart checkout */
|
|
108
|
+
smartCheckoutResult: SmartCheckoutInsufficient;
|
|
109
|
+
};
|
|
110
|
+
export type CancelResult = CancelResultSuccess | CancelResultFailed | CancelResultFulfillmentsUnsettled | CancelResultGasless;
|
|
111
|
+
/**
|
|
112
|
+
* Represents the result of {@link Checkout.cancel}
|
|
113
|
+
* @property {CheckoutStatus.SUCCESS} status
|
|
114
|
+
*/
|
|
115
|
+
export type CancelResultSuccess = {
|
|
116
|
+
/** The status to indicate success */
|
|
117
|
+
status: CheckoutStatus.SUCCESS;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Represents the result of {@link Checkout.cancel}
|
|
121
|
+
* @property {CheckoutStatus.FAILED} status
|
|
122
|
+
* @property {string} transactionHash
|
|
123
|
+
* @property {string} reason
|
|
124
|
+
*/
|
|
125
|
+
export type CancelResultFailed = {
|
|
126
|
+
/** The status to indicate failure */
|
|
127
|
+
status: CheckoutStatus.FAILED;
|
|
128
|
+
/** The transaction hash of the failed transaction */
|
|
129
|
+
transactionHash: string;
|
|
130
|
+
/** The reason for the failure */
|
|
131
|
+
reason: string;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Represents the result of {@link Checkout.cancel}
|
|
135
|
+
* @property {CheckoutStatus.FULFILLMENTS_UNSETTLED} status
|
|
136
|
+
* @property {SendTransactionResult[]} transactions
|
|
137
|
+
*/
|
|
138
|
+
export type CancelResultFulfillmentsUnsettled = {
|
|
139
|
+
/** The status to indicate the fulfillments have not yet settled on chain. */
|
|
140
|
+
status: CheckoutStatus.FULFILLMENTS_UNSETTLED;
|
|
141
|
+
/** Array of transaction results */
|
|
142
|
+
transactions: TransactionResponse[];
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Represents the result of {@link Checkout.cancel} when using gasless cancel
|
|
146
|
+
* @property {SuccessfulGaslessCancellation[]} successfulCancellations
|
|
147
|
+
* @property {FailedGaslessCancellation[]} failedCancellations
|
|
148
|
+
* @property {PendingGaslessCancellation[]} pendingCancellations
|
|
149
|
+
*/
|
|
150
|
+
export type CancelResultGasless = {
|
|
151
|
+
successfulCancellations: SuccessfulGaslessCancellation[];
|
|
152
|
+
failedCancellations: FailedGaslessCancellation[];
|
|
153
|
+
pendingCancellations: PendingGaslessCancellation[];
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Represents a successful gasless cancellation
|
|
157
|
+
* @property {string} orderId
|
|
158
|
+
*/
|
|
159
|
+
export type SuccessfulGaslessCancellation = {
|
|
160
|
+
/** The order id of the successful cancellation */
|
|
161
|
+
orderId: string;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Represents a failed gasless cancellation
|
|
165
|
+
* @property {string} orderId
|
|
166
|
+
* @property {string} reason
|
|
167
|
+
*/
|
|
168
|
+
export type FailedGaslessCancellation = {
|
|
169
|
+
/** The order id of the failed cancellation */
|
|
170
|
+
orderId: string;
|
|
171
|
+
/** The reason for failure */
|
|
172
|
+
reason: string;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Represents a pending gasless cancellation
|
|
176
|
+
* @property {string} orderId
|
|
177
|
+
*/
|
|
178
|
+
export type PendingGaslessCancellation = {
|
|
179
|
+
/** The order id of the pending cancellation */
|
|
180
|
+
orderId: string;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Represents the overrides available for {@link Checkout.cancel}
|
|
184
|
+
* @property {boolean} waitFulfillmentSettlements
|
|
185
|
+
*/
|
|
186
|
+
export type CancelOverrides = {
|
|
187
|
+
/** If the cancel should wait for the fulfillment transactions to settle */
|
|
188
|
+
waitFulfillmentSettlements?: boolean;
|
|
189
|
+
/** If the cancel should use the gasless option */
|
|
190
|
+
useGaslessCancel?: boolean;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* An enum representing the checkout status types
|
|
194
|
+
* @enum {string}
|
|
195
|
+
* @property {string} SUCCESS - If checkout succeeded as the transactions were able to be processed
|
|
196
|
+
* @property {string} FAILED - If checkout failed due to transactions not settling on chain
|
|
197
|
+
* @property {string} INSUFFICIENT_FUNDS - If checkout failed due to insufficient funds
|
|
198
|
+
* @property {string} FULFILLMENTS_UNSETTLED - If checkout succeeded but the fulfillment transactions are not yet settled
|
|
199
|
+
*/
|
|
200
|
+
export declare enum CheckoutStatus {
|
|
201
|
+
SUCCESS = "SUCCESS",
|
|
202
|
+
FAILED = "FAILED",
|
|
203
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
204
|
+
FULFILLMENTS_UNSETTLED = "FULFILLMENTS_UNSETTLED"
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The type representing the order to buy
|
|
208
|
+
* @property {string} orderId
|
|
209
|
+
* @property {OrderFee[]} takerFees
|
|
210
|
+
*/
|
|
211
|
+
export type BuyOrder = {
|
|
212
|
+
/** the id of the order to buy */
|
|
213
|
+
id: string;
|
|
214
|
+
/** array of order fees to apply to the order */
|
|
215
|
+
takerFees?: OrderFee[];
|
|
216
|
+
/** The amount of the order to fill - only applies to ERC1155 orders */
|
|
217
|
+
fillAmount?: string;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* The type representing the sell order to create a listing from
|
|
221
|
+
* @property {SellToken} sellToken
|
|
222
|
+
* @property {BuyToken} buyToken
|
|
223
|
+
* @property {OrderFee[]} makerFees
|
|
224
|
+
*/
|
|
225
|
+
export type SellOrder = {
|
|
226
|
+
/** the token to be listed for sale */
|
|
227
|
+
sellToken: SellToken;
|
|
228
|
+
/** the token info of the price of the item */
|
|
229
|
+
buyToken: BuyToken;
|
|
230
|
+
/** optional array of makerFees to be applied to the listing */
|
|
231
|
+
makerFees?: OrderFee[];
|
|
232
|
+
/** optional order expiry date. Default order expiry to 2 years from now */
|
|
233
|
+
orderExpiry?: Date;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Represents the token that the item can be bought with once listed for sale.
|
|
237
|
+
* NativeBuyToken or ERC20BuyToken {@link Checkout.smartCheckout}.
|
|
238
|
+
*/
|
|
239
|
+
export type BuyToken = NativeBuyToken | ERC20BuyToken;
|
|
240
|
+
/**
|
|
241
|
+
* Represents a native buy token
|
|
242
|
+
* @property {ItemType} type
|
|
243
|
+
* @property {string} amount
|
|
244
|
+
*/
|
|
245
|
+
export type NativeBuyToken = {
|
|
246
|
+
/** The type indicate this is a native token. */
|
|
247
|
+
type: ItemType.NATIVE;
|
|
248
|
+
/** The amount of native token. */
|
|
249
|
+
amount: string;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Represents a ERC20 buy token
|
|
253
|
+
* @property {ItemType} type
|
|
254
|
+
* @property {string} amount
|
|
255
|
+
* @property {string} tokenAddress
|
|
256
|
+
*/
|
|
257
|
+
export type ERC20BuyToken = {
|
|
258
|
+
/** The type indicate this is a ERC20 token. */
|
|
259
|
+
type: ItemType.ERC20;
|
|
260
|
+
/** The amount of native token. */
|
|
261
|
+
amount: string;
|
|
262
|
+
/** The token address of the ERC20. */
|
|
263
|
+
tokenAddress: string;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Represents the token listed for sale.
|
|
267
|
+
* ERC721SellToken or ERC1155SellToken {@link Checkout.smartCheckout}.
|
|
268
|
+
*/
|
|
269
|
+
export type SellToken = DeprecatedERC721SellToken | ERC721SellToken | ERC1155SellToken;
|
|
270
|
+
/**
|
|
271
|
+
* The ERC721SellToken type
|
|
272
|
+
* @property {string} id
|
|
273
|
+
* @property {string} collectionAddress
|
|
274
|
+
*/
|
|
275
|
+
export type ERC721SellToken = {
|
|
276
|
+
type: ItemType.ERC721;
|
|
277
|
+
/** The ERC721 token id */
|
|
278
|
+
id: string;
|
|
279
|
+
/** The ERC721 collection address */
|
|
280
|
+
collectionAddress: string;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* The original ERC721SellToken type, before the introduction of the ItemType enum
|
|
284
|
+
* @property {string} id
|
|
285
|
+
* @property {string} collectionAddress
|
|
286
|
+
* @deprecated
|
|
287
|
+
*/
|
|
288
|
+
export type DeprecatedERC721SellToken = {
|
|
289
|
+
/** The ERC721 token id */
|
|
290
|
+
id: string;
|
|
291
|
+
/** The ERC721 collection address */
|
|
292
|
+
collectionAddress: string;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* The ERC1155SellToken type
|
|
296
|
+
* @property {string} id
|
|
297
|
+
* @property {string} collectionAddress
|
|
298
|
+
* @property {string} amount
|
|
299
|
+
*/
|
|
300
|
+
export type ERC1155SellToken = {
|
|
301
|
+
type: ItemType.ERC1155;
|
|
302
|
+
/** The ERC1155 token id */
|
|
303
|
+
id: string;
|
|
304
|
+
/** The ERC1155 collection address */
|
|
305
|
+
collectionAddress: string;
|
|
306
|
+
/** The amount of the token to be sold */
|
|
307
|
+
amount: string;
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* Interface representing the parameters for {@link Checkout.smartCheckout}
|
|
311
|
+
* @property {WrappedBrowserProvider | Eip1193Provider} provider
|
|
312
|
+
* @property {ItemRequirement[]} itemRequirements
|
|
313
|
+
* @property {FulfillmentTransaction | GasAmount} transactionOrGasAmount
|
|
314
|
+
*/
|
|
315
|
+
export interface SmartCheckoutParams {
|
|
316
|
+
/** The provider to use for smart checkout. */
|
|
317
|
+
provider: WrappedBrowserProvider | Eip1193Provider;
|
|
318
|
+
/** The item requirements for the transaction. */
|
|
319
|
+
itemRequirements: (NativeItemRequirement | ERC20ItemRequirement | ERC721ItemRequirement | ERC1155ItemRequirement)[];
|
|
320
|
+
/** The transaction or gas amount. */
|
|
321
|
+
transactionOrGasAmount?: FulfillmentTransaction | GasAmount;
|
|
322
|
+
/** The overrides for funding routes to consider */
|
|
323
|
+
routingOptions?: AvailableRoutingOptions;
|
|
324
|
+
/** The callback to be executed once all funding routes are found */
|
|
325
|
+
onComplete?: (result: SmartCheckoutResult) => void;
|
|
326
|
+
/** The callback to be executed on each funding route found */
|
|
327
|
+
onFundingRoute?: (fundingRoute: FundingRoute) => void;
|
|
328
|
+
/** A flag to get funding routes based on full or partial amount */
|
|
329
|
+
fundingRouteFullAmount?: boolean;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Represents a native item requirement for a transaction.
|
|
333
|
+
* @property {ItemType.NATIVE} type
|
|
334
|
+
* @property {string} amount
|
|
335
|
+
*/
|
|
336
|
+
export type NativeItemRequirement = {
|
|
337
|
+
/** The type to indicate this is a native item requirement. */
|
|
338
|
+
type: ItemType.NATIVE;
|
|
339
|
+
/** The amount of the item. */
|
|
340
|
+
amount: string;
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Represents an ERC20 item requirement for a transaction.
|
|
344
|
+
* @property {ItemType.ERC20} type
|
|
345
|
+
* @property {string} tokenAddress
|
|
346
|
+
* @property {string} amount
|
|
347
|
+
* @property {string} spenderAddress
|
|
348
|
+
*/
|
|
349
|
+
export type ERC20ItemRequirement = {
|
|
350
|
+
/** The type to indicate this is a ERC20 item requirement. */
|
|
351
|
+
type: ItemType.ERC20;
|
|
352
|
+
/** The token address of the ERC20. */
|
|
353
|
+
tokenAddress: string;
|
|
354
|
+
/** The amount of the item. */
|
|
355
|
+
amount: string;
|
|
356
|
+
/** The contract address of the approver. */
|
|
357
|
+
spenderAddress: string;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Represents an ERC721 item requirement for a transaction.
|
|
361
|
+
* @property {ItemType.ERC721} type
|
|
362
|
+
* @property {string} contractAddress
|
|
363
|
+
* @property {string} id
|
|
364
|
+
* @property {string} spenderAddress
|
|
365
|
+
*/
|
|
366
|
+
export type ERC721ItemRequirement = {
|
|
367
|
+
/** The type to indicate this is a ERC721 item requirement. */
|
|
368
|
+
type: ItemType.ERC721;
|
|
369
|
+
/** The contract address of the ERC721 collection. */
|
|
370
|
+
contractAddress: string;
|
|
371
|
+
/** The ID of this ERC721 in the collection. */
|
|
372
|
+
id: string;
|
|
373
|
+
/** The contract address of the approver. */
|
|
374
|
+
spenderAddress: string;
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* Represents an ERC1155 item requirement for a transaction.
|
|
378
|
+
* @property {ItemType.ERC1155} type
|
|
379
|
+
* @property {string} contractAddress
|
|
380
|
+
* @property {string} id
|
|
381
|
+
* @property {string} spenderAddress
|
|
382
|
+
* @property {bigint} amount
|
|
383
|
+
*/
|
|
384
|
+
export type ERC1155ItemRequirement = {
|
|
385
|
+
/** The type to indicate this is a ERC1155 item requirement. */
|
|
386
|
+
type: ItemType.ERC1155;
|
|
387
|
+
/** The contract address of the ERC1155 collection. */
|
|
388
|
+
contractAddress: string;
|
|
389
|
+
/** The ID of this ERC1155 in the collection. */
|
|
390
|
+
id: string;
|
|
391
|
+
/** The contract address of the approver. */
|
|
392
|
+
spenderAddress: string;
|
|
393
|
+
/** The amount of the ERC1155 token ID being spent. */
|
|
394
|
+
amount: bigint;
|
|
395
|
+
};
|
|
396
|
+
/**
|
|
397
|
+
* Represents the item requirements for a transaction.
|
|
398
|
+
* NativeItem, ERC20Item, ERC721Item or ERC1155Item {@link Checkout.smartCheckout}.
|
|
399
|
+
*/
|
|
400
|
+
export type ItemRequirement = NativeItem | ERC20Item | ERC721Item | ERC1155Item;
|
|
401
|
+
/**
|
|
402
|
+
* An enum representing the item types
|
|
403
|
+
* @enum {string}
|
|
404
|
+
* @property {string} NATIVE - If the item is a native token.
|
|
405
|
+
* @property {string} ERC20 - If the item is an ERC20 token.
|
|
406
|
+
* @property {string} ERC721 - If the item is an ERC721 token.
|
|
407
|
+
* @property {string} ERC1155 - If the item is an ERC1155 token.
|
|
408
|
+
*/
|
|
409
|
+
export declare enum ItemType {
|
|
410
|
+
NATIVE = "NATIVE",
|
|
411
|
+
ERC20 = "ERC20",
|
|
412
|
+
ERC721 = "ERC721",
|
|
413
|
+
ERC1155 = "ERC1155"
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Represents a native item.
|
|
417
|
+
* @property {ItemType} type
|
|
418
|
+
* @property {bigint} amount
|
|
419
|
+
*/
|
|
420
|
+
export type NativeItem = {
|
|
421
|
+
/** The type indicate this is a native item. */
|
|
422
|
+
type: ItemType.NATIVE;
|
|
423
|
+
/** The amount of the item. */
|
|
424
|
+
amount: bigint;
|
|
425
|
+
/** Flag to indicate if the item is a transaction fee */
|
|
426
|
+
isFee: boolean;
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* Represents an ERC20 item.
|
|
430
|
+
* @property {ItemType} type
|
|
431
|
+
* @property {string} tokenAddress
|
|
432
|
+
* @property {BigNumber} amount
|
|
433
|
+
* @property {string} spenderAddress
|
|
434
|
+
*/
|
|
435
|
+
export type ERC20Item = {
|
|
436
|
+
/** The type to indicate this is an ERC20 item. */
|
|
437
|
+
type: ItemType.ERC20;
|
|
438
|
+
/** The token address of the ERC20. */
|
|
439
|
+
tokenAddress: string;
|
|
440
|
+
/** The amount of the item. */
|
|
441
|
+
amount: bigint;
|
|
442
|
+
/** The contract address of the approver. */
|
|
443
|
+
spenderAddress: string;
|
|
444
|
+
/** Flag to indicate if the item is a transaction fee */
|
|
445
|
+
isFee: boolean;
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* Represents an ERC721 item.
|
|
449
|
+
* @property {ItemType} type
|
|
450
|
+
* @property {string} contractAddress
|
|
451
|
+
* @property {string} id
|
|
452
|
+
* @property {string} spenderAddress
|
|
453
|
+
*/
|
|
454
|
+
export type ERC721Item = {
|
|
455
|
+
/** The type to indicate this is an ERC721 item. */
|
|
456
|
+
type: ItemType.ERC721;
|
|
457
|
+
/** The contract address of the ERC721 collection. */
|
|
458
|
+
contractAddress: string;
|
|
459
|
+
/** The ID of this ERC721 in the collection. */
|
|
460
|
+
id: string;
|
|
461
|
+
/** The contract address of the approver. */
|
|
462
|
+
spenderAddress: string;
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* Represents an ERC1155 item.
|
|
466
|
+
* @property {ItemType} type
|
|
467
|
+
* @property {string} contractAddress
|
|
468
|
+
* @property {string} id
|
|
469
|
+
* @property {string} spenderAddress
|
|
470
|
+
* @property {bigint} amount
|
|
471
|
+
*/
|
|
472
|
+
export type ERC1155Item = {
|
|
473
|
+
/** The type to indicate this is a ERC1155 item requirement. */
|
|
474
|
+
type: ItemType.ERC1155;
|
|
475
|
+
/** The contract address of the ERC1155 collection. */
|
|
476
|
+
contractAddress: string;
|
|
477
|
+
/** The ID of this ERC1155 in the collection. */
|
|
478
|
+
id: string;
|
|
479
|
+
/** The contract address of the approver. */
|
|
480
|
+
spenderAddress: string;
|
|
481
|
+
/** The amount of the ERC1155 token ID being spent. */
|
|
482
|
+
amount: bigint;
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* An enum representing transaction or gas types
|
|
486
|
+
* @enum {string}
|
|
487
|
+
* @property {string} TRANSACTION - If the type is a transaction
|
|
488
|
+
* @property {string} GAS - If the type is the gas amount
|
|
489
|
+
*/
|
|
490
|
+
export declare enum TransactionOrGasType {
|
|
491
|
+
TRANSACTION = "TRANSACTION",
|
|
492
|
+
GAS = "GAS"
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* The fulfillment transaction which contains the transaction to send.
|
|
496
|
+
* @property {TransactionOrGasType} type
|
|
497
|
+
* @property {TransactionRequest} transaction
|
|
498
|
+
*/
|
|
499
|
+
export type FulfillmentTransaction = {
|
|
500
|
+
/** The type to indicate this is a fulfillment transaction. */
|
|
501
|
+
type: TransactionOrGasType.TRANSACTION;
|
|
502
|
+
/** The transaction to send. */
|
|
503
|
+
transaction: TransactionRequest;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* The gas amount which contains the gas token and the gas limit.
|
|
507
|
+
* @property {TransactionOrGasType} type
|
|
508
|
+
* @property {GasToken} gasToken
|
|
509
|
+
*/
|
|
510
|
+
export type GasAmount = {
|
|
511
|
+
/** The type to indicate this is a gas amount. */
|
|
512
|
+
type: TransactionOrGasType.GAS;
|
|
513
|
+
/** The gas token. */
|
|
514
|
+
gasToken: GasToken;
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* Represents the gas token which is either a native token or an ERC20 token.
|
|
518
|
+
*/
|
|
519
|
+
export type GasToken = NativeGas | ERC20Gas;
|
|
520
|
+
/**
|
|
521
|
+
* An enum representing the gas token types
|
|
522
|
+
* @enum {string}
|
|
523
|
+
* @property {string} NATIVE - If the gas token is a native token.
|
|
524
|
+
* @property {string} ERC20 - If the gas token is an ERC20 token.
|
|
525
|
+
*/
|
|
526
|
+
export declare enum GasTokenType {
|
|
527
|
+
NATIVE = "NATIVE",
|
|
528
|
+
ERC20 = "ERC20"
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Represents a native gas token.
|
|
532
|
+
* @property {GasTokenType} type
|
|
533
|
+
* @property {bigint} limit
|
|
534
|
+
*/
|
|
535
|
+
export type NativeGas = {
|
|
536
|
+
/** The type to indicate this is a native gas token. */
|
|
537
|
+
type: GasTokenType.NATIVE;
|
|
538
|
+
/** The gas limit. */
|
|
539
|
+
limit: bigint;
|
|
540
|
+
};
|
|
541
|
+
/**
|
|
542
|
+
* Represents an ERC20 gas token.
|
|
543
|
+
* @property {GasTokenType} type
|
|
544
|
+
* @property {string} tokenAddress
|
|
545
|
+
* @property {bigint} limit
|
|
546
|
+
*/
|
|
547
|
+
export type ERC20Gas = {
|
|
548
|
+
/** The type to indicate this is an ERC20 gas token. */
|
|
549
|
+
type: GasTokenType.ERC20;
|
|
550
|
+
/** The token address of the ERC20. */
|
|
551
|
+
tokenAddress: string;
|
|
552
|
+
/** The gas limit. */
|
|
553
|
+
limit: bigint;
|
|
554
|
+
};
|
|
555
|
+
/**
|
|
556
|
+
* The type representing the result of {@link Checkout.smartCheckout}.
|
|
557
|
+
*/
|
|
558
|
+
export type SmartCheckoutResult = SmartCheckoutSufficient | SmartCheckoutInsufficient;
|
|
559
|
+
/**
|
|
560
|
+
* Represents the result of {@link Checkout.smartCheckout} when smart checkout is sufficient.
|
|
561
|
+
* @property {boolean} sufficient
|
|
562
|
+
* @property {TransactionRequirement[]} transactionRequirements
|
|
563
|
+
*/
|
|
564
|
+
export type SmartCheckoutSufficient = {
|
|
565
|
+
/** Indicates that smart checkout determined the user had sufficient funds. */
|
|
566
|
+
sufficient: true;
|
|
567
|
+
/** The transaction requirements smart checkout determined were required for the transaction. */
|
|
568
|
+
transactionRequirements: TransactionRequirement[];
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* Represents the result of {@link Checkout.smartCheckout} when smart checkout is insufficient.
|
|
572
|
+
* @property {boolean} sufficient
|
|
573
|
+
* @property {TransactionRequirement[]} transactionRequirements
|
|
574
|
+
* @property {SmartCheckoutRouter} router
|
|
575
|
+
*/
|
|
576
|
+
export type SmartCheckoutInsufficient = {
|
|
577
|
+
/** Indicates that smart checkout determined the user has insufficient funds */
|
|
578
|
+
sufficient: false;
|
|
579
|
+
/** The transaction requirements smart checkout determined were required for the transaction. */
|
|
580
|
+
transactionRequirements: TransactionRequirement[];
|
|
581
|
+
/** The type containing the funding routes the user can take to fulfill the transaction requirements */
|
|
582
|
+
router?: SmartCheckoutRouter;
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* Represents the routing outcome for a transaction.
|
|
586
|
+
* @property {AvailableRoutingOptions} availableRoutingOptions
|
|
587
|
+
* @property {RoutingOutcome} routingOutcome
|
|
588
|
+
*/
|
|
589
|
+
export type SmartCheckoutRouter = {
|
|
590
|
+
/** The routing options available to the user */
|
|
591
|
+
availableRoutingOptions: AvailableRoutingOptions;
|
|
592
|
+
/** The routing outcome for the transaction which includes the funding routes if routes were found */
|
|
593
|
+
routingOutcome: RoutingOutcome;
|
|
594
|
+
};
|
|
595
|
+
/**
|
|
596
|
+
* An enum representing the routing outcome types
|
|
597
|
+
* @enum {string}
|
|
598
|
+
* @property {string} ROUTES_FOUND - If funding routes were found for the transaction.
|
|
599
|
+
* @property {string} NO_ROUTES_FOUND - If no funding routes were found for the transaction.
|
|
600
|
+
* @property {string} NO_ROUTE_OPTIONS - If no routing options were available for the transaction.
|
|
601
|
+
*/
|
|
602
|
+
export declare enum RoutingOutcomeType {
|
|
603
|
+
ROUTES_FOUND = "ROUTES_FOUND",
|
|
604
|
+
NO_ROUTES_FOUND = "NO_ROUTES_FOUND",
|
|
605
|
+
NO_ROUTE_OPTIONS = "NO_ROUTE_OPTIONS"
|
|
606
|
+
}
|
|
607
|
+
export type RoutingOutcome = RoutesFound | NoRoutesFound | NoRouteOptions;
|
|
608
|
+
/**
|
|
609
|
+
* Represents a routing outcome where funding routes were found.
|
|
610
|
+
* @property {RoutingOutcomeType.ROUTES_FOUND} type
|
|
611
|
+
* @property {AvailableRoutingOptions} fundingRoutes
|
|
612
|
+
*/
|
|
613
|
+
export type RoutesFound = {
|
|
614
|
+
/** Indicates that funding routes were found for the transaction. */
|
|
615
|
+
type: RoutingOutcomeType.ROUTES_FOUND;
|
|
616
|
+
/** The funding routes found for the transaction. */
|
|
617
|
+
fundingRoutes: FundingRoute[];
|
|
618
|
+
};
|
|
619
|
+
/**
|
|
620
|
+
* Represents a routing outcome where no funding routes were found.
|
|
621
|
+
* @property {RoutingOutcomeType.NO_ROUTES_FOUND} type
|
|
622
|
+
* @property {string} message
|
|
623
|
+
*/
|
|
624
|
+
export type NoRoutesFound = {
|
|
625
|
+
/** Indicates that no funding routes were found for the transaction. */
|
|
626
|
+
type: RoutingOutcomeType.NO_ROUTES_FOUND;
|
|
627
|
+
/** The message indicating why no funding routes were found. */
|
|
628
|
+
message: string;
|
|
629
|
+
};
|
|
630
|
+
/**
|
|
631
|
+
* Represents a routing outcome where no routing options were available for the transaction.
|
|
632
|
+
* @property {RoutingOutcomeType.NO_ROUTE_OPTIONS} type
|
|
633
|
+
* @property {string} message
|
|
634
|
+
*/
|
|
635
|
+
export type NoRouteOptions = {
|
|
636
|
+
/** Indicates that no routing options were available for the transaction. */
|
|
637
|
+
type: RoutingOutcomeType.NO_ROUTE_OPTIONS;
|
|
638
|
+
/** The message indicating why no routing options were available. */
|
|
639
|
+
message: string;
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* Represents a funding route
|
|
643
|
+
* @property {number} priority
|
|
644
|
+
* @property {FundingStep[]} steps
|
|
645
|
+
*/
|
|
646
|
+
export type FundingRoute = {
|
|
647
|
+
/** The priority of the route */
|
|
648
|
+
priority: number;
|
|
649
|
+
/** The steps associated with this funding route */
|
|
650
|
+
steps: FundingStep[];
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* Represents a fee
|
|
654
|
+
* @property {bigint} amount
|
|
655
|
+
* @property {string} formatted
|
|
656
|
+
* @property {TokenInfo | undefined} token
|
|
657
|
+
*/
|
|
658
|
+
export type Fee = {
|
|
659
|
+
/** The type of fee */
|
|
660
|
+
type: FeeType;
|
|
661
|
+
/** The amount of the fee */
|
|
662
|
+
amount: bigint;
|
|
663
|
+
/** The formatted amount of the fee */
|
|
664
|
+
formattedAmount: string;
|
|
665
|
+
/** The token info for the fee */
|
|
666
|
+
token?: TokenInfo;
|
|
667
|
+
/** The basis points for the secondary fee */
|
|
668
|
+
basisPoints?: number;
|
|
669
|
+
};
|
|
670
|
+
/**
|
|
671
|
+
* An enum representing the funding step types
|
|
672
|
+
* @enum {string}
|
|
673
|
+
* @property {string} GAS - If the fee is a gas fee.
|
|
674
|
+
* @property {string} BRIDGE_FEE - If the fee is a bridge fee.
|
|
675
|
+
* @property {string} SWAP_FEE - If the fee is a swap fee.
|
|
676
|
+
* @property {string} IMMUTABLE_FEE - If the fee is an immutable fee.
|
|
677
|
+
*/
|
|
678
|
+
export declare enum FeeType {
|
|
679
|
+
GAS = "GAS",
|
|
680
|
+
BRIDGE_FEE = "BRIDGE_FEE",
|
|
681
|
+
SWAP_FEE = "SWAP_FEE",
|
|
682
|
+
IMMUTABLE_FEE = "IMMUTABLE_FEE"
|
|
683
|
+
}
|
|
684
|
+
export type FundingStep = BridgeFundingStep | SwapFundingStep | OnRampFundingStep;
|
|
685
|
+
/**
|
|
686
|
+
* Represents a bridge funding route
|
|
687
|
+
* @property {FundingStepType.BRIDGE} type
|
|
688
|
+
* @property {number} chainId
|
|
689
|
+
* @property {FundingItem} fundingItem
|
|
690
|
+
* @property {BridgeFees} fees
|
|
691
|
+
*/
|
|
692
|
+
export type BridgeFundingStep = {
|
|
693
|
+
/** Indicates that this is a bridge funding step */
|
|
694
|
+
type: FundingStepType.BRIDGE;
|
|
695
|
+
/** The chain id the bridge should be executed on */
|
|
696
|
+
chainId: number;
|
|
697
|
+
/** The funding item for the bridge */
|
|
698
|
+
fundingItem: FundingItem;
|
|
699
|
+
/** The fees for the bridge */
|
|
700
|
+
fees: BridgeFees;
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* Represents the fees for a bridge funding step
|
|
704
|
+
* @property {Fee} approvalGasFee
|
|
705
|
+
* @property {Fee} bridgeGasFee
|
|
706
|
+
* @property {Fee[]} bridgeFees
|
|
707
|
+
*/
|
|
708
|
+
export type BridgeFees = {
|
|
709
|
+
/** The approval gas fee for the bridge */
|
|
710
|
+
approvalGasFee: Fee;
|
|
711
|
+
/** The bridge gas fee for the bridge */
|
|
712
|
+
bridgeGasFee: Fee;
|
|
713
|
+
/** Additional bridge fees for the bridge */
|
|
714
|
+
bridgeFees: Fee[];
|
|
715
|
+
};
|
|
716
|
+
/**
|
|
717
|
+
* Represents a swap funding route
|
|
718
|
+
* @property {FundingStepType.SWAP} type
|
|
719
|
+
* @property {number} chainId
|
|
720
|
+
* @property {FundingItem} fundingItem
|
|
721
|
+
* @property {SwapFees} fees
|
|
722
|
+
*/
|
|
723
|
+
export type SwapFundingStep = {
|
|
724
|
+
/** Indicates that this is a swap funding step */
|
|
725
|
+
type: FundingStepType.SWAP;
|
|
726
|
+
/** The chain id the swap should be executed on */
|
|
727
|
+
chainId: number;
|
|
728
|
+
/** The funding item for the swap */
|
|
729
|
+
fundingItem: FundingItem;
|
|
730
|
+
/** The fees for the swap */
|
|
731
|
+
fees: SwapFees;
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* Represents the fees for a swap funding step
|
|
735
|
+
* @property {Fee} approvalGasFee
|
|
736
|
+
* @property {Fee} swapGasFee
|
|
737
|
+
* @property {Fee[]} swapFees
|
|
738
|
+
*/
|
|
739
|
+
export type SwapFees = {
|
|
740
|
+
/** The approval gas fee for the swap */
|
|
741
|
+
approvalGasFee: Fee;
|
|
742
|
+
/** The swap gas fee for the swap */
|
|
743
|
+
swapGasFee: Fee;
|
|
744
|
+
/** Additional swap fees for the swap */
|
|
745
|
+
swapFees: Fee[];
|
|
746
|
+
};
|
|
747
|
+
/**
|
|
748
|
+
* Represents an onramp funding route
|
|
749
|
+
* @property {FundingStepType.ONRAMP} type
|
|
750
|
+
* @property {number} chainId
|
|
751
|
+
* @property {FundingItem} fundingItem
|
|
752
|
+
*/
|
|
753
|
+
export type OnRampFundingStep = {
|
|
754
|
+
/** Indicates that this is an onramp funding step */
|
|
755
|
+
type: FundingStepType.ONRAMP;
|
|
756
|
+
/** The chain id the onramp should provide funds to */
|
|
757
|
+
chainId: number;
|
|
758
|
+
/** The item to be onramped */
|
|
759
|
+
fundingItem: FundingItem;
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* An enum representing the funding step types
|
|
763
|
+
* @enum {string}
|
|
764
|
+
* @property {string} BRIDGE - If the funding step is a bridge.
|
|
765
|
+
* @property {string} SWAP - If the funding step is a swap.
|
|
766
|
+
* @property {string} ONRAMP - If the funding step is an onramp.
|
|
767
|
+
*/
|
|
768
|
+
export declare enum FundingStepType {
|
|
769
|
+
BRIDGE = "BRIDGE",
|
|
770
|
+
SWAP = "SWAP",
|
|
771
|
+
ONRAMP = "ONRAMP"
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Represents a funding item
|
|
775
|
+
* @property {ItemType.NATIVE | ItemType.ERC20} type
|
|
776
|
+
* @property {FundsRequired} fundsRequired
|
|
777
|
+
* @property {UserBalance} userBalance
|
|
778
|
+
* @property {TokenInfo} token
|
|
779
|
+
*/
|
|
780
|
+
export type FundingItem = {
|
|
781
|
+
/** The type of the funding item */
|
|
782
|
+
type: ItemType.NATIVE | ItemType.ERC20;
|
|
783
|
+
/** The amount of funds required of this funding item */
|
|
784
|
+
fundsRequired: FundsRequired;
|
|
785
|
+
/** The current user balance of this funding item */
|
|
786
|
+
userBalance: UserBalance;
|
|
787
|
+
/** The token info for the funding item */
|
|
788
|
+
token: TokenInfo;
|
|
789
|
+
};
|
|
790
|
+
/**
|
|
791
|
+
* Represents the funds required of a funding item
|
|
792
|
+
* @property {bigint} amount
|
|
793
|
+
* @property {string} formattedAmount
|
|
794
|
+
*/
|
|
795
|
+
export type FundsRequired = {
|
|
796
|
+
/** The amount of funds required */
|
|
797
|
+
amount: bigint;
|
|
798
|
+
/** The formatted amount of funds required */
|
|
799
|
+
formattedAmount: string;
|
|
800
|
+
};
|
|
801
|
+
/**
|
|
802
|
+
* Represents the user balance of a funding item
|
|
803
|
+
* @property {bigint} balance
|
|
804
|
+
* @property {string} formattedBalance
|
|
805
|
+
*/
|
|
806
|
+
export type UserBalance = {
|
|
807
|
+
/** The balance of the funding item */
|
|
808
|
+
balance: bigint;
|
|
809
|
+
/** The formatted balance of the funding item */
|
|
810
|
+
formattedBalance: string;
|
|
811
|
+
};
|
|
812
|
+
/**
|
|
813
|
+
* Represents the transaction requirement for a transaction.
|
|
814
|
+
* @property {ItemType} type
|
|
815
|
+
* @property {boolean} sufficient
|
|
816
|
+
* @property {ItemBalance} required
|
|
817
|
+
* @property {ItemBalance} current
|
|
818
|
+
* @property {BalanceDelta} delta
|
|
819
|
+
*/
|
|
820
|
+
export type TransactionRequirement = {
|
|
821
|
+
/** The type of the transaction requirement. */
|
|
822
|
+
type: ItemType;
|
|
823
|
+
/** If the user address has sufficient funds to cover the transaction. */
|
|
824
|
+
sufficient: boolean;
|
|
825
|
+
/** The required item balance. */
|
|
826
|
+
required: ItemBalance;
|
|
827
|
+
/** The current item balance. */
|
|
828
|
+
current: ItemBalance;
|
|
829
|
+
/** The delta between the required and current balances. */
|
|
830
|
+
delta: BalanceDelta;
|
|
831
|
+
/** Flags if the requirement is needed for transaction fees */
|
|
832
|
+
isFee: boolean;
|
|
833
|
+
};
|
|
834
|
+
/**
|
|
835
|
+
* Represents the balance for either a native or ERC20 token.
|
|
836
|
+
* @property {ItemType.NATIVE | ItemType.ERC20} type
|
|
837
|
+
* @property {bigint} balance
|
|
838
|
+
* @property {string} formattedBalance
|
|
839
|
+
* @property {TokenInfo} token
|
|
840
|
+
*/
|
|
841
|
+
export type TokenBalance = {
|
|
842
|
+
/** Type to indicate this is a native or ERC20 token. */
|
|
843
|
+
type: ItemType.NATIVE | ItemType.ERC20;
|
|
844
|
+
/** The balance of the item. */
|
|
845
|
+
balance: bigint;
|
|
846
|
+
/** The formatted balance of the item. */
|
|
847
|
+
formattedBalance: string;
|
|
848
|
+
/** The token info of the item. */
|
|
849
|
+
token: TokenInfo;
|
|
850
|
+
};
|
|
851
|
+
/**
|
|
852
|
+
* Represents the balance for an ERC721.
|
|
853
|
+
* @property {ItemType.ERC721} type
|
|
854
|
+
* @property {bigint} balance
|
|
855
|
+
* @property {string} formattedBalance
|
|
856
|
+
* @property {string} contractAddress
|
|
857
|
+
* @property {string} id
|
|
858
|
+
*/
|
|
859
|
+
export type ERC721Balance = {
|
|
860
|
+
/** Type to indicate this is an ERC721 token. */
|
|
861
|
+
type: ItemType.ERC721;
|
|
862
|
+
/** The balance of the item. */
|
|
863
|
+
balance: bigint;
|
|
864
|
+
/** The formatted balance of the item. */
|
|
865
|
+
formattedBalance: string;
|
|
866
|
+
/** The contract address of the ERC721 collection. */
|
|
867
|
+
contractAddress: string;
|
|
868
|
+
/** The ID of the ERC721 in the collection */
|
|
869
|
+
id: string;
|
|
870
|
+
};
|
|
871
|
+
/**
|
|
872
|
+
* Type representing the balance of an item.
|
|
873
|
+
*/
|
|
874
|
+
export type ItemBalance = ERC721Balance | TokenBalance;
|
|
875
|
+
/**
|
|
876
|
+
* Represents the delta between two balances.
|
|
877
|
+
* @property {bigint} balance
|
|
878
|
+
* @property {string} formattedBalance
|
|
879
|
+
*/
|
|
880
|
+
export type BalanceDelta = {
|
|
881
|
+
/** The delta of the balance. */
|
|
882
|
+
balance: bigint;
|
|
883
|
+
/** The formatted balance of the delta. */
|
|
884
|
+
formattedBalance: string;
|
|
885
|
+
};
|
|
886
|
+
/**
|
|
887
|
+
* A type representing the Smart Checkout routing options available for a user
|
|
888
|
+
* if they are configured and enabled (not geo-blocked etc.)
|
|
889
|
+
* @property {boolean | undefined} onRamp
|
|
890
|
+
* @property {boolean | undefined} swap
|
|
891
|
+
* @property {boolean | undefined} bridge
|
|
892
|
+
*/
|
|
893
|
+
export type AvailableRoutingOptions = {
|
|
894
|
+
/** If the user can use onramp */
|
|
895
|
+
onRamp?: boolean;
|
|
896
|
+
/** If the user can use swap */
|
|
897
|
+
swap?: boolean;
|
|
898
|
+
/** If the user can use bridge */
|
|
899
|
+
bridge?: boolean;
|
|
900
|
+
};
|
|
901
|
+
export type FundingRouteFeeEstimate = SwapRouteFeeEstimate | BridgeRouteFeeEstimate;
|
|
902
|
+
export type SwapRouteFeeEstimate = {
|
|
903
|
+
type: FundingStepType.SWAP;
|
|
904
|
+
estimatedamount: bigint;
|
|
905
|
+
token: TokenInfo;
|
|
906
|
+
};
|
|
907
|
+
export type BridgeRouteFeeEstimate = {
|
|
908
|
+
type: FundingStepType.BRIDGE;
|
|
909
|
+
gasFee: {
|
|
910
|
+
estimatedamount: bigint;
|
|
911
|
+
token?: TokenInfo;
|
|
912
|
+
};
|
|
913
|
+
bridgeFee: {
|
|
914
|
+
estimatedamount: bigint;
|
|
915
|
+
token?: TokenInfo;
|
|
916
|
+
};
|
|
917
|
+
totalFees: bigint;
|
|
918
|
+
};
|