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,466 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
import fetch from 'cross-fetch';
|
|
4
|
+
import { Balance } from './interfaces/Balance';
|
|
5
|
+
import { Platform } from './interfaces/Platform';
|
|
6
|
+
import { Organization } from './interfaces/Organization';
|
|
7
|
+
import { Nexus } from './interfaces/Nexus';
|
|
8
|
+
import { Account } from './interfaces/Account';
|
|
9
|
+
import { Leaderboard } from './interfaces/Leaderboard';
|
|
10
|
+
import { Chain } from './interfaces/Chain';
|
|
11
|
+
import { Contract } from './interfaces/Contract';
|
|
12
|
+
import { Event } from './interfaces/Event';
|
|
13
|
+
import { TransactionData } from './interfaces/TransactionData';
|
|
14
|
+
import { AccountTransactions } from './interfaces/AccountTransactions';
|
|
15
|
+
import { Paginated } from './interfaces/Paginated';
|
|
16
|
+
import { Block } from './interfaces/Block';
|
|
17
|
+
import { Token } from './interfaces/Token';
|
|
18
|
+
import { TokenData } from './interfaces/TokenData';
|
|
19
|
+
import { Auction } from './interfaces/Auction';
|
|
20
|
+
import { Script } from './interfaces/Script';
|
|
21
|
+
import { Archive } from './interfaces/Archive';
|
|
22
|
+
import { ABIContract } from './interfaces/ABIContract';
|
|
23
|
+
import { Receipt } from './interfaces/Receipt';
|
|
24
|
+
import { Peer } from './interfaces/Peer';
|
|
25
|
+
import { Validator } from './interfaces/Validator';
|
|
26
|
+
import { Swap } from './interfaces/Swap';
|
|
27
|
+
import { NFT } from './interfaces/NFT';
|
|
28
|
+
|
|
29
|
+
export class PhantasmaAPI {
|
|
30
|
+
host: string;
|
|
31
|
+
rpcName: string;
|
|
32
|
+
nexus: string;
|
|
33
|
+
availableHosts: any[];
|
|
34
|
+
|
|
35
|
+
pingAsync(host: string): Promise<number> {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
var started = new Date().getTime();
|
|
38
|
+
var http = new XMLHttpRequest();
|
|
39
|
+
|
|
40
|
+
http.open('GET', host + '/rpc', true);
|
|
41
|
+
http.timeout = 4500;
|
|
42
|
+
http.onreadystatechange = function () {
|
|
43
|
+
if (http.readyState == 4 && http.status == 200) {
|
|
44
|
+
var ended = new Date().getTime();
|
|
45
|
+
var milliseconds = ended - started;
|
|
46
|
+
resolve(milliseconds);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
http.ontimeout = function () {
|
|
50
|
+
resolve(100000);
|
|
51
|
+
};
|
|
52
|
+
http.onerror = function () {
|
|
53
|
+
resolve(100000);
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
try {
|
|
57
|
+
http.send(null);
|
|
58
|
+
} catch (exception) {
|
|
59
|
+
// this is expected
|
|
60
|
+
reject();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
constructor(defHost: string, peersUrlJson: string, nexus: string) {
|
|
66
|
+
this.rpcName = 'Auto';
|
|
67
|
+
this.nexus = nexus;
|
|
68
|
+
this.host = defHost;
|
|
69
|
+
this.availableHosts = [];
|
|
70
|
+
|
|
71
|
+
if (peersUrlJson != undefined) {
|
|
72
|
+
fetch(peersUrlJson + '?_=' + new Date().getTime()).then(async (res) => {
|
|
73
|
+
const data = await res.json();
|
|
74
|
+
for (var i = 0; i < data.length; i++) {
|
|
75
|
+
console.log('Checking RPC: ', data[i]);
|
|
76
|
+
try {
|
|
77
|
+
const msecs = await this.pingAsync(data[i].url);
|
|
78
|
+
data[i].info = data[i].location + ' • ' + msecs + ' ms';
|
|
79
|
+
data[i].msecs = msecs;
|
|
80
|
+
console.log(data[i].location + ' • ' + msecs + ' ms • ' + data[i].url + '/rpc');
|
|
81
|
+
this.availableHosts.push(data[i]);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.log('Error with RPC: ' + data[i]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
this.availableHosts.sort((a, b) => a.msecs - b.msecs);
|
|
87
|
+
this.updateRpc();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async JSONRPC(method: string, params: Array<any>): Promise<any> {
|
|
93
|
+
let res = await fetch(this.host, {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
mode: 'cors',
|
|
96
|
+
body: JSON.stringify({
|
|
97
|
+
jsonrpc: '2.0',
|
|
98
|
+
method: method,
|
|
99
|
+
params: params,
|
|
100
|
+
id: '1',
|
|
101
|
+
}),
|
|
102
|
+
headers: { 'Content-Type': 'application/json' },
|
|
103
|
+
});
|
|
104
|
+
let resJson = await res.json();
|
|
105
|
+
console.log('method', method, resJson);
|
|
106
|
+
if (resJson.error) {
|
|
107
|
+
if (resJson.error.message) return { error: resJson.error.message };
|
|
108
|
+
return { error: resJson.error };
|
|
109
|
+
}
|
|
110
|
+
return await resJson.result;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
setRpcHost(rpcHost: string) {
|
|
114
|
+
this.host = rpcHost;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
setRpcByName(rpcName: string) {
|
|
118
|
+
this.rpcName = rpcName;
|
|
119
|
+
if (this.nexus === 'mainnet') this.updateRpc();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
setNexus(nexus: string) {
|
|
123
|
+
this.nexus = nexus.toLowerCase();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
updateRpc() {
|
|
127
|
+
if (this.nexus === 'mainnet' && this.availableHosts.length > 0) {
|
|
128
|
+
console.log('%cUpdate RPC with name ' + this.rpcName, 'font-size: 20px');
|
|
129
|
+
if (this.rpcName == 'Auto') {
|
|
130
|
+
this.host = this.availableHosts[0].url + '/rpc';
|
|
131
|
+
} else {
|
|
132
|
+
const rpc = this.availableHosts.find((h) => h.location == this.rpcName);
|
|
133
|
+
if (rpc) this.host = rpc.url + '/rpc';
|
|
134
|
+
else this.host = this.availableHosts[0].url + '/rpc';
|
|
135
|
+
}
|
|
136
|
+
console.log('%cSet RPC api to ' + this.host, 'font-size: 20px');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
convertDecimals(amount: number, decimals: number): number {
|
|
141
|
+
let mult = Math.pow(10, decimals);
|
|
142
|
+
return amount / mult;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//Returns the account name and balance of given address.
|
|
146
|
+
async getAccount(account: string, extended: boolean = true): Promise<Account> {
|
|
147
|
+
let params: Array<any> = [account, extended];
|
|
148
|
+
return (await this.JSONRPC('getAccount', params)) as Account;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
//Returns the accounts name and balance of given addresses.
|
|
152
|
+
async getAccounts(accounts: string[], extended: boolean = true): Promise<Account[]> {
|
|
153
|
+
let params: Array<any> = [accounts.join(','), extended];
|
|
154
|
+
return (await this.JSONRPC('getAccounts', params)) as Account[];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//Returns the address that owns a given name.
|
|
158
|
+
async lookUpName(name: string): Promise<string> {
|
|
159
|
+
let params: Array<any> = [name];
|
|
160
|
+
return (await this.JSONRPC('lookUpName', params)) as string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//Returns the address that owns a given name.
|
|
164
|
+
async getAddressesBySymbol(symbol: string, extended: boolean = false): Promise<Account[]> {
|
|
165
|
+
let params: Array<any> = [symbol, extended];
|
|
166
|
+
return (await this.JSONRPC('getAddressesBySymbol', params)) as Account[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//Returns the height of a chain.
|
|
170
|
+
async getBlockHeight(chainInput: string): Promise<number> {
|
|
171
|
+
let params: Array<any> = [chainInput];
|
|
172
|
+
return (await this.JSONRPC('getBlockHeight', params)) as number;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//Returns the number of transactions of given block hash or error if given hash is invalid or is not found.
|
|
176
|
+
async getBlockTransactionCountByHash(blockHash: string): Promise<number> {
|
|
177
|
+
let params: Array<any> = [blockHash];
|
|
178
|
+
return (await this.JSONRPC('getBlockTransactionCountByHash', params)) as number;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//Returns information about a block by hash.
|
|
182
|
+
async getBlockByHash(blockHash: string): Promise<Block> {
|
|
183
|
+
let params: Array<any> = [blockHash];
|
|
184
|
+
return (await this.JSONRPC('getBlockByHash', params)) as Block;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
//Returns a serialized string, containing information about a block by hash.
|
|
188
|
+
async getRawBlockByHash(blockHash: string): Promise<string> {
|
|
189
|
+
let params: Array<any> = [blockHash];
|
|
190
|
+
return (await this.JSONRPC('getRawBlockByHash', params)) as string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
//Returns information about a block by height and chain.
|
|
194
|
+
async getBlockByHeight(chainInput: string, height: number): Promise<Block> {
|
|
195
|
+
let params: Array<any> = [chainInput, height];
|
|
196
|
+
return (await this.JSONRPC('getBlockByHeight', params)) as Block;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
//Returns information about a block by height and chain.
|
|
200
|
+
async getLatestBlock(chainInput: string): Promise<Block> {
|
|
201
|
+
let params: Array<any> = [chainInput];
|
|
202
|
+
return (await this.JSONRPC('getLatestBlock', params)) as Block;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//Returns a serialized string, in hex format, containing information about a block by height and chain.
|
|
206
|
+
async getRawBlockByHeight(chainInput: string, height: number): Promise<string> {
|
|
207
|
+
let params: Array<any> = [chainInput, height];
|
|
208
|
+
return (await this.JSONRPC('getRawBlockByHeight', params)) as string;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//Returns a serialized string, in hex format, containing information about a block by height and chain.
|
|
212
|
+
async getRawLatestBlock(chainInput: string): Promise<string> {
|
|
213
|
+
let params: Array<any> = [chainInput];
|
|
214
|
+
return (await this.JSONRPC('getRawLatestBlock', params)) as string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
//Returns the information about a transaction requested by a block hash and transaction index.
|
|
218
|
+
async getTransactionByBlockHashAndIndex(
|
|
219
|
+
blockHash: string,
|
|
220
|
+
index: number
|
|
221
|
+
): Promise<TransactionData> {
|
|
222
|
+
let params: Array<any> = [blockHash, index];
|
|
223
|
+
return (await this.JSONRPC('getTransactionByBlockHashAndIndex', params)) as TransactionData;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
//Returns last X transactions of given address.
|
|
227
|
+
async getAddressTransactions(
|
|
228
|
+
account: string,
|
|
229
|
+
page: number,
|
|
230
|
+
pageSize: number
|
|
231
|
+
): Promise<Paginated<AccountTransactions>> {
|
|
232
|
+
let params: Array<any> = [account, page, pageSize];
|
|
233
|
+
return (await this.JSONRPC('getAddressTransactions', params)) as Paginated<AccountTransactions>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
//Get number of transactions in a specific address and chain
|
|
237
|
+
async getAddressTransactionCount(account: string, chainInput: string): Promise<number> {
|
|
238
|
+
let params: Array<any> = [account, chainInput];
|
|
239
|
+
return (await this.JSONRPC('getAddressTransactionCount', params)) as number;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//Allows to broadcast a signed operation on the network, but it's required to build it manually.
|
|
243
|
+
async sendRawTransaction(txData: string): Promise<string> {
|
|
244
|
+
let params: Array<any> = [txData];
|
|
245
|
+
return (await this.JSONRPC('sendRawTransaction', params)) as string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
//Allows to invoke script based on network state, without state changes.
|
|
249
|
+
async invokeRawScript(chainInput: string, scriptData: string): Promise<Script> {
|
|
250
|
+
let params: Array<any> = [chainInput, scriptData];
|
|
251
|
+
return (await this.JSONRPC('invokeRawScript', params)) as Script;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
//Returns information about a transaction by hash.
|
|
255
|
+
async getTransaction(hashText: string): Promise<TransactionData> {
|
|
256
|
+
let params: Array<any> = [hashText];
|
|
257
|
+
return (await this.JSONRPC('getTransaction', params)) as TransactionData;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
//Removes a pending transaction from the mempool.
|
|
261
|
+
async cancelTransaction(hashText: string): Promise<string> {
|
|
262
|
+
let params: Array<any> = [hashText];
|
|
263
|
+
return (await this.JSONRPC('cancelTransaction', params)) as string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
//Returns an array of all chains deployed in Phantasma.
|
|
267
|
+
async getChains(extended: boolean = true): Promise<Chain[]> {
|
|
268
|
+
let params: Array<any> = [extended];
|
|
269
|
+
return (await this.JSONRPC('getChains', params)) as Chain[];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
//Return the chain
|
|
273
|
+
async getChain(name: string, extended: boolean = true): Promise<Chain> {
|
|
274
|
+
let params: Array<any> = [name, extended];
|
|
275
|
+
return (await this.JSONRPC('getChain', params)) as Chain;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
//Returns info about the nexus.
|
|
279
|
+
async getNexus(extended: boolean = true): Promise<Nexus> {
|
|
280
|
+
let params: Array<any> = [extended];
|
|
281
|
+
return (await this.JSONRPC('getNexus', params)) as Nexus;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
//Returns an array of contracts deployed in Phantasma.
|
|
285
|
+
async getContracts(
|
|
286
|
+
chainAddressOrName: string = 'main',
|
|
287
|
+
extended: boolean = true
|
|
288
|
+
): Promise<Contract[]> {
|
|
289
|
+
let params: Array<any> = [chainAddressOrName, extended];
|
|
290
|
+
return (await this.JSONRPC('getContracts', params)) as Contract[];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
//Returns the contract info deployed in Phantasma.
|
|
294
|
+
async getContract(chainAddressOrName: string = 'main', contractName: string): Promise<Contract> {
|
|
295
|
+
let params: Array<any> = [chainAddressOrName, contractName];
|
|
296
|
+
return (await this.JSONRPC('getContract', params)) as Contract;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async getContractByAddress(
|
|
300
|
+
chainAddressOrName: string = 'main',
|
|
301
|
+
contractAddress: string
|
|
302
|
+
): Promise<Contract> {
|
|
303
|
+
let params: Array<any> = [chainAddressOrName, contractAddress];
|
|
304
|
+
return (await this.JSONRPC('getContractByAddress', params)) as Contract;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
//Returns info about an organization.
|
|
308
|
+
async getOrganization(ID: string, extended: boolean = true): Promise<Organization> {
|
|
309
|
+
let params: Array<any> = [ID, extended];
|
|
310
|
+
return (await this.JSONRPC('getOrganization', params)) as Organization;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
async getOrganizationByName(name: string, extended: boolean = true): Promise<Organization> {
|
|
314
|
+
let params: Array<any> = [name, extended];
|
|
315
|
+
return (await this.JSONRPC('getOrganizationByName', params)) as Organization;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
async getOrganizations(extended: boolean = false): Promise<Organization[]> {
|
|
319
|
+
let params: Array<any> = [extended];
|
|
320
|
+
return (await this.JSONRPC('getOrganizations', params)) as Organization[];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
//Returns content of a Phantasma leaderboard.
|
|
324
|
+
async getLeaderboard(name: string): Promise<Leaderboard> {
|
|
325
|
+
let params: Array<any> = [name];
|
|
326
|
+
return (await this.JSONRPC('getLeaderboard', params)) as Leaderboard;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
//Returns an array of tokens deployed in Phantasma.
|
|
330
|
+
async getTokens(extended: boolean = true): Promise<Token[]> {
|
|
331
|
+
let params: Array<any> = [extended];
|
|
332
|
+
return (await this.JSONRPC('getTokens', params)) as Token[];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
//Returns info about a specific token deployed in Phantasma.
|
|
336
|
+
async getToken(symbol: string, extended: boolean = true): Promise<Token> {
|
|
337
|
+
let params: Array<any> = [symbol, extended];
|
|
338
|
+
return (await this.JSONRPC('getToken', params)) as Token;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
//Returns data of a non-fungible token, in hexadecimal format.
|
|
342
|
+
async getTokenData(symbol: string, IDtext: string): Promise<TokenData> {
|
|
343
|
+
let params: Array<any> = [symbol, IDtext];
|
|
344
|
+
return (await this.JSONRPC('getTokenData', params)) as TokenData;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
//Returns the balance for a specific token and chain, given an address.
|
|
348
|
+
async getTokenBalance(
|
|
349
|
+
account: string,
|
|
350
|
+
tokenSymbol: string,
|
|
351
|
+
chainInput: string
|
|
352
|
+
): Promise<Balance> {
|
|
353
|
+
let params: Array<any> = [account, tokenSymbol, chainInput];
|
|
354
|
+
return (await this.JSONRPC('getTokenBalance', params)) as Balance;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
//Returns the number of active auctions.
|
|
358
|
+
async getAuctionsCount(chainAddressOrName: string, symbol: string): Promise<number> {
|
|
359
|
+
let params: Array<any> = [chainAddressOrName, symbol];
|
|
360
|
+
return (await this.JSONRPC('getAuctionsCount', params)) as number;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
//Returns the auctions available in the market.
|
|
364
|
+
async getAuctions(
|
|
365
|
+
chainAddressOrName: string,
|
|
366
|
+
symbol: string,
|
|
367
|
+
page: number,
|
|
368
|
+
pageSize: number
|
|
369
|
+
): Promise<Auction> {
|
|
370
|
+
let params: Array<any> = [chainAddressOrName, symbol, page, pageSize];
|
|
371
|
+
return (await this.JSONRPC('getAuctions', params)) as Auction;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
//Returns the auction for a specific token.
|
|
375
|
+
async getAuction(chainAddressOrName: string, symbol: string, IDtext: string): Promise<Auction> {
|
|
376
|
+
let params: Array<any> = [chainAddressOrName, symbol, IDtext];
|
|
377
|
+
return (await this.JSONRPC('getAuction', params)) as Auction;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
//Returns info about a specific archive.
|
|
381
|
+
async getArchive(hashText: string): Promise<Archive> {
|
|
382
|
+
let params: Array<any> = [hashText];
|
|
383
|
+
return (await this.JSONRPC('getArchive', params)) as Archive;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
//Writes the contents of an incomplete archive.
|
|
387
|
+
async writeArchive(hashText: string, blockIndex: number, blockContent: string): Promise<boolean> {
|
|
388
|
+
let params: Array<any> = [hashText, blockIndex, blockContent];
|
|
389
|
+
return (await this.JSONRPC('writeArchive', params)) as boolean;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
//Returns the ABI interface of specific contract.
|
|
393
|
+
async getABI(chainAddressOrName: string, contractName: string): Promise<ABIContract> {
|
|
394
|
+
let params: Array<any> = [chainAddressOrName, contractName];
|
|
395
|
+
return (await this.JSONRPC('getABI', params)) as ABIContract;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
//Returns list of known peers.
|
|
399
|
+
async getPeers(): Promise<Peer> {
|
|
400
|
+
let params: Array<any> = [];
|
|
401
|
+
return (await this.JSONRPC('getPeers', params)) as Peer;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
//Writes a message to the relay network.
|
|
405
|
+
async relaySend(receiptHex: string): Promise<boolean> {
|
|
406
|
+
let params: Array<any> = [receiptHex];
|
|
407
|
+
return (await this.JSONRPC('relaySend', params)) as boolean;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
//Receives messages from the relay network.
|
|
411
|
+
async relayReceive(account: string): Promise<Receipt> {
|
|
412
|
+
let params: Array<any> = [account];
|
|
413
|
+
return (await this.JSONRPC('relayReceive', params)) as Receipt;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
//Reads pending messages from the relay network.
|
|
417
|
+
async getEvents(account: string): Promise<Event> {
|
|
418
|
+
let params: Array<any> = [account];
|
|
419
|
+
return (await this.JSONRPC('getEvents', params)) as Event;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
//Returns an array of available interop platforms.
|
|
423
|
+
async getPlatforms(): Promise<Platform[]> {
|
|
424
|
+
let params: Array<any> = [];
|
|
425
|
+
return (await this.JSONRPC('getPlatforms', params)) as Platform[];
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
//Returns an array of available validators.
|
|
429
|
+
async getValidators(): Promise<Validator> {
|
|
430
|
+
let params: Array<any> = [];
|
|
431
|
+
return (await this.JSONRPC('getValidators', params)) as Validator;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
//Tries to settle a pending swap for a specific hash.
|
|
435
|
+
async settleSwap(
|
|
436
|
+
sourcePlatform: string,
|
|
437
|
+
destPlatform: string,
|
|
438
|
+
hashText: string
|
|
439
|
+
): Promise<string> {
|
|
440
|
+
let params: Array<any> = [sourcePlatform, destPlatform, hashText];
|
|
441
|
+
return (await this.JSONRPC('settleSwap', params)) as string;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
//Returns platform swaps for a specific address.
|
|
445
|
+
async getSwapsForAddressOld(account: string): Promise<Swap[]> {
|
|
446
|
+
let params: Array<any> = [account];
|
|
447
|
+
return (await this.JSONRPC('getSwapsForAddress', params)) as Swap[];
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
//Returns platform swaps for a specific address.
|
|
451
|
+
async getSwapsForAddress(account: string, platform: string): Promise<Swap[]> {
|
|
452
|
+
let params: Array<any> = [account, platform, false];
|
|
453
|
+
return (await this.JSONRPC('getSwapsForAddress', params)) as Swap[];
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
//Returns info of a nft.
|
|
457
|
+
async getNFT(symbol: string, nftId: string, extended: boolean = true): Promise<NFT> {
|
|
458
|
+
let params: Array<any> = [symbol, nftId, extended];
|
|
459
|
+
return (await this.JSONRPC('getNFT', params)) as NFT;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
async getNFTs(symbol: string, nftIDs: string[], extended: boolean = true): Promise<NFT[]> {
|
|
463
|
+
let params: Array<any> = [symbol, nftIDs.join(','), extended];
|
|
464
|
+
return (await this.JSONRPC('getNFTs', params)) as NFT[];
|
|
465
|
+
}
|
|
466
|
+
}
|