Package sg.dex.starfish.keeper
Class DirectPurchaseAdapter
java.lang.Object
sg.dex.starfish.keeper.DirectPurchaseAdapter
public final class DirectPurchaseAdapter extends Object
Direct purchase adapter.
It provides direct purchase functionality
- Author:
- Ilya Bukalov
-
Method Summary
Modifier and Type Method Description boolean
checkIsPaid(String purchaser_address, String publisher_address, BigInteger amount, String reference)
Check whether purchase is donestatic DirectPurchaseAdapter
create(DexConfig dexConfig)
Creates a DirectPurchaseAdapterorg.web3j.protocol.core.methods.response.TransactionReceipt
sendTokenAndLog(String to, BigInteger amount, String reference1, String reference2)
Sends tokens and log this transaction in blockchain.boolean
tokenApprove(String spenderAddress, String price)
Returns whether the transaction is successful
-
Method Details
-
create
Creates a DirectPurchaseAdapter- Parameters:
DexConfig
- config- Returns:
- DirectPurchaseAdapter The newly created DirectPurchaseAdapter
- Throws:
IOException
-
sendTokenAndLog
public org.web3j.protocol.core.methods.response.TransactionReceipt sendTokenAndLog(String to, BigInteger amount, String reference1, String reference2)Sends tokens and log this transaction in blockchain.- Parameters:
to
- The publisher address who is paid for assetamount
- The amount of tokens being transferredreference1
- 32 byte identifier (agent id)reference2
- Unique 32 byte identifier of asset- Returns:
- TransactionReceipt Ethereum transaction receipt.
-
tokenApprove
Returns whether the transaction is successful- Parameters:
spenderAddress
- The address who will be allowed to spend tokens of signerprice
- Amount of tokens to spend- Returns:
- boolean
-
checkIsPaid
public boolean checkIsPaid(String purchaser_address, String publisher_address, BigInteger amount, String reference)Check whether purchase is done- Parameters:
purchaser_address
- The address who paid for assetpublisher_address
- The address who was paid for assetamount
- Token amount to checkreference
- Unique 32 byte identifier of asset- Returns:
- boolean Result
-