-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserverAPI.ts
More file actions
100 lines (92 loc) · 2.78 KB
/
serverAPI.ts
File metadata and controls
100 lines (92 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import axios from 'axios'
import {ReceiptedType} from './localAPI'
const instance = axios.create({
// baseURL: 'https://hydro-bridgev2.herokuapp.com/api/1.0.0/',
baseURL: 'https://hydro-bridge.org/api/1.0.0/',
withCredentials: false,
})
export const serverApi = {
getHydroBalance(address: string, chainName: ChainType): Promise<GetHydroBalanceResponseType> {
return instance.get('getHydroBalance', {
params: {
address, chainName
}
})
},
getTransactionFee(amountOfHydro: string, destinationChain: ChainType): Promise<GetTransactionFeeType> {
return instance.get('getSwapCostInHydroTokens', {
params: {
amountOfHydro, destinationChain
}
})
},
transactionDetails(TransactionHash: string, chainName: ChainType): Promise<GetTransactionDetailsResponseType> {
return instance.get('transactionDetails', {
params: {
TransactionHash, chainName
}
})
},
performSwap(TransactionHashInput: ReceiptedType, sourceChainName: ChainType, destinationChainName: ChainType): Promise<PerformSwapType> {
const TransactionHash = TransactionHashInput.transactionHash
// const serverAnswer = await localAPI.swapTokens(hydroContractInstance, approvedAmount, leftChainId, rightChainId, way, bridgeContractInstance)
return instance.get('performSwapForTransaction', {
params: {
TransactionHash, sourceChainName, destinationChainName
}
})
},
getTotalHydroSwapped(): Promise<GetTotalHydroSwappedResponseType> {
return instance.get('getTotalHydroSwapped')
}
}
type SwappedChainType = {
chainName: string
swappedAmount: string
}
type GetTotalHydroSwappedResponseType = {
data: {
totalValueSwappedOnTestnet: string
totalValueSwappedOnMainnet: string
testnet: Array<SwappedChainType>
mainnet: Array<SwappedChainType>
}
}
type GetTransactionDetailsResponseType = {
data: {
amountDeposited: number,
depositor: string
}
}
type PerformSwapType = {
data: {
explorerLink: string
transactionHash: string
}
}
export type ChainType =
| 'ethereum'
| 'binanceMainnet'
| 'polygonTestnet'
| 'rinkebyTestnet'
| 'coinexTestNetwork'
| 'rinkeby'
| 'moonbeamAlphaTestnet'
| 'moonriverMainnet'
| 'coinex'
type GetHydroBalanceResponseType = {
data: {
tokenBalance: string
}
}
export type TransactionFeeType = {
gasPrice: string
gasRequired: number
hydroTokensToBeReceived: number
priceTimestamp: string
transactionCostInHydro: number
transactionCostinEth: string
}
type GetTransactionFeeType = {
data: TransactionFeeType
}