Skip to content

Commit

Permalink
Merge pull request #17 from proximax-storage/AccountProperties
Browse files Browse the repository at this point in the history
update version 0.0.5+2
  • Loading branch information
slackve authored May 24, 2020
2 parents 2f752cc + ed87b16 commit 44f7312
Show file tree
Hide file tree
Showing 36 changed files with 1,385 additions and 154 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.0.5+2
### New Features
[ADD] AccountPropertiesAddressTransaction.

[ADD] AccountPropertiesMosaicTransaction.

[ADD] AccountPropertiesEntityTypeTransaction.

## 0.0.5+1
### New Features
[ADD] AddExchangeOfferTransaction model.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Add this to your package's pubspec.yaml file:

```dart
dependencies:
xpx_chain_sdk: 0.0.5+1
xpx_chain_sdk: 0.0.5+2
```

**2. Install it**
Expand Down
1 change: 1 addition & 0 deletions lib/imp/buffer/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:typed_data';

import 'package:flat_buffers/flat_buffers.dart' as fb;

part 'model/account_properties_transaction_catapult.dart';
part 'model/aggregate_transaction_buffer.dart';
part 'model/alias_transaction_buffer.dart';
part 'model/exchange_transaction_buffer.dart';
Expand Down
291 changes: 291 additions & 0 deletions lib/imp/buffer/model/account_properties_transaction_catapult.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
part of xpx_chain_sdk.buffer.model;

class PropertyModificationBuffer {
factory PropertyModificationBuffer(List<int> bytes) {
final fb.BufferContext rootRef = new fb.BufferContext.fromBytes(bytes);
return reader.read(rootRef, 0);
}

PropertyModificationBuffer._(this._bc, this._bcOffset);

static const fb.Reader<PropertyModificationBuffer> reader =
const _PropertyModificationBufferReader();

final fb.BufferContext _bc;
final int _bcOffset;

int get modificationType =>
const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0);

/// In case of address it is 25 bytes array. In case of mosaic it is 8 byte array(or 2 uint32 array).
/// In case of transaction it is 2 byte array(ushort)
List<int> get value => const fb.ListReader<int>(const fb.Uint8Reader())
.vTableGet(_bc, _bcOffset, 6, null);

@override
String toString() =>
'PropertyModificationBuffer{modificationType: $modificationType, value: $value}';
}

class _PropertyModificationBufferReader
extends fb.TableReader<PropertyModificationBuffer> {
const _PropertyModificationBufferReader();

@override
PropertyModificationBuffer createObject(fb.BufferContext bc, int offset) =>
new PropertyModificationBuffer._(bc, offset);
}

class PropertyModificationBufferBuilder {
PropertyModificationBufferBuilder(this.fbBuilder) : assert(fbBuilder != null);

final fb.Builder fbBuilder;

void begin() {
fbBuilder.startTable();
}

int addModificationType(int modificationType) {
fbBuilder.addUint8(0, modificationType);
return fbBuilder.offset;
}

int addValueOffset(int offset) {
fbBuilder.addOffset(1, offset);
return fbBuilder.offset;
}

int finish() => fbBuilder.endTable();
}

class PropertyModificationBufferObjectBuilder extends fb.ObjectBuilder {
PropertyModificationBufferObjectBuilder({
int modificationType,
List<int> value,
}) : _modificationType = modificationType,
_value = value;

final int _modificationType;
final List<int> _value;

/// Finish building, and store into the [fbBuilder].
@override
int finish(fb.Builder fbBuilder) {
assert(fbBuilder != null);
final int valueOffset =
_value?.isNotEmpty == true ? fbBuilder.writeListUint8(_value) : null;

fbBuilder.startTable();
fbBuilder.addUint8(0, _modificationType);
if (valueOffset != null) {
fbBuilder.addOffset(1, valueOffset);
}
return fbBuilder.endTable();
}

/// Convenience method to serialize to byte list.
@override
Uint8List toBytes([String fileIdentifier]) {
final fb.Builder fbBuilder = new fb.Builder();
final int offset = finish(fbBuilder);
return fbBuilder.finish(offset, fileIdentifier);
}
}

