Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TSA1
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hernan Hegykozi
TSA1
Commits
ea3f5eb6
Commit
ea3f5eb6
authored
3 years ago
by
Hernan Hegykozi
Browse files
Options
Downloads
Patches
Plain Diff
Se agregan endpoint de balance, block y tx
parent
3b1809c1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/bfacontroller.js
+68
-2
68 additions, 2 deletions
api/bfacontroller.js
api/routes.js
+12
-0
12 additions, 0 deletions
api/routes.js
with
80 additions
and
2 deletions
api/bfacontroller.js
+
68
−
2
View file @
ea3f5eb6
...
...
@@ -161,9 +161,75 @@ verify : async function (req, res){
});
}
}
}
},
balance
:
async
function
(
req
,
res
){
const
now
=
new
Date
();
try
{
const
account
=
req
.
query
.
account
||
config
.
account
.
address
;
console
.
log
(
"
[
"
+
utils
.
dateFormat
(
now
,
"
%d/%m/%Y %H:%M:%S
"
,
false
)
+
"
] : balance : (
"
+
account
+
"
)
"
);
var
bal
=
await
web3
.
eth
.
getBalance
(
account
);
var
eth
=
web3
.
utils
.
fromWei
(
bal
,
"
ether
"
)
+
"
ETH
"
;
return
res
.
json
({
account
:
account
,
balanceETH
:
eth
,
balanceWEI
:
bal
});
}
catch
(
err
){
console
.
log
(
"
[
"
+
utils
.
dateFormat
(
now
,
"
%d/%m/%Y %H:%M:%S
"
,
false
)
+
"
] : ERROR balance :
"
,
err
);
return
res
.
status
(
500
).
json
({
messages
:
"
No se pudo realizar la operacion
"
,
status
:
"
failure
"
});
}
},
block
:
async
function
(
req
,
res
){
const
now
=
new
Date
();
try
{
const
block_number
=
req
.
query
.
number
;
console
.
log
(
"
[
"
+
utils
.
dateFormat
(
now
,
"
%d/%m/%Y %H:%M:%S
"
,
false
)
+
"
] : block : (
"
+
block_number
+
"
)
"
);
const
block
=
await
web3
.
eth
.
getBlock
(
block_number
);
return
res
.
json
(
block
);
}
catch
(
err
){
console
.
log
(
"
[
"
+
utils
.
dateFormat
(
now
,
"
%d/%m/%Y %H:%M:%S
"
,
false
)
+
"
] : ERROR block :
"
,
err
);
return
res
.
status
(
500
).
json
({
messages
:
"
No se pudo realizar la operacion
"
,
status
:
"
failure
"
});
}
}
,
tx
:
async
function
(
req
,
res
){
const
now
=
new
Date
();
try
{
const
tx_hash
=
req
.
query
.
hash
;
console
.
log
(
"
[
"
+
utils
.
dateFormat
(
now
,
"
%d/%m/%Y %H:%M:%S
"
,
false
)
+
"
] : tx : (
"
+
tx_hash
+
"
)
"
);
var
tx
=
await
web3
.
eth
.
getTransaction
(
tx_hash
);
return
res
.
json
(
tx
);
}
catch
(
err
){
console
.
log
(
"
[
"
+
utils
.
dateFormat
(
now
,
"
%d/%m/%Y %H:%M:%S
"
,
false
)
+
"
] : ERROR tx :
"
,
err
);
return
res
.
status
(
500
).
json
({
messages
:
"
No se pudo realizar la operacion
"
,
status
:
"
failure
"
});
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/routes.js
+
12
−
0
View file @
ea3f5eb6
...
...
@@ -12,6 +12,18 @@ router.get('/address', (req, res) => {
res
.
send
(
config
.
account
.
address
);
})
router
.
get
(
'
/balance
'
,
async
(
req
,
res
)
=>
{
await
BfaController
.
balance
(
req
,
res
);
})
router
.
get
(
'
/block
'
,
async
(
req
,
res
)
=>
{
await
BfaController
.
block
(
req
,
res
);
})
router
.
get
(
'
/tx
'
,
async
(
req
,
res
)
=>
{
await
BfaController
.
tx
(
req
,
res
);
})
router
.
post
(
'
/stamp
'
,
async
(
req
,
res
)
=>
{
await
BfaController
.
stamp
(
req
,
res
);
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment