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

Ergo connector: Large (>Number.MAX_SAFE_INTEGER) quantities in txs render them unsignable. #2209

Closed
deadit opened this issue Jul 3, 2021 · 15 comments · Fixed by #2232
Closed
Assignees
Labels
Milestone

Comments

@deadit
Copy link
Contributor

deadit commented Jul 3, 2021

Hey guys. I want to use sign_tx method for send 2 tokens in one TX. After I enter the spending password, nothing happens. Promise just has 'pending' state.

Screenshot 2021-07-03 at 16 49 39

If I reject this TX, I can catch 'reject' state.

  1. State after opened yoroi-dapp-connector window.
    image
  2. State after close yoroi-dapp-connector window.
    image
  1. State after opened yoroi-dapp-connector window.
    image
  2. State after entered and confirmed spending password.
    image
    image
@deadit
Copy link
Contributor Author

deadit commented Jul 3, 2021

@rooooooooob please, take a look

@oskin1
Copy link
Contributor

oskin1 commented Jul 5, 2021

@rooooooooob , @vantuz-subhuman
It seems Yoroi is incapable of handling transactions sending more that one token at once.

@vsubhuman vsubhuman added this to the 4.6.0 milestone Jul 5, 2021
@vsubhuman vsubhuman added the ergo label Jul 5, 2021
@rooooooooob
Copy link
Contributor

@deadit

I tried reproducing this and I have a tx that involves 2 tokens in one TX and it went through without a hitch. The two tokens were in separate inputs but went to a single output so that might be related. here it is on the explorer with tokens c804ec8f26627b004b11cf7387b6823893737ce682ebd70a7da902e95f49a4ae and 388b27170916e3565d0bf5de584534e0fc0c2c76fb3fe2e7945ddabd3aef7778.

Are you able to run into this issue with any other txs? What about one with just 2 tokens instead of 10? If you still do, can you check the page logs in your dApp for the RPC logging and tell me the parameters passed to the tx send endpoint?

connector received from page:
{"type":"connector_rpc_request","uid":4,"function":"submit_tx","params":[ /* here is the info that is relevant */]}

Does this happen in the Yoroi nightly or in which version? What happens if you inspect the popup window's logs for tx signing. does anything occur there (or in the extension's background page) once you enter the spending password?

@oskin1
Copy link
Contributor

oskin1 commented Jul 6, 2021

@deadit

I tried reproducing this and I have a tx that involves 2 tokens in one TX and it went through without a hitch. The two tokens were in separate inputs but went to a single output so that might be related. here it is on the explorer with tokens c804ec8f26627b004b11cf7387b6823893737ce682ebd70a7da902e95f49a4ae and 388b27170916e3565d0bf5de584534e0fc0c2c76fb3fe2e7945ddabd3aef7778.

Are you able to run into this issue with any other txs? What about one with just 2 tokens instead of 10? If you still do, can you check the page logs in your dApp for the RPC logging and tell me the parameters passed to the tx send endpoint?

connector received from page:
{"type":"connector_rpc_request","uid":4,"function":"submit_tx","params":[ /* here is the info that is relevant */]}

Does this happen in the Yoroi nightly or in which version? What happens if you inspect the popup window's logs for tx signing. does anything occur there (or in the extension's background page) once you enter the spending password?

@rooooooooob , here is the UnsignedTracnsaction causing the issue:

