fuel-connectors
fuel-connectors copied to clipboard
Add version for predicate based connectors
We need to ensure users will retain access to funds if the predicate bytecode is updated on connectors that include a predicate.
For this one solution, the idea is to;
- Save all predicate codes generated into a folder inside the connectors folder. Ex.
versions/<bytecode_hash>/{.bin,,abi.json}
- Create an entry map file, for example.
const VERSIONS = {
<bytecode_hash_v0>: { abi, bin },
<bytecode_hash_v1>: { abi, bin }
}
- Once the user connects an account to the connector, we fetch the transaction history (last: 1) of all the user addresses for each bytecode version. If the address had a tx, we select that predicate bytecode as the current version of the user bytecode and stop the search.
We should also consider a way for the connector to receive the bytecode_hash / version in the moment of instantiation in case the user wants to use another version.