@wishknish/knishio-client-js 0.5.2 → 0.6.0

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 (138) hide show
  1. package/README.md +207 -274
  2. package/dist/client.iife.js +577 -0
  3. package/package.json +36 -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 +37 -46
  8. package/src/KnishIOClient.js +932 -985
  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/apollo/ApolloClientWrapper.js +143 -0
  54. package/src/libraries/apollo/CipherLink.js +116 -0
  55. package/src/libraries/apollo/Client.js +154 -0
  56. package/src/libraries/apollo/ErrorHandler.js +32 -0
  57. package/src/libraries/apollo/SubscriptionManager.js +60 -0
  58. package/src/libraries/apollo/operationUtils.js +26 -0
  59. package/src/libraries/array.js +50 -41
  60. package/src/libraries/crypto.js +20 -27
  61. package/src/libraries/strings.js +58 -91
  62. package/src/mutation/Mutation.js +44 -25
  63. package/src/mutation/MutationActiveSession.js +12 -12
  64. package/src/mutation/MutationClaimShadowWallet.js +15 -17
  65. package/src/mutation/MutationCreateIdentifier.js +11 -12
  66. package/src/mutation/MutationCreateMeta.js +11 -12
  67. package/src/mutation/MutationCreateRule.js +11 -12
  68. package/src/mutation/MutationCreateToken.js +18 -13
  69. package/src/mutation/MutationCreateWallet.js +9 -11
  70. package/src/mutation/MutationDepositBufferToken.js +7 -9
  71. package/src/mutation/MutationLinkIdentifier.js +12 -14
  72. package/src/mutation/MutationProposeMolecule.js +24 -25
  73. package/src/mutation/MutationRequestAuthorization.js +9 -10
  74. package/src/mutation/MutationRequestAuthorizationGuest.js +12 -15
  75. package/src/mutation/MutationRequestTokens.js +11 -14
  76. package/src/mutation/MutationTransferTokens.js +11 -14
  77. package/src/mutation/MutationWithdrawBufferToken.js +7 -10
  78. package/src/query/Query.js +62 -36
  79. package/src/query/QueryActiveSession.js +11 -13
  80. package/src/query/QueryAtom.js +75 -76
  81. package/src/query/QueryBalance.js +11 -12
  82. package/src/query/QueryBatch.js +17 -14
  83. package/src/query/QueryBatchHistory.js +16 -13
  84. package/src/query/QueryContinuId.js +13 -10
  85. package/src/query/QueryMetaType.js +45 -57
  86. package/src/query/QueryMetaTypeViaAtom.js +49 -57
  87. package/src/query/QueryPolicy.js +11 -12
  88. package/src/query/QueryToken.js +11 -13
  89. package/src/query/QueryUserActivity.js +11 -13
  90. package/src/query/QueryWalletBundle.js +15 -47
  91. package/src/query/QueryWalletList.js +15 -16
  92. package/src/response/Response.js +29 -34
  93. package/src/response/ResponseActiveSession.js +6 -6
  94. package/src/response/ResponseAtom.js +29 -30
  95. package/src/response/ResponseAuthorizationGuest.js +17 -18
  96. package/src/response/ResponseBalance.js +12 -13
  97. package/src/response/ResponseClaimShadowWallet.js +1 -1
  98. package/src/response/ResponseContinuId.js +21 -22
  99. package/src/response/ResponseCreateIdentifier.js +1 -1
  100. package/src/response/ResponseCreateMeta.js +1 -1
  101. package/src/response/ResponseCreateRule.js +1 -1
  102. package/src/response/ResponseCreateToken.js +1 -1
  103. package/src/response/ResponseCreateWallet.js +1 -1
  104. package/src/response/ResponseLinkIdentifier.js +9 -10
  105. package/src/response/ResponseMetaBatch.js +6 -8
  106. package/src/response/ResponseMetaType.js +19 -20
  107. package/src/response/ResponseMetaTypeViaAtom.js +19 -19
  108. package/src/response/ResponsePolicy.js +14 -15
  109. package/src/response/ResponseProposeMolecule.js +27 -30
  110. package/src/response/ResponseQueryActiveSession.js +20 -23
  111. package/src/response/ResponseQueryUserActivity.js +11 -12
  112. package/src/response/ResponseRequestAuthorization.js +11 -16
  113. package/src/response/ResponseRequestAuthorizationGuest.js +18 -21
  114. package/src/response/ResponseRequestTokens.js +1 -1
  115. package/src/response/ResponseTransferTokens.js +8 -9
  116. package/src/response/ResponseWalletBundle.js +16 -17
  117. package/src/response/ResponseWalletList.js +44 -47
  118. package/src/subscribe/ActiveSessionSubscribe.js +5 -6
  119. package/src/subscribe/ActiveWalletSubscribe.js +5 -6
  120. package/src/subscribe/CreateMoleculeSubscribe.js +5 -5
  121. package/src/subscribe/Subscribe.js +26 -26
  122. package/src/subscribe/WalletStatusSubscribe.js +5 -6
  123. package/src/versions/HashAtom.js +78 -0
  124. package/src/versions/Version4.js +34 -0
  125. package/src/versions/index.js +5 -0
  126. package/dist/client.umd.js +0 -453
  127. package/src/httpClient/ApolloClient.js +0 -245
  128. package/src/libraries/ApolloLink/CipherLink.js +0 -117
  129. package/src/libraries/ApolloLink/Client.js +0 -231
  130. package/src/libraries/ApolloLink/PusherLink.js +0 -234
  131. package/src/libraries/ApolloLink/handler.js +0 -106
  132. package/src/libraries/Base58.js +0 -71
  133. package/src/libraries/Base64.js +0 -40
  134. package/src/libraries/BaseX.js +0 -91
  135. package/src/libraries/Soda.js +0 -93
  136. package/src/query/QueryMetaInstance.js +0 -99
  137. package/src/test/Test.js +0 -670
  138. package/src/test/TestTokenUnit.js +0 -340
