Documentation ¶
Index ¶
- Constants
- Variables
- func CalcTxHash(tx *core.Transaction) string
- func EthToTron(ethAddress string) (string, error)
- func GetSwapInAndExecFuncHash(tokenCfg *tokens.TokenConfig) string
- func GetSwapInFuncHash(tokenCfg *tokens.TokenConfig) string
- func PubKeyToAddress(pubKeyHex string) (address string, err error)
- func SupportsChainID(chainID *big.Int) bool
- func TronToEth(tronAddress string) (string, error)
- func VerifyMPCPubKey(mpcAddress, mpcPubkey string) error
- type Bridge
- func (b *Bridge) BroadcastTx(tx *core.Transaction) (err error)
- func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
- func (b *Bridge) BuildTriggerConstantContractTx(from, contract string, selector string, parameter string, fee_limit int64) (tx *core.Transaction, err error)
- func (b *Bridge) CallContract(contract string, data hexutil.Bytes, blockNumber string) (string, error)
- func (b *Bridge) ChainID() (*big.Int, error)
- func (b *Bridge) GetBalance(account string) (balance *big.Int, err error)
- func (b *Bridge) GetCode(contractAddress string) (data []byte, err error)
- func (b *Bridge) GetContractCodeHash(contract string) common.Hash
- func (b *Bridge) GetEIP1167Master(proxy string) (master common.Address)
- func (b *Bridge) GetErc20Balance(contract, address string) (*big.Int, error)
- func (b *Bridge) GetErc20Decimals(contract string) (uint8, error)
- func (b *Bridge) GetErc20TotalSupply(contract string) (*big.Int, error)
- func (b *Bridge) GetFactoryAddress(contractAddr string) (string, error)
- func (b *Bridge) GetLatestBlockNumber() (height uint64, err error)
- func (b *Bridge) GetLatestBlockNumberOf(url string) (latest uint64, err error)
- func (b *Bridge) GetMPCAddress(contractAddr string) (string, error)
- func (b *Bridge) GetOwnerAddress(contractAddr string) (string, error)
- func (b *Bridge) GetPairFor(factory, token0, token1 string) (string, error)
- func (b *Bridge) GetSignedTxHashOfKeyID(sender, keyID string, rawTx interface{}) (txHash string, err error)
- func (b *Bridge) GetTokenBalance(tokenType, tokenAddress, accountAddress string) (*big.Int, error)
- func (b *Bridge) GetTokenSupply(tokenType, tokenAddress string) (*big.Int, error)
- func (b *Bridge) GetTransaction(txHash string) (tx interface{}, err error)
- func (b *Bridge) GetTransactionInfo(txHash string) (*rpcGetTxInfoRes, error)
- func (b *Bridge) GetTransactionLog(txHash string) ([]*types.RPCLog, error)
- func (b *Bridge) GetTransactionStatus(txHash string) (status *tokens.TxStatus, err error)
- func (b *Bridge) GetTronTransaction(txHash string) (tx *core.Transaction, err error)
- func (b *Bridge) GetUnderlyingAddress(contractAddr string) (string, error)
- func (b *Bridge) GetVaultAddress(contractAddr string) (string, error)
- func (b *Bridge) GetWNativeAddress(contractAddr string) (string, error)
- func (b *Bridge) InitAfterConfig()
- func (b *Bridge) InitExtraCustoms()
- func (b *Bridge) InitRouterInfo(routerContract, routerVersion string) (err error)
- func (b *Bridge) IsContractAddress(address string) (bool, error)
- func (b *Bridge) IsMinter(contractAddr, minterAddr string) (bool, error)
- func (b *Bridge) IsValidAddress(address string) bool
- func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signTx interface{}, txHash string, err error)
- func (b *Bridge) NetworkID() (*big.Int, error)
- func (b *Bridge) PublicKeyToAddress(pubKeyHex string) (address string, err error)
- func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
- func (b *Bridge) SendTransaction(signedTx interface{}) (txHash string, err error)
- func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, priKey string) (signTx interface{}, txHash string, err error)
- func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHashes []string) error
- func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
- type CustomConfig
- type RPCError
Constants ¶
const (
ERC20TokenType = "ERC20"
)
token types (should be all upper case)
Variables ¶
var ( // v5 LogAnyCall(address,address,bytes,address,uint256) LogAnyCallV5Topic = common.FromHex("0x9ca1de98ebed0a9c38ace93d3ca529edacbbe199cf1b6f0f416ae9b724d4a81c") AnyExecV5FuncHash = common.FromHex("0xb4c5dbd0") // v6 LogAnyCall(address,address,bytes,address,uint256,uint256,string,uint256) LogAnyCallV6Topic = common.FromHex("0xa17aef042e1a5dd2b8e68f0d0d92f9a6a0b35dc25be1d12c0cb3135bfd8951c9") AnyExecV6FuncHash = common.FromHex("0x4a578150") )
anycall lot topics and func hashes
var ( ForceAnySwapInAutoTokenVersion = uint64(10001) ForceAnySwapInTokenVersion = uint64(10002) ForceAnySwapInUnderlyingTokenVersion = uint64(10003) ForceAnySwapInNativeTokenVersion = uint64(10004) ForceAnySwapInAndCallTokenVersion = uint64(10005) ForceAnySwapInUnerlyingAndCallTokenVersion = uint64(10006) // anySwapIn(bytes32 txs, address token, address to, uint amount, uint fromChainID) AnySwapInFuncHash = "anySwapIn(bytes32,address,address,uint256,uint256)" // anySwapInUnderlying(bytes32 txs, address token, address to, uint amount, uint fromChainID) AnySwapInUnderlyingFuncHash = "anySwapInUnderlying(bytes32,address,address,uint256,uint256)" // anySwapInNative(bytes32 txs, address token, address to, uint amount, uint fromChainID) AnySwapInNativeFuncHash = "anySwapInNative(bytes32,address,address,uint256,uint256)" // anySwapInAuto(bytes32 txs, address token, address to, uint amount, uint fromChainID) AnySwapInAutoFuncHash = "anySwapInAuto(bytes32,address,address,uint256,uint256)" // anySwapInAndExec(bytes32 txs, address token, address to, uint amount, uint fromChainID, address anycallProxy, bytes calldata data) AnySwapInAndExecFuncHash = "anySwapInAndExec(bytes32,address,address,uint256,uint256,address,bytes)" // anySwapInUnderlyingAndExec(bytes32 txs, address token, address to, uint amount, uint fromChainID, address anycallProxy, bytes calldata data) AnySwapInUnderlyingAndExecFuncHash = "anySwapInUnderlyingAndExec(bytes32,address,address,uint256,uint256,address,bytes)" )
router contract's func hashs
var ( // LogNFT721SwapOut(address,address,address,uint256,uint256,uint256); LogNFT721SwapOutTopic = common.FromHex("0x0d45b0b9f5add3e1bb841982f1fa9303628b0b619b000cb1f9f1c3903329a4c7") // LogNFT1155SwapOut(addressindexedtoken,address,address,uint256,uint256,uint256,uint256) LogNFT1155SwapOutTopic = common.FromHex("0x5058b8684cf36ffd9f66bc623fbc617a44dd65cf2273306d03d3104af0995cb0") //LogNFT1155SwapOutBatch(address,address,address,uint256[],uint256[],uint256,uint256) LogNFT1155SwapOutBatchTopic = common.FromHex("0xaa428a5ab688b49b415401782c170d216b33b15711d30cf69482f570eca8db38") )
nft swap log topics and func hashes
var ( // LogAnySwapOut(address token, address from, address to, uint amount, uint fromChainID, uint toChainID); LogAnySwapOutTopic = common.FromHex("0x97116cf6cd4f6412bb47914d6db18da9e16ab2142f543b86e207c24fbd16b23a") // LogAnySwapOut(address token, address from, string to, uint amount, uint fromChainID, uint toChainID); LogAnySwapOut2Topic = common.FromHex("0x409e0ad946b19f77602d6cf11d59e1796ddaa4828159a0b4fb7fa2ff6b161b79") // LogAnySwapOutAndCall(address token, address from, string to, uint amount, uint fromChainID, uint toChainID, string anycallProxy, bytes data); LogAnySwapOutAndCallTopic = common.FromHex("0x8e7e5695fff09074d4c7d6c71615fd382427677f75f460c522357233f3bd3ec3") )
router contract's log topics
var GRPC_TIMEOUT = time.Second * 15
var ( // LogNFT721SwapOut(address,address,address,uint256,uint256,uint256,bytes); LogNFT721SwapOutWithDataTopic = common.FromHex("0x8ef0d7d8b96825500b3d692d995a543110f8a93f16b7be5d23b5960fd4363bdc") )
nft swap with data log topics and func hashes
var SwapinFeeLimit int64 = 300000000 // 300 TRX
var TronMainnetChainID = uint64(112233)
var TronShastaChainID = uint64(2494104990)
Functions ¶
func CalcTxHash ¶
func CalcTxHash(tx *core.Transaction) string
func GetSwapInAndExecFuncHash ¶
func GetSwapInAndExecFuncHash(tokenCfg *tokens.TokenConfig) string
GetSwapInAndExecFuncHash get swapin and call func hash
func GetSwapInFuncHash ¶
func GetSwapInFuncHash(tokenCfg *tokens.TokenConfig) string
GetSwapInFuncHash get swapin func hash
func PubKeyToAddress ¶
PubKeyToAddress tool
func VerifyMPCPubKey ¶
VerifyMPCPubKey verify mpc address and public key is matching
Types ¶
type Bridge ¶
type Bridge struct { CustomConfig *tokens.CrossChainBridgeBase SignerChainID *big.Int TronChainID *big.Int }
Bridge eth bridge
func (*Bridge) BroadcastTx ¶
func (b *Bridge) BroadcastTx(tx *core.Transaction) (err error)
BroadcastTx broadcast tx to network
func (*Bridge) BuildRawTransaction ¶
func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
BuildRawTransaction build raw tx
func (*Bridge) BuildTriggerConstantContractTx ¶
func (*Bridge) CallContract ¶
func (b *Bridge) CallContract(contract string, data hexutil.Bytes, blockNumber string) (string, error)
CallContract
func (*Bridge) ChainID ¶
ChainID call eth_chainId Notice: eth_chainId return 0x0 for mainnet which is wrong (use net_version instead)
func (*Bridge) GetBalance ¶
GetBalance gets TRON token balance
func (*Bridge) GetContractCodeHash ¶
GetContractCodeHash get contract code hash
func (*Bridge) GetEIP1167Master ¶
GetEIP1167Master get eip1167 master address
func (*Bridge) GetErc20Balance ¶
GetErc20Balance get erc20 balacne of address
func (*Bridge) GetErc20Decimals ¶
GetErc20Decimals get erc20 decimals
func (*Bridge) GetErc20TotalSupply ¶
GetErc20TotalSupply get erc20 total supply of address
func (*Bridge) GetFactoryAddress ¶
GetFactoryAddress call "factory()"
func (*Bridge) GetLatestBlockNumber ¶
GetLatestBlockNumber returns current finalized block height
func (*Bridge) GetLatestBlockNumberOf ¶
GetLatestBlockNumberOf call eth_blockNumber
func (*Bridge) GetMPCAddress ¶
GetMPCAddress call "mpc()"
func (*Bridge) GetOwnerAddress ¶
GetOwnerAddress call "owner()"
func (*Bridge) GetPairFor ¶
GetPairFor call "getPair(address,address)"
func (*Bridge) GetSignedTxHashOfKeyID ¶
func (b *Bridge) GetSignedTxHashOfKeyID(sender, keyID string, rawTx interface{}) (txHash string, err error)
GetSignedTxHashOfKeyID get signed tx hash by keyID (called by oracle)
func (*Bridge) GetTokenBalance ¶
GetTokenBalance api
func (*Bridge) GetTokenSupply ¶
GetTokenSupply impl
func (*Bridge) GetTransaction ¶
GetTransaction impl
func (*Bridge) GetTransactionInfo ¶
func (*Bridge) GetTransactionLog ¶
GetTransactionLog
func (*Bridge) GetTransactionStatus ¶
GetTransactionStatus returns tx status
func (*Bridge) GetTronTransaction ¶
func (b *Bridge) GetTronTransaction(txHash string) (tx *core.Transaction, err error)
GetTronTransaction get tx
func (*Bridge) GetUnderlyingAddress ¶
GetUnderlyingAddress call "underlying()"
func (*Bridge) GetVaultAddress ¶
GetVaultAddress call "vault()"
func (*Bridge) GetWNativeAddress ¶
GetWNativeAddress call "wNATIVE()"
func (*Bridge) InitAfterConfig ¶
func (b *Bridge) InitAfterConfig()
InitAfterConfig init variables (ie. extra members) after loading config
func (*Bridge) InitExtraCustoms ¶
func (b *Bridge) InitExtraCustoms()
InitExtraCustoms init extra customs
func (*Bridge) InitRouterInfo ¶
InitRouterInfo init router info
func (*Bridge) IsContractAddress ¶
IsContractAddress is contract address
func (*Bridge) IsValidAddress ¶
IsValidAddress check address
func (*Bridge) MPCSignTransaction ¶
func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signTx interface{}, txHash string, err error)
MPCSignTransaction mpc sign raw tx
func (*Bridge) PublicKeyToAddress ¶
PublicKeyToAddress returns cosmos public key address
func (*Bridge) RegisterSwap ¶
func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
RegisterSwap api
func (*Bridge) SendTransaction ¶
SendTransaction send signed tx
func (*Bridge) SignTransactionWithPrivateKey ¶
func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, priKey string) (signTx interface{}, txHash string, err error)
SignTransactionWithPrivateKey sign tx with private key (use for testing)
func (*Bridge) VerifyMsgHash ¶
VerifyMsgHash verify msg hash
func (*Bridge) VerifyTransaction ¶
func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
VerifyTransaction api
type CustomConfig ¶
type CustomConfig struct { // some chain's rpc is slow and need config a longer rpc timeout RPCClientTimeout int // eg. RSK chain do not check mixed case or not same as eth DontCheckAddressMixedCase bool }
CustomConfig custom config
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package abicoder is simple tool to pack datas like solidity abi.
|
Package abicoder is simple tool to pack datas like solidity abi. |
tools
|
|