-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New TVM features #41
Open
Rovak
wants to merge
22
commits into
develop
Choose a base branch
from
develop-tvm
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
New TVM features #41
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
87863a2
add tvm contracts
Rovak d96d666
cleanup
Rovak e31a266
add GetBlockByLimitNext
Rovak 144ad8b
cleanup
Rovak d92a795
add vote round import
Rovak e277f8b
add allowance
Rovak 806b3e9
add new tvm grpc functions
Rovak d5bc8c9
add documentation for transaction builder
Rovak de5568a
add round vote api
Rovak 66f937c
add api documentation
Rovak 920ed02
cleanup
Rovak cfac5df
Merge branch 'develop' into develop-tvm
Rovak 1896e59
remove test url
Rovak 657a8b8
add http port scanner
Rovak 6eff589
check node type instead of handling exception
Rovak 4c2fe9c
add UpdateAsset contract to transaction builder
Rovak 6b9644f
cats
Rovak af80a22
fix decoder
Rovak ed221e2
add token filter
Rovak ed0f5d4
fix import
Rovak 57e7b7b
update schema
Rovak 5c5c77b
update protobuf
Rovak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ import scala.async.Async._ | |
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.Future | ||
import scala.concurrent.duration._ | ||
import org.tronscan.Extensions._ | ||
|
||
@Api( | ||
value = "Accounts", | ||
|
@@ -55,6 +56,10 @@ class AccountApi @Inject()( | |
|
||
val key = configurationProvider.get.get[String]("play.http.secret.key") | ||
|
||
/** | ||
* Query accounts | ||
* @return | ||
*/ | ||
@ApiResponses(Array( | ||
new ApiResponse( | ||
code = 200, | ||
|
@@ -112,6 +117,9 @@ class AccountApi @Inject()( | |
} | ||
} | ||
|
||
/** | ||
* Find account by the given address | ||
*/ | ||
@ApiOperation( | ||
value = "Find account by address", | ||
response = classOf[AccountModel]) | ||
|
@@ -149,7 +157,7 @@ class AccountApi @Inject()( | |
"allowance" -> account.allowance, | ||
"url" -> witness.map(_.url), | ||
), | ||
"name" -> new String(account.accountName.toByteArray).toString, | ||
"name" -> account.accountName.decodeString, | ||
"address" -> address, | ||
"bandwidth" -> Json.obj( | ||
"freeNetUsed" -> accountBandwidth.freeNetUsed, | ||
|
@@ -166,6 +174,7 @@ class AccountApi @Inject()( | |
), | ||
"balances" -> Json.toJson(balances), | ||
"balance" -> account.balance, | ||
"allowance" -> account.allowance, | ||
"tokenBalances" -> Json.toJson(balances), | ||
"frozen" -> Json.obj( | ||
"total" -> account.frozen.map(_.frozenBalance).sum, | ||
|
@@ -180,6 +189,9 @@ class AccountApi @Inject()( | |
} | ||
} | ||
|
||
/** | ||
* Retrieves the balances for the given address | ||
*/ | ||
@ApiOperation( | ||
value = "", | ||
hidden = true | ||
|
@@ -218,6 +230,9 @@ class AccountApi @Inject()( | |
} | ||
} | ||
|
||
/** | ||
* Votes cast by the given address | ||
*/ | ||
@ApiOperation( | ||
value = "", | ||
hidden = true | ||
|
@@ -226,7 +241,7 @@ class AccountApi @Inject()( | |
for { | ||
wallet <- walletClient.full | ||
account <- wallet.getAccount(Account( | ||
address = ByteString.copyFrom(Base58.decode58Check(address)) | ||
address = address.decodeAddress, | ||
)) | ||
} yield { | ||
|
||
|
@@ -248,6 +263,11 @@ class AccountApi @Inject()( | |
} | ||
} | ||
|
||
/** | ||
* Retrieve the Super Representative github link | ||
* @param address address of the SR | ||
* @return | ||
*/ | ||
@ApiOperation( | ||
value = "", | ||
hidden = true | ||
|
@@ -267,6 +287,9 @@ class AccountApi @Inject()( | |
} | ||
} | ||
|
||
/** | ||
* Update the super representative pages | ||
*/ | ||
@ApiOperation( | ||
value = "", | ||
hidden = true) | ||
|
@@ -308,70 +331,9 @@ class AccountApi @Inject()( | |
} | ||
} | ||
|
||
@ApiOperation( | ||
value = "", | ||
hidden = true | ||
) | ||
def resync = Action.async { req => | ||
|
||
throw new Exception("DISABLED") | ||
|
||
val decider: Supervision.Decider = { | ||
case exc => | ||
println("SOLIDITY STREAM ERROR", exc, ExceptionUtils.getStackTrace(exc)) | ||
Supervision.Resume | ||
} | ||
|
||
implicit val materializer = ActorMaterializer( | ||
ActorMaterializerSettings(system) | ||
.withSupervisionStrategy(decider))(system) | ||
|
||
async { | ||
|
||
val accounts = await(repo.findAll).toList | ||
|
||
val source = Source(accounts) | ||
.mapAsync(8) { existingAccount => | ||
async { | ||
|
||
val walletSolidity = await(walletClient.full) | ||
|
||
val account = await(walletSolidity.getAccount(Account( | ||
address = ByteString.copyFrom(Base58.decode58Check(existingAccount.address)) | ||
))) | ||
|
||
if (account != null) { | ||
|
||
val accountModel = AccountModel( | ||
address = existingAccount.address, | ||
name = new String(account.accountName.toByteArray), | ||
balance = account.balance, | ||
power = account.frozen.map(_.frozenBalance).sum, | ||
tokenBalances = Json.toJson(account.asset), | ||
dateUpdated = DateTime.now, | ||
) | ||
|
||
List(repo.buildInsertOrUpdate(accountModel)) ++ addressBalanceModelRepository.buildUpdateBalance(accountModel) | ||
} else { | ||
List.empty | ||
} | ||
|
||
} | ||
} | ||
.flatMapConcat(queries => Source(queries)) | ||
.groupedWithin(150, 10.seconds) | ||
.mapAsync(1) { queries => | ||
blockModelRepository.executeQueries(queries) | ||
} | ||
.toMat(Sink.ignore)(Keep.right) | ||
.run | ||
|
||
await(source) | ||
|
||
Ok("Done") | ||
} | ||
} | ||
|
||
/** | ||
* Synchronises the given account to the database | ||
*/ | ||
@ApiOperation( | ||
value = "", | ||
hidden = true) | ||
|
@@ -484,7 +446,8 @@ class AccountApi @Inject()( | |
} | ||
|
||
/** | ||
* Generates a new private key | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cube now nephew path grocery observe |
||
* Generates a new account with private key | ||
* | ||
* @return | ||
*/ | ||
def create = Action { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://tronscan.org/#/transaction/74570e0210f96443143c57506c3a5db139334d15183bd501b06395c3ea16d50c?lang=en