Skip to content
Prev Previous commit
api.tx.contracts.call.meta no version field, _isOldWeight still work?
  • Loading branch information
jasl committed Nov 11, 2022
commit bcddda6548be74b038c36db8af234639b0ebcecc
5 changes: 3 additions & 2 deletions packages/api-contract/src/base/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
origin,
this.address,
value,
this.api.tx.contracts.call.meta.version === 1
? this.#getGas(gasLimit, true).v1Weight
this._isOldWeight
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not remove the old getGas here. It would still be applicable.

Rather when we detect v2 runtime (or rather v1 runtime) we swap to pushing through the old weight, not the option. So the existing will stay as-is for v1, but for v2 we will do the v2 weight thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I don't understand your means, do you mean I need to revert this part change?

Copy link
Member

@jacogr jacogr Nov 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It should rather be adapted to al check for the new stuff. You can do this by detecting which version is used, i.e something like -

...
value,
this.api.tx.contracts.call.meta.version === 1
  ? this.#getGas(gasLimit, true).v1Weight
  : this.#getGas(gasLimit, true).v2Weight
...

This is important since the getGas also allows the developer to pass a number - since we don't like breaking compat, we have not changed the signatures. And we have to ensure that the behviour on anything old stays exactly the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as your suggest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages/api-contract/src/base/Contract.ts:144:43 - error TS2339: Property 'version' does not exist on type 'FunctionMetadataLatest'.

144           this.api.tx.contracts.call.meta.version === 1

I'll dig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems FunctionMetadataLatest doesn't have version field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacogr I still don't got this one

// jiggle v1 weights, metadata points to latest
? this.#getGas(gasLimit, true).v1Weight as unknown as WeightAll['v2Weight']
: this.#getGas(gasLimit, true).v2Weight,
storageDepositLimit,
message.toU8a(params)
Expand Down