Support BTreeSet. (#9206)

* Support BTreeSet.

* Fix style.
This commit is contained in:
Robert Gabriel Jakabosky 2023-03-21 21:35:08 +08:00 committed by GitHub
parent 5eebabd356
commit cce56c0e7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -22,7 +22,8 @@ function getParam ([{ name, type }]: ParamDef[], index: number): ParamDef {
}
export function getParams (inputParams: ParamDef[], prev: ParamDef[], max: number): ParamDef[] {
if (prev.length === max) {
// HACK: I don't know why `max` changes to `undefined`.
if (prev.length === max || isUndefined(max)) {
return prev;
}
@ -36,6 +37,10 @@ export function getParams (inputParams: ParamDef[], prev: ParamDef[], max: numbe
}
export function getValues ({ value }: RawParam): RawParam[] {
if (value instanceof Set) {
value = [...value.values()];
}
return Array.isArray(value)
? value.map((value: RawParam) =>
isUndefined(value) || isUndefined(value.isValid)

View File

@ -74,7 +74,7 @@ const componentDef: TypeToComponent[] = [
{ c: Text, t: ['String', 'Text'] },
{ c: Struct, t: ['Struct'] },
{ c: Tuple, t: ['Tuple'] },
{ c: Vector, t: ['Vec'] },
{ c: Vector, t: ['Vec', 'BTreeSet'] },
{ c: VectorFixed, t: ['VecFixed'] },
{ c: Vote, t: ['Vote'] },
{ c: VoteThreshold, t: ['VoteThreshold'] },
@ -121,6 +121,9 @@ function fromDef ({ displayName, info, lookupName, sub, type }: TypeDef): string
case TypeDefInfo.Struct:
return 'Struct';
case TypeDefInfo.BTreeSet:
return 'BTreeSet';
case TypeDefInfo.Tuple:
return components[type] === Account
? type