Skip to content

Commit

Permalink
Merge pull request #19 from proximax-storage/AccountProperties
Browse files Browse the repository at this point in the history
update version to 0.0.5+4
  • Loading branch information
slackve authored May 24, 2020
2 parents 2122f7a + 388e8ca commit c185968
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 53 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.5+4
### Updates
[UPDATE] analysis code.

## 0.0.5+3
### Updates
[UPDATE] format code.
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+3
xpx_chain_sdk: 0.0.5+4
```

**2. Install it**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class AccountPropertiesTransactionBuffer {
AccountPropertiesTransactionBuffer._(this._bc, this._bcOffset);

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

final fb.BufferContext _bc;
final int _bcOffset;
Expand Down
34 changes: 16 additions & 18 deletions lib/imp/buffer/model/exchange_transaction_buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,20 @@ class ExchangeOfferTransactionBuffer {

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

List<int> get signature => const fb.ListReader<int>(const fb.Uint8Reader())
List<int> get signature => const fb.ListReader<int>(fb.Uint8Reader())
.vTableGet(_bc, _bcOffset, 6, null);

List<int> get signer => const fb.ListReader<int>(const fb.Uint8Reader())
List<int> get signer => const fb.ListReader<int>(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())
List<int> get maxFee => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 14, null);

List<int> get deadline => const fb.ListReader<int>(const fb.Uint32Reader())
List<int> get deadline => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 16, null);

int get offersCount =>
Expand Down Expand Up @@ -414,10 +414,10 @@ class RemoveExchangeOfferTransactionBuffer {

int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0);

List<int> get maxFee => const fb.ListReader<int>(const fb.Uint32Reader())
List<int> get maxFee => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 14, null);

List<int> get deadline => const fb.ListReader<int>(const fb.Uint32Reader())
List<int> get deadline => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 16, null);

int get offersCount =>
Expand Down Expand Up @@ -598,19 +598,18 @@ class AddExchangeOfferBuffer {
final fb.BufferContext _bc;
final int _bcOffset;

List<int> get mosaicId => const fb.ListReader<int>(const fb.Uint32Reader())
List<int> get mosaicId => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 4, null);

List<int> get mosaicAmount =>
const fb.ListReader<int>(const fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 6, null);
List<int> get mosaicAmount => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 6, null);

List<int> get cost => const fb.ListReader<int>(const fb.Uint32Reader())
List<int> get cost => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 8, null);

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

List<int> get duration => const fb.ListReader<int>(const fb.Uint32Reader())
List<int> get duration => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 12, null);

@override
Expand Down Expand Up @@ -739,19 +738,18 @@ class ExchangeOfferBuffer {
final fb.BufferContext _bc;
final int _bcOffset;

List<int> get mosaicId => const fb.ListReader<int>(const fb.Uint32Reader())
List<int> get mosaicId => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 4, null);

List<int> get mosaicAmount =>
const fb.ListReader<int>(const fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 6, null);
List<int> get mosaicAmount => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 6, null);

List<int> get cost => const fb.ListReader<int>(const fb.Uint32Reader())
List<int> get cost => const fb.ListReader<int>(fb.Uint32Reader())
.vTableGet(_bc, _bcOffset, 8, null);

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

List<int> get owner => const fb.ListReader<int>(const fb.Uint8Reader())
List<int> get owner => const fb.ListReader<int>(fb.Uint8Reader())
.vTableGet(_bc, _bcOffset, 12, null);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class MosaicDefinitionTransactionBuffer {
MosaicDefinitionTransactionBuffer._(this._bc, this._bcOffset);

static const fb.Reader<MosaicDefinitionTransactionBuffer> reader =
const _MosaicDefinitionTransactionBufferReader();
_MosaicDefinitionTransactionBufferReader();

final fb.BufferContext _bc;
final int _bcOffset;
Expand Down
2 changes: 1 addition & 1 deletion lib/imp/buffer/model/transfer_transaction_buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class TransferTransactionBuffer {
TransferTransactionBuffer._(this._bc, this._bcOffset);

static const fb.Reader<TransferTransactionBuffer> reader =
const _TransferTransactionBufferReader();
_TransferTransactionBufferReader();

final fb.BufferContext _bc;
final int _bcOffset;
Expand Down
33 changes: 17 additions & 16 deletions lib/src/model/account/account_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ class Account {
Account._(this.publicAccount, this.account);

/// Create an Account from a given hex private key.
Account.fromPrivateKey(String shex, int networkType) {
account = crypto.KeyPair.fromHexString(shex);
publicAccount =
static Account fromPrivateKey(String shex, int networkType) {
final account = crypto.KeyPair.fromHexString(shex);
final publicAccount =
PublicAccount.fromPublicKey(account.publicKey.toString(), networkType);
return Account._(publicAccount, account);
}

/// Create an Account from a given networkType.
Account.random(int networkType) {
static Account random(int networkType) {
final kp = crypto.KeyPair.fromRandomKeyPair();
final acc = Account.fromPrivateKey(kp.privateKey.toString(), networkType);
publicAccount = acc.publicAccount;
account = acc.account;
final publicAccount = acc.publicAccount;
final account = acc.account;
return Account._(publicAccount, account);
}

PublicAccount publicAccount;
Expand Down Expand Up @@ -47,12 +49,13 @@ class PublicAccount {
PublicAccount._(this.publicKey, this.address);

/// Create an Account from a given publicKey hex string.
PublicAccount.fromPublicKey(this.publicKey, int networkType) {
static PublicAccount fromPublicKey(String publicKey, int networkType) {
if (publicKey == null ||
(publicKeySize != publicKey.length && 66 != publicKey.length)) {
throw errInvalidPublicKey;
}
address = Address.fromPublicKey(publicKey, networkType);
final address = Address.fromPublicKey(publicKey, networkType);
return PublicAccount._(publicKey, address);
}

String publicKey;
Expand Down Expand Up @@ -83,12 +86,12 @@ class PublicAccount {
}

class AccountNames {
AccountNames._();
AccountNames._(this.address, this.names);

AccountNames.fromDto(AccountNamesDTO dto) {
if (dto == null) return;
address = Address.fromEncoded(dto.address);
names = (dto._names == null) ? null : dto._names.cast<String>();
static AccountNames fromDto(AccountNamesDTO dto) {
final address = Address.fromEncoded(dto.address);
final names = (dto._names == null) ? null : dto._names.cast<String>();
return AccountNames._(address, names);
}

/* The address of the account in hexadecimal. */
Expand All @@ -98,9 +101,7 @@ class AccountNames {
List<String> names;

static List<AccountNames> listFromJson(List<AccountNamesDTO> json) =>
json == null
? <AccountNames>[]
: json.map((value) => AccountNames.fromDto(value)).toList();
json == null ? <AccountNames>[] : json.map(AccountNames.fromDto).toList();

@override
String toString() => '{\n'
Expand Down
2 changes: 0 additions & 2 deletions lib/src/model/account/account_properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ enum PropertyModificationType {
}

class AccountProperties {
AccountProperties._();

AccountProperties.fromDto(AccountPropertiesDTO dto) {
if (dto == null) return;
address = Address.fromEncoded(dto.address);
Expand Down
14 changes: 4 additions & 10 deletions lib/src/model/mosaic/mosaic_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ enum MosaicPropertyId {
}

class Mosaic {
Mosaic(AssetId mosaicId, Uint64 amount) {
if (mosaicId == null) {
Mosaic(this.assetId, this.amount) {
if (assetId == null) {
throw errNullMosaicId;
} else if (amount == null) {
throw errNullMosaicAmount;
} else if (amount.isZero) {
throw errNullMosaicAmount;
} else {
assetId = mosaicId;
this.amount = amount;
assetId = assetId;
amount = amount;
}
}

Expand Down Expand Up @@ -96,8 +96,6 @@ class MosaicId extends AssetId {
}

class MosaicIds {
MosaicIds._();

MosaicIds.fromList(List<MosaicId> list)
: assert(list != null, 'list must not be null') {
_list = list.map((item) => item).toList();
Expand Down Expand Up @@ -214,10 +212,6 @@ class MosaicProperties {

MosaicProperties.fromDTO(List<_MosaicPropertyDTO> value)
: assert(value != null, 'mosaic Properties is not valid') {
// if (value.length < 3) {//
// throw errInvalidMosaicProperties;
// }

var flags = Uint64.zero;

divisibility = 0;
Expand Down
2 changes: 0 additions & 2 deletions lib/src/model/network/network_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const Map<String, int> addressNet = {
};

class NetworkType {
NetworkType._(this.networkType, this.description);

NetworkType.fromJson(Map<String, dynamic> json)
: assert(json != null, 'json must not be null') {
networkType = json['name'];
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: xpx_chain_sdk
version: 0.0.5+3
version: 0.0.5+4
author: 'Eleazar Garrido <[email protected]>'

description: 'The ProximaX Sirius Chain Dart SDK works as a lightweight Dart library for interacting with the Sirius Blockchain.'
Expand Down

0 comments on commit c185968

Please sign in to comment.