@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,13 +45,12 @@ 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 BaseException from './BaseException';
48
+ import BaseException from './BaseException'
49
49
 
50
50
  /**
51
51
  * Thrown when V isotope atom amounts do not add up to zero
52
52
  */
53
53
  export default class TransferUnbalancedException extends BaseException {
54
-
55
54
  /**
56
55
  * Class constructor
57
56
  *
@@ -59,8 +58,8 @@ export default class TransferUnbalancedException extends BaseException {
59
58
  * @param {string|null} fileName
60
59
  * @param {number|null} lineNumber
61
60
  */
62
- constructor ( message = 'Token transfer atoms are unbalanced', fileName = null, lineNumber = null ) {
63
- super( message, fileName, lineNumber );
64
- this.name = 'TransferUnbalancedException';
61
+ constructor (message = 'Token transfer atoms are unbalanced', fileName = null, lineNumber = null) {
62
+ super(message, fileName, lineNumber)
63
+ this.name = 'TransferUnbalancedException'
65
64
  }
66
65
  }
@@ -45,13 +45,12 @@ 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 BaseException from './BaseException';
48
+ import BaseException from './BaseException'
49
49
 
50
50
  /**
51
51
  * Thrown when attempting to transact without an auth token
52
52
  */
53
53
  export default class UnauthenticatedException extends BaseException {
54
-
55
54
  /**
56
55
  * Class constructor
57
56
  *
@@ -59,8 +58,8 @@ export default class UnauthenticatedException extends BaseException {
59
58
  * @param {string|null} fileName
60
59
  * @param {number|null} lineNumber
61
60
  */
62
- constructor ( message = 'Authorization token missing or invalid.', fileName = null, lineNumber = null ) {
63
- super( message, fileName, lineNumber );
64
- this.name = 'UnauthenticatedException';
61
+ constructor (message = 'Authorization token missing or invalid.', fileName = null, lineNumber = null) {
62
+ super(message, fileName, lineNumber)
63
+ this.name = 'UnauthenticatedException'
65
64
  }
66
65
  }
@@ -45,49 +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 { ApolloLink } from '@apollo/client/core';
49
-
50
-
51
- class AuthLink extends ApolloLink {
52
-
53
- constructor () {
54
- super();
55
-
56
- this.auth = '';
57
- }
48
+ import BaseException from './BaseException'
58
49
 
50
+ /**
51
+ * Thrown when failing to retrieve shadow wallets
52
+ */
53
+ export default class WalletCredentialException extends BaseException {
59
54
  /**
55
+ * Class constructor
60
56
  *
61
- * @return {string}
62
- */
63
- getAuthToken () {
64
- return this.auth;
65
- }
66
-
67
- /**
68
- * @param {string} auth
57
+ * @param {string} message
58
+ * @param {string|null} fileName
59
+ * @param {number|null} lineNumber
69
60
  */
70
- setAuthToken ( auth ) {
71
- this.auth = auth;
72
- }
73
-
74
- /**
75
- *
76
- * @param {Operation} operation
77
- * @param {NextLink | undefined} forward
78
- * @returns {Observable<FetchResult> | null}
79
- */
80
- request ( operation, forward ) {
81
-
82
- operation.setContext( ( { headers = {} } ) => ( {
83
- headers: {
84
- ...headers,
85
- 'X-Auth-Token': this.getAuthToken()
86
- }
87
- } ) );
88
-
89
- return forward( operation );
61
+ constructor (message = 'Attempting to create a wallet with no credentials (secret or bundle hash)', fileName = null, lineNumber = null) {
62
+ super(message, fileName, lineNumber)
63
+ this.name = 'WalletCredentialException'
90
64
  }
91
65
  }
92
-
93
- export default AuthLink;
@@ -45,13 +45,12 @@ 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 BaseException from './BaseException';
48
+ import BaseException from './BaseException'
49
49
 
50
50
  /**
51
51
  * Thrown when failing to retrieve shadow wallets
52
52
  */
53
53
  export default class WalletShadowException extends BaseException {
54
-
55
54
  /**
56
55
  * Class constructor
57
56
  *
@@ -59,8 +58,8 @@ export default class WalletShadowException extends BaseException {
59
58
  * @param {string|null} fileName
60
59
  * @param {number|null} lineNumber
61
60
  */
62
- constructor ( message = 'The shadow wallet does not exist', fileName = null, lineNumber = null ) {
63
- super( message, fileName, lineNumber );
64
- this.name = 'WalletShadowException';
61
+ constructor (message = 'The shadow wallet does not exist', fileName = null, lineNumber = null) {
62
+ super(message, fileName, lineNumber)
63
+ this.name = 'WalletShadowException'
65
64
  }
66
65
  }
@@ -45,13 +45,12 @@ 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 BaseException from './BaseException';
48
+ import BaseException from './BaseException'
49
49
 
50
50
  /**
51
51
  * Thrown when trying to use an inappropriate token slug for a particular isotope
52
52
  */
53
53
  export default class WrongTokenTypeException extends BaseException {
54
-
55
54
  /**
56
55
  * Class constructor
57
56
  *
@@ -59,8 +58,8 @@ export default class WrongTokenTypeException extends BaseException {
59
58
  * @param {string|null} fileName
60
59
  * @param {number|null} lineNumber
61
60
  */
62
- constructor ( message = 'Wrong type of token for this isotope', fileName = null, lineNumber = null ) {
63
- super( message, fileName, lineNumber );
64
- this.name = 'WrongTokenTypeException';
61
+ constructor (message = 'Wrong type of token for this isotope', fileName = null, lineNumber = null) {
62
+ super(message, fileName, lineNumber)
63
+ this.name = 'WrongTokenTypeException'
65
64
  }
66
65
  }
@@ -45,31 +45,31 @@ 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 AtomIndexException from './AtomIndexException';
49
- import AtomsMissingException from './AtomsMissingException';
50
- import AuthorizationRejectedException from './AuthorizationRejectedException';
51
- import BalanceInsufficientException from './BalanceInsufficientException';
52
- import BatchIdException from './BatchIdException';
53
- import CodeException from './CodeException';
54
- import InvalidResponseException from './InvalidResponseException';
55
- import MetaMissingException from './MetaMissingException';
56
- import MolecularHashMismatchException from './MolecularHashMismatchException';
57
- import MolecularHashMissingException from './MolecularHashMissingException';
58
- import NegativeAmountException from './NegativeAmountException';
59
- import PolicyInvalidException from './PolicyInvalidException';
60
- import SignatureMalformedException from './SignatureMalformedException';
61
- import SignatureMismatchException from './SignatureMismatchException';
62
- import StackableUnitAmountException from './StackableUnitAmountException';
63
- import StackableUnitDecimalsException from './StackableUnitDecimalsException';
64
- import TransferBalanceException from './TransferBalanceException';
65
- import TransferMalformedException from './TransferMalformedException';
66
- import TransferMismatchedException from './TransferMismatchedException';
67
- import TransferRemainderException from './TransferRemainderException';
68
- import TransferToSelfException from './TransferToSelfException';
69
- import TransferUnbalancedException from './TransferUnbalancedException';
70
- import UnauthenticatedException from './UnauthenticatedException';
71
- import WalletShadowException from './WalletShadowException';
72
- import WrongTokenTypeException from './WrongTokenTypeException';
48
+ import AtomIndexException from './AtomIndexException'
49
+ import AtomsMissingException from './AtomsMissingException'
50
+ import AuthorizationRejectedException from './AuthorizationRejectedException'
51
+ import BalanceInsufficientException from './BalanceInsufficientException'
52
+ import BatchIdException from './BatchIdException'
53
+ import CodeException from './CodeException'
54
+ import InvalidResponseException from './InvalidResponseException'
55
+ import MetaMissingException from './MetaMissingException'
56
+ import MolecularHashMismatchException from './MolecularHashMismatchException'
57
+ import MolecularHashMissingException from './MolecularHashMissingException'
58
+ import NegativeAmountException from './NegativeAmountException'
59
+ import PolicyInvalidException from './PolicyInvalidException'
60
+ import SignatureMalformedException from './SignatureMalformedException'
61
+ import SignatureMismatchException from './SignatureMismatchException'
62
+ import StackableUnitAmountException from './StackableUnitAmountException'
63
+ import StackableUnitDecimalsException from './StackableUnitDecimalsException'
64
+ import TransferBalanceException from './TransferBalanceException'
65
+ import TransferMalformedException from './TransferMalformedException'
66
+ import TransferMismatchedException from './TransferMismatchedException'
67
+ import TransferRemainderException from './TransferRemainderException'
68
+ import TransferToSelfException from './TransferToSelfException'
69
+ import TransferUnbalancedException from './TransferUnbalancedException'
70
+ import UnauthenticatedException from './UnauthenticatedException'
71
+ import WalletShadowException from './WalletShadowException'
72
+ import WrongTokenTypeException from './WrongTokenTypeException'
73
73
 
74
74
  export {
75
75
  AtomIndexException,
@@ -97,4 +97,4 @@ export {
97
97
  UnauthenticatedException,
98
98
  WalletShadowException,
99
99
  WrongTokenTypeException
100
- };
100
+ }
package/src/index.js CHANGED
@@ -46,12 +46,11 @@ 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 Atom from './Atom';
50
- import Molecule from './Molecule';
51
- import Wallet from './Wallet';
52
- import Meta from './Meta';
53
- import KnishIOClient from './KnishIOClient';
54
- import Test from './test/Test';
49
+ import Atom from './Atom'
50
+ import Molecule from './Molecule'
51
+ import Wallet from './Wallet'
52
+ import Meta from './Meta'
53
+ import KnishIOClient from './KnishIOClient'
55
54
  import {
56
55
  base64ToHex,
57
56
  bufferToHexString,
@@ -61,11 +60,11 @@ import {
61
60
  hexToBase64,
62
61
  isHex,
63
62
  randomString
64
- } from './libraries/strings';
63
+ } from './libraries/strings'
65
64
  import {
66
65
  generateBundleHash,
67
66
  generateSecret
68
- } from './libraries/crypto';
67
+ } from './libraries/crypto'
69
68
 
70
69
  export {
71
70
  Atom,
@@ -73,7 +72,6 @@ export {
73
72
  Wallet,
74
73
  Meta,
75
74
  KnishIOClient,
76
- Test,
77
75
 
78
76
  // strings
79
77
  chunkSubstr,
@@ -88,4 +86,4 @@ export {
88
86
  // crypto
89
87
  generateSecret,
90
88
  generateBundleHash
91
- };
89
+ }
@@ -46,14 +46,13 @@ 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 Meta from './Meta';
50
- import RuleArgumentException from './exception/RuleArgumentException';
51
- import { isNumeric } from '../../libraries/strings';
52
- import { intersect } from '../../libraries/array';
53
- import CodeException from '../../exception/CodeException';
49
+ import Meta from './Meta'
50
+ import RuleArgumentException from './exception/RuleArgumentException'
51
+ import { isNumeric } from '../../libraries/strings'
52
+ import { intersect } from '../../libraries/array'
53
+ import CodeException from '../../exception/CodeException'
54
54
 
55
55
  export default class Callback {
56
-
57
56
  /**
58
57
  *
59
58
  * @param {string} action
@@ -65,7 +64,7 @@ export default class Callback {
65
64
  * @param {string|null} amount
66
65
  * @param {string|null} comparison
67
66
  */
68
- constructor ( {
67
+ constructor ({
69
68
  action,
70
69
  metaType = null,
71
70
  metaId = null,
@@ -74,214 +73,213 @@ export default class Callback {
74
73
  token = null,
75
74
  amount = null,
76
75
  comparison = null
77
- } ) {
78
- if ( meta ) {
79
- this.meta = meta;
76
+ }) {
77
+ if (meta) {
78
+ this.meta = meta
80
79
  }
81
80
 
82
- if ( !action ) {
83
- throw new RuleArgumentException( 'Callback structure violated, missing mandatory "action" parameter.' );
81
+ if (!action) {
82
+ throw new RuleArgumentException('Callback structure violated, missing mandatory "action" parameter.')
84
83
  }
85
84
 
86
- this.__metaId = metaId;
87
- this.__metaType = metaType;
88
- this.__action = action;
89
- this.__address = address;
90
- this.__token = token;
91
- this.__amount = amount;
92
- this.__comparison = comparison;
85
+ this.__metaId = metaId
86
+ this.__metaType = metaType
87
+ this.__action = action
88
+ this.__address = address
89
+ this.__token = token
90
+ this.__amount = amount
91
+ this.__comparison = comparison
93
92
  }
94
93
 
95
94
  /**
96
95
  *
97
96
  * @param {string} comparison
98
97
  */
99
- set comparison ( comparison ) {
100
- this.__comparison = comparison;
98
+ set comparison (comparison) {
99
+ this.__comparison = comparison
101
100
  }
102
101
 
103
102
  /**
104
103
  *
105
104
  * @param {string} amount
106
105
  */
107
- set amount ( amount ) {
108
- if ( !isNumeric( amount ) ) {
109
- throw new CodeException('Parameter amount should be a string containing numbers');
106
+ set amount (amount) {
107
+ if (!isNumeric(amount)) {
108
+ throw new CodeException('Parameter amount should be a string containing numbers')
110
109
  }
111
- this.__amount = amount;
110
+ this.__amount = amount
112
111
  }
113
112
 
114
113
  /**
115
114
  *
116
115
  * @param {string} token
117
116
  */
118
- set token ( token ) {
119
- this.__token = token;
117
+ set token (token) {
118
+ this.__token = token
120
119
  }
121
120
 
122
121
  /**
123
122
  *
124
123
  * @param {string} address
125
124
  */
126
- set address ( address ) {
127
- this.__address = address;
125
+ set address (address) {
126
+ this.__address = address
128
127
  }
129
128
 
130
129
  /**
131
130
  *
132
131
  * @param {Meta|object} meta
133
132
  */
134
- set meta ( meta ) {
135
- this.__meta = meta instanceof Meta ? meta : Meta.toObject( meta );
133
+ set meta (meta) {
134
+ this.__meta = meta instanceof Meta ? meta : Meta.toObject(meta)
136
135
  }
137
136
 
138
137
  /**
139
138
  *
140
139
  * @param {string} metaType
141
140
  */
142
- set metaType ( metaType ) {
143
- this.__metaType = metaType;
141
+ set metaType (metaType) {
142
+ this.__metaType = metaType
144
143
  }
145
144
 
146
145
  /**
147
146
  *
148
147
  * @param {string} metaId
149
148
  */
150
- set metaId ( metaId ) {
151
- this.__metaId = metaId;
149
+ set metaId (metaId) {
150
+ this.__metaId = metaId
152
151
  }
153
152
 
154
-
155
153
  /**
156
154
  *
157
- * @return {{action: string}}
155
+ * @param {object} object
156
+ *
157
+ * @return Callback
158
158
  */
159
- toJSON () {
160
- const meta = {
161
- action: this.__action
162
- };
159
+ static toObject (object) {
160
+ const callback = new Callback({
161
+ action: object.action
162
+ })
163
163
 
164
- if ( this.__metaType ) {
165
- meta.metaType = this.__metaType;
164
+ if (object.metaType) {
165
+ callback.metaType = object.metaType
166
166
  }
167
- if ( this.__metaId ) {
168
- meta.metaId = this.__metaId;
167
+
168
+ if (object.metaId) {
169
+ callback.metaId = object.metaId
169
170
  }
170
- if ( this.__meta ) {
171
- meta.meta = this.__meta;
171
+
172
+ if (object.meta) {
173
+ callback.meta = object.meta
172
174
  }
173
175
 
174
- if ( this.__address ) {
175
- meta.address = this.__address;
176
+ if (object.address) {
177
+ callback.address = object.address
176
178
  }
177
179
 
178
- if ( this.__token ) {
179
- meta.token = this.__token;
180
+ if (object.token) {
181
+ callback.token = object.token
180
182
  }
181
183
 
182
- if ( this.__amount ) {
183
- meta.amount = this.__amount;
184
+ if (object.amount) {
185
+ callback.amount = object.amount
184
186
  }
185
187
 
186
- if ( this.__comparison ) {
187
- meta.comparison = this.__comparison;
188
+ if (object.comparison) {
189
+ callback.comparison = object.comparison
188
190
  }
189
191
 
190
- return meta;
192
+ return callback
191
193
  }
192
194
 
193
195
  /**
194
196
  *
195
- * @param {object} object
196
- *
197
- * @return Callback
197
+ * @return {{action: string}}
198
198
  */
199
- static toObject ( object ) {
200
- const callback = new Callback( {
201
- action: object.action
202
- } );
203
-
204
- if ( object.metaType ) {
205
- callback.metaType = object.metaType;
199
+ toJSON () {
200
+ const meta = {
201
+ action: this.__action
206
202
  }
207
203
 
208
- if ( object.metaId ) {
209
- callback.metaId = object.metaId;
204
+ if (this.__metaType) {
205
+ meta.metaType = this.__metaType
210
206
  }
211
-
212
- if ( object.meta ) {
213
- callback.meta = object.meta;
207
+ if (this.__metaId) {
208
+ meta.metaId = this.__metaId
209
+ }
210
+ if (this.__meta) {
211
+ meta.meta = this.__meta
214
212
  }
215
213
 
216
- if ( object.address ) {
217
- callback.address = object.address;
214
+ if (this.__address) {
215
+ meta.address = this.__address
218
216
  }
219
217
 
220
- if ( object.token ) {
221
- callback.token = object.token;
218
+ if (this.__token) {
219
+ meta.token = this.__token
222
220
  }
223
221
 
224
- if ( object.amount ) {
225
- callback.amount = object.amount;
222
+ if (this.__amount) {
223
+ meta.amount = this.__amount
226
224
  }
227
225
 
228
- if ( object.comparison ) {
229
- callback.comparison = object.comparison;
226
+ if (this.__comparison) {
227
+ meta.comparison = this.__comparison
230
228
  }
231
229
 
232
- return callback;
230
+ return meta
233
231
  }
234
232
 
235
233
  /**
236
234
  * @return {boolean}
237
235
  */
238
236
  isReject () {
239
- return this._is( 'reject' );
237
+ return this._is('reject')
240
238
  }
241
239
 
242
240
  /**
243
241
  * @return {boolean}
244
242
  */
245
243
  isMeta () {
246
- const prop = intersect( Object.keys( this.toJSON() ), ['action', 'metaId', 'metaType', 'meta'] );
244
+ const prop = intersect(Object.keys(this.toJSON()), ['action', 'metaId', 'metaType', 'meta'])
247
245
 
248
- return prop.length === 4 && this._is( 'meta' );
246
+ return prop.length === 4 && this._is('meta')
249
247
  }
250
248
 
251
249
  /**
252
250
  * @return {boolean}
253
251
  */
254
252
  isCollect () {
255
- const prop = intersect( Object.keys( this.toJSON() ), ['action', 'address', 'token', 'amount', 'comparison'] );
253
+ const prop = intersect(Object.keys(this.toJSON()), ['action', 'address', 'token', 'amount', 'comparison'])
256
254
 
257
- return prop.length === 5 && this._is( 'collect' );
255
+ return prop.length === 5 && this._is('collect')
258
256
  }
259
257
 
260
258
  /**
261
259
  * @return {boolean}
262
260
  */
263
261
  isBuffer () {
264
- const prop = intersect( Object.keys( this.toJSON() ), ['action', 'address', 'token', 'amount', 'comparison'] );
262
+ const prop = intersect(Object.keys(this.toJSON()), ['action', 'address', 'token', 'amount', 'comparison'])
265
263
 
266
- return prop.length === 5 && this._is( 'buffer' );
264
+ return prop.length === 5 && this._is('buffer')
267
265
  }
268
266
 
269
267
  /**
270
268
  * @return {boolean}
271
269
  */
272
270
  isRemit () {
273
- const prop = intersect( Object.keys( this.toJSON() ), ['action', 'token', 'amount'] );
271
+ const prop = intersect(Object.keys(this.toJSON()), ['action', 'token', 'amount'])
274
272
 
275
- return prop.length === 3 && this._is( 'remit' );
273
+ return prop.length === 3 && this._is('remit')
276
274
  }
277
275
 
278
276
  /**
279
277
  * @return {boolean}
280
278
  */
281
279
  isBurn () {
282
- const prop = intersect( Object.keys( this.toJSON() ), ['action', 'token', 'amount', 'comparison'] );
280
+ const prop = intersect(Object.keys(this.toJSON()), ['action', 'token', 'amount', 'comparison'])
283
281
 
284
- return prop.length === 4 && this._is( 'burn' );
282
+ return prop.length === 4 && this._is('burn')
285
283
  }
286
284
 
287
285
  /**
@@ -290,7 +288,7 @@ export default class Callback {
290
288
  * @return {boolean}
291
289
  * @private
292
290
  */
293
- _is( type ) {
294
- return this.__action.toLowerCase() === type.toLowerCase();
291
+ _is (type) {
292
+ return this.__action.toLowerCase() === type.toLowerCase()
295
293
  }
296
294
  }