clean up, fixes and code gen

This commit is contained in:
julian 2023-10-20 11:41:51 -06:00
parent 33efc956e9
commit 8cd7f3fa7f
4 changed files with 67 additions and 148 deletions
lib
models/isar/models/blockchain_data/v2
services/mixins

View file

@ -80,7 +80,7 @@ class InputV2 {
..valueStringSats = valueStringSats
..witness = witness
..innerRedeemScriptAsm = innerRedeemScriptAsm
..innerRedeemScriptAsm = innerRedeemScriptAsm
..coinbase = coinbase
..walletOwns = walletOwns;
InputV2 copyWith({

View file

@ -346,37 +346,37 @@ const InputV2Schema = Schema(
name: r'coinbase',
type: IsarType.string,
),
r'hashCode': PropertySchema(
id: 2,
name: r'hashCode',
type: IsarType.long,
),
r'innerRedeemScriptAsm': PropertySchema(
id: 3,
id: 2,
name: r'innerRedeemScriptAsm',
type: IsarType.string,
),
r'outpoint': PropertySchema(
id: 4,
id: 3,
name: r'outpoint',
type: IsarType.object,
target: r'OutpointV2',
),
r'scriptSigHex': PropertySchema(
id: 5,
id: 4,
name: r'scriptSigHex',
type: IsarType.string,
),
r'sequence': PropertySchema(
id: 6,
id: 5,
name: r'sequence',
type: IsarType.long,
),
r'valueStringSats': PropertySchema(
id: 7,
id: 6,
name: r'valueStringSats',
type: IsarType.string,
),
r'walletOwns': PropertySchema(
id: 7,
name: r'walletOwns',
type: IsarType.bool,
),
r'witness': PropertySchema(
id: 8,
name: r'witness',
@ -446,17 +446,17 @@ void _inputV2Serialize(
) {
writer.writeStringList(offsets[0], object.addresses);
writer.writeString(offsets[1], object.coinbase);
writer.writeLong(offsets[2], object.hashCode);
writer.writeString(offsets[3], object.innerRedeemScriptAsm);
writer.writeString(offsets[2], object.innerRedeemScriptAsm);
writer.writeObject<OutpointV2>(
offsets[4],
offsets[3],
allOffsets,
OutpointV2Schema.serialize,
object.outpoint,
);
writer.writeString(offsets[5], object.scriptSigHex);
writer.writeLong(offsets[6], object.sequence);
writer.writeString(offsets[7], object.valueStringSats);
writer.writeString(offsets[4], object.scriptSigHex);
writer.writeLong(offsets[5], object.sequence);
writer.writeString(offsets[6], object.valueStringSats);
writer.writeBool(offsets[7], object.walletOwns);
writer.writeString(offsets[8], object.witness);
}
@ -469,15 +469,16 @@ InputV2 _inputV2Deserialize(
final object = InputV2();
object.addresses = reader.readStringList(offsets[0]) ?? [];
object.coinbase = reader.readStringOrNull(offsets[1]);
object.innerRedeemScriptAsm = reader.readStringOrNull(offsets[3]);
object.innerRedeemScriptAsm = reader.readStringOrNull(offsets[2]);
object.outpoint = reader.readObjectOrNull<OutpointV2>(
offsets[4],
offsets[3],
OutpointV2Schema.deserialize,
allOffsets,
);
object.scriptSigHex = reader.readStringOrNull(offsets[5]);
object.sequence = reader.readLongOrNull(offsets[6]);
object.valueStringSats = reader.readString(offsets[7]);
object.scriptSigHex = reader.readStringOrNull(offsets[4]);
object.sequence = reader.readLongOrNull(offsets[5]);
object.valueStringSats = reader.readString(offsets[6]);
object.walletOwns = reader.readBool(offsets[7]);
object.witness = reader.readStringOrNull(offsets[8]);
return object;
}
@ -494,21 +495,21 @@ P _inputV2DeserializeProp<P>(
case 1:
return (reader.readStringOrNull(offset)) as P;
case 2:
return (reader.readLong(offset)) as P;
case 3:
return (reader.readStringOrNull(offset)) as P;
case 4:
case 3:
return (reader.readObjectOrNull<OutpointV2>(
offset,
OutpointV2Schema.deserialize,
allOffsets,
)) as P;
case 5:
case 4:
return (reader.readStringOrNull(offset)) as P;
case 6:
case 5:
return (reader.readLongOrNull(offset)) as P;
case 7:
case 6:
return (reader.readString(offset)) as P;
case 7:
return (reader.readBool(offset)) as P;
case 8:
return (reader.readStringOrNull(offset)) as P;
default:
@ -884,59 +885,6 @@ extension InputV2QueryFilter
});
}
QueryBuilder<InputV2, InputV2, QAfterFilterCondition> hashCodeEqualTo(
int value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'hashCode',
value: value,
));
});
}
QueryBuilder<InputV2, InputV2, QAfterFilterCondition> hashCodeGreaterThan(
int value, {
bool include = false,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
include: include,
property: r'hashCode',
value: value,
));
});
}
QueryBuilder<InputV2, InputV2, QAfterFilterCondition> hashCodeLessThan(
int value, {
bool include = false,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.lessThan(
include: include,
property: r'hashCode',
value: value,
));
});
}
QueryBuilder<InputV2, InputV2, QAfterFilterCondition> hashCodeBetween(
int lower,
int upper, {
bool includeLower = true,
bool includeUpper = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.between(
property: r'hashCode',
lower: lower,
includeLower: includeLower,
upper: upper,
includeUpper: includeUpper,
));
});
}
QueryBuilder<InputV2, InputV2, QAfterFilterCondition>
innerRedeemScriptAsmIsNull() {
return QueryBuilder.apply(this, (query) {
@ -1458,6 +1406,16 @@ extension InputV2QueryFilter
});
}
QueryBuilder<InputV2, InputV2, QAfterFilterCondition> walletOwnsEqualTo(
bool value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'walletOwns',
value: value,
));
});
}
QueryBuilder<InputV2, InputV2, QAfterFilterCondition> witnessIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(

View file

@ -18,20 +18,20 @@ const OutputV2Schema = Schema(
name: r'addresses',
type: IsarType.stringList,
),
r'hashCode': PropertySchema(
id: 1,
name: r'hashCode',
type: IsarType.long,
),
r'scriptPubKeyHex': PropertySchema(
id: 2,
id: 1,
name: r'scriptPubKeyHex',
type: IsarType.string,
),
r'valueStringSats': PropertySchema(
id: 3,
id: 2,
name: r'valueStringSats',
type: IsarType.string,
),
r'walletOwns': PropertySchema(
id: 3,
name: r'walletOwns',
type: IsarType.bool,
)
},
estimateSize: _outputV2EstimateSize,
@ -65,9 +65,9 @@ void _outputV2Serialize(
Map<Type, List<int>> allOffsets,
) {
writer.writeStringList(offsets[0], object.addresses);
writer.writeLong(offsets[1], object.hashCode);
writer.writeString(offsets[2], object.scriptPubKeyHex);
writer.writeString(offsets[3], object.valueStringSats);
writer.writeString(offsets[1], object.scriptPubKeyHex);
writer.writeString(offsets[2], object.valueStringSats);
writer.writeBool(offsets[3], object.walletOwns);
}
OutputV2 _outputV2Deserialize(
@ -78,8 +78,9 @@ OutputV2 _outputV2Deserialize(
) {
final object = OutputV2();
object.addresses = reader.readStringList(offsets[0]) ?? [];
object.scriptPubKeyHex = reader.readString(offsets[2]);
object.valueStringSats = reader.readString(offsets[3]);
object.scriptPubKeyHex = reader.readString(offsets[1]);
object.valueStringSats = reader.readString(offsets[2]);
object.walletOwns = reader.readBool(offsets[3]);
return object;
}
@ -93,11 +94,11 @@ P _outputV2DeserializeProp<P>(
case 0:
return (reader.readStringList(offset) ?? []) as P;
case 1:
return (reader.readLong(offset)) as P;
return (reader.readString(offset)) as P;
case 2:
return (reader.readString(offset)) as P;
case 3:
return (reader.readString(offset)) as P;
return (reader.readBool(offset)) as P;
default:
throw IsarError('Unknown property with id $propertyId');
}
@ -329,59 +330,6 @@ extension OutputV2QueryFilter
});
}
QueryBuilder<OutputV2, OutputV2, QAfterFilterCondition> hashCodeEqualTo(
int value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'hashCode',
value: value,
));
});
}
QueryBuilder<OutputV2, OutputV2, QAfterFilterCondition> hashCodeGreaterThan(
int value, {
bool include = false,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
include: include,
property: r'hashCode',
value: value,
));
});
}
QueryBuilder<OutputV2, OutputV2, QAfterFilterCondition> hashCodeLessThan(
int value, {
bool include = false,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.lessThan(
include: include,
property: r'hashCode',
value: value,
));
});
}
QueryBuilder<OutputV2, OutputV2, QAfterFilterCondition> hashCodeBetween(
int lower,
int upper, {
bool includeLower = true,
bool includeUpper = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.between(
property: r'hashCode',
lower: lower,
includeLower: includeLower,
upper: upper,
includeUpper: includeUpper,
));
});
}
QueryBuilder<OutputV2, OutputV2, QAfterFilterCondition>
scriptPubKeyHexEqualTo(
String value, {
@ -653,6 +601,16 @@ extension OutputV2QueryFilter
));
});
}
QueryBuilder<OutputV2, OutputV2, QAfterFilterCondition> walletOwnsEqualTo(
bool value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'walletOwns',
value: value,
));
});
}
}
extension OutputV2QueryObject

View file

@ -67,6 +67,7 @@ mixin ElectrumXParsing {
final prevOut = OutputV2.fromElectrumXJson(
prevOutJson,
decimalPlaces: coin.decimals,
walletOwns: false,
);
outpoint = OutpointV2.isarCantDoRequiredInDefaultConstructor(
@ -86,6 +87,7 @@ mixin ElectrumXParsing {
witness: map["witness"] as String?,
coinbase: coinbase,
innerRedeemScriptAsm: map["innerRedeemscriptAsm"] as String?,
walletOwns: false,
);
inputs.add(input);
@ -97,6 +99,7 @@ mixin ElectrumXParsing {
final output = OutputV2.fromElectrumXJson(
Map<String, dynamic>.from(outputJson as Map),
decimalPlaces: coin.decimals,
walletOwns: false,
);
outputs.add(output);
}