@wishknish/knishio-client-ts 0.7.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.
- package/LICENSE +674 -0
- package/README.md +425 -0
- package/dist/index.cjs +9961 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.iife.js +32241 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.js +9853 -0
- package/dist/index.js.map +1 -0
- package/package.json +113 -0
- package/src/AuthToken.ts +214 -0
- package/src/KnishIOClient.ts +2020 -0
- package/src/constants.ts +398 -0
- package/src/core/Atom.ts +646 -0
- package/src/core/AtomMeta.ts +278 -0
- package/src/core/Meta.ts +428 -0
- package/src/core/Molecule.ts +825 -0
- package/src/core/PolicyMeta.ts +130 -0
- package/src/core/TokenUnit.ts +148 -0
- package/src/core/Wallet.ts +467 -0
- package/src/exception/AtomIndexException.ts +97 -0
- package/src/exception/AtomsMissingException.ts +109 -0
- package/src/exception/AuthorizationRejectedException.ts +63 -0
- package/src/exception/BalanceInsufficientException.ts +58 -0
- package/src/exception/BaseException.ts +275 -0
- package/src/exception/BatchIdException.ts +58 -0
- package/src/exception/CodeException.ts +119 -0
- package/src/exception/DecryptionKeyException.ts +65 -0
- package/src/exception/InvalidResponseException.ts +112 -0
- package/src/exception/MetaMissingException.ts +58 -0
- package/src/exception/MolecularHashMismatchException.ts +115 -0
- package/src/exception/MolecularHashMissingException.ts +58 -0
- package/src/exception/NegativeAmountException.ts +58 -0
- package/src/exception/PolicyInvalidException.ts +58 -0
- package/src/exception/SignatureMalformedException.ts +58 -0
- package/src/exception/SignatureMismatchException.ts +98 -0
- package/src/exception/StackableUnitAmountException.ts +65 -0
- package/src/exception/StackableUnitDecimalsException.ts +65 -0
- package/src/exception/TransferBalanceException.ts +98 -0
- package/src/exception/TransferMalformedException.ts +58 -0
- package/src/exception/TransferMismatchedException.ts +58 -0
- package/src/exception/TransferRemainderException.ts +58 -0
- package/src/exception/TransferToSelfException.ts +58 -0
- package/src/exception/TransferUnbalancedException.ts +58 -0
- package/src/exception/UnauthenticatedException.ts +147 -0
- package/src/exception/WalletCredentialException.ts +108 -0
- package/src/exception/WalletShadowException.ts +65 -0
- package/src/exception/WrongTokenTypeException.ts +58 -0
- package/src/exception/index.ts +272 -0
- package/src/index.ts +512 -0
- package/src/instance/rules/Callback.ts +257 -0
- package/src/instance/rules/Condition.ts +96 -0
- package/src/instance/rules/Meta.ts +163 -0
- package/src/instance/rules/Rule.ts +29 -0
- package/src/instance/rules/exception/RuleArgumentException.ts +65 -0
- package/src/libraries/CheckMolecule.ts +581 -0
- package/src/libraries/Decimal.ts +94 -0
- package/src/libraries/Dot.ts +202 -0
- package/src/libraries/GraphQLClient.ts +276 -0
- package/src/libraries/Hex.ts +155 -0
- package/src/libraries/UrqlClientWrapper.ts +336 -0
- package/src/libraries/array.ts +91 -0
- package/src/libraries/crypto.ts +816 -0
- package/src/libraries/strings.ts +458 -0
- package/src/mutation/Mutation.ts +103 -0
- package/src/mutation/MutationActiveSession.ts +108 -0
- package/src/mutation/MutationClaimShadowWallet.ts +91 -0
- package/src/mutation/MutationCreateIdentifier.ts +86 -0
- package/src/mutation/MutationCreateMeta.ts +92 -0
- package/src/mutation/MutationCreateRule.ts +90 -0
- package/src/mutation/MutationCreateToken.ts +92 -0
- package/src/mutation/MutationCreateWallet.ts +78 -0
- package/src/mutation/MutationDepositBufferToken.ts +72 -0
- package/src/mutation/MutationLinkIdentifier.ts +87 -0
- package/src/mutation/MutationProposeMolecule.ts +147 -0
- package/src/mutation/MutationRequestAuthorization.ts +77 -0
- package/src/mutation/MutationRequestAuthorizationGuest.ts +85 -0
- package/src/mutation/MutationRequestTokens.ts +98 -0
- package/src/mutation/MutationTransferTokens.ts +87 -0
- package/src/mutation/MutationWithdrawBufferToken.ts +73 -0
- package/src/query/Query.ts +187 -0
- package/src/query/QueryActiveSession.ts +89 -0
- package/src/query/QueryAtom.ts +275 -0
- package/src/query/QueryBalance.ts +102 -0
- package/src/query/QueryBatch.ts +145 -0
- package/src/query/QueryBatchHistory.ts +86 -0
- package/src/query/QueryContinuId.ts +91 -0
- package/src/query/QueryMetaType.ts +177 -0
- package/src/query/QueryMetaTypeViaAtom.ts +199 -0
- package/src/query/QueryPolicy.ts +91 -0
- package/src/query/QueryToken.ts +90 -0
- package/src/query/QueryUserActivity.ts +153 -0
- package/src/query/QueryWalletBundle.ts +92 -0
- package/src/query/QueryWalletList.ts +106 -0
- package/src/response/EnhancedResponse.ts +345 -0
- package/src/response/Response.ts +254 -0
- package/src/response/ResponseActiveSession.ts +72 -0
- package/src/response/ResponseAtom.ts +132 -0
- package/src/response/ResponseAuthorizationGuest.ts +119 -0
- package/src/response/ResponseBalance.ts +153 -0
- package/src/response/ResponseClaimShadowWallet.ts +56 -0
- package/src/response/ResponseContinuId.ts +101 -0
- package/src/response/ResponseCreateIdentifier.ts +56 -0
- package/src/response/ResponseCreateMeta.ts +58 -0
- package/src/response/ResponseCreateRule.ts +56 -0
- package/src/response/ResponseCreateToken.ts +58 -0
- package/src/response/ResponseCreateWallet.ts +58 -0
- package/src/response/ResponseLinkIdentifier.ts +87 -0
- package/src/response/ResponseMetaBatch.ts +72 -0
- package/src/response/ResponseMetaType.ts +108 -0
- package/src/response/ResponseMetaTypeViaAtom.ts +108 -0
- package/src/response/ResponsePolicy.ts +90 -0
- package/src/response/ResponseProposeMolecule.ts +155 -0
- package/src/response/ResponseQueryActiveSession.ts +105 -0
- package/src/response/ResponseQueryUserActivity.ts +89 -0
- package/src/response/ResponseRequestAuthorization.ts +100 -0
- package/src/response/ResponseRequestAuthorizationGuest.ts +133 -0
- package/src/response/ResponseRequestTokens.ts +58 -0
- package/src/response/ResponseTransferTokens.ts +72 -0
- package/src/response/ResponseWalletBundle.ts +95 -0
- package/src/response/ResponseWalletList.ts +165 -0
- package/src/schemas/index.ts +457 -0
- package/src/subscribe/ActiveSessionSubscribe.ts +72 -0
- package/src/subscribe/ActiveWalletSubscribe.ts +99 -0
- package/src/subscribe/CreateMoleculeSubscribe.ts +106 -0
- package/src/subscribe/Subscribe.ts +182 -0
- package/src/subscribe/WalletStatusSubscribe.ts +70 -0
- package/src/subscribe/index.ts +59 -0
- package/src/types/assertions.ts +722 -0
- package/src/types/client.ts +567 -0
- package/src/types/crypto.ts +541 -0
- package/src/types/graphql.ts +630 -0
- package/src/types/guards.ts +659 -0
- package/src/types/index.ts +614 -0
- package/src/types/response.ts +133 -0
- package/src/types/template-literals.ts +382 -0
- package/src/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts +580 -0
- package/src/validation/ValidationService.ts +607 -0
- package/src/validation/schemas.ts +447 -0
- package/src/versions/HashAtom.ts +170 -0
- package/src/versions/Version4.ts +120 -0
- package/src/versions/index.ts +80 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
(
|
|
3
|
+
(/(
|
|
4
|
+
(//(
|
|
5
|
+
(///(
|
|
6
|
+
(/////(
|
|
7
|
+
(//////( )
|
|
8
|
+
(////////( (/)
|
|
9
|
+
(////////( (///)
|
|
10
|
+
(//////////( (////)
|
|
11
|
+
(//////////( (//////)
|
|
12
|
+
(////////////( (///////)
|
|
13
|
+
(/////////////( (/////////)
|
|
14
|
+
(//////////////( (///////////)
|
|
15
|
+
(///////////////( (/////////////)
|
|
16
|
+
(////////////////( (//////////////)
|
|
17
|
+
((((((((((((((((((( (((((((((((((((
|
|
18
|
+
((((((((((((((((((( ((((((((((((((
|
|
19
|
+
((((((((((((((((((( ((((((((((((((
|
|
20
|
+
(((((((((((((((((((( (((((((((((((
|
|
21
|
+
(((((((((((((((((((( ((((((((((((
|
|
22
|
+
((((((((((((((((((( ((((((((((((
|
|
23
|
+
((((((((((((((((((( ((((((((((
|
|
24
|
+
((((((((((((((((((/ (((((((((
|
|
25
|
+
(((((((((((((((((( ((((((((
|
|
26
|
+
((((((((((((((((( (((((((
|
|
27
|
+
(((((((((((((((((( (((((
|
|
28
|
+
################# ##
|
|
29
|
+
################ #
|
|
30
|
+
################# ##
|
|
31
|
+
%################ ###
|
|
32
|
+
###############( ####
|
|
33
|
+
############### ####
|
|
34
|
+
############### ######
|
|
35
|
+
%#############( (#######
|
|
36
|
+
%############# #########
|
|
37
|
+
############( ##########
|
|
38
|
+
########### #############
|
|
39
|
+
######### ##############
|
|
40
|
+
%######
|
|
41
|
+
|
|
42
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import Response from './Response'
|
|
50
|
+
import type Query from '@/query/Query'
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Response for Active Session queries
|
|
54
|
+
*/
|
|
55
|
+
export default class ResponseActiveSession extends Response {
|
|
56
|
+
/**
|
|
57
|
+
* Constructor
|
|
58
|
+
*/
|
|
59
|
+
constructor({
|
|
60
|
+
query,
|
|
61
|
+
json
|
|
62
|
+
}: {
|
|
63
|
+
query: Query
|
|
64
|
+
json: Record<string, any>
|
|
65
|
+
}) {
|
|
66
|
+
super({
|
|
67
|
+
query,
|
|
68
|
+
json,
|
|
69
|
+
dataKey: 'data.ActiveSession'
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/*
|
|
2
|
+
(
|
|
3
|
+
(/(
|
|
4
|
+
(//(
|
|
5
|
+
(///(
|
|
6
|
+
(/////(
|
|
7
|
+
(//////( )
|
|
8
|
+
(////////( (/)
|
|
9
|
+
(////////( (///)
|
|
10
|
+
(//////////( (////)
|
|
11
|
+
(//////////( (//////)
|
|
12
|
+
(////////////( (///////)
|
|
13
|
+
(/////////////( (/////////)
|
|
14
|
+
(//////////////( (///////////)
|
|
15
|
+
(///////////////( (/////////////)
|
|
16
|
+
(////////////////( (//////////////)
|
|
17
|
+
((((((((((((((((((( (((((((((((((((
|
|
18
|
+
((((((((((((((((((( ((((((((((((((
|
|
19
|
+
((((((((((((((((((( ((((((((((((((
|
|
20
|
+
(((((((((((((((((((( (((((((((((((
|
|
21
|
+
(((((((((((((((((((( ((((((((((((
|
|
22
|
+
((((((((((((((((((( ((((((((((((
|
|
23
|
+
((((((((((((((((((( ((((((((((
|
|
24
|
+
((((((((((((((((((/ (((((((((
|
|
25
|
+
(((((((((((((((((( ((((((((
|
|
26
|
+
((((((((((((((((( (((((((
|
|
27
|
+
(((((((((((((((((( (((((
|
|
28
|
+
################# ##
|
|
29
|
+
################ #
|
|
30
|
+
################# ##
|
|
31
|
+
%################ ###
|
|
32
|
+
###############( ####
|
|
33
|
+
############### ####
|
|
34
|
+
############### ######
|
|
35
|
+
%#############( (#######
|
|
36
|
+
%############# #########
|
|
37
|
+
############( ##########
|
|
38
|
+
########### #############
|
|
39
|
+
######### ##############
|
|
40
|
+
%######
|
|
41
|
+
|
|
42
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import type Query from '../query/Query'
|
|
50
|
+
import Response from './Response'
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* ResponseAtom class - Response for Atom Query
|
|
54
|
+
* Matches JavaScript SDK ResponseAtom implementation exactly
|
|
55
|
+
*/
|
|
56
|
+
export default class ResponseAtom extends Response {
|
|
57
|
+
/**
|
|
58
|
+
* Class constructor
|
|
59
|
+
* Matches JavaScript SDK constructor signature exactly
|
|
60
|
+
*/
|
|
61
|
+
constructor({
|
|
62
|
+
query,
|
|
63
|
+
json
|
|
64
|
+
}: {
|
|
65
|
+
query: Query
|
|
66
|
+
json: any
|
|
67
|
+
}) {
|
|
68
|
+
super({
|
|
69
|
+
query,
|
|
70
|
+
json,
|
|
71
|
+
dataKey: 'data.Atom'
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns atom instance results
|
|
77
|
+
* Matches JavaScript SDK payload method exactly
|
|
78
|
+
*/
|
|
79
|
+
payload(): any | null {
|
|
80
|
+
const metaTypeData = this.data()
|
|
81
|
+
|
|
82
|
+
if (!metaTypeData) {
|
|
83
|
+
return null
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const response: any = {
|
|
87
|
+
instances: [],
|
|
88
|
+
instanceCount: {},
|
|
89
|
+
paginatorInfo: {}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (metaTypeData.instances) {
|
|
93
|
+
response.instances = metaTypeData.instances
|
|
94
|
+
|
|
95
|
+
for (const instanceKey in response.instances) {
|
|
96
|
+
const instance = response.instances[instanceKey]
|
|
97
|
+
if (instance.metasJson) {
|
|
98
|
+
response.instances[instanceKey].metas = JSON.parse(instance.metasJson)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (metaTypeData.instanceCount) {
|
|
104
|
+
response.instanceCount = metaTypeData.instanceCount
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (metaTypeData.paginatorInfo) {
|
|
108
|
+
response.paginatorInfo = metaTypeData.paginatorInfo
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return response
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Returns parsed metas from all instances
|
|
116
|
+
* Matches JavaScript SDK metas method exactly
|
|
117
|
+
*/
|
|
118
|
+
metas(): any[] {
|
|
119
|
+
const response = this.payload()
|
|
120
|
+
const metas: any[] = []
|
|
121
|
+
|
|
122
|
+
if (response && response.instances) {
|
|
123
|
+
for (const instance of response.instances) {
|
|
124
|
+
if (instance.metasJson) {
|
|
125
|
+
metas.push(JSON.parse(instance.metasJson))
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return metas
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/*
|
|
2
|
+
(
|
|
3
|
+
(/(
|
|
4
|
+
(//(
|
|
5
|
+
(///(
|
|
6
|
+
(/////(
|
|
7
|
+
(//////( )
|
|
8
|
+
(////////( (/)
|
|
9
|
+
(////////( (///)
|
|
10
|
+
(//////////( (////)
|
|
11
|
+
(//////////( (//////)
|
|
12
|
+
(////////////( (///////)
|
|
13
|
+
(/////////////( (/////////)
|
|
14
|
+
(//////////////( (///////////)
|
|
15
|
+
(///////////////( (/////////////)
|
|
16
|
+
(////////////////( (//////////////)
|
|
17
|
+
((((((((((((((((((( (((((((((((((((
|
|
18
|
+
((((((((((((((((((( ((((((((((((((
|
|
19
|
+
((((((((((((((((((( ((((((((((((((
|
|
20
|
+
(((((((((((((((((((( (((((((((((((
|
|
21
|
+
(((((((((((((((((((( ((((((((((((
|
|
22
|
+
((((((((((((((((((( ((((((((((((
|
|
23
|
+
((((((((((((((((((( ((((((((((
|
|
24
|
+
((((((((((((((((((/ (((((((((
|
|
25
|
+
(((((((((((((((((( ((((((((
|
|
26
|
+
((((((((((((((((( (((((((
|
|
27
|
+
(((((((((((((((((( (((((
|
|
28
|
+
################# ##
|
|
29
|
+
################ #
|
|
30
|
+
################# ##
|
|
31
|
+
%################ ###
|
|
32
|
+
###############( ####
|
|
33
|
+
############### ####
|
|
34
|
+
############### ######
|
|
35
|
+
%#############( (#######
|
|
36
|
+
%############# #########
|
|
37
|
+
############( ##########
|
|
38
|
+
########### #############
|
|
39
|
+
######### ##############
|
|
40
|
+
%######
|
|
41
|
+
|
|
42
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import Response from './Response'
|
|
50
|
+
import Dot from '@/libraries/Dot'
|
|
51
|
+
import { InvalidResponseException } from '@/exception'
|
|
52
|
+
import type Query from '@/query/Query'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Response for Guest Authorization Request
|
|
56
|
+
*/
|
|
57
|
+
export default class ResponseAuthorizationGuest extends Response {
|
|
58
|
+
/**
|
|
59
|
+
* Constructor
|
|
60
|
+
*/
|
|
61
|
+
constructor({
|
|
62
|
+
query,
|
|
63
|
+
json
|
|
64
|
+
}: {
|
|
65
|
+
query: Query
|
|
66
|
+
json: Record<string, any>
|
|
67
|
+
}) {
|
|
68
|
+
super({
|
|
69
|
+
query,
|
|
70
|
+
json,
|
|
71
|
+
dataKey: 'data.AccessToken'
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns the reason for rejection
|
|
77
|
+
*/
|
|
78
|
+
reason(): string {
|
|
79
|
+
return 'Invalid response from server'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns whether molecule was accepted or not
|
|
84
|
+
*/
|
|
85
|
+
success(): boolean {
|
|
86
|
+
return this.payload() !== null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns authorization data
|
|
91
|
+
*/
|
|
92
|
+
payload(): any {
|
|
93
|
+
return this.data()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns the authorization key
|
|
98
|
+
*/
|
|
99
|
+
payloadKey(key: string): any {
|
|
100
|
+
if (!Dot.has(this.payload(), key)) {
|
|
101
|
+
throw new InvalidResponseException(`ResponseAuthorizationGuest::payloadKey() - '${key}' key is not found in the payload!`)
|
|
102
|
+
}
|
|
103
|
+
return Dot.get(this.payload(), key)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Returns the auth token
|
|
108
|
+
*/
|
|
109
|
+
token(): any {
|
|
110
|
+
return this.payloadKey('token')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns timestamp
|
|
115
|
+
*/
|
|
116
|
+
time(): any {
|
|
117
|
+
return this.payloadKey('time')
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
(
|
|
3
|
+
(/(
|
|
4
|
+
(//(
|
|
5
|
+
(///(
|
|
6
|
+
(/////(
|
|
7
|
+
(//////( )
|
|
8
|
+
(////////( (/)
|
|
9
|
+
(////////( (///)
|
|
10
|
+
(//////////( (////)
|
|
11
|
+
(//////////( (//////)
|
|
12
|
+
(////////////( (///////)
|
|
13
|
+
(/////////////( (/////////)
|
|
14
|
+
(//////////////( (///////////)
|
|
15
|
+
(///////////////( (/////////////)
|
|
16
|
+
(////////////////( (//////////////)
|
|
17
|
+
((((((((((((((((((( (((((((((((((((
|
|
18
|
+
((((((((((((((((((( ((((((((((((((
|
|
19
|
+
((((((((((((((((((( ((((((((((((((
|
|
20
|
+
(((((((((((((((((((( (((((((((((((
|
|
21
|
+
(((((((((((((((((((( ((((((((((((
|
|
22
|
+
((((((((((((((((((( ((((((((((((
|
|
23
|
+
((((((((((((((((((( ((((((((((
|
|
24
|
+
((((((((((((((((((/ (((((((((
|
|
25
|
+
(((((((((((((((((( ((((((((
|
|
26
|
+
((((((((((((((((( (((((((
|
|
27
|
+
(((((((((((((((((( (((((
|
|
28
|
+
################# ##
|
|
29
|
+
################ #
|
|
30
|
+
################# ##
|
|
31
|
+
%################ ###
|
|
32
|
+
###############( ####
|
|
33
|
+
############### ####
|
|
34
|
+
############### ######
|
|
35
|
+
%#############( (#######
|
|
36
|
+
%############# #########
|
|
37
|
+
############( ##########
|
|
38
|
+
########### #############
|
|
39
|
+
######### ##############
|
|
40
|
+
%######
|
|
41
|
+
|
|
42
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import Response from './Response'
|
|
50
|
+
import Wallet from '../core/Wallet'
|
|
51
|
+
import type Query from '../query/Query'
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Response for balance query
|
|
55
|
+
* Matches JavaScript SDK ResponseBalance implementation exactly
|
|
56
|
+
*/
|
|
57
|
+
export default class ResponseBalance extends Response {
|
|
58
|
+
/**
|
|
59
|
+
* Class constructor
|
|
60
|
+
*/
|
|
61
|
+
constructor({
|
|
62
|
+
query,
|
|
63
|
+
json
|
|
64
|
+
}: {
|
|
65
|
+
query: Query
|
|
66
|
+
json: Record<string, unknown>
|
|
67
|
+
}) {
|
|
68
|
+
super({
|
|
69
|
+
query,
|
|
70
|
+
json,
|
|
71
|
+
dataKey: 'data.Balance'
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns a wallet with balance
|
|
77
|
+
* Matches JavaScript SDK payload() method exactly
|
|
78
|
+
*/
|
|
79
|
+
payload(): Wallet | null {
|
|
80
|
+
const walletData = this.data() as any
|
|
81
|
+
|
|
82
|
+
if (!walletData || !walletData.bundleHash || !walletData.tokenSlug) {
|
|
83
|
+
return null
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return ResponseBalance.toClientWallet({
|
|
87
|
+
data: walletData
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Returns a Knish.IO client Wallet class instance out of object data
|
|
93
|
+
* Simplified version - will be enhanced when TokenUnit is implemented
|
|
94
|
+
* Matches JavaScript SDK ResponseWalletList.toClientWallet pattern
|
|
95
|
+
*/
|
|
96
|
+
static toClientWallet({
|
|
97
|
+
data,
|
|
98
|
+
secret = null
|
|
99
|
+
}: {
|
|
100
|
+
data: any
|
|
101
|
+
secret?: string | null
|
|
102
|
+
}): Wallet {
|
|
103
|
+
let wallet: Wallet
|
|
104
|
+
|
|
105
|
+
if (data.position === null || typeof data.position === 'undefined') {
|
|
106
|
+
wallet = Wallet.create({
|
|
107
|
+
bundle: data.bundleHash,
|
|
108
|
+
token: data.tokenSlug,
|
|
109
|
+
batchId: data.batchId,
|
|
110
|
+
characters: data.characters
|
|
111
|
+
})
|
|
112
|
+
} else {
|
|
113
|
+
wallet = new Wallet({
|
|
114
|
+
secret,
|
|
115
|
+
token: data.tokenSlug,
|
|
116
|
+
position: data.position,
|
|
117
|
+
batchId: data.batchId,
|
|
118
|
+
characters: data.characters
|
|
119
|
+
})
|
|
120
|
+
wallet.address = data.address
|
|
121
|
+
wallet.bundle = data.bundleHash
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Set token information if available
|
|
125
|
+
if (data.token) {
|
|
126
|
+
wallet.tokenName = data.token.name
|
|
127
|
+
wallet.tokenAmount = data.token.amount
|
|
128
|
+
wallet.tokenSupply = data.token.supply
|
|
129
|
+
wallet.tokenFungibility = data.token.fungibility
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// TODO: Implement TokenUnit support when TokenUnit class is available
|
|
133
|
+
// if (data.tokenUnits && data.tokenUnits.length) {
|
|
134
|
+
// for (const tokenUnitData of data.tokenUnits) {
|
|
135
|
+
// wallet.tokenUnits.push(TokenUnit.createFromGraphQL(tokenUnitData))
|
|
136
|
+
// }
|
|
137
|
+
// }
|
|
138
|
+
|
|
139
|
+
// Set trade rates if available
|
|
140
|
+
if (data.tradeRates && data.tradeRates.length) {
|
|
141
|
+
for (const tradeRate of data.tradeRates) {
|
|
142
|
+
wallet.tradeRates[tradeRate.tokenSlug] = tradeRate.amount
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Set balance and other properties
|
|
147
|
+
wallet.balance = Number(data.amount || 0)
|
|
148
|
+
wallet.pubkey = data.pubkey
|
|
149
|
+
wallet.createdAt = data.createdAt
|
|
150
|
+
|
|
151
|
+
return wallet
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
(
|
|
3
|
+
(/(
|
|
4
|
+
(//(
|
|
5
|
+
(///(
|
|
6
|
+
(/////(
|
|
7
|
+
(//////( )
|
|
8
|
+
(////////( (/)
|
|
9
|
+
(////////( (///)
|
|
10
|
+
(//////////( (////)
|
|
11
|
+
(//////////( (//////)
|
|
12
|
+
(////////////( (///////)
|
|
13
|
+
(/////////////( (/////////)
|
|
14
|
+
(//////////////( (///////////)
|
|
15
|
+
(///////////////( (/////////////)
|
|
16
|
+
(////////////////( (//////////////)
|
|
17
|
+
((((((((((((((((((( (((((((((((((((
|
|
18
|
+
((((((((((((((((((( ((((((((((((((
|
|
19
|
+
((((((((((((((((((( ((((((((((((((
|
|
20
|
+
(((((((((((((((((((( (((((((((((((
|
|
21
|
+
(((((((((((((((((((( ((((((((((((
|
|
22
|
+
((((((((((((((((((( ((((((((((((
|
|
23
|
+
((((((((((((((((((( ((((((((((
|
|
24
|
+
((((((((((((((((((/ (((((((((
|
|
25
|
+
(((((((((((((((((( ((((((((
|
|
26
|
+
((((((((((((((((( (((((((
|
|
27
|
+
(((((((((((((((((( (((((
|
|
28
|
+
################# ##
|
|
29
|
+
################ #
|
|
30
|
+
################# ##
|
|
31
|
+
%################ ###
|
|
32
|
+
###############( ####
|
|
33
|
+
############### ####
|
|
34
|
+
############### ######
|
|
35
|
+
%#############( (#######
|
|
36
|
+
%############# #########
|
|
37
|
+
############( ##########
|
|
38
|
+
########### #############
|
|
39
|
+
######### ##############
|
|
40
|
+
%######
|
|
41
|
+
|
|
42
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import ResponseProposeMolecule from './ResponseProposeMolecule'
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Response for shadow wallet claim operations
|
|
53
|
+
*/
|
|
54
|
+
export default class ResponseClaimShadowWallet extends ResponseProposeMolecule {
|
|
55
|
+
// Inherits all functionality from ResponseProposeMolecule
|
|
56
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
(
|
|
3
|
+
(/(
|
|
4
|
+
(//(
|
|
5
|
+
(///(
|
|
6
|
+
(/////(
|
|
7
|
+
(//////( )
|
|
8
|
+
(////////( (/)
|
|
9
|
+
(////////( (///)
|
|
10
|
+
(//////////( (////)
|
|
11
|
+
(//////////( (//////)
|
|
12
|
+
(////////////( (///////)
|
|
13
|
+
(/////////////( (/////////)
|
|
14
|
+
(//////////////( (///////////)
|
|
15
|
+
(///////////////( (/////////////)
|
|
16
|
+
(////////////////( (//////////////)
|
|
17
|
+
((((((((((((((((((( (((((((((((((((
|
|
18
|
+
((((((((((((((((((( ((((((((((((((
|
|
19
|
+
((((((((((((((((((( ((((((((((((((
|
|
20
|
+
(((((((((((((((((((( (((((((((((((
|
|
21
|
+
(((((((((((((((((((( ((((((((((((
|
|
22
|
+
((((((((((((((((((( ((((((((((((
|
|
23
|
+
((((((((((((((((((( ((((((((((
|
|
24
|
+
((((((((((((((((((/ (((((((((
|
|
25
|
+
(((((((((((((((((( ((((((((
|
|
26
|
+
((((((((((((((((( (((((((
|
|
27
|
+
(((((((((((((((((( (((((
|
|
28
|
+
################# ##
|
|
29
|
+
################ #
|
|
30
|
+
################# ##
|
|
31
|
+
%################ ###
|
|
32
|
+
###############( ####
|
|
33
|
+
############### ####
|
|
34
|
+
############### ######
|
|
35
|
+
%#############( (#######
|
|
36
|
+
%############# #########
|
|
37
|
+
############( ##########
|
|
38
|
+
########### #############
|
|
39
|
+
######### ##############
|
|
40
|
+
%######
|
|
41
|
+
|
|
42
|
+
Powered by Knish.IO: Connecting a Decentralized World
|
|
43
|
+
|
|
44
|
+
Please visit https://github.com/WishKnish/KnishIO-Client-TS for information.
|
|
45
|
+
|
|
46
|
+
License: https://github.com/WishKnish/KnishIO-Client-TS/blob/master/LICENSE
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import type Query from '../query/Query'
|
|
50
|
+
import Response from './Response'
|
|
51
|
+
import Wallet from '../core/Wallet'
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* ResponseContinuId class - Response for ContinuID query
|
|
55
|
+
* Matches JavaScript SDK ResponseContinuId implementation exactly
|
|
56
|
+
*/
|
|
57
|
+
export default class ResponseContinuId extends Response {
|
|
58
|
+
/**
|
|
59
|
+
* Class constructor
|
|
60
|
+
* Matches JavaScript SDK constructor signature exactly
|
|
61
|
+
*/
|
|
62
|
+
constructor({
|
|
63
|
+
query,
|
|
64
|
+
json
|
|
65
|
+
}: {
|
|
66
|
+
query: Query
|
|
67
|
+
json: any
|
|
68
|
+
}) {
|
|
69
|
+
super({
|
|
70
|
+
query,
|
|
71
|
+
json,
|
|
72
|
+
dataKey: 'data.ContinuId'
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns the ContinuID wallet
|
|
78
|
+
* Matches JavaScript SDK payload method exactly
|
|
79
|
+
*/
|
|
80
|
+
payload(): Wallet | null {
|
|
81
|
+
let wallet: Wallet | null = null
|
|
82
|
+
|
|
83
|
+
const continuId = this.data()
|
|
84
|
+
|
|
85
|
+
if (continuId) {
|
|
86
|
+
wallet = new Wallet({
|
|
87
|
+
secret: null,
|
|
88
|
+
token: continuId.tokenSlug
|
|
89
|
+
})
|
|
90
|
+
wallet.address = continuId.address
|
|
91
|
+
wallet.position = continuId.position
|
|
92
|
+
wallet.bundle = continuId.bundleHash
|
|
93
|
+
wallet.batchId = continuId.batchId
|
|
94
|
+
wallet.characters = continuId.characters
|
|
95
|
+
wallet.pubkey = continuId.pubkey
|
|
96
|
+
wallet.balance = continuId.amount * 1.0
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return wallet
|
|
100
|
+
}
|
|
101
|
+
}
|