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

Initialize FxID fields in GetBlock and GetBlockByHeight #1306

Merged
merged 3 commits into from
Apr 7, 2023

Conversation

StephenButtolph
Copy link
Contributor

Why this should be merged

FxIDs are used to specify how to parse a json struct. Currently they are left uninitialized as 11111111111111111111111111111111LpoYY.

How this works

Initializes the FxID fields like we do in in the avm.getTx API for avm.getBlock and avm.getBlockByHeight.

How this was tested

Before:

{
    "jsonrpc": "2.0",
    "result": {
        "block": {
            "parentID": "aku3My3D5NZvsSLhkw1orTEvmCn3GS1nDnFQhivbvfFFUxdLw",
            "height": 5,
            "time": 1680889438,
            "merkleRoot": "11111111111111111111111111111111LpoYY",
            "txs": [
                {
                    "unsignedTx": {
                        "networkID": 12345,
                        "blockchainID": "2eNy1mUFdmaxXNj1eQHUe7Np4gju9sJsEtWQ4MX3ToiNKuADed",
                        "outputs": [
                            {
                                "assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe",
                                "fxID": "11111111111111111111111111111111LpoYY",
                                "output": {
                                    "addresses": [
                                        "X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u"
                                    ],
                                    "amount": 299999999995000000,
                                    "locktime": 0,
                                    "threshold": 1
                                }
                            }
                        ],
                        "inputs": [
                            {
                                "txID": "oW48Xytve3bEfiUGaMLbqfPpxGojfrwvi32SVHqS5cLWJju7R",
                                "outputIndex": 0,
                                "assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe",
                                "fxID": "11111111111111111111111111111111LpoYY",
                                "input": {
                                    "amount": 299999999996000000,
                                    "signatureIndices": [
                                        0
                                    ]
                                }
                            }
                        ],
                        "memo": "0x",
                        "name": "HI",
                        "symbol": "HI",
                        "denomination": 1,
                        "initialStates": [
                            {
                                "fxIndex": 0,
                                "fxID": "11111111111111111111111111111111LpoYY",
                                "outputs": [
                                    {
                                        "addresses": [
                                            "X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u"
                                        ],
                                        "amount": 49463,
                                        "locktime": 0,
                                        "threshold": 1
                                    }
                                ]
                            }
                        ]
                    },
                    "credentials": [
                        {
                            "fxID": "11111111111111111111111111111111LpoYY",
                            "credential": {
                                "signatures": [
                                    "0xcfe2a011413cf60a8d343b4a6ebce55757c2818149550d9118868833d09739170aa91d123de6c658ac679e07bfd67ce2328deb64c8ef8955b9db49e9410c60dd01"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        "encoding": "json"
    },
    "id": 1
}

After:

{
    "jsonrpc": "2.0",
    "result": {
        "block": {
            "parentID": "aku3My3D5NZvsSLhkw1orTEvmCn3GS1nDnFQhivbvfFFUxdLw",
            "height": 5,
            "time": 1680889438,
            "merkleRoot": "11111111111111111111111111111111LpoYY",
            "txs": [
                {
                    "unsignedTx": {
                        "networkID": 12345,
                        "blockchainID": "2eNy1mUFdmaxXNj1eQHUe7Np4gju9sJsEtWQ4MX3ToiNKuADed",
                        "outputs": [
                            {
                                "assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe",
                                "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
                                "output": {
                                    "addresses": [
                                        "X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u"
                                    ],
                                    "amount": 299999999995000000,
                                    "locktime": 0,
                                    "threshold": 1
                                }
                            }
                        ],
                        "inputs": [
                            {
                                "txID": "oW48Xytve3bEfiUGaMLbqfPpxGojfrwvi32SVHqS5cLWJju7R",
                                "outputIndex": 0,
                                "assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe",
                                "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
                                "input": {
                                    "amount": 299999999996000000,
                                    "signatureIndices": [
                                        0
                                    ]
                                }
                            }
                        ],
                        "memo": "0x",
                        "name": "HI",
                        "symbol": "HI",
                        "denomination": 1,
                        "initialStates": [
                            {
                                "fxIndex": 0,
                                "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
                                "outputs": [
                                    {
                                        "addresses": [
                                            "X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u"
                                        ],
                                        "amount": 49463,
                                        "locktime": 0,
                                        "threshold": 1
                                    }
                                ]
                            }
                        ]
                    },
                    "credentials": [
                        {
                            "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
                            "credential": {
                                "signatures": [
                                    "0xcfe2a011413cf60a8d343b4a6ebce55757c2818149550d9118868833d09739170aa91d123de6c658ac679e07bfd67ce2328deb64c8ef8955b9db49e9410c60dd01"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        "encoding": "json"
    },
    "id": 1
}

@StephenButtolph StephenButtolph added bug Something isn't working vm This involves virtual machines labels Apr 7, 2023
@StephenButtolph StephenButtolph added this to the v1.10.0 (Cortina) milestone Apr 7, 2023
@StephenButtolph StephenButtolph self-assigned this Apr 7, 2023
@StephenButtolph StephenButtolph merged commit 1915ce6 into dev Apr 7, 2023
14 checks passed
@StephenButtolph StephenButtolph deleted the initialize-fxids-in-blocks branch April 7, 2023 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vm This involves virtual machines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants