@wishknish/knishio-client-js 0.5.2 → 0.6.1

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 (133) hide show
  1. package/README.md +207 -274
  2. package/dist/client.iife.js +533 -0
  3. package/package.json +37 -79
  4. package/src/.babelrc +0 -22
  5. package/src/Atom.js +171 -132
  6. package/src/AtomMeta.js +76 -50
  7. package/src/AuthToken.js +38 -47
  8. package/src/KnishIOClient.js +934 -987
  9. package/src/Meta.js +15 -17
  10. package/src/Molecule.js +423 -494
  11. package/src/PolicyMeta.js +32 -41
  12. package/src/TokenUnit.js +30 -32
  13. package/src/Wallet.js +275 -265
  14. package/src/exception/AtomIndexException.js +4 -8
  15. package/src/exception/AtomsMissingException.js +4 -6
  16. package/src/exception/AuthorizationRejectedException.js +4 -5
  17. package/src/exception/BalanceInsufficientException.js +4 -8
  18. package/src/exception/BaseException.js +6 -8
  19. package/src/exception/BatchIdException.js +5 -7
  20. package/src/exception/CodeException.js +4 -8
  21. package/src/{libraries/ApolloLink/HttpLink.js → exception/DecryptionKeyException.js} +12 -15
  22. package/src/exception/InvalidResponseException.js +4 -5
  23. package/src/exception/MetaMissingException.js +4 -6
  24. package/src/exception/MolecularHashMismatchException.js +4 -6
  25. package/src/exception/MolecularHashMissingException.js +4 -5
  26. package/src/exception/NegativeAmountException.js +4 -5
  27. package/src/exception/PolicyInvalidException.js +4 -4
  28. package/src/exception/SignatureMalformedException.js +4 -5
  29. package/src/exception/SignatureMismatchException.js +4 -5
  30. package/src/exception/StackableUnitAmountException.js +4 -5
  31. package/src/exception/StackableUnitDecimalsException.js +4 -5
  32. package/src/exception/TransferBalanceException.js +4 -5
  33. package/src/exception/TransferMalformedException.js +4 -5
  34. package/src/exception/TransferMismatchedException.js +4 -5
  35. package/src/exception/TransferRemainderException.js +4 -5
  36. package/src/exception/TransferToSelfException.js +4 -5
  37. package/src/exception/TransferUnbalancedException.js +4 -5
  38. package/src/exception/UnauthenticatedException.js +4 -5
  39. package/src/{libraries/ApolloLink/AuthLink.js → exception/WalletCredentialException.js} +12 -40
  40. package/src/exception/WalletShadowException.js +4 -5
  41. package/src/exception/WrongTokenTypeException.js +4 -5
  42. package/src/exception/index.js +26 -26
  43. package/src/index.js +8 -10
  44. package/src/instance/Rules/Callback.js +91 -93
  45. package/src/instance/Rules/Condition.js +21 -23
  46. package/src/instance/Rules/Meta.js +13 -14
  47. package/src/instance/Rules/Rule.js +39 -43
  48. package/src/instance/Rules/exception/RuleArgumentException.js +4 -4
  49. package/src/libraries/CheckMolecule.js +253 -232
  50. package/src/libraries/Decimal.js +13 -17
  51. package/src/libraries/Dot.js +74 -48
  52. package/src/libraries/Hex.js +49 -54
  53. package/src/libraries/array.js +50 -41
  54. package/src/libraries/crypto.js +20 -27
  55. package/src/libraries/strings.js +58 -91
  56. package/src/libraries/urql/UrqlClientWrapper.js +166 -0
  57. package/src/mutation/Mutation.js +44 -25
  58. package/src/mutation/MutationActiveSession.js +12 -12
  59. package/src/mutation/MutationClaimShadowWallet.js +15 -17
  60. package/src/mutation/MutationCreateIdentifier.js +11 -12
  61. package/src/mutation/MutationCreateMeta.js +11 -12
  62. package/src/mutation/MutationCreateRule.js +11 -12
  63. package/src/mutation/MutationCreateToken.js +18 -13
  64. package/src/mutation/MutationCreateWallet.js +9 -11
  65. package/src/mutation/MutationDepositBufferToken.js +7 -9
  66. package/src/mutation/MutationLinkIdentifier.js +12 -14
  67. package/src/mutation/MutationProposeMolecule.js +24 -25
  68. package/src/mutation/MutationRequestAuthorization.js +9 -10
  69. package/src/mutation/MutationRequestAuthorizationGuest.js +12 -15
  70. package/src/mutation/MutationRequestTokens.js +11 -14
  71. package/src/mutation/MutationTransferTokens.js +11 -14
  72. package/src/mutation/MutationWithdrawBufferToken.js +7 -10
  73. package/src/query/Query.js +62 -36
  74. package/src/query/QueryActiveSession.js +11 -13
  75. package/src/query/QueryAtom.js +75 -76
  76. package/src/query/QueryBalance.js +11 -12
  77. package/src/query/QueryBatch.js +17 -14
  78. package/src/query/QueryBatchHistory.js +16 -13
  79. package/src/query/QueryContinuId.js +13 -10
  80. package/src/query/QueryMetaType.js +45 -57
  81. package/src/query/QueryMetaTypeViaAtom.js +49 -57
  82. package/src/query/QueryPolicy.js +11 -12
  83. package/src/query/QueryToken.js +11 -13
  84. package/src/query/QueryUserActivity.js +11 -13
  85. package/src/query/QueryWalletBundle.js +15 -47
  86. package/src/query/QueryWalletList.js +15 -16
  87. package/src/response/Response.js +29 -34
  88. package/src/response/ResponseActiveSession.js +6 -6
  89. package/src/response/ResponseAtom.js +29 -30
  90. package/src/response/ResponseAuthorizationGuest.js +17 -18
  91. package/src/response/ResponseBalance.js +12 -13
  92. package/src/response/ResponseClaimShadowWallet.js +1 -1
  93. package/src/response/ResponseContinuId.js +21 -22
  94. package/src/response/ResponseCreateIdentifier.js +1 -1
  95. package/src/response/ResponseCreateMeta.js +1 -1
  96. package/src/response/ResponseCreateRule.js +1 -1
  97. package/src/response/ResponseCreateToken.js +1 -1
  98. package/src/response/ResponseCreateWallet.js +1 -1
  99. package/src/response/ResponseLinkIdentifier.js +9 -10
  100. package/src/response/ResponseMetaBatch.js +6 -8
  101. package/src/response/ResponseMetaType.js +19 -20
  102. package/src/response/ResponseMetaTypeViaAtom.js +19 -19
  103. package/src/response/ResponsePolicy.js +14 -15
  104. package/src/response/ResponseProposeMolecule.js +27 -30
  105. package/src/response/ResponseQueryActiveSession.js +20 -23
  106. package/src/response/ResponseQueryUserActivity.js +11 -12
  107. package/src/response/ResponseRequestAuthorization.js +11 -16
  108. package/src/response/ResponseRequestAuthorizationGuest.js +18 -21
  109. package/src/response/ResponseRequestTokens.js +1 -1
  110. package/src/response/ResponseTransferTokens.js +8 -9
  111. package/src/response/ResponseWalletBundle.js +16 -17
  112. package/src/response/ResponseWalletList.js +44 -47
  113. package/src/subscribe/ActiveSessionSubscribe.js +5 -6
  114. package/src/subscribe/ActiveWalletSubscribe.js +5 -6
  115. package/src/subscribe/CreateMoleculeSubscribe.js +5 -5
  116. package/src/subscribe/Subscribe.js +26 -26
  117. package/src/subscribe/WalletStatusSubscribe.js +5 -6
  118. package/src/versions/HashAtom.js +78 -0
  119. package/src/versions/Version4.js +34 -0
  120. package/src/versions/index.js +5 -0
  121. package/dist/client.umd.js +0 -453
  122. package/src/httpClient/ApolloClient.js +0 -245
  123. package/src/libraries/ApolloLink/CipherLink.js +0 -117
  124. package/src/libraries/ApolloLink/Client.js +0 -231
  125. package/src/libraries/ApolloLink/PusherLink.js +0 -234
  126. package/src/libraries/ApolloLink/handler.js +0 -106
  127. package/src/libraries/Base58.js +0 -71
  128. package/src/libraries/Base64.js +0 -40
  129. package/src/libraries/BaseX.js +0 -91
  130. package/src/libraries/Soda.js +0 -93
  131. package/src/query/QueryMetaInstance.js +0 -99
  132. package/src/test/Test.js +0 -670
  133. package/src/test/TestTokenUnit.js +0 -340
