jr: showing balance works
This commit is contained in:
+22
-4
@@ -311,6 +311,23 @@ pi_repop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//async function
|
||||||
|
//mk_spend
|
||||||
|
// (source : string,
|
||||||
|
// recipient : string,
|
||||||
|
// amount : number)
|
||||||
|
//{
|
||||||
|
// let nonce: number = await get_nonce(source);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//async function
|
||||||
|
//get_nonce
|
||||||
|
// (source: string)
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get account balance of ak_... str
|
* get account balance of ak_... str
|
||||||
*/
|
*/
|
||||||
@@ -318,12 +335,12 @@ async function
|
|||||||
pi_balance
|
pi_balance
|
||||||
(akstr : string)
|
(akstr : string)
|
||||||
: Promise< {ok : true,
|
: Promise< {ok : true,
|
||||||
balance : number}
|
balance : string}
|
||||||
| {ok : false,
|
| {ok : false,
|
||||||
reason : string}
|
reason : string}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
let endpoint_init_url = 'https://demonet.qpq.swiss/v2/';
|
let endpoint_init_url = 'https://demonet.qpq.swiss/v2';
|
||||||
let this_endpoint = endpoint_init_url + '/accounts/' + akstr;
|
let this_endpoint = endpoint_init_url + '/accounts/' + akstr;
|
||||||
let input_params = {pubkey: akstr};
|
let input_params = {pubkey: akstr};
|
||||||
// fetch: https://developer.mozilla.org/en-US/docs/Web/API/fetch
|
// fetch: https://developer.mozilla.org/en-US/docs/Web/API/fetch
|
||||||
@@ -334,10 +351,11 @@ pi_balance
|
|||||||
switch (response.status) {
|
switch (response.status) {
|
||||||
case 200:
|
case 200:
|
||||||
// unstringify the body
|
// unstringify the body
|
||||||
let return_data = response.json();
|
let return_data = await response.json();
|
||||||
|
console.log('return data', return_data);
|
||||||
// get the balance
|
// get the balance
|
||||||
// @ts-ignore talking to foreign api
|
// @ts-ignore talking to foreign api
|
||||||
let balance = return_data.balance;
|
let balance = return_data.balance.toString();
|
||||||
return {ok : true,
|
return {ok : true,
|
||||||
balance : balance};
|
balance : balance};
|
||||||
// pubkey malformed
|
// pubkey malformed
|
||||||
|
|||||||
Reference in New Issue
Block a user