@@ -45,19 +45,17 @@ 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 ResponseMetaTypeViaAtom from '../response/ResponseMetaTypeViaAtom';
51
-
48
+ import Query from './Query'
49
+ import { gql } from '@apollo/client/core'
50
+ import ResponseMetaTypeViaAtom from '../response/ResponseMetaTypeViaAtom'
52
51
 
53
52
  export default class QueryMetaTypeViaAtom extends Query {
54
53
  /**
55
- * Class constructor
56
- *
57
- * @param apolloClient
54
+ * @param {ApolloClientWrapper} apolloClient
55
+ * @param {KnishIOClient} knishIOClient
58
56
  */
59
- constructor ( apolloClient ) {
60
- super( apolloClient );
57
+ constructor (apolloClient, knishIOClient) {
58
+ super(apolloClient, knishIOClient)
61
59
 
62
60
  this.$__query = gql`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!] ) {
63
61
  MetaTypeViaAtom(
@@ -91,20 +89,7 @@ export default class QueryMetaTypeViaAtom extends Query {
91
89
  total
92
90
  }
93
91
  }
94
- }`;
95
- }
96
-
97
- /**
98
- * Returns a Response object
99
- *
100
- * @param {object} json
101
- * @return {ResponseMetaTypeViaAtom}
102
- */
103
- createResponse ( json ) {
104
- return new ResponseMetaTypeViaAtom( {
105
- query: this,
106
- json
107
- } );
92
+ }`
108
93
  }
109
94
 
110
95
  /**
@@ -118,13 +103,12 @@ export default class QueryMetaTypeViaAtom extends Query {
118
103
  * @param {array|null} keys
119
104
  * @param {array|null} atomValues
120
105
  * @param {boolean|null} latest
121
- * @param {boolean|null} latestMetas
122
106
  * @param {array|null} filter
123
107
  * @param {object|null} queryArgs
124
108
  * @param {string|null} countBy
125
109
  * @return {{}}
126
110
  */
127
- static createVariables ( {
111
+ static createVariables ({
128
112
  metaType = null,
129
113
  metaId = null,
130
114
  key = null,
@@ -133,64 +117,72 @@ export default class QueryMetaTypeViaAtom extends Query {
133
117
  values = null,
134
118
  atomValues = null,
135
119
  latest = null,
136
- latestMetas = true,
137
120
  filter = null,
138
121
  queryArgs = null,
139
122
  countBy = null
140
- } ) {
141
- const variables = {};
123
+ }) {
124
+ const variables = {}
142
125
 
143
- if ( atomValues ) {
144
- variables[ 'atomValues' ] = atomValues;
126
+ if (atomValues) {
127
+ variables.atomValues = atomValues
145
128
  }
146
129
 
147
- if ( keys ) {
148
- variables[ 'keys' ] = keys;
130
+ if (keys) {
131
+ variables.keys = keys
149
132
  }
150
133
 
151
- if ( values ) {
152
- variables[ 'values' ] = values;
134
+ if (values) {
135
+ variables.values = values
153
136
  }
154
137
 
155
- if ( metaType ) {
156
- variables[ 'metaTypes' ] = typeof metaType === 'string' ? [ metaType ] : metaType;
138
+ if (metaType) {
139
+ variables.metaTypes = typeof metaType === 'string' ? [metaType] : metaType
157
140
  }
158
141
 
159
- if ( metaId ) {
160
- variables[ 'metaIds' ] = typeof metaId === 'string' ? [ metaId ] : metaId;
142
+ if (metaId) {
143
+ variables.metaIds = typeof metaId === 'string' ? [metaId] : metaId
161
144
  }
162
145
 
163
- if ( countBy ) {
164
- variables[ 'countBy' ] = countBy;
146
+ if (countBy) {
147
+ variables.countBy = countBy
165
148
  }
166
149
 
167
- if ( filter ) {
168
- variables[ 'filter' ] = filter;
150
+ if (filter) {
151
+ variables.filter = filter
169
152
  }
170
153
 
171
- if ( key && value ) {
172
- variables[ 'filter' ] = variables[ 'filter' ] || [];
173
- variables[ 'filter' ].push( {
154
+ if (key && value) {
155
+ variables.filter = variables.filter || []
156
+ variables.filter.push({
174
157
  key,
175
158
  value,
176
- 'comparison': '='
177
- } );
159
+ comparison: '='
160
+ })
178
161
  }
179
162
 
180
- if ( latest ) {
181
- variables[ 'latest' ] = !!latest;
182
- variables[ 'latest' ] = !!latestMetas;
183
- }
184
-
185
- if ( queryArgs ) {
163
+ variables.latest = latest === true
186
164
 
187
- if ( typeof queryArgs.limit === 'undefined' || queryArgs.limit === 0 ) {
188
- queryArgs.limit = '*';
165
+ if (queryArgs) {
166
+ if (typeof queryArgs.limit === 'undefined' || queryArgs.limit === 0) {
167
+ queryArgs.limit = '*'
189
168
  }
190
169
 
191
- variables[ 'queryArgs' ] = queryArgs;
170
+ variables.queryArgs = queryArgs
192
171
  }
193
172
 
194
- return variables;
173
+ return variables
174
+ }
175
+
176
+ /**
177
+ * Returns a Response object
178
+ *
179
+ * @param {object} json
180
+ * @return {ResponseMetaTypeViaAtom}
181
+ */
182
+ createResponse (json) {
183
+ return new ResponseMetaTypeViaAtom({
184
+ query: this,
185
+ json
186
+ })
195
187
  }
196
188
  }
@@ -46,18 +46,17 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
48
 
49
- import Query from './Query';
50
- import { gql } from '@apollo/client/core';
51
- import ResponsePolicy from '../response/ResponsePolicy';
49
+ import Query from './Query'
50
+ import { gql } from '@apollo/client/core'
51
+ import ResponsePolicy from '../response/ResponsePolicy'
52
52
 
53
53
  export default class QueryPolicy extends Query {
54
54
  /**
55
- * Class constructor
56
- *
57
- * @param apolloClient
55
+ * @param {ApolloClientWrapper} apolloClient
56
+ * @param {KnishIOClient} knishIOClient
58
57
  */
59
- constructor ( apolloClient ) {
60
- super( apolloClient );
58
+ constructor (apolloClient, knishIOClient) {
59
+ super(apolloClient, knishIOClient)
61
60
 
62
61
  this.$__query = gql`query( $metaType: String, $metaId: String, ) {
63
62
  Policy( metaType: $metaType, metaId: $metaId ) {
@@ -70,7 +69,7 @@ export default class QueryPolicy extends Query {
70
69
  rule,
71
70
  createdAt
72
71
  }
73
- }`;
72
+ }`
74
73
  }
75
74
 
76
75
  /**
@@ -79,10 +78,10 @@ export default class QueryPolicy extends Query {
79
78
  * @param {object} json
80
79
  * @return {ResponsePolicy}
81
80
  */
82
- createResponse ( json ) {
83
- return new ResponsePolicy( {
81
+ createResponse (json) {
82
+ return new ResponsePolicy({
84
83
  query: this,
85
84
  json
86
- } );
85
+ })
87
86
  }
88
87
  }
@@ -45,22 +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 Response from '../response/Response';
51
-
48
+ import Query from './Query'
49
+ import { gql } from '@apollo/client/core'
50
+ import Response from '../response/Response'
52
51
 
53
52
  /**
54
53
  * Query for getting the token info
55
54
  */
56
55
  export default class QueryToken extends Query {
57
56
  /**
58
- * Class constructor
59
- *
60
- * @param apolloClient
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
61
59
  */
62
- constructor ( apolloClient ) {
63
- super( apolloClient );
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
64
62
 
65
63
  this.$__query = gql`query( $slug: String, $slugs: [ String! ], $limit: Int, $order: String ) {
66
64
  Token( slug: $slug, slugs: $slugs, limit: $limit, order: $order ) {
@@ -72,7 +70,7 @@ export default class QueryToken extends Query {
72
70
  amount,
73
71
  icon,
74
72
  }
75
- }`;
73
+ }`
76
74
  }
77
75
 
78
76
  /**
@@ -80,11 +78,11 @@ export default class QueryToken extends Query {
80
78
  * @param json
81
79
  * @returns {Response}
82
80
  */
83
- createResponse ( json ) {
84
- return new Response( {
81
+ createResponse (json) {
82
+ return new Response({
85
83
  query: this,
86
84
  json,
87
85
  dataKey: 'data.Token'
88
- } );
86
+ })
89
87
  }
90
88
  }
@@ -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 ResponseQueryUserActivity from '../response/ResponseQueryUserActivity';
50
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import ResponseQueryUserActivity from '../response/ResponseQueryUserActivity'
50
+ import { gql } from '@apollo/client/core'
51
51
 
52
52
  /**
53
53
  * Query for retrieving information about user activity
54
54
  */
55
55
  export default class QueryUserActivity extends Query {
56
56
  /**
57
- * Class constructor
58
- *
59
- * @param httpClient
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
60
59
  */
61
- constructor ( httpClient ) {
62
- super( httpClient );
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
63
62
 
64
63
  this.$__query = gql`query UserActivity (
65
64
  $bundleHash:String,
@@ -134,7 +133,7 @@ export default class QueryUserActivity extends Query {
134
133
  }
135
134
  }
136
135
  }
137
- }`;
136
+ }`
138
137
  }
