Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Missing runtime APIs for Metadata v15 #2204

Merged
merged 11 commits into from
Oct 30, 2024
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Closes <!-- issue # -->

# Checklist
- [ ] Updated Pallet Readme?
- [ ] Updated js/api-augment for Custom RPC OR Runtime API?
- [ ] Updated js/api-augment for Custom RPC APIs?
- [ ] Design doc(s) updated?
- [ ] Unit Tests added?
- [ ] e2e Tests added?
Expand Down
5 changes: 4 additions & 1 deletion e2e/capacity/capacity_rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ describe('Capacity RPC', function () {
// Actual weights and fee
const {
weight: { refTime, proofSize },
} = await ExtrinsicHelper.apiPromise.call.transactionPaymentApi.queryInfo(call.toHex(), 0);
} = await ExtrinsicHelper.apiPromise.call.transactionPaymentApi.queryInfo(call.toU8a(), call.length);
// Why does it need to be call.toU8a() above instead of just call or call.toHex()?
// https://github.com/polkadot-js/apps/issues/10994

const weightFee = await ExtrinsicHelper.apiPromise.call.transactionPaymentApi.queryWeightToFee({
refTime,
proofSize,
Expand Down
704 changes: 351 additions & 353 deletions e2e/package-lock.json

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"@frequency-chain/api-augment": "file:../js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz",
"@helia/unixfs": "^4.0.0",
"@noble/curves": "^1.6.0",
"@polkadot-api/merkleize-metadata": "^1.1.7",
"@polkadot/api": "14.1.1",
"@polkadot/types": "14.1.1",
"@polkadot/util": "13.2.1",
"helia": "^5.0.1",
"multiformats": "^13.3.0",
"@polkadot-api/merkleize-metadata": "^1.1.9",
"@polkadot/api": "14.2.1",
"@polkadot/types": "14.2.1",
"@polkadot/util": "13.2.2",
"helia": "^5.1.0",
"multiformats": "^13.3.1",
"rxjs": "^7.8.1",
"workerpool": "^9.2.0"
},
Expand All @@ -37,12 +37,11 @@
"eslint": "^9.13.0",
"eslint-plugin-mocha": "^10.5.0",
"globals": "^15.11.0",
"mocha": "^10.7.3",
"node-datachannel": "^0.12.0",
"mocha": "^10.8.1",
"prettier": "^3.3.3",
"sinon": "^19.0.2",
"tsx": "^4.19.1",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.10.0"
"typescript-eslint": "^8.12.2"
}
}
17 changes: 3 additions & 14 deletions js/api-augment/definitions/frequency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,8 @@ export default {
event: 'u8',
data: 'Vec<u8>',
},
},
runtime: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Runtime types are part of the generation now

