@polymeshassociation/polymesh-sdk 22.0.0-alpha.3 → 22.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/CHANGELOG.md +9 -3
  2. package/api/client/AccountManagement.d.ts +1 -1
  3. package/api/client/AccountManagement.js +1 -1
  4. package/api/client/Claims.d.ts +3 -58
  5. package/api/client/Claims.d.ts.map +1 -1
  6. package/api/client/Claims.js +13 -121
  7. package/api/client/Claims.js.map +1 -1
  8. package/api/client/Network.d.ts +9 -60
  9. package/api/client/Network.d.ts.map +1 -1
  10. package/api/client/Network.js +9 -141
  11. package/api/client/Network.js.map +1 -1
  12. package/api/client/Polymesh.d.ts +0 -9
  13. package/api/client/Polymesh.d.ts.map +1 -1
  14. package/api/client/Polymesh.js +2 -26
  15. package/api/client/Polymesh.js.map +1 -1
  16. package/api/entities/Account/index.d.ts +5 -25
  17. package/api/entities/Account/index.d.ts.map +1 -1
  18. package/api/entities/Account/index.js +9 -92
  19. package/api/entities/Account/index.js.map +1 -1
  20. package/api/entities/Account/types.d.ts +1 -1
  21. package/api/entities/Account/types.d.ts.map +1 -1
  22. package/api/entities/Asset/index.d.ts +2 -17
  23. package/api/entities/Asset/index.d.ts.map +1 -1
  24. package/api/entities/Asset/index.js +11 -93
  25. package/api/entities/Asset/index.js.map +1 -1
  26. package/api/entities/Asset/types.d.ts +1 -1
  27. package/api/entities/Asset/types.d.ts.map +1 -1
  28. package/api/entities/DefaultTrustedClaimIssuer.d.ts +1 -8
  29. package/api/entities/DefaultTrustedClaimIssuer.d.ts.map +1 -1
  30. package/api/entities/DefaultTrustedClaimIssuer.js +3 -24
  31. package/api/entities/DefaultTrustedClaimIssuer.js.map +1 -1
  32. package/api/entities/DividendDistribution/index.d.ts +2 -18
  33. package/api/entities/DividendDistribution/index.d.ts.map +1 -1
  34. package/api/entities/DividendDistribution/index.js +4 -90
  35. package/api/entities/DividendDistribution/index.js.map +1 -1
  36. package/api/entities/Identity/AssetPermissions.d.ts +5 -34
  37. package/api/entities/Identity/AssetPermissions.d.ts.map +1 -1
  38. package/api/entities/Identity/AssetPermissions.js +18 -106
  39. package/api/entities/Identity/AssetPermissions.js.map +1 -1
  40. package/api/entities/Identity/index.d.ts +4 -21
  41. package/api/entities/Identity/index.d.ts.map +1 -1
  42. package/api/entities/Identity/index.js +5 -56
  43. package/api/entities/Identity/index.js.map +1 -1
  44. package/api/entities/Instruction/index.d.ts +2 -13
  45. package/api/entities/Instruction/index.d.ts.map +1 -1
  46. package/api/entities/Instruction/index.js +28 -81
  47. package/api/entities/Instruction/index.js.map +1 -1
  48. package/api/entities/NumberedPortfolio.d.ts +1 -8
  49. package/api/entities/NumberedPortfolio.d.ts.map +1 -1
  50. package/api/entities/NumberedPortfolio.js +5 -28
  51. package/api/entities/NumberedPortfolio.js.map +1 -1
  52. package/api/entities/Offering/index.d.ts +1 -14
  53. package/api/entities/Offering/index.d.ts.map +1 -1
  54. package/api/entities/Offering/index.js +2 -47
  55. package/api/entities/Offering/index.js.map +1 -1
  56. package/api/entities/Portfolio/index.d.ts +2 -19
  57. package/api/entities/Portfolio/index.d.ts.map +1 -1
  58. package/api/entities/Portfolio/index.js +15 -92
  59. package/api/entities/Portfolio/index.js.map +1 -1
  60. package/api/entities/Portfolio/types.d.ts +2 -1
  61. package/api/entities/Portfolio/types.d.ts.map +1 -1
  62. package/api/entities/Venue/index.js +2 -2
  63. package/api/entities/Venue/index.js.map +1 -1
  64. package/api/entities/Venue/types.d.ts +1 -1
  65. package/api/entities/Venue/types.d.ts.map +1 -1
  66. package/api/entities/common/namespaces/Authorizations.js +2 -2
  67. package/api/entities/common/namespaces/Authorizations.js.map +1 -1
  68. package/api/procedures/modifyClaims.d.ts.map +1 -1
  69. package/api/procedures/modifyClaims.js +15 -21
  70. package/api/procedures/modifyClaims.js.map +1 -1
  71. package/base/Context.d.ts +5 -73
  72. package/base/Context.d.ts.map +1 -1
  73. package/base/Context.js +39 -206
  74. package/base/Context.js.map +1 -1
  75. package/base/PolymeshTransactionBase.d.ts.map +1 -1
  76. package/base/PolymeshTransactionBase.js +3 -20
  77. package/base/PolymeshTransactionBase.js.map +1 -1
  78. package/middleware/{enumsV2.d.ts → enums.d.ts} +3 -3
  79. package/middleware/enums.d.ts.map +1 -0
  80. package/middleware/{enumsV2.js → enums.js} +20 -20
  81. package/middleware/enums.js.map +1 -0
  82. package/middleware/queries.d.ts +105 -42
  83. package/middleware/queries.d.ts.map +1 -1
  84. package/middleware/queries.js +841 -397
  85. package/middleware/queries.js.map +1 -1
  86. package/middleware/types.d.ts +30888 -1459
  87. package/middleware/types.d.ts.map +1 -1
  88. package/middleware/types.js +3212 -904
  89. package/middleware/types.js.map +1 -1
  90. package/middleware/typesV1.d.ts +13 -0
  91. package/middleware/typesV1.d.ts.map +1 -0
  92. package/middleware/typesV1.js +16 -0
  93. package/middleware/typesV1.js.map +1 -0
  94. package/npm-package/polymeshassociation-polymesh-sdk-22.0.0-alpha.5.tgz +0 -0
  95. package/package.json +3 -4
  96. package/types/index.d.ts +4 -4
  97. package/types/index.d.ts.map +1 -1
  98. package/types/index.js +7 -13
  99. package/types/index.js.map +1 -1
  100. package/types/internal.d.ts +1 -6
  101. package/types/internal.d.ts.map +1 -1
  102. package/types/internal.js.map +1 -1
  103. package/types/utils/index.d.ts +1 -2
  104. package/types/utils/index.d.ts.map +1 -1
  105. package/types/utils/index.js.map +1 -1
  106. package/utils/conversion.d.ts +9 -25
  107. package/utils/conversion.d.ts.map +1 -1
  108. package/utils/conversion.js +385 -433
  109. package/utils/conversion.js.map +1 -1
  110. package/utils/internal.d.ts +1 -1
  111. package/utils/internal.d.ts.map +1 -1
  112. package/utils/internal.js +2 -2
  113. package/utils/internal.js.map +1 -1
  114. package/middleware/enumsV2.d.ts.map +0 -1
  115. package/middleware/enumsV2.js.map +0 -1
  116. package/middleware/queriesV2.d.ts +0 -192
  117. package/middleware/queriesV2.d.ts.map +0 -1
  118. package/middleware/queriesV2.js +0 -1145
  119. package/middleware/queriesV2.js.map +0 -1
  120. package/middleware/typesV2.d.ts +0 -31094
  121. package/middleware/typesV2.d.ts.map +0 -1
  122. package/middleware/typesV2.js +0 -3215
  123. package/middleware/typesV2.js.map +0 -1
  124. package/npm-package/polymeshassociation-polymesh-sdk-22.0.0-alpha.3.tgz +0 -0
