111
This commit is contained in:
1 parent
68a2b4f68c
commit
7cd697187c
308 files changed
+30454
-75
No files matched your search
@@ -0,0 +1,258 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.system.domain.vo.EnergyAndBandwidthVo;
|
||||
import com.ruoyi.system.domain.vo.TronAccount;
|
||||
import com.ruoyi.system.domain.vo.TronAccountItem;
|
||||
import org.tron.trident.core.ApiWrapper;
|
||||
import org.tron.trident.core.exceptions.IllegalException;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public interface ITronService {
|
||||
Integer grpcPort();
|
||||
String grpcUrl();
|
||||
String type();
|
||||
ApiWrapper buildApiWrapper(String privateKey);
|
||||
|
||||
String contractAddress();
|
||||
|
||||
String tronscanApiUrl();
|
||||
|
||||
String tronscanApiKey();
|
||||
|
||||
String usdtTrans(ApiWrapper api,String fromAddress, String toAddress, String amount);
|
||||
|
||||
|
||||
String trxTrans(ApiWrapper api,String fromAddress, String toAddress, BigDecimal amount);
|
||||
/**
|
||||
* 不包含质押的数量
|
||||
* @param api
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getTRxBalance(ApiWrapper api,String address);
|
||||
|
||||
BigDecimal getUsdtBalance(ApiWrapper api,String address);
|
||||
|
||||
/**
|
||||
* 所有的可用的 包括別人代理給你的值
|
||||
* @param ownerAddr
|
||||
* @return
|
||||
*/
|
||||
EnergyAndBandwidthVo energyAndBandwidth(String ownerAddr);
|
||||
|
||||
/**
|
||||
* 別人代理給我的的能量和带宽值
|
||||
* @param ownerAddr
|
||||
* @return
|
||||
*/
|
||||
EnergyAndBandwidthVo allDelegatedDnergyAndBandwidth(String ownerAddr);
|
||||
|
||||
/**
|
||||
* 一天后生效,一天内可以cancle
|
||||
* @param api
|
||||
* @param ownerAddr
|
||||
* @param balance
|
||||
* @param resourceCode | 枚举 | code | 链上含义 | 能否 stake | 能否 unfreeze |
|
||||
* | -------------- | ----- | ----------- | -------- | ----------- |
|
||||
* | BANDWIDTH | 0 | 带宽 | ✅ | ✅ |
|
||||
* | ENERGY | 1 | 能量 | ✅ | ✅ |
|
||||
* | **TRON_POWER** | **2** | **投票权(TP)** | ❌ | ❌ |
|
||||
* | UNRECOGNIZED | -1 | protobuf 占位 | ❌ | ❌ |
|
||||
* @return
|
||||
*/
|
||||
boolean unstakeTrxBalance(ApiWrapper api,String ownerAddr, BigDecimal balance, int resourceCode);
|
||||
|
||||
/**
|
||||
* 取消 unstakeTrxBalance
|
||||
* @param api
|
||||
* @param ownerAddr
|
||||
* @return
|
||||
*/
|
||||
boolean cancleUnstakeTrxBalance(ApiWrapper api,String ownerAddr);
|
||||
|
||||
/**
|
||||
* 質押trx-获取带宽或者能量
|
||||
* 调用会消耗能量或者带宽-不足是会消耗TRX-所以不能一次性质押TXT,最好要预留一个trx-1
|
||||
* @param api
|
||||
* @param ownerAddr
|
||||
* @param balance
|
||||
* @param resourceCode | 枚举 | code | 链上含义 | 能否 stake | 能否 unfreeze |
|
||||
* | -------------- | ----- | ----------- | -------- | ----------- |
|
||||
* | BANDWIDTH | 0 | 带宽 | ✅ | ✅ |
|
||||
* | ENERGY | 1 | 能量 | ✅ | ✅ |
|
||||
* | **TRON_POWER** | **2** | **投票权(TP)** | ❌ | ❌ |
|
||||
* | UNRECOGNIZED | -1 | protobuf 占位 | ❌ | ❌ |
|
||||
*/
|
||||
boolean stakeTrxBalance(ApiWrapper api,String ownerAddr, BigDecimal balance, int resourceCode);
|
||||
|
||||
/**
|
||||
* 获取质押trx的数量-不包含代理的
|
||||
* @param ownerAddr
|
||||
* @param resourceCode | 枚举 | code | 链上含义 | 能否 stake | 能否 unfreeze |
|
||||
* | -------------- | ----- | ----------- | -------- | ----------- |
|
||||
* | BANDWIDTH | 0 | 带宽 | ✅ | ✅ |
|
||||
* | ENERGY | 1 | 能量 | ✅ | ✅ |
|
||||
* | **TRON_POWER** | **2** | **投票权(TP)** | ❌ | ❌ |
|
||||
* | UNRECOGNIZED | -1 | protobuf 占位 | ❌ | ❌ |
|
||||
* @return
|
||||
*/
|
||||
BigDecimal stakedTrxBalance(ApiWrapper api,String ownerAddr, int resourceCode);
|
||||
|
||||
/**
|
||||
* 获取别人质押的trx的数量-代理的
|
||||
* @param ownerAddr
|
||||
* @param resourceCode | 枚举 | code | 链上含义 | 能否 stake | 能否 unfreeze |
|
||||
* | -------------- | ----- | ----------- | -------- | ----------- |
|
||||
* | BANDWIDTH | 0 | 带宽 | ✅ | ✅ |
|
||||
* | ENERGY | 1 | 能量 | ✅ | ✅ |
|
||||
* | **TRON_POWER** | **2** | **投票权(TP)** | ❌ | ❌ |
|
||||
* | UNRECOGNIZED | -1 | protobuf 占位 | ❌ | ❌ |
|
||||
* @return
|
||||
*/
|
||||
BigDecimal acquiredDelegatedStakedTrxBalance(ApiWrapper api,String ownerAddr, int resourceCode);
|
||||
|
||||
|
||||
/**
|
||||
* 我质押的trx的数量-代理的给别人的
|
||||
* @param ownerAddr
|
||||
* @param resourceCode | 枚举 | code | 链上含义 | 能否 stake | 能否 unfreeze |
|
||||
* | -------------- | ----- | ----------- | -------- | ----------- |
|
||||
* | BANDWIDTH | 0 | 带宽 | ✅ | ✅ |
|
||||
* | ENERGY | 1 | 能量 | ✅ | ✅ |
|
||||
* | **TRON_POWER** | **2** | **投票权(TP)** | ❌ | ❌ |
|
||||
* | UNRECOGNIZED | -1 | protobuf 占位 | ❌ | ❌ |
|
||||
* @return
|
||||
*/
|
||||
BigDecimal delegatedStakedTrxBalance(ApiWrapper api,String ownerAddr, int resourceCode);
|
||||
|
||||
/**
|
||||
* 取消质押账户金额 - 在unstakeTrxBalance操作后会有值
|
||||
* @param api
|
||||
* @param ownerAddr
|
||||
* @param resourceCode
|
||||
* @return
|
||||
*/
|
||||
BigDecimal cancleStakedTrxBalance(ApiWrapper api, String ownerAddr, int resourceCode);
|
||||
|
||||
/**
|
||||
* 获取可投票的数量
|
||||
* @param ownerAddr
|
||||
* @return
|
||||
*/
|
||||
BigDecimal voteBalance(ApiWrapper api,String ownerAddr);
|
||||
|
||||
|
||||
/**
|
||||
* 已经投票的数量
|
||||
* @param ownerAddr
|
||||
* @return
|
||||
*/
|
||||
BigDecimal votedBalance(ApiWrapper api,String ownerAddr);
|
||||
|
||||
/**
|
||||
* 自动投票到top前size的地址上
|
||||
* @param api
|
||||
* @param ownerAddress
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
boolean autoVoteTop(ApiWrapper api,String ownerAddress,int size) throws IllegalException;
|
||||
|
||||
/**
|
||||
* 自动领取TRX奖励
|
||||
* @param api
|
||||
* @param ownerAddr
|
||||
* @throws IllegalException
|
||||
*/
|
||||
boolean autoGetReward(ApiWrapper api,String ownerAddr) throws IllegalException;
|
||||
|
||||
/**
|
||||
* 给某个sender 授权usdt 额度-是做覆盖操作
|
||||
* @param api ownerAddr的api
|
||||
* @param ownerAddr 账户所有者地址
|
||||
* @param sender - 被授权的钱包地址
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
Boolean approve(ApiWrapper api,String ownerAddr,String sender, BigDecimal amount);
|
||||
|
||||
|
||||
BigDecimal getAllowance(ApiWrapper api,String ownerAddress, String spenderAddress);
|
||||
/**
|
||||
* usdt 转账
|
||||
* @param api 被授权(approve)的账号生成的api
|
||||
* @param sender approve 被授权的钱包地址
|
||||
* @param fromAddress
|
||||
* @param toAddress
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
Boolean usdtTransferFrom(ApiWrapper api,String sender,String fromAddress, String toAddress, BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 创建钱包
|
||||
* @return
|
||||
*/
|
||||
TronAccountItem createTronAddress();
|
||||
|
||||
/**
|
||||
* 由助记词生成
|
||||
* @return
|
||||
*/
|
||||
TronAccount createTronWallet(Integer site);
|
||||
/**
|
||||
* 默认不使用
|
||||
* Estimate the energy required for the successful execution of smart contract transactions
|
||||
* This API is closed by default in tron node.
|
||||
* To open this interface, the two configuration items vm.estimateEnergy and vm.supportConstant
|
||||
* must be enabled in the node configuration file at the same time.
|
||||
* @param api
|
||||
* @param fromAddress
|
||||
* @param toAddress
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
long estimateEnergy(ApiWrapper api,String fromAddress, String toAddress, BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 默认消耗的energy
|
||||
* @return
|
||||
*/
|
||||
long defaultEstimateEnergy();
|
||||
|
||||
|
||||
long defaultEstimateBandwidth();
|
||||
/**
|
||||
* 获取transfer消耗的带宽
|
||||
* @param api
|
||||
* @param fromAddress
|
||||
* @param toAddress
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
long estimateBandwidth(ApiWrapper api,String fromAddress, String toAddress, BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 把质押的TRX 代理给其他账号获取 带宽或者能量
|
||||
* @param api
|
||||
* @param fromAddress
|
||||
* @param toAddress
|
||||
* @param amount
|
||||
* @param resourceCode
|
||||
* @return
|
||||
*/
|
||||
String delegateResourceV2(ApiWrapper api,String fromAddress, String toAddress,BigDecimal amount ,int resourceCode);
|
||||
|
||||
|
||||
/**
|
||||
* 取消把质押的TRX 代理给其他账号
|
||||
* @param api
|
||||
* @param fromAddress
|
||||
* @param toAddress
|
||||
* @param amount
|
||||
* @param resourceCode
|
||||
* @return
|
||||
*/
|
||||
String unDelegateResourceV2(ApiWrapper api,String fromAddress, String toAddress,BigDecimal amount ,int resourceCode);
|
||||
}
|
||||
Reference in new issue
Block a user