Skip to content

Commit

Permalink
State proof fixes (#736)
Browse files Browse the repository at this point in the history
* Added version 1 fallback

* removed log
  • Loading branch information
fboucquez committed Dec 7, 2020
1 parent caf7333 commit 5a6208d
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions e2e/service/StateProofService.spec.ts
Expand Up @@ -22,7 +22,7 @@ import { NamespaceRegistrationType } from '../../src/model/namespace';
import { StateMerkleProof } from '../../src/model/state';
import { StateProofService } from '../../src/service';

const url = 'http://api-01.us-west-2.0.10.0.x.symboldev.network:3000';
const url = 'http://localhost:3000';
const repositoryFactory = new RepositoryFactoryHttp(url);
const service = new StateProofService(repositoryFactory);
const stateCounts = 50;
Expand All @@ -46,7 +46,7 @@ async function test<E, C extends SearchCriteria>(
try {
const merkle = await merkleMethod(info).toPromise();
expect(merkle).to.not.undefined;
if (merkle.valid) console.log(stateUrl + ' ' + merkle.valid);
if (merkle.valid) console.log(stateUrl + ' ' + merkle.valid + ' ' + merkle.stateHash);
else {
console.error(stateUrl + ' ' + merkle.valid);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils/DtoMapping.ts
Expand Up @@ -39,7 +39,7 @@ export class DtoMapping {
*/
public static extractAccountRestrictionFromDto(accountRestrictions: AccountRestrictionsInfoDTO): AccountRestrictions {
return new AccountRestrictions(
accountRestrictions.accountRestrictions.version,
accountRestrictions.accountRestrictions.version || 1,
accountRestrictions['id'],
Address.createFromEncoded(accountRestrictions.accountRestrictions.address),
accountRestrictions.accountRestrictions.restrictions.map((prop) => {
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/AccountHttp.ts
Expand Up @@ -111,7 +111,7 @@ export class AccountHttp extends Http implements AccountRepository {
*/
public static toAccountInfo(dto: AccountInfoDTO): AccountInfo {
return new AccountInfo(
dto.account.version,
dto.account.version || 1,
dto.id,
Address.createFromEncoded(dto.account.address),
UInt64.fromNumericString(dto.account.addressHeight),
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/HashLockHttp.ts
Expand Up @@ -98,7 +98,7 @@ export class HashLockHttp extends Http implements HashLockRepository {
*/
private toHashLockInfo(dto: HashLockInfoDTO): HashLockInfo {
return new HashLockInfo(
dto.lock.version,
dto.lock.version || 1,
dto.id,
Address.createFromEncoded(dto.lock.ownerAddress),
new MosaicId(dto.lock.mosaicId),
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/MetadataHttp.ts
Expand Up @@ -120,7 +120,7 @@ export class MetadataHttp extends Http implements MetadataRepository {
return new Metadata(
metadata.id,
new MetadataEntry(
metadataEntry.version,
metadataEntry.version || 1,
metadataEntry.compositeHash,
Address.createFromEncoded(metadataEntry.sourceAddress),
Address.createFromEncoded(metadataEntry.targetAddress),
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/MosaicHttp.ts
Expand Up @@ -128,7 +128,7 @@ export class MosaicHttp extends Http implements MosaicRepository {
*/
public static toMosaicInfo(mosaicInfo: MosaicInfoDTO): MosaicInfo {
return new MosaicInfo(
mosaicInfo.mosaic.version,
mosaicInfo.mosaic.version || 1,
mosaicInfo.id,
new MosaicId(mosaicInfo.mosaic.id),
UInt64.fromNumericString(mosaicInfo.mosaic.supply),
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/MultisigHttp.ts
Expand Up @@ -91,7 +91,7 @@ export class MultisigHttp extends Http implements MultisigRepository {
*/
private toMultisigAccountInfo(dto: MultisigAccountInfoDTO): MultisigAccountInfo {
return new MultisigAccountInfo(
dto.multisig.version,
dto.multisig.version || 1,
Address.createFromEncoded(dto.multisig.accountAddress),
dto.multisig.minApproval,
dto.multisig.minRemoval,
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/NamespaceHttp.ts
Expand Up @@ -240,7 +240,7 @@ export class NamespaceHttp extends Http implements NamespaceRepository {
*/
private toNamespaceInfo(dto: NamespaceInfoDTO): NamespaceInfo {
return new NamespaceInfo(
dto.namespace.version,
dto.namespace.version || 1,
dto.meta.active,
dto.meta.index,
dto.id,
Expand Down
4 changes: 2 additions & 2 deletions src/infrastructure/RestrictionMosaicHttp.ts
Expand Up @@ -96,7 +96,7 @@ export class RestrictionMosaicHttp extends Http implements RestrictionMosaicRepo
if ((dto.mosaicRestrictionEntry as any).targetAddress) {
const addressRestrictionDto = dto as MosaicAddressRestrictionDTO;
return new MosaicAddressRestriction(
dto.mosaicRestrictionEntry.version,
dto.mosaicRestrictionEntry.version || 1,
dto.mosaicRestrictionEntry.compositeHash,
dto.mosaicRestrictionEntry.entryType.valueOf(),
new MosaicId(dto.mosaicRestrictionEntry.mosaicId),
Expand All @@ -107,7 +107,7 @@ export class RestrictionMosaicHttp extends Http implements RestrictionMosaicRepo

const globalRestrictionDto = dto as MosaicGlobalRestrictionDTO;
return new MosaicGlobalRestriction(
dto.mosaicRestrictionEntry.version,
dto.mosaicRestrictionEntry.version || 1,
dto.mosaicRestrictionEntry.compositeHash,
dto.mosaicRestrictionEntry.entryType.valueOf(),
new MosaicId(dto.mosaicRestrictionEntry.mosaicId),
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/SecretLockHttp.ts
Expand Up @@ -90,7 +90,7 @@ export class SecretLockHttp extends Http implements SecretLockRepository {
*/
private toSecretLockInfo(dto: SecretLockInfoDTO): SecretLockInfo {
return new SecretLockInfo(
dto.lock.version,
dto.lock.version || 1,
dto.id,
Address.createFromEncoded(dto.lock.ownerAddress),
new MosaicId(dto.lock.mosaicId),
Expand Down

0 comments on commit 5a6208d

Please sign in to comment.