139
138
 
140
139
  /**
@@ -143,11 +142,10 @@ export default class QueryUserActivity extends Query {
143
142
  * @param {object} json
144
143
  * @return {ResponseQueryUserActivity}
145
144
  */
146
- createResponse ( json ) {
147
- return new ResponseQueryUserActivity( {
145
+ createResponse (json) {
146
+ return new ResponseQueryUserActivity({
148
147
  query: this,
149
148
  json
150
- } );
149
+ })
151
150
  }
152
-
153
151
  }
@@ -45,19 +45,23 @@ 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 ResponseWalletBundle from '../response/ResponseWalletBundle';
50
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import ResponseWalletBundle from '../response/ResponseWalletBundle'
50
+ import { gql } from '@apollo/client/core'
51
51
 
52
52
  /**
53
53
  * Query for retrieving information about Wallet Bundles
54
54
  */
55
55
  export default class QueryWalletBundle extends Query {
56
+ /**
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
59
+ */
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
56
62
 
57
- constructor ( apolloClient ) {
58
- super( apolloClient );
59
- this.$__query = gql`query( $bundleHash: String, $bundleHashes: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $keys_values: [ MetaInput ], $latest: Boolean, $limit: Int, $order: String ) {
60
- WalletBundle( bundleHash: $bundleHash, bundleHashes: $bundleHashes, key: $key, keys: $keys, value: $value, values: $values, keys_values: $keys_values, latest: $latest, limit: $limit, order: $order ) {
63
+ this.$__query = gql`query( $bundleHashes: [ String! ] ) {
64
+ WalletBundle( bundleHashes: $bundleHashes ) {
61
65
  bundleHash,
62
66
  metas {
63
67
  molecularHash,
@@ -68,7 +72,7 @@ export default class QueryWalletBundle extends Query {
68
72
  },
69
73
  createdAt
70
74
  }
71
- }`;
75
+ }`
72
76
  }
73
77
 
74
78
  /**
@@ -77,46 +81,10 @@ export default class QueryWalletBundle extends Query {
77
81
  * @param {object} json
78
82
  * @return {ResponseWalletBundle}
79
83
  */
80
- createResponse ( json ) {
81
- return new ResponseWalletBundle( {
84
+ createResponse (json) {
85
+ return new ResponseWalletBundle({
82
86
  query: this,
83
87
  json
84
- } );
88
+ })
85
89
  }
86
-
87
- /**
88
- * Builds a GraphQL-friendly variables object based on input fields
89
- *
90
- * @param {string|array|null} bundleHash
91
- * @param {string|array|null} key
92
- * @param {string|array|null} value
93
- * @param {boolean|null} latest
94
- * @return {{}}
95
- */
96
- static createVariables ( {
97
- bundleHash = null,
98
- key = null,
99
- value = null,
100
- latest = true
101
- } ) {
102
-
103
- const variables = {
104
- latest: latest
105
- };
106
-
107
- if ( bundleHash ) {
108
- variables[ typeof bundleHash === 'string' ? 'bundleHash' : 'bundleHashes' ] = bundleHash;
109
- }
110
-
111
- if ( key ) {
112
- variables[ typeof key === 'string' ? 'key' : 'keys' ] = key;
113
- }
114
-
115
- if ( value ) {
116
- variables[ typeof value === 'string' ? 'value' : 'values' ] = value;
117
- }
118
-
119
- return variables;
120
- }
121
-
122
90
  }
@@ -45,19 +45,23 @@ 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 ResponseWalletList from '../response/ResponseWalletList';
50
- import { gql } from '@apollo/client/core';
48
+ import Query from './Query'
49
+ import ResponseWalletList from '../response/ResponseWalletList'
50
+ import { gql } from '@apollo/client/core'
51
51
 
52
52
  /**
53
53
  * Query for getting a list of Wallets
54
54
  */
55
55
  export default class QueryWalletList extends Query {
56
+ /**
57
+ * @param {ApolloClientWrapper} apolloClient
58
+ * @param {KnishIOClient} knishIOClient
59
+ */
60
+ constructor (apolloClient, knishIOClient) {
61
+ super(apolloClient, knishIOClient)
56
62
 
57
- constructor ( apolloClient ) {
58
- super( apolloClient );
59
- this.$__query = gql`query( $address: String, $bundleHash: String, $token: String, $position: String, $unspent: Boolean ) {
60
- Wallet( address: $address, bundleHash: $bundleHash, token: $token, position: $position, unspent: $unspent ) {
63
+ this.$__query = gql`query( $bundleHash: String, $tokenSlug: String ) {
64
+ Wallet( bundleHash: $bundleHash, tokenSlug: $tokenSlug ) {
61
65
  address,
62
66
  bundleHash,
63
67
  token {
@@ -66,10 +70,6 @@ export default class QueryWalletList extends Query {
66
70
  fungibility,
67
71
  supply
68
72
  },
69
- molecules {
70
- molecularHash,
71
- createdAt
72
- }
73
73
  tokenSlug,
74
74
  batchId,
75
75
  position,
@@ -87,7 +87,7 @@ export default class QueryWalletList extends Query {
87
87
  amount
88
88
  }
89
89
  }
90
- }`;
90
+ }`
91
91
  }
92
92
 
93
93
  /**
@@ -96,11 +96,10 @@ export default class QueryWalletList extends Query {
96
96
  * @param {object} json
97
97
  * @return {ResponseWalletList}
98
98
  */
99
- createResponse ( json ) {
100
- return new ResponseWalletList( {
99
+ createResponse (json) {
100
+ return new ResponseWalletList({
101
101
  query: this,
102
102
  json
103
- } );
103
+ })
104
104
  }
105
-
106
105
  }
@@ -45,15 +45,14 @@ 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 InvalidResponseException from '../exception/InvalidResponseException';
49
- import UnauthenticatedException from '../exception/UnauthenticatedException';
50
- import Dot from '../libraries/Dot';
48
+ import InvalidResponseException from '../exception/InvalidResponseException'
49
+ import UnauthenticatedException from '../exception/UnauthenticatedException'
50
+ import Dot from '../libraries/Dot'
51
51
 
52
52
  /**
53
53
  * Base Response class for processing node responses
54
54
  */
55
55
  export default class Response {
56
-
57
56
  /**
58
57
  * Class constructor
59
58
  *
@@ -61,35 +60,33 @@ export default class Response {
61
60
  * @param {object} json
62
61
  * @param {string|null} dataKey
63
62
  */
64
- constructor ( {
63
+ constructor ({
65
64
  query,
66
65
  json,
67
66
  dataKey = null
68
- } ) {
69
-
70
- this.dataKey = dataKey;
71
- this.errorKey = 'exception';
72
- this.$__payload = null;
73
- this.$__query = query;
74
- this.$__originResponse = json;
75
- this.$__response = json;
76
-
77
- if ( typeof this.$__response === 'undefined' || this.$__response === null ) {
78
- throw new InvalidResponseException();
67
+ }) {
68
+ this.dataKey = dataKey
69
+ this.errorKey = 'exception'
70
+ this.$__payload = null
71
+ this.$__query = query
72
+ this.$__originResponse = json
73
+ this.$__response = json
74
+
75
+ if (typeof this.$__response === 'undefined' || this.$__response === null) {
76
+ throw new InvalidResponseException()
79
77
  }
80
78
 
81
- if ( Dot.has( this.$__response, this.errorKey ) ) {
79
+ if (Dot.has(this.$__response, this.errorKey)) {
80
+ const error = Dot.get(this.$__response, this.errorKey)
82
81
 
83
- const error = Dot.get( this.$__response, this.errorKey );
84
-
85
- if ( String( error ).includes( 'Unauthenticated' ) ) {
86
- throw new UnauthenticatedException();
82
+ if (String(error).includes('Unauthenticated')) {
83
+ throw new UnauthenticatedException()
87
84
  }
88
85
 
89
- throw new InvalidResponseException();
86
+ throw new InvalidResponseException()
90
87
  }
91
88
 
92
- this.init();
89
+ this.init()
93
90
  }
94
91
 
95
92
  /**
@@ -102,45 +99,43 @@ export default class Response {
102
99
  * @return {*}
103
100
  */
104
101
  data () {
105
-
106
- if ( !this.dataKey ) {
107
- return this.response();
102
+ if (!this.dataKey) {
103
+ return this.response()
108
104
  }
109
105
 
110
106
  // Check key & return custom data from the response
111
- if ( !Dot.has( this.response(), this.dataKey ) ) {
112
- throw new InvalidResponseException();
107
+ if (!Dot.has(this.response(), this.dataKey)) {
108
+ throw new InvalidResponseException()
113
109
  }
114
110
 
115
- return Dot.get( this.response(), this.dataKey );
111
+ return Dot.get(this.response(), this.dataKey)
116
112
  }
117
113
 
118
114
  /**
119
115
  * @return {object}
120
116
  */
121
117
  response () {
122
- return this.$__response;
118
+ return this.$__response
123
119
  }
124
120
 
125
121
  /**
126
122
  * @return {*}
127
123
  */
128
124
  payload () {
129
- return null;
125
+ return null
130
126
  }
131
127
 
132
128
  /**
133
129
  * @return {Query}
134
130
  */
135
131
  query () {
136
- return this.$__query;
132
+ return this.$__query
137
133
  }
138
134
 
139
135
  /**
140
136
  * @return {*}
141
137
  */
142
138
  status () {
143
- return null;
139
+ return null
144
140
  }
145
-
146
141
  }
@@ -46,8 +46,8 @@ Please visit https://github.com/WishKnish/KnishIO-Client-JS for information.
46
46
  License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
47
47
  */
48
48
 
49
- import Query from '../query/Query';
50
- import Response from './Response';
49
+ import Query from '../query/Query'
50
+ import Response from './Response'
51
51
 
52
52
  export default class ResponseActiveSession extends Response {
53
53
  /**
@@ -56,14 +56,14 @@ export default class ResponseActiveSession extends Response {
56
56
  * @param {Query} query
57
57
  * @param {object} json
58
58
  */
59
- constructor ( {
59
+ constructor ({
60
60
  query,
61
61
  json
62
- } ) {
63
- super( {
62
+ }) {
63
+ super({
64
64
  query,
65
65
  json,
66
66
  dataKey: 'data.ActiveSession'
67
- } );
67
+ })
68
68
  }
69
69
  }