difftreelog
feat avoid changing name of primary version
in: master
7 files changed
crates/struct-versioning/src/lib.rsdiffbeforeafterboth1use proc_macro::TokenStream;2use quote::format_ident;3use syn::{4 parse::{Parse, ParseStream},5 Token, LitInt, parse_macro_input, ItemStruct, Error, Fields, Result, Field, Expr,6 parenthesized,7};8use quote::quote;910mod kw {11 syn::custom_keyword!(version);12 syn::custom_keyword!(first_version);13 syn::custom_keyword!(versions);14 syn::custom_keyword!(upper);15}1617struct VersionedAttrs {18 current_version: u32,19 first_version: u32,20 upper: bool,21}2223/// #[versioned(version = 2)]24impl Parse for VersionedAttrs {25 fn parse(input: ParseStream) -> Result<Self> {26 let mut current_version = None::<u32>;27 let mut first_version = None::<u32>;28 let mut upper = false;2930 loop {31 if input.is_empty() {32 break;33 }34 let lookahead = input.lookahead1();35 if lookahead.peek(kw::version) {36 input.parse::<kw::version>()?;37 input.parse::<Token![=]>()?;38 let t = input.parse::<LitInt>()?;39 if current_version.is_some() {40 return Err(Error::new_spanned(t, "version is already set"));41 }42 current_version = Some(t.base10_parse()?)43 } else if lookahead.peek(kw::first_version) {44 input.parse::<kw::first_version>()?;45 input.parse::<Token![=]>()?;46 let t = input.parse::<LitInt>()?;47 if first_version.is_some() {48 return Err(Error::new_spanned(t, "first version is already set"));49 }50 first_version = Some(t.base10_parse()?)51 } else if lookahead.peek(kw::upper) {52 input.parse::<kw::upper>()?;53 upper = true;54 } else {55 return Err(lookahead.error());56 }5758 if input.is_empty() {59 break;60 } else if input.peek(Token![,]) {61 input.parse::<Token![,]>()?;62 continue;63 } else {64 return Err(input.error("unexpected token"));65 }66 }67 let first_version = first_version.unwrap_or(1);68 let current_version = current_version.unwrap_or(first_version);6970 if current_version == 0 || first_version == 0 || first_version > current_version {71 return Err(Error::new(input.span(), "1 <= first_version <= version"));72 }7374 Ok(Self {75 current_version,76 first_version,77 upper,78 })79 }80}8182/// #[version(..3)] - field vas removed in version 3 (i.e it was exist on version 2, but doesn't on version 3)83/// #[version(3..)] - field has appeared in version 384/// #[version(2..4)] - field was on versions 2, 385/// #[version(1..2, upper(old_field + 1))] - when updating struct from old version to new - calculate new field value from passed expression86struct VersionAttr {87 since: u32,88 before: Option<u32>,8990 upper: Option<Expr>,91}92impl VersionAttr {93 fn exists_on(&self, version: u32) -> bool {94 version >= self.since && self.before.map_or(true, |before| version < before)95 }96}97impl Parse for VersionAttr {98 fn parse(input: ParseStream) -> Result<Self> {99 let mut since = None::<u32>;100 let mut before = None::<u32>;101 let lookahead = input.lookahead1();102103 if lookahead.peek(LitInt) {104 let t: LitInt = input.parse()?;105 since = Some(t.base10_parse()?);106 } else if !lookahead.peek(Token![..]) {107 return Err(lookahead.error());108 }109 let range = input.parse::<Token![..]>()?;110 let lookahead = input.lookahead1();111 if lookahead.peek(LitInt) {112 let t: LitInt = input.parse()?;113 before = Some(t.base10_parse()?);114 } else if !input.is_empty() && !lookahead.peek(Token![,]) {115 return Err(lookahead.error());116 }117118 let upper = if input.peek(Token![,]) {119 input.parse::<Token![,]>()?;120 input.parse::<kw::upper>()?;121 let expr;122 parenthesized!(expr in input);123124 Some(Expr::parse(&expr)?)125 } else {126 None127 };128129 if since.is_none() && before.is_none() {130 return Err(Error::new_spanned(131 range,132 "noop range, remove this version attribute",133 ));134 }135 Ok(Self {136 since: since.unwrap_or(1),137 before,138 upper,139 })140 }141}142impl Default for VersionAttr {143 fn default() -> Self {144 Self {145 since: 1,146 before: None,147 upper: None,148 }149 }150}151152/// Generate versioned variants of a struct153///154/// `#[versioned(version = 1[, first_version = 1][, upper][, versions])]`155/// - *version* - current version of a struct156/// - *first_version* - allows to skip generation of structs, which predates first supported version157/// - *upper* - generate From impls, which converts old version of structs to new158/// - *versions* - generate enum, which contains all possible versions of struct159///160/// Each field may have version attribute161/// `#[version([1]..[2][, upper(old)])]`162/// - *1* - version, on which this field is appeared163/// - *2* - version, in which this field was removed164/// (i.e if set to 2, this field was exist on version 1, and no longer exist on version 2)165/// - *upper* - code, which should be executed to transform old value to new/create new value166#[proc_macro_attribute]167pub fn versioned(attr: TokenStream, input: TokenStream) -> TokenStream {168 let attr = parse_macro_input!(attr as VersionedAttrs);169 let input = parse_macro_input!(input as ItemStruct);170171 let fields = match input.fields {172 Fields::Named(named) => named.named,173 _ => {174 return Error::new_spanned(input, "expected named fields")175 .into_compile_error()176 .into()177 }178 };179 let fields = fields180 .iter()181 .map(|field| {182 let version_attr = match field.attrs.iter().find(|a| a.path.is_ident("version")) {183 Some(v) => v.parse_args::<VersionAttr>()?,184 None => return Ok((VersionAttr::default(), field.clone())),185 };186 let mut field = field.clone();187 field.attrs.retain(|a| !a.path.is_ident("version"));188 Ok((version_attr, field))189 })190 .collect::<Result<Vec<(VersionAttr, Field)>>>();191 let fields = match fields {192 Ok(f) => f,193 Err(e) => return e.into_compile_error().into(),194 };195196 let attrs = input.attrs;197 let vis = input.vis;198 let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();199 let mut out = Vec::new();200 for version in attr.first_version..=attr.current_version {201 let name = format_ident!("{}Version{}", &input.ident, version);202 let current_fields = fields203 .iter()204 .filter_map(|(ver, field)| ver.exists_on(version).then(|| field));205206 let mut doc = Vec::new();207 if version > attr.first_version {208 doc.push(" # Versioning".into());209 doc.push(format!(" Changes between {} and {}:", version - 1, version));210 for (ver, field) in fields.iter() {211 match (ver.exists_on(version - 1), ver.exists_on(version)) {212 (true, false) => {213 let ty = &field.ty;214 doc.push(format!(215 " - {}: {} was removed",216 field.ident.as_ref().unwrap(),217 quote! {#ty}218 ))219 }220 (false, true) => {221 let ty = &field.ty;222 doc.push(format!(223 " - [`{}`]: {} was added",224 field.ident.as_ref().unwrap(),225 quote! {#ty}226 ))227 }228 _ => {}229 }230 }231 }232233 let upper = if attr.upper && version > attr.first_version {234 let prev_version = format_ident!("{}Version{}", &input.ident, version - 1);235 let removed_fields = fields236 .iter()237 .filter(|(v, _)| v.exists_on(version - 1) && !v.exists_on(version))238 .map(|(_, f)| f.ident.as_ref().unwrap())239 .collect::<Vec<_>>();240 let added_fields = fields241 .iter()242 .filter(|(v, _)| !v.exists_on(version - 1) && v.exists_on(version))243 .map(|(v, f)| {244 let name = f.ident.as_ref().unwrap();245 let value = v.upper.clone().unwrap_or_else(|| {246 Expr::Verbatim(247 Error::new_spanned(f, "missing upper declaration").to_compile_error(),248 )249 });250 quote! { #name: #value }251 });252 let passed_fields = fields253 .iter()254 .filter(|(v, _)| v.exists_on(version - 1) && v.exists_on(version))255 .map(|(_, f)| f.ident.as_ref().unwrap())256 .collect::<Vec<_>>();257 // let added_fields = fields;258 quote! {259 impl #impl_generics From<#prev_version #ty_generics> for #name #ty_generics #where_clause {260 fn from(old: #prev_version #ty_generics) -> Self {261 let #prev_version {262 #(#removed_fields,)*263 #(#passed_fields,)*264 } = old;265 #(let _ = &#removed_fields;)*266 Self {267 #(#added_fields,)*268 #(#passed_fields,)*269 }270 }271 }272 }273 } else {274 quote! {}275 };276277 out.push(quote! {278 #(#attrs)*279 #(#[doc = #doc])*280 #vis struct #name #impl_generics #where_clause {281 #(#current_fields,)*282 }283284 #upper285 });286 }287288 let ident = &input.ident;289 let last_version = format_ident!("{}Version{}", input.ident, attr.current_version);290291 quote! {292 #(#out)*293294 #vis type #ident #ty_generics = #last_version #ty_generics;295 }296 .into()297}1use proc_macro::TokenStream;2use quote::format_ident;3use syn::{4 parse::{Parse, ParseStream},5 Token, LitInt, parse_macro_input, ItemStruct, Error, Fields, Result, Field, Expr,6 parenthesized,7};8use quote::quote;910mod kw {11 syn::custom_keyword!(version);12 syn::custom_keyword!(first_version);13 syn::custom_keyword!(versions);14 syn::custom_keyword!(upper);15}1617struct VersionedAttrs {18 current_version: u32,19 first_version: u32,20 upper: bool,21}2223/// #[versioned(version = 2)]24impl Parse for VersionedAttrs {25 fn parse(input: ParseStream) -> Result<Self> {26 let mut current_version = None::<u32>;27 let mut first_version = None::<u32>;28 let mut upper = false;2930 loop {31 if input.is_empty() {32 break;33 }34 let lookahead = input.lookahead1();35 if lookahead.peek(kw::version) {36 input.parse::<kw::version>()?;37 input.parse::<Token![=]>()?;38 let t = input.parse::<LitInt>()?;39 if current_version.is_some() {40 return Err(Error::new_spanned(t, "version is already set"));41 }42 current_version = Some(t.base10_parse()?)43 } else if lookahead.peek(kw::first_version) {44 input.parse::<kw::first_version>()?;45 input.parse::<Token![=]>()?;46 let t = input.parse::<LitInt>()?;47 if first_version.is_some() {48 return Err(Error::new_spanned(t, "first version is already set"));49 }50 first_version = Some(t.base10_parse()?)51 } else if lookahead.peek(kw::upper) {52 input.parse::<kw::upper>()?;53 upper = true;54 } else {55 return Err(lookahead.error());56 }5758 if input.is_empty() {59 break;60 } else if input.peek(Token![,]) {61 input.parse::<Token![,]>()?;62 continue;63 } else {64 return Err(input.error("unexpected token"));65 }66 }67 let first_version = first_version.unwrap_or(1);68 let current_version = current_version.unwrap_or(first_version);6970 if current_version == 0 || first_version == 0 || first_version > current_version {71 return Err(Error::new(input.span(), "1 <= first_version <= version"));72 }7374 Ok(Self {75 current_version,76 first_version,77 upper,78 })79 }80}8182/// #[version(..3)] - field vas removed in version 3 (i.e it was exist on version 2, but doesn't on version 3)83/// #[version(3..)] - field has appeared in version 384/// #[version(2..4)] - field was on versions 2, 385/// #[version(1..2, upper(old_field + 1))] - when updating struct from old version to new - calculate new field value from passed expression86struct VersionAttr {87 since: u32,88 before: Option<u32>,8990 upper: Option<Expr>,91}92impl VersionAttr {93 fn exists_on(&self, version: u32) -> bool {94 version >= self.since && self.before.map_or(true, |before| version < before)95 }96}97impl Parse for VersionAttr {98 fn parse(input: ParseStream) -> Result<Self> {99 let mut since = None::<u32>;100 let mut before = None::<u32>;101 let lookahead = input.lookahead1();102103 if lookahead.peek(LitInt) {104 let t: LitInt = input.parse()?;105 since = Some(t.base10_parse()?);106 } else if !lookahead.peek(Token![..]) {107 return Err(lookahead.error());108 }109 let range = input.parse::<Token![..]>()?;110 let lookahead = input.lookahead1();111 if lookahead.peek(LitInt) {112 let t: LitInt = input.parse()?;113 before = Some(t.base10_parse()?);114 } else if !input.is_empty() && !lookahead.peek(Token![,]) {115 return Err(lookahead.error());116 }117118 let upper = if input.peek(Token![,]) {119 input.parse::<Token![,]>()?;120 input.parse::<kw::upper>()?;121 let expr;122 parenthesized!(expr in input);123124 Some(Expr::parse(&expr)?)125 } else {126 None127 };128129 if since.is_none() && before.is_none() {130 return Err(Error::new_spanned(131 range,132 "noop range, remove this version attribute",133 ));134 }135 Ok(Self {136 since: since.unwrap_or(1),137 before,138 upper,139 })140 }141}142impl Default for VersionAttr {143 fn default() -> Self {144 Self {145 since: 1,146 before: None,147 upper: None,148 }149 }150}151152/// Generate versioned variants of a struct153///154/// `#[versioned(version = 1[, first_version = 1][, upper][, versions])]`155/// - *version* - current version of a struct156/// - *first_version* - allows to skip generation of structs, which predates first supported version157/// - *upper* - generate From impls, which converts old version of structs to new158/// - *versions* - generate enum, which contains all possible versions of struct159///160/// Each field may have version attribute161/// `#[version([1]..[2][, upper(old)])]`162/// - *1* - version, on which this field is appeared163/// - *2* - version, in which this field was removed164/// (i.e if set to 2, this field was exist on version 1, and no longer exist on version 2)165/// - *upper* - code, which should be executed to transform old value to new/create new value166#[proc_macro_attribute]167pub fn versioned(attr: TokenStream, input: TokenStream) -> TokenStream {168 let attr = parse_macro_input!(attr as VersionedAttrs);169 let input = parse_macro_input!(input as ItemStruct);170171 let fields = match input.fields {172 Fields::Named(named) => named.named,173 _ => {174 return Error::new_spanned(input, "expected named fields")175 .into_compile_error()176 .into()177 }178 };179 let fields = fields180 .iter()181 .map(|field| {182 let version_attr = match field.attrs.iter().find(|a| a.path.is_ident("version")) {183 Some(v) => v.parse_args::<VersionAttr>()?,184 None => return Ok((VersionAttr::default(), field.clone())),185 };186 let mut field = field.clone();187 field.attrs.retain(|a| !a.path.is_ident("version"));188 Ok((version_attr, field))189 })190 .collect::<Result<Vec<(VersionAttr, Field)>>>();191 let fields = match fields {192 Ok(f) => f,193 Err(e) => return e.into_compile_error().into(),194 };195196 let attrs = input.attrs;197 let vis = input.vis;198 let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();199 let mut out = Vec::new();200 for version in attr.first_version..=attr.current_version {201 let name = if version == attr.current_version {202 input.ident.clone() 203 } else {204 format_ident!("{}Version{}", &input.ident, version)205 };206 let current_fields = fields207 .iter()208 .filter_map(|(ver, field)| ver.exists_on(version).then(|| field));209210 let mut doc = Vec::new();211 if version > attr.first_version {212 doc.push(" # Versioning".into());213 doc.push(format!(" Changes between {} and {}:", version - 1, version));214 for (ver, field) in fields.iter() {215 match (ver.exists_on(version - 1), ver.exists_on(version)) {216 (true, false) => {217 let ty = &field.ty;218 doc.push(format!(219 " - {}: {} was removed",220 field.ident.as_ref().unwrap(),221 quote! {#ty}222 ))223 }224 (false, true) => {225 let ty = &field.ty;226 doc.push(format!(227 " - [`{}`]: {} was added",228 field.ident.as_ref().unwrap(),229 quote! {#ty}230 ))231 }232 _ => {}233 }234 }235 }236237 let upper = if attr.upper && version > attr.first_version {238 let prev_version = format_ident!("{}Version{}", &input.ident, version - 1);239 let removed_fields = fields240 .iter()241 .filter(|(v, _)| v.exists_on(version - 1) && !v.exists_on(version))242 .map(|(_, f)| f.ident.as_ref().unwrap())243 .collect::<Vec<_>>();244 let added_fields = fields245 .iter()246 .filter(|(v, _)| !v.exists_on(version - 1) && v.exists_on(version))247 .map(|(v, f)| {248 let name = f.ident.as_ref().unwrap();249 let value = v.upper.clone().unwrap_or_else(|| {250 Expr::Verbatim(251 Error::new_spanned(f, "missing upper declaration").to_compile_error(),252 )253 });254 quote! { #name: #value }255 });256 let passed_fields = fields257 .iter()258 .filter(|(v, _)| v.exists_on(version - 1) && v.exists_on(version))259 .map(|(_, f)| f.ident.as_ref().unwrap())260 .collect::<Vec<_>>();261 // let added_fields = fields;262 quote! {263 impl #impl_generics From<#prev_version #ty_generics> for #name #ty_generics #where_clause {264 fn from(old: #prev_version #ty_generics) -> Self {265 let #prev_version {266 #(#removed_fields,)*267 #(#passed_fields,)*268 } = old;269 #(let _ = &#removed_fields;)*270 Self {271 #(#added_fields,)*272 #(#passed_fields,)*273 }274 }275 }276 }277 } else {278 quote! {}279 };280281 out.push(quote! {282 #(#attrs)*283 #(#[doc = #doc])*284 #vis struct #name #impl_generics #where_clause {285 #(#current_fields,)*286 }287288 #upper289 });290 }291292 let ident = &input.ident;293 let last_version = format_ident!("{}Version{}", input.ident, attr.current_version);294295 quote! {296 #(#out)*297298 #vis type #last_version #ty_generics = #ident #ty_generics;299 }300 .into()301}primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -594,9 +594,11 @@
use scale_info::{
Type, Path,
build::{FieldsBuilder, UnnamedFields},
+ type_params,
};
Type::builder()
.path(Path::new("up_data_structs", "PhantomType"))
+ .type_params(type_params!(T))
.composite(<FieldsBuilder<UnnamedFields>>::default().field(|b| b.ty::<[T; 0]>()))
}
}
tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -5,7 +5,7 @@
import type { BTreeMap, Bytes, Option, U256, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types-codec';
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';
-import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, EthereumBlock, EthereumReceiptReceiptV3, EthereumTransactionTransactionV2, FpRpcTransactionStatus, FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmContractHelpersSponsoringModeT, PalletNonfungibleItemData, PalletRefungibleItemData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PhantomTypeUpDataStructs, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1PersistedValidationData, PolkadotPrimitivesV1UpgradeRestriction, SpRuntimeDigest, SpTrieStorageProof, UpDataStructsCollectionField, UpDataStructsCollectionStats, UpDataStructsCollectionVersion2 } from '@polkadot/types/lookup';
+import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, EthereumBlock, EthereumReceiptReceiptV3, EthereumTransactionTransactionV2, FpRpcTransactionStatus, FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmContractHelpersSponsoringModeT, PalletNonfungibleItemData, PalletRefungibleItemData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PhantomTypeUpDataStructs, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1PersistedValidationData, PolkadotPrimitivesV1UpgradeRestriction, SpRuntimeDigest, SpTrieStorageProof, UpDataStructsCollection, UpDataStructsCollectionField, UpDataStructsCollectionStats } from '@polkadot/types/lookup';
import type { Observable } from '@polkadot/types/types';
declare module '@polkadot/api-base/types/storage' {
@@ -77,7 +77,7 @@
/**
* Collection info
**/
- collectionById: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<UpDataStructsCollectionVersion2>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ collectionById: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<UpDataStructsCollection>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
* Large variable-size collection fields are extracted here
**/
tests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */
-import type { PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsCollectionLimitsVersion2, UpDataStructsCollectionStats, UpDataStructsRpcCollection } from './unique';
+import type { PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsCollectionLimits, UpDataStructsCollectionStats, UpDataStructsRpcCollection } from './unique';
import type { AugmentedRpc } from '@polkadot/rpc-core/types';
import type { Metadata, StorageKey } from '@polkadot/types';
import type { Bytes, HashMap, Json, Null, Option, Text, U256, U64, Vec, bool, u128, u32, u64 } from '@polkadot/types-codec';
@@ -617,7 +617,7 @@
/**
* Get effective collection limits
**/
- effectiveCollectionLimits: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsCollectionLimitsVersion2>>>;
+ effectiveCollectionLimits: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsCollectionLimits>>>;
/**
* Get last token id
**/
tests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-tx.ts
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -5,7 +5,7 @@
import type { Bytes, Compact, Option, U256, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types-codec';
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, Call, H160, H256, MultiAddress, Perbill } from '@polkadot/types/interfaces/runtime';
-import type { CumulusPrimitivesParachainInherentParachainInherentData, EthereumTransactionTransactionV2, OrmlVestingVestingSchedule, PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsAccessMode, UpDataStructsCollectionLimitsVersion2, UpDataStructsCollectionMode, UpDataStructsCreateCollectionData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsMetaUpdatePermission, UpDataStructsSchemaVersion, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
+import type { CumulusPrimitivesParachainInherentParachainInherentData, EthereumTransactionTransactionV2, OrmlVestingVestingSchedule, PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsAccessMode, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCreateCollectionData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsMetaUpdatePermission, UpDataStructsSchemaVersion, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
declare module '@polkadot/api-base/types/submittable' {
export interface AugmentedSubmittables<ApiType extends ApiTypes> {
@@ -777,7 +777,7 @@
* * address.
**/
removeFromAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr]>;
- setCollectionLimits: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: UpDataStructsCollectionLimitsVersion2 | { accountTokenOwnershipLimit?: any; sponsoredDataSize?: any; sponsoredDataRateLimit?: any; tokenLimit?: any; sponsorTransferTimeout?: any; sponsorApproveTimeout?: any; ownerCanTransfer?: any; ownerCanDestroy?: any; transfersEnabled?: any; nestingRule?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsCollectionLimitsVersion2]>;
+ setCollectionLimits: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: UpDataStructsCollectionLimits | { accountTokenOwnershipLimit?: any; sponsoredDataSize?: any; sponsoredDataRateLimit?: any; tokenLimit?: any; sponsorTransferTimeout?: any; sponsorApproveTimeout?: any; ownerCanTransfer?: any; ownerCanDestroy?: any; transfersEnabled?: any; nestingRule?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsCollectionLimits]>;
/**
* # Permissions
*
tests/src/interfaces/augment-types.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-types.ts
+++ b/tests/src/interfaces/augment-types.ts
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
-import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportStorageBoundedBTreeSet, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OpalRuntimeRuntime, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletStructureCall, PalletStructureError, PalletStructureEvent, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PhantomTypeUpDataStructs, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1AbridgedHrmpChannel, PolkadotPrimitivesV1PersistedValidationData, PolkadotPrimitivesV1UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeModuleError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpTrieStorageProof, SpVersionRuntimeVersion, UpDataStructsAccessMode, UpDataStructsCollectionField, UpDataStructsCollectionLimitsVersion2, UpDataStructsCollectionMode, UpDataStructsCollectionStats, UpDataStructsCollectionVersion2, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsCreateNftData, UpDataStructsCreateNftExData, UpDataStructsCreateReFungibleData, UpDataStructsCreateRefungibleExData, UpDataStructsMetaUpdatePermission, UpDataStructsNestingRule, UpDataStructsRpcCollection, UpDataStructsSchemaVersion, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from './unique';
+import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportStorageBoundedBTreeSet, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OpalRuntimeRuntime, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletStructureCall, PalletStructureError, PalletStructureEvent, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PhantomTypeUpDataStructs, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1AbridgedHrmpChannel, PolkadotPrimitivesV1PersistedValidationData, PolkadotPrimitivesV1UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeModuleError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpTrieStorageProof, SpVersionRuntimeVersion, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionField, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsCreateNftData, UpDataStructsCreateNftExData, UpDataStructsCreateReFungibleData, UpDataStructsCreateRefungibleExData, UpDataStructsMetaUpdatePermission, UpDataStructsNestingRule, UpDataStructsRpcCollection, UpDataStructsSchemaVersion, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from './unique';
import type { Data, StorageKey } from '@polkadot/types';
import type { BTreeSet, BitVec, Bool, Bytes, I128, I16, I256, I32, I64, I8, Json, Null, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec';
import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets';
@@ -1168,11 +1168,11 @@
UnrewardedRelayer: UnrewardedRelayer;
UnrewardedRelayersState: UnrewardedRelayersState;
UpDataStructsAccessMode: UpDataStructsAccessMode;
+ UpDataStructsCollection: UpDataStructsCollection;
UpDataStructsCollectionField: UpDataStructsCollectionField;
- UpDataStructsCollectionLimitsVersion2: UpDataStructsCollectionLimitsVersion2;
+ UpDataStructsCollectionLimits: UpDataStructsCollectionLimits;
UpDataStructsCollectionMode: UpDataStructsCollectionMode;
UpDataStructsCollectionStats: UpDataStructsCollectionStats;
- UpDataStructsCollectionVersion2: UpDataStructsCollectionVersion2;
UpDataStructsCreateCollectionData: UpDataStructsCreateCollectionData;
UpDataStructsCreateFungibleData: UpDataStructsCreateFungibleData;
UpDataStructsCreateItemData: UpDataStructsCreateItemData;
tests/src/interfaces/unique/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/types.ts
+++ b/tests/src/interfaces/unique/types.ts
@@ -1429,7 +1429,7 @@
readonly isSetCollectionLimits: boolean;
readonly asSetCollectionLimits: {
readonly collectionId: u32;
- readonly newLimit: UpDataStructsCollectionLimitsVersion2;
+ readonly newLimit: UpDataStructsCollectionLimits;
} & Struct;
readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'SetPublicAccessMode' | 'SetMintPermission' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetVariableMetaData' | 'SetMetaUpdatePermissionFlag' | 'SetSchemaVersion' | 'SetOffchainSchema' | 'SetConstOnChainSchema' | 'SetVariableOnChainSchema' | 'SetCollectionLimits';
}
@@ -1595,7 +1595,7 @@
}
/** @name PhantomTypeUpDataStructs */
-export interface PhantomTypeUpDataStructs extends Vec<Lookup309> {}
+export interface PhantomTypeUpDataStructs extends Vec<Lookup308> {}
/** @name PolkadotCorePrimitivesInboundDownwardMessage */
export interface PolkadotCorePrimitivesInboundDownwardMessage extends Struct {
@@ -1775,6 +1775,21 @@
readonly type: 'Normal' | 'AllowList';
}
+/** @name UpDataStructsCollection */
+export interface UpDataStructsCollection extends Struct {
+ readonly owner: AccountId32;
+ readonly mode: UpDataStructsCollectionMode;
+ readonly access: UpDataStructsAccessMode;
+ readonly name: Vec<u16>;
+ readonly description: Vec<u16>;
+ readonly tokenPrefix: Bytes;
+ readonly mintMode: bool;
+ readonly schemaVersion: UpDataStructsSchemaVersion;
+ readonly sponsorship: UpDataStructsSponsorshipState;
+ readonly limits: UpDataStructsCollectionLimits;
+ readonly metaUpdatePermission: UpDataStructsMetaUpdatePermission;
+}
+
/** @name UpDataStructsCollectionField */
export interface UpDataStructsCollectionField extends Enum {
readonly isVariableOnChainSchema: boolean;
@@ -1783,8 +1798,8 @@
readonly type: 'VariableOnChainSchema' | 'ConstOnChainSchema' | 'OffchainSchema';
}
-/** @name UpDataStructsCollectionLimitsVersion2 */
-export interface UpDataStructsCollectionLimitsVersion2 extends Struct {
+/** @name UpDataStructsCollectionLimits */
+export interface UpDataStructsCollectionLimits extends Struct {
readonly accountTokenOwnershipLimit: Option<u32>;
readonly sponsoredDataSize: Option<u32>;
readonly sponsoredDataRateLimit: Option<UpDataStructsSponsoringRateLimit>;
@@ -1813,21 +1828,6 @@
readonly alive: u32;
}
-/** @name UpDataStructsCollectionVersion2 */
-export interface UpDataStructsCollectionVersion2 extends Struct {
- readonly owner: AccountId32;
- readonly mode: UpDataStructsCollectionMode;
- readonly access: UpDataStructsAccessMode;
- readonly name: Vec<u16>;
- readonly description: Vec<u16>;
- readonly tokenPrefix: Bytes;
- readonly mintMode: bool;
- readonly schemaVersion: UpDataStructsSchemaVersion;
- readonly sponsorship: UpDataStructsSponsorshipState;
- readonly limits: UpDataStructsCollectionLimitsVersion2;
- readonly metaUpdatePermission: UpDataStructsMetaUpdatePermission;
-}
-
/** @name UpDataStructsCreateCollectionData */
export interface UpDataStructsCreateCollectionData extends Struct {
readonly mode: UpDataStructsCollectionMode;
@@ -1838,7 +1838,7 @@
readonly offchainSchema: Bytes;
readonly schemaVersion: Option<UpDataStructsSchemaVersion>;
readonly pendingSponsor: Option<AccountId32>;
- readonly limits: Option<UpDataStructsCollectionLimitsVersion2>;
+ readonly limits: Option<UpDataStructsCollectionLimits>;
readonly variableOnChainSchema: Bytes;
readonly constOnChainSchema: Bytes;
readonly metaUpdatePermission: Option<UpDataStructsMetaUpdatePermission>;
@@ -1929,7 +1929,7 @@
readonly offchainSchema: Bytes;
readonly schemaVersion: UpDataStructsSchemaVersion;
readonly sponsorship: UpDataStructsSponsorshipState;
- readonly limits: UpDataStructsCollectionLimitsVersion2;
+ readonly limits: UpDataStructsCollectionLimits;
readonly variableOnChainSchema: Bytes;
readonly constOnChainSchema: Bytes;
readonly metaUpdatePermission: UpDataStructsMetaUpdatePermission;