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,900 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.PhantasmaAPI = void 0;
|
|
44
|
+
var cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
45
|
+
var PhantasmaAPI = /** @class */ (function () {
|
|
46
|
+
function PhantasmaAPI(defHost, peersUrlJson, nexus) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
this.rpcName = 'Auto';
|
|
49
|
+
this.nexus = nexus;
|
|
50
|
+
this.host = defHost;
|
|
51
|
+
this.availableHosts = [];
|
|
52
|
+
if (peersUrlJson != undefined) {
|
|
53
|
+
(0, cross_fetch_1.default)(peersUrlJson + '?_=' + new Date().getTime()).then(function (res) { return __awaiter(_this, void 0, void 0, function () {
|
|
54
|
+
var data, i, msecs, err_1;
|
|
55
|
+
return __generator(this, function (_a) {
|
|
56
|
+
switch (_a.label) {
|
|
57
|
+
case 0: return [4 /*yield*/, res.json()];
|
|
58
|
+
case 1:
|
|
59
|
+
data = _a.sent();
|
|
60
|
+
i = 0;
|
|
61
|
+
_a.label = 2;
|
|
62
|
+
case 2:
|
|
63
|
+
if (!(i < data.length)) return [3 /*break*/, 7];
|
|
64
|
+
console.log('Checking RPC: ', data[i]);
|
|
65
|
+
_a.label = 3;
|
|
66
|
+
case 3:
|
|
67
|
+
_a.trys.push([3, 5, , 6]);
|
|
68
|
+
return [4 /*yield*/, this.pingAsync(data[i].url)];
|
|
69
|
+
case 4:
|
|
70
|
+
msecs = _a.sent();
|
|
71
|
+
data[i].info = data[i].location + ' • ' + msecs + ' ms';
|
|
72
|
+
data[i].msecs = msecs;
|
|
73
|
+
console.log(data[i].location + ' • ' + msecs + ' ms • ' + data[i].url + '/rpc');
|
|
74
|
+
this.availableHosts.push(data[i]);
|
|
75
|
+
return [3 /*break*/, 6];
|
|
76
|
+
case 5:
|
|
77
|
+
err_1 = _a.sent();
|
|
78
|
+
console.log('Error with RPC: ' + data[i]);
|
|
79
|
+
return [3 /*break*/, 6];
|
|
80
|
+
case 6:
|
|
81
|
+
i++;
|
|
82
|
+
return [3 /*break*/, 2];
|
|
83
|
+
case 7:
|
|
84
|
+
this.availableHosts.sort(function (a, b) { return a.msecs - b.msecs; });
|
|
85
|
+
this.updateRpc();
|
|
86
|
+
return [2 /*return*/];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
PhantasmaAPI.prototype.pingAsync = function (host) {
|
|
93
|
+
return new Promise(function (resolve, reject) {
|
|
94
|
+
var started = new Date().getTime();
|
|
95
|
+
var http = new XMLHttpRequest();
|
|
96
|
+
http.open('GET', host + '/rpc', true);
|
|
97
|
+
http.timeout = 4500;
|
|
98
|
+
http.onreadystatechange = function () {
|
|
99
|
+
if (http.readyState == 4 && http.status == 200) {
|
|
100
|
+
var ended = new Date().getTime();
|
|
101
|
+
var milliseconds = ended - started;
|
|
102
|
+
resolve(milliseconds);
|
|
103
|
+
}
|
|
104
|
+
http.ontimeout = function () {
|
|
105
|
+
resolve(100000);
|
|
106
|
+
};
|
|
107
|
+
http.onerror = function () {
|
|
108
|
+
resolve(100000);
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
try {
|
|
112
|
+
http.send(null);
|
|
113
|
+
}
|
|
114
|
+
catch (exception) {
|
|
115
|
+
// this is expected
|
|
116
|
+
reject();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
PhantasmaAPI.prototype.JSONRPC = function (method, params) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var res, resJson;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0: return [4 /*yield*/, (0, cross_fetch_1.default)(this.host, {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
mode: 'cors',
|
|
128
|
+
body: JSON.stringify({
|
|
129
|
+
jsonrpc: '2.0',
|
|
130
|
+
method: method,
|
|
131
|
+
params: params,
|
|
132
|
+
id: '1',
|
|
133
|
+
}),
|
|
134
|
+
headers: { 'Content-Type': 'application/json' },
|
|
135
|
+
})];
|
|
136
|
+
case 1:
|
|
137
|
+
res = _a.sent();
|
|
138
|
+
return [4 /*yield*/, res.json()];
|
|
139
|
+
case 2:
|
|
140
|
+
resJson = _a.sent();
|
|
141
|
+
console.log('method', method, resJson);
|
|
142
|
+
if (resJson.error) {
|
|
143
|
+
if (resJson.error.message)
|
|
144
|
+
return [2 /*return*/, { error: resJson.error.message }];
|
|
145
|
+
return [2 /*return*/, { error: resJson.error }];
|
|
146
|
+
}
|
|
147
|
+
return [4 /*yield*/, resJson.result];
|
|
148
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
PhantasmaAPI.prototype.setRpcHost = function (rpcHost) {
|
|
154
|
+
this.host = rpcHost;
|
|
155
|
+
};
|
|
156
|
+
PhantasmaAPI.prototype.setRpcByName = function (rpcName) {
|
|
157
|
+
this.rpcName = rpcName;
|
|
158
|
+
if (this.nexus === 'mainnet')
|
|
159
|
+
this.updateRpc();
|
|
160
|
+
};
|
|
161
|
+
PhantasmaAPI.prototype.setNexus = function (nexus) {
|
|
162
|
+
this.nexus = nexus.toLowerCase();
|
|
163
|
+
};
|
|
164
|
+
PhantasmaAPI.prototype.updateRpc = function () {
|
|
165
|
+
var _this = this;
|
|
166
|
+
if (this.nexus === 'mainnet' && this.availableHosts.length > 0) {
|
|
167
|
+
console.log('%cUpdate RPC with name ' + this.rpcName, 'font-size: 20px');
|
|
168
|
+
if (this.rpcName == 'Auto') {
|
|
169
|
+
this.host = this.availableHosts[0].url + '/rpc';
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
var rpc = this.availableHosts.find(function (h) { return h.location == _this.rpcName; });
|
|
173
|
+
if (rpc)
|
|
174
|
+
this.host = rpc.url + '/rpc';
|
|
175
|
+
else
|
|
176
|
+
this.host = this.availableHosts[0].url + '/rpc';
|
|
177
|
+
}
|
|
178
|
+
console.log('%cSet RPC api to ' + this.host, 'font-size: 20px');
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
PhantasmaAPI.prototype.convertDecimals = function (amount, decimals) {
|
|
182
|
+
var mult = Math.pow(10, decimals);
|
|
183
|
+
return amount / mult;
|
|
184
|
+
};
|
|
185
|
+
//Returns the account name and balance of given address.
|
|
186
|
+
PhantasmaAPI.prototype.getAccount = function (account, extended) {
|
|
187
|
+
if (extended === void 0) { extended = true; }
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var params;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
params = [account, extended];
|
|
194
|
+
return [4 /*yield*/, this.JSONRPC('getAccount', params)];
|
|
195
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
//Returns the accounts name and balance of given addresses.
|
|
201
|
+
PhantasmaAPI.prototype.getAccounts = function (accounts, extended) {
|
|
202
|
+
if (extended === void 0) { extended = true; }
|
|
203
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
204
|
+
var params;
|
|
205
|
+
return __generator(this, function (_a) {
|
|
206
|
+
switch (_a.label) {
|
|
207
|
+
case 0:
|
|
208
|
+
params = [accounts.join(','), extended];
|
|
209
|
+
return [4 /*yield*/, this.JSONRPC('getAccounts', params)];
|
|
210
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
//Returns the address that owns a given name.
|
|
216
|
+
PhantasmaAPI.prototype.lookUpName = function (name) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
var params;
|
|
219
|
+
return __generator(this, function (_a) {
|
|
220
|
+
switch (_a.label) {
|
|
221
|
+
case 0:
|
|
222
|
+
params = [name];
|
|
223
|
+
return [4 /*yield*/, this.JSONRPC('lookUpName', params)];
|
|
224
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
//Returns the address that owns a given name.
|
|
230
|
+
PhantasmaAPI.prototype.getAddressesBySymbol = function (symbol, extended) {
|
|
231
|
+
if (extended === void 0) { extended = false; }
|
|
232
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
233
|
+
var params;
|
|
234
|
+
return __generator(this, function (_a) {
|
|
235
|
+
switch (_a.label) {
|
|
236
|
+
case 0:
|
|
237
|
+
params = [symbol, extended];
|
|
238
|
+
return [4 /*yield*/, this.JSONRPC('getAddressesBySymbol', params)];
|
|
239
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
//Returns the height of a chain.
|
|
245
|
+
PhantasmaAPI.prototype.getBlockHeight = function (chainInput) {
|
|
246
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
+
var params;
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
switch (_a.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
params = [chainInput];
|
|
252
|
+
return [4 /*yield*/, this.JSONRPC('getBlockHeight', params)];
|
|
253
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
//Returns the number of transactions of given block hash or error if given hash is invalid or is not found.
|
|
259
|
+
PhantasmaAPI.prototype.getBlockTransactionCountByHash = function (blockHash) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
+
var params;
|
|
262
|
+
return __generator(this, function (_a) {
|
|
263
|
+
switch (_a.label) {
|
|
264
|
+
case 0:
|
|
265
|
+
params = [blockHash];
|
|
266
|
+
return [4 /*yield*/, this.JSONRPC('getBlockTransactionCountByHash', params)];
|
|
267
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
//Returns information about a block by hash.
|
|
273
|
+
PhantasmaAPI.prototype.getBlockByHash = function (blockHash) {
|
|
274
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
275
|
+
var params;
|
|
276
|
+
return __generator(this, function (_a) {
|
|
277
|
+
switch (_a.label) {
|
|
278
|
+
case 0:
|
|
279
|
+
params = [blockHash];
|
|
280
|
+
return [4 /*yield*/, this.JSONRPC('getBlockByHash', params)];
|
|
281
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
//Returns a serialized string, containing information about a block by hash.
|
|
287
|
+
PhantasmaAPI.prototype.getRawBlockByHash = function (blockHash) {
|
|
288
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
289
|
+
var params;
|
|
290
|
+
return __generator(this, function (_a) {
|
|
291
|
+
switch (_a.label) {
|
|
292
|
+
case 0:
|
|
293
|
+
params = [blockHash];
|
|
294
|
+
return [4 /*yield*/, this.JSONRPC('getRawBlockByHash', params)];
|
|
295
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
//Returns information about a block by height and chain.
|
|
301
|
+
PhantasmaAPI.prototype.getBlockByHeight = function (chainInput, height) {
|
|
302
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
303
|
+
var params;
|
|
304
|
+
return __generator(this, function (_a) {
|
|
305
|
+
switch (_a.label) {
|
|
306
|
+
case 0:
|
|
307
|
+
params = [chainInput, height];
|
|
308
|
+
return [4 /*yield*/, this.JSONRPC('getBlockByHeight', params)];
|
|
309
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
//Returns information about a block by height and chain.
|
|
315
|
+
PhantasmaAPI.prototype.getLatestBlock = function (chainInput) {
|
|
316
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
317
|
+
var params;
|
|
318
|
+
return __generator(this, function (_a) {
|
|
319
|
+
switch (_a.label) {
|
|
320
|
+
case 0:
|
|
321
|
+
params = [chainInput];
|
|
322
|
+
return [4 /*yield*/, this.JSONRPC('getLatestBlock', params)];
|
|
323
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
//Returns a serialized string, in hex format, containing information about a block by height and chain.
|
|
329
|
+
PhantasmaAPI.prototype.getRawBlockByHeight = function (chainInput, height) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
331
|
+
var params;
|
|
332
|
+
return __generator(this, function (_a) {
|
|
333
|
+
switch (_a.label) {
|
|
334
|
+
case 0:
|
|
335
|
+
params = [chainInput, height];
|
|
336
|
+
return [4 /*yield*/, this.JSONRPC('getRawBlockByHeight', params)];
|
|
337
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
//Returns a serialized string, in hex format, containing information about a block by height and chain.
|
|
343
|
+
PhantasmaAPI.prototype.getRawLatestBlock = function (chainInput) {
|
|
344
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
345
|
+
var params;
|
|
346
|
+
return __generator(this, function (_a) {
|
|
347
|
+
switch (_a.label) {
|
|
348
|
+
case 0:
|
|
349
|
+
params = [chainInput];
|
|
350
|
+
return [4 /*yield*/, this.JSONRPC('getRawLatestBlock', params)];
|
|
351
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
//Returns the information about a transaction requested by a block hash and transaction index.
|
|
357
|
+
PhantasmaAPI.prototype.getTransactionByBlockHashAndIndex = function (blockHash, index) {
|
|
358
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
359
|
+
var params;
|
|
360
|
+
return __generator(this, function (_a) {
|
|
361
|
+
switch (_a.label) {
|
|
362
|
+
case 0:
|
|
363
|
+
params = [blockHash, index];
|
|
364
|
+
return [4 /*yield*/, this.JSONRPC('getTransactionByBlockHashAndIndex', params)];
|
|
365
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
//Returns last X transactions of given address.
|
|
371
|
+
PhantasmaAPI.prototype.getAddressTransactions = function (account, page, pageSize) {
|
|
372
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
373
|
+
var params;
|
|
374
|
+
return __generator(this, function (_a) {
|
|
375
|
+
switch (_a.label) {
|
|
376
|
+
case 0:
|
|
377
|
+
params = [account, page, pageSize];
|
|
378
|
+
return [4 /*yield*/, this.JSONRPC('getAddressTransactions', params)];
|
|
379
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
};
|
|
384
|
+
//Get number of transactions in a specific address and chain
|
|
385
|
+
PhantasmaAPI.prototype.getAddressTransactionCount = function (account, chainInput) {
|
|
386
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
387
|
+
var params;
|
|
388
|
+
return __generator(this, function (_a) {
|
|
389
|
+
switch (_a.label) {
|
|
390
|
+
case 0:
|
|
391
|
+
params = [account, chainInput];
|
|
392
|
+
return [4 /*yield*/, this.JSONRPC('getAddressTransactionCount', params)];
|
|
393
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
//Allows to broadcast a signed operation on the network, but it's required to build it manually.
|
|
399
|
+
PhantasmaAPI.prototype.sendRawTransaction = function (txData) {
|
|
400
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
401
|
+
var params;
|
|
402
|
+
return __generator(this, function (_a) {
|
|
403
|
+
switch (_a.label) {
|
|
404
|
+
case 0:
|
|
405
|
+
params = [txData];
|
|
406
|
+
return [4 /*yield*/, this.JSONRPC('sendRawTransaction', params)];
|
|
407
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
//Allows to invoke script based on network state, without state changes.
|
|
413
|
+
PhantasmaAPI.prototype.invokeRawScript = function (chainInput, scriptData) {
|
|
414
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
415
|
+
var params;
|
|
416
|
+
return __generator(this, function (_a) {
|
|
417
|
+
switch (_a.label) {
|
|
418
|
+
case 0:
|
|
419
|
+
params = [chainInput, scriptData];
|
|
420
|
+
return [4 /*yield*/, this.JSONRPC('invokeRawScript', params)];
|
|
421
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
//Returns information about a transaction by hash.
|
|
427
|
+
PhantasmaAPI.prototype.getTransaction = function (hashText) {
|
|
428
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
429
|
+
var params;
|
|
430
|
+
return __generator(this, function (_a) {
|
|
431
|
+
switch (_a.label) {
|
|
432
|
+
case 0:
|
|
433
|
+
params = [hashText];
|
|
434
|
+
return [4 /*yield*/, this.JSONRPC('getTransaction', params)];
|
|
435
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
//Removes a pending transaction from the mempool.
|
|
441
|
+
PhantasmaAPI.prototype.cancelTransaction = function (hashText) {
|
|
442
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
443
|
+
var params;
|
|
444
|
+
return __generator(this, function (_a) {
|
|
445
|
+
switch (_a.label) {
|
|
446
|
+
case 0:
|
|
447
|
+
params = [hashText];
|
|
448
|
+
return [4 /*yield*/, this.JSONRPC('cancelTransaction', params)];
|
|
449
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
};
|
|
454
|
+
//Returns an array of all chains deployed in Phantasma.
|
|
455
|
+
PhantasmaAPI.prototype.getChains = function (extended) {
|
|
456
|
+
if (extended === void 0) { extended = true; }
|
|
457
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
458
|
+
var params;
|
|
459
|
+
return __generator(this, function (_a) {
|
|
460
|
+
switch (_a.label) {
|
|
461
|
+
case 0:
|
|
462
|
+
params = [extended];
|
|
463
|
+
return [4 /*yield*/, this.JSONRPC('getChains', params)];
|
|
464
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
//Return the chain
|
|
470
|
+
PhantasmaAPI.prototype.getChain = function (name, extended) {
|
|
471
|
+
if (extended === void 0) { extended = true; }
|
|
472
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
473
|
+
var params;
|
|
474
|
+
return __generator(this, function (_a) {
|
|
475
|
+
switch (_a.label) {
|
|
476
|
+
case 0:
|
|
477
|
+
params = [name, extended];
|
|
478
|
+
return [4 /*yield*/, this.JSONRPC('getChain', params)];
|
|
479
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
//Returns info about the nexus.
|
|
485
|
+
PhantasmaAPI.prototype.getNexus = function (extended) {
|
|
486
|
+
if (extended === void 0) { extended = true; }
|
|
487
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
488
|
+
var params;
|
|
489
|
+
return __generator(this, function (_a) {
|
|
490
|
+
switch (_a.label) {
|
|
491
|
+
case 0:
|
|
492
|
+
params = [extended];
|
|
493
|
+
return [4 /*yield*/, this.JSONRPC('getNexus', params)];
|
|
494
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
//Returns an array of contracts deployed in Phantasma.
|
|
500
|
+
PhantasmaAPI.prototype.getContracts = function (chainAddressOrName, extended) {
|
|
501
|
+
if (chainAddressOrName === void 0) { chainAddressOrName = 'main'; }
|
|
502
|
+
if (extended === void 0) { extended = true; }
|
|
503
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
504
|
+
var params;
|
|
505
|
+
return __generator(this, function (_a) {
|
|
506
|
+
switch (_a.label) {
|
|
507
|
+
case 0:
|
|
508
|
+
params = [chainAddressOrName, extended];
|
|
509
|
+
return [4 /*yield*/, this.JSONRPC('getContracts', params)];
|
|
510
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
};
|
|
515
|
+
//Returns the contract info deployed in Phantasma.
|
|
516
|
+
PhantasmaAPI.prototype.getContract = function (chainAddressOrName, contractName) {
|
|
517
|
+
if (chainAddressOrName === void 0) { chainAddressOrName = 'main'; }
|
|
518
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
519
|
+
var params;
|
|
520
|
+
return __generator(this, function (_a) {
|
|
521
|
+
switch (_a.label) {
|
|
522
|
+
case 0:
|
|
523
|
+
params = [chainAddressOrName, contractName];
|
|
524
|
+
return [4 /*yield*/, this.JSONRPC('getContract', params)];
|
|
525
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
PhantasmaAPI.prototype.getContractByAddress = function (chainAddressOrName, contractAddress) {
|
|
531
|
+
if (chainAddressOrName === void 0) { chainAddressOrName = 'main'; }
|
|
532
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
533
|
+
var params;
|
|
534
|
+
return __generator(this, function (_a) {
|
|
535
|
+
switch (_a.label) {
|
|
536
|
+
case 0:
|
|
537
|
+
params = [chainAddressOrName, contractAddress];
|
|
538
|
+
return [4 /*yield*/, this.JSONRPC('getContractByAddress', params)];
|
|
539
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
//Returns info about an organization.
|
|
545
|
+
PhantasmaAPI.prototype.getOrganization = function (ID, extended) {
|
|
546
|
+
if (extended === void 0) { extended = true; }
|
|
547
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
548
|
+
var params;
|
|
549
|
+
return __generator(this, function (_a) {
|
|
550
|
+
switch (_a.label) {
|
|
551
|
+
case 0:
|
|
552
|
+
params = [ID, extended];
|
|
553
|
+
return [4 /*yield*/, this.JSONRPC('getOrganization', params)];
|
|
554
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
};
|
|
559
|
+
PhantasmaAPI.prototype.getOrganizationByName = function (name, extended) {
|
|
560
|
+
if (extended === void 0) { extended = true; }
|
|
561
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
562
|
+
var params;
|
|
563
|
+
return __generator(this, function (_a) {
|
|
564
|
+
switch (_a.label) {
|
|
565
|
+
case 0:
|
|
566
|
+
params = [name, extended];
|
|
567
|
+
return [4 /*yield*/, this.JSONRPC('getOrganizationByName', params)];
|
|
568
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
PhantasmaAPI.prototype.getOrganizations = function (extended) {
|
|
574
|
+
if (extended === void 0) { extended = false; }
|
|
575
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
576
|
+
var params;
|
|
577
|
+
return __generator(this, function (_a) {
|
|
578
|
+
switch (_a.label) {
|
|
579
|
+
case 0:
|
|
580
|
+
params = [extended];
|
|
581
|
+
return [4 /*yield*/, this.JSONRPC('getOrganizations', params)];
|
|
582
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
//Returns content of a Phantasma leaderboard.
|
|
588
|
+
PhantasmaAPI.prototype.getLeaderboard = function (name) {
|
|
589
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
590
|
+
var params;
|
|
591
|
+
return __generator(this, function (_a) {
|
|
592
|
+
switch (_a.label) {
|
|
593
|
+
case 0:
|
|
594
|
+
params = [name];
|
|
595
|
+
return [4 /*yield*/, this.JSONRPC('getLeaderboard', params)];
|
|
596
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
};
|
|
601
|
+
//Returns an array of tokens deployed in Phantasma.
|
|
602
|
+
PhantasmaAPI.prototype.getTokens = function (extended) {
|
|
603
|
+
if (extended === void 0) { extended = true; }
|
|
604
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
605
|
+
var params;
|
|
606
|
+
return __generator(this, function (_a) {
|
|
607
|
+
switch (_a.label) {
|
|
608
|
+
case 0:
|
|
609
|
+
params = [extended];
|
|
610
|
+
return [4 /*yield*/, this.JSONRPC('getTokens', params)];
|
|
611
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
};
|
|
616
|
+
//Returns info about a specific token deployed in Phantasma.
|
|
617
|
+
PhantasmaAPI.prototype.getToken = function (symbol, extended) {
|
|
618
|
+
if (extended === void 0) { extended = true; }
|
|
619
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
620
|
+
var params;
|
|
621
|
+
return __generator(this, function (_a) {
|
|
622
|
+
switch (_a.label) {
|
|
623
|
+
case 0:
|
|
624
|
+
params = [symbol, extended];
|
|
625
|
+
return [4 /*yield*/, this.JSONRPC('getToken', params)];
|
|
626
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
};
|
|
631
|
+
//Returns data of a non-fungible token, in hexadecimal format.
|
|
632
|
+
PhantasmaAPI.prototype.getTokenData = function (symbol, IDtext) {
|
|
633
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
634
|
+
var params;
|
|
635
|
+
return __generator(this, function (_a) {
|
|
636
|
+
switch (_a.label) {
|
|
637
|
+
case 0:
|
|
638
|
+
params = [symbol, IDtext];
|
|
639
|
+
return [4 /*yield*/, this.JSONRPC('getTokenData', params)];
|
|
640
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
//Returns the balance for a specific token and chain, given an address.
|
|
646
|
+
PhantasmaAPI.prototype.getTokenBalance = function (account, tokenSymbol, chainInput) {
|
|
647
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
648
|
+
var params;
|
|
649
|
+
return __generator(this, function (_a) {
|
|
650
|
+
switch (_a.label) {
|
|
651
|
+
case 0:
|
|
652
|
+
params = [account, tokenSymbol, chainInput];
|
|
653
|
+
return [4 /*yield*/, this.JSONRPC('getTokenBalance', params)];
|
|
654
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
};
|
|
659
|
+
//Returns the number of active auctions.
|
|
660
|
+
PhantasmaAPI.prototype.getAuctionsCount = function (chainAddressOrName, symbol) {
|
|
661
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
662
|
+
var params;
|
|
663
|
+
return __generator(this, function (_a) {
|
|
664
|
+
switch (_a.label) {
|
|
665
|
+
case 0:
|
|
666
|
+
params = [chainAddressOrName, symbol];
|
|
667
|
+
return [4 /*yield*/, this.JSONRPC('getAuctionsCount', params)];
|
|
668
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
};
|
|
673
|
+
//Returns the auctions available in the market.
|
|
674
|
+
PhantasmaAPI.prototype.getAuctions = function (chainAddressOrName, symbol, page, pageSize) {
|
|
675
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
676
|
+
var params;
|
|
677
|
+
return __generator(this, function (_a) {
|
|
678
|
+
switch (_a.label) {
|
|
679
|
+
case 0:
|
|
680
|
+
params = [chainAddressOrName, symbol, page, pageSize];
|
|
681
|
+
return [4 /*yield*/, this.JSONRPC('getAuctions', params)];
|
|
682
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
};
|
|
687
|
+
//Returns the auction for a specific token.
|
|
688
|
+
PhantasmaAPI.prototype.getAuction = function (chainAddressOrName, symbol, IDtext) {
|
|
689
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
690
|
+
var params;
|
|
691
|
+
return __generator(this, function (_a) {
|
|
692
|
+
switch (_a.label) {
|
|
693
|
+
case 0:
|
|
694
|
+
params = [chainAddressOrName, symbol, IDtext];
|
|
695
|
+
return [4 /*yield*/, this.JSONRPC('getAuction', params)];
|
|
696
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
});
|
|
700
|
+
};
|
|
701
|
+
//Returns info about a specific archive.
|
|
702
|
+
PhantasmaAPI.prototype.getArchive = function (hashText) {
|
|
703
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
704
|
+
var params;
|
|
705
|
+
return __generator(this, function (_a) {
|
|
706
|
+
switch (_a.label) {
|
|
707
|
+
case 0:
|
|
708
|
+
params = [hashText];
|
|
709
|
+
return [4 /*yield*/, this.JSONRPC('getArchive', params)];
|
|
710
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
//Writes the contents of an incomplete archive.
|
|
716
|
+
PhantasmaAPI.prototype.writeArchive = function (hashText, blockIndex, blockContent) {
|
|
717
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
718
|
+
var params;
|
|
719
|
+
return __generator(this, function (_a) {
|
|
720
|
+
switch (_a.label) {
|
|
721
|
+
case 0:
|
|
722
|
+
params = [hashText, blockIndex, blockContent];
|
|
723
|
+
return [4 /*yield*/, this.JSONRPC('writeArchive', params)];
|
|
724
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
};
|
|
729
|
+
//Returns the ABI interface of specific contract.
|
|
730
|
+
PhantasmaAPI.prototype.getABI = function (chainAddressOrName, contractName) {
|
|
731
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
732
|
+
var params;
|
|
733
|
+
return __generator(this, function (_a) {
|
|
734
|
+
switch (_a.label) {
|
|
735
|
+
case 0:
|
|
736
|
+
params = [chainAddressOrName, contractName];
|
|
737
|
+
return [4 /*yield*/, this.JSONRPC('getABI', params)];
|
|
738
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
//Returns list of known peers.
|
|
744
|
+
PhantasmaAPI.prototype.getPeers = function () {
|
|
745
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
746
|
+
var params;
|
|
747
|
+
return __generator(this, function (_a) {
|
|
748
|
+
switch (_a.label) {
|
|
749
|
+
case 0:
|
|
750
|
+
params = [];
|
|
751
|
+
return [4 /*yield*/, this.JSONRPC('getPeers', params)];
|
|
752
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
});
|
|
756
|
+
};
|
|
757
|
+
//Writes a message to the relay network.
|
|
758
|
+
PhantasmaAPI.prototype.relaySend = function (receiptHex) {
|
|
759
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
760
|
+
var params;
|
|
761
|
+
return __generator(this, function (_a) {
|
|
762
|
+
switch (_a.label) {
|
|
763
|
+
case 0:
|
|
764
|
+
params = [receiptHex];
|
|
765
|
+
return [4 /*yield*/, this.JSONRPC('relaySend', params)];
|
|
766
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
});
|
|
770
|
+
};
|
|
771
|
+
//Receives messages from the relay network.
|
|
772
|
+
PhantasmaAPI.prototype.relayReceive = function (account) {
|
|
773
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
774
|
+
var params;
|
|
775
|
+
return __generator(this, function (_a) {
|
|
776
|
+
switch (_a.label) {
|
|
777
|
+
case 0:
|
|
778
|
+
params = [account];
|
|
779
|
+
return [4 /*yield*/, this.JSONRPC('relayReceive', params)];
|
|
780
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
});
|
|
784
|
+
};
|
|
785
|
+
//Reads pending messages from the relay network.
|
|
786
|
+
PhantasmaAPI.prototype.getEvents = function (account) {
|
|
787
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
788
|
+
var params;
|
|
789
|
+
return __generator(this, function (_a) {
|
|
790
|
+
switch (_a.label) {
|
|
791
|
+
case 0:
|
|
792
|
+
params = [account];
|
|
793
|
+
return [4 /*yield*/, this.JSONRPC('getEvents', params)];
|
|
794
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
};
|
|
799
|
+
//Returns an array of available interop platforms.
|
|
800
|
+
PhantasmaAPI.prototype.getPlatforms = function () {
|
|
801
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
802
|
+
var params;
|
|
803
|
+
return __generator(this, function (_a) {
|
|
804
|
+
switch (_a.label) {
|
|
805
|
+
case 0:
|
|
806
|
+
params = [];
|
|
807
|
+
return [4 /*yield*/, this.JSONRPC('getPlatforms', params)];
|
|
808
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
});
|
|
812
|
+
};
|
|
813
|
+
//Returns an array of available validators.
|
|
814
|
+
PhantasmaAPI.prototype.getValidators = function () {
|
|
815
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
816
|
+
var params;
|
|
817
|
+
return __generator(this, function (_a) {
|
|
818
|
+
switch (_a.label) {
|
|
819
|
+
case 0:
|
|
820
|
+
params = [];
|
|
821
|
+
return [4 /*yield*/, this.JSONRPC('getValidators', params)];
|
|
822
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
});
|
|
826
|
+
};
|
|
827
|
+
//Tries to settle a pending swap for a specific hash.
|
|
828
|
+
PhantasmaAPI.prototype.settleSwap = function (sourcePlatform, destPlatform, hashText) {
|
|
829
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
830
|
+
var params;
|
|
831
|
+
return __generator(this, function (_a) {
|
|
832
|
+
switch (_a.label) {
|
|
833
|
+
case 0:
|
|
834
|
+
params = [sourcePlatform, destPlatform, hashText];
|
|
835
|
+
return [4 /*yield*/, this.JSONRPC('settleSwap', params)];
|
|
836
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
};
|
|
841
|
+
//Returns platform swaps for a specific address.
|
|
842
|
+
PhantasmaAPI.prototype.getSwapsForAddressOld = function (account) {
|
|
843
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
844
|
+
var params;
|
|
845
|
+
return __generator(this, function (_a) {
|
|
846
|
+
switch (_a.label) {
|
|
847
|
+
case 0:
|
|
848
|
+
params = [account];
|
|
849
|
+
return [4 /*yield*/, this.JSONRPC('getSwapsForAddress', params)];
|
|
850
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
};
|
|
855
|
+
//Returns platform swaps for a specific address.
|
|
856
|
+
PhantasmaAPI.prototype.getSwapsForAddress = function (account, platform) {
|
|
857
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
858
|
+
var params;
|
|
859
|
+
return __generator(this, function (_a) {
|
|
860
|
+
switch (_a.label) {
|
|
861
|
+
case 0:
|
|
862
|
+
params = [account, platform, false];
|
|
863
|
+
return [4 /*yield*/, this.JSONRPC('getSwapsForAddress', params)];
|
|
864
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
};
|
|
869
|
+
//Returns info of a nft.
|
|
870
|
+
PhantasmaAPI.prototype.getNFT = function (symbol, nftId, extended) {
|
|
871
|
+
if (extended === void 0) { extended = true; }
|
|
872
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
873
|
+
var params;
|
|
874
|
+
return __generator(this, function (_a) {
|
|
875
|
+
switch (_a.label) {
|
|
876
|
+
case 0:
|
|
877
|
+
params = [symbol, nftId, extended];
|
|
878
|
+
return [4 /*yield*/, this.JSONRPC('getNFT', params)];
|
|
879
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
};
|
|
884
|
+
PhantasmaAPI.prototype.getNFTs = function (symbol, nftIDs, extended) {
|
|
885
|
+
if (extended === void 0) { extended = true; }
|
|
886
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
887
|
+
var params;
|
|
888
|
+
return __generator(this, function (_a) {
|
|
889
|
+
switch (_a.label) {
|
|
890
|
+
case 0:
|
|
891
|
+
params = [symbol, nftIDs.join(','), extended];
|
|
892
|
+
return [4 /*yield*/, this.JSONRPC('getNFTs', params)];
|
|
893
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
});
|
|
897
|
+
};
|
|
898
|
+
return PhantasmaAPI;
|
|
899
|
+
}());
|
|
900
|
+
exports.PhantasmaAPI = PhantasmaAPI;
|