@@ -3,116 +3,153 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.tickerExternalAgentActions = exports.tickerExternalAgentHistory = exports.getHistoryOfPaymentEventsForCa = exports.getWithholdingTaxesOfCa = exports.investments = exports.settlements = exports.eventByAddedTrustedClaimIssuer = exports.heartbeat = exports.latestProcessedBlock = exports.proposal = exports.issuerDidsWithClaimsByTarget = exports.scopesByIdentity = exports.transactions = exports.tokensHeldByDid = exports.tokensByTrustedClaimIssuer = exports.proposals = exports.transactionByHash = exports.eventsByIndexedArgs = exports.eventByIndexedArgs = exports.didsWithClaims = exports.proposalVotes = void 0;
6
+ exports.authorizationsQuery = exports.polyxTransactionsQuery = exports.assetTransactionQuery = exports.portfolioMovementsQuery = exports.settlementsQuery = exports.assetHoldersQuery = exports.distributionPaymentsQuery = exports.distributionQuery = exports.tickerExternalAgentActionsQuery = exports.tickerExternalAgentHistoryQuery = exports.tickerExternalAgentsQuery = exports.assetQuery = exports.portfolioQuery = exports.trustingAssetsQuery = exports.trustedClaimIssuerQuery = exports.extrinsicsByArgs = exports.extrinsicByHash = exports.eventsByArgs = exports.instructionsByDidQuery = exports.instructionsQuery = exports.investmentsQuery = exports.claimsQuery = exports.claimsGroupingQuery = exports.latestSqVersionQuery = exports.metadataQuery = exports.heartbeatQuery = exports.latestBlockQuery = void 0;
7
7
  const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ const enums_1 = require("./enums");
9
+ const types_1 = require("./types");
8
10
  /**
9
11
  * @hidden
10
12
  *
11
- * Get the current voters list for given pipId
13
+ * Get the latest processed block number
12
14
  */