class AccountPropertiesTransactionBuffer {
factory AccountPropertiesTransactionBuffer(List<int> bytes) {
final fb.BufferContext rootRef = new fb.BufferContext.fromBytes(bytes);
return reader.read(rootRef, 0);
}

AccountPropertiesTransactionBuffer._(this._bc, this._bcOffset);

static const fb.Reader<AccountPropertiesTransactionBuffer> reader =
const _AccountPropertiesTransactionBufferReader();

final fb.BufferContext _bc;
final int _bcOffset;

int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0);
List<int> get signature => const fb.ListReader<int>(const fb.Uint8Reader())
.vTableGet(_bc, _bcOffset, 6, null);
List<int> get signer => const fb.ListReader<int>(const fb.Uint8Reader())
.vTableGet(_bc, _bcOffset, 8, null);
int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0);
int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0);
List<int> get maxFee => const fb.ListReader<int>(const fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 14, null);
List<int> get deadline => const fb.ListReader<int>(const fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 16, null);
int get propertyType =>
const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0);
int get modificationCount =>
const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, 0);
List<PropertyModificationBuffer> get modifications =>
const fb.ListReader<PropertyModificationBuffer>(
PropertyModificationBuffer.reader)
.vTableGet(_bc, _bcOffset, 22, null);

@override
String toString() =>
'AccountPropertiesTransactionBuffer{size: $size, signature: $signature, signer: $signer, version: $version, type: $type, maxFee: $maxFee, deadline: $deadline, propertyType: $propertyType, modificationCount: $modificationCount, modifications: $modifications}';
}

class _AccountPropertiesTransactionBufferReader
extends fb.TableReader<AccountPropertiesTransactionBuffer> {
const _AccountPropertiesTransactionBufferReader();

@override
AccountPropertiesTransactionBuffer createObject(
fb.BufferContext bc, int offset) =>
new AccountPropertiesTransactionBuffer._(bc, offset);
}

class AccountPropertiesTransactionBufferBuilder {
AccountPropertiesTransactionBufferBuilder(this.fbBuilder)
: assert(fbBuilder != null);

final fb.Builder fbBuilder;

void begin() {
fbBuilder.startTable();
}

int addSize(int size) {
fbBuilder.addUint32(0, size);
return fbBuilder.offset;
}

int addSignatureOffset(int offset) {
fbBuilder.addOffset(1, offset);
return fbBuilder.offset;
}

int addSignerOffset(int offset) {
fbBuilder.addOffset(2, offset);
return fbBuilder.offset;
}

int addVersion(int version) {
fbBuilder.addUint32(3, version);
return fbBuilder.offset;
}

int addType(int type) {
fbBuilder.addUint16(4, type);
return fbBuilder.offset;
}

int addMaxFeeOffset(int offset) {
fbBuilder.addOffset(5, offset);
return fbBuilder.offset;
}

int addDeadlineOffset(int offset) {
fbBuilder.addOffset(6, offset);
return fbBuilder.offset;
}

int addPropertyType(int propertyType) {
fbBuilder.addUint8(7, propertyType);
return fbBuilder.offset;
}

int addModificationCount(int modificationCount) {
fbBuilder.addUint8(8, modificationCount);
return fbBuilder.offset;
}

int addModificationsOffset(int offset) {
fbBuilder.addOffset(9, offset);
return fbBuilder.offset;
}

int finish() => fbBuilder.endTable();
}

class AccountPropertiesTransactionBufferObjectBuilder extends fb.ObjectBuilder {
AccountPropertiesTransactionBufferObjectBuilder({
int size,
List<int> signature,
List<int> signer,
int version,
int type,
List<int> maxFee,
List<int> deadline,
int propertyType,
int modificationCount,
List<PropertyModificationBufferObjectBuilder> modifications,
}) : _size = size,
_signature = signature,
_signer = signer,
_version = version,
_type = type,
_maxFee = maxFee,
_deadline = deadline,
_propertyType = propertyType,
_modificationCount = modificationCount,
_modifications = modifications;

final int _size;
final List<int> _signature;
final List<int> _signer;
final int _version;
final int _type;
final List<int> _maxFee;
final List<int> _deadline;
final int _propertyType;
final int _modificationCount;
final List<PropertyModificationBufferObjectBuilder> _modifications;

/// Finish building, and store into the [fbBuilder].
@override
int finish(fb.Builder fbBuilder) {
assert(fbBuilder != null);
final int signatureOffset = _signature?.isNotEmpty == true
? fbBuilder.writeListUint8(_signature)
: null;
final int signerOffset =
_signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null;
final int maxFeeOffset =
_maxFee?.isNotEmpty == true ? fbBuilder.writeListUint32(_maxFee) : null;
final int deadlineOffset = _deadline?.isNotEmpty == true
? fbBuilder.writeListUint32(_deadline)
: null;
final int modificationsOffset = _modifications?.isNotEmpty == true
? fbBuilder.writeList(
_modifications.map((b) => b.getOrCreateOffset(fbBuilder)).toList())
: null;

fbBuilder.startTable();
fbBuilder.addUint32(0, _size);
if (signatureOffset != null) {
fbBuilder.addOffset(1, signatureOffset);
}
if (signerOffset != null) {
fbBuilder.addOffset(2, signerOffset);
}
fbBuilder.addUint32(3, _version);
fbBuilder.addUint16(4, _type);
if (maxFeeOffset != null) {
fbBuilder.addOffset(5, maxFeeOffset);
}
if (deadlineOffset != null) {
fbBuilder.addOffset(6, deadlineOffset);
}
fbBuilder.addUint8(7, _propertyType);
fbBuilder.addUint8(8, _modificationCount);
if (modificationsOffset != null) {
fbBuilder.addOffset(9, modificationsOffset);
}
return fbBuilder.endTable();
}

/// Convenience method to serialize to byte list.
@override
Uint8List toBytes([String fileIdentifier]) {
final fb.Builder fbBuilder = new fb.Builder();
final int offset = finish(fbBuilder);
return fbBuilder.finish(offset, fileIdentifier);
}
}
1 change: 1 addition & 0 deletions lib/imp/buffer/schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:typed_data';

