@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,29 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
|
-
import { FQ } from "./field";
|
|
3
|
-
import { Point } from "./jubjub";
|
|
4
|
-
export declare class Signature {
|
|
5
|
-
R: Point;
|
|
6
|
-
s: FQ;
|
|
7
|
-
constructor(R: Point, s: FQ);
|
|
8
|
-
toStr(): string;
|
|
9
|
-
}
|
|
10
|
-
export declare class SignedMessage {
|
|
11
|
-
A: Point;
|
|
12
|
-
sig: Signature;
|
|
13
|
-
msg: BigNumber;
|
|
14
|
-
constructor(A: Point, sig: Signature, msg: BigNumber);
|
|
15
|
-
toStr(): string;
|
|
16
|
-
}
|
|
17
|
-
export declare class SignatureScheme {
|
|
18
|
-
static to_bytes(arg: BigNumber): number[];
|
|
19
|
-
static prehash_message(M: BigNumber): BigNumber;
|
|
20
|
-
static hash_secret_python(k: FQ, arg: BigNumber): BigNumber;
|
|
21
|
-
static B(): Point;
|
|
22
|
-
static sign(msg: BigNumber, key: FQ, B: Point): SignedMessage;
|
|
23
|
-
static as_scalar(point: Point): BigNumber[];
|
|
24
|
-
static hash_public(R: Point, A: Point, M: BigNumber): any;
|
|
25
|
-
}
|
|
26
|
-
export declare function bnToBuf(bn: string): number[];
|
|
27
|
-
export declare function bnToBufWithFixedLength(bn: string, outputLength: number): number[];
|
|
28
|
-
export declare function bufToBn(buf: any): bigint;
|
|
29
|
-
export declare function bytesToHexString(bytes: any): any;
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Implements Pure-EdDSA and Hash-EdDSA
|
|
3
|
-
|
|
4
|
-
The signer has two secret values:
|
|
5
|
-
|
|
6
|
-
* k = Secret key
|
|
7
|
-
* r = Per-(message,key) nonce
|
|
8
|
-
|
|
9
|
-
The signer provides a signature consiting of two values:
|
|
10
|
-
|
|
11
|
-
* R = Point, image of `r*B`
|
|
12
|
-
* s = Image of `r + (k*t)`
|
|
13
|
-
|
|
14
|
-
The signer provides the verifier with their public key:
|
|
15
|
-
|
|
16
|
-
* A = k*B
|
|
17
|
-
|
|
18
|
-
Both the verifier and the signer calculate the common reference string:
|
|
19
|
-
|
|
20
|
-
* t = H(R, A, M)
|
|
21
|
-
|
|
22
|
-
The nonce `r` is secret, and protects the value `s` from revealing the
|
|
23
|
-
signers secret key.
|
|
24
|
-
|
|
25
|
-
For Hash-EdDSA, the message `M` is compressed before H(R,A,M)
|
|
26
|
-
|
|
27
|
-
For further information see: https://ed2519.cr.yp.to/eddsa-20150704.pdf
|
|
28
|
-
*/
|
|
29
|
-
import { BigNumber } from "ethers";
|
|
30
|
-
import { field, FQ } from "./field";
|
|
31
|
-
import { jubjub, Point } from "./jubjub";
|
|
32
|
-
import { sha512 } from "js-sha512";
|
|
33
|
-
import { permunation, PoseidonParams } from "./permutation";
|
|
34
|
-
export class Signature {
|
|
35
|
-
constructor(R, s) {
|
|
36
|
-
this.R = R;
|
|
37
|
-
this.s = s;
|
|
38
|
-
}
|
|
39
|
-
toStr() {
|
|
40
|
-
return `${this.R.x.n} ${this.R.y.n} ${this.s.n}`;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export class SignedMessage {
|
|
44
|
-
constructor(A, sig, msg) {
|
|
45
|
-
this.A = A;
|
|
46
|
-
this.sig = sig;
|
|
47
|
-
this.msg = msg;
|
|
48
|
-
}
|
|
49
|
-
toStr() {
|
|
50
|
-
return `${this.A.x.n} ${this.A.y.n} ${this.sig.toStr()} ${this.msg.toString()}`;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export class SignatureScheme {
|
|
54
|
-
static to_bytes(arg) {
|
|
55
|
-
const outputLength = 32;
|
|
56
|
-
let bitIntDataItems = bnToBuf(arg.toString());
|
|
57
|
-
const more = outputLength - bitIntDataItems.length;
|
|
58
|
-
if (more > 0) {
|
|
59
|
-
for (let i = 0; i < more; i++) {
|
|
60
|
-
bitIntDataItems = [0].concat(bitIntDataItems);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
bitIntDataItems = bitIntDataItems.slice(0, outputLength);
|
|
65
|
-
}
|
|
66
|
-
bitIntDataItems = bitIntDataItems.reverse();
|
|
67
|
-
return bitIntDataItems;
|
|
68
|
-
}
|
|
69
|
-
/*
|
|
70
|
-
Identity function for message
|
|
71
|
-
|
|
72
|
-
Can be used to truncate the message before hashing it
|
|
73
|
-
as part of the public parameters.
|
|
74
|
-
*/
|
|
75
|
-
static prehash_message(M) {
|
|
76
|
-
return M;
|
|
77
|
-
}
|
|
78
|
-
/*
|
|
79
|
-
Hash the key and message to create `r`, the blinding factor for this signature.
|
|
80
|
-
|
|
81
|
-
If the same `r` value is used more than once, the key for the signature is revealed.
|
|
82
|
-
|
|
83
|
-
From: https://eprint.iacr.org/2015/677.pdf (EdDSA for more curves)
|
|
84
|
-
|
|
85
|
-
Page 3:
|
|
86
|
-
|
|
87
|
-
(Implementation detail: To save time in the computation of `rB`, the signer
|
|
88
|
-
can replace `r` with `r mod L` before computing `rB`.)
|
|
89
|
-
*/
|
|
90
|
-
static hash_secret_python(k, arg) {
|
|
91
|
-
const byteArray0 = this.to_bytes(k.n);
|
|
92
|
-
const byteArray1 = this.to_bytes(arg);
|
|
93
|
-
const sum = byteArray0.concat(byteArray1);
|
|
94
|
-
const digest1 = sha512.array(new Uint8Array(sum).buffer);
|
|
95
|
-
let sha512StrItems;
|
|
96
|
-
for (let i = 0; i < digest1.length; i++) {
|
|
97
|
-
const itemInt = digest1[i];
|
|
98
|
-
let st = itemInt.toString(16);
|
|
99
|
-
if (st.length == 1) {
|
|
100
|
-
st = "0" + st;
|
|
101
|
-
}
|
|
102
|
-
sha512StrItems = [st].concat(sha512StrItems);
|
|
103
|
-
}
|
|
104
|
-
const sha512MessageHexStr = sha512StrItems.join("");
|
|
105
|
-
const sha512MessageHexStrBigInt = BigNumber.from("0x" + sha512MessageHexStr);
|
|
106
|
-
const hashed = sha512MessageHexStrBigInt.mod(jubjub.JUBJUB_L);
|
|
107
|
-
return hashed;
|
|
108
|
-
}
|
|
109
|
-
static B() {
|
|
110
|
-
return Point.generate();
|
|
111
|
-
}
|
|
112
|
-
static sign(msg, key, B) {
|
|
113
|
-
const copyKey = new FQ(key.n, key.m);
|
|
114
|
-
const A = B.mul(copyKey.n);
|
|
115
|
-
const M = this.prehash_message(msg);
|
|
116
|
-
const r = this.hash_secret_python(key, M);
|
|
117
|
-
const copy_r = BigNumber.from(r.toString());
|
|
118
|
-
const R = B.mul(copy_r);
|
|
119
|
-
const t = this.hash_public(R, A, M);
|
|
120
|
-
const t_c = t;
|
|
121
|
-
const key_n_t = key.n.mul(t_c);
|
|
122
|
-
const left = r.add(key_n_t);
|
|
123
|
-
const S = left.mod(jubjub.JUBJUB_E);
|
|
124
|
-
const signatureResult = new Signature(R, new FQ(S));
|
|
125
|
-
const signedMessage = new SignedMessage(A, signatureResult, msg);
|
|
126
|
-
return signedMessage;
|
|
127
|
-
}
|
|
128
|
-
static as_scalar(point) {
|
|
129
|
-
return [point.x.n, point.y.n];
|
|
130
|
-
}
|
|
131
|
-
static hash_public(R, A, M) {
|
|
132
|
-
let inputMsg;
|
|
133
|
-
inputMsg = this.as_scalar(R).concat(this.as_scalar(A)).concat([M]);
|
|
134
|
-
const params = new PoseidonParams(field.SNARK_SCALAR_FIELD, 6, 6, 52, "poseidon", BigNumber.from(5), null, null, 128);
|
|
135
|
-
const result = permunation.poseidon(inputMsg, params);
|
|
136
|
-
return result;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
export function bnToBuf(bn) {
|
|
140
|
-
let hex = BigInt(bn).toString(16);
|
|
141
|
-
if (hex.length % 2) {
|
|
142
|
-
hex = "0" + hex;
|
|
143
|
-
}
|
|
144
|
-
const len = hex.length / 2;
|
|
145
|
-
const u8 = new Uint8Array(len);
|
|
146
|
-
let i = 0;
|
|
147
|
-
let j = 0;
|
|
148
|
-
while (i < len) {
|
|
149
|
-
u8[i] = parseInt(hex.slice(j, j + 2), 16);
|
|
150
|
-
i += 1;
|
|
151
|
-
j += 2;
|
|
152
|
-
}
|
|
153
|
-
return Array.from(u8);
|
|
154
|
-
}
|
|
155
|
-
export function bnToBufWithFixedLength(bn, outputLength) {
|
|
156
|
-
let hex = BigInt(bn).toString(16);
|
|
157
|
-
if (hex.length % 2) {
|
|
158
|
-
hex = "0" + hex;
|
|
159
|
-
}
|
|
160
|
-
const len = hex.length / 2;
|
|
161
|
-
const u8 = new Uint8Array(len);
|
|
162
|
-
let i = 0;
|
|
163
|
-
let j = 0;
|
|
164
|
-
while (i < len) {
|
|
165
|
-
u8[i] = parseInt(hex.slice(j, j + 2), 16);
|
|
166
|
-
i += 1;
|
|
167
|
-
j += 2;
|
|
168
|
-
}
|
|
169
|
-
let bitIntDataItems = Array.from(u8);
|
|
170
|
-
const more = outputLength - bitIntDataItems.length;
|
|
171
|
-
if (more > 0) {
|
|
172
|
-
for (let i = 0; i < more; i++) {
|
|
173
|
-
bitIntDataItems = [0].concat(bitIntDataItems);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
bitIntDataItems = bitIntDataItems.slice(0, outputLength);
|
|
178
|
-
}
|
|
179
|
-
return bitIntDataItems;
|
|
180
|
-
}
|
|
181
|
-
export function bufToBn(buf) {
|
|
182
|
-
let hex;
|
|
183
|
-
hex = [];
|
|
184
|
-
const u8 = Uint8Array.from(buf);
|
|
185
|
-
u8.forEach(function (i) {
|
|
186
|
-
let h = i.toString(16);
|
|
187
|
-
if (h.length % 2) {
|
|
188
|
-
h = "0" + h;
|
|
189
|
-
}
|
|
190
|
-
hex.push(h);
|
|
191
|
-
});
|
|
192
|
-
return BigInt("0x" + hex.join(""));
|
|
193
|
-
}
|
|
194
|
-
export function bytesToHexString(bytes) {
|
|
195
|
-
let strItems;
|
|
196
|
-
strItems = [];
|
|
197
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
198
|
-
const item = bytes[i];
|
|
199
|
-
let st = item.toString(16);
|
|
200
|
-
if (st.length == 1) {
|
|
201
|
-
st = "0" + st;
|
|
202
|
-
}
|
|
203
|
-
// st = st.toUpperCase()
|
|
204
|
-
strItems.push(st);
|
|
205
|
-
}
|
|
206
|
-
const strItemsJoined = strItems.join("");
|
|
207
|
-
return strItemsJoined;
|
|
208
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
|
-
export declare class field {
|
|
3
|
-
static SNARK_SCALAR_FIELD: BigNumber;
|
|
4
|
-
static FR_ORDER: BigNumber;
|
|
5
|
-
}
|
|
6
|
-
export declare class FQ {
|
|
7
|
-
m: BigNumber;
|
|
8
|
-
n: BigNumber;
|
|
9
|
-
constructor(n: BigNumber, field_modulus?: BigNumber);
|
|
10
|
-
add(other: BigNumber): FQ;
|
|
11
|
-
mul(other: BigNumber): FQ;
|
|
12
|
-
sub(other: BigNumber): FQ;
|
|
13
|
-
div(other: BigNumber): FQ;
|
|
14
|
-
static one(modulus?: BigNumber): FQ;
|
|
15
|
-
static zero(modulus?: BigNumber): FQ;
|
|
16
|
-
}
|
|
17
|
-
export declare function modulo(n: BigNumber, p: BigNumber, m: BigNumber): BigNumber;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
|
-
import { BigInteger } from "jsbn";
|
|
3
|
-
export class field {
|
|
4
|
-
}
|
|
5
|
-
// Fq is the base field of Jubjub
|
|
6
|
-
field.SNARK_SCALAR_FIELD = BigNumber.from("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
7
|
-
// Fr is the scalar field of Jubjub
|
|
8
|
-
field.FR_ORDER = BigNumber.from("21888242871839275222246405745257275088614511777268538073601725287587578984328");
|
|
9
|
-
// A class for field elements in FQ. Wrap a number in this class,
|
|
10
|
-
// and it becomes a field element.
|
|
11
|
-
export class FQ {
|
|
12
|
-
constructor(n, field_modulus = field.SNARK_SCALAR_FIELD) {
|
|
13
|
-
this.m = field_modulus;
|
|
14
|
-
this.n = n.mod(this.m);
|
|
15
|
-
}
|
|
16
|
-
//
|
|
17
|
-
// Use this.n as other
|
|
18
|
-
//
|
|
19
|
-
add(other) {
|
|
20
|
-
const on = other;
|
|
21
|
-
const n = (this.n.add(on)).mod(this.m);
|
|
22
|
-
return new FQ(n, this.m);
|
|
23
|
-
}
|
|
24
|
-
mul(other) {
|
|
25
|
-
const on = other;
|
|
26
|
-
const n = this.n.mul(on).mod(this.m);
|
|
27
|
-
return new FQ(n, this.m);
|
|
28
|
-
}
|
|
29
|
-
sub(other) {
|
|
30
|
-
const on = other;
|
|
31
|
-
let new_n;
|
|
32
|
-
if (this.n.gte(on)) {
|
|
33
|
-
new_n = (this.n.sub(on)).mod(this.m);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
new_n = (this.n.sub(on).add(this.m)).mod(this.m);
|
|
37
|
-
}
|
|
38
|
-
return new FQ(new_n, this.m);
|
|
39
|
-
}
|
|
40
|
-
div(other) {
|
|
41
|
-
const on_c = other;
|
|
42
|
-
const m_c = this.m;
|
|
43
|
-
const two_c = BigNumber.from("2");
|
|
44
|
-
const on_power_c = modulo(on_c, m_c.sub(two_c), m_c);
|
|
45
|
-
const n_on_power_remainder = this.n.mul(on_power_c).mod(this.m);
|
|
46
|
-
return new FQ(n_on_power_remainder, this.m);
|
|
47
|
-
}
|
|
48
|
-
static one(modulus = field.SNARK_SCALAR_FIELD) {
|
|
49
|
-
return new FQ(BigNumber.from("1"), modulus);
|
|
50
|
-
}
|
|
51
|
-
static zero(modulus = field.SNARK_SCALAR_FIELD) {
|
|
52
|
-
return new FQ(BigNumber.from("0"), modulus);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
export function modulo(n, p, m) {
|
|
56
|
-
const n_ = new BigInteger(n.toString());
|
|
57
|
-
const p_ = new BigInteger(p.toString());
|
|
58
|
-
const m_ = new BigInteger(m.toString());
|
|
59
|
-
const result = n_.modPow(p_, m_);
|
|
60
|
-
return BigNumber.from(result.toString());
|
|
61
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import * as ethUtil from 'ethereumjs-util';
|
|
2
|
-
import BN from 'bn.js';
|
|
3
|
-
import BigNumber from 'bignumber.js';
|
|
4
|
-
import { Buffer } from 'buffer';
|
|
5
|
-
import { AmmPoolInfoV3, LoopringMap, MarketInfo, TokenInfo, TOKENMAPLIST, TokenRelatedInfo, DefiMarketInfo } from './defs';
|
|
6
|
-
/**
|
|
7
|
-
* Returns hex string with '0x' prefix
|
|
8
|
-
* @param input
|
|
9
|
-
* @returns {string}
|
|
10
|
-
*/
|
|
11
|
-
export declare function addHexPrefix(input: any): string;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param mixed Buffer|number|string (hex string must be with '0x' prefix)
|
|
15
|
-
* @returns {Buffer}
|
|
16
|
-
*/
|
|
17
|
-
export declare function toBuffer(mixed: any): Buffer;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param num number|string (hex string must be with '0x' prefix)
|
|
21
|
-
* @param places number of zeros to pad
|
|
22
|
-
* @returns {Buffer}
|
|
23
|
-
*/
|
|
24
|
-
export declare function zeroPad(num: any, places: any): Buffer<ArrayBufferLike>;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param mixed number | BigNumber | BN | Buffer | string | Uint8Array
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
export declare function toHex(mixed: number | BigNumber | BN | Buffer | string | Uint8Array | BigInt): string;
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param mixed number | BigNumber | BN | Buffer | string | Uint8Array
|
|
34
|
-
* @returns {number}
|
|
35
|
-
*/
|
|
36
|
-
export declare function toNumber(mixed: number | BigNumber | BN | Buffer | string | Uint8Array): number;
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param mixed number | BigNumber | BN | Buffer | string | Uint8Array
|
|
40
|
-
* @returns {BigNumber}
|
|
41
|
-
*/
|
|
42
|
-
export declare function toBig(mixed: number | BigNumber | BN | Buffer | string | Uint8Array): BigNumber;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param mixed number | BigNumber | BN | Buffer | string
|
|
46
|
-
* @returns {BN}
|
|
47
|
-
*/
|
|
48
|
-
export declare function toBN(mixed: any): ethUtil.BN;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
* @param value number | BigNumber | Buffer | string
|
|
52
|
-
* @returns {BN}
|
|
53
|
-
*/
|
|
54
|
-
export declare function fromGWEI(value: any): BigNumber;
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
57
|
-
* @param value number | BigNumber | Buffer | string
|
|
58
|
-
* @returns {BN}
|
|
59
|
-
*/
|
|
60
|
-
export declare function toGWEI(value: any): BigNumber;
|
|
61
|
-
/**
|
|
62
|
-
* Returns formatted hex string of a given private key
|
|
63
|
-
* @param mixed Buffer | string | Uint8Array
|
|
64
|
-
* @returns {string}
|
|
65
|
-
*/
|
|
66
|
-
export declare function formatKey(mixed: Buffer | string | Uint8Array): string;
|
|
67
|
-
/**
|
|
68
|
-
* Returns hex string of a given address
|
|
69
|
-
* @param mixed Buffer | string |Uint8Array
|
|
70
|
-
* @returns {string}
|
|
71
|
-
*/
|
|
72
|
-
export declare function formatAddress(mixed: Buffer | string | Uint8Array): string;
|
|
73
|
-
/**
|
|
74
|
-
* Returns hex string without '0x' prefix
|
|
75
|
-
* @param input string
|
|
76
|
-
* @returns {string}
|
|
77
|
-
*/
|
|
78
|
-
export declare function clearHexPrefix(input: any): string;
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
* @param hex
|
|
82
|
-
* @returns {string}
|
|
83
|
-
*/
|
|
84
|
-
export declare function padLeftEven(hex: any): any;
|
|
85
|
-
/**
|
|
86
|
-
* Returns symbol of a given kind of currency
|
|
87
|
-
* @param settingsCurrency
|
|
88
|
-
* @returns {*}
|
|
89
|
-
*/
|
|
90
|
-
export declare function getDisplaySymbol(settingsCurrency: any): "" | "¥" | "$";
|
|
91
|
-
/**
|
|
92
|
-
* Returns number in string with a given precision
|
|
93
|
-
* @param number number | BigNumber
|
|
94
|
-
* @param precision number
|
|
95
|
-
* @param ceil bool round up
|
|
96
|
-
* @returns {string}
|
|
97
|
-
*/
|
|
98
|
-
export declare function toFixed(number: any, precision: any, ceil: any): string;
|
|
99
|
-
export declare function formatEddsaKey(key: any): string;
|
|
100
|
-
/**
|
|
101
|
-
* Returns a number with commas as thousands separators
|
|
102
|
-
* @param number number
|
|
103
|
-
* @returns {*}
|
|
104
|
-
*/
|
|
105
|
-
export declare function numberWithCommas(number: any): any;
|
|
106
|
-
export declare function sortObjDictionary(obj: {
|
|
107
|
-
[key: string]: any;
|
|
108
|
-
}): Map<string, any>;
|
|
109
|
-
export declare function makeMarket<R extends TokenInfo = TokenInfo>(raw_data: R[]): TOKENMAPLIST;
|
|
110
|
-
export declare function makeAmmPool<R>(raw_data: any): {
|
|
111
|
-
ammpools: LoopringMap<AmmPoolInfoV3>;
|
|
112
|
-
pairs: LoopringMap<TokenRelatedInfo>;
|
|
113
|
-
};
|
|
114
|
-
export declare function makeMarkets<R, C extends MarketInfo>(raw_data: any, url?: string): {
|
|
115
|
-
markets: LoopringMap<C>;
|
|
116
|
-
pairs: LoopringMap<TokenRelatedInfo>;
|
|
117
|
-
tokenArr: string[];
|
|
118
|
-
tokenArrStr: string;
|
|
119
|
-
marketArr: string[];
|
|
120
|
-
marketArrStr: string;
|
|
121
|
-
};
|
|
122
|
-
export declare function makeMarketsWithIdIndex<C extends MarketInfo>(raw_data: any, url: string | undefined, idIndex: any): {
|
|
123
|
-
markets: LoopringMap<C>;
|
|
124
|
-
pairs: LoopringMap<TokenRelatedInfo>;
|
|
125
|
-
tokenArr: string[];
|
|
126
|
-
tokenArrStr: string;
|
|
127
|
-
marketArr: string[];
|
|
128
|
-
marketArrStr: string;
|
|
129
|
-
};
|
|
130
|
-
export declare function makeInvestMarkets<C extends DefiMarketInfo>(raw_data: any, types?: string[]): {
|
|
131
|
-
markets: LoopringMap<C>;
|
|
132
|
-
pairs: LoopringMap<TokenRelatedInfo>;
|
|
133
|
-
tokenArr: string[];
|
|
134
|
-
tokenArrStr: string;
|
|
135
|
-
marketArr: string[];
|
|
136
|
-
marketArrStr: string;
|
|
137
|
-
};
|