fcl-js icon indicating copy to clipboard operation
fcl-js copied to clipboard

`getBlock` returns BlockObject without `signatures` field ([email protected])

Open bartolomej opened this issue 2 years ago • 2 comments

Problem

The documentation for getBlock() says that it returns BlockObject, which should contain the signatures field:

  • https://developers.flow.com/tools/fcl-js/reference/api#getblock
  • https://developers.flow.com/tools/fcl-js/reference/api#blockobject

This was indeed the case when I used [email protected], but now that I upgraded to the latest fcl-js version I don't see signatures field in the fetched blocks anymore.

The code that I use for fetching blocks:

function getBlockByHeight(height) {
    return fcl
      .send([fcl.getBlock(), fcl.atBlockHeight(height)])
      .then(fcl.decode);
}

Example blocks returned:

{
    id: '13c7ff23bb65feb5757cc65fdd75cd243506518c126385fae530ddebdad10b17',
    parentId: '0000000000000000000000000000000000000000000000000000000000000000',
    height: 0,
    timestamp: '2018-12-19T22:32:30.000000042Z',
    collectionGuarantees: [],
    blockSeals: []
}
{
    id: '60757af0e61c4a27dda37d53cf2aa35fa39b1778e19bb1b1647e87b21ab17801',
    parentId: '13c7ff23bb65feb5757cc65fdd75cd243506518c126385fae530ddebdad10b17',
    height: 1,
    timestamp: '2022-08-13T16:30:18.4232Z',
    collectionGuarantees: [
      {
        collectionId: 'f3083f99b91075eed0ed0ce686355ca3f650cededb7cf8ab5eb3a6d76a4b6645',
        signerIds: undefined
      }
    ],
    blockSeals: []
}

Steps to Reproduce

Fetch block by the provided code above.

Acceptance Criteria

BlockObject should contain signatures field with an array of signatures?

Context

I'm working on upgrading fcl-js lib to the latest version for Flowser tool.

bartolomej avatar Aug 13 '22 16:08 bartolomej

I think I found another issue. According to the docs fcl.getTransaction(id) function should return a TransactionObject value, which includes payloadSignatures and envelopeSignatures, which are both an array of SignableObject values.

According to docs, SignableObject is defined as:

Key Value Type Description
addr Address The address of the authorizer
keyId number The index of the key to use during authorization. (Multiple keys on an account is possible).
signature function A SigningFunction that can produce a valid signature for a user from a message.

But that isn't exactly the case when I try fetching the transaction details with the latest version of fcl-js. See that the envelopeSignatures array contains objects with address property, instead of addr as the documentation suggests.

}
        // ... other attributes
        "referenceBlockId": "13c7ff23bb65feb5757cc65fdd75cd243506518c126385fae530ddebdad10b17",
        "gasLimit": 200,
        "payer": "f8d6e0586b0a20c7",
        "proposalKey": {
            "address": "f8d6e0586b0a20c7",
            "keyId": null,
            "sequenceNumber": 0
        },
        "authorizers": [
            "f8d6e0586b0a20c7"
        ],
        "payloadSignatures": [],
        "envelopeSignatures": [
            {
                "address": "f8d6e0586b0a20c7",
                "keyId": 0,
                "signature": "cSGwNeUZoQMleWLkpwUjR0HYu/wmIQJ0I91mfXk824ZWhmJHIKfRLm8IQDSZ3Q/O87mrYqIm3pqU3lGu8ykJcQ=="
            }
        ]
    }

Not a major issue, but can cause some confusion and bugs in code.

bartolomej avatar Aug 14 '22 10:08 bartolomej

Just a little update: I looked into the signatures field and this was intentionally removed @ 1.0.0 - likely to maintain parity between HTTP and GRPC endpoints. There is an issue open for this in the flow-go repo https://github.com/onflow/flow-go/issues/921.

I'll see if there are any workarounds in the short term but it looks like we might be blocked until the HTTP Access API supports this field.

jribbink avatar Aug 14 '22 16:08 jribbink