mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-26 20:26:02 +00:00
clean up, fixes and code gen
This commit is contained in:
parent
33efc956e9
commit
8cd7f3fa7f
4 changed files with 67 additions and 148 deletions
|
@ -80,7 +80,7 @@ class InputV2 {
|
||||||
..valueStringSats = valueStringSats
|
..valueStringSats = valueStringSats
|
||||||
..witness = witness
|
..witness = witness
|
||||||
..innerRedeemScriptAsm = innerRedeemScriptAsm
|
..innerRedeemScriptAsm = innerRedeemScriptAsm
|
||||||
..innerRedeemScriptAsm = innerRedeemScriptAsm
|
..coinbase = coinbase
|
||||||
..walletOwns = walletOwns;
|
..walletOwns = walletOwns;
|
||||||
|
|
||||||
InputV2 copyWith({
|
InputV2 copyWith({
|
||||||
|
|
|
@ -346,37 +346,37 @@ const InputV2Schema = Schema(
|
||||||
name: r'coinbase',
|
name: r'coinbase',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
),
|
),
|
||||||
r'hashCode': PropertySchema(
|
|
||||||
id: 2,
|
|
||||||
name: r'hashCode',
|
|
||||||
type: IsarType.long,
|
|
||||||
),
|
|
||||||
r'innerRedeemScriptAsm': PropertySchema(
|
r'innerRedeemScriptAsm': PropertySchema(
|
||||||
id: 3,
|
id: 2,
|
||||||
name: r'innerRedeemScriptAsm',
|
name: r'innerRedeemScriptAsm',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
),
|
),
|
||||||
r'outpoint': PropertySchema(
|
r'outpoint': PropertySchema(
|
||||||
id: 4,
|
id: 3,
|
||||||
name: r'outpoint',
|
name: r'outpoint',
|
||||||
type: IsarType.object,
|
type: IsarType.object,
|
||||||
target: r'OutpointV2',
|
target: r'OutpointV2',
|
||||||
),
|
),
|
||||||
r'scriptSigHex': PropertySchema(
|
r'scriptSigHex': PropertySchema(
|
||||||
id: 5,
|
id: 4,
|
||||||
name: r'scriptSigHex',
|
name: r'scriptSigHex',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
),
|
),
|
||||||
r'sequence': PropertySchema(
|
r'sequence': PropertySchema(
|
||||||
id: 6,
|
id: 5,
|
||||||
name: r'sequence',
|
name: r'sequence',
|
||||||
type: IsarType.long,
|
type: IsarType.long,
|
||||||
),
|
),
|
||||||
r'valueStringSats': PropertySchema(
|
r'valueStringSats': PropertySchema(
|
||||||
id: 7,
|
id: 6,
|
||||||
name: r'valueStringSats',
|
name: r'valueStringSats',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
),
|
),
|
||||||
|
r'walletOwns': PropertySchema(
|
||||||
|
id: 7,
|
||||||
|
name: r'walletOwns',
|
||||||
|
type: IsarType.bool,
|
||||||
|
),
|
||||||
r'witness': PropertySchema(
|
r'witness': PropertySchema(
|
||||||
id: 8,
|
id: 8,
|
||||||
name: r'witness',
|
name: r'witness',
|
||||||
|
@ -446,17 +446,17 @@ void _inputV2Serialize(
|
||||||
) {
|
) {
|
||||||
writer.writeStringList(offsets[0], object.addresses);
|
writer.writeStringList(offsets[0], object.addresses);
|
||||||
writer.writeString(offsets[1], object.coinbase);
|
writer.writeString(offsets[1], object.coinbase);
|
||||||
writer.writeLong(offsets[2], object.hashCode);
|
writer.writeString(offsets[2], object.innerRedeemScriptAsm);
|
||||||
writer.writeString(offsets[3], object.innerRedeemScriptAsm);
|
|
||||||
writer.writeObject<OutpointV2>(
|
writer.writeObject<OutpointV2>(
|
||||||
offsets[4],
|
offsets[3],
|
||||||
allOffsets,
|
allOffsets,
|
||||||
OutpointV2Schema.serialize,
|
OutpointV2Schema.serialize,
|
||||||
object.outpoint,
|
object.outpoint,
|
||||||
);
|
);
|
||||||
writer.writeString(offsets[5], object.scriptSigHex);
|
writer.writeString(offsets[4], object.scriptSigHex);
|
||||||
writer.writeLong(offsets[6], object.sequence);
|
writer.writeLong(offsets[5], object.sequence);
|
||||||
writer.writeString(offsets[7], object.valueStringSats);
|
writer.writeString(offsets[6], object.valueStringSats);
|
||||||
|
writer.writeBool(offsets[7], object.walletOwns);
|
||||||
writer.writeString(offsets[8], object.witness);
|
writer.writeString(offsets[8], object.witness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,15 +469,16 @@ InputV2 _inputV2Deserialize(
|
||||||
final object = InputV2();
|
final object = InputV2();
|
||||||
object.addresses = reader.readStringList(offsets[0]) ?? [];
|
object.addresses = reader.readStringList(offsets[0]) ?? [];
|
||||||
object.coinbase = reader.readStringOrNull(offsets[1]);
|
object.coinbase = reader.readStringOrNull(offsets[1]);
|
||||||
object.innerRedeemScriptAsm = reader.readStringOrNull(offsets[3]);
|
object.innerRedeemScriptAsm = reader.readStringOrNull(offsets[2]);
|
||||||
object.outpoint = reader.readObjectOrNull<OutpointV2>(
|
object.outpoint = reader.readObjectOrNull<OutpointV2>(
|
||||||
offsets[4],
|
offsets[3],
|
||||||
OutpointV2Schema.deserialize,
|
OutpointV2Schema.deserialize,
|
||||||
allOffsets,
|
allOffsets,
|
||||||
);
|
);
|
||||||
object.scriptSigHex = reader.readStringOrNull(offsets[5]);
|
object.scriptSigHex = reader.readStringOrNull(offsets[4]);
|
||||||
object.sequence = reader.readLongOrNull(offsets[6]);
|
object.sequence = reader.readLongOrNull(offsets[5]);
|
||||||
object.valueStringSats = reader.readString(offsets[7]);
|
object.valueStringSats = reader.readString(offsets[6]);
|
||||||
|
object.walletOwns = reader.readBool(offsets[7]);
|
||||||
object.witness = reader.readStringOrNull(offsets[8]);
|
object.witness = reader.readStringOrNull(offsets[8]);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
@ -494,21 +495,21 @@ P _inputV2DeserializeProp<P>(
|
||||||
case 1:
|
case 1:
|
||||||
return (reader.readStringOrNull(offset)) as P;
|
return (reader.readStringOrNull(offset)) as P;
|
||||||
case 2:
|
case 2:
|
||||||
return (reader.readLong(offset)) as P;
|
|
||||||
case 3:
|
|
||||||
return (reader.readStringOrNull(offset)) as P;
|
return (reader.readStringOrNull(offset)) as P;
|
||||||
case 4:
|
case 3:
|
||||||
return (reader.readObjectOrNull<OutpointV2>(
|
return (reader.readObjectOrNull<OutpointV2>(
|
||||||
offset,
|
offset,
|
||||||
OutpointV2Schema.deserialize,
|
OutpointV2Schema.deserialize,
|
||||||
allOffsets,
|
allOffsets,
|
||||||
)) as P;
|
)) as P;
|
||||||
case 5:
|
case 4:
|
||||||
return (reader.readStringOrNull(offset)) as P;
|
return (reader.readStringOrNull(offset)) as P;
|
||||||
case 6:
|
case 5:
|
||||||
return (reader.readLongOrNull(offset)) as P;
|
return (reader.readLongOrNull(offset)) as P;
|
||||||
case 7:
|
case 6:
|
||||||
return (reader.readString(offset)) as P;
|
return (reader.readString(offset)) as P;
|
||||||
|
case 7:
|
||||||
|
return (reader.readBool(offset)) as P;
|
||||||
case 8:
|
case 8:
|
||||||
return (reader.readStringOrNull(offset)) as P;
|
return (reader.readStringOrNull(offset)) as P;
|
||||||
default:
|
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>
|
QueryBuilder<InputV2, InputV2, QAfterFilterCondition>
|
||||||
innerRedeemScriptAsmIsNull() {
|
innerRedeemScriptAsmIsNull() {
|
||||||
return QueryBuilder.apply(this, (query) {
|
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() {
|
QueryBuilder<InputV2, InputV2, QAfterFilterCondition> witnessIsNull() {
|
||||||
return QueryBuilder.apply(this, (query) {
|
return QueryBuilder.apply(this, (query) {
|
||||||
return query.addFilterCondition(const FilterCondition.isNull(
|
return query.addFilterCondition(const FilterCondition.isNull(
|
||||||
|
|
|
@ -18,20 +18,20 @@ const OutputV2Schema = Schema(
|
||||||
name: r'addresses',
|
name: r'addresses',
|
||||||
type: IsarType.stringList,
|
type: IsarType.stringList,
|
||||||
),
|
),
|
||||||
r'hashCode': PropertySchema(
|
|
||||||
id: 1,
|
|
||||||
name: r'hashCode',
|
|
||||||
type: IsarType.long,
|
|
||||||
),
|
|
||||||
r'scriptPubKeyHex': PropertySchema(
|
r'scriptPubKeyHex': PropertySchema(
|
||||||
id: 2,
|
id: 1,
|
||||||
name: r'scriptPubKeyHex',
|
name: r'scriptPubKeyHex',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
),
|
),
|
||||||
r'valueStringSats': PropertySchema(
|
r'valueStringSats': PropertySchema(
|
||||||
id: 3,
|
id: 2,
|
||||||
name: r'valueStringSats',
|
name: r'valueStringSats',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
|
),
|
||||||
|
r'walletOwns': PropertySchema(
|
||||||
|
id: 3,
|
||||||
|
name: r'walletOwns',
|
||||||
|
type: IsarType.bool,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
estimateSize: _outputV2EstimateSize,
|
estimateSize: _outputV2EstimateSize,
|
||||||
|
@ -65,9 +65,9 @@ void _outputV2Serialize(
|
||||||
Map<Type, List<int>> allOffsets,
|
Map<Type, List<int>> allOffsets,
|
||||||
) {
|
) {
|
||||||
writer.writeStringList(offsets[0], object.addresses);
|
writer.writeStringList(offsets[0], object.addresses);
|
||||||
writer.writeLong(offsets[1], object.hashCode);
|
writer.writeString(offsets[1], object.scriptPubKeyHex);
|
||||||
writer.writeString(offsets[2], object.scriptPubKeyHex);
|
writer.writeString(offsets[2], object.valueStringSats);
|
||||||
writer.writeString(offsets[3], object.valueStringSats);
|
writer.writeBool(offsets[3], object.walletOwns);
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputV2 _outputV2Deserialize(
|
OutputV2 _outputV2Deserialize(
|
||||||
|
@ -78,8 +78,9 @@ OutputV2 _outputV2Deserialize(
|
||||||
) {
|
) {
|
||||||
final object = OutputV2();
|
final object = OutputV2();
|
||||||
object.addresses = reader.readStringList(offsets[0]) ?? [];
|
object.addresses = reader.readStringList(offsets[0]) ?? [];
|
||||||
object.scriptPubKeyHex = reader.readString(offsets[2]);
|
object.scriptPubKeyHex = reader.readString(offsets[1]);
|
||||||
object.valueStringSats = reader.readString(offsets[3]);
|
object.valueStringSats = reader.readString(offsets[2]);
|
||||||
|
object.walletOwns = reader.readBool(offsets[3]);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,11 +94,11 @@ P _outputV2DeserializeProp<P>(
|
||||||
case 0:
|
case 0:
|
||||||
return (reader.readStringList(offset) ?? []) as P;
|
return (reader.readStringList(offset) ?? []) as P;
|
||||||
case 1:
|
case 1:
|
||||||
return (reader.readLong(offset)) as P;
|
return (reader.readString(offset)) as P;
|
||||||
case 2:
|
case 2:
|
||||||
return (reader.readString(offset)) as P;
|
return (reader.readString(offset)) as P;
|
||||||
case 3:
|
case 3:
|
||||||
return (reader.readString(offset)) as P;
|
return (reader.readBool(offset)) as P;
|
||||||
default:
|
default:
|
||||||
throw IsarError('Unknown property with id $propertyId');
|
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>
|
QueryBuilder<OutputV2, OutputV2, QAfterFilterCondition>
|
||||||
scriptPubKeyHexEqualTo(
|
scriptPubKeyHexEqualTo(
|
||||||
String value, {
|
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
|
extension OutputV2QueryObject
|
||||||
|
|
|
@ -67,6 +67,7 @@ mixin ElectrumXParsing {
|
||||||
final prevOut = OutputV2.fromElectrumXJson(
|
final prevOut = OutputV2.fromElectrumXJson(
|
||||||
prevOutJson,
|
prevOutJson,
|
||||||
decimalPlaces: coin.decimals,
|
decimalPlaces: coin.decimals,
|
||||||
|
walletOwns: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
outpoint = OutpointV2.isarCantDoRequiredInDefaultConstructor(
|
outpoint = OutpointV2.isarCantDoRequiredInDefaultConstructor(
|
||||||
|
@ -86,6 +87,7 @@ mixin ElectrumXParsing {
|
||||||
witness: map["witness"] as String?,
|
witness: map["witness"] as String?,
|
||||||
coinbase: coinbase,
|
coinbase: coinbase,
|
||||||
innerRedeemScriptAsm: map["innerRedeemscriptAsm"] as String?,
|
innerRedeemScriptAsm: map["innerRedeemscriptAsm"] as String?,
|
||||||
|
walletOwns: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
inputs.add(input);
|
inputs.add(input);
|
||||||
|
@ -97,6 +99,7 @@ mixin ElectrumXParsing {
|
||||||
final output = OutputV2.fromElectrumXJson(
|
final output = OutputV2.fromElectrumXJson(
|
||||||
Map<String, dynamic>.from(outputJson as Map),
|
Map<String, dynamic>.from(outputJson as Map),
|
||||||
decimalPlaces: coin.decimals,
|
decimalPlaces: coin.decimals,
|
||||||
|
walletOwns: false,
|
||||||
);
|
);
|
||||||
outputs.add(output);
|
outputs.add(output);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue