Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c26ed38
Added #50 Account property and modifications. Initial commit
Feb 27, 2019
0d4e609
added property modification transactions
Feb 28, 2019
1582774
fixed a few bugs on account property transaction
Mar 1, 2019
b05c8fe
Added #50 Account property and modifications. Initial commit
Feb 27, 2019
bf328f6
added property modification transactions
Feb 28, 2019
f0b5fcf
fixed a few bugs on account property transaction
Mar 1, 2019
fb0e64c
Removed and transaction type enum & sperate account property versions
rg911 Mar 4, 2019
84c1f8f
conflict resoved
rg911 Mar 4, 2019
03b2586
Added #50 Account property and modifications. Initial commit
Feb 27, 2019
897d305
added property modification transactions
Feb 28, 2019
d0e04ad
fixed a few bugs on account property transaction
Mar 1, 2019
df41887
Added #50 Account property and modifications. Initial commit
Feb 27, 2019
c39a3ca
added property modification transactions
Feb 28, 2019
991bdde
Removed and transaction type enum & sperate account property versions
rg911 Mar 4, 2019
1e64da6
config resolved
rg911 Mar 4, 2019
6e9b221
Renamed transaction version keys to match transaction type for accoun…
rg911 Mar 4, 2019
bba26cd
restore master package-lock
rg911 Mar 4, 2019
65b563e
typo fixed
rg911 Mar 6, 2019
dcd4c10
a few comments and linter changes
rg911 Mar 7, 2019
9fb23dd
updated account property filter docs
rg911 Mar 7, 2019
b71d16f
Merge branch 'master' into task/g50-account-properties
evias Mar 7, 2019
6ad7ba8
PR #73: upgrade nem2-library version to v0.9.9 to include AccountProp…
evias Mar 7, 2019
f9fb9a4
Merge branch 'task/g50-account-properties' of https://github.com/rg91…
rg911 Mar 7, 2019
05e1a34
updated nem2-lib to 0.9.10
rg911 Mar 7, 2019
babb10d
updated nem2-lib version
rg911 Mar 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions e2e/infrastructure/AccountHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ describe('AccountHttp', () => {
});
});

describe('getAccountProperty', () => {
it('should call getAccountProperty successfully', (done) => {
accountHttp.getAccountProperty(publicAccount).subscribe((accountProperty) => {
expect(accountProperty.accountProperties[0]!.address).to.be.equal(accountAddress);
done();
});
});
});