{
    "inputs": [
        {
            "boxId": "1d9ddad4bc48cd15f44a794f5f5430bb938e467e03c03f6dfa931e9067e11797",
            "value": 1000000000,
            "ergoTree": "0008cd0377ba17fa49c6b02d7b83452aad9db99ae5859ea84d25a1c002f956e8720deb48",
            "assets": [],
            "creationHeight": 504154,
            "additionalRegisters": {},
            "transactionId": "9f594a6327eff11dc1db97c8de2d5230281994e4fb2521fc5673ebcb5a868bfe",
            "index": 0,
            "extension": {}
        },
        {
            "boxId": "e75cf651aaec6c32ba1a1bca0d588af281ce941f332db940380064ad5b86819f",
            "value": 10000000,
            "ergoTree": "0008cd0377ba17fa49c6b02d7b83452aad9db99ae5859ea84d25a1c002f956e8720deb48",
            "assets": [
                {
                    "amount": 500000,
                    "tokenId": "231f4e245473c21777186ce97acd8279aa7c9fa3f3418504525a4a86478ac6f5"
                }
            ],
            "creationHeight": 504155,
            "additionalRegisters": {},
            "transactionId": "7ffbcb53ecdbeffc5c6a19c70c672fc300de3ce43bada5be9ab0de1a0d1af049",
            "index": 0,
            "extension": {}
        },
        {
            "boxId": "8692517cf16e918804970aca411582730311f3bf2386d3a2a5955c2e89903093",
            "value": 10000000,
            "ergoTree": "0008cd0377ba17fa49c6b02d7b83452aad9db99ae5859ea84d25a1c002f956e8720deb48",
            "assets": [
                {
                    "amount": 500,
                    "tokenId": "003bd19d0187117f130b62e1bcab0939929ff5c7709f843c5c4dd158949285d0"
                }
            ],
            "creationHeight": 504159,
            "additionalRegisters": {},
            "transactionId": "d2b1dc127bdc81a37b3bed455ed59b6740091d6b6c076fd72f1406a39c518602",
            "index": 0,
            "extension": {}
        },
        {
            "boxId": "aea26c45de82101f60e8d42f50bfff50430c67595bb851e982a8a18d9dadc0e1",
            "value": 10000000,
            "ergoTree": "0008cd03d4dc25841a62e6f54749bf4e98638d67d13edce35830eab85b6211b82d409ea9",
            "assets": [
                {
                    "amount": 46999999970,
                    "tokenId": "f45c4f0d95ce1c64defa607d94717a9a30c00fdd44827504be20db19f4dce36f"
                }
            ],
            "creationHeight": 522921,
            "additionalRegisters": {},
            "transactionId": "fc9a9cee7605f59d2ec467e1bd7da5e49c2dd83ee64fe81f5a1d4466fe56ad39",
            "index": 0,
            "extension": {}
        },
        {
            "boxId": "90c39a8566433bfc01e8aec0009eb71f614403d42b765bc32aa3a60df558a393",
            "value": 10000000,
            "ergoTree": "0008cd03d4dc25841a62e6f54749bf4e98638d67d13edce35830eab85b6211b82d409ea9",
            "assets": [
                {
                    "amount": 9987000000000000,
                    "tokenId": "f302c6c042ada3566df8e67069f8ac76d10ce15889535141593c168f3c59e776"
                }
            ],
            "creationHeight": 523830,
            "additionalRegisters": {},
            "transactionId": "2daeeaba003242bdef18c85b7a59dc646f25ff30417b35ed546b3f88783363e0",
            "index": 0,
            "extension": {}
        },
        {
            "boxId": "5bc792c42fd9621334e1796ce974b87efda2b061615921d01b3e5a9246e6ac32",
            "value": 10000000,
            "ergoTree": "0008cd03d4dc25841a62e6f54749bf4e98638d67d13edce35830eab85b6211b82d409ea9",
            "assets": [
                {
                    "amount": 1365544144,
                    "tokenId": "7f14228a5fd5b5c5d74bfbced3491916e2dc305106dd043f78b65b4cced9c2b9"
                }
            ],
            "creationHeight": 523830,
            "additionalRegisters": {},
            "transactionId": "b993e5871bcb7672ce669f5174bbd864eb90d0b5bf8fea587a017b1c4518f7ed",
            "index": 0,
            "extension": {}
        }
    ],
    "dataInputs": [],
    "outputs": [
        {
            "value": 10000000,
            "ergoTree": "1986020d08cd0377ba17fa49c6b02d7b83452aad9db99ae5859ea84d25a1c002f956e8720deb48040004020400040205feffffffffffffffff01040404000e2051ee3a4e30d0e763d3f1759be12239b1ff163068a5eae699d2e667f9effb348d05020580dac40904000402d808d6017300d602db6308b2a4730100d603b2a5730200d604b2db63087203730300d605b27202730400d606db6308a7d6077e9973058c72050206d6087e8cb272027306000206eb027201d1ed93b27202730700860273087309ededed93c27203d0720192c1720399c1a7730a938c7204018c720501927e8c72040206a19d9c7e8cb27206730b000206720772089d9c7e8cb27206730c00020672077208",
            "creationHeight": 506880,
            "assets": [
                {
                    "tokenId": "f45c4f0d95ce1c64defa607d94717a9a30c00fdd44827504be20db19f4dce36f",
                    "amount": 1
                },
                {
                    "tokenId": "f302c6c042ada3566df8e67069f8ac76d10ce15889535141593c168f3c59e776",
                    "amount": 124
                }
            ],
            "additionalRegisters": {}
        },
        {
            "value": 1030000000,
            "ergoTree": "0008cd0377ba17fa49c6b02d7b83452aad9db99ae5859ea84d25a1c002f956e8720deb48",
            "creationHeight": 506880,
            "assets": [
                {
                    "tokenId": "231f4e245473c21777186ce97acd8279aa7c9fa3f3418504525a4a86478ac6f5",
                    "amount": 500000
                },
                {
                    "tokenId": "003bd19d0187117f130b62e1bcab0939929ff5c7709f843c5c4dd158949285d0",
                    "amount": 500
                },
                {
                    "tokenId": "f45c4f0d95ce1c64defa607d94717a9a30c00fdd44827504be20db19f4dce36f",
                    "amount": 46999999969
                },
                {
                    "tokenId": "f302c6c042ada3566df8e67069f8ac76d10ce15889535141593c168f3c59e776",
                    "amount": 9986999999999876
                },
                {
                    "tokenId": "7f14228a5fd5b5c5d74bfbced3491916e2dc305106dd043f78b65b4cced9c2b9",
                    "amount": 1365544144
                }
            ],
            "additionalRegisters": {}
        },
        {
            "value": 10000000,
            "ergoTree": "1005040004000e36100204a00b08cd0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ea02d192a39a8cc7a701730073011001020402d19683030193a38cc7b2a57300000193c2b2a57301007473027303830108cdeeac93b1a57304",
            "creationHeight": 506880,
            "assets": [],
            "additionalRegisters": {}
        }
    ]
}

