Skip to content
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

Fix wallet history receive sub-query #644

Merged
merged 19 commits into from
Aug 5, 2021

Conversation

quantumagi
Copy link
Contributor

@quantumagi quantumagi commented Jul 27, 2021

@quantumagi quantumagi requested a review from fassadlr July 28, 2021 07:25
@fassadlr
Copy link
Contributor

fassadlr commented Aug 3, 2021

Normal wallet testing passed:

1. Receive funds with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
	- Check Wallet History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
		- Should contain Receive of 999
	- Check Smart Contract History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
		- Should be empty
		
2. Build normal send tx with smartcontracs/buildtx - 50CRS pass sender address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
	- Check Wallet History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
		- Should contain Receive of 999
		- Should contain Send of 50 plus fee of 0.0001
	- Check Smart Contract History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
		- Should be empty
		
3. Build normal send tx with smartcontracs/buildtx - 500CRS pass sender address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
	- Check Wallet History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
		- Should contain Receive of 999
		- Should contain Send of 50 plus fee of 0.0001
		- Should contain Send of 500 plus fee of 0.0001
	- Check Smart Contract History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
		- Should be empty
		
4. Receive funds with address tUyDcZ6ZiG525KxHxMvY6RTjfrDJd8P1X6
	- Check Wallet History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
		- Should contain Receive of 1000
		- Should contain Send of 50 plus fee of 0.0001
		- Should contain Send of 500 plus fee of 0.0001
	- Check Smart Contract History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
		- Should be empty
	- Check Wallet History with address tUyDcZ6ZiG525KxHxMvY6RTjfrDJd8P1X6
		- Should contain Receive of 999
	- Check Smart Contract History with address tUyDcZ6ZiG525KxHxMvY6RTjfrDJd8P1X6
		- Should be empty
		
5. Build normal send tx with smartcontracs/buildtx - 50CRS pass sender address tUyDcZ6ZiG525KxHxMvY6RTjfrDJd8P1X6
	- Check Wallet History with address tUyDcZ6ZiG525KxHxMvY6RTjfrDJd8P1X6
		- Should contain Receive of 999
		- Should contain Send of 50 plus fee of 0.0001
	- Check Smart Contract History with address tUyDcZ6ZiG525KxHxMvY6RTjfrDJd8P1X6
		- Should be empty

@fassadlr
Copy link
Contributor

fassadlr commented Aug 3, 2021

Tested Smart Contract execution:

  1. Create Auction smart contract with sender tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV

    • Check Wallet History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
      • Wallet history returns "Staked" transactions with 0 amount and "Send" tx which I assume is the fee and for executing the call/create.
    • Check Smart Contract History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
      • Should contain 1 Create (type 4) tx
  2. Wait for Auction to expire and Call contract with sender tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV TWICE

    • Check Wallet History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
      • Wallet history returns "Staked" transactions with 0 amount and "Send" tx which I assume is the fee apd for executing the call/create.
    • Check Smart Contract History with address tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV
      • Should contain 1 Create (type 4) txs
      • Should contain 2 Call (type 4) txs

@fassadlr
Copy link
Contributor

fassadlr commented Aug 3, 2021

See output below from calling wallet/history with Address = tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV:

"history": [
    {
      "accountName": "account 0",
      "accountHdPath": "m/44'/400'/0'",
      "coinType": 400,
      "transactionsHistory": [
        {
          "type": "staked",
          "toAddress": "tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV",
          "id": "b6aacfd49d6a4566622d224024c5a0fe1070d8c1ee10a5df9c2ac9c6facb1440",
          "amount": 0,
          "confirmedInBlock": 2429259,
          "timestamp": "1627991712",
          "txOutputTime": 1627991712,
          "txOutputIndex": 0
        },
        {
          "type": "send",
          "toAddress": "7CDCB98AD68A828EAE1FBCEAA18B007B057506F0",
          "id": "11842b38f4895575caffdc41b2bf612cd3fafb9731098b07ac752306c74a3859",
          "amount": 125010000,
          "payments": [],
          "fee": 125010000,
          "confirmedInBlock": 2429259,
          "timestamp": "1627991712",
          "txOutputTime": 1627991712,
          "txOutputIndex": 0
        },
        {
          "type": "staked",
          "toAddress": "tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV",
          "id": "380b084dc30ee5f947c06abe0cea72a4056390a1064ffbffe26f4d3047460946",
          "amount": 0,
          "confirmedInBlock": 2429255,
          "timestamp": "1627991616",
          "txOutputTime": 1627991616,
          "txOutputIndex": 0
        },
        {
          "type": "send",
          "toAddress": "7CDCB98AD68A828EAE1FBCEAA18B007B057506F0",
          "id": "be3eee675307ba217096c27efbc3f8e98134516e4307ff02c0bf6ef1f33f984b",
          "amount": 250010000,
          "payments": [],
          "fee": 250010000,
          "confirmedInBlock": 2429255,
          "timestamp": "1627991616",
          "txOutputTime": 1627991616,
          "txOutputIndex": 0
        },
        {
          "type": "staked",
          "toAddress": "tNrxdbtrVWGqZkKGtZnyuPuP2t3BbfqAuV",
          "id": "47ad5048091ac2136ab3e476ba6edcab20ab7ea91ba3ddcf89eb063e0bbc122b",
          "amount": 0,
          "confirmedInBlock": 2429224,
          "timestamp": "1627990928",
          "txOutputTime": 1627990928,
          "txOutputIndex": 0
        },
        {
          "type": "send",
          "toAddress": "0000000000000000000000000000000000000000",
          "id": "d6d7ac6c1013a8b7fd7a975240f870f343ec7048f1bfe1dea1bc2adddca9a3c5",
          "amount": 2500100000,
          "payments": [],
          "fee": 2500100000,
          "confirmedInBlock": 2429224,
          "timestamp": "1627990928",
          "txOutputTime": 1627990928,
          "txOutputIndex": 0
        },

@quantumagi
Copy link
Contributor Author

quantumagi commented Aug 4, 2021

Should contain 1 Create (type 4) tx

We shouldn't need type 4 as it is legacy behaviour for the SendToScriptPubKey to determine whether its create/call when using the SC history call, UNLESS of course we want to specifically prevent these from appearing as type 1.

                    if (scTransaction.SendToScriptPubKey.IsSmartContractCreate())
                    {
                        result.Type = ContractTransactionItemType.ContractCreate;
                        result.To = receipt?.NewContractAddress?.ToBase58Address(this.network) ?? string.Empty;
                    }
                    else if (scTransaction.SendToScriptPubKey.IsSmartContractCall())
                    {
                        result.Type = ContractTransactionItemType.ContractCall;
                        result.To = txData.ContractAddress.ToBase58Address(this.network);
                    }

image

I assume the wallet UI would have been showing "create" / "call" for these SC transactions.

@fassadlr
Copy link
Contributor

fassadlr commented Aug 4, 2021

I have now tested all the scenarios and they work. STRAX is unaffected.

@fassadlr fassadlr merged commit f234120 into stratisproject:master Aug 5, 2021
fassadlr pushed a commit that referenced this pull request Aug 5, 2021
* Fix history receive sub-query

* Fix formatting

* Refactor

* Fix null handling

* Add Type 4

* CreateOrCall code updates

* Only non-coinbase rows for Cirrus

* Fix Group By

* Fix Group By

* Add SUM on non-groupby `Value` field

* Revert Group By fixes for now

* Undo AddressType change

* Undo SUM

* Undo change

* Undo change

* Undo change

* Undo changes

* Fix formatting

* Fix Cirrus network detection
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.

None yet

2 participants