@kynesyslabs/demosdk 2.3.1-8.1 → 2.3.1-8.2
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/build/abstraction/CoinFinder.js +67 -0
- package/build/abstraction/CoinFinder.js.map +1 -0
- package/build/abstraction/EvmCoinFinder.js +280 -0
- package/build/abstraction/EvmCoinFinder.js.map +1 -0
- package/build/abstraction/Identities.d.ts +9 -9
- package/build/abstraction/Identities.js +348 -0
- package/build/abstraction/Identities.js.map +1 -0
- package/build/abstraction/index.d.ts +1 -1
- package/build/abstraction/index.js +16 -1
- package/build/abstraction/index.js.map +1 -0
- package/build/abstraction/providers/AbstractionProviders.js +65 -0
- package/build/abstraction/providers/AbstractionProviders.js.map +1 -0
- package/build/abstraction/providers/CoinAddresses.js +232 -0
- package/build/abstraction/providers/CoinAddresses.js.map +1 -0
- package/build/abstraction/providers/Providers.js +22 -0
- package/build/abstraction/providers/Providers.js.map +1 -0
- package/build/abstraction/providers/evm/ankr.js +36 -0
- package/build/abstraction/providers/evm/ankr.js.map +1 -0
- package/build/abstraction/providers/evm/arbitrum.js +23 -0
- package/build/abstraction/providers/evm/arbitrum.js.map +1 -0
- package/build/abstraction/providers/evm/bsc.js +27 -0
- package/build/abstraction/providers/evm/bsc.js.map +1 -0
- package/build/abstraction/providers/evm/ethereum.js +32 -0
- package/build/abstraction/providers/evm/ethereum.js.map +1 -0
- package/build/abstraction/providers/evm/index.js +15 -0
- package/build/abstraction/providers/evm/index.js.map +1 -0
- package/build/abstraction/providers/evm/optimism.js +27 -0
- package/build/abstraction/providers/evm/optimism.js.map +1 -0
- package/build/abstraction/providers/index.js +10 -0
- package/build/abstraction/providers/index.js.map +1 -0
- package/build/abstraction/providers/non-evm/bitcoin.js +23 -0
- package/build/abstraction/providers/non-evm/bitcoin.js.map +1 -0
- package/build/abstraction/providers/non-evm/index.js +15 -0
- package/build/abstraction/providers/non-evm/index.js.map +1 -0
- package/build/abstraction/providers/non-evm/multiversx.js +23 -0
- package/build/abstraction/providers/non-evm/multiversx.js.map +1 -0
- package/build/abstraction/providers/non-evm/solana.js +24 -0
- package/build/abstraction/providers/non-evm/solana.js.map +1 -0
- package/build/abstraction/providers/non-evm/xrp.js +23 -0
- package/build/abstraction/providers/non-evm/xrp.js.map +1 -0
- package/build/bridge/index.d.ts +2 -2
- package/build/bridge/index.js +27 -1
- package/build/bridge/index.js.map +1 -0
- package/build/bridge/nativeBridge.d.ts +3 -3
- package/build/bridge/nativeBridge.js +108 -0
- package/build/bridge/nativeBridge.js.map +1 -0
- package/build/bridge/nativeBridgeTypes.js +35 -0
- package/build/bridge/nativeBridgeTypes.js.map +1 -0
- package/build/bridge/rubicBridge.d.ts +3 -3
- package/build/bridge/rubicBridge.js +45 -0
- package/build/bridge/rubicBridge.js.map +1 -0
- package/build/demoswork/executor/index.js +21 -0
- package/build/demoswork/executor/index.js.map +1 -0
- package/build/demoswork/executor/stepexecutor.js +53 -0
- package/build/demoswork/executor/stepexecutor.js.map +1 -0
- package/build/demoswork/index.js +27 -1
- package/build/demoswork/index.js.map +1 -0
- package/build/demoswork/operations/baseoperation.d.ts +1 -1
- package/build/demoswork/operations/baseoperation.js +29 -0
- package/build/demoswork/operations/baseoperation.js.map +1 -0
- package/build/demoswork/operations/conditional/condition.d.ts +5 -5
- package/build/demoswork/operations/conditional/condition.js +54 -0
- package/build/demoswork/operations/conditional/condition.js.map +1 -0
- package/build/demoswork/operations/conditional/index.d.ts +4 -4
- package/build/demoswork/operations/conditional/index.js +110 -0
- package/build/demoswork/operations/conditional/index.js.map +1 -0
- package/build/demoswork/operations/index.d.ts +2 -2
- package/build/demoswork/operations/index.js +65 -0
- package/build/demoswork/operations/index.js.map +1 -0
- package/build/demoswork/utils/createTestWorkScript.d.ts +1 -1
- package/build/demoswork/utils/createTestWorkScript.js +64 -0
- package/build/demoswork/utils/createTestWorkScript.js.map +1 -0
- package/build/demoswork/utils/index.js +61 -0
- package/build/demoswork/utils/index.js.map +1 -0
- package/build/demoswork/validator/index.d.ts +1 -1
- package/build/demoswork/validator/index.js +43 -0
- package/build/demoswork/validator/index.js.map +1 -0
- package/build/demoswork/validator/steps.validator.d.ts +1 -1
- package/build/demoswork/validator/steps.validator.js +77 -0
- package/build/demoswork/validator/steps.validator.js.map +1 -0
- package/build/demoswork/work.d.ts +3 -3
- package/build/demoswork/work.js +77 -0
- package/build/demoswork/work.js.map +1 -0
- package/build/demoswork/workstep.d.ts +3 -3
- package/build/demoswork/workstep.js +88 -0
- package/build/demoswork/workstep.js.map +1 -0
- package/build/encryption/Cryptography.js +271 -0
- package/build/encryption/Cryptography.js.map +1 -0
- package/build/encryption/FHE/index.js +28 -0
- package/build/encryption/FHE/index.js.map +1 -0
- package/build/encryption/Hashing.js +30 -0
- package/build/encryption/Hashing.js.map +1 -0
- package/build/encryption/PQC/enigma.js +249 -0
- package/build/encryption/PQC/enigma.js.map +1 -0
- package/build/encryption/PQC/falconts/falcon.js +228 -0
- package/build/encryption/PQC/falconts/falcon.js.map +1 -0
- package/build/encryption/PQC/falconts/index.js +19 -0
- package/build/encryption/PQC/falconts/index.js.map +1 -0
- package/build/encryption/PQC/falconts/mnemonic.js +109 -0
- package/build/encryption/PQC/falconts/mnemonic.js.map +1 -0
- package/build/encryption/PQC/falconts/wordlist.js +216 -0
- package/build/encryption/PQC/falconts/wordlist.js.map +1 -0
- package/build/encryption/PQC/utils.js +16 -0
- package/build/encryption/PQC/utils.js.map +1 -0
- package/build/encryption/index.js +51 -1
- package/build/encryption/index.js.map +1 -0
- package/build/encryption/unifiedCrypto.d.ts +1 -1
- package/build/encryption/unifiedCrypto.js +409 -0
- package/build/encryption/unifiedCrypto.js.map +1 -0
- package/build/encryption/zK/index.js +38 -0
- package/build/encryption/zK/index.js.map +1 -0
- package/build/encryption/zK/interactive/index.js +43 -0
- package/build/encryption/zK/interactive/index.js.map +1 -0
- package/build/encryption/zK/primer.js +69 -0
- package/build/encryption/zK/primer.js.map +1 -0
- package/build/index.d.ts +0 -14
- package/build/index.js +20 -1
- package/build/index.js.map +1 -0
- package/build/instant_messaging/index.js +675 -0
- package/build/instant_messaging/index.js.map +1 -0
- package/build/l2ps/index.js +9 -1
- package/build/l2ps/index.js.map +1 -0
- package/build/l2ps/l2ps.d.ts +1 -1
- package/build/l2ps/l2ps.js +312 -0
- package/build/l2ps/l2ps.js.map +1 -0
- package/build/multichain/core/aptos.d.ts +1 -1
- package/build/multichain/core/aptos.js +554 -0
- package/build/multichain/core/aptos.js.map +1 -0
- package/build/multichain/core/btc.d.ts +2 -2
- package/build/multichain/core/btc.js +409 -0
- package/build/multichain/core/btc.js.map +1 -0
- package/build/multichain/core/evm.js +359 -0
- package/build/multichain/core/evm.js.map +1 -0
- package/build/multichain/core/ibc.js +269 -0
- package/build/multichain/core/ibc.js.map +1 -0
- package/build/multichain/core/index.js +29 -1
- package/build/multichain/core/index.js.map +1 -0
- package/build/multichain/core/multiversx.d.ts +1 -1
- package/build/multichain/core/multiversx.js +173 -0
- package/build/multichain/core/multiversx.js.map +1 -0
- package/build/multichain/core/near.js +214 -0
- package/build/multichain/core/near.js.map +1 -0
- package/build/multichain/core/solana.js +246 -0
- package/build/multichain/core/solana.js.map +1 -0
- package/build/multichain/core/ten.js +142 -0
- package/build/multichain/core/ten.js.map +1 -0
- package/build/multichain/core/ton.js +142 -0
- package/build/multichain/core/ton.js.map +1 -0
- package/build/multichain/core/types/SolanaPhantomProvider.js +5 -0
- package/build/multichain/core/types/SolanaPhantomProvider.js.map +1 -0
- package/build/multichain/core/types/defaultChain.js +83 -0
- package/build/multichain/core/types/defaultChain.js.map +1 -0
- package/build/multichain/core/types/interfaces.js +9 -0
- package/build/multichain/core/types/interfaces.js.map +1 -0
- package/build/multichain/core/utils.js +21 -0
- package/build/multichain/core/utils.js.map +1 -0
- package/build/multichain/core/xrp.d.ts +1 -1
- package/build/multichain/core/xrp.js +191 -0
- package/build/multichain/core/xrp.js.map +1 -0
- package/build/multichain/index.js +40 -0
- package/build/multichain/index.js.map +1 -0
- package/build/multichain/localsdk/aptos.js +192 -0
- package/build/multichain/localsdk/aptos.js.map +1 -0
- package/build/multichain/localsdk/btc.d.ts +1 -1
- package/build/multichain/localsdk/btc.js +89 -0
- package/build/multichain/localsdk/btc.js.map +1 -0
- package/build/multichain/localsdk/evm.d.ts +1 -1
- package/build/multichain/localsdk/evm.js +59 -0
- package/build/multichain/localsdk/evm.js.map +1 -0
- package/build/multichain/localsdk/ibc.d.ts +1 -1
- package/build/multichain/localsdk/ibc.js +26 -0
- package/build/multichain/localsdk/ibc.js.map +1 -0
- package/build/multichain/localsdk/index.js +22 -1
- package/build/multichain/localsdk/index.js.map +1 -0
- package/build/multichain/localsdk/multiversx.d.ts +1 -1
- package/build/multichain/localsdk/multiversx.js +52 -0
- package/build/multichain/localsdk/multiversx.js.map +1 -0
- package/build/multichain/localsdk/near.js +34 -0
- package/build/multichain/localsdk/near.js.map +1 -0
- package/build/multichain/localsdk/solana.js +32 -0
- package/build/multichain/localsdk/solana.js.map +1 -0
- package/build/multichain/localsdk/ten.js +66 -0
- package/build/multichain/localsdk/ten.js.map +1 -0
- package/build/multichain/localsdk/ton.d.ts +1 -1
- package/build/multichain/localsdk/ton.js +34 -0
- package/build/multichain/localsdk/ton.js.map +1 -0
- package/build/multichain/localsdk/xrp.d.ts +1 -1
- package/build/multichain/localsdk/xrp.js +88 -0
- package/build/multichain/localsdk/xrp.js.map +1 -0
- package/build/multichain/websdk/aptos.js +289 -0
- package/build/multichain/websdk/aptos.js.map +1 -0
- package/build/multichain/websdk/btc.d.ts +1 -1
- package/build/multichain/websdk/btc.js +11 -0
- package/build/multichain/websdk/btc.js.map +1 -0
- package/build/multichain/websdk/evm.d.ts +1 -1
- package/build/multichain/websdk/evm.js +11 -0
- package/build/multichain/websdk/evm.js.map +1 -0
- package/build/multichain/websdk/ibc.d.ts +1 -1
- package/build/multichain/websdk/ibc.js +12 -0
- package/build/multichain/websdk/ibc.js.map +1 -0
- package/build/multichain/websdk/index.js +22 -1
- package/build/multichain/websdk/index.js.map +1 -0
- package/build/multichain/websdk/multiversx.d.ts +1 -1
- package/build/multichain/websdk/multiversx.js +69 -0
- package/build/multichain/websdk/multiversx.js.map +1 -0
- package/build/multichain/websdk/near.js +12 -0
- package/build/multichain/websdk/near.js.map +1 -0
- package/build/multichain/websdk/solana.d.ts +1 -1
- package/build/multichain/websdk/solana.js +92 -0
- package/build/multichain/websdk/solana.js.map +1 -0
- package/build/multichain/websdk/ton.js +8 -0
- package/build/multichain/websdk/ton.js.map +1 -0
- package/build/multichain/websdk/xrp.d.ts +1 -1
- package/build/multichain/websdk/xrp.js +11 -0
- package/build/multichain/websdk/xrp.js.map +1 -0
- package/build/types/abstraction/index.js +4 -0
- package/build/types/abstraction/index.js.map +1 -0
- package/build/types/blockchain/Confirmation.js +23 -0
- package/build/types/blockchain/Confirmation.js.map +1 -0
- package/build/types/blockchain/GCREdit.js +5 -0
- package/build/types/blockchain/GCREdit.js.map +1 -0
- package/build/types/blockchain/ISignature.js +3 -0
- package/build/types/blockchain/ISignature.js.map +1 -0
- package/build/types/blockchain/Transaction.d.ts +2 -2
- package/build/types/blockchain/Transaction.js +19 -0
- package/build/types/blockchain/Transaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/CrosschainTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/CrosschainTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/CrosschainTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/DemosworkTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/DemosworkTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/DemosworkTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/IdentityTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/IdentityTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/IdentityTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/InstantMessagingTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/InstantMessagingTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/InstantMessagingTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/L2PSHashTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/L2PSHashTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/L2PSTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/L2PSTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/L2PSTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/NativeBridgeTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/NativeBridgeTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/NativeBridgeTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/NativeTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/NativeTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/NativeTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/SmartContractTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/SmartContractTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/StorageTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/StorageTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/Web2Transaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/Web2Transaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/Web2Transaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/index.js +27 -0
- package/build/types/blockchain/TransactionSubtypes/index.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/utils.js +42 -0
- package/build/types/blockchain/TransactionSubtypes/utils.js.map +1 -0
- package/build/types/blockchain/TxFee.js +3 -0
- package/build/types/blockchain/TxFee.js.map +1 -0
- package/build/types/blockchain/ValidityData.js +8 -0
- package/build/types/blockchain/ValidityData.js.map +1 -0
- package/build/types/blockchain/WalletTypes.js +3 -0
- package/build/types/blockchain/WalletTypes.js.map +1 -0
- package/build/types/blockchain/address.js +3 -0
- package/build/types/blockchain/address.js.map +1 -0
- package/build/types/blockchain/addressInfo.js +3 -0
- package/build/types/blockchain/addressInfo.js.map +1 -0
- package/build/types/blockchain/blocks.d.ts +2 -2
- package/build/types/blockchain/blocks.js +13 -0
- package/build/types/blockchain/blocks.js.map +1 -0
- package/build/types/blockchain/encryptedTransaction.js +3 -0
- package/build/types/blockchain/encryptedTransaction.js.map +1 -0
- package/build/types/blockchain/genesisTypes.js +4 -0
- package/build/types/blockchain/genesisTypes.js.map +1 -0
- package/build/types/blockchain/identities.js +14 -0
- package/build/types/blockchain/identities.js.map +1 -0
- package/build/types/blockchain/rawTransaction.js +13 -0
- package/build/types/blockchain/rawTransaction.js.map +1 -0
- package/build/types/blockchain/statusNative.js +3 -0
- package/build/types/blockchain/statusNative.js.map +1 -0
- package/build/types/blockchain/statusProperties.js +3 -0
- package/build/types/blockchain/statusProperties.js.map +1 -0
- package/build/types/bridge/bridgeTradePayload.js +3 -0
- package/build/types/bridge/bridgeTradePayload.js.map +1 -0
- package/build/types/bridge/constants.js +91 -0
- package/build/types/bridge/constants.js.map +1 -0
- package/build/types/communication/demosWork.js +3 -0
- package/build/types/communication/demosWork.js.map +1 -0
- package/build/types/communication/rpc.js +11 -0
- package/build/types/communication/rpc.js.map +1 -0
- package/build/types/communication/transmit.js +13 -0
- package/build/types/communication/transmit.js.map +1 -0
- package/build/types/cryptography.js +3 -0
- package/build/types/cryptography.js.map +1 -0
- package/build/types/demoswork/datatypes.js +10 -0
- package/build/types/demoswork/datatypes.js.map +1 -0
- package/build/types/demoswork/index.d.ts +1 -1
- package/build/types/demoswork/index.js +3 -0
- package/build/types/demoswork/index.js.map +1 -0
- package/build/types/demoswork/operations.d.ts +1 -1
- package/build/types/demoswork/operations.js +3 -0
- package/build/types/demoswork/operations.js.map +1 -0
- package/build/types/demoswork/steps.d.ts +2 -2
- package/build/types/demoswork/steps.js +21 -0
- package/build/types/demoswork/steps.js.map +1 -0
- package/build/types/gls/Operation.js +3 -0
- package/build/types/gls/Operation.js.map +1 -0
- package/build/types/gls/StateChange.js +13 -0
- package/build/types/gls/StateChange.js.map +1 -0
- package/build/types/index.js +24 -0
- package/build/types/index.js.map +1 -0
- package/build/types/instantMessaging/index.js +3 -0
- package/build/types/instantMessaging/index.js.map +1 -0
- package/build/types/native/INativePayload.js +4 -0
- package/build/types/native/INativePayload.js.map +1 -0
- package/build/types/native/index.js +18 -0
- package/build/types/native/index.js.map +1 -0
- package/build/types/network/ExecutionResult.js +3 -0
- package/build/types/network/ExecutionResult.js.map +1 -0
- package/build/types/network/SecurityTypes.js +3 -0
- package/build/types/network/SecurityTypes.js.map +1 -0
- package/build/types/peers/Peer.js +13 -0
- package/build/types/peers/Peer.js.map +1 -0
- package/build/types/web2/index.js +9 -0
- package/build/types/web2/index.js.map +1 -0
- package/build/types/web2/telegram.js +6 -0
- package/build/types/web2/telegram.js.map +1 -0
- package/build/types/web2/twitter.js +3 -0
- package/build/types/web2/twitter.js.map +1 -0
- package/build/types/xm/apiTools.js +3 -0
- package/build/types/xm/apiTools.js.map +1 -0
- package/build/types/xm/index.js +3 -0
- package/build/types/xm/index.js.map +1 -0
- package/build/utils/dataManipulation.js +37 -0
- package/build/utils/dataManipulation.js.map +1 -0
- package/build/utils/getRemoteIP.js +19 -0
- package/build/utils/getRemoteIP.js.map +1 -0
- package/build/utils/index.js +55 -1
- package/build/utils/index.js.map +1 -0
- package/build/utils/pprint.js +17 -0
- package/build/utils/pprint.js.map +1 -0
- package/build/utils/uint8Serialize.js +22 -0
- package/build/utils/uint8Serialize.js.map +1 -0
- package/build/wallet/Wallet.d.ts +3 -3
- package/build/wallet/Wallet.js +120 -0
- package/build/wallet/Wallet.js.map +1 -0
- package/build/wallet/index.js +38 -1
- package/build/wallet/index.js.map +1 -0
- package/build/wallet/passkeys/passkeys.js +60 -0
- package/build/wallet/passkeys/passkeys.js.map +1 -0
- package/build/websdk/DemosTransactions.d.ts +2 -2
- package/build/websdk/DemosTransactions.js +298 -0
- package/build/websdk/DemosTransactions.js.map +1 -0
- package/build/websdk/DemosWebAuth.js +187 -0
- package/build/websdk/DemosWebAuth.js.map +1 -0
- package/build/websdk/GCRGeneration.d.ts +2 -2
- package/build/websdk/GCRGeneration.js +237 -0
- package/build/websdk/GCRGeneration.js.map +1 -0
- package/build/websdk/Web2Calls.d.ts +1 -1
- package/build/websdk/Web2Calls.js +107 -0
- package/build/websdk/Web2Calls.js.map +1 -0
- package/build/websdk/XMTransactions.d.ts +1 -1
- package/build/websdk/XMTransactions.js +150 -0
- package/build/websdk/XMTransactions.js.map +1 -0
- package/build/websdk/bridge.d.ts +3 -3
- package/build/websdk/bridge.js +46 -0
- package/build/websdk/bridge.js.map +1 -0
- package/build/websdk/demos.js +11 -0
- package/build/websdk/demos.js.map +1 -0
- package/build/websdk/demosclass.d.ts +5 -5
- package/build/websdk/demosclass.js +734 -0
- package/build/websdk/demosclass.js.map +1 -0
- package/build/websdk/examples/tryWeb2.js +81 -0
- package/build/websdk/examples/tryWeb2.js.map +1 -0
- package/build/websdk/index.js +70 -1
- package/build/websdk/index.js.map +1 -0
- package/build/websdk/rsa.js +86 -0
- package/build/websdk/rsa.js.map +1 -0
- package/build/websdk/types/IBuffer.js +3 -0
- package/build/websdk/types/IBuffer.js.map +1 -0
- package/build/websdk/types/KeyPair.js +3 -0
- package/build/websdk/types/KeyPair.js.map +1 -0
- package/build/websdk/utils/bufferizer.js +18 -0
- package/build/websdk/utils/bufferizer.js.map +1 -0
- package/build/websdk/utils/forge_converter.js +61 -0
- package/build/websdk/utils/forge_converter.js.map +1 -0
- package/build/websdk/utils/required.js +47 -0
- package/build/websdk/utils/required.js.map +1 -0
- package/build/websdk/utils/sha256.js +18 -0
- package/build/websdk/utils/sha256.js.map +1 -0
- package/build/websdk/utils/skeletons.d.ts +1 -1
- package/build/websdk/utils/skeletons.js +70 -0
- package/build/websdk/utils/skeletons.js.map +1 -0
- package/package.json +2 -15
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TODO Implement the identities abstraction
|
|
3
|
+
// This should be able to query and set the GCR identities for a Demos address
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.Identities = void 0;
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const encryption_1 = require("../encryption");
|
|
11
|
+
const websdk_1 = require("../websdk");
|
|
12
|
+
class Identities {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.formats = {
|
|
15
|
+
web2: {
|
|
16
|
+
github: [
|
|
17
|
+
"https://gist.github.com",
|
|
18
|
+
"https://raw.githubusercontent.com",
|
|
19
|
+
"https://gist.githubusercontent.com",
|
|
20
|
+
],
|
|
21
|
+
twitter: ["https://x.com", "https://twitter.com"],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a web2 proof payload for use with web2 identity inference.
|
|
27
|
+
*
|
|
28
|
+
* @param keypair The keypair of the demos account.
|
|
29
|
+
* @returns The web2 proof payload string.
|
|
30
|
+
*/
|
|
31
|
+
async createWeb2ProofPayload(demos) {
|
|
32
|
+
const message = "dw2p";
|
|
33
|
+
const signature = await demos.crypto.sign(demos.algorithm, new TextEncoder().encode(message));
|
|
34
|
+
return `demos:${message}:${demos.algorithm}:${(0, encryption_1.uint8ArrayToHex)(signature.signature)}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Infer an identity from either a crosschain payload or a web2 proof.
|
|
38
|
+
*
|
|
39
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
40
|
+
* @param context The context of the identity to infer.
|
|
41
|
+
* @param payload The payload to infer the identity from.
|
|
42
|
+
*
|
|
43
|
+
* @returns The validity data of the identity transaction.
|
|
44
|
+
*/
|
|
45
|
+
async inferIdentity(demos, context, payload) {
|
|
46
|
+
if (context === "web2") {
|
|
47
|
+
if (!this.formats.web2[payload.context].some((format) => payload.proof.startsWith(format))) {
|
|
48
|
+
// construct informative error message
|
|
49
|
+
const errorMessage = `Invalid ${payload.context} proof format. Supported formats are: ${this.formats.web2[payload.context].join(", ")}`;
|
|
50
|
+
throw new Error(errorMessage);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const tx = websdk_1.DemosTransactions.empty();
|
|
54
|
+
const ed25519 = await demos.crypto.getIdentity("ed25519");
|
|
55
|
+
const address = (0, encryption_1.uint8ArrayToHex)(ed25519.publicKey);
|
|
56
|
+
tx.content = {
|
|
57
|
+
...tx.content,
|
|
58
|
+
type: "identity",
|
|
59
|
+
to: address,
|
|
60
|
+
amount: 0,
|
|
61
|
+
data: [
|
|
62
|
+
"identity",
|
|
63
|
+
{
|
|
64
|
+
context: context,
|
|
65
|
+
method: (context + "_identity_assign"),
|
|
66
|
+
payload: payload,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
nonce: 1,
|
|
70
|
+
timestamp: Date.now(),
|
|
71
|
+
};
|
|
72
|
+
const signedTx = await demos.sign(tx);
|
|
73
|
+
return await demos.confirm(signedTx);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Remove a crosschain identity associated with an address.
|
|
77
|
+
*
|
|
78
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
79
|
+
* @param payload The payload to remove the identity from.
|
|
80
|
+
* @returns The response from the RPC call.
|
|
81
|
+
*/
|
|
82
|
+
async removeIdentity(demos, context, payload) {
|
|
83
|
+
const tx = websdk_1.DemosTransactions.empty();
|
|
84
|
+
const ed25519 = await demos.crypto.getIdentity("ed25519");
|
|
85
|
+
const address = (0, encryption_1.uint8ArrayToHex)(ed25519.publicKey);
|
|
86
|
+
tx.content = {
|
|
87
|
+
...tx.content,
|
|
88
|
+
type: "identity",
|
|
89
|
+
to: address,
|
|
90
|
+
amount: 0,
|
|
91
|
+
data: [
|
|
92
|
+
"identity",
|
|
93
|
+
{
|
|
94
|
+
context: context,
|
|
95
|
+
method: (context + "_identity_remove"),
|
|
96
|
+
payload: payload,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
nonce: 1,
|
|
100
|
+
timestamp: Date.now(),
|
|
101
|
+
};
|
|
102
|
+
const signedTx = await demos.sign(tx);
|
|
103
|
+
return await demos.confirm(signedTx);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Infer a crosschain identity from a signature.
|
|
107
|
+
*
|
|
108
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
109
|
+
* @param payload The payload to infer the identity from.
|
|
110
|
+
* @returns The validity data of the identity transaction.
|
|
111
|
+
*/
|
|
112
|
+
async inferXmIdentity(demos, payload, referralCode) {
|
|
113
|
+
return await this.inferIdentity(demos, "xm", { ...payload, referralCode: referralCode });
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Infer a web2 identity from a proof payload.
|
|
117
|
+
*
|
|
118
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
119
|
+
* @param payload The payload to infer the identity from.
|
|
120
|
+
*
|
|
121
|
+
* @returns The validity data of the identity transaction.
|
|
122
|
+
*/
|
|
123
|
+
async inferWeb2Identity(demos, payload) {
|
|
124
|
+
return await this.inferIdentity(demos, "web2", payload);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Remove a crosschain identity from the network.
|
|
128
|
+
*
|
|
129
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
130
|
+
* @param payload The payload to remove the identity.
|
|
131
|
+
* @returns The response from the RPC call.
|
|
132
|
+
*/
|
|
133
|
+
async removeXmIdentity(demos, payload) {
|
|
134
|
+
return await this.removeIdentity(demos, "xm", payload);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Remove a web2 identity from the network.
|
|
138
|
+
*
|
|
139
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
140
|
+
* @param payload The payload to remove the identity.
|
|
141
|
+
* @returns The response from the RPC call.
|
|
142
|
+
*/
|
|
143
|
+
async removeWeb2Identity(demos, payload) {
|
|
144
|
+
return await this.removeIdentity(demos, "web2", payload);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Add a github identity to the GCR.
|
|
148
|
+
*
|
|
149
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
150
|
+
* @param payload The payload to add the identity to.
|
|
151
|
+
* @returns The response from the RPC call.
|
|
152
|
+
*/
|
|
153
|
+
async addGithubIdentity(demos, payload, referralCode) {
|
|
154
|
+
const username = payload.split("/")[3];
|
|
155
|
+
const ghUser = await axios_1.default.get(`https://api.github.com/users/${username}`);
|
|
156
|
+
if (!ghUser.data.login) {
|
|
157
|
+
throw new Error("Failed to get github user");
|
|
158
|
+
}
|
|
159
|
+
let githubPayload = {
|
|
160
|
+
context: "github",
|
|
161
|
+
proof: payload,
|
|
162
|
+
username: ghUser.data.login,
|
|
163
|
+
userId: ghUser.data.id,
|
|
164
|
+
referralCode: referralCode,
|
|
165
|
+
};
|
|
166
|
+
return await this.inferIdentity(demos, "web2", githubPayload);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Add a twitter identity to the GCR.
|
|
170
|
+
*
|
|
171
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
172
|
+
* @param payload The payload to add the identity to.
|
|
173
|
+
* @returns The response from the RPC call.
|
|
174
|
+
*/
|
|
175
|
+
async addTwitterIdentity(demos, payload, referralCode) {
|
|
176
|
+
const data = await demos.web2.getTweet(payload);
|
|
177
|
+
if (!data.success) {
|
|
178
|
+
throw new Error(data.error);
|
|
179
|
+
}
|
|
180
|
+
if (!data.tweet.userId || !data.tweet.username) {
|
|
181
|
+
throw new Error("Unable to get twitter user info. Please try again.");
|
|
182
|
+
}
|
|
183
|
+
let twitterPayload = {
|
|
184
|
+
context: "twitter",
|
|
185
|
+
proof: payload,
|
|
186
|
+
username: data.tweet.username,
|
|
187
|
+
userId: data.tweet.userId,
|
|
188
|
+
referralCode: referralCode,
|
|
189
|
+
};
|
|
190
|
+
return await this.inferIdentity(demos, "web2", twitterPayload);
|
|
191
|
+
}
|
|
192
|
+
// SECTION: PQC Identities
|
|
193
|
+
async bindPqcIdentity(demos, algorithms = "all") {
|
|
194
|
+
let addressTypes = [];
|
|
195
|
+
// Create the address types to bind
|
|
196
|
+
if (algorithms === "all") {
|
|
197
|
+
await demos.crypto.generateAllIdentities();
|
|
198
|
+
addressTypes = encryption_1.UnifiedCrypto.supportedPQCAlgorithms;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
for (const algorithm of algorithms) {
|
|
202
|
+
await demos.crypto.generateIdentity(algorithm);
|
|
203
|
+
addressTypes.push(algorithm);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// Create the payloads
|
|
207
|
+
const payloads = [];
|
|
208
|
+
for (const addressType of addressTypes) {
|
|
209
|
+
// INFO: Create an ed25519 signature for each address type
|
|
210
|
+
const keypair = await demos.crypto.getIdentity(addressType);
|
|
211
|
+
const address = (0, encryption_1.uint8ArrayToHex)(keypair.publicKey);
|
|
212
|
+
const signature = await demos.crypto.sign("ed25519", new TextEncoder().encode(address));
|
|
213
|
+
payloads.push({
|
|
214
|
+
algorithm: addressType,
|
|
215
|
+
address: address,
|
|
216
|
+
signature: (0, encryption_1.uint8ArrayToHex)(signature.signature),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return await this.inferIdentity(demos, "pqc", payloads);
|
|
220
|
+
}
|
|
221
|
+
async removePqcIdentity(demos, algorithms = "all") {
|
|
222
|
+
let addressTypes = [];
|
|
223
|
+
// Create the address types to remove
|
|
224
|
+
if (algorithms === "all") {
|
|
225
|
+
await demos.crypto.generateAllIdentities();
|
|
226
|
+
addressTypes = encryption_1.UnifiedCrypto.supportedPQCAlgorithms;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
for (const algorithm of algorithms) {
|
|
230
|
+
await demos.crypto.generateIdentity(algorithm);
|
|
231
|
+
addressTypes.push(algorithm);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Create the payloads
|
|
235
|
+
const payloads = [];
|
|
236
|
+
for (const addressType of addressTypes) {
|
|
237
|
+
const address = await demos.crypto.getIdentity(addressType);
|
|
238
|
+
payloads.push({
|
|
239
|
+
algorithm: addressType,
|
|
240
|
+
address: (0, encryption_1.uint8ArrayToHex)(address.publicKey),
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return await this.removeIdentity(demos, "pqc", payloads);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Get the identities associated with an address.
|
|
247
|
+
*
|
|
248
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
249
|
+
* @param address The address to get identities for.
|
|
250
|
+
* @returns The identities associated with the address.
|
|
251
|
+
*/
|
|
252
|
+
async getIdentities(demos, call = "getIdentities", address) {
|
|
253
|
+
if (!address) {
|
|
254
|
+
const ed25519 = await demos.crypto.getIdentity("ed25519");
|
|
255
|
+
address = (0, encryption_1.uint8ArrayToHex)(ed25519.publicKey);
|
|
256
|
+
}
|
|
257
|
+
const request = {
|
|
258
|
+
method: "gcr_routine",
|
|
259
|
+
params: [
|
|
260
|
+
{
|
|
261
|
+
method: call,
|
|
262
|
+
params: [address],
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
};
|
|
266
|
+
return await demos.rpcCall(request, true);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Get the crosschain identities associated with an address.
|
|
270
|
+
*
|
|
271
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
272
|
+
* @param address The address to get identities for.
|
|
273
|
+
* @returns The identities associated with the address.
|
|
274
|
+
*/
|
|
275
|
+
async getXmIdentities(demos, address) {
|
|
276
|
+
return await this.getIdentities(demos, "getXmIdentities", address);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get the web2 identities associated with an address.
|
|
280
|
+
*
|
|
281
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
282
|
+
* @param address The address to get identities for.
|
|
283
|
+
* @returns The identities associated with the address.
|
|
284
|
+
*/
|
|
285
|
+
async getWeb2Identities(demos, address) {
|
|
286
|
+
return await this.getIdentities(demos, "getWeb2Identities", address);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Get the points associated with an identity
|
|
290
|
+
*
|
|
291
|
+
* @param demos A Demos instance to communicate with the RPC
|
|
292
|
+
* @param address The address to get points for. Defaults to the connected wallet's address.
|
|
293
|
+
* @returns The points data for the identity
|
|
294
|
+
*/
|
|
295
|
+
async getUserPoints(demos, address) {
|
|
296
|
+
(0, websdk_1._required)(address || demos.walletConnected, "No address provided and no wallet connected");
|
|
297
|
+
if (!address) {
|
|
298
|
+
address = await demos.getEd25519Address();
|
|
299
|
+
}
|
|
300
|
+
const request = {
|
|
301
|
+
method: "gcr_routine",
|
|
302
|
+
params: [
|
|
303
|
+
{
|
|
304
|
+
method: "getPoints",
|
|
305
|
+
params: [address],
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
};
|
|
309
|
+
return await demos.rpcCall(request, true);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Validate a referral code to check if it exists and is valid.
|
|
313
|
+
*
|
|
314
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
315
|
+
* @param referralCode The referral code to validate.
|
|
316
|
+
* @returns The validation result containing validity status, referrer public key, and message.
|
|
317
|
+
*/
|
|
318
|
+
async validateReferralCode(demos, referralCode) {
|
|
319
|
+
const request = {
|
|
320
|
+
method: "gcr_routine",
|
|
321
|
+
params: [
|
|
322
|
+
{ method: "validateReferralCode", params: [referralCode] },
|
|
323
|
+
],
|
|
324
|
+
};
|
|
325
|
+
return await demos.rpcCall(request, true);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Get referral information for an address.
|
|
329
|
+
*
|
|
330
|
+
* @param demos A Demos instance to communicate with the RPC.
|
|
331
|
+
* @param address The address to get referral info for. Defaults to the connected wallet's address.
|
|
332
|
+
* @returns The referral information associated with the address.
|
|
333
|
+
*/
|
|
334
|
+
async getReferralInfo(demos, address) {
|
|
335
|
+
if (!address) {
|
|
336
|
+
address = await demos.getEd25519Address();
|
|
337
|
+
}
|
|
338
|
+
const request = {
|
|
339
|
+
method: "gcr_routine",
|
|
340
|
+
params: [
|
|
341
|
+
{ method: "getReferralInfo", params: [address] },
|
|
342
|
+
],
|
|
343
|
+
};
|
|
344
|
+
return await demos.rpcCall(request, true);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
exports.Identities = Identities;
|
|
348
|
+
//# sourceMappingURL=Identities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Identities.js","sourceRoot":"","sources":["../../../src/abstraction/Identities.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,8EAA8E;;;;;;AAE9E,kDAAyB;AAezB,6CAA6D;AAC7D,qCAAmE;AAEnE,MAAa,UAAU;IAAvB;QACI,YAAO,GAAG;YACN,IAAI,EAAE;gBACF,MAAM,EAAE;oBACJ,yBAAyB;oBACzB,mCAAmC;oBACnC,oCAAoC;iBACvC;gBACD,OAAO,EAAE,CAAC,eAAe,EAAE,qBAAqB,CAAC;aACpD;SACJ,CAAA;IA+YL,CAAC;IA7YG;;;;;OAKG;IACH,KAAK,CAAC,sBAAsB,CAAC,KAAY;QACrC,MAAM,OAAO,GAAG,MAAM,CAAA;QACtB,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CACrC,KAAK,CAAC,SAAS,EACf,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CACpC,CAAA;QAED,OAAO,SAAS,OAAO,IAAI,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identities } from "./Identities";
|
|
10
|
-
import { InferFromWritePayload, InferFromSignaturePayload, XMCoreTargetIdentityPayload, Web2CoreTargetIdentityPayload, InferFromGithubPayload, GithubProof, InferFromTwitterPayload, TwitterProof, IdentityPayload, InferFromSignatureTargetIdentityPayload, PqcIdentityAssignPayload, PqcIdentityRemovePayload, UserPoints } from "
|
|
10
|
+
import { InferFromWritePayload, InferFromSignaturePayload, XMCoreTargetIdentityPayload, Web2CoreTargetIdentityPayload, InferFromGithubPayload, GithubProof, InferFromTwitterPayload, TwitterProof, IdentityPayload, InferFromSignatureTargetIdentityPayload, PqcIdentityAssignPayload, PqcIdentityRemovePayload, UserPoints } from "../types/abstraction";
|
|
11
11
|
export { EvmCoinFinder, CoinFinder, Identities, InferFromWritePayload, InferFromSignaturePayload, XMCoreTargetIdentityPayload, Web2CoreTargetIdentityPayload, InferFromGithubPayload, GithubProof, InferFromTwitterPayload, TwitterProof, IdentityPayload, InferFromSignatureTargetIdentityPayload, PqcIdentityAssignPayload, PqcIdentityRemovePayload, UserPoints, };
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
"use strict";var t=require("@solana/web3.js"),e=require("ethers"),n=require("axios"),r=require("crypto"),s=require("falcon-sign"),i=require("node-forge"),a=require("fs");function o(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var c=o(e),h=o(r),d=o(i);class l{constructor(){this.evm={},this.solana={mainnet:[],testnet:[]},this.multiversx={mainnet:[],testnet:[]},this.xrp={mainnet:[],testnet:[]},this.bitcoin={mainnet:[],testnet:[]}}static getInstance(){return l._instance||(l._instance=new l),l._instance}registerEVM(t,e){this.evm[t]||(this.evm[t]=[]),this.evm[t].push(...e)}registerChainProviders(t,e,n){this[t]&&this[t][e]&&this[t][e].push(...n)}}const u=l.getInstance,p={eth:{mainnet:1,ropsten:3,rinkeby:4,goerli:5,sepolia:11155111,holesky:17e3},bsc:{mainnet:56,testnet:97},arbitrum:{mainnet:42161,testnet:421614},optimism:{mainnet:10,testnet:11155420}};var f;!function(t){t.ETHEREUM="ethereum",t.BSC="bsc",t.ARBITRUM="arbitrum",t.OPTIMISM="optimism",t.SOLANA="solana",t.MULTIVERSX="multiversx",t.XRP="xrp",t.BITCOIN="bitcoin",t.TON="ton"}(f||(f={}));const y={ethereum:{mainnet:"0x0000000000000000000000000000000000000000",sepolia:"0x0000000000000000000000000000000000000000",wrapped:{ethereum:{mainnet:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",testnet:"0xfff9976782d46cc05630d1f6ebab18b2324d6b14"},bsc:{mainnet:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",testnet:"0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd"},arbitrum:{mainnet:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",testnet:"0x980B62Da83eFf3D4576C647993b0c1D7faf17c73"},optimism:{mainnet:"0x4200000000000000000000000000000000000006",testnet:"0x4200000000000000000000000000000000000006"}}},solana:{mainnet:"So11111111111111111111111111111111111111112",testnet:"So11111111111111111111111111111111111111112",wrapped:{ethereum:{mainnet:"0xD31a59c85aE9D8edEFeC411D448f90841571b89c",testnet:""},bsc:{mainnet:"0x570A5D26f7765Ecb712C0924E4De545B89fD43dF",testnet:""},arbitrum:{mainnet:"0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",testnet:""},optimism:{mainnet:"",testnet:""}}},xrp:{mainnet:"XRP",testnet:"XRP",wrapped:{ethereum:{mainnet:"0x39fBBABf11738317a448031930706cd3e612e1B9",testnet:"0x0000000000000000000000000000000000000000"},bsc:{mainnet:"0x1D2F0da169ceB9fC7B3144628dB156f3F6c60dBE",testnet:"0x0000000000000000000000000000000000000000"},arbitrum:{mainnet:"0x0000000000000000000000000000000000000000",testnet:"0x0000000000000000000000000000000000000000"},optimism:{mainnet:"0x0000000000000000000000000000000000000000",testnet:"0x0000000000000000000000000000000000000000"}}},bitcoin:{mainnet:"BTC",testnet:"BTC",wrapped:{ethereum:{mainnet:"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",testnet:"0x92c63d0e701CAAe670C9415d91C474F686298f00"},bsc:{mainnet:"0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c",testnet:"0x6ce8dA28E2f864420840cF74474eFf5fD80E65B8"},arbitrum:{mainnet:"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",testnet:""},optimism:{mainnet:"0x68f180fcCe6836688e9084f035309E29Bf0A2095",testnet:""}}},multiversx:{mainnet:"EGLD",testnet:"EGLD",wrapped:{ethereum:{mainnet:"",testnet:""},bsc:{mainnet:"0xbF7c81FFF98BbE61B40Ed186e4AfD6DDd01337fe",testnet:""},arbitrum:{mainnet:"",testnet:""},optimism:{mainnet:"",testnet:""}}},usdc:{ethereum:{mainnet:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",testnet:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"},bsc:{mainnet:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",testnet:"0x64544969ed7EBf5f083679233325356EbE738930"},arbitrum:{mainnet:"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",testnet:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},optimism:{mainnet:"0x7F5c764cBc14f9669B88837ca1490cCa17c31607",testnet:"0x0000000000000000000000000000000000000000"},solana:{mainnet:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",testnet:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"},multiversx:{mainnet:"USDC-c76f1f",testnet:"USDC-8d4068"},xrp:{mainnet:"",testnet:""},ton:{mainnet:"",testnet:""}},usdt:{ethereum:{mainnet:"0xdAC17F958D2ee523a2206206994597C13D831ec7",testnet:"0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"},bsc:{mainnet:"0x55d398326f99059fF775485246999027B3197955",testnet:"0x337610d27c682E347C9cD60BD4b3b107C9d34dDd"},arbitrum:{mainnet:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",testnet:"0x0000000000000000000000000000000000000000"},optimism:{mainnet:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",testnet:"0x0000000000000000000000000000000000000000"},solana:{mainnet:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",testnet:""},multiversx:{mainnet:"",testnet:""},xrp:{mainnet:"",testnet:""},ton:{mainnet:"",testnet:""}}};u().registerEVM(p.eth.mainnet.toString(),["https://rpc.ankr.com/eth","https://eth.drpc.org","https://eth.llamarpc.com","https://ethereum.publicnode.com","https://rpc.flashbots.net","https://rpc.payload.de","https://singapore.rpc.blxrbdn.com","https://uk.rpc.blxrbdn.com","https://virginia.rpc.blxrbdn.com"]),u().registerEVM(p.eth.sepolia.toString(),["https://rpc.ankr.com/eth_sepolia","https://eth-sepolia.public.blastapi.io","https://endpoints.omniatech.io/v1/eth/sepolia/public","https://1rpc.io/sepolia","https://ethereum-sepolia.blockpi.network/v1/rpc/private"]),u().registerEVM("bsc",["https://bsc-dataseed.bnbchain.org","https://bsc-dataseed.nariox.org","https://bsc-dataseed.defibit.io","https://bsc-dataseed.ninicoin.io","https://bsc.nodereal.io","https://bsc-dataseed-public.bnbchain.org","https://bnb.rpc.subquery.network/public"]),u().registerEVM("bsc_testnet",["https://bsc-testnet-dataseed.bnbchain.org","https://bsc-testnet.bnbchain.org","https://bsc-prebsc-dataseed.bnbchain.org"]),u().registerEVM("arbitrum",["https://arb1.arbitrum.io/rpc","https://rpc.ankr.com/arbitrum","https://arbitrum.drpc.org","https://arbitrum.meowrpc.com","https://arb-pokt.nodies.app"]),u().registerEVM("arbitrum_testnet",["https://sepolia-rollup.arbitrum.io/rpc"]),u().registerEVM("optimism",["https://mainnet.optimism.io","https://rpc.ankr.com/optimism","https://endpoints.omniatech.io/v1/op/mainnet/public","https://optimism-rpc.publicnode.com","https://optimism.drpc.org","https://optimism.meowrpc.com"]),u().registerEVM("optimism-sepolia",["https://api.zan.top/opt-sepolia","https://optimism-sepolia.gateway.tenderly.co","https://endpoints.omniatech.io/v1/op/sepolia/public","https://optimism-sepolia.drpc.org"]),u().solana.mainnet=["https://api.mainnet-beta.solana.com",t.clusterApiUrl("mainnet-beta"),"https://solana.api.chainstack.com/mainnet-beta","https://api.metaplex.solana.com"],u().solana.testnet=["https://api.testnet.solana.com",t.clusterApiUrl("testnet"),"https://api.metaplex.solana.com/testnet"],u().multiversx.mainnet=["https://api.multiversx.com","https://gateway.multiversx.com","https://api.elrond.com","https://elrond-api.public.blastapi.io"],u().multiversx.testnet=["https://testnet-api.multiversx.com","https://testnet-gateway.multiversx.com","https://testnet-api.elrond.com"],u().xrp.mainnet=["wss://xrplcluster.com","wss://s1.ripple.com:51233","wss://s2.ripple.com:51233","wss://s.devnet.rippletest.net:51233","wss://xrpl.ws"],u().xrp.testnet=["wss://s.altnet.rippletest.net:51233","wss://testnet.xrpl-labs.com"],u().bitcoin.mainnet=["https://blockstream.info/api","https://mempool.space/api","https://api.blockcypher.com/v1/btc/main","https://api.blockchain.info"],u().bitcoin.testnet=["https://blockstream.info/testnet/api","https://mempool.space/testnet/api","https://api.blockcypher.com/v1/btc/test3"];const m=u();class g extends Error{constructor(t,e,n){super(t),this.code=e,this.details=n}}const b=BigInt(2**32-1),w=BigInt(32);function x(t,e=!1){return e?{h:Number(t&b),l:Number(t>>w&b)}:{h:0|Number(t>>w&b),l:0|Number(t&b)}}function A(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:a}=x(t[i],e);[r[i],s[i]]=[n,a]}return[r,s]}const k=(t,e,n)=>t>>>n,_=(t,e,n)=>t<<32-n|e>>>n,v=(t,e,n)=>t>>>n|e<<32-n,E=(t,e,n)=>t<<32-n|e>>>n,I=(t,e,n)=>t<<64-n|e>>>n-32,C=(t,e,n)=>t>>>n-32|e<<64-n;function B(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:0|s}}const K=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),T=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,U=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),D=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,S=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),F=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,L="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function H(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function P(t,...e){if(!((n=t)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function M(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");H(t.outputLen),H(t.blockLen)}function O(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function R(t,e){P(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function N(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function G(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function X(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function j(t,e){return t<<32-e|t>>>e}function q(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const $=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=q(t[e]);return t},V=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),W=48,Y=57,J=65,Q=70,z=97,Z=102;function tt(t){return t>=W&&t<=Y?t-W:t>=J&&t<=Q?t-(J-10):t>=z&&t<=Z?t-(z-10):void 0}function et(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(V)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,s=0;e<n;e++,s+=2){const n=tt(t.charCodeAt(s)),i=tt(t.charCodeAt(s+1));if(void 0===n||void 0===i){const e=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+s)}r[e]=16*n+i}return r}function nt(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function rt(t){return"string"==typeof t&&(t=nt(t)),P(t),t}function st(t){return"string"==typeof t&&(t=nt(t)),P(t),t}function it(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];P(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const s=t[e];n.set(s,r),r+=s.length}return n}class at{}function ot(t){const e=e=>t().update(rt(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ct(t=32){if(L&&"function"==typeof L.getRandomValues)return L.getRandomValues(new Uint8Array(t));if(L&&"function"==typeof L.randomBytes)return Uint8Array.from(L.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const ht=BigInt(0),dt=BigInt(1),lt=BigInt(2),ut=BigInt(7),pt=BigInt(256),ft=BigInt(113),yt=[],mt=[],gt=[];for(let t=0,e=dt,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],yt.push(2*(5*r+n)),mt.push((t+1)*(t+2)/2%64);let s=ht;for(let t=0;t<7;t++)e=(e<<dt^(e>>ut)*ft)%pt,e<&&(s^=dt<<(dt<<BigInt(t))-dt);gt.push(s)}const bt=A(gt,!0),wt=bt[0],xt=bt[1],At=(t,e,n)=>n>32?((t,e,n)=>e<<n-32|t>>>64-n)(t,e,n):((t,e,n)=>t<<n|e>>>32-n)(t,e,n),kt=(t,e,n)=>n>32?((t,e,n)=>t<<n-32|e>>>64-n)(t,e,n):((t,e,n)=>e<<n|t>>>32-n)(t,e,n);class _t extends at{constructor(t,e,n,r=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=s,H(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=N(this.state)}clone(){return this._cloneInto()}keccak(){$(this.state32),function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,s=(e+2)%10,i=n[s],a=n[s+1],o=At(i,a,1)^n[r],c=kt(i,a,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=o,t[e+n+1]^=c}let e=t[2],s=t[3];for(let n=0;n<24;n++){const r=mt[n],i=At(e,s,r),a=kt(e,s,r),o=yt[n];e=t[o],s=t[o+1],t[o]=i,t[o+1]=a}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=wt[r],t[1]^=xt[r]}G(n)}(this.state32,this.rounds),$(this.state32),this.posOut=0,this.pos=0}update(t){O(this),P(t=rt(t));const{blockLen:e,state:n}=this,r=t.length;for(let s=0;s<r;){const i=Math.min(e-this.pos,r-s);for(let e=0;e<i;e++)n[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){O(this,!1),P(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,s=t.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);t.set(e.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return H(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(R(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,G(this.state)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return t||(t=new _t(e,n,r,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=r,t.enableXOF=i,t.destroyed=this.destroyed,t}}const vt=(t,e,n)=>ot(()=>new _t(e,t,n)),Et=(()=>vt(6,144,28))(),It=(()=>vt(6,136,32))(),Ct=(()=>vt(6,104,48))(),Bt=(()=>vt(6,72,64))(),Kt=(t,e,n)=>function(t){const e=(e,n)=>t(n).update(rt(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e}((r={})=>new _t(e,t,void 0===r.dkLen?n:r.dkLen,!0)),Tt=(()=>Kt(31,168,16))(),Ut=(()=>Kt(31,136,32))();function Dt(t,e,n){return t&e^~t&n}function St(t,e,n){return t&e^t&n^e&n}class Ft extends at{constructor(t,e,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=X(this.buffer)}update(t){O(this),P(t=rt(t));const{view:e,buffer:n,blockLen:r}=this,s=t.length;for(let i=0;i<s;){const a=Math.min(r-this.pos,s-i);if(a===r){const e=X(t);for(;r<=s-i;i+=r)this.process(e,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){O(this),R(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:s}=this;let{pos:i}=this;e[i++]=128,G(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let t=i;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),c=r?4:0,h=r?0:4;t.setUint32(e+c,a,r),t.setUint32(e+h,o,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const a=X(t),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)a.setUint32(4*t,h[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=r,t.pos=a,r%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const Lt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Pt=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Mt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ot=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Rt=new Uint32Array(64);class Nt extends Ft{constructor(t=32){super(64,t,8,!1),this.A=0|Lt[0],this.B=0|Lt[1],this.C=0|Lt[2],this.D=0|Lt[3],this.E=0|Lt[4],this.F=0|Lt[5],this.G=0|Lt[6],this.H=0|Lt[7]}get(){const{A:t,B:e,C:n,D:r,E:s,F:i,G:a,H:o}=this;return[t,e,n,r,s,i,a,o]}set(t,e,n,r,s,i,a,o){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|a,this.H=0|o}process(t,e){for(let n=0;n<16;n++,e+=4)Rt[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Rt[t-15],n=Rt[t-2],r=j(e,7)^j(e,18)^e>>>3,s=j(n,17)^j(n,19)^n>>>10;Rt[t]=s+Rt[t-7]+r+Rt[t-16]|0}let{A:n,B:r,C:s,D:i,E:a,F:o,G:c,H:h}=this;for(let t=0;t<64;t++){const e=h+(j(a,6)^j(a,11)^j(a,25))+Dt(a,o,c)+Ot[t]+Rt[t]|0,d=(j(n,2)^j(n,13)^j(n,22))+St(n,r,s)|0;h=c,c=o,o=a,a=i+e|0,i=s,s=r,r=n,n=e+d|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,o=o+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(n,r,s,i,a,o,c,h)}roundClean(){G(Rt)}destroy(){this.set(0,0,0,0,0,0,0,0),G(this.buffer)}}class Gt extends Nt{constructor(){super(28),this.A=0|Ht[0],this.B=0|Ht[1],this.C=0|Ht[2],this.D=0|Ht[3],this.E=0|Ht[4],this.F=0|Ht[5],this.G=0|Ht[6],this.H=0|Ht[7]}}const Xt=(()=>A(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),jt=(()=>Xt[0])(),qt=(()=>Xt[1])(),$t=new Uint32Array(80),Vt=new Uint32Array(80);class Wt extends Ft{constructor(t=64){super(128,t,16,!1),this.Ah=0|Mt[0],this.Al=0|Mt[1],this.Bh=0|Mt[2],this.Bl=0|Mt[3],this.Ch=0|Mt[4],this.Cl=0|Mt[5],this.Dh=0|Mt[6],this.Dl=0|Mt[7],this.Eh=0|Mt[8],this.El=0|Mt[9],this.Fh=0|Mt[10],this.Fl=0|Mt[11],this.Gh=0|Mt[12],this.Gl=0|Mt[13],this.Hh=0|Mt[14],this.Hl=0|Mt[15]}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:s,Cl:i,Dh:a,Dl:o,Eh:c,El:h,Fh:d,Fl:l,Gh:u,Gl:p,Hh:f,Hl:y}=this;return[t,e,n,r,s,i,a,o,c,h,d,l,u,p,f,y]}set(t,e,n,r,s,i,a,o,c,h,d,l,u,p,f,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|s,this.Cl=0|i,this.Dh=0|a,this.Dl=0|o,this.Eh=0|c,this.El=0|h,this.Fh=0|d,this.Fl=0|l,this.Gh=0|u,this.Gl=0|p,this.Hh=0|f,this.Hl=0|y}process(t,e){for(let n=0;n<16;n++,e+=4)$t[n]=t.getUint32(e),Vt[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|$t[t-15],n=0|Vt[t-15],r=v(e,n,1)^v(e,n,8)^k(e,0,7),s=E(e,n,1)^E(e,n,8)^_(e,n,7),i=0|$t[t-2],a=0|Vt[t-2],o=v(i,a,19)^I(i,a,61)^k(i,0,6),c=E(i,a,19)^C(i,a,61)^_(i,a,6),h=U(s,c,Vt[t-7],Vt[t-16]),d=D(h,r,o,$t[t-7],$t[t-16]);$t[t]=0|d,Vt[t]=0|h}let{Ah:n,Al:r,Bh:s,Bl:i,Ch:a,Cl:o,Dh:c,Dl:h,Eh:d,El:l,Fh:u,Fl:p,Gh:f,Gl:y,Hh:m,Hl:g}=this;for(let t=0;t<80;t++){const e=v(d,l,14)^v(d,l,18)^I(d,l,41),b=E(d,l,14)^E(d,l,18)^C(d,l,41),w=d&u^~d&f,x=S(g,b,l&p^~l&y,qt[t],Vt[t]),A=F(x,m,e,w,jt[t],$t[t]),k=0|x,_=v(n,r,28)^I(n,r,34)^I(n,r,39),U=E(n,r,28)^C(n,r,34)^C(n,r,39),D=n&s^n&a^s&a,L=r&i^r&o^i&o;m=0|f,g=0|y,f=0|u,y=0|p,u=0|d,p=0|l,({h:d,l:l}=B(0|c,0|h,0|A,0|k)),c=0|a,h=0|o,a=0|s,o=0|i,s=0|n,i=0|r;const H=K(k,U,L);n=T(H,A,_,D),r=0|H}({h:n,l:r}=B(0|this.Ah,0|this.Al,0|n,0|r)),({h:s,l:i}=B(0|this.Bh,0|this.Bl,0|s,0|i)),({h:a,l:o}=B(0|this.Ch,0|this.Cl,0|a,0|o)),({h:c,l:h}=B(0|this.Dh,0|this.Dl,0|c,0|h)),({h:d,l:l}=B(0|this.Eh,0|this.El,0|d,0|l)),({h:u,l:p}=B(0|this.Fh,0|this.Fl,0|u,0|p)),({h:f,l:y}=B(0|this.Gh,0|this.Gl,0|f,0|y)),({h:m,l:g}=B(0|this.Hh,0|this.Hl,0|m,0|g)),this.set(n,r,s,i,a,o,c,h,d,l,u,p,f,y,m,g)}roundClean(){G($t,Vt)}destroy(){G(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Yt extends Wt{constructor(){super(48),this.Ah=0|Pt[0],this.Al=0|Pt[1],this.Bh=0|Pt[2],this.Bl=0|Pt[3],this.Ch=0|Pt[4],this.Cl=0|Pt[5],this.Dh=0|Pt[6],this.Dl=0|Pt[7],this.Eh=0|Pt[8],this.El=0|Pt[9],this.Fh=0|Pt[10],this.Fl=0|Pt[11],this.Gh=0|Pt[12],this.Gl=0|Pt[13],this.Hh=0|Pt[14],this.Hl=0|Pt[15]}}const Jt=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Qt=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class zt extends Wt{constructor(){super(28),this.Ah=0|Jt[0],this.Al=0|Jt[1],this.Bh=0|Jt[2],this.Bl=0|Jt[3],this.Ch=0|Jt[4],this.Cl=0|Jt[5],this.Dh=0|Jt[6],this.Dl=0|Jt[7],this.Eh=0|Jt[8],this.El=0|Jt[9],this.Fh=0|Jt[10],this.Fl=0|Jt[11],this.Gh=0|Jt[12],this.Gl=0|Jt[13],this.Hh=0|Jt[14],this.Hl=0|Jt[15]}}class Zt extends Wt{constructor(){super(32),this.Ah=0|Qt[0],this.Al=0|Qt[1],this.Bh=0|Qt[2],this.Bl=0|Qt[3],this.Ch=0|Qt[4],this.Cl=0|Qt[5],this.Dh=0|Qt[6],this.Dl=0|Qt[7],this.Eh=0|Qt[8],this.El=0|Qt[9],this.Fh=0|Qt[10],this.Fl=0|Qt[11],this.Gh=0|Qt[12],this.Gl=0|Qt[13],this.Hh=0|Qt[14],this.Hl=0|Qt[15]}}const te=ot(()=>new Nt),ee=ot(()=>new Gt),ne=ot(()=>new Wt),re=ot(()=>new Yt),se=ot(()=>new Zt),ie=ot(()=>new zt),ae=P,oe=ct;function ce(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return 0===n}function he(...t){const e=t=>"number"==typeof t?t:t.bytesLen,n=t.reduce((t,n)=>t+e(n),0);return{bytesLen:n,encode:r=>{const s=new Uint8Array(n);for(let n=0,i=0;n<t.length;n++){const a=t[n],o=e(a),c="number"==typeof a?r[n]:a.encode(r[n]);ae(c,o),s.set(c,i),"number"!=typeof a&&c.fill(0),i+=o}return s},decode:r=>{ae(r,n);const s=[];for(const n of t){const t=e(n),i=r.subarray(0,t);s.push("number"==typeof n?i:n.decode(i)),r=r.subarray(t)}return s}}}function de(t,e){const n=e*t.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const s=new Uint8Array(n);for(let e=0,n=0;e<r.length;e++){const i=t.encode(r[e]);s.set(i,n),i.fill(0),n+=i.length}return s},decode:e=>{ae(e,n);const r=[];for(let n=0;n<e.length;n+=t.bytesLen)r.push(t.decode(e.subarray(n,n+t.bytesLen)));return r}}}function le(...t){for(const e of t)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function ue(t){return(1<<t)-1}const pe=new Uint8Array(0);function fe(t,e=pe){if(ae(t),ae(e),e.length>255)throw new Error("context should be less than 255 bytes");return it(new Uint8Array([0,e.length]),e,t)}const ye={"SHA2-256":{oid:et("0609608648016503040201"),hash:te},"SHA2-384":{oid:et("0609608648016503040202"),hash:re},"SHA2-512":{oid:et("0609608648016503040203"),hash:ne},"SHA2-224":{oid:et("0609608648016503040204"),hash:ee},"SHA2-512/224":{oid:et("0609608648016503040205"),hash:ie},"SHA2-512/256":{oid:et("0609608648016503040206"),hash:se},"SHA3-224":{oid:et("0609608648016503040207"),hash:Et},"SHA3-256":{oid:et("0609608648016503040208"),hash:It},"SHA3-384":{oid:et("0609608648016503040209"),hash:Ct},"SHA3-512":{oid:et("060960864801650304020A"),hash:Bt},"SHAKE-128":{oid:et("060960864801650304020B"),hash:t=>Tt(t,{dkLen:32})},"SHAKE-256":{oid:et("060960864801650304020C"),hash:t=>Ut(t,{dkLen:64})}};function me(t,e,n=pe){if(ae(e),ae(n),n.length>255)throw new Error("context should be less than 255 bytes");if(!ye[t])throw new Error("unknown hash: "+t);const{oid:r,hash:s}=ye[t],i=s(e);return it(new Uint8Array([1,n.length]),n,r,i)}function ge(t,e=8){const n=t.toString(2).padStart(8,"0").slice(-e).padStart(7,"0").split("").reverse().join("");return Number.parseInt(n,2)}const be=t=>{const{newPoly:e,N:n,Q:r,F:s,ROOT_OF_UNITY:i,brvBits:a,isKyber:o}=t,c=(t,e=r)=>{const n=t%e|0;return 0|(n>=0?n:e+n)};const h=function(){const t=e(n);for(let e=0;e<n;e++){const n=ge(e,a),s=BigInt(i)**BigInt(n)%BigInt(r);t[e]=0|Number(s)}return t}(),d=o?128:n,l=o?1:0,u={encode:t=>{for(let e=1,r=128;r>l;r>>=1)for(let s=0;s<n;s+=2*r){const n=h[e++];for(let e=s;e<s+r;e++){const s=c(n*t[e+r]);t[e+r]=0|c(t[e]-s),t[e]=0|c(t[e]+s)}}return t},decode:t=>{for(let e=d-1,r=1+l;r<d+l;r<<=1)for(let s=0;s<n;s+=2*r){const n=h[e--];for(let e=s;e<s+r;e++){const s=t[e];t[e]=c(s+t[e+r]),t[e+r]=c(n*(t[e+r]-s))}}for(let e=0;e<t.length;e++)t[e]=c(s*t[e]);return t}};return{mod:c,smod:(t,e=r)=>{const n=0|c(t,e);return 0|(n>e>>1?n-e:n)},nttZetas:h,NTT:u,bitsCoder:(t,r)=>{const s=ue(t),i=t*(n/8);return{bytesLen:i,encode:e=>{const n=new Uint8Array(i);for(let i=0,a=0,o=0,c=0;i<e.length;i++)for(a|=(r.encode(e[i])&s)<<o,o+=t;o>=8;o-=8,a>>=8)n[c++]=a&ue(o);return n},decode:i=>{const a=e(n);for(let e=0,n=0,o=0,c=0;e<i.length;e++)for(n|=i[e]<<o,o+=8;o>=t;o-=t,n>>=t)a[c++]=r.decode(n&s);return a}}}}},we=t=>(e,n)=>{n||(n=t.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const s=e.length,i=new Uint8Array(n);let a=t.create({}),o=0,c=0;return{stats:()=>({calls:o,xofs:c}),get:(e,n)=>(r[s+0]=e,r[s+1]=n,a.destroy(),a=t.create({}).update(r),o++,()=>(c++,a.xofInto(i))),clean:()=>{a.destroy(),i.fill(0),r.fill(0)}}},xe=we(Tt),Ae=we(Ut),ke=256,_e=3329,{mod:ve,nttZetas:Ee,NTT:Ie,bitsCoder:Ce}=be({N:ke,Q:_e,F:3303,ROOT_OF_UNITY:17,newPoly:t=>new Uint16Array(t),brvBits:7,isKyber:!0}),Be=t=>Ce(t,(t=>{if(t>=12)return{encode:t=>t,decode:t=>t};const e=2**(t-1);return{encode:e=>((e<<t)+_e/2)/_e,decode:n=>n*_e+e>>>t}})(t));function Ke(t,e){for(let n=0;n<ke;n++)t[n]=ve(t[n]+e[n])}function Te(t,e,n,r,s){return{c0:ve(e*r*s+t*n),c1:ve(t*r+e*n)}}function Ue(t,e){for(let n=0;n<128;n++){let r=Ee[64+(n>>1)];1&n&&(r=-r);const{c0:s,c1:i}=Te(t[2*n+0],t[2*n+1],e[2*n+0],e[2*n+1],r);t[2*n+0]=s,t[2*n+1]=i}return t}function De(t){const e=new Uint16Array(ke);for(let n=0;n<ke;){const r=t();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let t=0;n<ke&&t+3<=r.length;t+=3){const s=4095&(r[t+0]|r[t+1]<<8),i=4095&(r[t+1]>>4|r[t+2]<<4);s<_e&&(e[n++]=s),n<ke&&i<_e&&(e[n++]=i)}}return e}function Se(t,e,n,r){const s=t(r*ke/4,e,n),i=new Uint16Array(ke),a=N(s);let o=0;for(let t=0,e=0,n=0,s=0;t<a.length;t++){let c=a[t];for(let t=0;t<32;t++)n+=1&c,c>>=1,o+=1,o===r?(s=n,n=0):o===2*r&&(i[e++]=ve(s-n),n=0,o=0)}if(o)throw new Error(`sampleCBD: leftover bits: ${o}`);return i}const Fe=t=>{const{K:e,PRF:n,XOF:r,HASH512:s,ETA1:i,ETA2:a,du:o,dv:c}=t,h=Be(1),d=Be(c),l=Be(o),u=he(de(Be(12),e),32),p=de(Be(12),e),f=he(de(l,e),d),y=he(32,32);return{secretCoder:p,secretKeyLen:p.bytesLen,publicKeyLen:u.bytesLen,cipherTextLen:f.bytesLen,keygen:t=>{ae(t,32);const a=new Uint8Array(33);a.set(t),a[32]=e;const o=s(a),[c,h]=y.decode(o),d=[],l=[];for(let t=0;t<e;t++)d.push(Ie.encode(Se(n,h,t,i)));const f=r(c);for(let t=0;t<e;t++){const r=Ie.encode(Se(n,h,e+t,i));for(let n=0;n<e;n++){Ke(r,Ue(De(f.get(n,t)),d[n]))}l.push(r)}f.clean();const m={publicKey:u.encode([l,c]),secretKey:p.encode(d)};return le(c,h,d,l,a,o),m},encrypt:(t,s,o)=>{const[c,d]=u.decode(t),l=[];for(let t=0;t<e;t++)l.push(Ie.encode(Se(n,o,t,i)));const p=r(d),y=new Uint16Array(ke),m=[];for(let t=0;t<e;t++){const r=Se(n,o,e+t,a),s=new Uint16Array(ke);for(let n=0;n<e;n++){Ke(s,Ue(De(p.get(t,n)),l[n]))}Ke(r,Ie.decode(s)),m.push(r),Ke(y,Ue(c[t],l[t])),s.fill(0)}p.clean();const g=Se(n,o,2*e,a);Ke(g,Ie.decode(y));const b=h.decode(s);return Ke(b,g),le(c,l,y,g),f.encode([m,b])},decrypt:(t,n)=>{const[r,s]=f.decode(t),i=p.decode(n),a=new Uint16Array(ke);for(let t=0;t<e;t++)Ke(a,Ue(i[t],Ie.encode(r[t])));return function(t,e){for(let n=0;n<ke;n++)t[n]=ve(t[n]-e[n])}(s,Ie.decode(a)),le(a,i,r),h.encode(s)}}};function Le(t){const e=Fe(t),{HASH256:n,HASH512:r,KDF:s}=t,{secretCoder:i,cipherTextLen:a}=e,o=e.publicKeyLen,c=he(e.secretKeyLen,e.publicKeyLen,32,32),h=c.bytesLen;return{publicKeyLen:o,msgLen:32,keygen:(t=oe(64))=>{ae(t,64);const{publicKey:r,secretKey:s}=e.keygen(t.subarray(0,32)),i=n(r),a=c.encode([s,r,i,t.subarray(32)]);return le(s,i),{publicKey:r,secretKey:a}},encapsulate:(s,a=oe(32))=>{ae(s,o),ae(a,32);const c=s.subarray(0,384*t.K),h=i.encode(i.decode(c.slice()));if(!ce(h,c))throw le(h),new Error("ML-KEM.encapsulate: wrong publicKey modulus");le(h);const d=r.create().update(a).update(n(s)).digest(),l=e.encrypt(s,a,d.subarray(32,64));return d.subarray(32).fill(0),{cipherText:l,sharedSecret:d.subarray(0,32)}},decapsulate:(t,n)=>{ae(n,h),ae(t,a);const[i,o,d,l]=c.decode(n),u=e.decrypt(t,i),p=r.create().update(u).update(d).digest(),f=p.subarray(0,32),y=e.encrypt(o,u,p.subarray(32,64)),m=ce(t,y),g=s.create({dkLen:32}).update(l).update(t).digest();return le(u,y,m?g:f),m?f:g}}}const He=Le({...{HASH256:It,HASH512:Bt,KDF:Ut,XOF:xe,PRF:function(t,e,n){return Ut.create({dkLen:t}).update(e).update(new Uint8Array([n])).digest()}},...{N:ke,Q:_e,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}}),Pe=256,Me=8380417,Oe=0|Math.floor(95232),Re=0|Math.floor(261888),Ne={K:6,L:5,D:13,GAMMA1:2**19,GAMMA2:Re,TAU:49,ETA:4,OMEGA:55},Ge=t=>new Int32Array(t),{mod:Xe,smod:je,NTT:qe,bitsCoder:$e}=be({N:Pe,Q:Me,F:8347681,ROOT_OF_UNITY:1753,newPoly:Ge,isKyber:!1,brvBits:8}),Ve=t=>t,We=(t,e=Ve,n=Ve)=>$e(t,{encode:t=>e(n(t)),decode:t=>n(e(t))}),Ye=(t,e)=>{for(let n=0;n<t.length;n++)t[n]=Xe(t[n]+e[n]);return t},Je=(t,e)=>{for(let n=0;n<t.length;n++)t[n]=Xe(t[n]-e[n]);return t},Qe=t=>{for(let e=0;e<Pe;e++)t[e]<<=13;return t},ze=(t,e)=>{for(let n=0;n<Pe;n++)if(Math.abs(je(t[n]))>=e)return!0;return!1},Ze=(t,e)=>{const n=Ge(Pe);for(let r=0;r<t.length;r++)n[r]=Xe(t[r]*e[r]);return n};function tn(t){const e=Ge(Pe);for(let n=0;n<Pe;){const r=t();if(r.length%3)throw new Error("RejNTTPoly: unaligned block");for(let t=0;n<Pe&&t<=r.length-3;t+=3){const s=8388607&(r[t+0]|r[t+1]<<8|r[t+2]<<16);s<Me&&(e[n++]=s)}}return e}function en(t){const{K:e,L:n,GAMMA1:r,GAMMA2:s,TAU:i,ETA:a,OMEGA:o}=t,{CRH_BYTES:c,TR_BYTES:h,C_TILDE_BYTES:d,XOF128:l,XOF256:u}=t;if(![2,4].includes(a))throw new Error("Wrong ETA");if(![1<<17,1<<19].includes(r))throw new Error("Wrong GAMMA1");if(![Oe,Re].includes(s))throw new Error("Wrong GAMMA2");const p=i*a,f=t=>{const e=Xe(t),n=0|je(e,2*s);if(e-n===Me-1)return{r1:0,r0:n-1|0};return{r1:0|Math.floor((e-n)/(2*s)),r0:n}},y=t=>f(t).r1,m=t=>f(t).r0,g=(t,e)=>t<=s||t>Me-s||t===Me-s&&0===e?0:1,b=(t,e)=>{const n=Math.floor((Me-1)/(2*s)),{r1:r,r0:i}=f(e);return 1===t?i>0?0|Xe(r+1,n):0|Xe(r-1,n):0|r},w=t=>{const e=Xe(t),n=0|je(e,8192);return{r1:0|Math.floor((e-n)/8192),r0:n}},x={bytesLen:o+e,encode:t=>{if(!1===t)throw new Error("hint.encode: hint is false");const n=new Uint8Array(o+e);for(let r=0,s=0;r<e;r++){for(let e=0;e<Pe;e++)0!==t[r][e]&&(n[s++]=e);n[o+r]=s}return n},decode:t=>{const n=[];let r=0;for(let s=0;s<e;s++){const e=Ge(Pe);if(t[o+s]<r||t[o+s]>o)return!1;for(let n=r;n<t[o+s];n++){if(n>r&&t[n]<=t[n-1])return!1;e[t[n]]=1}r=t[o+s],n.push(e)}for(let e=r;e<o;e++)if(0!==t[e])return!1;return n}},A=We(2===a?3:4,t=>a-t,t=>{if(!(-a<=t&&t<=a))throw new Error(`malformed key s1/s3 ${t} outside of ETA range [${-a}, ${a}]`);return t}),k=We(13,t=>4096-t),_=We(10),v=We(r===1<<17?18:20,t=>je(r-t)),E=de(We(s===Oe?6:4),e),I=he(32,de(_,e)),C=he(32,32,h,de(A,n),de(A,e),de(k,e)),B=he(d,de(v,n),x),K=2===a?t=>t<15&&2-t%5:t=>t<9&&4-t;function T(t){const e=Ge(Pe);for(let n=0;n<Pe;){const r=t();for(let t=0;n<Pe&&t<r.length;t+=1){const s=K(15&r[t]),i=K(r[t]>>4&15);!1!==s&&(e[n++]=s),n<Pe&&!1!==i&&(e[n++]=i)}}return e}const U=t=>{const e=Ge(Pe),n=Ut.create({}).update(t),r=new Uint8Array(Ut.blockLen);n.xofInto(r);const s=r.slice(0,8);for(let t=Pe-i,a=8,o=0,c=0;t<Pe;t++){let i=t+1;for(;i>t;)i=r[a++],a<Ut.blockLen||(n.xofInto(r),a=0);e[t]=e[i],e[i]=1-((s[o]>>c++&1)<<1),c>=8&&(o++,c=0)}return e},D=t=>{const e=Ge(Pe),n=Ge(Pe);for(let r=0;r<t.length;r++){const{r0:s,r1:i}=w(t[r]);e[r]=s,n[r]=i}return{r0:e,r1:n}},S=(t,e)=>{for(let n=0;n<Pe;n++)t[n]=b(e[n],t[n]);return t},F=(t,e)=>{const n=Ge(Pe);let r=0;for(let s=0;s<Pe;s++){const i=g(t[s],e[s]);n[s]=i,r+=i}return{v:n,cnt:r}},L=he(32,64,32),H={signRandBytes:32,keygen:t=>{const r=new Uint8Array(34),s=void 0===t;s&&(t=oe(32)),ae(t,32),r.set(t),s&&t.fill(0),r[32]=e,r[33]=n;const[i,a,o]=L.decode(Ut(r,{dkLen:L.bytesLen})),c=u(a),d=[];for(let t=0;t<n;t++)d.push(T(c.get(255&t,t>>8&255)));const p=[];for(let t=n;t<n+e;t++)p.push(T(c.get(255&t,t>>8&255)));const f=d.map(t=>qe.encode(t.slice())),y=[],m=[],g=l(i),b=Ge(Pe);for(let t=0;t<e;t++){b.fill(0);for(let e=0;e<n;e++){const n=tn(g.get(e,t));Ye(b,Ze(n,f[e]))}qe.decode(b);const{r0:e,r1:r}=D(Ye(b,p[t]));y.push(e),m.push(r)}const w=I.encode([i,m]),x=Ut(w,{dkLen:h}),A=C.encode([i,o,x,d,p,y]);return g.clean(),c.clean(),le(i,a,o,d,p,f,b,y,m,x,r),{publicKey:w,secretKey:A}},sign:(t,i,a,h=!1)=>{const[f,g,b,w,x,A]=C.decode(t),k=[],_=l(f);for(let t=0;t<e;t++){const e=[];for(let r=0;r<n;r++)e.push(tn(_.get(r,t)));k.push(e)}_.clean();for(let t=0;t<n;t++)qe.encode(w[t]);for(let t=0;t<e;t++)qe.encode(x[t]),qe.encode(A[t]);const I=h?i:Ut.create({dkLen:c}).update(b).update(i).digest(),K=a||new Uint8Array(32);ae(K);const T=Ut.create({dkLen:c}).update(g).update(K).update(I).digest();ae(T,c);const D=u(T,v.bytesLen);t:for(let t=0;;){const i=[];for(let e=0;e<n;e++,t++)i.push(v.decode(D.get(255&t,t>>8)()));const a=i.map(t=>qe.encode(t.slice())),c=[];for(let t=0;t<e;t++){const e=Ge(Pe);for(let r=0;r<n;r++)Ye(e,Ze(k[t][r],a[r]));qe.decode(e),c.push(e)}const h=c.map(t=>t.map(y)),l=Ut.create({dkLen:d}).update(I).update(E.encode(h)).digest(),u=qe.encode(U(l)),f=w.map(t=>Ze(t,u));for(let t=0;t<n;t++)if(Ye(qe.decode(f[t]),i[t]),ze(f[t],r-p))continue t;let g=0;const b=[];for(let t=0;t<e;t++){const e=qe.decode(Ze(x[t],u)),n=Je(c[t],e).map(m);if(ze(n,s-p))continue t;const r=qe.decode(Ze(A[t],u));if(ze(r,s))continue t;Ye(n,r);const i=F(n,h[t]);b.push(i.v),g+=i.cnt}if(g>o)continue;D.clean();const _=B.encode([l,f,b]);return le(l,f,b,u,h,c,a,i,T,I,w,x,A,...k),_}throw new Error("Unreachable code path reached, report this error")},verify:(t,s,i,a=!1)=>{const[u,f]=I.decode(t),y=Ut(t,{dkLen:h});if(i.length!==B.bytesLen)return!1;const[m,g,b]=B.decode(i);if(!1===b)return!1;for(let t=0;t<n;t++)if(ze(g[t],r-p))return!1;const w=a?s:Ut.create({dkLen:c}).update(y).update(s).digest(),x=qe.encode(U(m)),A=g.map(t=>t.slice());for(let t=0;t<n;t++)qe.encode(A[t]);const k=[],_=l(u);for(let t=0;t<e;t++){const e=Ze(qe.encode(Qe(f[t])),x),r=Ge(Pe);for(let e=0;e<n;e++){const n=tn(_.get(e,t));Ye(r,Ze(n,A[e]))}const s=qe.decode(Je(r,e));k.push(S(s,b[t]))}_.clean();const v=Ut.create({dkLen:d}).update(w).update(E.encode(k)).digest();for(const t of b){if(!(t.reduce((t,e)=>t+e,0)<=o))return!1}for(const t of g)if(ze(t,r-p))return!1;return ce(m,v)}};return{internal:H,keygen:H.keygen,signRandBytes:H.signRandBytes,sign:(t,e,n=pe,r)=>{const s=fe(e,n),i=H.sign(t,s,r);return s.fill(0),i},verify:(t,e,n,r=pe)=>H.verify(t,fe(e,r),n),prehash:t=>({sign:(e,n,r=pe,s)=>{const i=me(t,n,r),a=H.sign(e,i,s);return i.fill(0),a},verify:(e,n,r,s=pe)=>H.verify(e,me(t,n,s),r)})}}const nn=en({...Ne,CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:xe,XOF256:Ae});class rn{constructor(t){if(t&&"falcon512_n3_v1"!==t&&"falcon1024_n3_v1"!==t)throw new Error(`Invalid algorithm ID: ${t}\nSupported algorithms: falcon512_n3_v1, falcon1024_n3_v1\nLeave blank for default: falcon512_n3_v1`);this.algid=t||"falcon512_n3_v1"}async init(){this.kernel=await s.getKernel(this.algid)}async genkey(t){this.keypair=t?this.kernel.genkey(t):this.kernel.genkey()}async sign(t,e){return e?this.kernel.sign(t,this.keypair.sk,e):this.kernel.sign(t,this.keypair.sk)}async verify(t,e,n){return this.kernel.verify(e,t,n)}async publicKeyCreate(t){return this.kernel.publicKeyCreate(t)}async setKeypair(t){this.keypair=t}async getPublicKey(){return this.keypair.pk}async getPrivateKey(){return this.keypair.sk}async getAlgid(){return this.algid}async getKeypair(){return this.keypair}async getKernel(){return this.kernel}static uint8ArrayToHex(t){return Array.from(t).map(t=>t.toString(16).padStart(2,"0")).join("")}static hexToUint8Array(t){(t=t.replace(/[^0-9a-fA-F]/g,"")).length%2!=0&&(t="0"+t);const e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n/2]=parseInt(t.substring(n,n+2),16);return e}async getPublicKeyHex(){const t=await this.getPublicKey();return rn.uint8ArrayToHex(t)}async getPrivateKeyHex(){const t=await this.getPrivateKey();return rn.uint8ArrayToHex(t)}async signHex(t){const e=await this.sign(t);return rn.uint8ArrayToHex(e)}async verifyHex(t,e,n){const r=rn.hexToUint8Array(e),s=rn.hexToUint8Array(n);return this.verify(t,r,s)}async publicKeyCreateHex(t){const e=rn.hexToUint8Array(t),n=await this.publicKeyCreate(e);return rn.uint8ArrayToHex(n)}async setPrivateKeyHex(t){const e=rn.hexToUint8Array(t),n=await this.publicKeyCreate(e);return this.keypair={genkeySeed:new Uint8Array(0),sk:e,pk:n},rn.uint8ArrayToHex(n)}static uint8ArrayToBase64(t){return Buffer.from(t).toString("base64")}static base64ToUint8Array(t){return Buffer.from(t,"base64")}async getPublicKeyBase64(){const t=await this.getPublicKey();return rn.uint8ArrayToBase64(t)}async getPrivateKeyBase64(){const t=await this.getPrivateKey();return rn.uint8ArrayToBase64(t)}async signBase64(t){const e=await this.sign(t);return rn.uint8ArrayToBase64(e)}async verifyBase64(t,e,n){const r=rn.base64ToUint8Array(e),s=rn.base64ToUint8Array(n);return this.verify(t,r,s)}async publicKeyCreateBase64(t){const e=rn.base64ToUint8Array(t),n=await this.publicKeyCreate(e);return rn.uint8ArrayToBase64(n)}async setPrivateKeyBase64(t){const e=rn.base64ToUint8Array(t),n=await this.publicKeyCreate(e);return this.keypair={genkeySeed:new Uint8Array(0),sk:e,pk:n},rn.uint8ArrayToBase64(n)}}class sn{constructor(){this.ml_dsa_signing_keypair=null,this.falcon_signing_keypair=null,this.ml_kem_encryption_keypair=null,this.ml_kem_aes_parameters=null}static async hash(t,e="sha3-256"){return It.create().update(t).digest()}static async verify_ml_dsa(t,e,n){return nn.verify(n,e,t)}static async verify_falcon(t,e,n){const r=new rn;return await r.init(),r.verify(e,t,n)}async sign_ml_dsa(t,e){if(e||(e=this.ml_dsa_signing_keypair),!e.privateKey)throw new Error("ml_dsa_signing_keypair.privateKey is not set");return nn.sign(e.privateKey,t)}async sign_falcon(t,e){if(e||(e=this.falcon_signing_keypair),!e.privateKey)throw new Error("falcon_signing_keypair.privateKey is not set");const n=new rn;return await n.init(),await n.setKeypair({genkeySeed:this.falcon_signing_keypair.genKey,sk:this.falcon_signing_keypair.privateKey,pk:this.falcon_signing_keypair.publicKey}),n.sign(t)}async encapsulate_ml_kem(t){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");return He.encapsulate(t)}async decapsulate_ml_kem(t){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");return He.decapsulate(t,this.ml_kem_encryption_keypair.privateKey)}async encrypt_ml_kem_aes(t,e){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");const n=He.encapsulate(e),r=h.randomBytes(12),s=h.createCipheriv("aes-256-gcm",n.sharedSecret,r),i=Buffer.concat([s.update(t),s.final()]),a=s.getAuthTag(),o=Buffer.concat([r,i,a]);return{cipherText:n.cipherText,encryptedMessage:o}}async decrypt_ml_kem_aes(t,e){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");const n=He.decapsulate(e,this.ml_kem_encryption_keypair.privateKey),r=t.slice(0,12),s=t.slice(12,-16),i=t.slice(-16),a=h.createDecipheriv("aes-256-gcm",n,r);a.setAuthTag(i);return Buffer.concat([a.update(s),a.final()])}async generate_ml_dsa_signing_keypair(t=null){t||(t=r.randomBytes(32));const e=nn.keygen(t);this.ml_dsa_signing_keypair={publicKey:e.publicKey,privateKey:e.secretKey}}async generate_falcon_signing_keypair(t=null){t||(t=r.randomBytes(48));const e=new rn;await e.init(),await e.genkey(t);const n=await e.getKeypair();this.falcon_signing_keypair={genKey:n.genkeySeed,publicKey:n.pk,privateKey:n.sk}}async generate_ml_kem_encryption_keypair(t=null){t||(t=r.randomBytes(64));let e=He.keygen(t);this.ml_kem_encryption_keypair={privateKey:e.secretKey,publicKey:e.publicKey}}}class an extends at{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,M(t);const n=rt(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),G(s)}update(t){return O(this),this.iHash.update(t),this}digestInto(t){O(this),P(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:s,blockLen:i,outputLen:a}=this;return t.finished=r,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const on=(t,e,n)=>new an(t,e).update(n).digest();function cn(t,e,n,r){M(t);const s=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("options should be object or undefined");return Object.assign(t,e)}({dkLen:32,asyncTick:10},r),{c:i,dkLen:a,asyncTick:o}=s;if(H(i),H(a),H(o),i<1)throw new Error("iterations (c) should be >= 1");const c=st(e),h=st(n),d=new Uint8Array(a),l=on.create(t,c),u=l._cloneInto().update(h);return{c:i,dkLen:a,asyncTick:o,DK:d,PRF:l,PRFSalt:u}}function hn(t,e,n,r){const{c:s,dkLen:i,DK:a,PRF:o,PRFSalt:c}=cn(t,e,n,r);let h;const d=new Uint8Array(4),l=X(d),u=new Uint8Array(o.outputLen);for(let t=1,e=0;e<i;t++,e+=o.outputLen){const n=a.subarray(e,e+o.outputLen);l.setInt32(0,t,!1),(h=c._cloneInto(h)).update(d).digestInto(u),n.set(u.subarray(0,n.length));for(let t=1;t<s;t++){o._cloneInto(h).update(u).digestInto(u);for(let t=0;t<n.length;t++)n[t]^=u[t]}}return function(t,e,n,r,s){return t.destroy(),e.destroy(),r&&r.destroy(),G(s),n}(o,c,a,h,u)}function dn(t){if("string"!=typeof t)throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}on.create=(t,e)=>new an(t,e);function ln(t,e=""){return hn(ne,function(t){const e=dn(t),n=e.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:n}}(t).nfkd,(t=>dn("mnemonic"+t))(e),{c:2048,dkLen:64})}function un(t){t=t.slice(2);let e=new Uint8Array(64);for(let n=0;n<t.length;n+=2){const r=t.substr(n,2),s=parseInt(r,16);e[n/2]=s}return e}class pn{static sha256(t){const e=i.sha256.create();return e.update(t),e.digest().toHex()}static sha3_512(t){return Bt(t)}}const fn="aes-256-cbc";class yn{static new(){const t=i.random.getBytesSync(32);return i.pki.ed25519.generateKeyPair({seed:t})}static newFromSeed(t){"string"==typeof t&&(t=ln(t));const e=t.toString(),n=pn.sha256(e),r=Buffer.from(n,"hex");return i.pki.ed25519.generateKeyPair({seed:r})}static async save(t,e,n="hex"){if("hex"===n){let n=yn.saveToHex(t.privateKey);await a.promises.writeFile(e,n)}else await a.promises.writeFile(e,JSON.stringify(t.privateKey))}static saveToHex(t){return"0x"+t.toString("hex")}static async saveEncrypted(t,e,n){const r=h.createCipher(fn,n),s=t.privateKey.toString("hex"),i=r.update(s,"utf8","hex");await a.promises.writeFile(e,i)}static async loadEncrypted(t,e){let n={privateKey:null,publicKey:null};const r=h.createDecipher(fn,e),s=await a.promises.readFile(t,"utf8");return n=r.update(s,"hex","utf8").includes("{")?yn.loadFromBufferString(s):yn.loadFromHex(s),n}static async load(t,e=!0){let n,r={privateKey:null,publicKey:null};return n=e?await a.promises.readFile(t,"utf8"):t,r=n.includes("{")?yn.loadFromBufferString(n):yn.loadFromHex(n),r}static loadFromHex(t){let e={publicKey:null,privateKey:null};t=t.slice(2);let n=new Uint8Array(64);for(let e=0;e<t.length;e+=2){const r=t.substr(e,2),s=parseInt(r,16);n[e/2]=s}return e.privateKey=Buffer.from(n),e.publicKey=i.pki.ed25519.publicKeyFromPrivateKey({privateKey:e.privateKey}),e}static loadFromBufferString(t){let e={publicKey:null,privateKey:null};return e.privateKey=Buffer.from(JSON.parse(t)),e.publicKey=i.pki.ed25519.publicKeyFromPrivateKey({privateKey:e.privateKey}),e}static sign(t,e){return"string"==e.type&&(e=un(e)),i.pki.ed25519.sign({message:t,encoding:"utf8",privateKey:e})}static verify(t,e,n){return"string"==e.type&&(e=un(e)),"string"==n.type&&(n=un(n)),"Buffer"==e.type&&(e=Buffer.from(e)),"Buffer"==n.type&&(n=Buffer.from(n)),i.pki.ed25519.verify({message:t,encoding:"utf8",signature:e,publicKey:n})}}yn.ed25519={sign:(t,e)=>("string"==e.type&&(e=un(e)),i.pki.ed25519.sign({message:t,encoding:"utf8",privateKey:e})),verify:(t,e,n)=>("string"==e.type&&(e=un(e)),"string"==n.type&&(n=un(n)),"Buffer"==e.type&&(e=Buffer.from(e)),"Buffer"==n.type&&(n=Buffer.from(n)),i.pki.ed25519.verify({message:t,encoding:"utf8",signature:e,publicKey:n}))},yn.rsa={encrypt:(t,e)=>{"Buffer"==e.type&&(e=Buffer.from(e));let n=i.util.encode64(t);return[!0,e.encrypt(n)]},decrypt:(t,e=null)=>{try{"Buffer"==e.type&&(e=Buffer.from(e))}catch(t){}if(!e)return[!1,"No private key found"];let n=i.util.decode64(t);return[!0,e.decrypt(n).toString()]}};const mn=Uint8Array.from([0]),gn=Uint8Array.of();const bn=(t,e,n,r,s)=>function(t,e,n,r=32){M(t),H(r);const s=t.outputLen;if(r>255*s)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/s);void 0===n&&(n=gn);const a=new Uint8Array(i*s),o=on.create(t,e),c=o._cloneInto(),h=new Uint8Array(o.outputLen);for(let t=0;t<i;t++)mn[0]=t+1,c.update(0===t?gn:h).update(n).update(mn).digestInto(h),a.set(h,s*t),o._cloneInto(c);return o.destroy(),c.destroy(),G(h,mn),a.slice(0,r)}(t,function(t,e,n){return M(t),on(t,rt(n),rt(e))}(t,e,n),r,s);function wn(t){return"0x"+Array.from(t,t=>t.toString(16).padStart(2,"0")).join("")}class xn{constructor(t,e){this.enigma=new sn,this.masterSeed=e,this.instanceId=t}static getInstance(t,e){const n=t||xn.DEFAULT_INSTANCE_ID;return xn.instances.has(n)?e&&!xn.instances.get(n).masterSeed&&(xn.instances.get(n).masterSeed=e):xn.instances.set(n,new xn(n,e)),xn.instances.get(n)}getId(){return this.instanceId}static getInstanceIds(){return Array.from(xn.instances.keys())}static removeInstance(t){return xn.instances.delete(t)}async ensureSeed(t){t||this.masterSeed?t&&(this.masterSeed=t):(t=ct(128),this.masterSeed=t),this.masterSeed.length}async deriveSeed(t,e){if(await this.ensureSeed(e),"ed25519"===t)return bn(te,this.masterSeed,"master seed","ed25519",32);if("falcon"===t)return bn(te,this.masterSeed,"master seed","falcon",48);if("ml-dsa"===t)return bn(te,this.masterSeed,"master seed","ml-dsa",32);if("ml-kem-aes"===t)return bn(te,this.masterSeed,"master seed","ml-kem-aes",64);if("rsa"===t)return bn(te,this.masterSeed,"master seed","rsa",32);throw new Error("Invalid algorithm")}async generateAllIdentities(t){await this.generateIdentity("ed25519",t),await this.generateIdentity("falcon",t),await this.generateIdentity("ml-dsa",t),await this.generateIdentity("ml-kem-aes",t)}async generateIdentity(t,e){let n;if(n=e?await this.deriveSeed(t,e):await this.deriveSeed(t),"ed25519"===t)this.ed25519KeyPair=yn.newFromSeed(n);else if("falcon"===t)await this.enigma.generate_falcon_signing_keypair(n);else if("ml-dsa"===t)await this.enigma.generate_ml_dsa_signing_keypair(n);else if("ml-kem-aes"===t)await this.enigma.generate_ml_kem_encryption_keypair(n);else{if("rsa"!==t)throw new Error("Invalid algorithm");{var r=d.random.createInstance();const t=(new TextDecoder).decode(n);r.seedFileSync=()=>t,this.rsaKeyPair=await d.pki.rsa.generateKeyPair({bits:3072,prng:r,workers:2})}}}async getIdentity(t){if("falcon"===t)return this.enigma.falcon_signing_keypair;if("ml-dsa"===t)return this.enigma.ml_dsa_signing_keypair;if("ml-kem-aes"===t)return this.enigma.ml_kem_encryption_keypair;if("ed25519"===t)return{publicKey:this.ed25519KeyPair.publicKey,privateKey:this.ed25519KeyPair.privateKey};if("rsa"===t)return{publicKey:this.rsaKeyPair.publicKey,privateKey:this.rsaKeyPair.privateKey};throw new Error("Invalid algorithm")}async encrypt(t,e,n){let r={algorithm:t,encryptedData:new Uint8Array};if("ml-kem-aes"===t){const{cipherText:t,encryptedMessage:s}=await this.enigma.encrypt_ml_kem_aes(e,n);r.cipherText=t,r.encryptedData=s}else if("rsa"===t){if(!this.rsaKeyPair)throw new Error("RSA key pair not generated");const t=(new TextDecoder).decode(e);let n=this.rsaKeyPair.publicKey.encrypt(t);r.encryptedData=(new TextEncoder).encode(n)}return r}async sign(t,e){let n;if("ed25519"===t){if(!this.ed25519KeyPair)throw new Error("Ed25519 key pair not generated");n={algorithm:"ed25519",signature:yn.sign((new TextDecoder).decode(e),this.ed25519KeyPair.privateKey),message:e,publicKey:this.ed25519KeyPair.publicKey}}else if("ml-dsa"===t)n={algorithm:t,signature:await this.enigma.sign_ml_dsa(e),message:e,publicKey:this.enigma.ml_dsa_signing_keypair.publicKey};else if("falcon"===t){let r=(new TextDecoder).decode(e);n={algorithm:t,signature:await this.enigma.sign_falcon(r),message:e,publicKey:this.enigma.falcon_signing_keypair.publicKey}}return n}async decrypt(t){if("ml-kem-aes"===t.algorithm)return this.enigma.decrypt_ml_kem_aes(t.encryptedData,t.cipherText);if("rsa"===t.algorithm){const e=(new TextDecoder).decode(t.encryptedData);let n=this.rsaKeyPair.privateKey.decrypt(e);return(new TextEncoder).encode(n)}throw new Error("Invalid algorithm")}async verify(t){if("ml-dsa"===t.algorithm)return await sn.verify_ml_dsa(t.signature,t.message,t.publicKey);if("falcon"===t.algorithm){const e=(new TextDecoder).decode(t.message);return await sn.verify_falcon(t.signature,e,t.publicKey)}if("ed25519"===t.algorithm){const e=(new TextDecoder).decode(t.message);return yn.verify(e,t.signature,t.publicKey)}throw new Error("Invalid algorithm")}}xn.supportedPQCAlgorithms=["falcon","ml-dsa"],xn.instances=new Map,xn.DEFAULT_INSTANCE_ID="default",new Proxy({},{get(t,e){if(e in xn&&"function"==typeof xn[e])return xn[e].bind(xn);const n=xn.getInstance(),r=n[e];return"function"==typeof r?r.bind(n):r}});const An={content:{type:"",from:"",to:"",amount:0,data:["",""],nonce:0,timestamp:0,transaction_fee:{network_fee:0,rpc_fee:0,additional_fee:0}},signature:null,hash:"",status:"",blockNumber:null};class kn{static async generate(t,e=!1){const n=[],{content:r}=t;switch(r.type){case"demoswork":case"genesis":break;case"native":var s=await _n.handle(t,e);n.push(...s);break;case"web2Request":case"crosschainOperation":const a=this.createAssignEdit(r,t.hash);n.push(a);break;case"identity":var i=await vn.handle(t);n.push(...i)}t:try{if("identity"===r.type)break t;let s=await this.createGasEdit(r.from_ed25519_address,t.hash,e,1);n.push(s)}catch(t){throw new Error("Error creating gas edit: "+t)}n.push(this.createNonceEdit(r.from_ed25519_address,t.hash));for(const t of n)t.account.startsWith("0x")||(t.account="0x"+t.account);return n}static async createGasEdit(t,e,n=!1,r=1){return{type:"balance",account:t,operation:n?"add":"remove",amount:r,txhash:e,isRollback:n}}static createAssignEdit(t,e,n=!1){return{type:"assign",account:t.from_ed25519_address,context:"web2Request"===t.type?"web2":"xm",txhash:e,isRollback:n}}static createNonceEdit(t,e,n=!1){return{type:"nonce",operation:"add",account:t,amount:1,txhash:e,isRollback:n}}}class _n{static async handle(t,e=!1){let n=[],r=t.content.data[1];if("send"===r.nativeOperation){var[s,i]=r.args,a={type:"balance",operation:"remove",isRollback:e,account:t.content.from_ed25519_address,txhash:t.hash,amount:i};n.push(a);var o={type:"balance",operation:"add",isRollback:e,account:s,txhash:t.hash,amount:i};n.push(o)}return n}}class vn{static async handle(t){const e=[],n=t.content.data[1],r={account:t.content.from_ed25519_address,type:"identity",operation:n.method.endsWith("assign")?"add":"remove",txhash:t.hash,isRollback:!1,context:n.context,data:null,referralCode:null};switch(n.method){case"xm_identity_assign":{const e=n.payload.target_identity;if(e.isEVM&&!e.chainId)throw new Error("Failed: chainId not provided");const s=structuredClone(e);r.data={...s,timestamp:t.content.timestamp},r.referralCode=n.payload.referralCode;break}case"pqc_identity_assign":r.data=n.payload.map(e=>({...e,timestamp:t.content.timestamp}));break;case"web2_identity_assign":{const e=n.payload;r.data={context:e.context,data:{username:e.username,userId:e.userId,proof:e.proof,proofHash:pn.sha256(e.proof),timestamp:t.content.timestamp}},r.referralCode=n.payload.referralCode;break}case"xm_identity_remove":case"web2_identity_remove":case"pqc_identity_remove":r.data=n.payload}return e.push(r),e}}function En(t,e="Missing required element",n=!0){if(!t){if(n)throw new Error("[REQUIRED] "+e);return!1}return!0}const In={empty:function(){return structuredClone(An)},prepare:async function(t=null){const e=structuredClone(An);return t&&(e.content.data=t),e},async pay(t,e,n){En(n.keypair,"Wallet not connected");let r=In.empty();const{publicKey:s}=await n.crypto.getIdentity("ed25519"),i=wn(s),a=await n.getAddressNonce(i);return r.content.to=t,r.content.nonce=a+1,r.content.amount=e,r.content.type="native",r.content.timestamp=Date.now(),r.content.data=["native",{nativeOperation:"send",args:[t,e]}],await n.sign(r)},transfer:(t,e,n)=>In.pay(t,e,n),sign:async function(t,e,n){return En(e,"Private key not provided"),n&&n.algorithm||(n={algorithm:"ed25519"}),t.content.timestamp&&0!==t.content.timestamp||(t.content.timestamp=Date.now()),t.content.from=wn(e.publicKey),t.content.gcr_edits=await kn.generate(t),t.hash=await async function(t){const e=(new TextEncoder).encode(t),n=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("")}(JSON.stringify(t.content)),t.signature=await In.signWithAlgorithm(t.hash,e,{algorithm:n.algorithm}),t},signWithAlgorithm:async function(t,e,n){if(En(e,"Private key not provided"),En(n&&n.algorithm,"Algorithm not provided"),"ed25519"===n.algorithm){return{type:"ed25519",data:wn(yn.sign(t,e.privateKey))}}const r=new sn;if("falcon"===n.algorithm){return{type:"falcon",data:wn(await r.sign_falcon(t,e))}}if("ml-dsa"===n.algorithm){const n=(new TextEncoder).encode(t);return{type:"ml-dsa",data:wn(await r.sign_ml_dsa(n,e))}}throw new Error("Unsupported algorithm: "+n.algorithm)},confirm:async function(t,e){let n=await e.call("execute","",t,"confirmTx");if(!n.response.data.valid)throw new Error("[Confirm] Transaction is not valid: "+n.response.data.message);return n},broadcast:async function(t,e){if(!t.response.data.valid)throw new Error("[Broadcast] Transaction is not valid: "+t.response.data.message);const n=await e.call("execute","",t,"broadcastTx");try{return{...n,response:JSON.parse(n.response)}}catch(t){return n}},async store(t,e){En(e.keypair,"Wallet not connected");let n=In.empty();const{publicKey:r}=await e.crypto.getIdentity("ed25519"),s=wn(r),i=await e.getAddressNonce(s),a=Buffer.from(t).toString("base64");return n.content.to=s,n.content.nonce=i+1,n.content.amount=0,n.content.type="storage",n.content.timestamp=Date.now(),n.content.data=["storage",{bytes:a}],await e.sign(n)},async createL2PSHashUpdate(t,e,n,r){En(r.keypair,"Wallet not connected"),En(t,"L2PS UID is required"),En(e,"Consolidated hash is required"),En(n>=0,"Transaction count must be non-negative");let s=In.empty();const{publicKey:i}=await r.crypto.getIdentity("ed25519"),a=wn(i),o=await r.getAddressNonce(a);return s.content.to=a,s.content.nonce=o+1,s.content.amount=0,s.content.type="l2ps_hash_update",s.content.timestamp=Date.now(),s.content.data=["l2ps_hash_update",{l2ps_uid:t,consolidated_hash:e,transaction_count:n,timestamp:Date.now()}],await r.sign(s)}};exports.CoinFinder=class{static validateChain(t){if(!Object.values(f).includes(t))throw new Error(`Invalid chain: ${t}`)}static async findWrappedToken(t,e){return this.validateChain(t),this.validateChain(e),y[t].wrapped?.[e]?.mainnet||!1}static getNativeForSupportedChain(t,e=1){const[n,r]=t.split("_");switch(n){case f.ETHEREUM:case f.BSC:case f.ARBITRUM:case f.OPTIMISM:if(e!=={[f.ETHEREUM]:p.eth.mainnet,[f.BSC]:p.bsc.mainnet,[f.ARBITRUM]:p.arbitrum.mainnet,[f.OPTIMISM]:p.optimism.mainnet}[n])throw new Error(`Chain ID doesn't match ${n}`);return y.ethereum[r];case f.SOLANA:case f.MULTIVERSX:case f.XRP:case f.BITCOIN:case f.TON:if(1!==e)throw new Error("Non-EVM chains only support targetChainId 1");return y[n][r];default:throw new Error(`Unsupported chain: ${t}`)}}},exports.EvmCoinFinder=class{static getChainName(t){switch(t){case p.eth.mainnet:return f.ETHEREUM;case p.bsc.mainnet:return f.BSC;case p.arbitrum.mainnet:return f.ARBITRUM;case p.optimism.mainnet:return f.OPTIMISM;default:throw new Error(`Unsupported chain ID: ${t}`)}}static isValidAddress(t){return c.isAddress(t)}static getChainNameFromId(t){switch(t){case p.eth.mainnet:return f.ETHEREUM;case p.bsc.mainnet:return f.BSC;case p.arbitrum.mainnet:return f.ARBITRUM;case p.optimism.mainnet:return f.OPTIMISM;default:return}}static async getRandomProvider(t){const e=m.evm[t.toString()].filter(t=>!t.includes("flashbots.net")&&!t.includes("payload.de"));if(!e||0===e.length)throw new Error(`No providers found for chain ${t}`);const n=[...e].sort(()=>Math.random()-.5);for(const t of n)try{const e=new c.JsonRpcProvider(t,void 0,{staticNetwork:!0});return await e.getNetwork(),e}catch(t){continue}throw new Error(`All RPC providers failed for chain ${t}`)}static validateChainId(t){if(!Object.values(p).some(e=>Object.values(e).includes(t)))throw new g(`Unsupported chain ID: ${t}`,"UNSUPPORTED_CHAIN_ID")}static async findNativeEth(t){const e={};for(const n of t){let t;switch(this.validateChainId(n),n){case p.eth.mainnet:t=y.ethereum.wrapped.ethereum.mainnet;break;case p.bsc.mainnet:t=y.ethereum.wrapped.bsc.mainnet;break;case p.arbitrum.mainnet:t=y.ethereum.wrapped.arbitrum.mainnet;break;case p.optimism.mainnet:t=y.ethereum.wrapped.optimism.mainnet}t&&(e[n]={native:y.ethereum.mainnet,wrapped:t})}return e}static async findWrappedAssets(t){const e={};for(const n of t)this.validateChainId(n),e[n]={native:y.ethereum.mainnet,wrapped:y.ethereum.wrapped[this.getChainName(n)]?.mainnet||!1};return e}static async findTokenPairs(t,e,n){if(!this.isValidAddress(t))throw new g("Invalid token address","INVALID_ADDRESS",{address:t});const r={},s=await this.getRandomProvider(e);if("0x"===await s.getCode(t))throw new Error("Token contract not found on source chain");const i=this.getChainNameFromId(e);if(!i)throw new Error(`Unsupported chain ID: ${e}`);for(const s of n){if(s===e){r[s]={native:t,wrapped:!1};continue}const n=this.getChainNameFromId(s);n?t!==y.usdc[i]?.mainnet?t!==y.usdt[i]?.mainnet?r[s]={native:t,wrapped:!1}:r[s]={native:t,wrapped:y.usdt[n]?.mainnet||!1}:r[s]={native:t,wrapped:y.usdc[n]?.mainnet||!1}:r[s]={native:t,wrapped:!1}}return r}static getNativeForSupportedChain(t,e){switch(t){case f.ETHEREUM:if(e!==p.eth.mainnet)throw new Error("Chain ID doesn't match ethereum");return y.ethereum.mainnet;case f.BSC:if(e!==p.bsc.mainnet)throw new Error("Chain ID doesn't match bsc");break;case f.ARBITRUM:if(e!==p.arbitrum.mainnet)throw new Error("Chain ID doesn't match arbitrum");break;case f.OPTIMISM:if(e!==p.optimism.mainnet)throw new Error("Chain ID doesn't match optimism");break;default:throw new Error(`Unsupported chain: ${t}`)}return y.ethereum.mainnet}},exports.Identities=class{constructor(){this.formats={web2:{github:["https://gist.github.com","https://raw.githubusercontent.com","https://gist.githubusercontent.com"],twitter:["https://x.com","https://twitter.com"]}}}async createWeb2ProofPayload(t){const e="dw2p",n=await t.crypto.sign(t.algorithm,(new TextEncoder).encode(e));return`demos:${e}:${t.algorithm}:${wn(n.signature)}`}async inferIdentity(t,e,n){if("web2"===e&&!this.formats.web2[n.context].some(t=>n.proof.startsWith(t))){const t=`Invalid ${n.context} proof format. Supported formats are: ${this.formats.web2[n.context].join(", ")}`;throw new Error(t)}const r=In.empty(),s=wn((await t.crypto.getIdentity("ed25519")).publicKey);r.content={...r.content,type:"identity",to:s,amount:0,data:["identity",{context:e,method:e+"_identity_assign",payload:n}],nonce:1,timestamp:Date.now()};const i=await t.sign(r);return await t.confirm(i)}async removeIdentity(t,e,n){const r=In.empty(),s=wn((await t.crypto.getIdentity("ed25519")).publicKey);r.content={...r.content,type:"identity",to:s,amount:0,data:["identity",{context:e,method:e+"_identity_remove",payload:n}],nonce:1,timestamp:Date.now()};const i=await t.sign(r);return await t.confirm(i)}async inferXmIdentity(t,e,n){return await this.inferIdentity(t,"xm",{...e,referralCode:n})}async inferWeb2Identity(t,e){return await this.inferIdentity(t,"web2",e)}async removeXmIdentity(t,e){return await this.removeIdentity(t,"xm",e)}async removeWeb2Identity(t,e){return await this.removeIdentity(t,"web2",e)}async addGithubIdentity(t,e,r){const s=e.split("/")[3],i=await n.get(`https://api.github.com/users/${s}`);if(!i.data.login)throw new Error("Failed to get github user");let a={context:"github",proof:e,username:i.data.login,userId:i.data.id,referralCode:r};return await this.inferIdentity(t,"web2",a)}async addTwitterIdentity(t,e,n){const r=await t.web2.getTweet(e);if(!r.success)throw new Error(r.error);if(!r.tweet.userId||!r.tweet.username)throw new Error("Unable to get twitter user info. Please try again.");let s={context:"twitter",proof:e,username:r.tweet.username,userId:r.tweet.userId,referralCode:n};return await this.inferIdentity(t,"web2",s)}async bindPqcIdentity(t,e="all"){let n=[];if("all"===e)await t.crypto.generateAllIdentities(),n=xn.supportedPQCAlgorithms;else for(const r of e)await t.crypto.generateIdentity(r),n.push(r);const r=[];for(const e of n){const n=wn((await t.crypto.getIdentity(e)).publicKey),s=await t.crypto.sign("ed25519",(new TextEncoder).encode(n));r.push({algorithm:e,address:n,signature:wn(s.signature)})}return await this.inferIdentity(t,"pqc",r)}async removePqcIdentity(t,e="all"){let n=[];if("all"===e)await t.crypto.generateAllIdentities(),n=xn.supportedPQCAlgorithms;else for(const r of e)await t.crypto.generateIdentity(r),n.push(r);const r=[];for(const e of n){const n=await t.crypto.getIdentity(e);r.push({algorithm:e,address:wn(n.publicKey)})}return await this.removeIdentity(t,"pqc",r)}async getIdentities(t,e="getIdentities",n){if(!n){n=wn((await t.crypto.getIdentity("ed25519")).publicKey)}const r={method:"gcr_routine",params:[{method:e,params:[n]}]};return await t.rpcCall(r,!0)}async getXmIdentities(t,e){return await this.getIdentities(t,"getXmIdentities",e)}async getWeb2Identities(t,e){return await this.getIdentities(t,"getWeb2Identities",e)}async getUserPoints(t,e){En(e||t.walletConnected,"No address provided and no wallet connected"),e||(e=await t.getEd25519Address());const n={method:"gcr_routine",params:[{method:"getPoints",params:[e]}]};return await t.rpcCall(n,!0)}async validateReferralCode(t,e){const n={method:"gcr_routine",params:[{method:"validateReferralCode",params:[e]}]};return await t.rpcCall(n,!0)}async getReferralInfo(t,e){e||(e=await t.getEd25519Address());const n={method:"gcr_routine",params:[{method:"getReferralInfo",params:[e]}]};return await t.rpcCall(n,!0)}};
|
|
1
|
+
"use strict";
|
|
2
|
+
/** NOTE
|
|
3
|
+
* The finders should use public RPCs with failover mechanisms through the Providers singleton getter.
|
|
4
|
+
* The getter is automatically initialized, updated and imported in the exported finders.
|
|
5
|
+
* This is to ensure that the finders don't get rate limited or go offline.
|
|
6
|
+
* This also means that the SDK calls should be made locally (using the ip address of the user).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Identities = exports.CoinFinder = exports.EvmCoinFinder = void 0;
|
|
10
|
+
const EvmCoinFinder_1 = require("./EvmCoinFinder");
|
|
11
|
+
Object.defineProperty(exports, "EvmCoinFinder", { enumerable: true, get: function () { return EvmCoinFinder_1.EvmCoinFinder; } });
|
|
12
|
+
const CoinFinder_1 = require("./CoinFinder");
|
|
13
|
+
Object.defineProperty(exports, "CoinFinder", { enumerable: true, get: function () { return CoinFinder_1.CoinFinder; } });
|
|
14
|
+
const Identities_1 = require("./Identities");
|
|
15
|
+
Object.defineProperty(exports, "Identities", { enumerable: true, get: function () { return Identities_1.Identities; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/abstraction/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mDAA+C;AAoB3C,8FApBK,6BAAa,OAoBL;AAnBjB,6CAAyC;AAoBrC,2FApBK,uBAAU,OAoBL;AAnBd,6CAAyC;AAoBrC,2FApBK,uBAAU,OAoBL"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/** NOTE
|
|
4
|
+
* This is the singleton class that contains the list of providers for the abstraction layer.
|
|
5
|
+
* It also contains the methods to register new providers.
|
|
6
|
+
*
|
|
7
|
+
* INFO for developers:
|
|
8
|
+
* - The providers can be registered by adding a new provider registration file in the ./index.ts file.
|
|
9
|
+
* - The provider registration files use the registerEVM and registerChainProviders methods to register the providers.
|
|
10
|
+
* - The registerEVM method takes a chainId and an array of RPC URLs as arguments.
|
|
11
|
+
* - The registerChainProviders method takes a chain type, a network, and an array of RPC URLs as arguments.
|
|
12
|
+
* - For an example of how to register a new provider, see the ./ankr.ts file.
|
|
13
|
+
* - The Providers.ts file export the singleton instance of the AbstractionProviders class, already registered with all providers.
|
|
14
|
+
*
|
|
15
|
+
* NOTE: The Providers object should only used internally (e.g. in EvmCoinFinder.ts and CoinFinder.ts).
|
|
16
|
+
* This is due to the fact that it is initialized with all the providers at runtime.
|
|
17
|
+
*/
|
|
18
|
+
class _AbstractionProviders {
|
|
19
|
+
// This is the list of providers for the abstraction layer
|
|
20
|
+
constructor() {
|
|
21
|
+
this.evm = {};
|
|
22
|
+
this.solana = {
|
|
23
|
+
mainnet: [],
|
|
24
|
+
testnet: [],
|
|
25
|
+
};
|
|
26
|
+
this.multiversx = {
|
|
27
|
+
mainnet: [],
|
|
28
|
+
testnet: [],
|
|
29
|
+
};
|
|
30
|
+
this.xrp = {
|
|
31
|
+
mainnet: [],
|
|
32
|
+
testnet: [],
|
|
33
|
+
};
|
|
34
|
+
this.bitcoin = {
|
|
35
|
+
mainnet: [],
|
|
36
|
+
testnet: [],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Singleton
|
|
40
|
+
static getInstance() {
|
|
41
|
+
if (!_AbstractionProviders._instance) {
|
|
42
|
+
_AbstractionProviders._instance = new _AbstractionProviders();
|
|
43
|
+
}
|
|
44
|
+
return _AbstractionProviders._instance;
|
|
45
|
+
}
|
|
46
|
+
// Register EVM providers
|
|
47
|
+
registerEVM(chainName, rpcUrls) {
|
|
48
|
+
if (!this.evm[chainName]) {
|
|
49
|
+
this.evm[chainName] = [];
|
|
50
|
+
}
|
|
51
|
+
this.evm[chainName].push(...rpcUrls);
|
|
52
|
+
}
|
|
53
|
+
// Register chain providers
|
|
54
|
+
registerChainProviders(chain, network, rpcUrls) {
|
|
55
|
+
if (this[chain] && this[chain][network]) {
|
|
56
|
+
this[chain][network].push(...rpcUrls);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Create and initialize the singleton immediately
|
|
61
|
+
// NOTE We export the getInstance method instead of the instance itself to ensure we update the singleton each time
|
|
62
|
+
const AbstractionProvidersInstance = _AbstractionProviders.getInstance;
|
|
63
|
+
// Export the initialized instance
|
|
64
|
+
exports.default = AbstractionProvidersInstance;
|
|
65
|
+
//# sourceMappingURL=AbstractionProviders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractionProviders.js","sourceRoot":"","sources":["../../../../src/abstraction/providers/AbstractionProviders.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,qBAAqB;IAGvB,0DAA0D;IAC1D;QACI,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,MAAM,GAAG;YACV,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;SACd,CAAA;QACD,IAAI,CAAC,UAAU,GAAG;YACd,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;SACd,CAAA;QACD,IAAI,CAAC,GAAG,GAAG;YACP,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;SACd,CAAA;QACD,IAAI,CAAC,OAAO,GAAG;YACX,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;SACd,CAAA;IACL,CAAC;IACD,YAAY;IACZ,MAAM,CAAC,WAAW;QACd,IAAI,CAAC,qBAAqB,CAAC,SAAS,EAAE,CAAC;YACnC,qBAAqB,CAAC,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAA;QACjE,CAAC;QACD,OAAO,qBAAqB,CAAC,SAAS,CAAA;IAC1C,CAAC;IAqBD,yBAAyB;IACzB,WAAW,CAAC,SAAiB,EAAE,OAAiB;QAC5C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAA;QAC5B,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAA;IACx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