part 'schema/buffer_schema.dart';
part 'schema/buffer_schema_transfer.dart';
part 'schema/buffer_schema_account_property.dart';
part 'schema/buffer_schema_register_namespace.dart';
part 'schema/buffer_schema_mosaic_definition.dart';
part 'schema/buffer_schema_mosaic_supply_change.dart';
Expand Down
22 changes: 11 additions & 11 deletions lib/imp/buffer/schema/buffer_schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,25 +210,25 @@ class TableAttribute extends AbstractSchemaAttribute
}
}

ArrayAttribute _newArrayAttribute(String name, int size) =>
ArrayAttribute arrayAttribute(String name, int size) =>
ArrayAttribute(name, size);

ScalarAttribute _newScalarAttribute(String name, int size) =>
ScalarAttribute scalarAttribute(String name, int size) =>
ScalarAttribute(name, size);

TableArrayAttribute _newTableArrayAttribute(
TableArrayAttribute tableArrayAttribute(
String name, List<SchemaAttribute> schema) =>
TableArrayAttribute(name, schema);

TableAttribute _newTableAttribute(String name, List<SchemaAttribute> schema) =>
TableAttribute tableAttribute(String name, List<SchemaAttribute> schema) =>
TableAttribute(name, schema);

List<SchemaAttribute> commonSchema() => [
_newScalarAttribute('size', _intSize),
_newArrayAttribute('signature', _byteSize),
_newArrayAttribute('signer', _byteSize),
_newScalarAttribute('version', _intSize),
_newScalarAttribute('type', _shortSize),
_newArrayAttribute('maxFee', _intSize),
_newArrayAttribute('deadline', _intSize),
scalarAttribute('size', _intSize),
arrayAttribute('signature', _byteSize),
arrayAttribute('signer', _byteSize),
scalarAttribute('version', _intSize),
scalarAttribute('type', _shortSize),
arrayAttribute('maxFee', _intSize),
arrayAttribute('deadline', _intSize),
];
16 changes: 16 additions & 0 deletions lib/imp/buffer/schema/buffer_schema_account_property.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
part of xpx_chain_sdk.buffer.schema;

Schema accountPropertyTransactionSchema() {
final List<SchemaAttribute> schemaDefinition = [
scalarAttribute('propertyType', _byteSize),
scalarAttribute('modificationCount', _byteSize),
tableArrayAttribute(
'modifications',
Schema([
scalarAttribute('modificationType', _byteSize),
arrayAttribute('value', _byteSize),
]).schemaDefinition)
];
schemaDefinition.insertAll(0, commonSchema());
return Schema(schemaDefinition);
}
4 changes: 2 additions & 2 deletions lib/imp/buffer/schema/buffer_schema_aggregate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ part of xpx_chain_sdk.buffer.schema;

Schema aggregateTransactionSchema() {
final List<SchemaAttribute> schemaDefinition = [
_newScalarAttribute('transactionsSize', _intSize),
_newArrayAttribute('transactions', _byteSize),
scalarAttribute('transactionsSize', _intSize),
arrayAttribute('transactions', _byteSize),
];
schemaDefinition.insertAll(0, commonSchema());
return Schema(schemaDefinition);
Expand Down
Loading

0 comments on commit 44f7312

Please sign in to comment.