phantasma-sdk-ts 0.1.71
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/.eslintignore +13 -0
- package/.eslintrc.cjs +15 -0
- package/.github/workflows/npm-publish.yml +47 -0
- package/.prettierignore +13 -0
- package/.prettierrc +8 -0
- package/LICENSE +201 -0
- package/README.md +842 -0
- package/babel.config.js +6 -0
- package/core/index.d.ts +10 -0
- package/core/index.d.ts.map +1 -0
- package/core/index.js +25 -0
- package/core/interfaces/IContract.d.ts +27 -0
- package/core/interfaces/IContract.d.ts.map +1 -0
- package/core/interfaces/IContract.js +25 -0
- package/core/interfaces/IKeyPair.d.ts +7 -0
- package/core/interfaces/IKeyPair.d.ts.map +1 -0
- package/core/interfaces/IKeyPair.js +2 -0
- package/core/interfaces/ISerializable.d.ts +6 -0
- package/core/interfaces/ISerializable.d.ts.map +1 -0
- package/core/interfaces/ISerializable.js +9 -0
- package/core/interfaces/IStack.d.ts +7 -0
- package/core/interfaces/IStack.d.ts.map +1 -0
- package/core/interfaces/IStack.js +2 -0
- package/core/interfaces/IToken.d.ts +29 -0
- package/core/interfaces/IToken.d.ts.map +1 -0
- package/core/interfaces/IToken.js +22 -0
- package/core/interfaces/Signature.d.ts +21 -0
- package/core/interfaces/Signature.d.ts.map +1 -0
- package/core/interfaces/Signature.js +31 -0
- package/core/interfaces/index.d.ts +7 -0
- package/core/interfaces/index.d.ts.map +1 -0
- package/core/interfaces/index.js +22 -0
- package/core/ledger/Address-Transcode.d.ts +20 -0
- package/core/ledger/Address-Transcode.d.ts.map +1 -0
- package/core/ledger/Address-Transcode.js +70 -0
- package/core/ledger/Ledger-Commands.d.ts +76 -0
- package/core/ledger/Ledger-Commands.d.ts.map +1 -0
- package/core/ledger/Ledger-Commands.js +530 -0
- package/core/ledger/Ledger-Utils.d.ts +74 -0
- package/core/ledger/Ledger-Utils.d.ts.map +1 -0
- package/core/ledger/Ledger-Utils.js +609 -0
- package/core/ledger/LedgerConfig.d.ts +17 -0
- package/core/ledger/LedgerConfig.d.ts.map +1 -0
- package/core/ledger/LedgerConfig.js +2 -0
- package/core/ledger/Mnemonic.d.ts +35 -0
- package/core/ledger/Mnemonic.d.ts.map +1 -0
- package/core/ledger/Mnemonic.js +65 -0
- package/core/ledger/Transaction-Sign.d.ts +10 -0
- package/core/ledger/Transaction-Sign.d.ts.map +1 -0
- package/core/ledger/Transaction-Sign.js +149 -0
- package/core/ledger/Transaction-Transcode.d.ts +24 -0
- package/core/ledger/Transaction-Transcode.d.ts.map +1 -0
- package/core/ledger/Transaction-Transcode.js +47 -0
- package/core/ledger/index.d.ts +9 -0
- package/core/ledger/index.d.ts.map +1 -0
- package/core/ledger/index.js +24 -0
- package/core/ledger/interfaces/ApplicationNameResponse.d.ts +6 -0
- package/core/ledger/interfaces/ApplicationNameResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/ApplicationNameResponse.js +2 -0
- package/core/ledger/interfaces/Device.d.ts +7 -0
- package/core/ledger/interfaces/Device.d.ts.map +1 -0
- package/core/ledger/interfaces/Device.js +2 -0
- package/core/ledger/interfaces/DeviceResponse.d.ts +7 -0
- package/core/ledger/interfaces/DeviceResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/DeviceResponse.js +2 -0
- package/core/ledger/interfaces/Ledger.d.ts +2 -0
- package/core/ledger/interfaces/Ledger.d.ts.map +1 -0
- package/core/ledger/interfaces/Ledger.js +2 -0
- package/core/ledger/interfaces/LedgerBalanceFromLedgerResponse.d.ts +12 -0
- package/core/ledger/interfaces/LedgerBalanceFromLedgerResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerBalanceFromLedgerResponse.js +2 -0
- package/core/ledger/interfaces/LedgerConfig.d.ts +17 -0
- package/core/ledger/interfaces/LedgerConfig.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerConfig.js +2 -0
- package/core/ledger/interfaces/LedgerDeviceInfoResponse.d.ts +7 -0
- package/core/ledger/interfaces/LedgerDeviceInfoResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerDeviceInfoResponse.js +2 -0
- package/core/ledger/interfaces/LedgerSendTransactionResponse.d.ts +5 -0
- package/core/ledger/interfaces/LedgerSendTransactionResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerSendTransactionResponse.js +2 -0
- package/core/ledger/interfaces/LedgerSigner.d.ts +6 -0
- package/core/ledger/interfaces/LedgerSigner.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerSigner.js +2 -0
- package/core/ledger/interfaces/LedgerSignerData.d.ts +8 -0
- package/core/ledger/interfaces/LedgerSignerData.d.ts.map +1 -0
- package/core/ledger/interfaces/LedgerSignerData.js +2 -0
- package/core/ledger/interfaces/PublicKeyResponse.d.ts +6 -0
- package/core/ledger/interfaces/PublicKeyResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/PublicKeyResponse.js +2 -0
- package/core/ledger/interfaces/SignResponse.d.ts +6 -0
- package/core/ledger/interfaces/SignResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/SignResponse.js +2 -0
- package/core/ledger/interfaces/VersionResponse.d.ts +6 -0
- package/core/ledger/interfaces/VersionResponse.d.ts.map +1 -0
- package/core/ledger/interfaces/VersionResponse.js +2 -0
- package/core/ledger/interfaces/index.d.ts +14 -0
- package/core/ledger/interfaces/index.d.ts.map +1 -0
- package/core/ledger/interfaces/index.js +29 -0
- package/core/ledger/ledger-comm.d.ts +85 -0
- package/core/ledger/ledger-comm.d.ts.map +1 -0
- package/core/ledger/ledger-comm.js +613 -0
- package/core/link/easyConnect.d.ts +23 -0
- package/core/link/easyConnect.d.ts.map +1 -0
- package/core/link/easyConnect.js +237 -0
- package/core/link/easyScript.d.ts +13 -0
- package/core/link/easyScript.d.ts.map +1 -0
- package/core/link/easyScript.js +52 -0
- package/core/link/index.d.ts +2 -0
- package/core/link/index.d.ts.map +1 -0
- package/core/link/index.js +17 -0
- package/core/link/interfaces/IAccount.d.ts +13 -0
- package/core/link/interfaces/IAccount.d.ts.map +1 -0
- package/core/link/interfaces/IAccount.js +2 -0
- package/core/link/interfaces/IFile.d.ts +7 -0
- package/core/link/interfaces/IFile.d.ts.map +1 -0
- package/core/link/interfaces/IFile.js +2 -0
- package/core/link/interfaces/ProofOfWork.d.ts +9 -0
- package/core/link/interfaces/ProofOfWork.d.ts.map +1 -0
- package/core/link/interfaces/ProofOfWork.js +12 -0
- package/core/link/interfaces/index.d.ts +4 -0
- package/core/link/interfaces/index.d.ts.map +1 -0
- package/core/link/interfaces/index.js +19 -0
- package/core/link/phantasmaLink.d.ts +41 -0
- package/core/link/phantasmaLink.d.ts.map +1 -0
- package/core/link/phantasmaLink.js +479 -0
- package/core/rpc/index.d.ts +3 -0
- package/core/rpc/index.d.ts.map +1 -0
- package/core/rpc/index.js +18 -0
- package/core/rpc/interfaces/ABIContract.d.ts +6 -0
- package/core/rpc/interfaces/ABIContract.d.ts.map +1 -0
- package/core/rpc/interfaces/ABIContract.js +2 -0
- package/core/rpc/interfaces/ABIEvent.d.ts +7 -0
- package/core/rpc/interfaces/ABIEvent.d.ts.map +1 -0
- package/core/rpc/interfaces/ABIEvent.js +2 -0
- package/core/rpc/interfaces/ABIMethod.d.ts +7 -0
- package/core/rpc/interfaces/ABIMethod.d.ts.map +1 -0
- package/core/rpc/interfaces/ABIMethod.js +2 -0
- package/core/rpc/interfaces/ABIParameter.d.ts +5 -0
- package/core/rpc/interfaces/ABIParameter.d.ts.map +1 -0
- package/core/rpc/interfaces/ABIParameter.js +2 -0
- package/core/rpc/interfaces/Account.d.ts +16 -0
- package/core/rpc/interfaces/Account.d.ts.map +1 -0
- package/core/rpc/interfaces/Account.js +2 -0
- package/core/rpc/interfaces/AccountTransactions.d.ts +6 -0
- package/core/rpc/interfaces/AccountTransactions.d.ts.map +1 -0
- package/core/rpc/interfaces/AccountTransactions.js +2 -0
- package/core/rpc/interfaces/Archive.d.ts +11 -0
- package/core/rpc/interfaces/Archive.d.ts.map +1 -0
- package/core/rpc/interfaces/Archive.js +2 -0
- package/core/rpc/interfaces/Auction.d.ts +13 -0
- package/core/rpc/interfaces/Auction.d.ts.map +1 -0
- package/core/rpc/interfaces/Auction.js +2 -0
- package/core/rpc/interfaces/Balance.d.ts +8 -0
- package/core/rpc/interfaces/Balance.d.ts.map +1 -0
- package/core/rpc/interfaces/Balance.js +2 -0
- package/core/rpc/interfaces/Block.d.ts +17 -0
- package/core/rpc/interfaces/Block.d.ts.map +1 -0
- package/core/rpc/interfaces/Block.js +2 -0
- package/core/rpc/interfaces/Chain.d.ts +10 -0
- package/core/rpc/interfaces/Chain.d.ts.map +1 -0
- package/core/rpc/interfaces/Chain.js +2 -0
- package/core/rpc/interfaces/Channel.d.ts +13 -0
- package/core/rpc/interfaces/Channel.d.ts.map +1 -0
- package/core/rpc/interfaces/Channel.js +2 -0
- package/core/rpc/interfaces/Contract.d.ts +11 -0
- package/core/rpc/interfaces/Contract.d.ts.map +1 -0
- package/core/rpc/interfaces/Contract.js +2 -0
- package/core/rpc/interfaces/Dapp.d.ts +6 -0
- package/core/rpc/interfaces/Dapp.d.ts.map +1 -0
- package/core/rpc/interfaces/Dapp.js +2 -0
- package/core/rpc/interfaces/Event.d.ts +7 -0
- package/core/rpc/interfaces/Event.d.ts.map +1 -0
- package/core/rpc/interfaces/Event.js +2 -0
- package/core/rpc/interfaces/Governance.d.ts +5 -0
- package/core/rpc/interfaces/Governance.d.ts.map +1 -0
- package/core/rpc/interfaces/Governance.js +2 -0
- package/core/rpc/interfaces/Interop.d.ts +5 -0
- package/core/rpc/interfaces/Interop.d.ts.map +1 -0
- package/core/rpc/interfaces/Interop.js +2 -0
- package/core/rpc/interfaces/KeyValue.d.ts +5 -0
- package/core/rpc/interfaces/KeyValue.d.ts.map +1 -0
- package/core/rpc/interfaces/KeyValue.js +2 -0
- package/core/rpc/interfaces/Leaderboard.d.ts +6 -0
- package/core/rpc/interfaces/Leaderboard.d.ts.map +1 -0
- package/core/rpc/interfaces/Leaderboard.js +2 -0
- package/core/rpc/interfaces/LeaderboardRow.d.ts +5 -0
- package/core/rpc/interfaces/LeaderboardRow.d.ts.map +1 -0
- package/core/rpc/interfaces/LeaderboardRow.js +2 -0
- package/core/rpc/interfaces/NFT.d.ts +14 -0
- package/core/rpc/interfaces/NFT.d.ts.map +1 -0
- package/core/rpc/interfaces/NFT.js +2 -0
- package/core/rpc/interfaces/Nexus.d.ts +14 -0
- package/core/rpc/interfaces/Nexus.d.ts.map +1 -0
- package/core/rpc/interfaces/Nexus.js +2 -0
- package/core/rpc/interfaces/Oracle.d.ts +5 -0
- package/core/rpc/interfaces/Oracle.d.ts.map +1 -0
- package/core/rpc/interfaces/Oracle.js +2 -0
- package/core/rpc/interfaces/Organization.d.ts +6 -0
- package/core/rpc/interfaces/Organization.d.ts.map +1 -0
- package/core/rpc/interfaces/Organization.js +2 -0
- package/core/rpc/interfaces/Paginated.d.ts +8 -0
- package/core/rpc/interfaces/Paginated.d.ts.map +1 -0
- package/core/rpc/interfaces/Paginated.js +2 -0
- package/core/rpc/interfaces/Peer.d.ts +8 -0
- package/core/rpc/interfaces/Peer.d.ts.map +1 -0
- package/core/rpc/interfaces/Peer.js +2 -0
- package/core/rpc/interfaces/Platform.d.ts +9 -0
- package/core/rpc/interfaces/Platform.d.ts.map +1 -0
- package/core/rpc/interfaces/Platform.js +2 -0
- package/core/rpc/interfaces/Receipt.d.ts +10 -0
- package/core/rpc/interfaces/Receipt.d.ts.map +1 -0
- package/core/rpc/interfaces/Receipt.js +2 -0
- package/core/rpc/interfaces/Script.d.ts +9 -0
- package/core/rpc/interfaces/Script.d.ts.map +1 -0
- package/core/rpc/interfaces/Script.js +2 -0
- package/core/rpc/interfaces/SendRawTx.d.ts +5 -0
- package/core/rpc/interfaces/SendRawTx.d.ts.map +1 -0
- package/core/rpc/interfaces/SendRawTx.js +2 -0
- package/core/rpc/interfaces/SignatureResult.d.ts +5 -0
- package/core/rpc/interfaces/SignatureResult.d.ts.map +1 -0
- package/core/rpc/interfaces/SignatureResult.js +2 -0
- package/core/rpc/interfaces/Stake.d.ts +6 -0
- package/core/rpc/interfaces/Stake.d.ts.map +1 -0
- package/core/rpc/interfaces/Stake.js +2 -0
- package/core/rpc/interfaces/Storage.d.ts +8 -0
- package/core/rpc/interfaces/Storage.d.ts.map +1 -0
- package/core/rpc/interfaces/Storage.js +2 -0
- package/core/rpc/interfaces/Swap.d.ts +13 -0
- package/core/rpc/interfaces/Swap.d.ts.map +1 -0
- package/core/rpc/interfaces/Swap.js +2 -0
- package/core/rpc/interfaces/Token.d.ts +19 -0
- package/core/rpc/interfaces/Token.d.ts.map +1 -0
- package/core/rpc/interfaces/Token.js +2 -0
- package/core/rpc/interfaces/TokenData.d.ts +13 -0
- package/core/rpc/interfaces/TokenData.d.ts.map +1 -0
- package/core/rpc/interfaces/TokenData.js +2 -0
- package/core/rpc/interfaces/TokenExternal.d.ts +5 -0
- package/core/rpc/interfaces/TokenExternal.d.ts.map +1 -0
- package/core/rpc/interfaces/TokenExternal.js +2 -0
- package/core/rpc/interfaces/TokenPrice.d.ts +8 -0
- package/core/rpc/interfaces/TokenPrice.d.ts.map +1 -0
- package/core/rpc/interfaces/TokenPrice.js +2 -0
- package/core/rpc/interfaces/TokenSeries.d.ts +12 -0
- package/core/rpc/interfaces/TokenSeries.d.ts.map +1 -0
- package/core/rpc/interfaces/TokenSeries.js +2 -0
- package/core/rpc/interfaces/TransactionData.d.ts +23 -0
- package/core/rpc/interfaces/TransactionData.d.ts.map +1 -0
- package/core/rpc/interfaces/TransactionData.js +2 -0
- package/core/rpc/interfaces/Validator.d.ts +5 -0
- package/core/rpc/interfaces/Validator.d.ts.map +1 -0
- package/core/rpc/interfaces/Validator.js +2 -0
- package/core/rpc/interfaces/index.d.ts +42 -0
- package/core/rpc/interfaces/index.d.ts.map +1 -0
- package/core/rpc/interfaces/index.js +57 -0
- package/core/rpc/phantasma.d.ts +89 -0
- package/core/rpc/phantasma.d.ts.map +1 -0
- package/core/rpc/phantasma.js +900 -0
- package/core/tx/SignatureKind.js +9 -0
- package/core/tx/Transaction.d.ts +28 -0
- package/core/tx/Transaction.d.ts.map +1 -0
- package/core/tx/Transaction.js +209 -0
- package/core/tx/index.d.ts +3 -0
- package/core/tx/index.d.ts.map +1 -0
- package/core/tx/index.js +18 -0
- package/core/tx/utils.d.ts +10 -0
- package/core/tx/utils.d.ts.map +1 -0
- package/core/tx/utils.js +147 -0
- package/core/types/Address.d.ts +41 -0
- package/core/types/Address.d.ts.map +1 -0
- package/core/types/Address.js +276 -0
- package/core/types/Consensus.d.ts +61 -0
- package/core/types/Consensus.d.ts.map +1 -0
- package/core/types/Consensus.js +151 -0
- package/core/types/Contract.d.ts +60 -0
- package/core/types/Contract.d.ts.map +1 -0
- package/core/types/Contract.js +342 -0
- package/core/types/DomainSettings.d.ts +87 -0
- package/core/types/DomainSettings.d.ts.map +1 -0
- package/core/types/DomainSettings.js +107 -0
- package/core/types/Ed25519Signature.d.ts +16 -0
- package/core/types/Ed25519Signature.d.ts.map +1 -0
- package/core/types/Ed25519Signature.js +78 -0
- package/core/types/Entropy.d.ts +5 -0
- package/core/types/Entropy.d.ts.map +1 -0
- package/core/types/Entropy.js +24 -0
- package/core/types/Extensions/Base16.d.ts +7 -0
- package/core/types/Extensions/Base16.d.ts.map +1 -0
- package/core/types/Extensions/Base16.js +36 -0
- package/core/types/Extensions/BinaryReader.d.ts +17 -0
- package/core/types/Extensions/BinaryReader.d.ts.map +1 -0
- package/core/types/Extensions/BinaryReader.js +192 -0
- package/core/types/Extensions/BinaryWriter.d.ts +25 -0
- package/core/types/Extensions/BinaryWriter.d.ts.map +1 -0
- package/core/types/Extensions/BinaryWriter.js +191 -0
- package/core/types/Extensions/Describer.d.ts +5 -0
- package/core/types/Extensions/Describer.d.ts.map +1 -0
- package/core/types/Extensions/Describer.js +25 -0
- package/core/types/Extensions/PBinaryReader.d.ts +42 -0
- package/core/types/Extensions/PBinaryReader.d.ts.map +1 -0
- package/core/types/Extensions/PBinaryReader.js +269 -0
- package/core/types/Extensions/PBinaryWriter.d.ts +49 -0
- package/core/types/Extensions/PBinaryWriter.d.ts.map +1 -0
- package/core/types/Extensions/PBinaryWriter.js +250 -0
- package/core/types/Extensions/TableColumns.d.ts +5 -0
- package/core/types/Extensions/TableColumns.d.ts.map +1 -0
- package/core/types/Extensions/TableColumns.js +22 -0
- package/core/types/Extensions/index.d.ts +5 -0
- package/core/types/Extensions/index.d.ts.map +1 -0
- package/core/types/Extensions/index.js +20 -0
- package/core/types/PhantasmaKeys.d.ts +19 -0
- package/core/types/PhantasmaKeys.d.ts.map +1 -0
- package/core/types/PhantasmaKeys.js +92 -0
- package/core/types/Serialization.d.ts +22 -0
- package/core/types/Serialization.d.ts.map +1 -0
- package/core/types/Serialization.js +195 -0
- package/core/types/Stack.d.ts +16 -0
- package/core/types/Stack.d.ts.map +1 -0
- package/core/types/Stack.js +42 -0
- package/core/types/Timestamp.d.ts +26 -0
- package/core/types/Timestamp.d.ts.map +1 -0
- package/core/types/Timestamp.js +74 -0
- package/core/types/index.d.ts +12 -0
- package/core/types/index.d.ts.map +1 -0
- package/core/types/index.js +27 -0
- package/core/utils/index.d.ts +25 -0
- package/core/utils/index.d.ts.map +1 -0
- package/core/utils/index.js +236 -0
- package/core/vm/Contracts.d.ts +17 -0
- package/core/vm/Contracts.d.ts.map +1 -0
- package/core/vm/Contracts.js +20 -0
- package/core/vm/Decoder.d.ts +19 -0
- package/core/vm/Decoder.d.ts.map +1 -0
- package/core/vm/Decoder.js +175 -0
- package/core/vm/EventData.d.ts +97 -0
- package/core/vm/EventData.d.ts.map +1 -0
- package/core/vm/EventData.js +134 -0
- package/core/vm/Opcode.d.ts +57 -0
- package/core/vm/Opcode.d.ts.map +1 -0
- package/core/vm/Opcode.js +69 -0
- package/core/vm/ScriptBuilder.d.ts +65 -0
- package/core/vm/ScriptBuilder.d.ts.map +1 -0
- package/core/vm/ScriptBuilder.js +592 -0
- package/core/vm/VMObject.d.ts +55 -0
- package/core/vm/VMObject.d.ts.map +1 -0
- package/core/vm/VMObject.js +1101 -0
- package/core/vm/VMType.d.ts +12 -0
- package/core/vm/VMType.d.ts.map +1 -0
- package/core/vm/VMType.js +15 -0
- package/core/vm/index.d.ts +8 -0
- package/core/vm/index.d.ts.map +1 -0
- package/core/vm/index.js +23 -0
- package/html/TestWebPage.html +187 -0
- package/html/phantasma.js +60504 -0
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -0
- package/index.js +36 -0
- package/jest.config.js +5 -0
- package/package.json +67 -0
- package/src/core/index.ts +9 -0
- package/src/core/interfaces/IContract.ts +28 -0
- package/src/core/interfaces/IKeyPair.ts +14 -0
- package/src/core/interfaces/ISerializable.ts +6 -0
- package/src/core/interfaces/IStack.ts +6 -0
- package/src/core/interfaces/IToken.ts +31 -0
- package/src/core/interfaces/Signature.ts +32 -0
- package/src/core/interfaces/index.ts +6 -0
- package/src/core/ledger/Address-Transcode.ts +44 -0
- package/src/core/ledger/Ledger-Commands.ts +463 -0
- package/src/core/ledger/Ledger-Utils.ts +549 -0
- package/src/core/ledger/Mnemonic.ts +79 -0
- package/src/core/ledger/Transaction-Sign.ts +126 -0
- package/src/core/ledger/Transaction-Transcode.ts +56 -0
- package/src/core/ledger/index.ts +8 -0
- package/src/core/ledger/interfaces/ApplicationNameResponse.ts +5 -0
- package/src/core/ledger/interfaces/Device.ts +6 -0
- package/src/core/ledger/interfaces/DeviceResponse.ts +6 -0
- package/src/core/ledger/interfaces/Ledger.ts +10 -0
- package/src/core/ledger/interfaces/LedgerBalanceFromLedgerResponse.ts +9 -0
- package/src/core/ledger/interfaces/LedgerConfig.ts +17 -0
- package/src/core/ledger/interfaces/LedgerDeviceInfoResponse.ts +7 -0
- package/src/core/ledger/interfaces/LedgerSendTransactionResponse.ts +4 -0
- package/src/core/ledger/interfaces/LedgerSigner.ts +6 -0
- package/src/core/ledger/interfaces/LedgerSignerData.ts +8 -0
- package/src/core/ledger/interfaces/PublicKeyResponse.ts +5 -0
- package/src/core/ledger/interfaces/SignResponse.ts +5 -0
- package/src/core/ledger/interfaces/VersionResponse.ts +5 -0
- package/src/core/ledger/interfaces/index.ts +13 -0
- package/src/core/link/easyConnect.ts +214 -0
- package/src/core/link/easyScript.ts +67 -0
- package/src/core/link/index.ts +1 -0
- package/src/core/link/interfaces/IAccount.ts +13 -0
- package/src/core/link/interfaces/IFile.ts +6 -0
- package/src/core/link/interfaces/ProofOfWork.ts +8 -0
- package/src/core/link/interfaces/index.ts +3 -0
- package/src/core/link/phantasmaLink.ts +561 -0
- package/src/core/rpc/index.ts +2 -0
- package/src/core/rpc/interfaces/ABIContract.ts +6 -0
- package/src/core/rpc/interfaces/ABIEvent.ts +6 -0
- package/src/core/rpc/interfaces/ABIMethod.ts +7 -0
- package/src/core/rpc/interfaces/ABIParameter.ts +4 -0
- package/src/core/rpc/interfaces/Account.ts +16 -0
- package/src/core/rpc/interfaces/AccountTransactions.ts +6 -0
- package/src/core/rpc/interfaces/Archive.ts +10 -0
- package/src/core/rpc/interfaces/Auction.ts +12 -0
- package/src/core/rpc/interfaces/Balance.ts +7 -0
- package/src/core/rpc/interfaces/Block.ts +17 -0
- package/src/core/rpc/interfaces/Chain.ts +9 -0
- package/src/core/rpc/interfaces/Channel.ts +12 -0
- package/src/core/rpc/interfaces/Contract.ts +11 -0
- package/src/core/rpc/interfaces/Dapp.ts +5 -0
- package/src/core/rpc/interfaces/Event.ts +6 -0
- package/src/core/rpc/interfaces/Governance.ts +4 -0
- package/src/core/rpc/interfaces/Interop.ts +4 -0
- package/src/core/rpc/interfaces/KeyValue.ts +4 -0
- package/src/core/rpc/interfaces/Leaderboard.ts +6 -0
- package/src/core/rpc/interfaces/LeaderboardRow.ts +4 -0
- package/src/core/rpc/interfaces/NFT.ts +14 -0
- package/src/core/rpc/interfaces/Nexus.ts +14 -0
- package/src/core/rpc/interfaces/Oracle.ts +4 -0
- package/src/core/rpc/interfaces/Organization.ts +5 -0
- package/src/core/rpc/interfaces/Paginated.ts +7 -0
- package/src/core/rpc/interfaces/Peer.ts +7 -0
- package/src/core/rpc/interfaces/Platform.ts +9 -0
- package/src/core/rpc/interfaces/Receipt.ts +9 -0
- package/src/core/rpc/interfaces/Script.ts +9 -0
- package/src/core/rpc/interfaces/SendRawTx.ts +4 -0
- package/src/core/rpc/interfaces/SignatureResult.ts +4 -0
- package/src/core/rpc/interfaces/Stake.ts +5 -0
- package/src/core/rpc/interfaces/Storage.ts +8 -0
- package/src/core/rpc/interfaces/Swap.ts +12 -0
- package/src/core/rpc/interfaces/Token.ts +19 -0
- package/src/core/rpc/interfaces/TokenData.ts +12 -0
- package/src/core/rpc/interfaces/TokenExternal.ts +4 -0
- package/src/core/rpc/interfaces/TokenPrice.ts +7 -0
- package/src/core/rpc/interfaces/TokenSeries.ts +12 -0
- package/src/core/rpc/interfaces/TransactionData.ts +23 -0
- package/src/core/rpc/interfaces/Validator.ts +4 -0
- package/src/core/rpc/interfaces/index.ts +41 -0
- package/src/core/rpc/phantasma.ts +466 -0
- package/src/core/tx/Transaction.ts +258 -0
- package/src/core/tx/index.ts +2 -0
- package/src/core/tx/utils.ts +106 -0
- package/src/core/types/Address.ts +290 -0
- package/src/core/types/Consensus.ts +181 -0
- package/src/core/types/Contract.ts +324 -0
- package/src/core/types/DomainSettings.ts +128 -0
- package/src/core/types/Ed25519Signature.ts +78 -0
- package/src/core/types/Entropy.ts +16 -0
- package/src/core/types/Extensions/Base16.ts +36 -0
- package/src/core/types/Extensions/Describer.ts +17 -0
- package/src/core/types/Extensions/PBinaryReader.ts +247 -0
- package/src/core/types/Extensions/PBinaryWriter.ts +278 -0
- package/src/core/types/Extensions/index.ts +4 -0
- package/src/core/types/PhantasmaKeys.ts +119 -0
- package/src/core/types/Serialization.ts +211 -0
- package/src/core/types/Stack.ts +46 -0
- package/src/core/types/Timestamp.ts +93 -0
- package/src/core/types/index.ts +11 -0
- package/src/core/utils/index.ts +206 -0
- package/src/core/vm/Contracts.ts +17 -0
- package/src/core/vm/Decoder.ts +162 -0
- package/src/core/vm/Disassembler.ts +1 -0
- package/src/core/vm/EventData.ts +135 -0
- package/src/core/vm/Opcode.ts +74 -0
- package/src/core/vm/ScriptBuilder.ts +588 -0
- package/src/core/vm/VMObject.ts +1162 -0
- package/src/core/vm/VMType.ts +11 -0
- package/src/core/vm/index.ts +7 -0
- package/src/core/vm/utils/DisasmMethodCall.ts +22 -0
- package/src/core/vm/utils/DisasmUtils.ts +89 -0
- package/src/core/vm/utils/index.ts +2 -0
- package/src/index.ts +7 -0
- package/tests/VMObject.test.ts +146 -0
- package/tests/ledger/Address-Transacode.test.ts +26 -0
- package/tests/tx/Transaction.test.ts +274 -0
- package/tests/types/Address.test.ts +26 -0
- package/tests/types/Consensus.test.ts +67 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PhantasmaLink = void 0;
|
|
4
|
+
var vm_1 = require("../vm");
|
|
5
|
+
var ProofOfWork_1 = require("./interfaces/ProofOfWork");
|
|
6
|
+
var PhantasmaLink = /** @class */ (function () {
|
|
7
|
+
//Construct The Link
|
|
8
|
+
function PhantasmaLink(dappID, logging) {
|
|
9
|
+
if (logging === void 0) { logging = true; }
|
|
10
|
+
var _this = this;
|
|
11
|
+
this.requestID = 0;
|
|
12
|
+
//Message Logging
|
|
13
|
+
this.onMessage = function (msg) {
|
|
14
|
+
if (_this.messageLogging == true) {
|
|
15
|
+
console.log(msg);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
this.version = 2;
|
|
19
|
+
this.nexus = 'testnet';
|
|
20
|
+
this.chain = 'main';
|
|
21
|
+
this.platform = 'poltergeist';
|
|
22
|
+
//Turn On|Off Console Logging
|
|
23
|
+
if (logging == false) {
|
|
24
|
+
this.messageLogging = false;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.messageLogging = true;
|
|
28
|
+
console.log('%cPhantasmaLink created', 'color:green');
|
|
29
|
+
}
|
|
30
|
+
this.requestID = 0;
|
|
31
|
+
//Standard Sets
|
|
32
|
+
this.host = 'localhost:7090';
|
|
33
|
+
this.dapp = dappID;
|
|
34
|
+
this.onLogin = function (succ) { }; //Does Nothing for Now
|
|
35
|
+
this.onError = function (message) { }; //Does Nothing for Now
|
|
36
|
+
}
|
|
37
|
+
//Connect To Wallet
|
|
38
|
+
PhantasmaLink.prototype.login = function (onLoginCallback, onErrorCallback, version, platform, providerHint) {
|
|
39
|
+
if (version === void 0) { version = 2; }
|
|
40
|
+
if (platform === void 0) { platform = 'phantasma'; }
|
|
41
|
+
if (providerHint === void 0) { providerHint = 'poltergeist'; }
|
|
42
|
+
this.providerHint = providerHint;
|
|
43
|
+
this.onLogin = onLoginCallback;
|
|
44
|
+
this.onError = onErrorCallback;
|
|
45
|
+
this.version = version;
|
|
46
|
+
this.platform = platform;
|
|
47
|
+
this.providerHint = providerHint;
|
|
48
|
+
this.createSocket();
|
|
49
|
+
};
|
|
50
|
+
//Script Invoking With Wallet Connection
|
|
51
|
+
PhantasmaLink.prototype.invokeScript = function (script, callback) {
|
|
52
|
+
this.onMessage('Relaying transaction to wallet...');
|
|
53
|
+
if (!this.socket) {
|
|
54
|
+
callback('not logged in');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (script.length >= 8192) {
|
|
58
|
+
callback('script too big, sorry :(');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var requestStr = this.chain + '/' + script;
|
|
62
|
+
if (this.version >= 2) {
|
|
63
|
+
requestStr = requestStr;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
requestStr = this.nexus + '/' + requestStr;
|
|
67
|
+
}
|
|
68
|
+
var invokeScriptRequest = 'invokeScript/' + requestStr;
|
|
69
|
+
var that = this;
|
|
70
|
+
this.sendLinkRequest(invokeScriptRequest, function (result) {
|
|
71
|
+
if (result.success) {
|
|
72
|
+
that.onMessage('Invoke successful, hash: ' + result + '...');
|
|
73
|
+
if (callback) {
|
|
74
|
+
callback(result);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
//Wallet Transaction Signing + Sending
|
|
80
|
+
PhantasmaLink.prototype.signTx = function (script, payload, callback, onErrorCallback, pow, signature) {
|
|
81
|
+
if (pow === void 0) { pow = ProofOfWork_1.ProofOfWork.None; }
|
|
82
|
+
if (signature === void 0) { signature = 'Ed25519'; }
|
|
83
|
+
//Overload Protection
|
|
84
|
+
if (script.length >= 65536) {
|
|
85
|
+
this.onMessage('Error: script is too big!');
|
|
86
|
+
if (onErrorCallback) {
|
|
87
|
+
onErrorCallback();
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
//Check Payload
|
|
92
|
+
if (payload == null) {
|
|
93
|
+
payload = '7068616e7461736d612d7473'; //Says 'Phantasma-ts' in hex
|
|
94
|
+
}
|
|
95
|
+
else if (typeof payload === 'string') {
|
|
96
|
+
//Turn String Payload -> Bytes -> Hex
|
|
97
|
+
var sb = new vm_1.ScriptBuilder();
|
|
98
|
+
var bytes = sb.RawString(payload);
|
|
99
|
+
sb.AppendBytes(bytes);
|
|
100
|
+
payload = sb.EndScript();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.onMessage('Error: Invalid Payload');
|
|
104
|
+
if (onErrorCallback) {
|
|
105
|
+
onErrorCallback();
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.onError = onErrorCallback; //Sets Error Callback Function
|
|
110
|
+
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
111
|
+
var request = 'signTx/' +
|
|
112
|
+
this.chain +
|
|
113
|
+
'/' +
|
|
114
|
+
script +
|
|
115
|
+
'/' +
|
|
116
|
+
payload +
|
|
117
|
+
'/' +
|
|
118
|
+
signature +
|
|
119
|
+
'/' +
|
|
120
|
+
this.platform +
|
|
121
|
+
'/' +
|
|
122
|
+
pow;
|
|
123
|
+
if (this.version == 1) {
|
|
124
|
+
request = 'signTx/' + this.nexus + '/' + this.chain + '/' + script + '/' + payload;
|
|
125
|
+
}
|
|
126
|
+
//Sends Signiture Request To Connected Wallet For Script
|
|
127
|
+
this.sendLinkRequest(request, function (result) {
|
|
128
|
+
if (result.success) {
|
|
129
|
+
if (result.hash.error) {
|
|
130
|
+
that.onMessage('Error: ' + result.hash.error);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
that.onMessage('Transaction successful, hash: ' + result.hash.substr(0, 15) + '...');
|
|
134
|
+
if (callback) {
|
|
135
|
+
callback(result);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
if (onErrorCallback) {
|
|
140
|
+
onErrorCallback();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
// Wallet Transaction Signing
|
|
146
|
+
PhantasmaLink.prototype.signTxSignature = function (tx, callback, onErrorCallback, signature) {
|
|
147
|
+
if (signature === void 0) { signature = 'Ed25519'; }
|
|
148
|
+
if (!this.socket) {
|
|
149
|
+
this.onMessage('not logged in');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (tx == null) {
|
|
153
|
+
this.onMessage('invalid data, sorry :(');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (tx.length >= 1024) {
|
|
157
|
+
this.onMessage('data too big, sorry :(');
|
|
158
|
+
if (onErrorCallback) {
|
|
159
|
+
onErrorCallback();
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
var signDataStr = 'signTxSignature/' + tx + '/' + signature + '/' + this.platform;
|
|
164
|
+
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
165
|
+
this.sendLinkRequest(signDataStr, function (result) {
|
|
166
|
+
if (result.success) {
|
|
167
|
+
that.onMessage('Data successfully signed');
|
|
168
|
+
if (callback) {
|
|
169
|
+
callback(result);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (onErrorCallback) {
|
|
174
|
+
onErrorCallback();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
PhantasmaLink.prototype.multiSig = function (subject, callback, onErrorCallback, signature) {
|
|
180
|
+
if (signature === void 0) { signature = 'Ed25519'; }
|
|
181
|
+
if (!this.socket) {
|
|
182
|
+
this.onMessage('not logged in');
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (subject == null) {
|
|
186
|
+
this.onMessage('invalid data, sorry :(');
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (subject.length >= 1024) {
|
|
190
|
+
this.onMessage('data too big, sorry :(');
|
|
191
|
+
if (onErrorCallback) {
|
|
192
|
+
onErrorCallback();
|
|
193
|
+
}
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
var signDataStr = 'multiSig/' + subject + '/' + signature + '/' + this.platform;
|
|
197
|
+
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
198
|
+
this.sendLinkRequest(signDataStr, function (result) {
|
|
199
|
+
if (result.success) {
|
|
200
|
+
that.onMessage('Data successfully signed');
|
|
201
|
+
if (callback) {
|
|
202
|
+
callback(result);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
if (onErrorCallback) {
|
|
207
|
+
onErrorCallback();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
PhantasmaLink.prototype.getPeer = function (callback, onErrorCallback) {
|
|
213
|
+
this.onError = onErrorCallback; //Sets Error Callback Function
|
|
214
|
+
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
215
|
+
//Sends Signiture Request To Connected Wallet For Script
|
|
216
|
+
this.sendLinkRequest('getPeer/', function (result) {
|
|
217
|
+
if (result.success) {
|
|
218
|
+
that.onMessage('Peer Query,: ' + result);
|
|
219
|
+
if (callback) {
|
|
220
|
+
callback(result);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
if (onErrorCallback) {
|
|
225
|
+
onErrorCallback();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
PhantasmaLink.prototype.fetchWallet = function (callback, onErrorCallback) {
|
|
231
|
+
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
232
|
+
var getAccountRequest = 'getAccount/' + this.platform;
|
|
233
|
+
this.sendLinkRequest(getAccountRequest, function (result) {
|
|
234
|
+
if (result.success) {
|
|
235
|
+
that.account = result;
|
|
236
|
+
callback(result);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
onErrorCallback('Could not obtain account info... Make sure you have an account currently open in ' +
|
|
240
|
+
that.wallet +
|
|
241
|
+
'...');
|
|
242
|
+
//that.disconnect("Unable to optain Account Info");
|
|
243
|
+
}
|
|
244
|
+
//that.onLogin(result.success);
|
|
245
|
+
//that.onLogin = null;
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
PhantasmaLink.prototype.getNexus = function (callback, onErrorCallback) {
|
|
249
|
+
this.onError = onErrorCallback; //Sets Error Callback Function
|
|
250
|
+
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
251
|
+
//Sends Signiture Request To Connected Wallet For Script
|
|
252
|
+
this.sendLinkRequest('getNexus/', function (result) {
|
|
253
|
+
if (result.success) {
|
|
254
|
+
that.onMessage('Nexus Query,: ' + result);
|
|
255
|
+
if (callback) {
|
|
256
|
+
callback(result);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
if (onErrorCallback) {
|
|
261
|
+
onErrorCallback('Error: ' + result.error);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
PhantasmaLink.prototype.getWalletVersion = function (callback, onErrorCallback) {
|
|
267
|
+
this.onError = onErrorCallback; //Sets Error Callback Function
|
|
268
|
+
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
269
|
+
//Sends Signiture Request To Connected Wallet For Script
|
|
270
|
+
this.sendLinkRequest('getWalletVersion/', function (result) {
|
|
271
|
+
if (result.success) {
|
|
272
|
+
that.onMessage('Wallet Version Query,: ' + result);
|
|
273
|
+
if (callback) {
|
|
274
|
+
callback(result);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
if (onErrorCallback) {
|
|
279
|
+
onErrorCallback('Error: ' + result.error);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
//Uses Wallet To Sign Data With Signiture
|
|
285
|
+
// Data needs to be in Base16 encode.
|
|
286
|
+
PhantasmaLink.prototype.signData = function (data, callback, onErrorCallback, signature) {
|
|
287
|
+
if (signature === void 0) { signature = 'Ed25519'; }
|
|
288
|
+
if (!this.socket) {
|
|
289
|
+
this.onMessage('not logged in');
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (data == null) {
|
|
293
|
+
this.onMessage('invalid data, sorry :(');
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (data.length >= 1024) {
|
|
297
|
+
this.onMessage('data too big, sorry :(');
|
|
298
|
+
if (onErrorCallback) {
|
|
299
|
+
onErrorCallback('data too big, sorry :(');
|
|
300
|
+
}
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
var signDataStr = 'signData/' + data + '/' + signature + '/' + this.platform;
|
|
304
|
+
var that = this; //Allows the use of 'this' inside sendLinkRequest Object
|
|
305
|
+
this.sendLinkRequest(signDataStr, function (result) {
|
|
306
|
+
if (result.success) {
|
|
307
|
+
that.onMessage('Data successfully signed');
|
|
308
|
+
if (callback) {
|
|
309
|
+
callback(result);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
if (onErrorCallback) {
|
|
314
|
+
onErrorCallback(result);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
//Wallet Socket Connection Creation
|
|
320
|
+
PhantasmaLink.prototype.createSocket = function (isResume) {
|
|
321
|
+
if (isResume === void 0) { isResume = false; }
|
|
322
|
+
var path = 'ws://' + this.host + '/phantasma';
|
|
323
|
+
this.onMessage('Phantasma Link connecting...');
|
|
324
|
+
if (this.socket) {
|
|
325
|
+
this.socket.close();
|
|
326
|
+
}
|
|
327
|
+
//@ts-ignore
|
|
328
|
+
this.socket = //@ts-ignore
|
|
329
|
+
window.PhantasmaLinkSocket && this.providerHint !== 'poltergeist'
|
|
330
|
+
? // @ts-ignore
|
|
331
|
+
new PhantasmaLinkSocket()
|
|
332
|
+
: new WebSocket(path);
|
|
333
|
+
this.requestCallback = null;
|
|
334
|
+
this.token = null;
|
|
335
|
+
this.account = null;
|
|
336
|
+
this.requestID = 0;
|
|
337
|
+
var authorizeRequest = 'authorize/' + this.dapp + '/' + this.version;
|
|
338
|
+
var getAccountRequest = 'getAccount/' + this.platform;
|
|
339
|
+
var that = this;
|
|
340
|
+
//Once Socket Opened
|
|
341
|
+
this.socket.onopen = function (e) {
|
|
342
|
+
that.onMessage('Connection established, authorizing dapp in wallet...');
|
|
343
|
+
if (isResume) {
|
|
344
|
+
that.fetchWallet(undefined, undefined);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
that.sendLinkRequest(authorizeRequest, function (result) {
|
|
348
|
+
//Set Global Variables With Successful Account Query
|
|
349
|
+
if (result.success) {
|
|
350
|
+
that.token = result.token;
|
|
351
|
+
that.wallet = result.wallet;
|
|
352
|
+
that.onMessage('Authorized, obtaining account info...');
|
|
353
|
+
that.sendLinkRequest(getAccountRequest, function (result) {
|
|
354
|
+
if (result.success) {
|
|
355
|
+
that.account = result;
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
that.onError('Could not obtain account info... Make sure you have an account currently open in ' +
|
|
359
|
+
that.wallet +
|
|
360
|
+
'...');
|
|
361
|
+
that.disconnect('Unable to optain Account Info');
|
|
362
|
+
}
|
|
363
|
+
that.onLogin(result.success);
|
|
364
|
+
that.onLogin = null;
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
that.onError('Authorization failed...');
|
|
369
|
+
that.disconnect('Auth Failure');
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
//Retrieves Message From Socket and Processes It
|
|
375
|
+
this.socket.onmessage = function (event) {
|
|
376
|
+
var obj = JSON.parse(event.data);
|
|
377
|
+
if (that.messageLogging == true) {
|
|
378
|
+
console.log('%c' + event.data, 'color:blue');
|
|
379
|
+
}
|
|
380
|
+
//Checks What To Do Based On Message
|
|
381
|
+
switch (obj.message) {
|
|
382
|
+
case 'Wallet is Closed':
|
|
383
|
+
that.onError('Could not obtain account info... Make sure you have an account currently open in ' +
|
|
384
|
+
that.wallet);
|
|
385
|
+
that.disconnect(true);
|
|
386
|
+
break;
|
|
387
|
+
case 'not logged in':
|
|
388
|
+
that.onError('Could not obtain account info... Make sure you have an account currently logged in');
|
|
389
|
+
that.disconnect(true);
|
|
390
|
+
break;
|
|
391
|
+
case 'A previouus request is still pending' || 'A previous request is still pending':
|
|
392
|
+
that.onError('You have a pending action in your wallet');
|
|
393
|
+
break;
|
|
394
|
+
case 'user rejected':
|
|
395
|
+
that.onError('Transaction cancelled by user in ' + that.wallet);
|
|
396
|
+
break;
|
|
397
|
+
case 'user rejected':
|
|
398
|
+
that.onError('Transaction cancelled by user in ' + that.wallet);
|
|
399
|
+
break;
|
|
400
|
+
default:
|
|
401
|
+
if (obj.message && obj.message.startsWith('nexus mismatch')) {
|
|
402
|
+
that.onError(obj.message);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
var temp = that.requestCallback;
|
|
406
|
+
if (temp == null) {
|
|
407
|
+
that.onError('Something bad happened');
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
that.requestCallback = null;
|
|
411
|
+
temp(obj);
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
//Cleanup After Socket Closes
|
|
417
|
+
this.socket.onclose = function (event) {
|
|
418
|
+
if (!event.wasClean) {
|
|
419
|
+
if (that.onLogin) {
|
|
420
|
+
that.onError('Connection terminated...');
|
|
421
|
+
}
|
|
422
|
+
that.onLogin = null;
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
//Error Callback When Socket Has Error
|
|
426
|
+
this.socket.onerror = function (error) {
|
|
427
|
+
if (error.message !== undefined) {
|
|
428
|
+
that.onMessage('Error: ' + error.message);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
//Message Logging Util
|
|
433
|
+
PhantasmaLink.prototype.toggleMessageLogging = function () {
|
|
434
|
+
if (this.messageLogging == true) {
|
|
435
|
+
this.messageLogging = false;
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
this.messageLogging = true;
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
PhantasmaLink.prototype.resume = function (token) {
|
|
442
|
+
this.token = token;
|
|
443
|
+
this.retry();
|
|
444
|
+
};
|
|
445
|
+
//Retry Util
|
|
446
|
+
PhantasmaLink.prototype.retry = function () {
|
|
447
|
+
this.createSocket();
|
|
448
|
+
};
|
|
449
|
+
Object.defineProperty(PhantasmaLink.prototype, "dappID", {
|
|
450
|
+
get: function () {
|
|
451
|
+
return this.dapp;
|
|
452
|
+
},
|
|
453
|
+
//Get Dapp ID Name Util
|
|
454
|
+
set: function (dapp) {
|
|
455
|
+
this.dapp = dapp;
|
|
456
|
+
},
|
|
457
|
+
enumerable: false,
|
|
458
|
+
configurable: true
|
|
459
|
+
});
|
|
460
|
+
//Build Request and Send To Wallet Via Socket
|
|
461
|
+
PhantasmaLink.prototype.sendLinkRequest = function (request, callback) {
|
|
462
|
+
this.onMessage('Sending Phantasma Link request: ' + request);
|
|
463
|
+
if (this.token != null) {
|
|
464
|
+
request = request + '/' + this.dapp + '/' + this.token;
|
|
465
|
+
}
|
|
466
|
+
this.requestID++; //Object Nonce Increase?
|
|
467
|
+
request = this.requestID + ',' + request;
|
|
468
|
+
this.requestCallback = callback;
|
|
469
|
+
this.socket.send(request);
|
|
470
|
+
};
|
|
471
|
+
//Disconnect The Wallet Connection Socket
|
|
472
|
+
PhantasmaLink.prototype.disconnect = function (triggered) {
|
|
473
|
+
this.onMessage('Disconnecting Phantasma Link: ' + triggered);
|
|
474
|
+
if (this.socket)
|
|
475
|
+
this.socket.close();
|
|
476
|
+
};
|
|
477
|
+
return PhantasmaLink;
|
|
478
|
+
}());
|
|
479
|
+
exports.PhantasmaLink = PhantasmaLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/rpc/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./phantasma"), exports);
|
|
18
|
+
__exportStar(require("./interfaces/index"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ABIContract.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/ABIContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ABIEvent.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/ABIEvent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ABIMethod.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/ABIMethod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ABIParameter.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/ABIParameter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Balance } from './Balance';
|
|
2
|
+
import { Stake } from './Stake';
|
|
3
|
+
import { Storage } from './Storage';
|
|
4
|
+
export interface Account {
|
|
5
|
+
address: string;
|
|
6
|
+
name: string;
|
|
7
|
+
stakes: Stake;
|
|
8
|
+
stake: string;
|
|
9
|
+
unclaimed: string;
|
|
10
|
+
relay: string;
|
|
11
|
+
validator: string;
|
|
12
|
+
storage: Storage;
|
|
13
|
+
balances: Array<Balance>;
|
|
14
|
+
txs: Array<string>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=Account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/Account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountTransactions.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/AccountTransactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Archive.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/Archive.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Auction {
|
|
2
|
+
creatorAddress: string;
|
|
3
|
+
chainAddress: string;
|
|
4
|
+
startDate: number;
|
|
5
|
+
endDate: number;
|
|
6
|
+
baseSymbol: string;
|
|
7
|
+
quoteSymbol: string;
|
|
8
|
+
tokenId: string;
|
|
9
|
+
price: string;
|
|
10
|
+
rom: string;
|
|
11
|
+
ram: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Auction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Auction.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/Auction.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Balance.d.ts","sourceRoot":"","sources":["../../../src/core/rpc/interfaces/Balance.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACrB"}
|