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

Research: Meta type system #7

Open
xlc opened this issue Apr 29, 2024 · 0 comments
Open

Research: Meta type system #7

xlc opened this issue Apr 29, 2024 · 0 comments

Comments

@xlc
Copy link
Member

xlc commented Apr 29, 2024

In order for XCQ to be generic, we need to have a meta type system to describe types. This is required to support chains with different type definitions for common operation. For example, the AssetId for a fungible extension could be a numeric ID (asset hub), or a xcm::Location (also asset hub), or an enum (Acala). Therefore we need to allow the chain to describe such type and then the client can decode the output correctly using the type information.

We could either build a simple one, or use scale-info

enum PrimitiveType {
  /// Unsigned Integer up to 128 bits
  Unsigned,
  /// Signed Integer up to 128 bigs
  Signed,
  U256,
  I256,
  Bool,
  /// Vec<u8>
  Bytes,
  /// [u8; 32]
  H256,
}

struct Field {
  iden: Vec<u8>,
  type: Type,
}

struct StructType {
  iden: Vec<u8>,
  fields: Vec<Field>,
}

enum VariantField {
  Unnamed(Vec<Type>),
  Named(Vec<Field>),
}

struct Variant {
  iden: Vec<u8>,
  fields: Vec<VariantField>
}

struct EnumType {
  iden: Vec<u8>,
  variants: Vec<Variant>
}

enum Type {
  Primitive(PrimitiveType),
  Struct(StructType),
  Enum(EnumType),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant