Skip to content

Commit 3baf340

Browse files
authored
Merge pull request #292 from rg911/task/g289_open_api_re_apply
JAV-61, JAV-60 Apply OpenAPI 0.7.19 and MosaicRestriction Key
2 parents 56fbd02 + 50ab61c commit 3baf340

File tree

188 files changed

+772
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+772
-260
lines changed

e2e/service/MosaicRestrictionTransactionService.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { assert, expect } from 'chai';
2+
import { KeyGenerator } from '../../src/core/format/KeyGenerator';
23
import { Listener } from '../../src/infrastructure/Listener';
34
import { RestrictionHttp } from '../../src/infrastructure/RestrictionHttp';
45
import { TransactionHttp } from '../../src/infrastructure/TransactionHttp';
@@ -19,7 +20,7 @@ import { MosaicRestrictionTransactionService } from '../../src/service/MosaicRes
1920

2021
describe('MosaicRestrictionTransactionService', () => {
2122
const deadline = Deadline.create();
22-
const key = '9876543';
23+
const key = KeyGenerator.generateUInt64Key('TestKey');
2324
let targetAccount: Account;
2425
let account: Account;
2526
let restrictionHttp: RestrictionHttp;
@@ -98,7 +99,7 @@ describe('MosaicRestrictionTransactionService', () => {
9899
const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create(
99100
Deadline.create(),
100101
mosaicId,
101-
UInt64.fromNumericString(key),
102+
key,
102103
UInt64.fromUint(0),
103104
MosaicRestrictionType.NONE,
104105
UInt64.fromUint(0),
@@ -132,7 +133,7 @@ describe('MosaicRestrictionTransactionService', () => {
132133
const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create(
133134
Deadline.create(),
134135
mosaicId,
135-
UInt64.fromNumericString(key),
136+
key,
136137
targetAccount.address,
137138
UInt64.fromUint(2),
138139
NetworkType.MIJIN_TEST,
@@ -177,7 +178,7 @@ describe('MosaicRestrictionTransactionService', () => {
177178
expect(transaction.previousRestrictionType).to.be.equal(MosaicRestrictionType.GE);
178179
expect(transaction.newRestrictionValue.toString()).to.be.equal('1');
179180
expect(transaction.newRestrictionType).to.be.equal(MosaicRestrictionType.GE);
180-
expect(transaction.restrictionKey.toString()).to.be.equal(key);
181+
expect(transaction.restrictionKey.toHex()).to.be.equal(key.toHex());
181182
done();
182183
});
183184
});
@@ -196,7 +197,7 @@ describe('MosaicRestrictionTransactionService', () => {
196197
expect(transaction.previousRestrictionValue.toString()).to.be.equal('2');
197198
expect(transaction.newRestrictionValue.toString()).to.be.equal('3');
198199
expect(transaction.targetAddress.plain()).to.be.equal(targetAccount.address.plain());
199-
expect(transaction.restrictionKey.toString()).to.be.equal(key);
200+
expect(transaction.restrictionKey.toHex()).to.be.equal(key.toHex());
200201
done();
201202
});
202203
});

src/infrastructure/NamespaceHttp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ export class NamespaceHttp extends Http implements NamespaceRepository {
270270
*/
271271
private extractAlias(namespace: any): Alias {
272272
if (namespace.alias && namespace.alias.type === AliasType.Mosaic) {
273-
return new MosaicAlias(namespace.alias.mosaicId);
273+
return new MosaicAlias(new MosaicId(namespace.alias.mosaicId));
274274
} else if (namespace.alias && namespace.alias.type === AliasType.Address) {
275-
return new AddressAlias(namespace.alias.address);
275+
return new AddressAlias(Address.createFromEncoded(namespace.alias.address));
276276
}
277277

278278
return new EmptyAlias();

src/infrastructure/RestrictionHttp.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class RestrictionHttp extends Http implements RestrictionRepository {
108108
});
109109
return new MosaicAddressRestriction(
110110
payload.compositeHash,
111-
payload.entryType,
111+
payload.entryType.valueOf(),
112112
new MosaicId(payload.mosaicId),
113113
Address.createFromEncoded(payload.targetAddress),
114114
restirctionItems,
@@ -140,7 +140,7 @@ export class RestrictionHttp extends Http implements RestrictionRepository {
140140
});
141141
return new MosaicAddressRestriction(
142142
payload.mosaicRestrictionEntry.compositeHash,
143-
payload.mosaicRestrictionEntry.entryType,
143+
payload.mosaicRestrictionEntry.entryType.valueOf(),
144144
new MosaicId(payload.mosaicRestrictionEntry.mosaicId),
145145
Address.createFromEncoded(payload.mosaicRestrictionEntry.targetAddress),
146146
restirctionItems,
@@ -168,7 +168,7 @@ export class RestrictionHttp extends Http implements RestrictionRepository {
168168
new MosaicGlobalRestrictionItem(
169169
new MosaicId(restriction.restriction.referenceMosaicId),
170170
restriction.restriction.restrictionValue,
171-
restriction.restriction.restrictionType,
171+
restriction.restriction.restrictionType.valueOf(),
172172
)));
173173
return new MosaicGlobalRestriction(
174174
payload.compositeHash,
@@ -202,7 +202,7 @@ export class RestrictionHttp extends Http implements RestrictionRepository {
202202
new MosaicGlobalRestrictionItem(
203203
new MosaicId(restriction.restriction.referenceMosaicId),
204204
restriction.restriction.restrictionValue,
205-
restriction.restriction.restrictionType,
205+
restriction.restriction.restrictionType.valueOf(),
206206
)));
207207
return new MosaicGlobalRestriction(
208208
payload.mosaicRestrictionEntry.compositeHash,

src/infrastructure/api/accountRoutesApi.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Catapult REST Endpoints
1818
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
1919
*
20-
* The version of the OpenAPI document: 0.7.18
20+
* The version of the OpenAPI document: 0.7.19
2121
*
2222
*
2323
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -262,8 +262,6 @@ export class AccountRoutesApi {
262262
statusMessage: response.statusMessage,
263263
}, body: response.body });
264264
}
265-
266-
reject();
267265
}
268266
});
269267
});