@deadit deadit closed this as completed Jul 6, 2021
@deadit deadit reopened this Jul 6, 2021
@deadit
Copy link
Contributor Author

deadit commented Jul 6, 2021

@deadit

I tried reproducing this and I have a tx that involves 2 tokens in one TX and it went through without a hitch. The two tokens were in separate inputs but went to a single output so that might be related. here it is on the explorer with tokens c804ec8f26627b004b11cf7387b6823893737ce682ebd70a7da902e95f49a4ae and 388b27170916e3565d0bf5de584534e0fc0c2c76fb3fe2e7945ddabd3aef7778.

Are you able to run into this issue with any other txs? What about one with just 2 tokens instead of 10? If you still do, can you check the page logs in your dApp for the RPC logging and tell me the parameters passed to the tx send endpoint?

connector received from page:
{"type":"connector_rpc_request","uid":4,"function":"submit_tx","params":[ /* here is the info that is relevant */]}

Does this happen in the Yoroi nightly or in which version? What happens if you inspect the popup window's logs for tx signing. does anything occur there (or in the extension's background page) once you enter the spending password?

Yoroi nightly dapp - 0.4.0
Yoroi nightly - 4.5.5001

@deadit
Copy link
Contributor Author

deadit commented Jul 6, 2021

Hey, I think I found how to test extensions!
Here is the error after input the spending password. Maybe it is on our side problem, will take a look with @oskin1!

image

@rooooooooob
Copy link
Contributor

That error originates inside of Yoroi's code. I think we might be able to remove this now though? I vaguely recall seeing the JSON type updated at some point. When I first wrote this code the JSON I saw supported had a type of only number but it might be number | string now. Due to this we had a function for converting the string -> numbers so that we could parse it via sigma-rust's JSON.

@rooooooooob rooooooooob changed the title Nothing happens when send 2 tokens in one TX. Ergo connector: Large (>Number.MAX_SAFE_INTEGER) quantities in txs render them unsignable. Jul 6, 2021
@oskin1
Copy link
Contributor

oskin1 commented Jul 6, 2021

That error originates inside of Yoroi's code. I think we might be able to remove this now though? I vaguely recall seeing the JSON type updated at some point. When I first wrote this code the JSON I saw supported had a type of only number but it might be number | string now. Due to this we had a function for converting the string -> numbers so that we could parse it via sigma-rust's JSON.

@rooooooooob, why not switching to BigInt instead of number | string ? It's more convenient to work with.

@rooooooooob
Copy link
Contributor

Internally we use it for calculations, but for the JSON passing to/from the dApp we have it as number | string. However, the sigma-rust json parsing expects (or was expecting at the time of writing) only number which is why we had that conversion + error.

@rooooooooob
Copy link
Contributor

It looks like the types for sigma-rust's JSON parsing is now number | string as well. I'll try just removing the check/conversion then and we'll see what happens.

@oskin1
Copy link
Contributor

oskin1 commented Jul 6, 2021

It looks like the types for sigma-rust's JSON parsing is now number | string as well. I'll try just removing the check/conversion then and we'll see what happens.

This problematic UnsignedTracnsaction JSON I've provided above is decoded smoothly by ergo-wasm. So this should work.

@rooooooooob
Copy link
Contributor

Sorry for the delay in getting this fix in. I had the actual fix ready last week since it wasn't anything big, but then I ran into a bunch of issues testing it that were unrelated to this issue. The PR is up now to fix this though #2232

@deadit
Copy link
Contributor Author

deadit commented Jul 15, 2021

@rooooooooob when you release new version? I still have this problem on latest versions

@vsubhuman
Copy link
Contributor

@deadit , the new version is expected probably around the beginning of the next week. Let me now create a new nightly which includes the fix and notify you here, when it's available.

@vsubhuman
Copy link
Contributor

@deadit , nightly version 4.5.7003 is available now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants