pendulum-chain / pendulum

GNU General Public License v3.0
43 stars 14 forks source link

249 extract chain extension implementation and re use it in all runtimes #437

Closed gianfra-t closed 3 months ago

gianfra-t commented 3 months ago

Closes #249.

The objective of this PR is not to modify the functionality of the chain extensions, but just to separate them to their own modules, which can later be reused by the runtimes.

We add three new modules shared by the runtimes containing the logic of the chain extensions. One for tokens related functions, one for price and one common to both.

The latter mostly contains mappings of errors. Although some of these mappings belong to a specific chain extension and would better be located in the respective module, it is difficult to separate this definitions and avoid cyclic references.

For each runtime, we only need to define an id for each extension and declare a tuple for the ChainExtension type in pallet contracts.

Since we implement the RegisteredChainExtension trait linked above, a tuple of can be defined given the implementation for tuples defined here.

TorstenStueber commented 3 months ago

Thanks @gianfra-t for this PR. Looks to me like the file runtime/common/src/chain_ext.rs can be removed now but it has not been as part of this PR.

gianfra-t commented 3 months ago

Yes you are right it should have been removed. I will add these changes to the next upcoming PR and reference this one.