src/infrastructure/api/apis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Catapult REST Endpoints
1818
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
1919
*
20-
* The version of the OpenAPI document: 0.7.18
20+
* The version of the OpenAPI document: 0.7.19
2121
*
2222
*
2323
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

src/infrastructure/api/blockRoutesApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Catapult REST Endpoints
1818
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
1919
*
20-
* The version of the OpenAPI document: 0.7.18
20+
* The version of the OpenAPI document: 0.7.19
2121
*
2222
*
2323
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

src/infrastructure/api/chainRoutesApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Catapult REST Endpoints
1818
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
1919
*
20-
* The version of the OpenAPI document: 0.7.18
20+
* The version of the OpenAPI document: 0.7.19
2121
*
2222
*
2323
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

src/infrastructure/api/diagnosticRoutesApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Catapult REST Endpoints
1818
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
1919
*
20-
* The version of the OpenAPI document: 0.7.18
20+
* The version of the OpenAPI document: 0.7.19
2121
*
2222
*
2323
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

src/infrastructure/api/metadataRoutesApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Catapult REST Endpoints
1818
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
1919
*
20-
* The version of the OpenAPI document: 0.7.18
20+
* The version of the OpenAPI document: 0.7.19
2121
*
2222
*
2323
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

src/infrastructure/api/mosaicRoutesApi.ts

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Catapult REST Endpoints
1818
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
1919
*
20-
* The version of the OpenAPI document: 0.7.18
20+
* The version of the OpenAPI document: 0.7.19
2121
*
2222
*
2323
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -29,6 +29,7 @@ import localVarRequest = require('request');
2929
import http = require('http');
3030

