Skip to content

Commit a4dd69a

Browse files
authored
Merge pull request #270 from gz-c/switch-txns
Switch from /explorer/address to /transactions
2 parents 95e047e + 7769af1 commit a4dd69a

File tree

4 files changed

+6
-68
lines changed

4 files changed

+6
-68
lines changed

explorer.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -244,68 +244,6 @@ var apiEndpoints = []APIEndpoint{
244244
ExampleRequest: "/api/coinmarketcap",
245245
ExampleResponse: "7187500.000000",
246246
},
247-
{
248-
ExplorerPath: "/api/address",
249-
SkycoinPath: "/explorer/address",
250-
QueryArgs: []string{"address"},
251-
Description: "Returns address info.",
252-
ExampleRequest: "/api/address?address=SeDoYN6SNaTiAZFHwArnFwQmcyz7ZvJm17",
253-
ExampleResponse: `[
254-
{
255-
"status": {
256-
"confirmed": true,
257-
"unconfirmed": false,
258-
"height": 10161,
259-
"block_seq": 1893,
260-
"unknown": false
261-
},
262-
"length": 414,
263-
"type": 0,
264-
"txid": "c297eb14a9e68ec5501aa886e5bb720a58fe6466be633a8264f61eee9580a2c3",
265-
"inner_hash": "5fcc1649794894f2c79411a832f799ba12e0528ff530d7068abaa03c10e451cf",
266-
"timestamp": 1499405825,
267-
"sigs": [
268-
"b951fd0c1528df88c87eb90cb1ecbc3ba2b6332ace16c2f1cc731976c0cebfb10ecb1c20335374f8cf0b832364a523c3e16f32c3240ed4eccfac1803caf8815100",
269-
"6a06e57d130f6e780eecbe0c2626eed7724a2443438258598af287bf8fc1b87f041d04a7082550bd2055a08f0849419200fdac27c018d5cebf84e8bba1c4f61201",
270-
"8cc9ae6ae5be81456fc8e2d54b6868c45b415556c689c8c4329cd30b671a18254885a1aef8a3ac9ab76a8dc83e08607516fdef291a003935ae4507775ae53c7800"
271-
],
272-
"inputs": [
273-
{
274-
"uxid": "0922a7b41d1b76b6b56bfad0d5d0f6845517bbd895c660eab0ebe3899b5f63c4",
275-
"owner": "2Q2VViWhgBzz6c8GkXQyDVFdQUWcBcDon4L",
276-
"coins": "7.000000",
277-
"hours": "851106"
278-
},
279-
{
280-
"uxid": "d73cf1f1d04a1d493fe3480a00e48187f9201bb64828fe0c638f17c0c88bb3d9",
281-
"owner": "YPhukwVyLsPGX1FAPQa2ktr5XnSLqyGbr5",
282-
"coins": "5.000000",
283-
"hours": "6402335"
284-
},
285-
{
286-
"uxid": "16dd81af869743599fe60108c22d7ee1fcbf1a7f460fffd3a015fbb3f721c36d",
287-
"owner": "YPhukwVyLsPGX1FAPQa2ktr5XnSLqyGbr5",
288-
"coins": "2400.000000",
289-
"hours": "800291"
290-
}
291-
],
292-
"outputs": [
293-
{
294-
"uxid": "8a941208d3f2d2c4a32438e05645fb64dba3b4b7d83c48d52f51bc1eb9a4117a",
295-
"dst": "2GgFvqoyk9RjwVzj8tqfcXVXB4orBwoc9qv",
296-
"coins": "2361.000000",
297-
"hours": 1006716
298-
},
299-
{
300-
"uxid": "a70d1f0f488066a327acd0d5ea77b87d62b3b061d3db8361c90194a6520ab29f",
301-
"dst": "SeDoYN6SNaTiAZFHwArnFwQmcyz7ZvJm17",
302-
"coins": "51.000000",
303-
"hours": 2013433
304-
}
305-
]
306-
}
307-
]`,
308-
},
309247

310248
{
311249
ExplorerPath: "/api/blockchain/metadata",

src/app/app.datatypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ export class GetTransactionResponse {
229229
txn: GenericTransactionResponse;
230230
}
231231

232-
export function parseGetTransaction(raw: GetTransactionResponse): Transaction {
232+
export function parseGetTransaction(raw: GetTransactionResponse, address: string = null): Transaction {
233233
raw.txn.status = raw.status;
234-
return parseGenericTransaction(raw.txn);
234+
return parseGenericTransaction(raw.txn, address);
235235
}
236236

237237
export class GetUxoutResponse {

src/app/services/api/api.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export class ApiService {
1616
private http: HttpClient
1717
) { }
1818

19-
getAddress(address: string): Observable<GenericTransactionResponse[]> {
20-
return this.get('address', { address: address });
19+
getAddress(address: string): Observable<GetTransactionResponse[]> {
20+
return this.get('transactions', { addrs: address, verbose: 1 });
2121
}
2222

2323
getUnconfirmedTransactions(): Observable<GetUnconfirmedTransactionResponse[]> {

src/app/services/explorer/explorer.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export class ExplorerService {
3131
getTransactions(address: string): Observable<Transaction[]> {
3232
return this.api.getAddress(address)
3333
.map(response => {
34-
response = response.sort((a, b) => a.timestamp - b.timestamp);
34+
response = response.sort((a, b) => a.txn.timestamp - b.txn.timestamp);
3535

3636
let currentBalance = new BigNumber('0');
3737
return response.map(rawTx => {
38-
const parsedTx = parseGenericTransaction(rawTx, address);
38+
const parsedTx = parseGetTransaction(rawTx, address);
3939
parsedTx.initialBalance = currentBalance;
4040
currentBalance = currentBalance.plus(parsedTx.balance);
4141
parsedTx.finalBalance = currentBalance;

0 commit comments

Comments
 (0)