starknet.js icon indicating copy to clipboard operation
starknet.js copied to clipboard

fix: verification signature error with new braavos account

Open PhilippeR26 opened this issue 1 year ago • 1 comments

Motivation and Resolution

Solve issue #987 . Accounts have now 2 possible names of message verification function. So it's necessary to search this name in the Abi prior of message verification.

Usage related changes

No change

Development related changes

A special attention has been taken to minimize the interactions with the node to get the Abi. At first use of an account instance, Starknet.js is asking the sierra file to the node, to find in the Abi the cairo version. Now, at the same time, the code try to find the name of the verification function. If it's an account behind a proxy, the request to the node of the implementation class Abi is performed only if the account.verifyMessage() is called.

  • getContractVersion() is now also trying to get the verification function name ; so, it has been renamed getContractSpecificities().
  • ContractVersion type has been renamed ContractSpecificities has the function name has been included.
  • add property signatureVerifFunctionName in Account.

Checklist:

  • [x] Performed a self-review of the code
  • [x] Rebased to the last commit of the target branch (or merged it into my branch)
  • [x] Linked the issues which this PR resolves
  • [x] Documented the changes in code (API docs will be generated automatically)
  • [x] Updated the tests
  • [x] All tests are passing

PhilippeR26 avatar Mar 01 '24 11:03 PhilippeR26

Some tests have been performed (with success) with various types of accounts, outside of the test suite : Capture d’écran du 2024-03-01 10-42-00

PhilippeR26 avatar Mar 01 '24 11:03 PhilippeR26

Name of variable modified.

PhilippeR26 avatar Mar 19 '24 08:03 PhilippeR26

This can be a temporal hotfix, but it should be resolved on SNIP-6 as a Proposed update.

tabaktoni avatar Mar 27 '24 07:03 tabaktoni

All done.

PhilippeR26 avatar Mar 27 '24 08:03 PhilippeR26

With an account that has been instantiated with CairoVersion as parameter, the signatureVerifFunctionName is never defined. So, I have added just this code : https://github.com/starknet-io/starknet.js/pull/989/commits/9c2726105955e26f60d036a7c1bf85932d0d64df A consequence is that this test is now failing at line 649 : https://github.com/starknet-io/starknet.js/blob/a85d48ee73acb1365da6bef3f9d3a65153f9a422/tests/account.test.ts#L641-L679

LibraryError: RPC: starknet_getClassAt with params {
      "block_id": "pending",
      "contract_address": "0x311c7b427829ff25aac8a7a3f1332f4baef1c5d3069d5eca5808a905910a9ad"
    }
     
            20: Contract not found: undefined

In the JSdoc, it's written that for estimateFeeBulk, the account has to be deployed : https://github.com/starknet-io/starknet.js/blob/a85d48ee73acb1365da6bef3f9d3a65153f9a422/src/account/interface.ts#L148 But the test is trying to use account.estimateFeeBulk() with a non deployed account. So, either the JSDoc of account.estimateFeeBulk() is wrong, or its test should use a deployed account. But there is an error somewhere.

What do you think is wrong?

PhilippeR26 avatar Apr 16 '24 08:04 PhilippeR26

Closing in favor of PR https://github.com/starknet-io/starknet.js/pull/989 based on this branch

tabaktoni avatar May 16 '24 08:05 tabaktoni