describe('getAccountProperties', () => {
it('should call getAccountProperties successfully', (done) => {
accountHttp.getAccountProperties([accountAddress]).subscribe((accountProperties) => {
expect(accountProperties[0]!.accountProperties[0]!.address).to.be.equal(accountAddress);
done();
});
});
});
describe('getMultisigAccountGraphInfo', () => {
it('should call getMultisigAccountGraphInfo successfully', (done) => {
accountHttp.getMultisigAccountGraphInfo(multisigPublicAccount.address).subscribe((multisigAccountGraphInfo) => {
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/crypto-js": "^3.1.43",
"crypto-js": "^3.1.9-1",
"js-joda": "^1.6.2",
"nem2-library": "^0.9.8",
"nem2-library": "^0.9.11",
"request": "^2.83.0",
"request-promise-native": "^1.0.5",
"rxjs": "^6.2.1",
Expand Down
50 changes: 39 additions & 11 deletions src/infrastructure/AccountHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {AccountRoutesApi} from 'nem2-library';
import {from as observableFrom, Observable} from 'rxjs';
import {map, mergeMap} from 'rxjs/operators';
import {AccountInfo} from '../model/account/AccountInfo';
import { AccountPropertiesInfo } from '../model/account/AccountPropertiesInfo';
import { AccountProperty } from '../model/account/AccountProperty';
import {Address} from '../model/account/Address';
import {MultisigAccountGraphInfo} from '../model/account/MultisigAccountGraphInfo';
import {MultisigAccountInfo} from '../model/account/MultisigAccountInfo';
Expand Down Expand Up @@ -79,6 +81,38 @@ export class AccountHttp extends Http implements AccountRepository {
}));
}

/**
* Gets Account property.
* @param publicAccount public account
* @returns Observable<AccountProperty>
*/
public getAccountProperty(publicAccount: PublicAccount): Observable<AccountPropertiesInfo> {
return observableFrom(this.accountRoutesApi.getAccountProperties(publicAccount.publicKey)).pipe(map((accountProperties) => {
return new AccountPropertiesInfo(
accountProperties.meta,
accountProperties.accountProperties,
);
}));
}

/**
* Gets Account properties.
* @param address list of addresses
* @returns Observable<AccountProperty[]>
*/
public getAccountProperties(addresses: Address[]): Observable<AccountPropertiesInfo[]> {
const accountIds = addresses.map((address) => address.plain());
return observableFrom(
this.accountRoutesApi.getAccountPropertiesFromAccounts(accountIds)).pipe(map((accountProperties) => {
return accountProperties.map((property) => {
return new AccountPropertiesInfo(
property.meta,
property.accountProperties,
);
});
}));
}

/**
* Gets AccountsInfo for different accounts.
* @param addresses List of Address
Expand Down Expand Up @@ -160,8 +194,7 @@ export class AccountHttp extends Http implements AccountRepository {
* @param queryParams - (Optional) Query params
* @returns Observable<Transaction[]>
*/
public transactions(publicAccount: PublicAccount,
queryParams?: QueryParams): Observable<Transaction[]> {
public transactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable<Transaction[]> {
return observableFrom(
this.accountRoutesApi.transactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe(
map((transactionsDTO) => {
Expand All @@ -178,8 +211,7 @@ export class AccountHttp extends Http implements AccountRepository {
* @param queryParams - (Optional) Query params
* @returns Observable<Transaction[]>
*/
public incomingTransactions(publicAccount: PublicAccount,
queryParams?: QueryParams): Observable<Transaction[]> {
public incomingTransactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable <Transaction[]> {
return observableFrom(
this.accountRoutesApi.incomingTransactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe(
map((transactionsDTO) => {
Expand All @@ -196,8 +228,7 @@ export class AccountHttp extends Http implements AccountRepository {
* @param queryParams - (Optional) Query params
* @returns Observable<Transaction[]>
*/
public outgoingTransactions(publicAccount: PublicAccount,
queryParams?: QueryParams): Observable<Transaction[]> {
public outgoingTransactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable <Transaction[]> {
return observableFrom(
this.accountRoutesApi.outgoingTransactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe(
map((transactionsDTO) => {
Expand All @@ -215,8 +246,7 @@ export class AccountHttp extends Http implements AccountRepository {
* @param queryParams - (Optional) Query params
* @returns Observable<Transaction[]>
*/
public unconfirmedTransactions(publicAccount: PublicAccount,
queryParams?: QueryParams): Observable<Transaction[]> {
public unconfirmedTransactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable <Transaction[]> {
return observableFrom(
this.accountRoutesApi.unconfirmedTransactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe(
map((transactionsDTO) => {
Expand All @@ -233,9 +263,7 @@ export class AccountHttp extends Http implements AccountRepository {
* @param queryParams - (Optional) Query params
* @returns Observable<AggregateTransaction[]>
*/
public aggregateBondedTransactions(publicAccount: PublicAccount,
queryParams?: QueryParams): Observable<AggregateTransaction[]> {

public aggregateBondedTransactions(publicAccount: PublicAccount, queryParams?: QueryParams): Observable <AggregateTransaction[]> {
return observableFrom(
this.accountRoutesApi.partialTransactions(publicAccount.publicKey, queryParams != null ? queryParams : {})).pipe(
map((transactionsDTO) => {
Expand Down
49 changes: 49 additions & 0 deletions src/infrastructure/transaction/CreateTransactionFromDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import {Address} from '../../model/account/Address';
import {PublicAccount} from '../../model/account/PublicAccount';
import {NetworkType} from '../../model/blockchain/NetworkType';
import { AccountPropertyModification,
ModifyAccountPropertyAddressTransaction,
ModifyAccountPropertyEntityTypeTransaction,
ModifyAccountPropertyMosaicTransaction } from '../../model/model';
import {Mosaic} from '../../model/mosaic/Mosaic';
import {MosaicId} from '../../model/mosaic/MosaicId';
import {MosaicProperties} from '../../model/mosaic/MosaicProperties';
Expand Down Expand Up @@ -254,6 +258,51 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
PublicAccount.createFromPublicKey(transactionDTO.signer, extractNetworkType(transactionDTO.version)),
transactionInfo,
);
} else if (transactionDTO.type === TransactionType.MODIFY_ACCOUNT_PROPERTY_ADDRESS) {
return new ModifyAccountPropertyAddressTransaction(
extractNetworkType(transactionDTO.version),
extractTransactionVersion(transactionDTO.version),
Deadline.createFromDTO(transactionDTO.deadline),
new UInt64(transactionDTO.fee),
transactionDTO.propertyType,
transactionDTO.modifications ? transactionDTO.modifications.map((modificationDTO) => new AccountPropertyModification(
modificationDTO.modificationType,
modificationDTO.value,
)) : [],
transactionDTO.signature,
PublicAccount.createFromPublicKey(transactionDTO.signer, extractNetworkType(transactionDTO.version)),
transactionInfo,
);
} else if (transactionDTO.type === TransactionType.MODIFY_ACCOUNT_PROPERTY_ENTITY_TYPE) {
return new ModifyAccountPropertyEntityTypeTransaction(
extractNetworkType(transactionDTO.version),
extractTransactionVersion(transactionDTO.version),
Deadline.createFromDTO(transactionDTO.deadline),
new UInt64(transactionDTO.fee),
transactionDTO.propertyType,
transactionDTO.modifications ? transactionDTO.modifications.map((modificationDTO) => new AccountPropertyModification(
modificationDTO.modificationType,
modificationDTO.value,
)) : [],
transactionDTO.signature,
PublicAccount.createFromPublicKey(transactionDTO.signer, extractNetworkType(transactionDTO.version)),
transactionInfo,
);
} else if (transactionDTO.type === TransactionType.MODIFY_ACCOUNT_PROPERTY_MOSAIC) {
return new ModifyAccountPropertyMosaicTransaction(
extractNetworkType(transactionDTO.version),
extractTransactionVersion(transactionDTO.version),
Deadline.createFromDTO(transactionDTO.deadline),
new UInt64(transactionDTO.fee),
transactionDTO.propertyType,
transactionDTO.modifications ? transactionDTO.modifications.map((modificationDTO) => new AccountPropertyModification(
modificationDTO.modificationType,
modificationDTO.value,
)) : [],
transactionDTO.signature,
PublicAccount.createFromPublicKey(transactionDTO.signer, extractNetworkType(transactionDTO.version)),
transactionInfo,
);
}

throw new Error('Unimplemented transaction with type ' + transactionDTO.type);
Expand Down
39 changes: 39 additions & 0 deletions src/model/account/AccountProperties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2019 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AccountProperty } from './AccountProperty';
import { Address } from './Address';
/**
* Account properties structure describes property information for an account.
*/
export class AccountProperties {

/**
* Constructor
* @param address
* @param properties
*/
constructor(
/**
* Account Address
*/
public readonly address: Address,
/**
* Properties.
*/
public readonly properties: AccountProperty[]) {

}
}
38 changes: 38 additions & 0 deletions src/model/account/AccountPropertiesInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2019 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AccountProperties } from './AccountProperties';
/**
* Account properties structure describes property information for an account.
*/
export class AccountPropertiesInfo {

/**
* Constructor
* @param meta
* @param accountProperties
*/
constructor(
/**
* meta
*/
public readonly meta: any,
/**
* Properties.
*/
public readonly accountProperties: AccountProperties[]) {

}
}
40 changes: 40 additions & 0 deletions src/model/account/AccountProperty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2019 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { PropertyType } from './PropertyType';
/**
* Account property structure describes property information.
*/
export class AccountProperty {

/**
* Constructor
* @param propertyType
* @param values
*/
constructor(
/**
* Account property type
*/
public readonly propertyType: PropertyType,
/**
* Property values.
*/
public readonly values: object[]) {

}

}
23 changes: 23 additions & 0 deletions src/model/account/PropertyModificationType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2019 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Account property modification type
*/
export enum PropertyModificationType {
Add = 0x00,
Remove = 0x01,
}
Loading