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,126 @@
|
|
|
1
|
+
import * as crypto from 'crypto';
|
|
2
|
+
|
|
3
|
+
const PUBLIC_KEY_PREFIX = '302A300506032B6570032100';
|
|
4
|
+
const DEBUG = false;
|
|
5
|
+
|
|
6
|
+
export const PrivateToDer = (privateKeyHex: string): Buffer => {
|
|
7
|
+
if (DEBUG) {
|
|
8
|
+
console.log('privateToDer', 'privateKeyHex', privateKeyHex);
|
|
9
|
+
}
|
|
10
|
+
const derHex = `302e020100300506032b657004220420${privateKeyHex}`;
|
|
11
|
+
if (DEBUG) {
|
|
12
|
+
console.log('privateToDer', 'derHex', derHex);
|
|
13
|
+
}
|
|
14
|
+
return Buffer.from(derHex, 'hex');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const PublicToDer = (publicKeyHex: string): Buffer => {
|
|
18
|
+
const publicKeyDerHex = `${PUBLIC_KEY_PREFIX}${publicKeyHex}`;
|
|
19
|
+
return Buffer.from(publicKeyDerHex, 'hex');
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const PublicToPem = (publicKeyHex: string): string => {
|
|
23
|
+
const publicKeyDer = PublicToDer(publicKeyHex);
|
|
24
|
+
const publicKeyDerBase64 = publicKeyDer.toString('base64');
|
|
25
|
+
return `-----BEGIN PUBLIC KEY-----\n${publicKeyDerBase64}\n-----END PUBLIC KEY-----`;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const SignBytes = (hash: Buffer, privateKey: Buffer): string => {
|
|
29
|
+
if (DEBUG) {
|
|
30
|
+
console.log('signBytes.hash', hash);
|
|
31
|
+
console.log('signBytes.privateKey', privateKey);
|
|
32
|
+
}
|
|
33
|
+
const privateKeyDer = PrivateToDer(privateKey.toString('hex'));
|
|
34
|
+
if (DEBUG) {
|
|
35
|
+
console.log('signBytes.privateKeyDer', privateKeyDer);
|
|
36
|
+
}
|
|
37
|
+
const privateKeyObj = crypto.createPrivateKey({
|
|
38
|
+
key: privateKeyDer,
|
|
39
|
+
format: 'der',
|
|
40
|
+
type: 'pkcs8',
|
|
41
|
+
});
|
|
42
|
+
const signature = crypto.sign(undefined, hash, privateKeyObj);
|
|
43
|
+
const signatureHex = signature.toString('hex');
|
|
44
|
+
if (DEBUG) {
|
|
45
|
+
console.log('signatureHex', signatureHex);
|
|
46
|
+
}
|
|
47
|
+
return signatureHex;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const GetHash = (encodedTx: string, debug?: boolean): Buffer => {
|
|
51
|
+
return Buffer.from(encodedTx, 'hex');
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Sign = (encodedTx: string, privateKeyHex: string): string => {
|
|
55
|
+
if (DEBUG) {
|
|
56
|
+
console.log('sign', 'encodedTx', encodedTx);
|
|
57
|
+
}
|
|
58
|
+
const privateKey = Buffer.from(privateKeyHex, 'hex');
|
|
59
|
+
if (DEBUG) {
|
|
60
|
+
console.log('sign', 'privateKey', privateKey.toString('hex'));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const hash = GetHash(encodedTx);
|
|
64
|
+
if (DEBUG) {
|
|
65
|
+
console.log('sign', 'hash', hash.toString('hex'));
|
|
66
|
+
}
|
|
67
|
+
const signature = SignBytes(hash, privateKey);
|
|
68
|
+
if (DEBUG) {
|
|
69
|
+
console.log('sign', 'signature', signature);
|
|
70
|
+
}
|
|
71
|
+
return signature.toLowerCase();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Verify = (encodedTx: string, signatureHex: string, publicKeyHex: string): boolean => {
|
|
75
|
+
if (DEBUG) {
|
|
76
|
+
console.log('verify', 'encodedTx', encodedTx);
|
|
77
|
+
console.log('verify', 'signatureHex', signatureHex);
|
|
78
|
+
console.log('verify', 'publicKeyHex', publicKeyHex);
|
|
79
|
+
}
|
|
80
|
+
const publicKeyPem = PublicToPem(publicKeyHex);
|
|
81
|
+
if (DEBUG) {
|
|
82
|
+
console.log('verify', 'publicKeyPem', publicKeyPem);
|
|
83
|
+
}
|
|
84
|
+
const publicKeyObj = crypto.createPublicKey({
|
|
85
|
+
key: publicKeyPem,
|
|
86
|
+
format: 'pem',
|
|
87
|
+
type: 'spki',
|
|
88
|
+
});
|
|
89
|
+
const signature = Buffer.from(signatureHex, 'hex');
|
|
90
|
+
const hash = GetHash(encodedTx);
|
|
91
|
+
if (DEBUG) {
|
|
92
|
+
console.log('verify', 'hash', hash.toString('hex'));
|
|
93
|
+
}
|
|
94
|
+
return crypto.verify(undefined, hash, publicKeyObj, signature);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const GetPublicFromPrivate = (privateKey: string): string => {
|
|
98
|
+
const privateKeyDer = PrivateToDer(privateKey);
|
|
99
|
+
const privateKeyObj = crypto.createPrivateKey({
|
|
100
|
+
key: privateKeyDer,
|
|
101
|
+
format: 'der',
|
|
102
|
+
type: 'pkcs8',
|
|
103
|
+
});
|
|
104
|
+
const privateKeyString = privateKeyObj.export({ format: 'der', type: 'pkcs8' });
|
|
105
|
+
/*const publicKeyObj = crypto.createPublicKey({
|
|
106
|
+
key: privateKeyObj,
|
|
107
|
+
format: 'pem',
|
|
108
|
+
type: 'sec1',
|
|
109
|
+
});*/
|
|
110
|
+
const publicKeyObj = crypto.createPublicKey({
|
|
111
|
+
key: privateKeyString,
|
|
112
|
+
format: 'pem',
|
|
113
|
+
type: 'spki',
|
|
114
|
+
});
|
|
115
|
+
const encodedHex = publicKeyObj
|
|
116
|
+
.export({ format: 'der', type: 'spki' })
|
|
117
|
+
.toString('hex')
|
|
118
|
+
.toUpperCase();
|
|
119
|
+
if (encodedHex.startsWith(PUBLIC_KEY_PREFIX)) {
|
|
120
|
+
return encodedHex.substring(PUBLIC_KEY_PREFIX.length);
|
|
121
|
+
} else {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`unknown prefix, expecting '${PUBLIC_KEY_PREFIX}' cannot decode public key '${encodedHex}'`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { ScriptBuilder } from '../vm';
|
|
4
|
+
import { Address } from '../types';
|
|
5
|
+
import { Transaction } from '../tx/Transaction';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Expiration Date is in UTC Seconds
|
|
9
|
+
* @param expirationDate
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export const GetDateAsUTCSeconds = (expirationDate) => {
|
|
13
|
+
const expirationDateUTCms = Date.UTC(
|
|
14
|
+
expirationDate.getUTCFullYear(),
|
|
15
|
+
expirationDate.getUTCMonth(),
|
|
16
|
+
expirationDate.getUTCDate(),
|
|
17
|
+
expirationDate.getUTCHours(),
|
|
18
|
+
expirationDate.getUTCMinutes(),
|
|
19
|
+
expirationDate.getUTCSeconds()
|
|
20
|
+
);
|
|
21
|
+
return expirationDateUTCms / 1000;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get Expiration Date
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export const GetExpirationDate = () => {
|
|
29
|
+
// TODO: make expirationDate configurable.
|
|
30
|
+
const expirationMinutes = 5; // This is in minutes
|
|
31
|
+
const expirationDate = new Date(Date.now() + expirationMinutes * 60000);
|
|
32
|
+
return expirationDate;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param transaction
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
export const EncodeSendTxWithSignature = (transaction) => {
|
|
41
|
+
// console.log('encodeSendTx', 'transaction', transaction);
|
|
42
|
+
const sendTx = transaction.toString(true);
|
|
43
|
+
// console.log('encodeSendTx', 'sendTx', sendTx);
|
|
44
|
+
return sendTx;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param transaction
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
export const EncodeSendTxWithoutSignature = (transaction) => {
|
|
53
|
+
const sendTx = transaction.toString(false);
|
|
54
|
+
// console.log('encodeSendTx', 'sendTx', sendTx);
|
|
55
|
+
return sendTx;
|
|
56
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './Mnemonic';
|
|
2
|
+
export * from './Address-Transcode';
|
|
3
|
+
export * from './interfaces/LedgerConfig';
|
|
4
|
+
export * from './Ledger-Utils';
|
|
5
|
+
export * from './Ledger-Commands';
|
|
6
|
+
export * from './Transaction-Transcode';
|
|
7
|
+
export * from './Transaction-Sign';
|
|
8
|
+
export * from './interfaces/index';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PhantasmaAPI } from '../../rpc/phantasma';
|
|
2
|
+
|
|
3
|
+
export interface LedgerConfig {
|
|
4
|
+
Debug: boolean;
|
|
5
|
+
Transport: any; // Replace 'any' with the actual type of transport
|
|
6
|
+
Bip39: any; // Replace 'any' with the actual type of bip39
|
|
7
|
+
Bip32Factory: any; // Replace 'any' with the actual type of bip32Factory
|
|
8
|
+
Curve: any; // Replace 'any' with the actual type of curve
|
|
9
|
+
NexusName: string;
|
|
10
|
+
ChainName: string;
|
|
11
|
+
Payload: string;
|
|
12
|
+
TokenNames: string[];
|
|
13
|
+
RPC: PhantasmaAPI;
|
|
14
|
+
GasPrice: number;
|
|
15
|
+
GasLimit: number;
|
|
16
|
+
VerifyResponse: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './ApplicationNameResponse';
|
|
2
|
+
export * from './Device';
|
|
3
|
+
export * from './DeviceResponse';
|
|
4
|
+
export * from './Ledger';
|
|
5
|
+
export * from './LedgerConfig';
|
|
6
|
+
export * from './LedgerDeviceInfoResponse';
|
|
7
|
+
export * from './PublicKeyResponse';
|
|
8
|
+
export * from './SignResponse';
|
|
9
|
+
export * from './VersionResponse';
|
|
10
|
+
export * from './LedgerBalanceFromLedgerResponse';
|
|
11
|
+
export * from './LedgerSigner';
|
|
12
|
+
export * from './LedgerSignerData';
|
|
13
|
+
export * from './LedgerSendTransactionResponse';
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { PhantasmaLink } from './phantasmaLink';
|
|
2
|
+
import { ProofOfWork } from './interfaces/ProofOfWork';
|
|
3
|
+
import { EasyScript, Nexus } from './easyScript';
|
|
4
|
+
|
|
5
|
+
export class EasyConnect {
|
|
6
|
+
requiredVersion: number;
|
|
7
|
+
platform: string;
|
|
8
|
+
providerHint: string;
|
|
9
|
+
link: PhantasmaLink;
|
|
10
|
+
connected: boolean;
|
|
11
|
+
script: EasyScript;
|
|
12
|
+
nexus: Nexus;
|
|
13
|
+
|
|
14
|
+
constructor(_options: Array<string> = null) {
|
|
15
|
+
this.platform = 'phantasma';
|
|
16
|
+
this.providerHint = 'poltergeist';
|
|
17
|
+
this.script = new EasyScript();
|
|
18
|
+
this.link = new PhantasmaLink('easyConnect', false);
|
|
19
|
+
this.connected = false;
|
|
20
|
+
this.requiredVersion = 2;
|
|
21
|
+
|
|
22
|
+
//Make This Auto In Future
|
|
23
|
+
this.nexus = Nexus.Mainnet;
|
|
24
|
+
|
|
25
|
+
if (_options == null) {
|
|
26
|
+
this.setConfig('auto');
|
|
27
|
+
} else {
|
|
28
|
+
try {
|
|
29
|
+
this.requiredVersion = Number(_options[0]);
|
|
30
|
+
this.platform = _options[1];
|
|
31
|
+
this.providerHint = _options[2];
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.log(error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
this.script = new EasyScript();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setConfig(_provider: string) {
|
|
40
|
+
this.requiredVersion = 2;
|
|
41
|
+
this.platform = 'phantasma';
|
|
42
|
+
|
|
43
|
+
switch (_provider) {
|
|
44
|
+
case 'auto':
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
if (!!window.PhantasmaLinkSocket == true) {
|
|
47
|
+
this.setConfig('ecto');
|
|
48
|
+
} else {
|
|
49
|
+
this.providerHint = '';
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
|
|
53
|
+
case 'ecto':
|
|
54
|
+
this.providerHint = 'ecto';
|
|
55
|
+
break;
|
|
56
|
+
|
|
57
|
+
case 'poltergeist':
|
|
58
|
+
this.providerHint = 'poltergeist';
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
connect(
|
|
64
|
+
onSuccess: any = (data) => {},
|
|
65
|
+
onFail: any = (data) => {
|
|
66
|
+
console.log('%cError: ' + data, 'color:red');
|
|
67
|
+
}
|
|
68
|
+
) {
|
|
69
|
+
let that = this;
|
|
70
|
+
|
|
71
|
+
this.link.login(
|
|
72
|
+
function (data) {
|
|
73
|
+
//Console Logging for Debugging Purposes
|
|
74
|
+
if (data) {
|
|
75
|
+
that.connected = true;
|
|
76
|
+
onSuccess(data);
|
|
77
|
+
console.log('%c[EasyConnect Connected]', 'color:green');
|
|
78
|
+
console.log(
|
|
79
|
+
"Wallet Address '" + that.link.account.address + "' connected via " + that.link.wallet
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
onFail();
|
|
83
|
+
console.log('EasyConnect could not connect to wallet');
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
onFail,
|
|
87
|
+
this.requiredVersion,
|
|
88
|
+
this.platform,
|
|
89
|
+
this.providerHint
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
disconnect(_message: string = 'Graceful Disconect') {
|
|
94
|
+
this.link.disconnect(_message);
|
|
95
|
+
this.connected = false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async query(
|
|
99
|
+
_type: string = null,
|
|
100
|
+
_arguments: Array<string> = null,
|
|
101
|
+
_callback: any = (data) => {
|
|
102
|
+
console.log(data);
|
|
103
|
+
}
|
|
104
|
+
) {
|
|
105
|
+
if (this.connected == true) {
|
|
106
|
+
switch (_type) {
|
|
107
|
+
case 'account':
|
|
108
|
+
let account = this.link.account;
|
|
109
|
+
_callback(account);
|
|
110
|
+
return account;
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case 'name':
|
|
114
|
+
let name = this.link.account.name;
|
|
115
|
+
_callback(name);
|
|
116
|
+
return name;
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case 'balances':
|
|
120
|
+
let balances = this.link.account.balances;
|
|
121
|
+
_callback(balances);
|
|
122
|
+
return balances;
|
|
123
|
+
break;
|
|
124
|
+
|
|
125
|
+
case 'walletAddress':
|
|
126
|
+
let walletAddress = this.link.account.address;
|
|
127
|
+
_callback(walletAddress);
|
|
128
|
+
return walletAddress;
|
|
129
|
+
break;
|
|
130
|
+
|
|
131
|
+
case 'avatar':
|
|
132
|
+
let avatar = this.link.account.avatar;
|
|
133
|
+
_callback(avatar);
|
|
134
|
+
return avatar;
|
|
135
|
+
break;
|
|
136
|
+
|
|
137
|
+
case 'tokenBalance':
|
|
138
|
+
//let token = _arguments[0];
|
|
139
|
+
//return this.link.accounts[]
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
console.log('%cWallet is not connected', 'color:red');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async action(
|
|
148
|
+
_type: string = null,
|
|
149
|
+
_arguments: Array<any> = null,
|
|
150
|
+
onSuccess: any = (data) => {},
|
|
151
|
+
onFail: any = (data) => {
|
|
152
|
+
console.log('%cError: ' + data, 'color:red');
|
|
153
|
+
}
|
|
154
|
+
) {
|
|
155
|
+
if (this.connected == true) {
|
|
156
|
+
switch (_type) {
|
|
157
|
+
case 'sendFT':
|
|
158
|
+
let sendFTScript = await this.script.buildScript('interop', [
|
|
159
|
+
'Runtime.SendTokens',
|
|
160
|
+
[_arguments[0], _arguments[1], _arguments[2], _arguments[3]],
|
|
161
|
+
]);
|
|
162
|
+
this.signTransaction(sendFTScript, null, onSuccess, onFail);
|
|
163
|
+
break;
|
|
164
|
+
|
|
165
|
+
case 'sendNFT':
|
|
166
|
+
let sendNFTScript = await this.script.buildScript('interop', [
|
|
167
|
+
'Runtime.SendTokens',
|
|
168
|
+
[_arguments[0], _arguments[1], _arguments[2], _arguments[3]],
|
|
169
|
+
]);
|
|
170
|
+
this.signTransaction(sendNFTScript, null, onSuccess, onFail);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
console.log('%cWallet is not connected', 'color:red');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
signTransaction(
|
|
179
|
+
script: string,
|
|
180
|
+
payload = null,
|
|
181
|
+
onSuccess: any = (data) => {},
|
|
182
|
+
onFail: any = (data) => {
|
|
183
|
+
console.log('%cError: ' + data, 'color:red');
|
|
184
|
+
}
|
|
185
|
+
) {
|
|
186
|
+
this.link.signTx(script, payload, onSuccess, onFail);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
signData(
|
|
190
|
+
data: any,
|
|
191
|
+
onSuccess: any = (data) => {},
|
|
192
|
+
onFail: any = (data) => {
|
|
193
|
+
console.log('%cError: ' + data, 'color:red');
|
|
194
|
+
}
|
|
195
|
+
) {
|
|
196
|
+
this.link.signData(data, onSuccess, onFail);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
invokeScript(script: string, _callback: any) {
|
|
200
|
+
this.link.invokeScript(script, _callback);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
deployContract(
|
|
204
|
+
script: string,
|
|
205
|
+
payload = null,
|
|
206
|
+
proofOfWork: ProofOfWork = ProofOfWork.Minimal,
|
|
207
|
+
onSuccess: any = (data) => {},
|
|
208
|
+
onFail: any = (data) => {
|
|
209
|
+
console.log('%cError: ' + data, 'color:red');
|
|
210
|
+
}
|
|
211
|
+
) {
|
|
212
|
+
this.link.signTx(script, payload, onSuccess, onFail, proofOfWork);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ScriptBuilder } from "../vm";
|
|
2
|
+
|
|
3
|
+
export enum Nexus {
|
|
4
|
+
Mainnet = "mainnet",
|
|
5
|
+
Simnet = "simnet",
|
|
6
|
+
Testnet = "testnet",
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class EasyScript {
|
|
10
|
+
nexus: Nexus;
|
|
11
|
+
sb: ScriptBuilder;
|
|
12
|
+
|
|
13
|
+
constructor(nexus: Nexus = Nexus.Mainnet) {
|
|
14
|
+
this.sb = new ScriptBuilder();
|
|
15
|
+
this.nexus = nexus;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
buildScript(_type: string, _options: Array<any> = [null]) {
|
|
19
|
+
this.sb = new ScriptBuilder();
|
|
20
|
+
|
|
21
|
+
switch (_type) {
|
|
22
|
+
case "interact":
|
|
23
|
+
let contractNameInteract: string = _options[0];
|
|
24
|
+
let methodNameInteract: string = _options[1];
|
|
25
|
+
let inputArgumentsInteract: Array<any> = _options[2];
|
|
26
|
+
|
|
27
|
+
return this.sb
|
|
28
|
+
.CallContract("gas", "AllowGas", [])
|
|
29
|
+
.CallContract(
|
|
30
|
+
contractNameInteract,
|
|
31
|
+
methodNameInteract,
|
|
32
|
+
inputArgumentsInteract
|
|
33
|
+
) //The Meat of the Script
|
|
34
|
+
.CallContract("gas", "SpendGas", [])
|
|
35
|
+
.EndScript();
|
|
36
|
+
|
|
37
|
+
break;
|
|
38
|
+
|
|
39
|
+
case "invoke":
|
|
40
|
+
let contractNameInvoke: string = _options[0];
|
|
41
|
+
let methodNameInvoke: string = _options[1];
|
|
42
|
+
let inputArgumentsInvoke: Array<any> = _options[2];
|
|
43
|
+
|
|
44
|
+
return this.sb
|
|
45
|
+
.CallContract(
|
|
46
|
+
contractNameInvoke,
|
|
47
|
+
methodNameInvoke,
|
|
48
|
+
inputArgumentsInvoke
|
|
49
|
+
) //The Meat of the Script
|
|
50
|
+
.EndScript();
|
|
51
|
+
|
|
52
|
+
break;
|
|
53
|
+
|
|
54
|
+
case "interop":
|
|
55
|
+
let interopNameInterop: string = _options[0];
|
|
56
|
+
let inputArgumentsInterop: Array<any> = _options[1];
|
|
57
|
+
|
|
58
|
+
return this.sb
|
|
59
|
+
.CallContract("gas", "AllowGas", [])
|
|
60
|
+
.CallInterop(interopNameInterop, inputArgumentsInterop)
|
|
61
|
+
.CallContract("gas", "SpendGas", [])
|
|
62
|
+
.EndScript();
|
|
63
|
+
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './interfaces';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Balance } from '../../rpc/interfaces/Balance';
|
|
2
|
+
import { IFile } from './IFile';
|
|
3
|
+
|
|
4
|
+
export interface IAccount {
|
|
5
|
+
alias: string;
|
|
6
|
+
name: string;
|
|
7
|
+
address: string;
|
|
8
|
+
avatar: string;
|
|
9
|
+
platform: string;
|
|
10
|
+
external: string;
|
|
11
|
+
balances: Balance[];
|
|
12
|
+
files: IFile[];
|
|
13
|
+
}
|