@@ -45,28 +45,30 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import CodeException from '../exception/CodeException';
49
- import Response from '../response/Response';
48
+ import CodeException from '../exception/CodeException'
49
+ import Response from '../response/Response'
50
50
 
51
51
  export default class Query {
52
52
  /**
53
- *
54
- * @param {ApolloClient} apolloClient
53
+ * @param {UrqlClientWrapper} graphQLClient
54
+ * @param {KnishIOClient} knishIOClient
55
55
  */
56
- constructor ( apolloClient ) {
57
- this.client = apolloClient;
58
- this.$__variables = null;
59
- this.$__query = null;
56
+ constructor (graphQLClient, knishIOClient) {
57
+ this.client = graphQLClient
58
+ this.knishIOClient = knishIOClient
59
+ this.$__variables = null
60
+ this.$__query = null
61
+ this.$__response = null
62
+ this.$__request = null
60
63
  }
61
64
 
62
-
63
65
  /**
64
66
  * Return a response object
65
67
  * Used at KnishIOClient::createMolecule => sets the source wallet from the remainder one stored in response object
66
68
  * @return {Response}
67
69
  */
68
70
  response () {
69
- return this.$__response;
71
+ return this.$__response
70
72
  }
71
73
 
72
74
  /**
@@ -75,8 +77,8 @@ export default class Query {
75
77
  * @param response
76
78
  * @return {Promise<Response>}
77
79
  */
78
- async createResponseRaw ( response ) {
79
- return this.createResponse( response );
80
+ async createResponseRaw (response) {
81
+ return this.createResponse(response)
80
82
  }
81
83
 
82
84
  /**
@@ -85,11 +87,11 @@ export default class Query {
85
87
  * @param {object} json
86
88
  * @return {Response}
87
89
  */
88
- createResponse ( json ) {
89
- return new Response( {
90
+ createResponse (json) {
91
+ return new Response({
90
92
  query: this,
91
93
  json
92
- } );
94
+ })
93
95
  }
94
96
 
95
97
  /**
@@ -98,43 +100,62 @@ export default class Query {
98
100
  * @param {{}} variables
99
101
  * @returns {{variables: (Object|null), query: null}}
100
102
  */
101
- createQuery ( { variables = null } ) {
102
- this.$__variables = this.compiledVariables( variables );
103
+ createQuery ({ variables = null }) {
104
+ this.$__variables = this.compiledVariables(variables)
103
105
 
104
106
  // Uri is a required parameter
105
- let uri = this.uri();
107
+ const uri = this.uri()
106
108
 
107
- if ( !uri ) {
108
- throw new CodeException( 'Query::createQuery() - Node URI was not initialized for this client instance!' );
109
+ if (!uri) {
110
+ throw new CodeException('Query::createQuery() - Node URI was not initialized for this client instance!')
109
111
  }
110
112
 
111
- if ( this.$__query === null ) {
112
- throw new CodeException( 'Query::createQuery() - GraphQL subscription was not initialized!' );
113
+ if (this.$__query === null) {
114
+ throw new CodeException('Query::createQuery() - GraphQL subscription was not initialized!')
113
115
  }
114
116
 
115
117
  return {
116
118
  query: this.$__query,
117
119
  variables: this.variables()
118
- };
120
+ }
119
121
  }
120
122
 
121
123
  /**
122
124
  * Sends the Query to a Knish.IO node and returns the Response
123
125
  *
124
126
  * @param {object} variables
127
+ * @param {object} context
125
128
  * @return {Promise<Response>}
126
129
  */
127
- async execute ( { variables = null } ) {
128
-
129
- this.$__request = this.createQuery( {
130
- variables
131
- } );
132
-
133
- let response = await this.client.query( this.$__request );
130
+ async execute ({ variables = null, context = {} }) {
131
+ this.$__request = this.createQuery({ variables })
134
132
 
135
- this.$__response = await this.createResponseRaw( response );
133
+ const mergedContext = {
134
+ ...context,
135
+ ...this.createQueryContext()
136
+ }
136
137
 
137
- return this.$__response;
138
+ try {
139
+ const response = await this.client.query({
140
+ ...this.$__request,
141
+ context: mergedContext
142
+ })
143
+
144
+ this.$__response = await this.createResponseRaw(response)
145
+
146
+ return this.$__response
147
+ } catch (error) {
148
+ if (error.name === 'AbortError') {
149
+ this.knishIOClient.log('warn', 'Query was cancelled')
150
+ // You might want to create a custom response for cancelled queries
151
+ return new Response({
152
+ query: this,
153
+ json: { data: null, errors: [{ message: 'Query was cancelled' }] }
154
+ })
155
+ } else {
156
+ throw error
157
+ }
158
+ }
138
159
  }
139
160
 
140
161
  /**
@@ -143,8 +164,8 @@ export default class Query {
143
164
  * @param {object} variables
144
165
  * @return {object}
145
166
  */
146
- compiledVariables ( variables = null ) {
147
- return variables || {};
167
+ compiledVariables (variables = null) {
168
+ return variables || {}
148
169
  }
149
170
 
150
171
  /**
@@ -153,7 +174,7 @@ export default class Query {
153
174
  * @return {string}
154
175
  */
155
176
  uri () {
156
- return this.client.getUri();
177
+ return this.client.getUri()
157
178
  }
158
179
 
159
180
  /**
@@ -162,6 +183,11 @@ export default class Query {
162
183
  * @return {object|null}
163
184
  */
164
185
  variables () {
165
- return this.$__variables;
186
+ return this.$__variables
187
+ }
188
+
189
+ createQueryContext () {
190
+ // Override this method in subclasses if needed
191
+ return {}
166
192
  }
167
193
  }
@@ -45,21 +45,20 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import ResponseQueryActiveSession from '../response/ResponseQueryActiveSession';
50
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import ResponseQueryActiveSession from '../response/ResponseQueryActiveSession'
50
+ import { gql } from '@urql/core'
51
51
 
52
52
  /**
53
53
  * Query for retrieving a list of active User Sessions
54
54
  */
55
55
  export default class QueryActiveSession extends Query {
56
56
  /**
57
- * Class constructor
58
- *
59
- * @param httpClient
57
+ * @param {UrqlClientWrapper} graphQLClient
58
+ * @param {KnishIOClient} knishIOClient
60
59
  */
61
- constructor ( httpClient ) {
62
- super( httpClient );
60
+ constructor (graphQLClient, knishIOClient) {
61
+ super(graphQLClient, knishIOClient)
63
62
 
64
63
  this.$__query = gql`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
65
64
  ActiveUser (bundleHash: $bundleHash, metaType: $metaType, metaId: $metaId) {
@@ -70,18 +69,17 @@ export default class QueryActiveSession extends Query {
70
69
  createdAt,
71
70
  updatedAt
72
71
  }
73
- }`;
72
+ }`
74
73
  }
75
74
 
76
75
  /**
77
76
  * @param {object} json
78
77
  * @return {ResponseQueryActiveSession}
79
78
  */
80
- createResponse ( json ) {
81
- return new ResponseQueryActiveSession( {
79
+ createResponse (json) {
80
+ return new ResponseQueryActiveSession({
82
81
  query: this,
83
82
  json
84
- } );
83
+ })
85
84
  }
86
-
87
85
  }
@@ -45,21 +45,20 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import { gql } from '@apollo/client/core';
50
- import ResponseAtom from '../response/ResponseAtom';
48
+ import Query from './Query'
49
+ import ResponseAtom from '../response/ResponseAtom'
50
+ import { gql } from '@urql/core'
51
51
 
52
52
  /**
53
53
  * Query for getting the balance of a given wallet or token slug
54
54
  */
55
55
  export default class QueryAtom extends Query {
56
56
  /**
57
- * Class constructor
58
- *
59
- * @param apolloClient
57
+ * @param {UrqlClientWrapper} graphQLClient
58
+ * @param {KnishIOClient} knishIOClient
60
59
  */
61
- constructor ( apolloClient ) {
62
- super( apolloClient );
60
+ constructor (graphQLClient, knishIOClient) {
61
+ super(graphQLClient, knishIOClient)
63
62
 
64
63
  this.$__query = gql`query(
65
64
  $molecularHashes: [String!],
@@ -117,20 +116,7 @@ export default class QueryAtom extends Query {
117
116
  total
118
117
  }
119
118
  }
120
- }`;
121
- }
122
-
123
- /**
124
- * Returns a Response object
125
- *
126
- * @param {object} json
127
- * @return {ResponseAtom}
128
- */
129
- createResponse ( json ) {
130
- return new ResponseAtom( {
131
- query: this,
132
- json
133
- } );
119
+ }`
134
120
  }
135
121
 
136
122
  /**
@@ -165,7 +151,7 @@ export default class QueryAtom extends Query {
165
151
  * @param {object} queryArgs
166
152
  * @return {object}
167
153
  */
168
- static createVariables ( {
154
+ static createVariables ({
169
155
  molecularHashes,
170
156
  molecularHash,
171
157
  bundleHashes,
@@ -193,83 +179,96 @@ export default class QueryAtom extends Query {
193
179
  filter,
194
180
  latest,
195
181
  queryArgs
196
- } ) {
197
- if ( molecularHash ) {
198
- molecularHashes = molecularHashes || [];
199
- molecularHashes.push( molecularHash );
182
+ }) {
183
+ if (molecularHash) {
184
+ molecularHashes = molecularHashes || []
185
+ molecularHashes.push(molecularHash)
200
186
  }
201
187
 
202
- if ( bundleHash ) {
203
- bundleHashes = bundleHashes || [];
204
- bundleHashes.push( bundleHash );
188
+ if (bundleHash) {
189
+ bundleHashes = bundleHashes || []
190
+ bundleHashes.push(bundleHash)
205
191
  }
206
192
 
207
- if ( position ) {
208
- positions = positions || [];
209
- positions.push( position );
193
+ if (position) {
194
+ positions = positions || []
195
+ positions.push(position)
210
196
  }
211
197
 
212
- if ( walletAddress ) {
213
- walletAddresses = walletAddresses || [];
214
- walletAddresses.push( walletAddress );
198
+ if (walletAddress) {
199
+ walletAddresses = walletAddresses || []
200
+ walletAddresses.push(walletAddress)
215
201
  }
216
202
 
217
- if ( isotope ) {
218
- isotopes = isotopes || [];
219
- isotopes.push( isotope );
203
+ if (isotope) {
204
+ isotopes = isotopes || []
205
+ isotopes.push(isotope)
220
206
  }
221
207
 
222
- if ( tokenSlug ) {
223
- tokenSlugs = tokenSlugs || [];
224
- tokenSlugs.push( tokenSlug );
208
+ if (tokenSlug) {
209
+ tokenSlugs = tokenSlugs || []
210
+ tokenSlugs.push(tokenSlug)
225
211
  }
226
212
 
227
- if ( cellSlug ) {
228
- cellSlugs = cellSlugs || [];
229
- cellSlugs.push( cellSlug );
213
+ if (cellSlug) {
214
+ cellSlugs = cellSlugs || []
215
+ cellSlugs.push(cellSlug)
230
216
  }
231
217
 
232
- if ( batchId ) {
233
- batchIds = batchIds || [];
234
- batchIds.push( batchId );
218
+ if (batchId) {
219
+ batchIds = batchIds || []
220
+ batchIds.push(batchId)
235
221
  }
236
222
 
237
- if ( value ) {
238
- values = values || [];
239
- values.push( value );
223
+ if (value) {
224
+ values = values || []
225
+ values.push(value)
240
226
  }
241
227
 
242
- if ( metaType ) {
243
- metaTypes = metaTypes || [];
244
- metaTypes.push( metaType );
228
+ if (metaType) {
229
+ metaTypes = metaTypes || []
230
+ metaTypes.push(metaType)
245
231
  }
246
232
 
247
- if ( metaId ) {
248
- metaIds = metaIds || [];
249
- metaIds.push( metaId );
233
+ if (metaId) {
234
+ metaIds = metaIds || []
235
+ metaIds.push(metaId)
250
236
  }
251
237
 
252
- if ( index ) {
253
- indexes = indexes || [];
254
- indexes.push( index );
238
+ if (index) {
239
+ indexes = indexes || []
240
+ indexes.push(index)
255
241
  }
256
242
 
257
243
  return {
258
- molecularHashes: molecularHashes,
259
- bundleHashes: bundleHashes,
260
- positions: positions,
261
- walletAddresses: walletAddresses,
262
- isotopes: isotopes,
263
- tokenSlugs: tokenSlugs,
264
- cellSlugs: cellSlugs,
265
- batchIds: batchIds,
266
- values: values,
267
- metaTypes: metaTypes,
268
- metaIds: metaIds,
269
- indexes: indexes,
270
- filter: filter,
271
- latest: latest,
272
- queryArgs: queryArgs
273
- };
244
+ molecularHashes,
245
+ bundleHashes,
246
+ positions,
247
+ walletAddresses,
248
+ isotopes,
249
+ tokenSlugs,
250
+ cellSlugs,
251
+ batchIds,
252
+ values,
253
+ metaTypes,
254
+ metaIds,
255
+ indexes,
256
+ filter,
257
+ latest,
258
+ queryArgs
259
+ }
260
+ }
261
+
262
+ /**
263
+ * Returns a Response object
264
+ *
265
+ * @param {object} json
266
+ * @return {ResponseAtom}
267
+ */
268
+ createResponse (json) {
269
+ return new ResponseAtom({
270
+ query: this,
271
+ json
272
+ })
274
273
  }
275
274
  }
@@ -45,21 +45,20 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import { gql } from '@apollo/client/core';
50
- import ResponseBalance from '../response/ResponseBalance';
48
+ import Query from './Query'
49
+ import ResponseBalance from '../response/ResponseBalance'
50
+ import { gql } from '@urql/core'
51
51
 
52
52
  /**
53
53
  * Query for getting the balance of a given wallet or token slug
54
54
  */
55
55
  export default class QueryBalance extends Query {
56
56
  /**
57
- * Class constructor
58
- *
59
- * @param apolloClient
57
+ * @param {UrqlClientWrapper} graphQLClient
58
+ * @param {KnishIOClient} knishIOClient
60
59
  */
61
- constructor ( apolloClient ) {
62
- super( apolloClient );
60
+ constructor (graphQLClient, knishIOClient) {
61
+ super(graphQLClient, knishIOClient)
63
62
 
64
63
  this.$__query = gql`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
65
64
  Balance( address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position ) {
@@ -83,17 +82,17 @@ export default class QueryBalance extends Query {
83
82
  amount
84
83
  }
85
84
  }
86
- }`;
85
+ }`
87
86
  }
88
87
 
89
88
  /**
90
89
  * @param {object} json
91
90
  * @return {ResponseBalance}
92
91
  */
93
- createResponse ( json ) {
94
- return new ResponseBalance( {
92
+ createResponse (json) {
93
+ return new ResponseBalance({
95
94
  query: this,
96
95
  json
97
- } );
96
+ })
98
97
  }
99
98
  }
@@ -45,17 +45,21 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import Response from '../response/Response';
50
- import { gql } from '@apollo/client/core';
51
-
48
+ import Query from './Query'
49
+ import Response from '../response/Response'
50
+ import { gql } from '@urql/core'
52
51
 
53
52
  /**
54
53
  * Query for retrieving Meta Asset information
55
54
  */
56
55
  export default class QueryBatch extends Query {
57
- constructor ( apolloClient ) {
58
- super( apolloClient );
56
+ /**
57
+ * @param {UrqlClientWrapper} graphQLClient
58
+ * @param {KnishIOClient} knishIOClient
59
+ */
60
+ constructor (graphQLClient, knishIOClient) {
61
+ super(graphQLClient, knishIOClient)
62
+
59
63
  this.$__query = gql`query( $batchId: String ) {
60
64
  Batch( batchId: $batchId ) {
61
65
  ${ QueryBatch.getFields() },
@@ -63,7 +67,7 @@ export default class QueryBatch extends Query {
63
67
  ${ QueryBatch.getFields() }
64
68
  }
65
69
  }
66
- }`;
70
+ }`
67
71
  }
68
72
 
69
73
  static getFields () {
@@ -116,7 +120,7 @@ export default class QueryBatch extends Query {
116
120
  throughMetas {
117
121
  key,
118
122
  value
119
- }`;
123
+ }`
120
124
  }
121
125
 
122
126
  /**
@@ -125,13 +129,12 @@ export default class QueryBatch extends Query {
125
129
  * @param {object} json
126
130
  * @return {Response}
127
131
  */
128
- createResponse ( json ) {
129
- let responseObject = new Response( {
132
+ createResponse (json) {
133
+ const responseObject = new Response({
130
134
  query: this,
131
135
  json
132
- } );
133
- responseObject.dataKey = 'data.Batch';
134
- return responseObject;
136
+ })
137
+ responseObject.dataKey = 'data.Batch'
138
+ return responseObject
135
139
  }
136
-
137
140
  }
@@ -45,23 +45,27 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import QueryBatch from './QueryBatch';
50
- import Response from '../response/Response';
51
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import QueryBatch from './QueryBatch'
50
+ import Response from '../response/Response'
51
+ import { gql } from '@urql/core'
52
52
 
53
53
  /**
54
54
  * Query for retrieving Meta Asset information
55
55
  */
56
56
  export default class QueryBatchHistory extends Query {
57
+ /**
58
+ * @param {UrqlClientWrapper} graphQLClient
59
+ * @param {KnishIOClient} knishIOClient
60
+ */
61
+ constructor (graphQLClient, knishIOClient) {
62
+ super(graphQLClient, knishIOClient)
57
63
 
58
- constructor ( apolloClient ) {
59
- super( apolloClient );
60
64
  this.$__query = gql`query( $batchId: String ) {
61
65
  BatchHistory( batchId: $batchId ) {
62
66
  ${ QueryBatch.getFields() }
63
67
  }
64
- }`;
68
+ }`
65
69
  }
66
70
 
67
71
  /**
@@ -70,13 +74,12 @@ export default class QueryBatchHistory extends Query {
70
74
  * @param {object} json
71
75
  * @return {Response}
72
76
  */
73
- createResponse ( json ) {
74
- let responseObject = new Response( {
77
+ createResponse (json) {
78
+ const responseObject = new Response({
75
79
  query: this,
76
80
  json
77
- } );
78
- responseObject.dataKey = 'data.BatchHistory';
79
- return responseObject;
81
+ })
82
+ responseObject.dataKey = 'data.BatchHistory'
83
+ return responseObject
80
84
  }
81
-
82
85
  }
@@ -45,17 +45,21 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
45
45
 
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
- import Query from './Query';
49
- import ResponseContinuId from '../response/ResponseContinuId';
50
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import ResponseContinuId from '../response/ResponseContinuId'
50
+ import { gql } from '@urql/core'
51
51
 
52
52
  /**
53
53
  * Queries the node for the next wallet to sign with for ContinuID
54
54
  */
55
55
  export default class QueryContinuId extends Query {
56
+ /**
57
+ * @param {UrqlClientWrapper} graphQLClient
58
+ * @param {KnishIOClient} knishIOClient
59
+ */
60
+ constructor (graphQLClient, knishIOClient) {
61
+ super(graphQLClient, knishIOClient)
56
62
 
57
- constructor ( apolloClient ) {
58
- super( apolloClient );
59
63
  this.$__query = gql`query ($bundle: String!) {
60
64
  ContinuId(bundle: $bundle) {
61
65
  address,
@@ -68,7 +72,7 @@ export default class QueryContinuId extends Query {
68
72
  amount,
69
73
  createdAt
70
74
  }
71
- }`;
75
+ }`
72
76
  }
73
77
 
74
78
  /**
@@ -77,11 +81,10 @@ export default class QueryContinuId extends Query {
77
81
  * @param {object} json
78
82
  * @return {ResponseContinuId}
79
83
  */
80
- createResponse ( json ) {
81
- return new ResponseContinuId( {
84
+ createResponse (json) {
85
+ return new ResponseContinuId({
82
86
  query: this,
83
87
  json
84
- } );
88
+ })
85
89
  }
86
-
87
90
  }