wharfkit / signing-request

Library to assist in creating and digesting Signing Requests (ESR)
https://github.com/eosio-eps/EEPs/blob/master/EEPS/eep-7.md
Other
33 stars 20 forks source link

Error: Number 275926164 overflows uint16 #27

Closed reynaldi-lorenzo closed 2 years ago

reynaldi-lorenzo commented 2 years ago

Hello. I just encountered an issue "Error: Number 275926164 overflows uint16" when resolving SigningRequest by calling SigninRequest.resolve(abis, authorization, block). Any idea to solve this issue, or should i "hard coded" it in js file to be Uint32?

aaroncox commented 2 years ago

It sounds like the transaction itself might have some invalid data?

Without knowing more, that's about the best guess I can make.

Do you have some sample code or a signing request string to share that reproduces the problem?

reynaldi-lorenzo commented 2 years ago

Sure. This is the result of decoding QRCode from wax.blocks.io that scanned :

esr:gmPgYmJAAYwMy5pMmF8ZhALZ4bo2Z88yJqw7eTnB9nIJSLZhtdpyVSSB-4UbfA4zLH4oCJLkCHeMANEsyflJiQxM1hklJQXFVvr6yUl6iXnJGflFejmZedn6pqkGBgYWRqa6KcaGSbomiYnmuhZJJga6FuamFolGSYYmKSmWjCwgpScZgaZdYeTJtGFgyg1l3bx6oUz-JjWvHdaqvtom5z2-ttn33U7-enW7XJdm2lxGR7AdPiArjPVM9QwVnIryy4tTi0KKEvOKC_KLSqDCvvlVmTk5ifqmegYKGr6JyZl5JfnFGdYKnnklqTkKQAEF_2CFCAVDg3hD03hzTQXHgoKc1PDUJO_MEn1TY3M9YzMFDW-PEF8fHYWczOxUBffU5Ox8TQXnjKL83FR9QwMLPQMQVAhOTEssyoRqAQA

When i'm not using "resolve" method as in readme.md, issue i got is "Error: Transaction's reference block did not match. Is this transaction from a different fork?", but when i try to resolve, i got overflow error

aaroncox commented 2 years ago

I'm seeing the same thing. It looks like the code in the README file broke at some point, either when the block_num grew to a certain height or maybe some sort of API response changed.

The issue is the 3rd parameter of the resolve() call, where in the example it shows:

// In order to resolve the transaction, we need a recent block
const head = (await rpc.get_info(true)).head_block_num;
const block = await rpc.get_block(head);

// Fetch the ABIs needed for decoding
const abis = await decoded.fetchAbis();

// An authorization to resolve the transaction to
const authorization = {
    actor: 'teamgreymass',
    permission: 'active',
}

// Resolve the transaction as a specific user
const resolved = await decoded.resolve(abis, authorization, block);

The value contained in block is causing the problem. We'll have to investigate and get that fixed.

As an immediate workaround, you can instead use the information from the v1/chain/get_info API call to resolve the transaction. Below is some more modern code that I think should work:

import {APIClient} from '@greymass/eosio'

const client = new APIClient({ url: 'https://jungle3.greymass.com' })
const info = await client.v1.chain.get_info()
const expireSeconds = 120
const header = info.getTransactionHeader(expireSeconds)

// Fetch the ABIs needed for decoding
const abis = await result.request.fetchAbis()

// An authorization to resolve the transaction to
const authorization = {
    actor: 'teamgreymass',
    permission: 'active',
}

// Resolve the transaction as a specific user
const resolved = await result.request.resolve(abis, authorization, header)

This approach resolves the transaction without the need for the v1/chain/get_block API call and achieves the same result.

aaroncox commented 2 years ago

As an update, version 2.5.2 of eosio-signing-request is now published to npm, and resolves this issue. The method as described in the README.md file should work again. Let us know if you have any other issues!