AcalaNetwork / acala-types.js

Apache License 2.0
0 stars 0 forks source link

use `typesBundle` for api options #54

Closed shunjizhan closed 9 months ago

shunjizhan commented 9 months ago

Context

Our api initialization has some issue that it is not able to decode some old blocks. https://github.com/AcalaNetwork/bodhi.js/issues/920

There seems to be some mysterious bug(feature?) that if we pass both typesBundle and types as apiOptions, it will fail to decode some certain old blocks.

Change

To fix the issue and to be more concise, this PR puts everything needed into typesBundle, and pass it as the only param to api to avoid conflict.

we keep options for backward compatibility, but now we can also initialize api like this

const api = await new ApiPromise({
  typesBundle: acalaTypesBundle,
  provider,
}

Test

tested with bodhi CI, and everything still works. Decoding old blocks also works now. https://github.com/AcalaNetwork/bodhi.js/pull/931

Question

we don't use lookupTypes and derivedTypes anymore, what are they, and do we still need them? If we do, should we include them into the bundle, or pass as apiOption?