Skip to content

Unity3dAPI: added receipt search#666

Closed
noescape00 wants to merge 2 commits intostratisproject:masterfrom
noescape00:unity_SCReceipt
Closed

Unity3dAPI: added receipt search#666
noescape00 wants to merge 2 commits intostratisproject:masterfrom
noescape00:unity_SCReceipt

Conversation

@noescape00
Copy link
Contributor

Pretty straight forward, it just calls receipt search from SC controller

[HttpGet]
public async Task<List<ReceiptResponse>> ReceiptSearchAPI([FromQuery] string contractAddress, [FromQuery] string eventName, [FromQuery] List<string> topics = null, [FromQuery] int fromBlock = 0, [FromQuery] int? toBlock = null)
{
List<ReceiptResponse> result = this.smartContractsController.ReceiptSearch(contractAddress, eventName, topics, fromBlock, toBlock);
Copy link
Contributor

@fassadlr fassadlr Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ivan,

It seems that the logic in SmartContractsController.ReceiptSearch is now shared between 2 controllers. There is already a smartContractTransactionService in this controller, so move the logic in SmartContractsController.ReceiptSearch there and then just call smartContractTransactionService.ReceipSearch from here (also just update SmartContractsController to do the same).

😎

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the logic in SmartContractsController.ReceiptSearch is now shared between 2 controllers.
Logic was just in SC controller and unity controller called it (same was done with other methods as well)

But anyway, changes applied

Copy link
Contributor

@fassadlr fassadlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know its a bit more code bit this looks a lot cleaner now ;) I was worried also that some person randomly moves or even remove the sc controller and then your code breaks.

}

IEnumerable<byte[]> topicsBytes = topics != null ? topics.Where(topic => topic != null).Select(t => t.HexToByteArray()) : new List<byte[]>();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra newline

Comment on lines +520 to +521
/// Therefore, it is possible to return a smart contract's transaction receipts
/// which match a specific event (as defined by the struct name).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps put all of this on one line.

@quantumagi
Copy link
Contributor

Fix the tests.

@noescape00
Copy link
Contributor Author

Closing this one and moving it to #712

@noescape00 noescape00 closed this Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants