AvaProtocol / oak.js

Javascript dev-utils library to access OAK Network APIs, leveraging typing decoration of polkadot.js library.
Apache License 2.0
2 stars 0 forks source link

The Weight type in getXcmWeight is not printable #73

Open chrisli30 opened 12 months ago

chrisli30 commented 12 months ago

The type of the output of getXcmWeight() seems to be the same as those from paymentInfo(), but the console.log behavior is different from the original. They can’t be printed with variableName.toJSON(). We need to stick with the original Weight type definition as much as possible. Maybe the output needs to be defined as type WeightV2 in polkadot.js?

Code Reference: https://github.com/OAK-Foundation/oak.js/blob/764b69ebdc1e82e6c3a8c5f2f3e3c5b1dccfaae1/packages/adapter/src/chains/astar.ts#L56C5-L56C10

Expected

The weight type should be printable with a toJSON() method

const taskPayloadExtrinsic = astarApi.tx.proxy.proxy(keyringPair.addressRaw, 'Any', payload);
const { weight: encodedCallWeight } = await taskPayloadExtrinsic.paymentInfo(keyringPair.address);
console.log('encodedCallWeight.toJSON()', encodedCallWeight.toJSON());

> encodedCallWeight.toJSON() { refTime: 5367272555, proofSize: 58115 }

Actual

const { encodedCallWeight, overallWeight } = await astarAdapter.getXcmWeight(taskPayloadExtrinsic, keyringPair.address, oakTransactXcmInstructionCount);
console.log('encodedCallWeight.toJSON()', encodedCallWeight.toJSON());

> TypeError: encodedCallWeight.toJSON is not a function
chrisli30 commented 9 months ago

@imstar15 did we fix this issue?

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.