-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrong signature index at
EVMWalletConnector
(#112)
Co-authored-by: LuizAsFight <felipebolsonigomes@gmail.com>
- Loading branch information
1 parent
204bf27
commit a87a9a4
Showing
5 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@fuel-connectors/evm-connector": patch | ||
--- | ||
|
||
fix: wrong signature index at `EVMWalletConnector` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { BytesLike } from 'fuels'; | ||
|
||
/** | ||
* Since the predicate resources were fetched and added to the TransactionRequest before the predicate | ||
* was instantiated, it is very likely that they were fetched and added as normal account resources, | ||
* resulting in a witness placeholder being added to the witnesses of the TransactionRequest to | ||
* later be replaced with an actual signature. Since predicate resources do not require a signature, | ||
* this placeholder witness will be removed when calling `Predicate.populateTransactionPredicateData`. | ||
* However, we need to validate if this placeholder witness was added here in order to instantiate the | ||
* predicate with the correct witness index argument. | ||
*/ | ||
export const getSignatureIndex = (witnesses: BytesLike[]) => { | ||
const hasPlaceholderWitness = witnesses.some( | ||
(item) => | ||
item instanceof Uint8Array && | ||
item.length === 64 && | ||
item.every((value) => value === 0), | ||
); | ||
|
||
// if it is a placeholder witness, we can safely replace it, otherwise we will consider a new element. | ||
return hasPlaceholderWitness ? witnesses.length - 1 : witnesses.length; | ||
}; |