13
- function proposalVotes(variables) {
15
+ function latestBlockQuery() {
14
16
  const query = (0, graphql_tag_1.default) `
15
- query ProposalVotesQuery(
16
- $pipId: Int!
17
- $vote: Boolean!
18
- $count: Int
19
- $skip: Int
20
- $orderBy: ProposalVotesOrderByInput
21
- ) {
22
- proposalVotes(pipId: $pipId, vote: $vote, count: $count, skip: $skip, orderBy: $orderBy) {
23
- blockId
24
- eventIdx
25
- account
26
- vote
27
- weight
17
+ query latestBlock {
18
+ blocks(first: 1, orderBy: [${types_1.BlocksOrderBy.BlockIdDesc}]) {
19
+ nodes {
20
+ blockId
21
+ }
28
22
  }
29
23
  }
30
24
  `;
31
25
  return {
32
26
  query,
33
- variables,
27
+ variables: undefined,
34
28
  };
35
29
  }
36
- exports.proposalVotes = proposalVotes;
30
+ exports.latestBlockQuery = latestBlockQuery;
37
31
  /**
38
32
  * @hidden
39
33
  *
40
- * Get all dids with at least one claim for a given scope and from one the given trustedClaimIssuers
34
+ * Middleware V2 heartbeat
41
35
  */
42
- function didsWithClaims(variables) {
36
+ function heartbeatQuery() {
43
37
  const query = (0, graphql_tag_1.default) `
44
- query DidsWithClaimsQuery(
45
- $dids: [String!]
46
- $scope: ScopeInput
47
- $trustedClaimIssuers: [String!]
48
- $claimTypes: [ClaimTypeEnum!]
49
- $includeExpired: Boolean
50
- $count: Int
51
- $skip: Int
52
- ) {
53
- didsWithClaims(
54
- dids: $dids
55
- scope: $scope
56
- trustedClaimIssuers: $trustedClaimIssuers
57
- claimTypes: $claimTypes
58
- includeExpired: $includeExpired
59
- count: $count
60
- skip: $skip
61
- ) {
62
- totalCount
63
- items {
64
- did
65
- claims {
66
- targetDID
67
- issuer
68
- issuance_date
69
- last_update_date
70
- expiry
71
- type
72
- jurisdiction
73
- cdd_id
74
- scope {
75
- type
76
- value
77
- }
78
- }
38
+ query {
39
+ block(id: "1") {
40
+ id
41
+ }
42
+ }
43
+ `;
44
+ return {
45
+ query,
46
+ variables: undefined,
47
+ };
48
+ }
49
+ exports.heartbeatQuery = heartbeatQuery;
50
+ /**
51
+ * @hidden
52
+ *
53
+ * Get details about the SubQuery indexer
54
+ */
55
+ function metadataQuery() {
56
+ const query = (0, graphql_tag_1.default) `
57
+ query Metadata {
58
+ _metadata {
59
+ chain
60
+ specName
61
+ genesisHash
62
+ lastProcessedHeight
63
+ lastProcessedTimestamp
64
+ targetHeight
65
+ indexerHealthy
66
+ indexerNodeVersion
67
+ queryNodeVersion
68
+ dynamicDatasources
69
+ }
70
+ }
71
+ `;
72
+ return {
73
+ query,
74
+ variables: undefined,
75
+ };
76
+ }
77
+ exports.metadataQuery = metadataQuery;
78
+ /**
79
+ * @hidden
80
+ *
81
+ * Get details about the latest Subquery version
82
+ */
83
+ function latestSqVersionQuery() {
84
+ const query = (0, graphql_tag_1.default) `
85
+ query SubqueryVersions {
86
+ subqueryVersions(orderBy: [${types_1.SubqueryVersionsOrderBy.UpdatedAtDesc}], first: 1) {
87
+ nodes {
88
+ id
89
+ version
90
+ createdAt
91
+ updatedAt
79
92
  }
80
93
  }
81
94
  }
82
95
  `;
83
96
  return {
84
97
  query,
85
- variables,
98
+ variables: undefined,
99
+ };
100
+ }
101
+ exports.latestSqVersionQuery = latestSqVersionQuery;
102
+ /**
103
+ * @hidden
104
+ */
105
+ function createClaimsFilters(variables) {
106
+ const args = ['$size: Int, $start: Int'];
107
+ const filters = ['revokeDate: { isNull: true }'];
108
+ const { dids, claimTypes, trustedClaimIssuers, scope, includeExpired } = variables;
109
+ if (dids === null || dids === void 0 ? void 0 : dids.length) {
110
+ args.push('$dids: [String!]');
111
+ filters.push('targetId: { in: $dids }');
112
+ }
113
+ if (claimTypes) {
114
+ args.push('$claimTypes: [ClaimTypeEnum!]!');
115
+ filters.push('type: { in: $claimTypes }');
116
+ }
117
+ if (trustedClaimIssuers === null || trustedClaimIssuers === void 0 ? void 0 : trustedClaimIssuers.length) {
118
+ args.push('$trustedClaimIssuers: [String!]');
119
+ filters.push('issuerId: { in: $trustedClaimIssuers }');
120
+ }
121
+ if (scope !== undefined) {
122
+ args.push('$scope: JSON!');
123
+ filters.push('scope: { contains: $scope }');
124
+ }
125
+ if (!includeExpired) {
126
+ args.push('$expiryTimestamp: BigFloat');
127
+ filters.push('or: [{ filterExpiry: { lessThan: $expiryTimestamp } }, { expiry: { isNull: true } }]');
128
+ }
129
+ return {
130
+ args: `(${args.join()})`,
131
+ filter: `filter: { ${filters.join()} },`,
86
132
  };
87
133
  }
88
- exports.didsWithClaims = didsWithClaims;
89
134
  /**
90
135
  * @hidden
91
136
  *
92
- * Get a single event by any of its indexed arguments
137
+ * Get all dids with at least one claim for a given scope and from one of the given trusted claim issuers
93
138
  */
94
- function eventByIndexedArgs(variables) {
139
+ function claimsGroupingQuery(variables, orderBy = types_1.ClaimsOrderBy.TargetIdAsc, groupBy = types_1.ClaimsGroupBy.TargetId) {
140
+ const { args, filter } = createClaimsFilters(variables);
95
141
  const query = (0, graphql_tag_1.default) `
96
- query EventByIndexedArgsQuery(
97
- $moduleId: ModuleIdEnum!
98
- $eventId: EventIdEnum!
99
- $eventArg0: String
100
- $eventArg1: String
101
- $eventArg2: String
102
- ) {
103
- eventByIndexedArgs(
104
- moduleId: $moduleId
105
- eventId: $eventId
106
- eventArg0: $eventArg0
107
- eventArg1: $eventArg1
108
- eventArg2: $eventArg2
142
+ query claimsGroupingQuery
143
+ ${args}
144
+ {
145
+ claims(
146
+ ${filter}
147
+ orderBy: [${orderBy}]
148
+ first: $size
149
+ offset: $start
109
150
  ) {
110
- block_id
111
- event_idx
112
- extrinsic_idx
113
- block {
114
- datetime
115
- hash
151
+ groupedAggregates(groupBy: [${groupBy}], having: {}) {
152
+ keys
116
153
  }
117
154
  }
118
155
  }
@@ -122,152 +159,294 @@ function eventByIndexedArgs(variables) {
122
159
  variables,
123
160
  };
124
161
  }
125
- exports.eventByIndexedArgs = eventByIndexedArgs;
162
+ exports.claimsGroupingQuery = claimsGroupingQuery;
126
163
  /**
127
164
  * @hidden
128
165
  *
129
- * Get all events by any of its indexed arguments
166
+ * Get all claims that a given target DID has, with a given scope and from one of the given trustedClaimIssuers
130
167
  */
131
- function eventsByIndexedArgs(variables) {
168
+ function claimsQuery(filters, size, start) {
169
+ const { args, filter } = createClaimsFilters(filters);
132
170
  const query = (0, graphql_tag_1.default) `
133
- query EventsByIndexedArgsQuery(
134
- $moduleId: ModuleIdEnum!
135
- $eventId: EventIdEnum!
136
- $eventArg0: String
137
- $eventArg1: String
138
- $eventArg2: String
139
- $count: Int
140
- $skip: Int
141
- ) {
142
- eventsByIndexedArgs(
143
- moduleId: $moduleId
144
- eventId: $eventId
145
- eventArg0: $eventArg0
146
- eventArg1: $eventArg1
147
- eventArg2: $eventArg2
148
- count: $count
149
- skip: $skip
171
+ query ClaimsQuery
172
+ ${args}
173
+ {
174
+ claims(
175
+ ${filter}
176
+ orderBy: [${types_1.ClaimsOrderBy.TargetIdAsc}, ${types_1.ClaimsOrderBy.CreatedAtAsc}, ${types_1.ClaimsOrderBy.CreatedBlockIdAsc}, ${types_1.ClaimsOrderBy.EventIdxAsc}]
177
+ first: $size
178
+ offset: $start
179
+ ) {
180
+ totalCount
181
+ nodes {
182
+ targetId
183
+ type
184
+ scope
185
+ cddId
186
+ issuerId
187
+ issuanceDate
188
+ lastUpdateDate
189
+ expiry
190
+ jurisdiction
191
+ }
192
+ }
193
+ }
194
+ `;
195
+ return {
196
+ query,
197
+ variables: Object.assign(Object.assign({}, filters), { expiryTimestamp: filters.includeExpired ? undefined : new Date().getTime(), size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
198
+ };
199
+ }
200
+ exports.claimsQuery = claimsQuery;
201
+ /**
202
+ * @hidden
203
+ *
204
+ * Get all investments for a given offering
205
+ */
206
+ function investmentsQuery(filters, size, start) {
207
+ const query = (0, graphql_tag_1.default) `
208
+ query InvestmentsQuery($stoId: Int!, $offeringToken: String!, $size: Int, $start: Int) {
209
+ investments(
210
+ filter: { stoId: { equalTo: $stoId }, offeringToken: { equalTo: $offeringToken } }
211
+ first: $size
212
+ offset: $start
213
+ orderBy: [${types_1.InvestmentsOrderBy.CreatedAtAsc}, ${types_1.InvestmentsOrderBy.CreatedBlockIdAsc}]
150
214
  ) {
151
- block_id
152
- event_idx
153
- extrinsic_idx
154
- block {
155
- datetime
156
- hash
215
+ totalCount
216
+ nodes {
217
+ investorId
218
+ offeringToken
219
+ raiseToken
220
+ offeringTokenAmount
221
+ raiseTokenAmount
157
222
  }
158
223
  }
159
224
  }
160
225
  `;
161
226
  return {
162
227
  query,
163
- variables,
228
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
229
+ };
230
+ }
231
+ exports.investmentsQuery = investmentsQuery;
232
+ /**
233
+ * Create args and filters to be supplied to GQL query
234
+ *
235
+ * @param filters - filters to be applied
236
+ * @param typeMap - Map defining the types corresponding to each attribute. All missing attributes whose types are not defined are considered to be `String`
237
+ *
238
+ * @hidden
239
+ */
240
+ function createArgsAndFilters(filters, typeMap) {
241
+ const args = ['$start: Int', '$size: Int'];
242
+ const gqlFilters = [];
243
+ Object.keys(filters).forEach(attribute => {
244
+ if (filters[attribute]) {
245
+ const type = typeMap[attribute] || 'String';
246
+ const middlewareType = enums_1.middlewareEnumMap[type] || type;
247
+ args.push(`$${attribute}: ${middlewareType}!`);
248
+ gqlFilters.push(`${attribute}: { equalTo: $${attribute} }`);
249
+ }
250
+ });
251
+ return {
252
+ args: `(${args.join()})`,
253
+ filter: gqlFilters.length ? `filter: { ${gqlFilters.join()} }` : '',
164
254
  };
165
255
  }
166
- exports.eventsByIndexedArgs = eventsByIndexedArgs;
167
256
  /**
168
257
  * @hidden
169
258
  *
170
- * Get a transaction by hash
259
+ * Get a specific instruction within a venue for a specific event
171
260
  */
172
- function transactionByHash(variables) {
261
+ function instructionsQuery(filters, size, start) {
262
+ const { args, filter } = createArgsAndFilters(filters, {
263
+ eventId: 'EventIdEnum',
264
+ status: 'InstructionStatusEnum',
265
+ });
173
266
  const query = (0, graphql_tag_1.default) `
174
- query TransactionByHashQuery($transactionHash: String) {
175
- transactionByHash(transactionHash: $transactionHash) {
176
- block_id
177
- extrinsic_idx
178
- address
179
- nonce
180
- module_id
181
- call_id
182
- params
183
- success
184
- spec_version_id
185
- extrinsic_hash
186
- block {
187
- hash
267
+ query InstructionsQuery
268
+ ${args}
269
+ {
270
+ instructions(
271
+ ${filter}
272
+ first: $size
273
+ offset: $start
274
+ orderBy: [${types_1.InstructionsOrderBy.CreatedAtDesc}, ${types_1.InstructionsOrderBy.IdDesc}]
275
+ ) {
276
+ totalCount
277
+ nodes {
278
+ id
279
+ eventIdx
280
+ eventId
281
+ status
282
+ settlementType
283
+ venueId
284
+ endBlock
285
+ tradeDate
286
+ valueDate
287
+ legs {
288
+ nodes {
289
+ fromId
290
+ from {
291
+ identityId
292
+ number
293
+ }
294
+ toId
295
+ to {
296
+ identityId
297
+ number
298
+ }
299
+ assetId
300
+ amount
301
+ addresses
302
+ }
303
+ }
304
+ memo
305
+ createdBlock {
306
+ blockId
307
+ hash
308
+ datetime
309
+ }
310
+ updatedBlock {
311
+ blockId
312
+ hash
313
+ datetime
314
+ }
188
315
  }
189
316
  }
190
317
  }
191
318
  `;
192
319
  return {
193
320
  query,
194
- variables,
321
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
195
322
  };
196
323
  }
197
- exports.transactionByHash = transactionByHash;
324
+ exports.instructionsQuery = instructionsQuery;
198
325
  /**
199
326
  * @hidden
200
327
  *
201
- * Get all proposals optionally filtered by pipId, proposer or state
328
+ * Get Instructions where an identity is involved
202
329
  */
203
- function proposals(variables) {
330
+ function instructionsByDidQuery(identityId) {
204
331
  const query = (0, graphql_tag_1.default) `
205
- query ProposalsQuery(
206
- $pipIds: [Int!]
207
- $proposers: [String!]
208
- $states: [ProposalState!]
209
- $count: Int
210
- $skip: Int
211
- $orderBy: ProposalOrderByInput
212
- ) {
213
- proposals(
214
- pipIds: $pipIds
215
- proposers: $proposers
216
- states: $states
217
- count: $count
218
- skip: $skip
219
- orderBy: $orderBy
332
+ query InstructionsByDidQuery($fromId: String!, $toId: String!)
333
+ {
334
+ legs(
335
+ filter: { or: [{ fromId: { startsWith: $fromId } }, { toId: { startsWith: $toId } }] }
336
+ orderBy: [${types_1.LegsOrderBy.CreatedAtAsc}, ${types_1.LegsOrderBy.InstructionIdAsc}]
220
337
  ) {
221
- pipId
222
- proposer
223
- createdAt
224
- url
225
- description
226
- coolOffEndBlock
227
- endBlock
228
- proposal
229
- lastState
230
- lastStateUpdatedAt
231
- totalVotes
232
- totalAyesWeight
233
- totalNaysWeight
338
+ nodes {
339
+ instruction {
340
+ id
341
+ eventIdx
342
+ eventId
343
+ status
344
+ settlementType
345
+ venueId
346
+ endBlock
347
+ tradeDate
348
+ valueDate
349
+ legs {
350
+ nodes {
351
+ fromId
352
+ from {
353
+ identityId
354
+ number
355
+ }
356
+ toId
357
+ to {
358
+ identityId
359
+ number
360
+ }
361
+ assetId
362
+ amount
363
+ addresses
364
+ }
365
+ }
366
+ memo
367
+ createdBlock {
368
+ blockId
369
+ hash
370
+ datetime
371
+ }
372
+ updatedBlock {
373
+ blockId
374
+ hash
375
+ datetime
376
+ }
377
+ }
378
+ }
234
379
  }
235
380
  }
236
381
  `;
237
382
  return {
238
383
  query,
239
- variables,
384
+ variables: { fromId: `${identityId}/`, toId: `${identityId}/` },
240
385
  };
241
386
  }
242
- exports.proposals = proposals;
387
+ exports.instructionsByDidQuery = instructionsByDidQuery;
243
388
  /**
244
389
  * @hidden
245
390
  *
246
- * Get the tickers of all the Assets for which the passed DID is a trusted claim issuer
391
+ * Get a single event by any of its indexed arguments
247
392
  */
248
- function tokensByTrustedClaimIssuer(variables) {
393
+ function eventsByArgs(filters, size, start) {
394
+ const { args, filter } = createArgsAndFilters(filters, {
395
+ moduleId: 'ModuleIdEnum',
396
+ eventId: 'EventIdEnum',
397
+ });
249
398
  const query = (0, graphql_tag_1.default) `
250
- query TokensByTrustedClaimIssuerQuery($claimIssuerDid: String!) {
251
- tokensByTrustedClaimIssuer(claimIssuerDid: $claimIssuerDid)
399
+ query EventsQuery
400
+ ${args}
401
+ {
402
+ events(
403
+ ${filter}
404
+ orderBy: [${types_1.EventsOrderBy.CreatedAtAsc}, ${types_1.EventsOrderBy.BlockIdAsc}]
405
+ first: $size
406
+ offset: $start
407
+ ) {
408
+ nodes {
409
+ eventIdx
410
+ block {
411
+ blockId
412
+ hash
413
+ datetime
414
+ }
415
+ }
416
+ }
252
417
  }
253
418
  `;
254
419
  return {
255
420
  query,
256
- variables,
421
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
257
422
  };
258
423
  }
259
- exports.tokensByTrustedClaimIssuer = tokensByTrustedClaimIssuer;
424
+ exports.eventsByArgs = eventsByArgs;
260
425
  /**
261
426
  * @hidden
262
427
  *
263
- * Get all tickers of Assets that were held at some point by the given did
428
+ * Get a transaction by hash
264
429
  */
265
- function tokensHeldByDid(variables) {
430
+ function extrinsicByHash(variables) {
266
431
  const query = (0, graphql_tag_1.default) `
267
- query TokensHeldByDidQuery($did: String!, $count: Int, $skip: Int, $order: Order) {
268
- tokensHeldByDid(did: $did, count: $count, skip: $skip, order: $order) {
269
- totalCount
270
- items
432
+ query TransactionByHashQuery($extrinsicHash: String!) {
433
+ extrinsics(filter: { extrinsicHash: { equalTo: $extrinsicHash } }) {
434
+ nodes {
435
+ extrinsicIdx
436
+ address
437
+ nonce
438
+ moduleId
439
+ callId
440
+ paramsTxt
441
+ success
442
+ specVersionId
443
+ extrinsicHash
444
+ block {
445
+ blockId
446
+ hash
447
+ datetime
448
+ }
449
+ }
271
450
  }
272
451
  }
273
452
  `;
@@ -276,46 +455,40 @@ function tokensHeldByDid(variables) {
276
455
  variables,
277
456
  };
278
457
  }
279
- exports.tokensHeldByDid = tokensHeldByDid;
458
+ exports.extrinsicByHash = extrinsicByHash;
280
459
  /**
281
460
  * @hidden
282
461
  *
283
462
  * Get transactions
284
463
  */
285
- function transactions(variables) {
464
+ function extrinsicsByArgs(filters, size, start, orderBy = types_1.ExtrinsicsOrderBy.BlockIdAsc) {
465
+ const { args, filter } = createArgsAndFilters(filters, {
466
+ moduleId: 'ModuleIdEnum',
467
+ callId: 'CallIdEnum',
468
+ success: 'Int',
469
+ });
286
470
  const query = (0, graphql_tag_1.default) `
287
- query TransactionsQuery(
288
- $block_id: Int
289
- $address: String
290
- $module_id: ModuleIdEnum
291
- $call_id: CallIdEnum
292
- $success: Boolean
293
- $count: Int
294
- $skip: Int
295
- $orderBy: TransactionOrderByInput
296
- ) {
297
- transactions(
298
- block_id: $block_id
299
- address: $address
300
- module_id: $module_id
301
- call_id: $call_id
302
- success: $success
303
- count: $count
304
- skip: $skip
305
- orderBy: $orderBy
471
+ query TransactionsQuery
472
+ ${args}
473
+ {
474
+ extrinsics(
475
+ ${filter}
476
+ orderBy: [${orderBy}]
477
+ first: $size
478
+ offset: $start
306
479
  ) {
307
480
  totalCount
308
- items {
309
- block_id
310
- extrinsic_idx
481
+ nodes {
482
+ blockId
483
+ extrinsicIdx
311
484
  address
312
485
  nonce
313
- module_id
314
- call_id
315
- params
486
+ moduleId
487
+ callId
488
+ paramsTxt
316
489
  success
317
- spec_version_id
318
- extrinsic_hash
490
+ specVersionId
491
+ extrinsicHash
319
492
  block {
320
493
  hash
321
494
  }
@@ -325,24 +498,30 @@ function transactions(variables) {
325
498
  `;
326
499
  return {
327
500
  query,
328
- variables,
501
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
329
502
  };
330
503
  }
331
- exports.transactions = transactions;
504
+ exports.extrinsicsByArgs = extrinsicsByArgs;
332
505
  /**
333
506
  * @hidden
334
507
  *
335
- * Get the scopes (and ticker, if applicable) of claims issued on an Identity
508
+ * Get an trusted claim issuer event for an asset and an issuer
336
509
  */
337
- function scopesByIdentity(variables) {
510
+ function trustedClaimIssuerQuery(variables) {
338
511
  const query = (0, graphql_tag_1.default) `
339
- query ScopesByIdentityQuery($did: String!) {
340
- scopesByIdentity(did: $did) {
341
- scope {
342
- type
343
- value
512
+ query TrustedClaimIssuerQuery($assetId: String!, $issuer: String!) {
513
+ trustedClaimIssuers(
514
+ filter: { assetId: { equalTo: $assetId }, issuer: { equalTo: $issuer } },
515
+ orderBy: [${types_1.TrustedClaimIssuersOrderBy.CreatedAtDesc}, ${types_1.TrustedClaimIssuersOrderBy.CreatedBlockIdDesc}]
516
+ ) {
517
+ nodes {
518
+ eventIdx
519
+ createdBlock {
520
+ blockId
521
+ datetime
522
+ hash
523
+ }
344
524
  }
345
- ticker
346
525
  }
347
526
  }
348
527
  `;
@@ -351,47 +530,21 @@ function scopesByIdentity(variables) {
351
530
  variables,
352
531
  };
353
532
  }
354
- exports.scopesByIdentity = scopesByIdentity;
533
+ exports.trustedClaimIssuerQuery = trustedClaimIssuerQuery;
355
534
  /**
356
535
  * @hidden
357
536
  *
358
- * Get issuer dids with at least one claim for given target
537
+ * Get an trusted claim issuer event for an asset and an issuer
359
538
  */
360
- function issuerDidsWithClaimsByTarget(variables) {
539
+ function trustingAssetsQuery(variables) {
361
540
  const query = (0, graphql_tag_1.default) `
362
- query IssuerDidsWithClaimsByTargetQuery(
363
- $target: String!
364
- $scope: ScopeInput
365
- $trustedClaimIssuers: [String!]
366
- $includeExpired: Boolean
367
- $count: Int
368
- $skip: Int
369
- ) {
370
- issuerDidsWithClaimsByTarget(
371
- target: $target
372
- scope: $scope
373
- trustedClaimIssuers: $trustedClaimIssuers
374
- includeExpired: $includeExpired
375
- count: $count
376
- skip: $skip
541
+ query TrustedClaimIssuerQuery($issuer: String!) {
542
+ trustedClaimIssuers(
543
+ filter: { issuer: { equalTo: $issuer } },
544
+ orderBy: [${types_1.TrustedClaimIssuersOrderBy.AssetIdAsc}]
377
545
  ) {
378
- totalCount
379
- items {
380
- did
381
- claims {
382
- targetDID
383
- issuer
384
- issuance_date
385
- last_update_date
386
- expiry
387
- type
388
- jurisdiction
389
- cdd_id
390
- scope {
391
- type
392
- value
393
- }
394
- }
546
+ nodes {
547
+ assetId
395
548
  }
396
549
  }
397
550
  }
@@ -401,29 +554,24 @@ function issuerDidsWithClaimsByTarget(variables) {
401
554
  variables,
402
555
  };
403
556
  }
404
- exports.issuerDidsWithClaimsByTarget = issuerDidsWithClaimsByTarget;
557
+ exports.trustingAssetsQuery = trustingAssetsQuery;
405
558
  /**
406
559
  * @hidden
407
560
  *
408
- * Get a proposal by its pipId
561
+ * Get portfolio details for a given DID and portfolio number
409
562
  */
410
- function proposal(variables) {
563
+ function portfolioQuery(variables) {
411
564
  const query = (0, graphql_tag_1.default) `
412
- query ProposalQuery($pipId: Int!) {
413
- proposal(pipId: $pipId) {
414
- pipId
415
- proposer
416
- createdAt
417
- url
418
- description
419
- coolOffEndBlock
420
- endBlock
421
- proposal
422
- lastState
423
- lastStateUpdatedAt
424
- totalVotes
425
- totalAyesWeight
426
- totalNaysWeight
565
+ query PortfolioQuery($identityId: String!, $number: Int!) {
566
+ portfolios(filter: { identityId: { equalTo: $identityId }, number: { equalTo: $number } }) {
567
+ nodes {
568
+ eventIdx
569
+ createdBlock {
570
+ blockId
571
+ datetime
572
+ hash
573
+ }
574
+ }
427
575
  }
428
576
  }
429
577
  `;
@@ -432,58 +580,84 @@ function proposal(variables) {
432
580
  variables,
433
581
  };
434
582
  }
435
- exports.proposal = proposal;
583
+ exports.portfolioQuery = portfolioQuery;
436
584
  /**
437
585
  * @hidden
438
586
  *
439
- * Fetch the number of the latest block that has been processed by the middleware
587
+ * Get Asset details for a given ticker
440
588
  */
441
- function latestProcessedBlock() {
589
+ function assetQuery(variables) {
442
590
  const query = (0, graphql_tag_1.default) `
443
- query {
444
- latestBlock {
445
- id
591
+ query AssetQuery($ticker: String!) {
592
+ assets(filter: { ticker: { equalTo: $ticker } }) {
593
+ nodes {
594
+ eventIdx
595
+ createdBlock {
596
+ blockId
597
+ datetime
598
+ hash
599
+ }
600
+ }
446
601
  }
447
602
  }
448
603
  `;
449
604
  return {
450
605
  query,
451
- variables: undefined,
606
+ variables,
452
607
  };
453
608
  }
454
- exports.latestProcessedBlock = latestProcessedBlock;
609
+ exports.assetQuery = assetQuery;
455
610
  /**
456
611
  * @hidden
457
612
  *
458
- * Middleware heartbeat
613
+ * Get the event details when external agent added for a ticker
459
614
  */
460
- function heartbeat() {
615
+ function tickerExternalAgentsQuery(variables) {
461
616
  const query = (0, graphql_tag_1.default) `
462
- query {
463
- heartbeat
617
+ query TickerExternalAgentQuery($assetId: String!) {
618
+ tickerExternalAgents(
619
+ filter: { assetId: { equalTo: $assetId } }
620
+ orderBy: [${types_1.TickerExternalAgentsOrderBy.CreatedAtDesc}, ${types_1.TickerExternalAgentsOrderBy.CreatedBlockIdDesc}]
621
+ first: 1
622
+ ) {
623
+ nodes {
624
+ eventIdx
625
+ createdBlock {
626
+ blockId
627
+ datetime
628
+ hash
629
+ }
630
+ }
631
+ }
464
632
  }
465
633
  `;
466
634
  return {
467
635
  query,
468
- variables: undefined,
636
+ variables,
469
637
  };
470
638
  }
471
- exports.heartbeat = heartbeat;
639
+ exports.tickerExternalAgentsQuery = tickerExternalAgentsQuery;
472
640
  /**
473
641
  * @hidden
474
642
  *
475
- * Get an added trusted claim issuer event by its indexed arguments
643
+ * Get the transaction history of each external agent of an Asset
476
644
  */
477
- function eventByAddedTrustedClaimIssuer(variables) {
645
+ function tickerExternalAgentHistoryQuery(variables) {
478
646
  const query = (0, graphql_tag_1.default) `
479
- query EventByAddedTrustedClaimIssuerQuery($ticker: String!, $identityId: String!) {
480
- eventByAddedTrustedClaimIssuer(ticker: $ticker, identityId: $identityId) {
481
- block_id
482
- event_idx
483
- extrinsic_idx
484
- block {
485
- datetime
486
- hash
647
+ query TickerExternalAgentHistoryQuery($assetId: String!) {
648
+ tickerExternalAgentHistories(
649
+ filter: { assetId: { equalTo: $assetId } }
650
+ orderBy: [${types_1.TickerExternalAgentHistoriesOrderBy.CreatedAtAsc}, ${types_1.TickerExternalAgentHistoriesOrderBy.CreatedBlockIdAsc}]
651
+ ) {
652
+ nodes {
653
+ identityId
654
+ assetId
655
+ eventIdx
656
+ createdBlock {
657
+ blockId
658
+ hash
659
+ datetime
660
+ }
487
661
  }
488
662
  }
489
663
  }
@@ -493,92 +667,200 @@ function eventByAddedTrustedClaimIssuer(variables) {
493
667
  variables,
494
668
  };
495
669
  }
496
- exports.eventByAddedTrustedClaimIssuer = eventByAddedTrustedClaimIssuer;
670
+ exports.tickerExternalAgentHistoryQuery = tickerExternalAgentHistoryQuery;
497
671
  /**
498
672
  * @hidden
499
673
  *
500
- * Get Settlements where a Portfolio is involved
674
+ * Get list of Events triggered by actions (from the set of actions that can only be performed by external agents) that have been performed on a specific Asset
501
675
  */
502
- function settlements(variables) {
676
+ function tickerExternalAgentActionsQuery(filters, size, start) {
677
+ const { args, filter } = createArgsAndFilters(filters, { eventId: 'EventIdEnum' });
503
678
  const query = (0, graphql_tag_1.default) `
504
- query SettlementsQuery(
505
- $identityId: String!
506
- $portfolioNumber: String
507
- $addressFilter: String
508
- $tickerFilter: String
509
- $count: Int
510
- $skip: Int
511
- ) {
512
- settlements(
513
- identityId: $identityId
514
- portfolioNumber: $portfolioNumber
515
- addressFilter: $addressFilter
516
- tickerFilter: $tickerFilter
517
- count: $count
518
- skip: $skip
679
+ query TickerExternalAgentActionsQuery
680
+ ${args}
681
+ {
682
+ tickerExternalAgentActions(
683
+ ${filter}
684
+ first: $size
685
+ offset: $start
686
+ orderBy: [${types_1.TickerExternalAgentActionsOrderBy.CreatedAtDesc}, ${types_1.TickerExternalAgentActionsOrderBy.CreatedBlockIdDesc}]
519
687
  ) {
520
688
  totalCount
521
- items {
522
- block_id
523
- result
524
- addresses
525
- legs {
526
- ticker
527
- amount
528
- direction
529
- from {
530
- did
531
- kind
532
- }
533
- to {
534
- did
535
- kind
536
- }
689
+ nodes {
690
+ eventIdx
691
+ palletName
692
+ eventId
693
+ callerId
694
+ createdBlock {
695
+ blockId
696
+ datetime
697
+ hash
537
698
  }
538
699
  }
539
700
  }
540
701
  }
702
+ `;
703
+ return {
704
+ query,
705
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
706
+ };
707
+ }
708
+ exports.tickerExternalAgentActionsQuery = tickerExternalAgentActionsQuery;
709
+ /**
710
+ * @hidden
711
+ *
712
+ * Get distribution details for a CAId
713
+ */
714
+ function distributionQuery(variables) {
715
+ const query = (0, graphql_tag_1.default) `
716
+ query DistributionQuery($id: String!) {
717
+ distribution(id: $id) {
718
+ taxes
719
+ }
720
+ }
541
721
  `;
542
722
  return {
543
723
  query,
544
724
  variables,
545
725
  };
546
726
  }
547
- exports.settlements = settlements;
727
+ exports.distributionQuery = distributionQuery;
548
728
  /**
549
729
  * @hidden
550
730
  *
551
- * Get all investments for a given offering
731
+ * Get history of claims for a distribution
552
732
  */
553
- function investments(variables) {
733
+ function distributionPaymentsQuery(filters, size, start) {
554
734
  const query = (0, graphql_tag_1.default) `
555
- query InvestmentsQuery($stoId: Int!, $ticker: String!, $count: Int, $skip: Int) {
556
- investments(stoId: $stoId, ticker: $ticker, count: $count, skip: $skip) {
735
+ query DistributionPaymentQuery($distributionId: String!, $size: Int, $start: Int) {
736
+ distributionPayments(
737
+ filter: { distributionId: { equalTo: $distributionId } }
738
+ first: $size
739
+ offset: $start
740
+ ) {
557
741
  totalCount
558
- items {
559
- investor
560
- offeringTokenAmount
561
- raiseTokenAmount
742
+ nodes {
743
+ eventId
744
+ targetId
745
+ datetime
746
+ amount
747
+ tax
748
+ createdBlock {
749
+ blockId
750
+ hash
751
+ }
562
752
  }
563
753
  }
564
754
  }
565
755
  `;
566
756
  return {
567
757
  query,
758
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
759
+ };
760
+ }
761
+ exports.distributionPaymentsQuery = distributionPaymentsQuery;
762
+ /**
763
+ * @hidden
764
+ *
765
+ * Get asset held by a DID
766
+ */
767
+ function assetHoldersQuery(filters, size, start, orderBy = types_1.AssetHoldersOrderBy.AssetIdAsc) {
768
+ const query = (0, graphql_tag_1.default) `
769
+ query AssetHoldersQuery($identityId: String!, $size: Int, $start: Int) {
770
+ assetHolders(
771
+ filter: { identityId: { equalTo: $identityId } }
772
+ first: $size
773
+ offset: $start
774
+ orderBy: [${orderBy}]
775
+ ) {
776
+ totalCount
777
+ nodes {
778
+ assetId
779
+ }
780
+ }
781
+ }
782
+ `;
783
+ return {
784
+ query,
785
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
786
+ };
787
+ }
788
+ exports.assetHoldersQuery = assetHoldersQuery;
789
+ /**
790
+ * @hidden
791
+ */
792
+ function createLegFilters({ identityId, portfolioId, ticker, address }) {
793
+ const args = ['$fromId: String!, $toId: String!'];
794
+ const fromIdFilters = ['fromId: { equalTo: $fromId }'];
795
+ const toIdFilters = ['toId: { equalTo: $toId }'];
796
+ const portfolioNumber = portfolioId ? portfolioId.toNumber() : 0;
797
+ const variables = {
798
+ fromId: `${identityId}/${portfolioNumber}`,
799
+ toId: `${identityId}/${portfolioNumber}`,
800
+ };
801
+ if (ticker) {
802
+ variables.assetId = ticker;
803
+ args.push('$assetId: String!');
804
+ const assetIdFilter = 'assetId: { equalTo: $assetId }';
805
+ toIdFilters.push(assetIdFilter);
806
+ fromIdFilters.push(assetIdFilter);
807
+ }
808
+ if (address) {
809
+ variables.addresses = [address];
810
+ args.push('$addresses: [String!]!');
811
+ const addressFilter = 'addresses: { in: $addresses }';
812
+ toIdFilters.push(addressFilter);
813
+ fromIdFilters.push(addressFilter);
814
+ }
815
+ return {
816
+ args: `(${args.join()})`,
817
+ filter: `filter: { or: [{ ${fromIdFilters.join()}, settlementId: { isNull: false } }, { ${toIdFilters.join()}, settlementId: { isNull: false } } ] }`,
568
818
  variables,
569
819
  };
570
820
  }
571
- exports.investments = investments;
572
821
  /**
573
822
  * @hidden
574
823
  *
575
- * Get current amount of withheld tax for a distribution
824
+ * Get Settlements where a Portfolio is involved
576
825
  */
577
- function getWithholdingTaxesOfCa(variables) {
826
+ function settlementsQuery(filters) {
827
+ const { args, filter, variables } = createLegFilters(filters);
578
828
  const query = (0, graphql_tag_1.default) `
579
- query GetWithholdingTaxesOfCAQuery($CAId: CAId!, $fromDate: DateTime, $toDate: DateTime) {
580
- getWithholdingTaxesOfCA(CAId: $CAId, fromDate: $fromDate, toDate: $toDate) {
581
- taxes
829
+ query SettlementsQuery
830
+ ${args}
831
+ {
832
+ legs(
833
+ ${filter}
834
+ orderBy: [${types_1.LegsOrderBy.CreatedAtAsc}, ${types_1.LegsOrderBy.InstructionIdAsc}]
835
+ ) {
836
+ nodes {
837
+ settlement {
838
+ id
839
+ createdBlock {
840
+ blockId
841
+ datetime
842
+ hash
843
+ }
844
+ result
845
+ legs {
846
+ nodes {
847
+ fromId
848
+ from {
849
+ identityId
850
+ number
851
+ }
852
+ toId
853
+ to {
854
+ identityId
855
+ number
856
+ }
857
+ assetId
858
+ amount
859
+ addresses
860
+ }
861
+ }
862
+ }
863
+ }
582
864
  }
583
865
  }
584
866
  `;
@@ -587,115 +869,277 @@ function getWithholdingTaxesOfCa(variables) {
587
869
  variables,
588
870
  };
589
871
  }
590
- exports.getWithholdingTaxesOfCa = getWithholdingTaxesOfCa;
872
+ exports.settlementsQuery = settlementsQuery;
873
+ /**
874
+ * @hidden
875
+ */
876
+ function createPortfolioMovementFilters({ identityId, portfolioId, ticker, address, }) {
877
+ const args = ['$fromId: String!, $toId: String!'];
878
+ const fromIdFilters = ['fromId: { equalTo: $fromId }'];
879
+ const toIdFilters = ['toId: { equalTo: $toId }'];
880
+ const portfolioNumber = portfolioId ? portfolioId.toNumber() : 0;
881
+ const variables = {
882
+ fromId: `${identityId}/${portfolioNumber}`,
883
+ toId: `${identityId}/${portfolioNumber}`,
884
+ };
885
+ if (ticker) {
886
+ variables.assetId = ticker;
887
+ args.push('$assetId: String!');
888
+ const assetIdFilter = 'assetId: { equalTo: $assetId }';
889
+ toIdFilters.push(assetIdFilter);
890
+ fromIdFilters.push(assetIdFilter);
891
+ }
892
+ if (address) {
893
+ variables.address = address;
894
+ args.push('$address: String!');
895
+ const addressFilter = 'address: { equalTo: $address }';
896
+ toIdFilters.push(addressFilter);
897
+ fromIdFilters.push(addressFilter);
898
+ }
899
+ return {
900
+ args: `(${args.join()})`,
901
+ filter: `filter: { or: [ { ${fromIdFilters.join()} }, { ${toIdFilters.join()} } ] }`,
902
+ variables,
903
+ };
904
+ }
591
905
  /**
592
906
  * @hidden
593
907
  *
594
- * Get history of claims for a distribution
908
+ * Get Settlements where a Portfolio is involved
909
+ */
910
+ function portfolioMovementsQuery(filters) {
911
+ const { args, filter, variables } = createPortfolioMovementFilters(filters);
912
+ const query = (0, graphql_tag_1.default) `
913
+ query PortfolioMovementsQuery
914
+ ${args}
915
+ {
916
+ portfolioMovements(
917
+ ${filter}
918
+ orderBy: [${types_1.PortfolioMovementsOrderBy.CreatedAtAsc}, ${types_1.PortfolioMovementsOrderBy.IdAsc}]
919
+ ) {
920
+ nodes {
921
+ id
922
+ fromId
923
+ from {
924
+ identityId
925
+ number
926
+ }
927
+ toId
928
+ to {
929
+ identityId
930
+ number
931
+ }
932
+ assetId
933
+ amount
934
+ address
935
+ createdBlock {
936
+ blockId
937
+ datetime
938
+ hash
939
+ }
940
+ }
941
+ }
942
+ }
943
+ `;
944
+ return {
945
+ query,
946
+ variables,
947
+ };
948
+ }
949
+ exports.portfolioMovementsQuery = portfolioMovementsQuery;
950
+ /**
951
+ * @hidden
952
+ */
953
+ function createPolyxTransactionFilters({ identityId, addresses }) {
954
+ const args = ['$size: Int, $start: Int'];
955
+ const fromIdFilters = [];
956
+ const toIdFilters = [];
957
+ const variables = {};
958
+ if (identityId) {
959
+ variables.identityId = identityId;
960
+ args.push('$identityId: String!');
961
+ fromIdFilters.push('identityId: { equalTo: $identityId }');
962
+ toIdFilters.push('toId: { equalTo: $identityId }');
963
+ }
964
+ if (addresses === null || addresses === void 0 ? void 0 : addresses.length) {
965
+ variables.addresses = addresses;
966
+ args.push('$addresses: [String!]!');
967
+ fromIdFilters.push('address: { in: $addresses }');
968
+ toIdFilters.push('toAddress: { in: $addresses }');
969
+ }
970
+ return {
971
+ args: `(${args.join()})`,
972
+ filter: fromIdFilters.length && toIdFilters.length
973
+ ? `filter: { or: [ { ${fromIdFilters.join()} }, { ${toIdFilters.join()} } ] }`
974
+ : '',
975
+ variables,
976
+ };
977
+ }
978
+ /**
979
+ * @hidden
980
+ *
981
+ * Get the balance history for an Asset
595
982
  */
596
- function getHistoryOfPaymentEventsForCa(variables) {
983
+ function assetTransactionQuery(filters, size, start) {
597
984
  const query = (0, graphql_tag_1.default) `
598
- query GetHistoryOfPaymentEventsForCAQuery(
599
- $CAId: CAId!
600
- $fromDate: DateTime
601
- $toDate: DateTime
602
- $count: Int
603
- $skip: Int
604
- ) {
605
- getHistoryOfPaymentEventsForCA(
606
- CAId: $CAId
607
- fromDate: $fromDate
608
- toDate: $toDate
609
- count: $count
610
- skip: $skip
985
+ query AssetTransactionQuery($assetId: String!) {
986
+ assetTransactions(
987
+ filter: { assetId: { equalTo: $assetId } }
988
+ orderBy: [${types_1.AssetTransactionsOrderBy.CreatedAtAsc}, ${types_1.AssetTransactionsOrderBy.CreatedBlockIdAsc}]
611
989
  ) {
612
990
  totalCount
613
- items {
614
- blockId
991
+ nodes {
992
+ assetId
993
+ amount
994
+ fromPortfolioId
995
+ fromPortfolio {
996
+ identityId
997
+ number
998
+ }
999
+ toPortfolioId
1000
+ toPortfolio {
1001
+ identityId
1002
+ number
1003
+ }
615
1004
  eventId
616
- eventDid
1005
+ eventIdx
1006
+ extrinsicIdx
1007
+ fundingRound
617
1008
  datetime
618
- ticker
619
- localId
620
- balance
621
- tax
1009
+ createdBlock {
1010
+ blockId
1011
+ hash
1012
+ datetime
1013
+ }
622
1014
  }
623
1015
  }
624
1016
  }
625
1017
  `;
626
1018
  return {
627
1019
  query,
628
- variables,
1020
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
629
1021
  };
630
1022
  }
631
- exports.getHistoryOfPaymentEventsForCa = getHistoryOfPaymentEventsForCa;
1023
+ exports.assetTransactionQuery = assetTransactionQuery;
632
1024
  /**
633
1025
  * @hidden
634
1026
  *
635
- * Get the transaction history of each external agent of an Asset
1027
+ * Get POLYX transactions where an Account or an Identity is involved
636
1028
  */
637
- function tickerExternalAgentHistory(variables) {
1029
+ function polyxTransactionsQuery(filters, size, start) {
1030
+ const { args, filter, variables } = createPolyxTransactionFilters(filters);
638
1031
  const query = (0, graphql_tag_1.default) `
639
- query TickerExternalAgentHistoryQuery($ticker: String!) {
640
- tickerExternalAgentHistory(ticker: $ticker) {
641
- did
642
- history {
1032
+ query PolyxTransactionsQuery
1033
+ ${args}
1034
+ {
1035
+ polyxTransactions(
1036
+ ${filter}
1037
+ first: $size
1038
+ offset: $start
1039
+ orderBy: [${types_1.PolyxTransactionsOrderBy.CreatedAtAsc}, ${types_1.PolyxTransactionsOrderBy.CreatedBlockIdAsc}]
1040
+ ) {
1041
+ nodes {
1042
+ id
1043
+ identityId
1044
+ address
1045
+ toId
1046
+ toAddress
1047
+ amount
1048
+ type
1049
+ extrinsic {
1050
+ extrinsicIdx
1051
+ }
1052
+ callId
1053
+ eventId
1054
+ moduleId
1055
+ eventIdx
1056
+ memo
643
1057
  datetime
644
- block_id
645
- event_idx
1058
+ createdBlock {
1059
+ blockId
1060
+ datetime
1061
+ hash
1062
+ }
646
1063
  }
647
1064
  }
648
1065
  }
649
1066
  `;
650
1067
  return {
651
1068
  query,
1069
+ variables: Object.assign(Object.assign({}, variables), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
1070
+ };
1071
+ }
1072
+ exports.polyxTransactionsQuery = polyxTransactionsQuery;
1073
+ /**
1074
+ * @hidden
1075
+ */
1076
+ function createAuthorizationFilters(variables) {
1077
+ const args = ['$size: Int, $start: Int'];
1078
+ const filters = [];
1079
+ const { fromId, toId, toKey, status, type } = variables;
1080
+ if (fromId === null || fromId === void 0 ? void 0 : fromId.length) {
1081
+ args.push('$fromId: String!');
1082
+ filters.push('fromId: { equalTo: $fromId }');
1083
+ }
1084
+ if (toId === null || toId === void 0 ? void 0 : toId.length) {
1085
+ args.push('$toId: String!');
1086
+ filters.push('toId: { equalTo: $toId }');
1087
+ }
1088
+ if (toKey === null || toKey === void 0 ? void 0 : toKey.length) {
1089
+ args.push('$toKey: String!');
1090
+ filters.push('toKey: { equalTo: $toKey }');
1091
+ }
1092
+ if (type) {
1093
+ args.push(`$type: ${enums_1.middlewareEnumMap.AuthTypeEnum}!`);
1094
+ filters.push('type: { equalTo: $type }');
1095
+ }
1096
+ if (status) {
1097
+ args.push(`$status: ${enums_1.middlewareEnumMap.AuthorizationStatusEnum}!`);
1098
+ filters.push('status: { equalTo: $status }');
1099
+ }
1100
+ return {
1101
+ args: `(${args.join()})`,
1102
+ filter: filters.length ? `filter: { ${filters.join()} }` : '',
652
1103
  variables,
653
1104
  };
654
1105
  }
655
- exports.tickerExternalAgentHistory = tickerExternalAgentHistory;
656
1106
  /**
657
1107
  * @hidden
658
1108
  *
659
- * Get list of Events triggered by actions (from the set of actions that can only be performed by external agents) that have been performed on a specific Asset
1109
+ * Get all authorizations with specified filters
660
1110
  */
661
- function tickerExternalAgentActions(variables) {
1111
+ function authorizationsQuery(filters, size, start) {
1112
+ const { args, filter } = createAuthorizationFilters(filters);
662
1113
  const query = (0, graphql_tag_1.default) `
663
- query TickerExternalAgentActionsQuery(
664
- $ticker: String!
665
- $caller_did: String
666
- $pallet_name: ModuleIdEnum
667
- $event_id: EventIdEnum
668
- $max_block: Int
669
- $count: Int
670
- $skip: Int
671
- $order: Order
672
- ) {
673
- tickerExternalAgentActions(
674
- ticker: $ticker
675
- caller_did: $caller_did
676
- pallet_name: $pallet_name
677
- event_id: $event_id
678
- max_block: $max_block
679
- count: $count
680
- skip: $skip
681
- order: $order
1114
+ query AuthorizationsQuery
1115
+ ${args}
1116
+ {
1117
+ authorizations(
1118
+ ${filter}
1119
+ first: $size
1120
+ offset: $start
1121
+ orderBy: [${types_1.AuthorizationsOrderBy.CreatedAtAsc}, ${types_1.AuthorizationsOrderBy.CreatedBlockIdAsc}]
682
1122
  ) {
683
1123
  totalCount
684
- items {
685
- datetime
686
- block_id
687
- event_idx
688
- pallet_name
689
- event_id
690
- caller_did
1124
+ nodes {
1125
+ id
1126
+ type
1127
+ fromId
1128
+ toId
1129
+ toKey
1130
+ data
1131
+ expiry
1132
+ status
1133
+ createdBlockId
1134
+ updatedBlockId
691
1135
  }
692
1136
  }
693
1137
  }
694
1138
  `;
695
1139
  return {
696
1140
  query,
697
- variables,
1141
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
698
1142
  };
699
1143
  }
700
- exports.tickerExternalAgentActions = tickerExternalAgentActions;
1144
+ exports.authorizationsQuery = authorizationsQuery;
701
1145
  //# sourceMappingURL=queries.js.map