LegacyBCS constructor
LegacyBCS(
- BcsConfig scheme
Construct a BCS instance with a prepared schema.
Implementation
LegacyBCS(BcsConfig scheme) {
schema = scheme;
// Register address type under key 'address'.
registerAddressType(
LegacyBCS.ADDRESS,
schema.addressLength,
schema.addressEncoding ?? Encoding.hex
);
registerVectorType(schema.vectorType);
if (schema.fixedArrayType != null) {
registerFixedArrayType(schema.fixedArrayType!);
}
// Register struct types if they were passed.
if (schema.types?.structs != null) {
for (var item in schema.types!.structs!.entries) {
registerStructType(item.key, item.value);
}
}
// Register enum types if they were passed.
if (schema.types?.enums != null) {
for (var item in schema.types!.enums!.entries) {
registerEnumType(item.key, item.value);
}
}
// Register aliases if they were passed.
if (schema.types?.aliases != null) {
for (var item in schema.types!.aliases!.entries) {
registerAlias(item.key, item.value);
}
}
if (schema.withPrimitives != false) {
registerPrimitives(this);
}
}