@wishknish/knishio-client-ts 0.7.0 → 0.7.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.
- package/dist/index.cjs +235 -194
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1833 -0
- package/dist/index.d.ts +1833 -0
- package/dist/index.iife.js +238 -181
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +235 -194
- package/dist/index.js.map +1 -1
- package/package.json +5 -7
- package/src/KnishIOClient.ts +183 -231
- package/src/core/Atom.ts +1 -1
- package/src/core/Molecule.ts +0 -1
- package/src/core/Wallet.ts +71 -8
- package/src/libraries/CheckMolecule.ts +3 -3
- package/src/libraries/GraphQLClient.ts +61 -23
- package/src/libraries/array.ts +2 -2
- package/src/libraries/crypto.ts +28 -25
- package/src/libraries/strings.ts +3 -3
- package/src/mutation/MutationProposeMolecule.ts +2 -1
- package/src/query/Query.ts +2 -1
- package/src/query/QueryAtom.ts +4 -3
- package/src/query/QueryBalance.ts +2 -1
- package/src/query/QueryBatch.ts +4 -3
- package/src/query/QueryContinuId.ts +4 -3
- package/src/query/QueryMetaType.ts +4 -3
- package/src/query/QueryMetaTypeViaAtom.ts +4 -3
- package/src/query/QueryWalletBundle.ts +2 -1
- package/src/query/QueryWalletList.ts +4 -3
- package/src/response/EnhancedResponse.ts +19 -24
- package/src/response/Response.ts +3 -3
- package/src/response/ResponseAtom.ts +1 -1
- package/src/response/ResponseAuthorizationGuest.ts +1 -1
- package/src/response/ResponseBalance.ts +1 -1
- package/src/response/ResponseContinuId.ts +1 -1
- package/src/response/ResponseMetaType.ts +1 -1
- package/src/response/ResponseMetaTypeViaAtom.ts +1 -1
- package/src/response/ResponsePolicy.ts +1 -1
- package/src/response/ResponseProposeMolecule.ts +4 -5
- package/src/response/ResponseQueryActiveSession.ts +1 -1
- package/src/response/ResponseQueryUserActivity.ts +1 -1
- package/src/response/ResponseRequestAuthorizationGuest.ts +1 -1
- package/src/response/ResponseTransferTokens.ts +1 -1
- package/src/response/ResponseWalletBundle.ts +1 -1
- package/src/response/ResponseWalletList.ts +1 -1
- package/src/types/graphql.ts +8 -0
- package/src/types/index.ts +2 -7
- package/src/types/response.ts +12 -7
package/dist/index.iife.js
CHANGED
|
@@ -921,9 +921,19 @@ var KnishIO = (function (exports) {
|
|
|
921
921
|
});
|
|
922
922
|
|
|
923
923
|
// src/exception/StackableUnitAmountException.ts
|
|
924
|
+
var StackableUnitAmountException, StackableUnitAmountException_default;
|
|
924
925
|
var init_StackableUnitAmountException = __esm({
|
|
925
926
|
"src/exception/StackableUnitAmountException.ts"() {
|
|
926
927
|
init_BaseException();
|
|
928
|
+
StackableUnitAmountException = class extends exports.BaseException {
|
|
929
|
+
/**
|
|
930
|
+
* Constructor using proper error type
|
|
931
|
+
*/
|
|
932
|
+
constructor(message = "Stackable tokens with unit IDs cannot have an amount!") {
|
|
933
|
+
super("STACKABLE_UNIT_AMOUNT_ERROR", message);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
StackableUnitAmountException_default = StackableUnitAmountException;
|
|
927
937
|
}
|
|
928
938
|
});
|
|
929
939
|
|
|
@@ -19896,7 +19906,7 @@ ${operationTypes.join("\n")}
|
|
|
19896
19906
|
// Enhanced response validation
|
|
19897
19907
|
validate() {
|
|
19898
19908
|
try {
|
|
19899
|
-
|
|
19909
|
+
ValidationResultSchema.parse(this.toValidationResult());
|
|
19900
19910
|
return {
|
|
19901
19911
|
success: true,
|
|
19902
19912
|
data: this._payload,
|
|
@@ -19917,14 +19927,14 @@ ${operationTypes.join("\n")}
|
|
|
19917
19927
|
static createSuccessResponse(payload, operation, rawData, duration) {
|
|
19918
19928
|
return StandardResponse.success(payload, rawData, {
|
|
19919
19929
|
operation,
|
|
19920
|
-
duration,
|
|
19930
|
+
...duration !== void 0 ? { duration } : {},
|
|
19921
19931
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
19922
19932
|
});
|
|
19923
19933
|
}
|
|
19924
19934
|
static createErrorResponse(errorMessage, operation, rawData, duration) {
|
|
19925
19935
|
return StandardResponse.failure(errorMessage, rawData, {
|
|
19926
19936
|
operation,
|
|
19927
|
-
duration,
|
|
19937
|
+
...duration !== void 0 ? { duration } : {},
|
|
19928
19938
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
19929
19939
|
});
|
|
19930
19940
|
}
|
|
@@ -19983,7 +19993,7 @@ ${operationTypes.join("\n")}
|
|
|
19983
19993
|
if (exports.Dot.has(this.$__response, this.errorKey)) {
|
|
19984
19994
|
const error2 = exports.Dot.get(this.$__response, this.errorKey);
|
|
19985
19995
|
if (String(error2).includes("Unauthenticated")) {
|
|
19986
|
-
throw new UnauthenticatedException();
|
|
19996
|
+
throw new UnauthenticatedException("Unauthenticated request");
|
|
19987
19997
|
}
|
|
19988
19998
|
throw new exports.InvalidResponseException();
|
|
19989
19999
|
}
|
|
@@ -20839,7 +20849,7 @@ ${operationTypes.join("\n")}
|
|
|
20839
20849
|
}
|
|
20840
20850
|
function toCamelCase(str) {
|
|
20841
20851
|
if (!str) return "";
|
|
20842
|
-
return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (
|
|
20852
|
+
return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_match, chr) => chr.toUpperCase());
|
|
20843
20853
|
}
|
|
20844
20854
|
function toSnakeCase(str) {
|
|
20845
20855
|
if (!str) return "";
|
|
@@ -21086,13 +21096,14 @@ ${operationTypes.join("\n")}
|
|
|
21086
21096
|
const totalCondition = total < 0;
|
|
21087
21097
|
while (total !== 0) {
|
|
21088
21098
|
for (let index = 0; index < normalized.length; index++) {
|
|
21089
|
-
const
|
|
21099
|
+
const value2 = normalized[index];
|
|
21100
|
+
const condition = totalCondition ? value2 < 8 : value2 > -8;
|
|
21090
21101
|
if (condition) {
|
|
21091
21102
|
if (totalCondition) {
|
|
21092
|
-
normalized[index]
|
|
21103
|
+
normalized[index] = value2 + 1;
|
|
21093
21104
|
total++;
|
|
21094
21105
|
} else {
|
|
21095
|
-
normalized[index]
|
|
21106
|
+
normalized[index] = value2 - 1;
|
|
21096
21107
|
total--;
|
|
21097
21108
|
}
|
|
21098
21109
|
if (total === 0) break;
|
|
@@ -22086,7 +22097,7 @@ ${operationTypes.join("\n")}
|
|
|
22086
22097
|
);
|
|
22087
22098
|
var genShake = (suffix, blockLen, outputLen, info = {}) => createHasher((opts2 = {}) => new Keccak(blockLen, suffix, opts2.dkLen === void 0 ? outputLen : opts2.dkLen, true), info);
|
|
22088
22099
|
var shake128 = /* @__PURE__ */ genShake(31, 168, 16, /* @__PURE__ */ oidNist(11));
|
|
22089
|
-
var
|
|
22100
|
+
var shake2562 = /* @__PURE__ */ genShake(31, 136, 32, /* @__PURE__ */ oidNist(12));
|
|
22090
22101
|
|
|
22091
22102
|
// node_modules/@noble/curves/abstract/fft.js
|
|
22092
22103
|
function checkU32(n3) {
|
|
@@ -22600,12 +22611,12 @@ ${operationTypes.join("\n")}
|
|
|
22600
22611
|
};
|
|
22601
22612
|
}
|
|
22602
22613
|
function shakePRF(dkLen, key, nonce) {
|
|
22603
|
-
return
|
|
22614
|
+
return shake2562.create({ dkLen }).update(key).update(new Uint8Array([nonce])).digest();
|
|
22604
22615
|
}
|
|
22605
22616
|
var opts = {
|
|
22606
22617
|
HASH256: sha3_256,
|
|
22607
22618
|
HASH512: sha3_512,
|
|
22608
|
-
KDF:
|
|
22619
|
+
KDF: shake2562,
|
|
22609
22620
|
XOF: XOF128,
|
|
22610
22621
|
PRF: shakePRF
|
|
22611
22622
|
};
|
|
@@ -22629,6 +22640,12 @@ ${operationTypes.join("\n")}
|
|
|
22629
22640
|
tokenUnits;
|
|
22630
22641
|
tradeRates;
|
|
22631
22642
|
molecules;
|
|
22643
|
+
// Token metadata (populated from query responses)
|
|
22644
|
+
tokenName;
|
|
22645
|
+
tokenAmount;
|
|
22646
|
+
tokenSupply;
|
|
22647
|
+
tokenFungibility;
|
|
22648
|
+
createdAt;
|
|
22632
22649
|
constructor({
|
|
22633
22650
|
secret = null,
|
|
22634
22651
|
bundle = null,
|
|
@@ -22775,6 +22792,45 @@ ${operationTypes.join("\n")}
|
|
|
22775
22792
|
characters: this.characters
|
|
22776
22793
|
});
|
|
22777
22794
|
}
|
|
22795
|
+
/**
|
|
22796
|
+
* Sets up a batch ID - either using the sender's, or a new one
|
|
22797
|
+
* Matches JavaScript SDK Wallet.initBatchId exactly
|
|
22798
|
+
*/
|
|
22799
|
+
initBatchId({
|
|
22800
|
+
sourceWallet,
|
|
22801
|
+
isRemainder = false
|
|
22802
|
+
}) {
|
|
22803
|
+
if (sourceWallet.batchId) {
|
|
22804
|
+
this.batchId = isRemainder ? sourceWallet.batchId : generateBatchId({});
|
|
22805
|
+
}
|
|
22806
|
+
}
|
|
22807
|
+
/**
|
|
22808
|
+
* Split token units between wallets
|
|
22809
|
+
* Matches JavaScript SDK Wallet.splitUnits exactly
|
|
22810
|
+
*
|
|
22811
|
+
* @param units - Array of token unit IDs to transfer
|
|
22812
|
+
* @param remainderWallet - Wallet to receive units not being transferred
|
|
22813
|
+
* @param recipientWallet - Wallet to receive the transferred units (optional)
|
|
22814
|
+
*/
|
|
22815
|
+
splitUnits(units, remainderWallet, recipientWallet = null) {
|
|
22816
|
+
if (units.length === 0) {
|
|
22817
|
+
return;
|
|
22818
|
+
}
|
|
22819
|
+
const recipientTokenUnits = [];
|
|
22820
|
+
const remainderTokenUnits = [];
|
|
22821
|
+
this.tokenUnits.forEach((tokenUnit) => {
|
|
22822
|
+
if (units.includes(tokenUnit.id)) {
|
|
22823
|
+
recipientTokenUnits.push(tokenUnit);
|
|
22824
|
+
} else {
|
|
22825
|
+
remainderTokenUnits.push(tokenUnit);
|
|
22826
|
+
}
|
|
22827
|
+
});
|
|
22828
|
+
this.tokenUnits = recipientTokenUnits;
|
|
22829
|
+
if (recipientWallet !== null) {
|
|
22830
|
+
recipientWallet.tokenUnits = recipientTokenUnits;
|
|
22831
|
+
}
|
|
22832
|
+
remainderWallet.tokenUnits = remainderTokenUnits;
|
|
22833
|
+
}
|
|
22778
22834
|
/**
|
|
22779
22835
|
* Get token units data
|
|
22780
22836
|
* Stub for compatibility
|
|
@@ -22797,7 +22853,7 @@ ${operationTypes.join("\n")}
|
|
|
22797
22853
|
* Initializes the ML-KEM key pair (matches JavaScript SDK exactly)
|
|
22798
22854
|
*/
|
|
22799
22855
|
initializeMLKEM() {
|
|
22800
|
-
const seedHex = generateSecret(this.key,
|
|
22856
|
+
const seedHex = generateSecret(this.key, 64);
|
|
22801
22857
|
const seed = new Uint8Array(64);
|
|
22802
22858
|
for (let i4 = 0; i4 < 64; i4++) {
|
|
22803
22859
|
seed[i4] = parseInt(seedHex.substr(i4 * 2, 2), 16);
|
|
@@ -23314,9 +23370,9 @@ ${operationTypes.join("\n")}
|
|
|
23314
23370
|
}
|
|
23315
23371
|
const metas = Meta.aggregateMeta(atom.meta);
|
|
23316
23372
|
for (const key of policyArray) {
|
|
23317
|
-
|
|
23318
|
-
if (
|
|
23319
|
-
policy = JSON.parse(
|
|
23373
|
+
const policyRaw = metas[key];
|
|
23374
|
+
if (policyRaw) {
|
|
23375
|
+
const policy = JSON.parse(policyRaw);
|
|
23320
23376
|
for (const [policyName, policyValue] of Object.entries(policy)) {
|
|
23321
23377
|
if (!policyArray.includes(policyName)) {
|
|
23322
23378
|
if (!Object.keys(metas).includes(policyName)) {
|
|
@@ -26862,8 +26918,7 @@ ${operationTypes.join("\n")}
|
|
|
26862
26918
|
}
|
|
26863
26919
|
createUrqlClient({
|
|
26864
26920
|
serverUri,
|
|
26865
|
-
socket
|
|
26866
|
-
encrypt
|
|
26921
|
+
socket
|
|
26867
26922
|
}) {
|
|
26868
26923
|
const exchanges = [cacheExchange, fetchExchange];
|
|
26869
26924
|
if (socket?.socketUri) {
|
|
@@ -26915,13 +26970,36 @@ ${operationTypes.join("\n")}
|
|
|
26915
26970
|
const result = await this.$__client.query(request.query, finalVariables).toPromise();
|
|
26916
26971
|
return this.formatResponse(result);
|
|
26917
26972
|
}
|
|
26918
|
-
async
|
|
26973
|
+
async mutation(request, variables) {
|
|
26919
26974
|
const finalVariables = variables || request.variables || {};
|
|
26920
|
-
const
|
|
26975
|
+
const mutationString = request.mutation || request.query;
|
|
26976
|
+
const result = await this.$__client.mutation(mutationString, finalVariables).toPromise();
|
|
26921
26977
|
return this.formatResponse(result);
|
|
26922
26978
|
}
|
|
26923
|
-
|
|
26924
|
-
|
|
26979
|
+
// Alias for mutation() to match JS SDK interface
|
|
26980
|
+
async mutate(request, variables) {
|
|
26981
|
+
return this.mutation(request, variables);
|
|
26982
|
+
}
|
|
26983
|
+
async *subscription(request, variables) {
|
|
26984
|
+
const finalVariables = variables || request.variables || {};
|
|
26985
|
+
const subscription = this.$__client.subscription(request.query, finalVariables);
|
|
26986
|
+
const results = [];
|
|
26987
|
+
const { unsubscribe } = pipe(
|
|
26988
|
+
subscription,
|
|
26989
|
+
subscribe((result) => {
|
|
26990
|
+
results.push(this.formatResponse(result));
|
|
26991
|
+
})
|
|
26992
|
+
);
|
|
26993
|
+
try {
|
|
26994
|
+
while (true) {
|
|
26995
|
+
if (results.length > 0) {
|
|
26996
|
+
yield results.shift();
|
|
26997
|
+
}
|
|
26998
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
26999
|
+
}
|
|
27000
|
+
} finally {
|
|
27001
|
+
unsubscribe();
|
|
27002
|
+
}
|
|
26925
27003
|
}
|
|
26926
27004
|
subscribe(request, callback) {
|
|
26927
27005
|
const { query, variables, operationName = "subscription" } = request;
|
|
@@ -26950,7 +27028,7 @@ ${operationTypes.join("\n")}
|
|
|
26950
27028
|
}
|
|
26951
27029
|
}
|
|
26952
27030
|
unsubscribeAll() {
|
|
26953
|
-
this.$__subscriptionManager.forEach((
|
|
27031
|
+
this.$__subscriptionManager.forEach((_subscription, operationName) => {
|
|
26954
27032
|
this.unsubscribe(operationName);
|
|
26955
27033
|
});
|
|
26956
27034
|
}
|
|
@@ -27806,7 +27884,6 @@ ${operationTypes.join("\n")}
|
|
|
27806
27884
|
};
|
|
27807
27885
|
var validationService = ValidationService.getInstance();
|
|
27808
27886
|
var validateClientConfig = (config) => validationService.validateClientConfig(config);
|
|
27809
|
-
var validateTransferParams = (params) => validationService.validateTransferParams(params);
|
|
27810
27887
|
var { typeGuards } = validationService;
|
|
27811
27888
|
|
|
27812
27889
|
// src/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts
|
|
@@ -28163,7 +28240,7 @@ ${operationTypes.join("\n")}
|
|
|
28163
28240
|
*/
|
|
28164
28241
|
constructor(graphQLClient, knishIOClient) {
|
|
28165
28242
|
super(graphQLClient, knishIOClient);
|
|
28166
|
-
this.$__query = `
|
|
28243
|
+
this.$__query = gql`
|
|
28167
28244
|
query($address: String, $bundleHash: String, $type: String, $token: String, $position: String) {
|
|
28168
28245
|
Balance(address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position) {
|
|
28169
28246
|
address,
|
|
@@ -28384,7 +28461,7 @@ ${operationTypes.join("\n")}
|
|
|
28384
28461
|
*/
|
|
28385
28462
|
constructor(graphQLClient, knishIOClient) {
|
|
28386
28463
|
super(graphQLClient, knishIOClient);
|
|
28387
|
-
this.$__query = `query( $bundleHash: String, $tokenSlug: String ) {
|
|
28464
|
+
this.$__query = gql`query( $bundleHash: String, $tokenSlug: String ) {
|
|
28388
28465
|
Wallet( bundleHash: $bundleHash, tokenSlug: $tokenSlug ) {
|
|
28389
28466
|
address,
|
|
28390
28467
|
bundleHash,
|
|
@@ -28466,7 +28543,7 @@ ${operationTypes.join("\n")}
|
|
|
28466
28543
|
*/
|
|
28467
28544
|
constructor(graphQLClient, knishIOClient) {
|
|
28468
28545
|
super(graphQLClient, knishIOClient);
|
|
28469
|
-
this.$__query = `
|
|
28546
|
+
this.$__query = gql`
|
|
28470
28547
|
query($bundleHashes: [String!]) {
|
|
28471
28548
|
WalletBundle(bundleHashes: $bundleHashes) {
|
|
28472
28549
|
bundleHash,
|
|
@@ -28543,7 +28620,7 @@ ${operationTypes.join("\n")}
|
|
|
28543
28620
|
*/
|
|
28544
28621
|
constructor(graphQLClient, knishIOClient) {
|
|
28545
28622
|
super(graphQLClient, knishIOClient);
|
|
28546
|
-
this.$__query = `query ($bundle: String!) {
|
|
28623
|
+
this.$__query = gql`query ($bundle: String!) {
|
|
28547
28624
|
ContinuId(bundle: $bundle) {
|
|
28548
28625
|
address,
|
|
28549
28626
|
bundleHash,
|
|
@@ -28622,7 +28699,7 @@ ${operationTypes.join("\n")}
|
|
|
28622
28699
|
*/
|
|
28623
28700
|
constructor(graphQLClient, knishIOClient) {
|
|
28624
28701
|
super(graphQLClient, knishIOClient);
|
|
28625
|
-
this.$__query = `query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String, $cellSlug: String ) {
|
|
28702
|
+
this.$__query = gql`query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String, $cellSlug: String ) {
|
|
28626
28703
|
MetaType( metaType: $metaType, metaTypes: $metaTypes, metaId: $metaId, metaIds: $metaIds, key: $key, keys: $keys, value: $value, values: $values, count: $count, filter: $filter, queryArgs: $queryArgs, countBy: $countBy, cellSlug: $cellSlug ) {
|
|
28627
28704
|
metaType,
|
|
28628
28705
|
instanceCount {
|
|
@@ -28719,7 +28796,7 @@ ${operationTypes.join("\n")}
|
|
|
28719
28796
|
*/
|
|
28720
28797
|
constructor(graphQLClient, knishIOClient) {
|
|
28721
28798
|
super(graphQLClient, knishIOClient);
|
|
28722
|
-
this.$__query = `query( $batchId: String ) {
|
|
28799
|
+
this.$__query = gql`query( $batchId: String ) {
|
|
28723
28800
|
Batch( batchId: $batchId ) {
|
|
28724
28801
|
${_QueryBatch.getFields()},
|
|
28725
28802
|
children {
|
|
@@ -28901,7 +28978,7 @@ ${operationTypes.join("\n")}
|
|
|
28901
28978
|
*/
|
|
28902
28979
|
constructor(graphQLClient, knishIOClient) {
|
|
28903
28980
|
super(graphQLClient, knishIOClient);
|
|
28904
|
-
this.$__query = `query(
|
|
28981
|
+
this.$__query = gql`query(
|
|
28905
28982
|
$molecularHashes: [String!],
|
|
28906
28983
|
$bundleHashes: [String!],
|
|
28907
28984
|
$positions:[String!],
|
|
@@ -29422,7 +29499,7 @@ ${operationTypes.join("\n")}
|
|
|
29422
29499
|
*/
|
|
29423
29500
|
constructor(graphQLClient, knishIOClient) {
|
|
29424
29501
|
super(graphQLClient, knishIOClient);
|
|
29425
|
-
this.$__query = `query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
29502
|
+
this.$__query = gql`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
29426
29503
|
MetaTypeViaAtom(
|
|
29427
29504
|
metaTypes: $metaTypes
|
|
29428
29505
|
metaIds: $metaIds
|
|
@@ -29534,7 +29611,6 @@ ${operationTypes.join("\n")}
|
|
|
29534
29611
|
init_Dot();
|
|
29535
29612
|
var ResponseProposeMolecule = class extends exports.Response {
|
|
29536
29613
|
$__clientMolecule;
|
|
29537
|
-
$__payload = null;
|
|
29538
29614
|
/**
|
|
29539
29615
|
* Class constructor
|
|
29540
29616
|
*/
|
|
@@ -29625,7 +29701,7 @@ ${operationTypes.join("\n")}
|
|
|
29625
29701
|
super(graphQLClient, knishIOClient);
|
|
29626
29702
|
this.$__molecule = molecule;
|
|
29627
29703
|
this.$__remainderWallet = null;
|
|
29628
|
-
this.$__query = `
|
|
29704
|
+
this.$__query = gql`
|
|
29629
29705
|
mutation($molecule: MoleculeInput!) {
|
|
29630
29706
|
ProposeMolecule(molecule: $molecule) {
|
|
29631
29707
|
molecularHash,
|
|
@@ -30625,6 +30701,9 @@ ${operationTypes.join("\n")}
|
|
|
30625
30701
|
* Get random uri from specified this.$__uris
|
|
30626
30702
|
*/
|
|
30627
30703
|
getRandomUri() {
|
|
30704
|
+
if (this.$__uris.length === 0) {
|
|
30705
|
+
throw new Error("No URIs configured");
|
|
30706
|
+
}
|
|
30628
30707
|
const rand = Math.floor(Math.random() * this.$__uris.length);
|
|
30629
30708
|
return this.$__uris[rand];
|
|
30630
30709
|
}
|
|
@@ -30785,8 +30864,8 @@ ${operationTypes.join("\n")}
|
|
|
30785
30864
|
molecule = null
|
|
30786
30865
|
}) {
|
|
30787
30866
|
this.log("info", `KnishIOClient::createMoleculeMutation() - Creating a new ${mutationClass.name} query...`);
|
|
30788
|
-
molecule || await this.createMolecule({});
|
|
30789
|
-
const mutation = new mutationClass(this.client(), this);
|
|
30867
|
+
const _molecule = molecule || await this.createMolecule({});
|
|
30868
|
+
const mutation = new mutationClass(this.client(), this, _molecule);
|
|
30790
30869
|
if (!(mutation instanceof Mutation)) {
|
|
30791
30870
|
throw new CodeException(`${this.constructor.name}::createMoleculeMutation() - This method only accepts Mutation subclasses!`);
|
|
30792
30871
|
}
|
|
@@ -30835,68 +30914,74 @@ ${operationTypes.join("\n")}
|
|
|
30835
30914
|
}
|
|
30836
30915
|
/**
|
|
30837
30916
|
* Transfer tokens between wallets
|
|
30838
|
-
*
|
|
30917
|
+
* Matches JavaScript SDK transferToken implementation exactly
|
|
30839
30918
|
*/
|
|
30840
|
-
async transferToken(
|
|
30841
|
-
|
|
30842
|
-
|
|
30843
|
-
|
|
30844
|
-
|
|
30845
|
-
|
|
30846
|
-
|
|
30847
|
-
|
|
30848
|
-
return {
|
|
30849
|
-
success: false,
|
|
30850
|
-
error: {
|
|
30851
|
-
code: "VALIDATION_ERROR",
|
|
30852
|
-
message: "Invalid transfer parameters",
|
|
30853
|
-
details: validationResult.error.details,
|
|
30854
|
-
context: "transferToken"
|
|
30855
|
-
}
|
|
30856
|
-
};
|
|
30857
|
-
}
|
|
30858
|
-
validationResult.data;
|
|
30859
|
-
let {
|
|
30860
|
-
bundleHash,
|
|
30861
|
-
token,
|
|
30862
|
-
amount = null,
|
|
30863
|
-
units = [],
|
|
30864
|
-
batchId = null,
|
|
30865
|
-
sourceWallet = null
|
|
30866
|
-
} = params;
|
|
30919
|
+
async transferToken({
|
|
30920
|
+
bundleHash,
|
|
30921
|
+
token,
|
|
30922
|
+
amount = null,
|
|
30923
|
+
units = [],
|
|
30924
|
+
batchId = null,
|
|
30925
|
+
sourceWallet = null
|
|
30926
|
+
}) {
|
|
30867
30927
|
if (units.length > 0) {
|
|
30868
|
-
if (amount && amount > 0) {
|
|
30869
|
-
throw new
|
|
30928
|
+
if (amount !== null && amount > 0) {
|
|
30929
|
+
throw new StackableUnitAmountException_default();
|
|
30870
30930
|
}
|
|
30871
30931
|
amount = units.length;
|
|
30872
30932
|
}
|
|
30873
|
-
|
|
30874
|
-
|
|
30875
|
-
token,
|
|
30876
|
-
batchId
|
|
30877
|
-
});
|
|
30878
|
-
if (!sourceWallet) {
|
|
30879
|
-
sourceWallet = await this.getSourceWallet();
|
|
30933
|
+
if (amount === null) {
|
|
30934
|
+
amount = 0;
|
|
30880
30935
|
}
|
|
30881
|
-
if (
|
|
30936
|
+
if (sourceWallet === null) {
|
|
30937
|
+
sourceWallet = await this.querySourceWallet({
|
|
30938
|
+
token,
|
|
30939
|
+
amount
|
|
30940
|
+
});
|
|
30941
|
+
}
|
|
30942
|
+
if (sourceWallet === null || Decimal.cmp(sourceWallet.balance, amount) < 0) {
|
|
30882
30943
|
throw new exports.TransferBalanceException();
|
|
30883
30944
|
}
|
|
30945
|
+
const recipientWallet = Wallet.create({
|
|
30946
|
+
bundle: bundleHash,
|
|
30947
|
+
token
|
|
30948
|
+
});
|
|
30949
|
+
if (batchId !== null) {
|
|
30950
|
+
recipientWallet.batchId = batchId;
|
|
30951
|
+
} else {
|
|
30952
|
+
recipientWallet.initBatchId({
|
|
30953
|
+
sourceWallet
|
|
30954
|
+
});
|
|
30955
|
+
}
|
|
30884
30956
|
const remainderWallet = sourceWallet.createRemainder(this.getSecret());
|
|
30885
|
-
|
|
30957
|
+
sourceWallet.splitUnits(
|
|
30958
|
+
units,
|
|
30959
|
+
remainderWallet,
|
|
30960
|
+
recipientWallet
|
|
30961
|
+
);
|
|
30962
|
+
const molecule = await this.createMolecule({
|
|
30886
30963
|
sourceWallet,
|
|
30887
30964
|
remainderWallet
|
|
30888
30965
|
});
|
|
30889
|
-
|
|
30966
|
+
const query = await this.createMoleculeMutation({
|
|
30967
|
+
mutationClass: MutationTransferTokens,
|
|
30968
|
+
molecule
|
|
30969
|
+
});
|
|
30970
|
+
query.fillMolecule({
|
|
30971
|
+
recipientWallet,
|
|
30972
|
+
amount
|
|
30973
|
+
});
|
|
30974
|
+
return await this.executeQuery(query);
|
|
30890
30975
|
}
|
|
30891
30976
|
/**
|
|
30892
30977
|
* Request authorization token
|
|
30893
30978
|
*/
|
|
30894
30979
|
async requestAuthToken({
|
|
30895
|
-
secret = null,
|
|
30896
|
-
seed = null,
|
|
30897
|
-
cellSlug = null,
|
|
30898
|
-
encrypt = false
|
|
30899
|
-
}) {
|
|
30980
|
+
secret: _secret = null,
|
|
30981
|
+
seed: _seed = null,
|
|
30982
|
+
cellSlug: _cellSlug = null,
|
|
30983
|
+
encrypt: _encrypt = false
|
|
30984
|
+
} = {}) {
|
|
30900
30985
|
if (this.$__serverSdkVersion < 3) {
|
|
30901
30986
|
this.log("warn", "KnishIOClient::authorize() - Server SDK version does not require an authorization...");
|
|
30902
30987
|
return null;
|
|
@@ -30998,7 +31083,8 @@ ${operationTypes.join("\n")}
|
|
|
30998
31083
|
type: type2
|
|
30999
31084
|
});
|
|
31000
31085
|
const sourceWallet = response.payload();
|
|
31001
|
-
|
|
31086
|
+
const amountNum = typeof amount === "string" ? Number(amount) : amount;
|
|
31087
|
+
if (sourceWallet === null || Decimal.cmp(sourceWallet.balance || 0, amountNum) < 0) {
|
|
31002
31088
|
throw new exports.TransferBalanceException();
|
|
31003
31089
|
}
|
|
31004
31090
|
if (!sourceWallet.position || !sourceWallet.address) {
|
|
@@ -31028,7 +31114,7 @@ ${operationTypes.join("\n")}
|
|
|
31028
31114
|
*/
|
|
31029
31115
|
async queryBundle({
|
|
31030
31116
|
bundle = null,
|
|
31031
|
-
fields = null,
|
|
31117
|
+
fields: _fields = null,
|
|
31032
31118
|
raw = false
|
|
31033
31119
|
} = {}) {
|
|
31034
31120
|
this.log("info", `KnishIOClient::queryBundle() - Querying wallet bundle metadata${bundle ? ` for ${bundle}` : ""}...`);
|
|
@@ -31062,7 +31148,7 @@ ${operationTypes.join("\n")}
|
|
|
31062
31148
|
key = null,
|
|
31063
31149
|
value: value2 = null,
|
|
31064
31150
|
latest = null,
|
|
31065
|
-
fields = null,
|
|
31151
|
+
fields: _fields = null,
|
|
31066
31152
|
filter: filter2 = null,
|
|
31067
31153
|
queryArgs = null,
|
|
31068
31154
|
count = null,
|
|
@@ -31368,21 +31454,22 @@ ${operationTypes.join("\n")}
|
|
|
31368
31454
|
amount = null,
|
|
31369
31455
|
meta = null,
|
|
31370
31456
|
batchId = null,
|
|
31371
|
-
units = null
|
|
31457
|
+
units: _units = null
|
|
31372
31458
|
}) {
|
|
31373
31459
|
this.log("info", `KnishIOClient::createToken() - Creating token ${token}...`);
|
|
31374
|
-
const mutation = this.
|
|
31375
|
-
const
|
|
31376
|
-
|
|
31377
|
-
|
|
31460
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateToken });
|
|
31461
|
+
const recipientWallet = new Wallet({
|
|
31462
|
+
secret: this.getSecret(),
|
|
31463
|
+
bundle: this.getBundle(),
|
|
31378
31464
|
token: token.toUpperCase(),
|
|
31379
|
-
|
|
31380
|
-
|
|
31381
|
-
|
|
31382
|
-
|
|
31465
|
+
batchId
|
|
31466
|
+
});
|
|
31467
|
+
await mutation.fillMolecule({
|
|
31468
|
+
recipientWallet,
|
|
31469
|
+
amount: amount ?? 0,
|
|
31470
|
+
meta
|
|
31383
31471
|
});
|
|
31384
|
-
const
|
|
31385
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31472
|
+
const response = await this.executeQuery(mutation);
|
|
31386
31473
|
if (!response) {
|
|
31387
31474
|
throw new CodeException("Token creation failed");
|
|
31388
31475
|
}
|
|
@@ -31395,24 +31482,21 @@ ${operationTypes.join("\n")}
|
|
|
31395
31482
|
token,
|
|
31396
31483
|
to = null,
|
|
31397
31484
|
amount = null,
|
|
31398
|
-
units = null,
|
|
31485
|
+
units: _units = null,
|
|
31399
31486
|
meta = null,
|
|
31400
31487
|
batchId = null
|
|
31401
31488
|
}) {
|
|
31402
31489
|
this.log("info", `KnishIOClient::requestTokens() - Requesting ${amount || "units"} of ${token}...`);
|
|
31403
|
-
const mutation = this.
|
|
31404
|
-
const sourceWallet = await this.getSourceWallet();
|
|
31490
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationRequestTokens });
|
|
31405
31491
|
await mutation.fillMolecule({
|
|
31406
|
-
sourceWallet,
|
|
31407
31492
|
token: token.toUpperCase(),
|
|
31408
|
-
|
|
31409
|
-
|
|
31410
|
-
|
|
31493
|
+
amount: amount ?? 0,
|
|
31494
|
+
metaType: to || "",
|
|
31495
|
+
metaId: to || "",
|
|
31411
31496
|
meta,
|
|
31412
31497
|
batchId
|
|
31413
31498
|
});
|
|
31414
|
-
const
|
|
31415
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31499
|
+
const response = await this.executeQuery(mutation);
|
|
31416
31500
|
if (!response) {
|
|
31417
31501
|
throw new CodeException("Token request failed");
|
|
31418
31502
|
}
|
|
@@ -31424,7 +31508,7 @@ ${operationTypes.join("\n")}
|
|
|
31424
31508
|
async burnTokens({
|
|
31425
31509
|
token,
|
|
31426
31510
|
amount = null,
|
|
31427
|
-
units = null,
|
|
31511
|
+
units: _units = null,
|
|
31428
31512
|
sourceWallet = null
|
|
31429
31513
|
}) {
|
|
31430
31514
|
this.log("info", `KnishIOClient::burnTokens() - Burning ${amount || "units"} of ${token}...`);
|
|
@@ -31434,17 +31518,17 @@ ${operationTypes.join("\n")}
|
|
|
31434
31518
|
amount: amount || 0
|
|
31435
31519
|
});
|
|
31436
31520
|
}
|
|
31437
|
-
const mutation = this.
|
|
31521
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationTransferTokens });
|
|
31522
|
+
const recipientWallet = new Wallet({
|
|
31523
|
+
secret: this.getSecret(),
|
|
31524
|
+
bundle: "0000000000000000000000000000000000000000000000000000000000000000",
|
|
31525
|
+
token: token.toUpperCase()
|
|
31526
|
+
});
|
|
31438
31527
|
await mutation.fillMolecule({
|
|
31439
|
-
|
|
31440
|
-
|
|
31441
|
-
// Burn address
|
|
31442
|
-
token: token.toUpperCase(),
|
|
31443
|
-
amount,
|
|
31444
|
-
units
|
|
31528
|
+
recipientWallet,
|
|
31529
|
+
amount: amount ?? 0
|
|
31445
31530
|
});
|
|
31446
|
-
const
|
|
31447
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31531
|
+
const response = await this.executeQuery(mutation);
|
|
31448
31532
|
if (!response) {
|
|
31449
31533
|
throw new CodeException("Token burn failed");
|
|
31450
31534
|
}
|
|
@@ -31457,7 +31541,7 @@ ${operationTypes.join("\n")}
|
|
|
31457
31541
|
token,
|
|
31458
31542
|
amount = null,
|
|
31459
31543
|
units = null,
|
|
31460
|
-
sourceWallet = null
|
|
31544
|
+
sourceWallet: _sourceWallet = null
|
|
31461
31545
|
}) {
|
|
31462
31546
|
this.log("info", `KnishIOClient::replenishToken() - Replenishing ${amount || "units"} of ${token}...`);
|
|
31463
31547
|
return this.requestTokens({
|
|
@@ -31470,11 +31554,11 @@ ${operationTypes.join("\n")}
|
|
|
31470
31554
|
* Fuse token units
|
|
31471
31555
|
*/
|
|
31472
31556
|
async fuseToken({
|
|
31473
|
-
bundleHash,
|
|
31557
|
+
bundleHash: _bundleHash,
|
|
31474
31558
|
tokenSlug,
|
|
31475
|
-
newTokenUnit,
|
|
31476
|
-
fusedTokenUnitIds,
|
|
31477
|
-
sourceWallet = null
|
|
31559
|
+
newTokenUnit: _newTokenUnit,
|
|
31560
|
+
fusedTokenUnitIds: _fusedTokenUnitIds,
|
|
31561
|
+
sourceWallet: _sourceWallet = null
|
|
31478
31562
|
}) {
|
|
31479
31563
|
this.log("info", `KnishIOClient::fuseToken() - Fusing token units for ${tokenSlug}...`);
|
|
31480
31564
|
throw new CodeException("Token fusion not yet implemented");
|
|
@@ -31489,14 +31573,14 @@ ${operationTypes.join("\n")}
|
|
|
31489
31573
|
token
|
|
31490
31574
|
}) {
|
|
31491
31575
|
this.log("info", `KnishIOClient::createWallet() - Creating wallet for token ${token}...`);
|
|
31492
|
-
const mutation = this.
|
|
31493
|
-
const
|
|
31494
|
-
|
|
31495
|
-
|
|
31576
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateWallet });
|
|
31577
|
+
const newWallet = new Wallet({
|
|
31578
|
+
secret: this.getSecret(),
|
|
31579
|
+
bundle: this.getBundle(),
|
|
31496
31580
|
token: token.toUpperCase()
|
|
31497
31581
|
});
|
|
31498
|
-
|
|
31499
|
-
const response = await this.executeQuery(
|
|
31582
|
+
await mutation.fillMolecule(newWallet);
|
|
31583
|
+
const response = await this.executeQuery(mutation);
|
|
31500
31584
|
if (!response) {
|
|
31501
31585
|
throw new CodeException("Wallet creation failed");
|
|
31502
31586
|
}
|
|
@@ -31508,7 +31592,7 @@ ${operationTypes.join("\n")}
|
|
|
31508
31592
|
async claimShadowWallet({
|
|
31509
31593
|
token,
|
|
31510
31594
|
batchId = null,
|
|
31511
|
-
molecule = null
|
|
31595
|
+
molecule: _molecule = null
|
|
31512
31596
|
}) {
|
|
31513
31597
|
this.log("info", `KnishIOClient::claimShadowWallet() - Claiming shadow wallet for token ${token}...`);
|
|
31514
31598
|
const shadowWallets = await this.queryWallets({ token });
|
|
@@ -31522,15 +31606,12 @@ ${operationTypes.join("\n")}
|
|
|
31522
31606
|
if (!shadowWallet.isShadow()) {
|
|
31523
31607
|
throw new WalletShadowException_default("Wallet is not a shadow wallet");
|
|
31524
31608
|
}
|
|
31525
|
-
const mutation = this.
|
|
31526
|
-
const sourceWallet = await this.getSourceWallet();
|
|
31609
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationClaimShadowWallet });
|
|
31527
31610
|
await mutation.fillMolecule({
|
|
31528
|
-
sourceWallet,
|
|
31529
31611
|
token: token.toUpperCase(),
|
|
31530
31612
|
batchId: shadowWallet.batchId
|
|
31531
31613
|
});
|
|
31532
|
-
const
|
|
31533
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31614
|
+
const response = await this.executeQuery(mutation);
|
|
31534
31615
|
if (!response) {
|
|
31535
31616
|
throw new CodeException("Shadow wallet claim failed");
|
|
31536
31617
|
}
|
|
@@ -31575,17 +31656,14 @@ ${operationTypes.join("\n")}
|
|
|
31575
31656
|
policy = null
|
|
31576
31657
|
}) {
|
|
31577
31658
|
this.log("info", `KnishIOClient::createMeta() - Creating metadata for ${metaType}:${metaId}...`);
|
|
31578
|
-
const mutation = this.
|
|
31579
|
-
const sourceWallet = await this.getSourceWallet();
|
|
31659
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateMeta });
|
|
31580
31660
|
await mutation.fillMolecule({
|
|
31581
|
-
sourceWallet,
|
|
31582
31661
|
metaType: metaType.toUpperCase(),
|
|
31583
31662
|
metaId,
|
|
31584
31663
|
meta,
|
|
31585
31664
|
policy
|
|
31586
31665
|
});
|
|
31587
|
-
const
|
|
31588
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31666
|
+
const response = await this.executeQuery(mutation);
|
|
31589
31667
|
if (!response) {
|
|
31590
31668
|
throw new CodeException("Metadata creation failed");
|
|
31591
31669
|
}
|
|
@@ -31601,17 +31679,14 @@ ${operationTypes.join("\n")}
|
|
|
31601
31679
|
policy = null
|
|
31602
31680
|
}) {
|
|
31603
31681
|
this.log("info", `KnishIOClient::createRule() - Creating rule for ${metaType}:${metaId}...`);
|
|
31604
|
-
const mutation = this.
|
|
31605
|
-
const sourceWallet = await this.getSourceWallet();
|
|
31682
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateRule });
|
|
31606
31683
|
await mutation.fillMolecule({
|
|
31607
|
-
sourceWallet,
|
|
31608
31684
|
metaType: metaType.toUpperCase(),
|
|
31609
31685
|
metaId,
|
|
31610
31686
|
rule,
|
|
31611
31687
|
policy
|
|
31612
31688
|
});
|
|
31613
|
-
const
|
|
31614
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31689
|
+
const response = await this.executeQuery(mutation);
|
|
31615
31690
|
if (!response) {
|
|
31616
31691
|
throw new CodeException("Rule creation failed");
|
|
31617
31692
|
}
|
|
@@ -31642,16 +31717,13 @@ ${operationTypes.join("\n")}
|
|
|
31642
31717
|
code
|
|
31643
31718
|
}) {
|
|
31644
31719
|
this.log("info", `KnishIOClient::createIdentifier() - Creating identifier of type ${type2}...`);
|
|
31645
|
-
const mutation = this.
|
|
31646
|
-
const sourceWallet = await this.getSourceWallet();
|
|
31720
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateIdentifier });
|
|
31647
31721
|
await mutation.fillMolecule({
|
|
31648
|
-
sourceWallet,
|
|
31649
31722
|
type: type2,
|
|
31650
31723
|
contact,
|
|
31651
31724
|
code
|
|
31652
31725
|
});
|
|
31653
|
-
const
|
|
31654
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31726
|
+
const response = await this.executeQuery(mutation);
|
|
31655
31727
|
if (!response) {
|
|
31656
31728
|
throw new CodeException("Identifier creation failed");
|
|
31657
31729
|
}
|
|
@@ -31666,14 +31738,11 @@ ${operationTypes.join("\n")}
|
|
|
31666
31738
|
}) {
|
|
31667
31739
|
this.log("info", `KnishIOClient::linkIdentifier() - Linking identifier of type ${type2}...`);
|
|
31668
31740
|
const mutation = this.createQuery(MutationLinkIdentifier);
|
|
31669
|
-
const
|
|
31670
|
-
|
|
31671
|
-
sourceWallet,
|
|
31741
|
+
const response = await this.executeQuery(mutation, {
|
|
31742
|
+
bundle: this.getBundle(),
|
|
31672
31743
|
type: type2,
|
|
31673
|
-
contact
|
|
31744
|
+
content: contact
|
|
31674
31745
|
});
|
|
31675
|
-
const moleculeMutation = await this.createMoleculeMutation({ mutationClass: mutation });
|
|
31676
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31677
31746
|
if (!response) {
|
|
31678
31747
|
throw new CodeException("Identifier linking failed");
|
|
31679
31748
|
}
|
|
@@ -31698,10 +31767,8 @@ ${operationTypes.join("\n")}
|
|
|
31698
31767
|
}) {
|
|
31699
31768
|
this.log("info", `KnishIOClient::activeSession() - Declaring active session for ${metaType}:${metaId}...`);
|
|
31700
31769
|
const mutation = this.createQuery(MutationActiveSession);
|
|
31701
|
-
const
|
|
31702
|
-
|
|
31703
|
-
sourceWallet,
|
|
31704
|
-
bundle,
|
|
31770
|
+
const response = await this.executeQuery(mutation, {
|
|
31771
|
+
bundle: bundle || this.getBundle(),
|
|
31705
31772
|
metaType: metaType.toUpperCase(),
|
|
31706
31773
|
metaId,
|
|
31707
31774
|
ipAddress,
|
|
@@ -31711,8 +31778,6 @@ ${operationTypes.join("\n")}
|
|
|
31711
31778
|
timeZone,
|
|
31712
31779
|
json
|
|
31713
31780
|
});
|
|
31714
|
-
const moleculeMutation = await this.createMoleculeMutation({ mutationClass: mutation });
|
|
31715
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31716
31781
|
if (!response) {
|
|
31717
31782
|
throw new CodeException("Active session declaration failed");
|
|
31718
31783
|
}
|
|
@@ -31734,15 +31799,12 @@ ${operationTypes.join("\n")}
|
|
|
31734
31799
|
amount
|
|
31735
31800
|
});
|
|
31736
31801
|
}
|
|
31737
|
-
const mutation = this.
|
|
31802
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationDepositBufferToken });
|
|
31738
31803
|
await mutation.fillMolecule({
|
|
31739
|
-
|
|
31740
|
-
tokenSlug: tokenSlug.toUpperCase(),
|
|
31741
|
-
amount,
|
|
31804
|
+
amount: typeof amount === "string" ? Number(amount) : amount,
|
|
31742
31805
|
tradeRates
|
|
31743
31806
|
});
|
|
31744
|
-
const
|
|
31745
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31807
|
+
const response = await this.executeQuery(mutation);
|
|
31746
31808
|
if (!response) {
|
|
31747
31809
|
throw new CodeException("Buffer token deposit failed");
|
|
31748
31810
|
}
|
|
@@ -31761,15 +31823,15 @@ ${operationTypes.join("\n")}
|
|
|
31761
31823
|
if (!sourceWallet) {
|
|
31762
31824
|
sourceWallet = await this.getSourceWallet();
|
|
31763
31825
|
}
|
|
31764
|
-
const mutation = this.
|
|
31765
|
-
|
|
31766
|
-
|
|
31767
|
-
|
|
31768
|
-
|
|
31769
|
-
signingWallet
|
|
31770
|
-
}
|
|
31771
|
-
|
|
31772
|
-
const response = await this.executeQuery(
|
|
31826
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationWithdrawBufferToken });
|
|
31827
|
+
const recipients = {};
|
|
31828
|
+
recipients[this.getBundle()] = amount;
|
|
31829
|
+
const fillMoleculeParams = { recipients };
|
|
31830
|
+
if (signingWallet) {
|
|
31831
|
+
fillMoleculeParams.signingWallet = signingWallet;
|
|
31832
|
+
}
|
|
31833
|
+
await mutation.fillMolecule(fillMoleculeParams);
|
|
31834
|
+
const response = await this.executeQuery(mutation);
|
|
31773
31835
|
if (!response) {
|
|
31774
31836
|
throw new CodeException("Buffer token withdrawal failed");
|
|
31775
31837
|
}
|
|
@@ -31787,11 +31849,9 @@ ${operationTypes.join("\n")}
|
|
|
31787
31849
|
} = {}) {
|
|
31788
31850
|
this.log("info", "KnishIOClient::requestGuestAuthToken() - Requesting guest auth token...");
|
|
31789
31851
|
const mutation = this.createQuery(MutationRequestAuthorizationGuest);
|
|
31790
|
-
await
|
|
31852
|
+
const response = await this.executeQuery(mutation, {
|
|
31791
31853
|
cellSlug: cellSlug || this.getCellSlug()
|
|
31792
31854
|
});
|
|
31793
|
-
const moleculeMutation = await this.createMoleculeMutation({ mutationClass: mutation });
|
|
31794
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31795
31855
|
if (!response) {
|
|
31796
31856
|
throw new CodeException("Guest auth token request failed");
|
|
31797
31857
|
}
|
|
@@ -31809,14 +31869,11 @@ ${operationTypes.join("\n")}
|
|
|
31809
31869
|
}) {
|
|
31810
31870
|
this.log("info", "KnishIOClient::requestProfileAuthToken() - Requesting profile auth token...");
|
|
31811
31871
|
this.setSecret(secret);
|
|
31812
|
-
const mutation = this.
|
|
31813
|
-
const sourceWallet = await this.getSourceWallet();
|
|
31872
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationRequestAuthorization });
|
|
31814
31873
|
await mutation.fillMolecule({
|
|
31815
|
-
|
|
31816
|
-
cellSlug: this.getCellSlug()
|
|
31874
|
+
meta: { encrypt: encrypt ? "true" : "false" }
|
|
31817
31875
|
});
|
|
31818
|
-
const
|
|
31819
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
31876
|
+
const response = await this.executeQuery(mutation);
|
|
31820
31877
|
if (!response) {
|
|
31821
31878
|
throw new CodeException("Profile auth token request failed");
|
|
31822
31879
|
}
|