@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,87 @@
|
|
|
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 Mutation from './Mutation'
|
|
50
|
+
import ResponseLinkIdentifier from '@/response/ResponseLinkIdentifier'
|
|
51
|
+
import { gql } from '@urql/core'
|
|
52
|
+
import type { GraphQLClient as IGraphQLClient } from '@/types'
|
|
53
|
+
import type KnishIOClient from '@/KnishIOClient'
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Mutation for linking an Identifier to a Wallet Bundle
|
|
57
|
+
*/
|
|
58
|
+
export default class MutationLinkIdentifier extends Mutation {
|
|
59
|
+
/**
|
|
60
|
+
* Constructor
|
|
61
|
+
*/
|
|
62
|
+
constructor(graphQLClient: IGraphQLClient, knishIOClient: KnishIOClient) {
|
|
63
|
+
super(graphQLClient, knishIOClient)
|
|
64
|
+
|
|
65
|
+
this.$__query = gql`
|
|
66
|
+
mutation($bundle: String!, $type: String!, $content: String!) {
|
|
67
|
+
LinkIdentifier(bundle: $bundle, type: $type, content: $content) {
|
|
68
|
+
type
|
|
69
|
+
bundle
|
|
70
|
+
content
|
|
71
|
+
set
|
|
72
|
+
message
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Returns a Response object
|
|
80
|
+
*/
|
|
81
|
+
override createResponse(json: Record<string, any>): ResponseLinkIdentifier {
|
|
82
|
+
return new ResponseLinkIdentifier({
|
|
83
|
+
query: this,
|
|
84
|
+
json
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
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 Mutation from './Mutation'
|
|
50
|
+
import ResponseProposeMolecule from '../response/ResponseProposeMolecule'
|
|
51
|
+
import type GraphQLClient from '../libraries/GraphQLClient'
|
|
52
|
+
import type KnishIOClient from '../KnishIOClient'
|
|
53
|
+
import type Molecule from '../core/Molecule'
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* MutationProposeMolecule - Foundation for all molecular proposals
|
|
57
|
+
* Matches JavaScript SDK MutationProposeMolecule implementation exactly
|
|
58
|
+
*/
|
|
59
|
+
export default abstract class MutationProposeMolecule extends Mutation {
|
|
60
|
+
protected $__molecule: Molecule
|
|
61
|
+
protected $__remainderWallet: any | null = null
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Create MutationProposeMolecule instance
|
|
65
|
+
*/
|
|
66
|
+
constructor(graphQLClient: GraphQLClient, knishIOClient: KnishIOClient, molecule: Molecule) {
|
|
67
|
+
super(graphQLClient, knishIOClient)
|
|
68
|
+
|
|
69
|
+
this.$__molecule = molecule
|
|
70
|
+
this.$__remainderWallet = null
|
|
71
|
+
this.$__query = `
|
|
72
|
+
mutation($molecule: MoleculeInput!) {
|
|
73
|
+
ProposeMolecule(molecule: $molecule) {
|
|
74
|
+
molecularHash,
|
|
75
|
+
height,
|
|
76
|
+
depth,
|
|
77
|
+
status,
|
|
78
|
+
reason,
|
|
79
|
+
payload,
|
|
80
|
+
createdAt,
|
|
81
|
+
receivedAt,
|
|
82
|
+
processedAt,
|
|
83
|
+
broadcastedAt
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns an object of query variables
|
|
91
|
+
* Matches JavaScript SDK compiledVariables method exactly
|
|
92
|
+
*/
|
|
93
|
+
override compiledVariables(variables: Record<string, any> | null = null): Record<string, any> {
|
|
94
|
+
const _variables = super.compiledVariables(variables)
|
|
95
|
+
return { ..._variables, ...{ molecule: this.molecule() } }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates a new response from a JSON object
|
|
100
|
+
* Matches JavaScript SDK createResponse method signature exactly
|
|
101
|
+
*/
|
|
102
|
+
override createResponse(json: Record<string, unknown>): ResponseProposeMolecule {
|
|
103
|
+
return new ResponseProposeMolecule({
|
|
104
|
+
query: this,
|
|
105
|
+
json
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Executes the mutation
|
|
111
|
+
* Matches JavaScript SDK execute method signature exactly
|
|
112
|
+
*/
|
|
113
|
+
override async execute({ variables = null }: { variables?: Record<string, any> | null } = {}): Promise<ResponseProposeMolecule | null> {
|
|
114
|
+
variables = variables || {}
|
|
115
|
+
variables.molecule = this.molecule()
|
|
116
|
+
|
|
117
|
+
const response = await super.execute({
|
|
118
|
+
variables
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
return response as ResponseProposeMolecule | null
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns the remainder wallet
|
|
126
|
+
* Matches JavaScript SDK remainderWallet method exactly
|
|
127
|
+
*/
|
|
128
|
+
remainderWallet(): any | null {
|
|
129
|
+
return this.$__remainderWallet
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns the molecule we are proposing
|
|
134
|
+
* Matches JavaScript SDK molecule method exactly
|
|
135
|
+
*/
|
|
136
|
+
molecule(): any {
|
|
137
|
+
// Convert molecule to GraphQL input format
|
|
138
|
+
// This should match the JavaScript SDK's molecule serialization
|
|
139
|
+
return this.$__molecule.toJSON ? this.$__molecule.toJSON() : this.$__molecule
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Abstract method to be implemented by subclasses
|
|
144
|
+
* Fills the molecule with specific mutation data
|
|
145
|
+
*/
|
|
146
|
+
abstract fillMolecule(params: any): void
|
|
147
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 MutationProposeMolecule from './MutationProposeMolecule'
|
|
50
|
+
import ResponseRequestAuthorization from '../response/ResponseRequestAuthorization'
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* MutationRequestAuthorization class - Mutation for requesting an authorization token from the node
|
|
54
|
+
* Matches JavaScript SDK MutationRequestAuthorization implementation exactly
|
|
55
|
+
*/
|
|
56
|
+
export default class MutationRequestAuthorization extends MutationProposeMolecule {
|
|
57
|
+
/**
|
|
58
|
+
* Fill molecule for authorization request
|
|
59
|
+
* Matches JavaScript SDK fillMolecule method exactly
|
|
60
|
+
*/
|
|
61
|
+
override fillMolecule({ meta }: { meta: any }): void {
|
|
62
|
+
(this.$__molecule as any).initAuthorization({ meta });
|
|
63
|
+
(this.$__molecule as any).sign({});
|
|
64
|
+
(this.$__molecule as any).check()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns a Response object
|
|
69
|
+
* Matches JavaScript SDK createResponse method exactly
|
|
70
|
+
*/
|
|
71
|
+
override createResponse(json: any): ResponseRequestAuthorization {
|
|
72
|
+
return new ResponseRequestAuthorization({
|
|
73
|
+
query: this,
|
|
74
|
+
json
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 Mutation from './Mutation'
|
|
50
|
+
import ResponseRequestAuthorizationGuest from '@/response/ResponseRequestAuthorizationGuest'
|
|
51
|
+
import { gql } from '@urql/core'
|
|
52
|
+
import type { GraphQLClient as IGraphQLClient } from '@/types'
|
|
53
|
+
import type KnishIOClient from '@/KnishIOClient'
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Mutation for requesting guest authorization
|
|
57
|
+
*/
|
|
58
|
+
export default class MutationRequestAuthorizationGuest extends Mutation {
|
|
59
|
+
/**
|
|
60
|
+
* Constructor
|
|
61
|
+
*/
|
|
62
|
+
constructor(graphQLClient: IGraphQLClient, knishIOClient: KnishIOClient) {
|
|
63
|
+
super(graphQLClient, knishIOClient)
|
|
64
|
+
|
|
65
|
+
this.$__query = gql`
|
|
66
|
+
mutation($cellSlug: String, $pubkey: String, $encrypt: Boolean) {
|
|
67
|
+
AccessToken(cellSlug: $cellSlug, pubkey: $pubkey, encrypt: $encrypt) {
|
|
68
|
+
token
|
|
69
|
+
pubkey
|
|
70
|
+
expiresAt
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns a Response object
|
|
78
|
+
*/
|
|
79
|
+
override createResponse(json: Record<string, any>): ResponseRequestAuthorizationGuest {
|
|
80
|
+
return new ResponseRequestAuthorizationGuest({
|
|
81
|
+
query: this,
|
|
82
|
+
json
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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 MutationProposeMolecule from './MutationProposeMolecule'
|
|
50
|
+
import ResponseRequestTokens from '../response/ResponseRequestTokens'
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* MutationRequestTokens class - Mutation for requesting tokens
|
|
54
|
+
* Matches JavaScript SDK MutationRequestTokens implementation exactly
|
|
55
|
+
*/
|
|
56
|
+
export default class MutationRequestTokens extends MutationProposeMolecule {
|
|
57
|
+
/**
|
|
58
|
+
* Fills a Molecule with the appropriate atoms and prepares for broadcast
|
|
59
|
+
* Matches JavaScript SDK fillMolecule method exactly
|
|
60
|
+
*/
|
|
61
|
+
override fillMolecule({
|
|
62
|
+
token,
|
|
63
|
+
amount,
|
|
64
|
+
metaType,
|
|
65
|
+
metaId,
|
|
66
|
+
meta = null,
|
|
67
|
+
batchId = null
|
|
68
|
+
}: {
|
|
69
|
+
token: string
|
|
70
|
+
amount: number | string
|
|
71
|
+
metaType: string
|
|
72
|
+
metaId: string
|
|
73
|
+
meta?: any | null
|
|
74
|
+
batchId?: string | null
|
|
75
|
+
}): void {
|
|
76
|
+
(this.$__molecule as any).initTokenRequest({
|
|
77
|
+
token,
|
|
78
|
+
amount,
|
|
79
|
+
metaType,
|
|
80
|
+
metaId,
|
|
81
|
+
meta: meta || {},
|
|
82
|
+
batchId
|
|
83
|
+
});
|
|
84
|
+
(this.$__molecule as any).sign({});
|
|
85
|
+
(this.$__molecule as any).check()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Builds a Response object out of a JSON object
|
|
90
|
+
* Matches JavaScript SDK createResponse method exactly
|
|
91
|
+
*/
|
|
92
|
+
override createResponse(json: any): ResponseRequestTokens {
|
|
93
|
+
return new ResponseRequestTokens({
|
|
94
|
+
query: this,
|
|
95
|
+
json
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 MutationProposeMolecule from './MutationProposeMolecule'
|
|
50
|
+
import ResponseTransferTokens from '../response/ResponseTransferTokens'
|
|
51
|
+
import type Wallet from '../core/Wallet'
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Mutation for moving tokens between wallets
|
|
55
|
+
* Matches JavaScript SDK MutationTransferTokens implementation exactly
|
|
56
|
+
*/
|
|
57
|
+
export default class MutationTransferTokens extends MutationProposeMolecule {
|
|
58
|
+
/**
|
|
59
|
+
* Fills the Molecule with provided wallet and amount data
|
|
60
|
+
* Matches JavaScript SDK fillMolecule method exactly
|
|
61
|
+
*/
|
|
62
|
+
override fillMolecule({
|
|
63
|
+
recipientWallet,
|
|
64
|
+
amount
|
|
65
|
+
}: {
|
|
66
|
+
recipientWallet: Wallet
|
|
67
|
+
amount: number | string
|
|
68
|
+
}): void {
|
|
69
|
+
(this.$__molecule as any).initValue({
|
|
70
|
+
recipientWallet,
|
|
71
|
+
amount
|
|
72
|
+
});
|
|
73
|
+
(this.$__molecule as any).sign({});
|
|
74
|
+
(this.$__molecule as any).check((this.$__molecule as any).sourceWallet)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Builds a Response object out of a JSON object
|
|
79
|
+
* Matches JavaScript SDK createResponse method signature exactly
|
|
80
|
+
*/
|
|
81
|
+
override createResponse(json: Record<string, unknown>): ResponseTransferTokens {
|
|
82
|
+
return new ResponseTransferTokens({
|
|
83
|
+
query: this,
|
|
84
|
+
json
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 MutationProposeMolecule from './MutationProposeMolecule'
|
|
50
|
+
import type Wallet from '@/core/Wallet'
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Mutation for withdrawing buffer tokens
|
|
54
|
+
*/
|
|
55
|
+
export default class MutationWithdrawBufferToken extends MutationProposeMolecule {
|
|
56
|
+
/**
|
|
57
|
+
* Fills the molecule with buffer withdrawal data
|
|
58
|
+
*/
|
|
59
|
+
override fillMolecule({
|
|
60
|
+
recipients,
|
|
61
|
+
signingWallet
|
|
62
|
+
}: {
|
|
63
|
+
recipients: Record<string, any>
|
|
64
|
+
signingWallet?: Wallet
|
|
65
|
+
}): void {
|
|
66
|
+
(this.$__molecule as any).initWithdrawBuffer({
|
|
67
|
+
recipients,
|
|
68
|
+
signingWallet
|
|
69
|
+
})
|
|
70
|
+
this.$__molecule.sign({})
|
|
71
|
+
this.$__molecule.check(this.$__molecule.sourceWallet)
|
|
72
|
+
}
|
|
73
|
+
}
|