forked from Qortal/qortal
Added "GET_PRICE" action.
This commit is contained in:
parent
86d6037af3
commit
57eacbdd59
11
Q-Apps.md
11
Q-Apps.md
@ -76,6 +76,7 @@ Here is a list of currently supported actions:
|
|||||||
- FETCH_BLOCK
|
- FETCH_BLOCK
|
||||||
- FETCH_BLOCK_RANGE
|
- FETCH_BLOCK_RANGE
|
||||||
- SEARCH_TRANSACTIONS
|
- SEARCH_TRANSACTIONS
|
||||||
|
- GET_PRICE
|
||||||
|
|
||||||
More functionality will be added in the future.
|
More functionality will be added in the future.
|
||||||
|
|
||||||
@ -392,6 +393,16 @@ let res = await qortalRequest({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Get an estimate of the QORT price
|
||||||
|
```
|
||||||
|
let res = await qortalRequest({
|
||||||
|
action: "GET_PRICE",
|
||||||
|
blockchain: "LITECOIN",
|
||||||
|
// maxtrades: 10,
|
||||||
|
inverse: true
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Sample App
|
## Sample App
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import org.qortal.api.*;
|
|||||||
import org.qortal.api.model.NameSummary;
|
import org.qortal.api.model.NameSummary;
|
||||||
import org.qortal.api.resource.*;
|
import org.qortal.api.resource.*;
|
||||||
import org.qortal.arbitrary.misc.Service;
|
import org.qortal.arbitrary.misc.Service;
|
||||||
|
import org.qortal.crosschain.SupportedBlockchain;
|
||||||
import org.qortal.data.account.AccountData;
|
import org.qortal.data.account.AccountData;
|
||||||
import org.qortal.data.arbitrary.ArbitraryResourceInfo;
|
import org.qortal.data.arbitrary.ArbitraryResourceInfo;
|
||||||
import org.qortal.data.arbitrary.ArbitraryResourceStatus;
|
import org.qortal.data.arbitrary.ArbitraryResourceStatus;
|
||||||
@ -214,6 +215,14 @@ public class AppsResource {
|
|||||||
return transactionsResource.searchTransactions(startBlock, blockLimit, txGroupId, txTypes, address, confirmationStatus, limit, offset, reverse);
|
return transactionsResource.searchTransactions(startBlock, blockLimit, txGroupId, txTypes, address, confirmationStatus, limit, offset, reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/price")
|
||||||
|
@Hidden // For internal Q-App API use only
|
||||||
|
public long getPrice(@QueryParam("blockchain") SupportedBlockchain foreignBlockchain, @QueryParam("maxtrades") Integer maxtrades, @QueryParam("inverse") Boolean inverse) {
|
||||||
|
CrossChainResource crossChainResource = (CrossChainResource) buildResource(CrossChainResource.class, request, response, context);
|
||||||
|
return crossChainResource.getTradePriceEstimate(foreignBlockchain, maxtrades, inverse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Object buildResource(Class<?> resourceClass, HttpServletRequest request, HttpServletResponse response, ServletContext context) {
|
public static Object buildResource(Class<?> resourceClass, HttpServletRequest request, HttpServletResponse response, ServletContext context) {
|
||||||
try {
|
try {
|
||||||
|
@ -190,6 +190,14 @@ window.addEventListener("message", (event) => {
|
|||||||
response = httpGet(url);
|
response = httpGet(url);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "GET_PRICE":
|
||||||
|
url = "/apps/price?";
|
||||||
|
if (data.blockchain != null) url = url.concat("&blockchain=" + data.blockchain);
|
||||||
|
if (data.maxtrades != null) url = url.concat("&maxtrades=" + data.maxtrades);
|
||||||
|
if (data.inverse != null) url = url.concat("&inverse=" + data.inverse);
|
||||||
|
response = httpGet(url);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Pass to parent (UI), in case they can fulfil this request
|
// Pass to parent (UI), in case they can fulfil this request
|
||||||
event.data.requestedHandler = "UI";
|
event.data.requestedHandler = "UI";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user