forked from anyswap/CrossChain-Router
-
Notifications
You must be signed in to change notification settings - Fork 8
/
apitests.html
151 lines (151 loc) · 5.64 KB
/
apitests.html
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<style type="text/css">
DIV {
margin: 10px;
padding: 10px;
border: 2px solid #cccccc;
}
INPUT[type="text"] {
width: 50%;
}
SPAN {
display: none;
}
</style>
<script type="text/javascript">
$(document).ready(() => {
const apiUrl = $('#api_url')
const prepareFormUrl = (e) => {
e.preventDefault()
const $form = $($(e.target).parents('FORM')[0])
const urlTemplate = $($form.find('[data-type="url-template"]')[0]).val()
const urlParts = $form.find('[type="text"]')
let formUrl = urlTemplate
urlParts.each((i, part) => {
const name = $(part).data('name')
const value = $(part).val()
formUrl = formUrl.replace('{'+name+'}', value)
})
$form.attr('action', apiUrl.val() + formUrl)
$form.append($('#api_result_holder'))
$form[0].submit()
}
$('INPUT[data-type="send-form"]').bind('click', prepareFormUrl)
})
</script>
</head>
<body>
<div>
<strong>Api url (without last "/"):</strong>
<input type="text" value="http://localhost:11556" id="api_url" />
</div>
<h2>Bridge api - start,status,history</h2>
<div>
<strong>(POST) /swap/register/{chainid}/{txid}</strong>
<form method="post" action="#" target="api_result">
<input type="hidden" data-type="url-template" value="/swap/register/{chainid}/{txid}" />
<div>
<label>chainid:</label>
<input type="text" data-name="chainid" value="97" />
</div>
<div>
<label>txid:</label>
<input type="text" data-name="txid" value="0xa2a2c0ec4e7291669be1172148cf694f2a65ba3244b2f771b229a209369c857d" />
<span>tx id on source chain (97) of anySwapOutUnderlying method</span>
</div>
<input type="submit" value="send" data-type="send-form" />
</form>
</div>
<div>
<strong>(GET) /swap/status/{chainid}/{txid}</strong>
<form method="get" action="#" target="api_result">
<input type="hidden" data-type="url-template" value="/swap/status/{chainid}/{txid}" />
<div>
<label>chainid:</label>
<input type="text" data-name="chainid" value="97" />
</div>
<div>
<label>txid:</label>
<input type="text" data-name="txid" value="0xa2a2c0ec4e7291669be1172148cf694f2a65ba3244b2f771b229a209369c857d" />
<span>tx id on source chain (97) of anySwapOutUnderlying method</span>
</div>
<input type="submit" value="send" data-type="send-form" />
</form>
</div>
<h2>Chain and tokens info</h2>
<div>
<strong>(GET) /allchainids</strong>
<form method="get" action="#" target="api_result">
<input type="hidden" data-type="url-template" value="/allchainids" />
<input type="submit" value="send" data-type="send-form" />
</form>
</div>
<div>
<strong>(GET) /alltokenids</strong>
<form method="get" action="#" target="api_result">
<input type="hidden" data-type="url-template" value="/alltokenids" />
<input type="submit" value="send" data-type="send-form" />
</form>
</div>
<div>
<strong>(GET) /allmultichaintokens/{tokenid}</strong>
<form method="get" action="#" target="api_result">
<input type="hidden" data-type="url-template" value="/allmultichaintokens/{tokenid}" />
<div>
<label>tokenid:</label>
<input type="text" data-name="tokenid" value="TETHER" />
</div>
<input type="submit" value="send" data-type="send-form" />
</form>
</div>
<div>
<strong>(GET) /chainconfig/{chainid}</strong>
<form method="get" action="#" target="api_result">
<input type="hidden" data-type="url-template" value="/chainconfig/{chainid}" />
<div>
<label>chainid:</label>
<input type="text" data-name="chainid" value="97" />
</div>
<input type="submit" value="send" data-type="send-form" />
</form>
</div>
<div>
<strong>(GET) /tokenconfig/{chainid}/{address}</strong>
<form method="get" action="#" target="api_result">
<input type="hidden" data-type="url-template" value="/tokenconfig/{chainid}/{address}" />
<div>
<label>chainid:</label>
<input type="text" data-name="chainid" value="97" />
</div>
<div>
<label>address:</label>
<input type="text" data-name="address" value="0xc0c3394781c23faa538a506b3c96fb59c050bed8" />
</div>
<input type="submit" value="send" data-type="send-form" />
</form>
</div>
<div>
<strong>(GET) /swapconfig/{tokenid}/{chainid}</strong>
<form method="get" action="#" target="api_result">
<input type="hidden" data-type="url-template" value="/swapconfig/{tokenid}/{chainid}" />
<div>
<label>tokenid:</label>
<input type="text" data-name="tokenid" value="TETHER" />
</div>
<div>
<label>chainid:</label>
<input type="text" data-name="chainid" value="97" />
</div>
<input type="submit" value="send" data-type="send-form" />
</form>
</div>
<div style="display: none">
<div id="api_result_holder">
<h3>Api answer result</h3>
<iframe src="about:block" id="api_result" name="api_result" width="100%" height="200px"></iframe>
</div>
</div>
</body>
</html>