3131
/* tslint:disable:no-unused-locals */
32+
import { AccountIds } from '../model/accountIds';
3233
import { ModelError } from '../model/modelError';
3334
import { MosaicIds } from '../model/mosaicIds';
3435
import { MosaicInfoDTO } from '../model/mosaicInfoDTO';
@@ -205,6 +206,129 @@ export class MosaicRoutesApi {
205206
});
206207
});
207208
}
209+
/**
210+
* Gets an array of mosaics created for a given account address.
211+
* @summary Get mosaics created by an account
212+
* @param accountId Account public key or address.
213+
* @param pageSize Number of transactions to return for each request.
214+
* @param id Mosaic identifier up to which transactions are returned.
215+
*/
216+
public async getMosaicsFromAccount (accountId: string, pageSize?: number, id?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array<MosaicInfoDTO>; }> {
217+
const localVarPath = this.basePath + '/account/{accountId}/mosaics'
218+
.replace('{' + 'accountId' + '}', encodeURIComponent(String(accountId)));
219+
let localVarQueryParameters: any = {};
220+
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
221+
let localVarFormParams: any = {};
222+
223+
// verify required parameter 'accountId' is not null or undefined
224+
if (accountId === null || accountId === undefined) {
225+
throw new Error('Required parameter accountId was null or undefined when calling getMosaicsFromAccount.');
226+
}
227+
228+
if (pageSize !== undefined) {
229+
localVarQueryParameters['pageSize'] = ObjectSerializer.serialize(pageSize, "number");
230+
}
231+
232+
if (id !== undefined) {
233+
localVarQueryParameters['id'] = ObjectSerializer.serialize(id, "string");
234+
}
235+
236+
(<any>Object).assign(localVarHeaderParams, options.headers);
237+
238+
let localVarUseFormData = false;
239+
240+
let localVarRequestOptions: localVarRequest.Options = {
241+
method: 'GET',
242+
qs: localVarQueryParameters,
243+
headers: localVarHeaderParams,
244+
uri: localVarPath,
245+
useQuerystring: this._useQuerystring,
246+
json: true,
247+
};
248+
249+
let authenticationPromise = Promise.resolve();
250+
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
251+
return authenticationPromise.then(() => {
252+
if (Object.keys(localVarFormParams).length) {
253+
if (localVarUseFormData) {
254+
(<any>localVarRequestOptions).formData = localVarFormParams;
255+
} else {
256+
localVarRequestOptions.form = localVarFormParams;
257+
}
258+
}
259+
return new Promise<{ response: http.ClientResponse; body: Array<MosaicInfoDTO>; }>((resolve, reject) => {
260+
localVarRequest(localVarRequestOptions, (error, response, body) => {
261+
if (error) {
262+
reject(error);
263+
} else {
264+
body = ObjectSerializer.deserialize(body, "Array<MosaicInfoDTO>");
265+
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
266+
resolve({ response: response, body: body });
267+
} else {
268+
reject({ response: {
269+
statusCode: response.statusCode,
270+
statusMessage: response.statusMessage,
271+
}, body: response.body });
272+
}
273+
}
274+
});
275+
});
276+
});
277+
}
278+
/**
279+
* Gets mosaics created for a given array of addresses.
280+
* @summary Get mosaics created for given array of addresses
281+
* @param accountIds
282+
*/
283+
public async getMosaicsFromAccounts (accountIds?: AccountIds, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array<MosaicInfoDTO>; }> {
284+
const localVarPath = this.basePath + '/account/mosaics';
285+
let localVarQueryParameters: any = {};
286+
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
287+
let localVarFormParams: any = {};
288+
289+
(<any>Object).assign(localVarHeaderParams, options.headers);
290+
291+
let localVarUseFormData = false;
292+
293+
let localVarRequestOptions: localVarRequest.Options = {
294+
method: 'POST',
295+
qs: localVarQueryParameters,
296+
headers: localVarHeaderParams,
297+
uri: localVarPath,
298+
useQuerystring: this._useQuerystring,
299+
json: true,
300+
body: ObjectSerializer.serialize(accountIds, "AccountIds")
301+
};
302+
303+
let authenticationPromise = Promise.resolve();
304+
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
305+
return authenticationPromise.then(() => {
306+
if (Object.keys(localVarFormParams).length) {
307+
if (localVarUseFormData) {
308+
(<any>localVarRequestOptions).formData = localVarFormParams;
309+
} else {
310+
localVarRequestOptions.form = localVarFormParams;
311+
}
312+
}
313+
return new Promise<{ response: http.ClientResponse; body: Array<MosaicInfoDTO>; }>((resolve, reject) => {
314+
localVarRequest(localVarRequestOptions, (error, response, body) => {
315+
if (error) {
316+
reject(error);
317+
} else {
318+
body = ObjectSerializer.deserialize(body, "Array<MosaicInfoDTO>");
319+
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
320+
resolve({ response: response, body: body });
321+
} else {
322+
reject({ response: {
323+
statusCode: response.statusCode,
324+
statusMessage: response.statusMessage,
325+
}, body: response.body });
326+
}
327+
}
328+
});
329+
});
330+
});
331+
}
208332
/**
209333
* Returns friendly names for mosaics.
210334
* @summary Get readable names for a set of mosaics

0 commit comments

Comments
 (0)