@layerswap/widget 0.1.4 → 0.1.14
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/README.md +78 -3
- package/dist/Models/Theme.d.ts +7 -6
- package/dist/Models/Theme.js +7 -7
- package/dist/Models/WalletProvider.d.ts +0 -4
- package/dist/Models/WalletProvider.js +2 -0
- package/dist/components/Buttons/copyButton.js +4 -3
- package/dist/components/ColorSchema.js +79 -45
- package/dist/components/Common/AddressIcon.js +1 -0
- package/dist/components/Common/AverageCompletionTime.js +1 -1
- package/dist/components/Common/CountDownTimer.js +2 -2
- package/dist/components/Common/FormattedAverageCompletionTime.js +1 -1
- package/dist/components/HeaderWithMenu/index.js +1 -8
- package/dist/components/Input/Address/AddressNote.js +3 -2
- package/dist/components/Input/Address/AddressPicker/AddressWithIcon.js +2 -2
- package/dist/components/Input/Address/AddressPicker/ConnectedWallets/ConnectWalletButton.js +12 -5
- package/dist/components/Input/Address/AddressPicker/ExchangeNote.d.ts +1 -1
- package/dist/components/Input/Address/AddressPicker/ExchangeNote.js +1 -1
- package/dist/components/Input/RouteIcon.js +1 -1
- package/dist/components/LayerswapMenu/MenuList.js +2 -56
- package/dist/components/Pages/404/index.js +1 -0
- package/dist/components/Pages/Auth/Steps/CodeStep/VerifyEmailCode.js +1 -0
- package/dist/components/Pages/Auth/index.d.ts +1 -1
- package/dist/components/Pages/Auth/index.js +3 -2
- package/dist/components/Pages/Campaigns/Details/Leaderboard.js +1 -0
- package/dist/components/Pages/Campaigns/Details/index.d.ts +1 -1
- package/dist/components/Pages/Campaigns/Details/index.js +3 -2
- package/dist/components/Pages/Campaigns/index.d.ts +1 -1
- package/dist/components/Pages/Campaigns/index.js +3 -2
- package/dist/components/Pages/Maintanance/index.js +1 -0
- package/dist/components/Pages/NoCookies/index.js +1 -0
- package/dist/components/Pages/SwapHistory/History.js +1 -2
- package/dist/components/Pages/SwapHistory/index.d.ts +1 -1
- package/dist/components/Pages/SwapHistory/index.js +4 -3
- package/dist/components/Pages/SwapPages/Form/FeeDetails/Campaign.js +1 -0
- package/dist/components/Pages/SwapPages/Form/Form.js +1 -4
- package/dist/components/Pages/SwapPages/Form/SecondaryComponents/ValidationError.js +1 -1
- package/dist/components/Pages/SwapPages/Form/Select/Popover/PopoverSelect.js +1 -1
- package/dist/components/Pages/SwapPages/Form/index.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Coinbase/Carousel.js +8 -6
- package/dist/components/Pages/SwapPages/Withdraw/Processing/Processing.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/FuelWalletWithdrawal.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/FuelWalletWithdrawal.js +159 -125
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/ImtblxWalletWithdrawStep.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/ImtblxWalletWithdrawStep.js +69 -51
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/ActivationTokentPicker.d.ts +0 -8
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/ActivationTokentPicker.js +87 -45
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/hooks.d.ts +0 -40
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/hooks.js +73 -46
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/index.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/index.js +175 -128
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/index.d.ts +0 -7
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/index.js +138 -116
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/transactionSender.d.ts +0 -8
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/transactionSender.js +96 -75
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SophonWalletWithdraw.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/StarknetWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/StarknetWalletWithdraw.js +88 -71
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TonWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TonWalletWithdraw.js +146 -136
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TronWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TronWalletWithdraw.js +120 -99
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/TransferToken.js +3 -3
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/buttons.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/index.js +1 -1
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/transactionMessage.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransferContent.js +101 -33
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Evm.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Evm.js +60 -55
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Starknet.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Starknet.js +71 -55
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/buttons.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/index.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/index.js +56 -52
- package/dist/components/Pages/SwapPages/Withdraw/index.d.ts +1 -1
- package/dist/components/Pages/SwapPages/Withdraw/index.js +3 -2
- package/dist/components/Wallet/WalletModal/Connector.js +1 -1
- package/dist/components/Wallet/WalletProviders/FuelProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/FuelProvider.js +25 -20
- package/dist/components/Wallet/WalletProviders/ImtblPassportProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/ImtblPassportProvider.js +39 -36
- package/dist/components/Wallet/WalletProviders/SolanaProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/SolanaProvider.js +49 -38
- package/dist/components/Wallet/WalletProviders/StarknetProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/StarknetProvider.js +112 -117
- package/dist/components/Wallet/WalletProviders/TonConnectProvider.d.ts +0 -6
- package/dist/components/Wallet/WalletProviders/TonConnectProvider.js +58 -50
- package/dist/components/Wallet/WalletProviders/TronProvider.d.ts +0 -3
- package/dist/components/Wallet/WalletProviders/TronProvider.js +23 -15
- package/dist/components/Wallet/WalletProviders/Wagmi.d.ts +1 -1
- package/dist/components/Wallet/WalletProviders/Wagmi.js +20 -10
- package/dist/components/Wallet/WalletProviders/index.js +13 -6
- package/dist/components/Widget/Footer.d.ts +2 -1
- package/dist/components/Widget/Footer.js +13 -4
- package/dist/components/Widget/Index.d.ts +1 -1
- package/dist/components/Widget/Index.js +1 -1
- package/dist/components/WidgetLoading.d.ts +1 -0
- package/dist/components/WidgetLoading.js +5 -0
- package/dist/components/Wizard/Wizard.js +1 -1
- package/dist/components/shadcn/command.js +1 -1
- package/dist/components/themeWrapper.js +3 -2
- package/dist/context/{LayerswapContext.d.ts → LayerswapProvider.d.ts} +3 -8
- package/dist/context/{LayerswapContext.js → LayerswapProvider.js} +8 -9
- package/dist/context/authContext.js +1 -0
- package/dist/context/walletHooksProvider.js +1 -0
- package/dist/hooks/useWallet.js +10 -14
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +2 -4
- package/dist/index.mjs +19 -0
- package/dist/lib/AppSettings.d.ts +7 -3
- package/dist/lib/AppSettings.js +8 -7
- package/dist/lib/address/formatter/index.js +8 -9
- package/dist/lib/address/validator/index.js +18 -20
- package/dist/lib/axiosInterceptor.js +1 -2
- package/dist/lib/balances/balanceResolver.js +16 -16
- package/dist/lib/balances/providers/evmBalanceProvider.js +3 -3
- package/dist/lib/balances/providers/loopringBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/loopringBalanceProvider.js +56 -43
- package/dist/lib/balances/providers/paradexBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/paradexBalanceProvider.js +42 -42
- package/dist/lib/balances/providers/solanaBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/solanaBalanceProvider.js +70 -71
- package/dist/lib/balances/providers/starknetBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/starknetBalanceProvider.js +48 -45
- package/dist/lib/balances/providers/tonBalanceProvider.d.ts +0 -18
- package/dist/lib/balances/providers/tonBalanceProvider.js +104 -100
- package/dist/lib/balances/providers/tronBalanceResolver.js +2 -3
- package/dist/lib/fuels/common/FakeAccount.d.ts +0 -24
- package/dist/lib/fuels/common/FakeAccount.js +58 -36
- package/dist/lib/fuels/common/PredicateConnector.d.ts +0 -54
- package/dist/lib/fuels/common/PredicateConnector.js +292 -205
- package/dist/lib/fuels/common/PredicateFactory.d.ts +0 -29
- package/dist/lib/fuels/common/PredicateFactory.js +123 -76
- package/dist/lib/fuels/common/PredicateWalletAdapter.d.ts +0 -17
- package/dist/lib/fuels/common/PredicateWalletAdapter.js +44 -29
- package/dist/lib/fuels/common/index.d.ts +0 -4
- package/dist/lib/fuels/common/index.js +4 -4
- package/dist/lib/fuels/connectors/fuel-wallet/FuelWalletConnector.d.ts +0 -51
- package/dist/lib/fuels/connectors/fuel-wallet/FuelWalletConnector.js +268 -234
- package/dist/lib/fuels/connectors/fuel-wallet/index.d.ts +0 -2
- package/dist/lib/fuels/connectors/fuel-wallet/index.js +2 -2
- package/dist/lib/fuels/connectors/fuel-wallet/types.d.ts +0 -50
- package/dist/lib/fuels/connectors/fuel-wallet/types.js +53 -9
- package/dist/lib/fuels/connectors/fuelet-wallet/FueletWalletConnector.d.ts +0 -7
- package/dist/lib/fuels/connectors/fuelet-wallet/FueletWalletConnector.js +20 -19
- package/dist/lib/fuels/connectors/fuelet-wallet/index.d.ts +0 -1
- package/dist/lib/fuels/connectors/fuelet-wallet/index.js +1 -1
- package/dist/lib/gases/gasResolver.d.ts +1 -1
- package/dist/lib/gases/gasResolver.js +10 -10
- package/dist/lib/gases/providers/evmGasProvider.js +5 -4
- package/dist/lib/gases/providers/loopringGasProvider.d.ts +0 -6
- package/dist/lib/gases/providers/loopringGasProvider.js +27 -24
- package/dist/lib/gases/providers/solanaGasProvider.d.ts +0 -7
- package/dist/lib/gases/providers/solanaGasProvider.js +32 -31
- package/dist/lib/gases/providers/starknetGasProvider.d.ts +0 -7
- package/dist/lib/gases/providers/starknetGasProvider.js +34 -33
- package/dist/lib/imtbl.d.ts +0 -69
- package/dist/lib/imtbl.js +63 -60
- package/dist/lib/internalApiClient.d.ts +0 -2
- package/dist/lib/internalApiClient.js +1 -4
- package/dist/lib/layerSwapApiClient.js +3 -3
- package/dist/lib/logError.js +2 -2
- package/dist/lib/nft/nftBalanceResolver.js +1 -2
- package/dist/lib/nft/providers/starknetNftProvider.d.ts +0 -6
- package/dist/lib/nft/providers/starknetNftProvider.js +49 -50
- package/dist/lib/wallets/connectors/EthereumProvider.d.ts +2 -2
- package/dist/lib/wallets/connectors/useSyncProviders/store.d.ts +1 -4
- package/dist/lib/wallets/fuel/Bako.d.ts +0 -15
- package/dist/lib/wallets/fuel/Bako.js +34 -29
- package/dist/lib/wallets/fuel/Basko.d.ts +0 -15
- package/dist/lib/wallets/fuel/Basko.js +34 -29
- package/dist/lib/wallets/fuel/useFuel.d.ts +0 -2
- package/dist/lib/wallets/fuel/useFuel.js +211 -192
- package/dist/lib/wallets/imtblX/useImtblX.d.ts +0 -2
- package/dist/lib/wallets/imtblX/useImtblX.js +87 -87
- package/dist/lib/wallets/paradex/Authorize/Ethereum.d.ts +0 -2
- package/dist/lib/wallets/paradex/Authorize/Ethereum.js +24 -23
- package/dist/lib/wallets/paradex/Authorize/Starknet.d.ts +0 -2
- package/dist/lib/wallets/paradex/Authorize/Starknet.js +14 -13
- package/dist/lib/wallets/paradex/lib/account.d.ts +0 -28
- package/dist/lib/wallets/paradex/lib/account.js +102 -53
- package/dist/lib/wallets/paradex/lib/index.d.ts +0 -24
- package/dist/lib/wallets/paradex/lib/index.js +20 -20
- package/dist/lib/wallets/paradex/lib/paraclear-provider.d.ts +0 -6
- package/dist/lib/wallets/paradex/lib/paraclear-provider.js +13 -9
- package/dist/lib/wallets/paradex/lib/paraclear.d.ts +0 -137
- package/dist/lib/wallets/paradex/lib/paraclear.js +258 -131
- package/dist/lib/wallets/paradex/lib/starknet-account-support.d.ts +0 -22
- package/dist/lib/wallets/paradex/lib/starknet-account-support.js +296 -220
- package/dist/lib/wallets/paradex/lib/starknet-signer.d.ts +0 -15
- package/dist/lib/wallets/paradex/lib/starknet-signer.js +120 -94
- package/dist/lib/wallets/paradex/useParadex.d.ts +0 -7
- package/dist/lib/wallets/paradex/useParadex.js +197 -194
- package/dist/lib/wallets/solana/transactionBuilder.d.ts +0 -4
- package/dist/lib/wallets/solana/transactionBuilder.js +63 -39
- package/dist/lib/wallets/solana/useSVM.d.ts +0 -5
- package/dist/lib/wallets/solana/useSVM.js +139 -142
- package/dist/lib/wallets/starknet/useStarknet.d.ts +0 -2
- package/dist/lib/wallets/starknet/useStarknet.js +139 -139
- package/dist/lib/wallets/ton/client.d.ts +0 -3
- package/dist/lib/wallets/ton/client.js +7 -7
- package/dist/lib/wallets/ton/useTON.d.ts +0 -2
- package/dist/lib/wallets/ton/useTON.js +121 -122
- package/dist/lib/wallets/tron/connectors/bitkeep.d.ts +0 -61
- package/dist/lib/wallets/tron/connectors/bitkeep.js +326 -303
- package/dist/lib/wallets/tron/connectors/index.d.ts +0 -4
- package/dist/lib/wallets/tron/connectors/index.js +4 -4
- package/dist/lib/wallets/tron/connectors/okxWallet.d.ts +0 -66
- package/dist/lib/wallets/tron/connectors/okxWallet.js +364 -336
- package/dist/lib/wallets/tron/connectors/tokenPocket.d.ts +0 -72
- package/dist/lib/wallets/tron/connectors/tokenPocket.js +337 -308
- package/dist/lib/wallets/tron/connectors/tronLink/index.d.ts +0 -102
- package/dist/lib/wallets/tron/connectors/tronLink/index.js +560 -520
- package/dist/lib/wallets/tron/connectors/tronLink/types.d.ts +0 -56
- package/dist/lib/wallets/tron/connectors/tronLink/types.js +53 -1
- package/dist/lib/wallets/tron/connectors/tronLink/utils.d.ts +0 -14
- package/dist/lib/wallets/tron/connectors/tronLink/utils.js +64 -61
- package/dist/lib/wallets/tron/useTron.d.ts +0 -2
- package/dist/lib/wallets/tron/useTron.js +111 -111
- package/dist/lib/wallets/utils/resolveWalletIcon.js +1 -0
- package/package.json +26 -77
- package/dist/hooks/useCopyClipboard.d.ts +0 -1
- package/dist/hooks/useCopyClipboard.js +0 -21
- package/dist/index.cjs +0 -125
- package/dist/lib/abis/ERC20.json +0 -258
- package/dist/lib/fuels/connectors/walletConnect/WalletConnectConnector.d.ts +0 -42
- package/dist/lib/fuels/connectors/walletConnect/WalletConnectConnector.js +0 -357
- package/dist/lib/fuels/connectors/walletConnect/constants.d.ts +0 -6
- package/dist/lib/fuels/connectors/walletConnect/constants.js +0 -7
- package/dist/lib/fuels/connectors/walletConnect/index.d.ts +0 -3
- package/dist/lib/fuels/connectors/walletConnect/index.js +0 -3
- package/dist/lib/fuels/connectors/walletConnect/types.d.ts +0 -12
- package/dist/lib/fuels/connectors/walletConnect/types.js +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/index.d.ts +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/index.js +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/subscribeAndEnforceChain.d.ts +0 -2
- package/dist/lib/fuels/connectors/walletConnect/utils/subscribeAndEnforceChain.js +0 -39
- package/dist/lib/fuels/connectors/walletConnect/web3Modal.d.ts +0 -10
- package/dist/lib/fuels/connectors/walletConnect/web3Modal.js +0 -38
- package/dist/lib/loopring/LoopringAPI.d.ts +0 -12
- package/dist/lib/loopring/LoopringAPI.js +0 -13
- package/dist/lib/loopring/defs.d.ts +0 -425
- package/dist/lib/loopring/defs.js +0 -217
- package/dist/lib/loopring/eddsa.d.ts +0 -29
- package/dist/lib/loopring/eddsa.js +0 -208
- package/dist/lib/loopring/field.d.ts +0 -17
- package/dist/lib/loopring/field.js +0 -61
- package/dist/lib/loopring/formatter.d.ts +0 -137
- package/dist/lib/loopring/formatter.js +0 -516
- package/dist/lib/loopring/helpers.d.ts +0 -36
- package/dist/lib/loopring/helpers.js +0 -140
- package/dist/lib/loopring/jubjub.d.ts +0 -19
- package/dist/lib/loopring/jubjub.js +0 -79
- package/dist/lib/loopring/permutation.d.ts +0 -22
- package/dist/lib/loopring/permutation.js +0 -198
- package/dist/lib/loopring/poseidon/EDDSAUtil.d.ts +0 -14
- package/dist/lib/loopring/poseidon/EDDSAUtil.js +0 -61
- package/dist/lib/loopring/poseidon/babyJub.d.ts +0 -6
- package/dist/lib/loopring/poseidon/babyJub.js +0 -51
- package/dist/lib/loopring/poseidon/eddsa.d.ts +0 -29
- package/dist/lib/loopring/poseidon/eddsa.js +0 -210
- package/dist/lib/loopring/utils.d.ts +0 -76
- package/dist/lib/loopring/utils.js +0 -230
- package/dist/styles/dialog-transition.css +0 -28
- package/dist/styles/globals.css +0 -372
- package/dist/styles/manual-trasnfer-svg.css +0 -299
- package/dist/styles/vaul.css +0 -256
|
@@ -1,205 +1,292 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
1
|
+
// import {
|
|
2
|
+
// type AbiMap,
|
|
3
|
+
// Address,
|
|
4
|
+
// type Asset,
|
|
5
|
+
// type BytesLike,
|
|
6
|
+
// type ConnectorMetadata,
|
|
7
|
+
// FuelConnector,
|
|
8
|
+
// FuelConnectorEventTypes,
|
|
9
|
+
// type JsonAbi,
|
|
10
|
+
// type Network,
|
|
11
|
+
// type SelectNetworkArguments,
|
|
12
|
+
// type TransactionRequestLike,
|
|
13
|
+
// type Version,
|
|
14
|
+
// ZeroBytes32,
|
|
15
|
+
// bn,
|
|
16
|
+
// calculateGasFee,
|
|
17
|
+
// concat,
|
|
18
|
+
// transactionRequestify,
|
|
19
|
+
// } from 'fuels';
|
|
20
|
+
// import { PredicateFactory, getMockedSignatureIndex } from './PredicateFactory';
|
|
21
|
+
// // import type { PredicateWalletAdapter } from './PredicateWalletAdapter';
|
|
22
|
+
// import type {
|
|
23
|
+
// ConnectorConfig,
|
|
24
|
+
// Maybe,
|
|
25
|
+
// MaybeAsync,
|
|
26
|
+
// PredicateConfig,
|
|
27
|
+
// PredicateVersion,
|
|
28
|
+
// PreparedTransaction,
|
|
29
|
+
// ProviderDictionary,
|
|
30
|
+
// SignedMessageCustomCurve,
|
|
31
|
+
// } from './types';
|
|
32
|
+
// export abstract class PredicateConnector extends FuelConnector {
|
|
33
|
+
// public connected = false;
|
|
34
|
+
// public installed = false;
|
|
35
|
+
// external = true;
|
|
36
|
+
// public events = FuelConnectorEventTypes;
|
|
37
|
+
// protected predicateAddress!: string;
|
|
38
|
+
// protected customPredicate: Maybe<PredicateConfig>;
|
|
39
|
+
// protected predicateAccount: Maybe<PredicateFactory> = null;
|
|
40
|
+
// protected subscriptions: Array<() => void> = [];
|
|
41
|
+
// protected hasProviderSucceeded = true;
|
|
42
|
+
// private _predicateVersions!: Array<PredicateFactory>;
|
|
43
|
+
// public abstract name: string;
|
|
44
|
+
// public abstract metadata: ConnectorMetadata;
|
|
45
|
+
// public abstract sendTransaction(
|
|
46
|
+
// address: string,
|
|
47
|
+
// transaction: TransactionRequestLike,
|
|
48
|
+
// ): Promise<string>;
|
|
49
|
+
// public abstract connect(): Promise<boolean>;
|
|
50
|
+
// public abstract disconnect(): Promise<boolean>;
|
|
51
|
+
// protected abstract configProviders(config: ConnectorConfig): MaybeAsync<void>;
|
|
52
|
+
// protected abstract getWalletAdapter(): any//PredicateWalletAdapter;
|
|
53
|
+
// protected abstract getPredicateVersions(): Record<string, PredicateVersion>;
|
|
54
|
+
// protected abstract getAccountAddress(): MaybeAsync<Maybe<string>>;
|
|
55
|
+
// protected abstract getProviders(): Promise<ProviderDictionary>;
|
|
56
|
+
// protected abstract requireConnection(): MaybeAsync<void>;
|
|
57
|
+
// protected abstract walletAccounts(): Promise<Array<string>>;
|
|
58
|
+
// abstract signMessageCustomCurve(
|
|
59
|
+
// _message: string,
|
|
60
|
+
// ): Promise<SignedMessageCustomCurve>;
|
|
61
|
+
// protected async emitAccountChange(
|
|
62
|
+
// address: string,
|
|
63
|
+
// connected = true,
|
|
64
|
+
// ): Promise<void> {
|
|
65
|
+
// await this.setupPredicate();
|
|
66
|
+
// this.emit(this.events.connection, connected);
|
|
67
|
+
// this.emit(
|
|
68
|
+
// this.events.currentAccount,
|
|
69
|
+
// this.predicateAccount?.getPredicateAddress(address),
|
|
70
|
+
// );
|
|
71
|
+
// this.emit(
|
|
72
|
+
// this.events.accounts,
|
|
73
|
+
// this.predicateAccount?.getPredicateAddresses(await this.walletAccounts()),
|
|
74
|
+
// );
|
|
75
|
+
// }
|
|
76
|
+
// protected get predicateVersions(): Array<PredicateFactory> {
|
|
77
|
+
// if (!this._predicateVersions) {
|
|
78
|
+
// this._predicateVersions = Object.entries(this.getPredicateVersions())
|
|
79
|
+
// .map(
|
|
80
|
+
// ([key, pred]) =>
|
|
81
|
+
// new PredicateFactory(
|
|
82
|
+
// this.getWalletAdapter(),
|
|
83
|
+
// pred.predicate,
|
|
84
|
+
// key,
|
|
85
|
+
// pred.generatedAt,
|
|
86
|
+
// ),
|
|
87
|
+
// )
|
|
88
|
+
// .sort((a, b) => a.sort(b));
|
|
89
|
+
// }
|
|
90
|
+
// return this._predicateVersions;
|
|
91
|
+
// }
|
|
92
|
+
// protected isAddressPredicate(b: BytesLike, walletAccount: string): boolean {
|
|
93
|
+
// return this.predicateVersions.some(
|
|
94
|
+
// (predicate) => predicate.getPredicateAddress(walletAccount) === b,
|
|
95
|
+
// );
|
|
96
|
+
// }
|
|
97
|
+
// protected async getCurrentUserPredicate(): Promise<Maybe<PredicateFactory>> {
|
|
98
|
+
// const oldFirstPredicateVersions = [...this.predicateVersions].reverse();
|
|
99
|
+
// for (const predicateInstance of oldFirstPredicateVersions) {
|
|
100
|
+
// const address = await this.getAccountAddress();
|
|
101
|
+
// if (!address) {
|
|
102
|
+
// continue;
|
|
103
|
+
// }
|
|
104
|
+
// const { fuelProvider } = await this.getProviders();
|
|
105
|
+
// const predicate = predicateInstance.build(address, fuelProvider, [1]);
|
|
106
|
+
// const balance = await predicate.getBalance();
|
|
107
|
+
// if (!balance.isZero()) {
|
|
108
|
+
// return predicateInstance;
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// return null;
|
|
112
|
+
// }
|
|
113
|
+
// protected getNewestPredicate(): Maybe<PredicateFactory> {
|
|
114
|
+
// return this.predicateVersions[0];
|
|
115
|
+
// }
|
|
116
|
+
// protected async setupPredicate(): Promise<PredicateFactory> {
|
|
117
|
+
// if (this.customPredicate?.abi && this.customPredicate?.bin) {
|
|
118
|
+
// this.predicateAccount = new PredicateFactory(
|
|
119
|
+
// this.getWalletAdapter(),
|
|
120
|
+
// this.customPredicate,
|
|
121
|
+
// 'custom',
|
|
122
|
+
// );
|
|
123
|
+
// this.predicateAddress = 'custom';
|
|
124
|
+
// return this.predicateAccount;
|
|
125
|
+
// }
|
|
126
|
+
// const predicate =
|
|
127
|
+
// (await this.getCurrentUserPredicate()) ?? this.getNewestPredicate();
|
|
128
|
+
// if (!predicate) throw new Error('No predicate found');
|
|
129
|
+
// this.predicateAddress = predicate.getRoot();
|
|
130
|
+
// this.predicateAccount = predicate;
|
|
131
|
+
// return this.predicateAccount;
|
|
132
|
+
// }
|
|
133
|
+
// protected subscribe(listener: () => void) {
|
|
134
|
+
// this.subscriptions.push(listener);
|
|
135
|
+
// }
|
|
136
|
+
// protected async prepareTransaction(
|
|
137
|
+
// address: string,
|
|
138
|
+
// transaction: TransactionRequestLike,
|
|
139
|
+
// ): Promise<PreparedTransaction> {
|
|
140
|
+
// if (!(await this.isConnected())) {
|
|
141
|
+
// throw Error('No connected accounts');
|
|
142
|
+
// }
|
|
143
|
+
// if (!this.predicateAccount) {
|
|
144
|
+
// throw Error('No predicate account found');
|
|
145
|
+
// }
|
|
146
|
+
// const b256Address = Address.fromDynamicInput(address).toString();
|
|
147
|
+
// const { fuelProvider } = await this.getProviders();
|
|
148
|
+
// const chainId = await fuelProvider.getChainId();
|
|
149
|
+
// const walletAccount = this.predicateAccount.getAccountAddress(
|
|
150
|
+
// b256Address,
|
|
151
|
+
// await this.walletAccounts(),
|
|
152
|
+
// );
|
|
153
|
+
// if (!walletAccount) {
|
|
154
|
+
// throw Error(`No account found for ${b256Address}`);
|
|
155
|
+
// }
|
|
156
|
+
// const transactionRequest = transactionRequestify(transaction);
|
|
157
|
+
// const transactionFee = transactionRequest.maxFee.toNumber();
|
|
158
|
+
// const predicateSignatureIndex = getMockedSignatureIndex(
|
|
159
|
+
// transactionRequest.witnesses,
|
|
160
|
+
// );
|
|
161
|
+
// // Create a predicate and set the witness index to call in predicate`
|
|
162
|
+
// const predicate = this.predicateAccount.build(walletAccount, fuelProvider, [
|
|
163
|
+
// predicateSignatureIndex,
|
|
164
|
+
// ]);
|
|
165
|
+
// predicate.connect(fuelProvider);
|
|
166
|
+
// // To each input of the request, attach the predicate and its data
|
|
167
|
+
// const requestWithPredicateAttached =
|
|
168
|
+
// predicate.populateTransactionPredicateData(transactionRequest);
|
|
169
|
+
// const maxGasUsed =
|
|
170
|
+
// await this.predicateAccount.getMaxPredicateGasUsed(fuelProvider);
|
|
171
|
+
// let predictedGasUsedPredicate = bn(0);
|
|
172
|
+
// requestWithPredicateAttached.inputs.forEach((input) => {
|
|
173
|
+
// if ('predicate' in input && input.predicate) {
|
|
174
|
+
// input.witnessIndex = 0;
|
|
175
|
+
// predictedGasUsedPredicate = predictedGasUsedPredicate.add(maxGasUsed);
|
|
176
|
+
// }
|
|
177
|
+
// });
|
|
178
|
+
// // Add a placeholder for the predicate signature to count on bytes measurement from start. It will be replaced later
|
|
179
|
+
// requestWithPredicateAttached.witnesses[predicateSignatureIndex] = concat([
|
|
180
|
+
// ZeroBytes32,
|
|
181
|
+
// ZeroBytes32,
|
|
182
|
+
// ]);
|
|
183
|
+
// const { gasPriceFactor } = predicate.provider.getGasConfig();
|
|
184
|
+
// const { maxFee, gasPrice } = await predicate.provider.estimateTxGasAndFee({
|
|
185
|
+
// transactionRequest: requestWithPredicateAttached,
|
|
186
|
+
// });
|
|
187
|
+
// const predicateSuccessFeeDiff = calculateGasFee({
|
|
188
|
+
// gas: predictedGasUsedPredicate,
|
|
189
|
+
// priceFactor: gasPriceFactor,
|
|
190
|
+
// gasPrice,
|
|
191
|
+
// });
|
|
192
|
+
// const feeWithFat = maxFee.add(predicateSuccessFeeDiff);
|
|
193
|
+
// const isNeededFatFee = feeWithFat.gt(transactionFee);
|
|
194
|
+
// if (isNeededFatFee) {
|
|
195
|
+
// // add more 10 just in case sdk fee estimation is not accurate
|
|
196
|
+
// requestWithPredicateAttached.maxFee = feeWithFat.add(10);
|
|
197
|
+
// }
|
|
198
|
+
// // Attach missing inputs (including estimated predicate gas usage) / outputs to the request
|
|
199
|
+
// await predicate.provider.estimateTxDependencies(
|
|
200
|
+
// requestWithPredicateAttached,
|
|
201
|
+
// );
|
|
202
|
+
// return {
|
|
203
|
+
// predicate,
|
|
204
|
+
// request: requestWithPredicateAttached,
|
|
205
|
+
// transactionId: requestWithPredicateAttached.getTransactionId(chainId),
|
|
206
|
+
// account: walletAccount,
|
|
207
|
+
// transactionRequest,
|
|
208
|
+
// };
|
|
209
|
+
// }
|
|
210
|
+
// public clearSubscriptions() {
|
|
211
|
+
// if (!this.subscriptions) {
|
|
212
|
+
// return;
|
|
213
|
+
// }
|
|
214
|
+
// this.subscriptions.forEach((listener) => listener());
|
|
215
|
+
// this.subscriptions = [];
|
|
216
|
+
// }
|
|
217
|
+
// public async ping(): Promise<boolean> {
|
|
218
|
+
// this.getProviders()
|
|
219
|
+
// .catch(() => {
|
|
220
|
+
// this.hasProviderSucceeded = false;
|
|
221
|
+
// })
|
|
222
|
+
// .then(() => {
|
|
223
|
+
// this.hasProviderSucceeded = true;
|
|
224
|
+
// });
|
|
225
|
+
// return this.hasProviderSucceeded;
|
|
226
|
+
// }
|
|
227
|
+
// public async version(): Promise<Version> {
|
|
228
|
+
// return { app: '0.0.0', network: '0.0.0' };
|
|
229
|
+
// }
|
|
230
|
+
// public async isConnected(): Promise<boolean> {
|
|
231
|
+
// await this.requireConnection();
|
|
232
|
+
// const accounts = await this.accounts();
|
|
233
|
+
// return accounts.length > 0;
|
|
234
|
+
// }
|
|
235
|
+
// public async accounts(): Promise<Array<string>> {
|
|
236
|
+
// if (!this.predicateAccount) {
|
|
237
|
+
// return [];
|
|
238
|
+
// }
|
|
239
|
+
// const accs = await this.walletAccounts();
|
|
240
|
+
// return this.predicateAccount.getPredicateAddresses(accs);
|
|
241
|
+
// }
|
|
242
|
+
// public async currentAccount(): Promise<string | null> {
|
|
243
|
+
// if (!(await this.isConnected())) {
|
|
244
|
+
// throw Error('No connected accounts');
|
|
245
|
+
// }
|
|
246
|
+
// if (!this.predicateAccount) {
|
|
247
|
+
// throw Error('No predicate account found');
|
|
248
|
+
// }
|
|
249
|
+
// const account = await this.getAccountAddress();
|
|
250
|
+
// return account ? this.predicateAccount.getPredicateAddress(account) : null;
|
|
251
|
+
// }
|
|
252
|
+
// public async networks(): Promise<Network[]> {
|
|
253
|
+
// return [await this.currentNetwork()];
|
|
254
|
+
// }
|
|
255
|
+
// public async currentNetwork(): Promise<Network> {
|
|
256
|
+
// const { fuelProvider } = await this.getProviders();
|
|
257
|
+
// const chainId = await fuelProvider.getChainId();
|
|
258
|
+
// return { url: fuelProvider.url, chainId: chainId };
|
|
259
|
+
// }
|
|
260
|
+
// public async signMessage(
|
|
261
|
+
// _address: string,
|
|
262
|
+
// _message: string,
|
|
263
|
+
// ): Promise<string> {
|
|
264
|
+
// throw new Error('A predicate account cannot sign messages');
|
|
265
|
+
// }
|
|
266
|
+
// public async addAssets(_assets: Asset[]): Promise<boolean> {
|
|
267
|
+
// throw new Error('Method not implemented.');
|
|
268
|
+
// }
|
|
269
|
+
// public async addAsset(_asset: Asset): Promise<boolean> {
|
|
270
|
+
// throw new Error('Method not implemented.');
|
|
271
|
+
// }
|
|
272
|
+
// public async assets(): Promise<Array<Asset>> {
|
|
273
|
+
// return [];
|
|
274
|
+
// }
|
|
275
|
+
// public async addNetwork(_networkUrl: string): Promise<boolean> {
|
|
276
|
+
// throw new Error('Method not implemented.');
|
|
277
|
+
// }
|
|
278
|
+
// public async selectNetwork(
|
|
279
|
+
// _network: SelectNetworkArguments,
|
|
280
|
+
// ): Promise<boolean> {
|
|
281
|
+
// throw new Error('Method not implemented.');
|
|
282
|
+
// }
|
|
283
|
+
// public async addAbi(_abiMap: AbiMap): Promise<boolean> {
|
|
284
|
+
// throw new Error('Method not implemented.');
|
|
285
|
+
// }
|
|
286
|
+
// public async getAbi(_contractId: string): Promise<JsonAbi> {
|
|
287
|
+
// throw Error('Cannot get contractId ABI for a predicate');
|
|
288
|
+
// }
|
|
289
|
+
// public async hasAbi(_contractId: string): Promise<boolean> {
|
|
290
|
+
// throw Error('A predicate account cannot have an ABI');
|
|
291
|
+
// }
|
|
292
|
+
// }
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type BytesLike } from 'fuels';
|
|
2
|
-
import type { PredicateWalletAdapter } from './PredicateWalletAdapter';
|
|
3
|
-
import type { Maybe, PredicateConfig } from './types';
|
|
4
|
-
export declare class PredicateFactory {
|
|
5
|
-
private abi;
|
|
6
|
-
private bytecode;
|
|
7
|
-
private adapter;
|
|
8
|
-
private root;
|
|
9
|
-
private generatedAt;
|
|
10
|
-
constructor(adapter: PredicateWalletAdapter, { abi, bin }: PredicateConfig, root: string, generatedAt?: number);
|
|
11
|
-
getRoot: () => string;
|
|
12
|
-
getPredicateAddress: any;
|
|
13
|
-
build: any;
|
|
14
|
-
getAccountAddress: (address: string, accounts?: Array<string>) => Maybe<string>;
|
|
15
|
-
getPredicateAddresses: (accounts?: Array<string>) => Array<string>;
|
|
16
|
-
getMaxPredicateGasUsed: any;
|
|
17
|
-
equals: (predicate: Maybe<PredicateFactory>) => boolean;
|
|
18
|
-
sort: (predicate: PredicateFactory) => number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Since the predicate resources were fetched and added to the TransactionRequest before the predicate
|
|
22
|
-
* was instantiated, it is very likely that they were fetched and added as normal account resources,
|
|
23
|
-
* resulting in a witness placeholder being added to the witnesses of the TransactionRequest to
|
|
24
|
-
* later be replaced with an actual signature. Since predicate resources do not require a signature,
|
|
25
|
-
* this placeholder witness will be removed when calling `Predicate.populateTransactionPredicateData`.
|
|
26
|
-
* However, we need to validate if this placeholder witness was added here in order to instantiate the
|
|
27
|
-
* predicate with the correct witness index argument.
|
|
28
|
-
*/
|
|
29
|
-
export declare const getMockedSignatureIndex: (witnesses: BytesLike[]) => number;
|