AdditionalRuntimeApi: [
{
methods: {
get_events: {
description: 'Get the events with simple SCALE decoding',
params: [],
type: 'Vec<RpcEvent>',
},
},
version: 1,
},
],
// Part of the auraApi that is missing the type.
// Unsure why, but can safely be here.
SpConsensusSlotsSlotDuration: 'u64',
},
};
23 changes: 0 additions & 23 deletions js/api-augment/definitions/frequencyTxPayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,4 @@ export default {
},
},
types: {},
runtime: {
CapacityTransactionPaymentRuntimeApi: [
{
methods: {
compute_capacity_fee: {
description: 'Compute the capacity fee for a given transaction',
params: [
{
name: 'encoded_xt',
type: 'Vec<u8>',
},
{
name: 'at',
type: 'Option<BlockHash>',
},
],
type: 'FeeDetails',
},
},
version: 1,
},
],
},
};
53 changes: 0 additions & 53 deletions js/api-augment/definitions/handles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,57 +57,4 @@ export default {
base_handle: 'String',
},
},
runtime: {
HandlesRuntimeApi: [
{
methods: {
get_handle_for_msa: {
description: 'Get handle for a given msa_id',
params: [
{
name: 'msa_id',
type: 'MessageSourceId',
},
],
type: 'Option<HandleResponse>',
},
get_msa_for_handle: {
description: 'Get msa_id for a given handle',
params: [
{
name: 'display_handle',
type: 'Vec<u8>',
},
],
type: 'Option<MessageSourceId>',
},
get_next_suffixes: {
description: 'Get next suffixes for a given handle and count',
params: [
{
name: 'base_handle',
type: 'Vec<u8>',
},
{
name: 'count',
type: 'u16',
},
],
type: 'PresumptiveSuffixesResponse',
},
validate_handle: {
description: 'Check whether the supplied handle passes all the checks performed by claim_handle call.',
params: [
{
name: 'base_handle',
type: 'String',
},
],
type: 'bool',
},
},
version: 2,
},
],
},
};
37 changes: 0 additions & 37 deletions js/api-augment/definitions/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,4 @@ export default {
next_index: 'Option<u32>',
},
},
runtime: {
MessagesRuntimeApi: [
{
methods: {
get_messages_by_schema_and_block: {
description: 'Retrieve the messages for a particular schema and block number',
params: [
{
name: 'schema_id',
type: 'SchemaId',
},
{
name: 'schema_payload_location',
type: 'PayloadLocation',
},
{
name: 'block_number',
type: 'BlockNumber',
},
],
type: 'Vec<MessageResponse>',
},
get_schema_by_id: {
description: 'Retrieve a schema by id',
params: [
{
name: 'schema_id',
type: 'SchemaId',
},
],
type: 'Option<SchemaResponse>',
},
},
version: 1,
},
],
},
};
61 changes: 4 additions & 57 deletions js/api-augment/definitions/msa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,62 +73,9 @@ export default {
provider_id: 'ProviderId',
permissions: 'Vec<SchemaGrantResponse>',
},
},
runtime: {
MsaRuntimeApi: [
{
methods: {
has_delegation: {
description:
'Check to see if a delegation existed between the given delegator and provider at a given block',
params: [
{
name: 'delegator_id',
type: 'DelegatorId',
},
{
name: 'provider_id',
type: 'ProviderId',
},
{
name: 'block_number',
type: 'BlockNumber',
},
{
name: 'schema_id',
type: 'Option<SchemaId>',
},
],
type: 'bool',
},
get_granted_schemas_by_msa_id: {
description:
'Get the list of schema ids (if any) that exist in any delegation between the delegator and provider',
params: [
{
name: 'delegator_id',
type: 'DelegatorId',
},
{
name: 'provider_id',
type: 'ProviderId',
},
],
type: 'Option<Vec<SchemaGrantResponse>>',
},
get_all_granted_delegations_by_msa_id: {
description: 'Get the list of all delegated providers with schema permission grants',
params: [
{
name: 'delegator_msa_id',
type: 'DelegatorId',
},
],
type: 'Vec<DelegationResponse>',
},
},
version: 2,
},
],
// Runtime types
// Not sure why these have to be noted here, but they do
CommonPrimitivesMsaDelegatorId: 'u64',
CommonPrimitivesMsaProviderId: 'u64',
},
};
29 changes: 0 additions & 29 deletions js/api-augment/definitions/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,4 @@ export default {
schema_id: 'SchemaId',
},
},
runtime: {
SchemasRuntimeApi: [
{
methods: {
get_by_schema_id: {
description: 'Fetch the schema by id',
params: [
{
name: 'schema_id',
type: 'SchemaId',
},
],
type: 'Option<SchemaResponse>',
},
get_schema_versions_by_name: {
description: 'Fetch the schema versions by name',
params: [
{
name: 'schema_name',
type: 'Vec<u8>',
},
],
type: 'Option<Vec<SchemaVersionResponse>>',
},
},
version: 2,
},
],
},
};
37 changes: 0 additions & 37 deletions js/api-augment/definitions/statefulStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,4 @@ export default {
items: 'Vec<ItemizedStorageResponse>',
},
},
runtime: {
StatefulStorageRuntimeApi: [
{
methods: {
get_paginated_storage: {
description: 'Fetch the stateful paginated storage by msa_id and schema_id',
params: [
{
name: 'msa_id',
type: 'MessageSourceId',
},
{
name: 'schema_id',
type: 'SchemaId',
},
],
type: 'Result<Vec<PaginatedStorageResponse>, SpRuntimeDispatchError>',
},
get_itemized_storage: {
description: 'Fetch the stateful itemized storage by msa_id and schema_id',
params: [
{
name: 'msa_id',
type: 'MessageSourceId',
},
{
name: 'schema_id',
type: 'SchemaId',
},
],
type: 'Result<ItemizedStoragePageResponse, SpRuntimeDispatchError>',
},
},
version: 1,
},
],
},
};
11 changes: 0 additions & 11 deletions js/api-augment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ export const signedExtensions: ExtDef = {
},
};

/**
* Build up all the Runtime Api Calls
*/
export const runtime = Object.entries(definitions).reduce((acc, [key, value]) => {
return {
...acc,
...value.runtime,
};
}, {});

/**
* Export for easy use with Polkadot API's ApiPromise
*
Expand All @@ -78,5 +68,4 @@ export const options = {
rpc,
types,
signedExtensions,
runtime,
};
Loading
Loading