starknet.js
starknet.js copied to clipboard
fix: verification signature error with new braavos account
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 renamedgetContractSpecificities().ContractVersiontype has been renamedContractSpecificitieshas the function name has been included.- add property
signatureVerifFunctionNamein 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
Some tests have been performed (with success) with various types of accounts, outside of the test suite :
Name of variable modified.
This can be a temporal hotfix, but it should be resolved on SNIP-6 as a Proposed update.
All done.
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?
Closing in favor of PR https://github.com/starknet-io/starknet.js/pull/989 based on this branch