@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.cjs
CHANGED
|
@@ -920,9 +920,19 @@ var init_DecryptionKeyException = __esm({
|
|
|
920
920
|
});
|
|
921
921
|
|
|
922
922
|
// src/exception/StackableUnitAmountException.ts
|
|
923
|
+
var StackableUnitAmountException, StackableUnitAmountException_default;
|
|
923
924
|
var init_StackableUnitAmountException = __esm({
|
|
924
925
|
"src/exception/StackableUnitAmountException.ts"() {
|
|
925
926
|
init_BaseException();
|
|
927
|
+
StackableUnitAmountException = class extends exports.BaseException {
|
|
928
|
+
/**
|
|
929
|
+
* Constructor using proper error type
|
|
930
|
+
*/
|
|
931
|
+
constructor(message = "Stackable tokens with unit IDs cannot have an amount!") {
|
|
932
|
+
super("STACKABLE_UNIT_AMOUNT_ERROR", message);
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
StackableUnitAmountException_default = StackableUnitAmountException;
|
|
926
936
|
}
|
|
927
937
|
});
|
|
928
938
|
|
|
@@ -1494,7 +1504,7 @@ var init_EnhancedResponse = __esm({
|
|
|
1494
1504
|
// Enhanced response validation
|
|
1495
1505
|
validate() {
|
|
1496
1506
|
try {
|
|
1497
|
-
|
|
1507
|
+
ValidationResultSchema.parse(this.toValidationResult());
|
|
1498
1508
|
return {
|
|
1499
1509
|
success: true,
|
|
1500
1510
|
data: this._payload,
|
|
@@ -1515,14 +1525,14 @@ var init_EnhancedResponse = __esm({
|
|
|
1515
1525
|
static createSuccessResponse(payload, operation, rawData, duration) {
|
|
1516
1526
|
return StandardResponse.success(payload, rawData, {
|
|
1517
1527
|
operation,
|
|
1518
|
-
duration,
|
|
1528
|
+
...duration !== void 0 ? { duration } : {},
|
|
1519
1529
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1520
1530
|
});
|
|
1521
1531
|
}
|
|
1522
1532
|
static createErrorResponse(errorMessage, operation, rawData, duration) {
|
|
1523
1533
|
return StandardResponse.failure(errorMessage, rawData, {
|
|
1524
1534
|
operation,
|
|
1525
|
-
duration,
|
|
1535
|
+
...duration !== void 0 ? { duration } : {},
|
|
1526
1536
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1527
1537
|
});
|
|
1528
1538
|
}
|
|
@@ -1581,7 +1591,7 @@ var init_Response = __esm({
|
|
|
1581
1591
|
if (exports.Dot.has(this.$__response, this.errorKey)) {
|
|
1582
1592
|
const error = exports.Dot.get(this.$__response, this.errorKey);
|
|
1583
1593
|
if (String(error).includes("Unauthenticated")) {
|
|
1584
|
-
throw new UnauthenticatedException();
|
|
1594
|
+
throw new UnauthenticatedException("Unauthenticated request");
|
|
1585
1595
|
}
|
|
1586
1596
|
throw new exports.InvalidResponseException();
|
|
1587
1597
|
}
|
|
@@ -1849,7 +1859,7 @@ function isNumeric(str) {
|
|
|
1849
1859
|
}
|
|
1850
1860
|
function toCamelCase(str) {
|
|
1851
1861
|
if (!str) return "";
|
|
1852
|
-
return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (
|
|
1862
|
+
return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_match, chr) => chr.toUpperCase());
|
|
1853
1863
|
}
|
|
1854
1864
|
function toSnakeCase(str) {
|
|
1855
1865
|
if (!str) return "";
|
|
@@ -2096,13 +2106,14 @@ function normalizeMolecularHash(mappedHashArray) {
|
|
|
2096
2106
|
const totalCondition = total < 0;
|
|
2097
2107
|
while (total !== 0) {
|
|
2098
2108
|
for (let index = 0; index < normalized.length; index++) {
|
|
2099
|
-
const
|
|
2109
|
+
const value = normalized[index];
|
|
2110
|
+
const condition = totalCondition ? value < 8 : value > -8;
|
|
2100
2111
|
if (condition) {
|
|
2101
2112
|
if (totalCondition) {
|
|
2102
|
-
normalized[index]
|
|
2113
|
+
normalized[index] = value + 1;
|
|
2103
2114
|
total++;
|
|
2104
2115
|
} else {
|
|
2105
|
-
normalized[index]
|
|
2116
|
+
normalized[index] = value - 1;
|
|
2106
2117
|
total--;
|
|
2107
2118
|
}
|
|
2108
2119
|
if (total === 0) break;
|
|
@@ -2814,6 +2825,12 @@ var Wallet = class _Wallet {
|
|
|
2814
2825
|
tokenUnits;
|
|
2815
2826
|
tradeRates;
|
|
2816
2827
|
molecules;
|
|
2828
|
+
// Token metadata (populated from query responses)
|
|
2829
|
+
tokenName;
|
|
2830
|
+
tokenAmount;
|
|
2831
|
+
tokenSupply;
|
|
2832
|
+
tokenFungibility;
|
|
2833
|
+
createdAt;
|
|
2817
2834
|
constructor({
|
|
2818
2835
|
secret = null,
|
|
2819
2836
|
bundle = null,
|
|
@@ -2960,6 +2977,45 @@ var Wallet = class _Wallet {
|
|
|
2960
2977
|
characters: this.characters
|
|
2961
2978
|
});
|
|
2962
2979
|
}
|
|
2980
|
+
/**
|
|
2981
|
+
* Sets up a batch ID - either using the sender's, or a new one
|
|
2982
|
+
* Matches JavaScript SDK Wallet.initBatchId exactly
|
|
2983
|
+
*/
|
|
2984
|
+
initBatchId({
|
|
2985
|
+
sourceWallet,
|
|
2986
|
+
isRemainder = false
|
|
2987
|
+
}) {
|
|
2988
|
+
if (sourceWallet.batchId) {
|
|
2989
|
+
this.batchId = isRemainder ? sourceWallet.batchId : generateBatchId({});
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
/**
|
|
2993
|
+
* Split token units between wallets
|
|
2994
|
+
* Matches JavaScript SDK Wallet.splitUnits exactly
|
|
2995
|
+
*
|
|
2996
|
+
* @param units - Array of token unit IDs to transfer
|
|
2997
|
+
* @param remainderWallet - Wallet to receive units not being transferred
|
|
2998
|
+
* @param recipientWallet - Wallet to receive the transferred units (optional)
|
|
2999
|
+
*/
|
|
3000
|
+
splitUnits(units, remainderWallet, recipientWallet = null) {
|
|
3001
|
+
if (units.length === 0) {
|
|
3002
|
+
return;
|
|
3003
|
+
}
|
|
3004
|
+
const recipientTokenUnits = [];
|
|
3005
|
+
const remainderTokenUnits = [];
|
|
3006
|
+
this.tokenUnits.forEach((tokenUnit) => {
|
|
3007
|
+
if (units.includes(tokenUnit.id)) {
|
|
3008
|
+
recipientTokenUnits.push(tokenUnit);
|
|
3009
|
+
} else {
|
|
3010
|
+
remainderTokenUnits.push(tokenUnit);
|
|
3011
|
+
}
|
|
3012
|
+
});
|
|
3013
|
+
this.tokenUnits = recipientTokenUnits;
|
|
3014
|
+
if (recipientWallet !== null) {
|
|
3015
|
+
recipientWallet.tokenUnits = recipientTokenUnits;
|
|
3016
|
+
}
|
|
3017
|
+
remainderWallet.tokenUnits = remainderTokenUnits;
|
|
3018
|
+
}
|
|
2963
3019
|
/**
|
|
2964
3020
|
* Get token units data
|
|
2965
3021
|
* Stub for compatibility
|
|
@@ -2982,7 +3038,7 @@ var Wallet = class _Wallet {
|
|
|
2982
3038
|
* Initializes the ML-KEM key pair (matches JavaScript SDK exactly)
|
|
2983
3039
|
*/
|
|
2984
3040
|
initializeMLKEM() {
|
|
2985
|
-
const seedHex = generateSecret(this.key,
|
|
3041
|
+
const seedHex = generateSecret(this.key, 64);
|
|
2986
3042
|
const seed = new Uint8Array(64);
|
|
2987
3043
|
for (let i = 0; i < 64; i++) {
|
|
2988
3044
|
seed[i] = parseInt(seedHex.substr(i * 2, 2), 16);
|
|
@@ -3499,9 +3555,9 @@ var CheckMolecule = class {
|
|
|
3499
3555
|
}
|
|
3500
3556
|
const metas = Meta.aggregateMeta(atom.meta);
|
|
3501
3557
|
for (const key of policyArray) {
|
|
3502
|
-
|
|
3503
|
-
if (
|
|
3504
|
-
policy = JSON.parse(
|
|
3558
|
+
const policyRaw = metas[key];
|
|
3559
|
+
if (policyRaw) {
|
|
3560
|
+
const policy = JSON.parse(policyRaw);
|
|
3505
3561
|
for (const [policyName, policyValue] of Object.entries(policy)) {
|
|
3506
3562
|
if (!policyArray.includes(policyName)) {
|
|
3507
3563
|
if (!Object.keys(metas).includes(policyName)) {
|
|
@@ -4621,8 +4677,7 @@ var GraphQLClient = class {
|
|
|
4621
4677
|
}
|
|
4622
4678
|
createUrqlClient({
|
|
4623
4679
|
serverUri,
|
|
4624
|
-
socket
|
|
4625
|
-
encrypt
|
|
4680
|
+
socket
|
|
4626
4681
|
}) {
|
|
4627
4682
|
const exchanges = [core.cacheExchange, core.fetchExchange];
|
|
4628
4683
|
if (socket?.socketUri) {
|
|
@@ -4674,13 +4729,36 @@ var GraphQLClient = class {
|
|
|
4674
4729
|
const result = await this.$__client.query(request.query, finalVariables).toPromise();
|
|
4675
4730
|
return this.formatResponse(result);
|
|
4676
4731
|
}
|
|
4677
|
-
async
|
|
4732
|
+
async mutation(request, variables) {
|
|
4678
4733
|
const finalVariables = variables || request.variables || {};
|
|
4679
|
-
const
|
|
4734
|
+
const mutationString = request.mutation || request.query;
|
|
4735
|
+
const result = await this.$__client.mutation(mutationString, finalVariables).toPromise();
|
|
4680
4736
|
return this.formatResponse(result);
|
|
4681
4737
|
}
|
|
4682
|
-
|
|
4683
|
-
|
|
4738
|
+
// Alias for mutation() to match JS SDK interface
|
|
4739
|
+
async mutate(request, variables) {
|
|
4740
|
+
return this.mutation(request, variables);
|
|
4741
|
+
}
|
|
4742
|
+
async *subscription(request, variables) {
|
|
4743
|
+
const finalVariables = variables || request.variables || {};
|
|
4744
|
+
const subscription = this.$__client.subscription(request.query, finalVariables);
|
|
4745
|
+
const results = [];
|
|
4746
|
+
const { unsubscribe } = wonka.pipe(
|
|
4747
|
+
subscription,
|
|
4748
|
+
wonka.subscribe((result) => {
|
|
4749
|
+
results.push(this.formatResponse(result));
|
|
4750
|
+
})
|
|
4751
|
+
);
|
|
4752
|
+
try {
|
|
4753
|
+
while (true) {
|
|
4754
|
+
if (results.length > 0) {
|
|
4755
|
+
yield results.shift();
|
|
4756
|
+
}
|
|
4757
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
4758
|
+
}
|
|
4759
|
+
} finally {
|
|
4760
|
+
unsubscribe();
|
|
4761
|
+
}
|
|
4684
4762
|
}
|
|
4685
4763
|
subscribe(request, callback) {
|
|
4686
4764
|
const { query, variables, operationName = "subscription" } = request;
|
|
@@ -4709,7 +4787,7 @@ var GraphQLClient = class {
|
|
|
4709
4787
|
}
|
|
4710
4788
|
}
|
|
4711
4789
|
unsubscribeAll() {
|
|
4712
|
-
this.$__subscriptionManager.forEach((
|
|
4790
|
+
this.$__subscriptionManager.forEach((_subscription, operationName) => {
|
|
4713
4791
|
this.unsubscribe(operationName);
|
|
4714
4792
|
});
|
|
4715
4793
|
}
|
|
@@ -5562,7 +5640,6 @@ var ValidationChainBuilder = class {
|
|
|
5562
5640
|
};
|
|
5563
5641
|
var validationService = ValidationService.getInstance();
|
|
5564
5642
|
var validateClientConfig = (config) => validationService.validateClientConfig(config);
|
|
5565
|
-
var validateTransferParams = (params) => validationService.validateTransferParams(params);
|
|
5566
5643
|
var { typeGuards } = validationService;
|
|
5567
5644
|
|
|
5568
5645
|
// src/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts
|
|
@@ -5911,15 +5988,13 @@ var ResponseBalance = class _ResponseBalance extends exports.Response {
|
|
|
5911
5988
|
return wallet;
|
|
5912
5989
|
}
|
|
5913
5990
|
};
|
|
5914
|
-
|
|
5915
|
-
// src/query/QueryBalance.ts
|
|
5916
5991
|
var QueryBalance = class extends Query {
|
|
5917
5992
|
/**
|
|
5918
5993
|
* Create QueryBalance instance
|
|
5919
5994
|
*/
|
|
5920
5995
|
constructor(graphQLClient, knishIOClient) {
|
|
5921
5996
|
super(graphQLClient, knishIOClient);
|
|
5922
|
-
this.$__query = `
|
|
5997
|
+
this.$__query = core.gql`
|
|
5923
5998
|
query($address: String, $bundleHash: String, $type: String, $token: String, $position: String) {
|
|
5924
5999
|
Balance(address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position) {
|
|
5925
6000
|
address,
|
|
@@ -6131,8 +6206,6 @@ var ResponseWalletList = class _ResponseWalletList extends exports.Response {
|
|
|
6131
6206
|
return this.getWallets();
|
|
6132
6207
|
}
|
|
6133
6208
|
};
|
|
6134
|
-
|
|
6135
|
-
// src/query/QueryWalletList.ts
|
|
6136
6209
|
var QueryWalletList = class extends Query {
|
|
6137
6210
|
/**
|
|
6138
6211
|
* Create new QueryWalletList instance
|
|
@@ -6140,7 +6213,7 @@ var QueryWalletList = class extends Query {
|
|
|
6140
6213
|
*/
|
|
6141
6214
|
constructor(graphQLClient, knishIOClient) {
|
|
6142
6215
|
super(graphQLClient, knishIOClient);
|
|
6143
|
-
this.$__query = `query( $bundleHash: String, $tokenSlug: String ) {
|
|
6216
|
+
this.$__query = core.gql`query( $bundleHash: String, $tokenSlug: String ) {
|
|
6144
6217
|
Wallet( bundleHash: $bundleHash, tokenSlug: $tokenSlug ) {
|
|
6145
6218
|
address,
|
|
6146
6219
|
bundleHash,
|
|
@@ -6214,15 +6287,13 @@ var ResponseWalletBundle = class extends exports.Response {
|
|
|
6214
6287
|
return aggregate;
|
|
6215
6288
|
}
|
|
6216
6289
|
};
|
|
6217
|
-
|
|
6218
|
-
// src/query/QueryWalletBundle.ts
|
|
6219
6290
|
var QueryWalletBundle = class extends Query {
|
|
6220
6291
|
/**
|
|
6221
6292
|
* Create QueryWalletBundle instance
|
|
6222
6293
|
*/
|
|
6223
6294
|
constructor(graphQLClient, knishIOClient) {
|
|
6224
6295
|
super(graphQLClient, knishIOClient);
|
|
6225
|
-
this.$__query = `
|
|
6296
|
+
this.$__query = core.gql`
|
|
6226
6297
|
query($bundleHashes: [String!]) {
|
|
6227
6298
|
WalletBundle(bundleHashes: $bundleHashes) {
|
|
6228
6299
|
bundleHash,
|
|
@@ -6290,8 +6361,6 @@ var ResponseContinuId = class extends exports.Response {
|
|
|
6290
6361
|
return wallet;
|
|
6291
6362
|
}
|
|
6292
6363
|
};
|
|
6293
|
-
|
|
6294
|
-
// src/query/QueryContinuId.ts
|
|
6295
6364
|
var QueryContinuId = class extends Query {
|
|
6296
6365
|
/**
|
|
6297
6366
|
* Create new QueryContinuId instance
|
|
@@ -6299,7 +6368,7 @@ var QueryContinuId = class extends Query {
|
|
|
6299
6368
|
*/
|
|
6300
6369
|
constructor(graphQLClient, knishIOClient) {
|
|
6301
6370
|
super(graphQLClient, knishIOClient);
|
|
6302
|
-
this.$__query = `query ($bundle: String!) {
|
|
6371
|
+
this.$__query = core.gql`query ($bundle: String!) {
|
|
6303
6372
|
ContinuId(bundle: $bundle) {
|
|
6304
6373
|
address,
|
|
6305
6374
|
bundleHash,
|
|
@@ -6369,8 +6438,6 @@ var ResponseMetaType = class extends exports.Response {
|
|
|
6369
6438
|
return response;
|
|
6370
6439
|
}
|
|
6371
6440
|
};
|
|
6372
|
-
|
|
6373
|
-
// src/query/QueryMetaType.ts
|
|
6374
6441
|
var QueryMetaType = class extends Query {
|
|
6375
6442
|
/**
|
|
6376
6443
|
* Create new QueryMetaType instance
|
|
@@ -6378,7 +6445,7 @@ var QueryMetaType = class extends Query {
|
|
|
6378
6445
|
*/
|
|
6379
6446
|
constructor(graphQLClient, knishIOClient) {
|
|
6380
6447
|
super(graphQLClient, knishIOClient);
|
|
6381
|
-
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 ) {
|
|
6448
|
+
this.$__query = core.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 ) {
|
|
6382
6449
|
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 ) {
|
|
6383
6450
|
metaType,
|
|
6384
6451
|
instanceCount {
|
|
@@ -6475,7 +6542,7 @@ var QueryBatch = class _QueryBatch extends Query {
|
|
|
6475
6542
|
*/
|
|
6476
6543
|
constructor(graphQLClient, knishIOClient) {
|
|
6477
6544
|
super(graphQLClient, knishIOClient);
|
|
6478
|
-
this.$__query = `query( $batchId: String ) {
|
|
6545
|
+
this.$__query = core.gql`query( $batchId: String ) {
|
|
6479
6546
|
Batch( batchId: $batchId ) {
|
|
6480
6547
|
${_QueryBatch.getFields()},
|
|
6481
6548
|
children {
|
|
@@ -6648,8 +6715,6 @@ var ResponseAtom = class extends exports.Response {
|
|
|
6648
6715
|
return metas;
|
|
6649
6716
|
}
|
|
6650
6717
|
};
|
|
6651
|
-
|
|
6652
|
-
// src/query/QueryAtom.ts
|
|
6653
6718
|
var QueryAtom = class extends Query {
|
|
6654
6719
|
/**
|
|
6655
6720
|
* Create new QueryAtom instance
|
|
@@ -6657,7 +6722,7 @@ var QueryAtom = class extends Query {
|
|
|
6657
6722
|
*/
|
|
6658
6723
|
constructor(graphQLClient, knishIOClient) {
|
|
6659
6724
|
super(graphQLClient, knishIOClient);
|
|
6660
|
-
this.$__query = `query(
|
|
6725
|
+
this.$__query = core.gql`query(
|
|
6661
6726
|
$molecularHashes: [String!],
|
|
6662
6727
|
$bundleHashes: [String!],
|
|
6663
6728
|
$positions:[String!],
|
|
@@ -7163,8 +7228,6 @@ var ResponseMetaTypeViaAtom = class extends exports.Response {
|
|
|
7163
7228
|
return response;
|
|
7164
7229
|
}
|
|
7165
7230
|
};
|
|
7166
|
-
|
|
7167
|
-
// src/query/QueryMetaTypeViaAtom.ts
|
|
7168
7231
|
var QueryMetaTypeViaAtom = class extends Query {
|
|
7169
7232
|
/**
|
|
7170
7233
|
* Create new QueryMetaTypeViaAtom instance
|
|
@@ -7172,7 +7235,7 @@ var QueryMetaTypeViaAtom = class extends Query {
|
|
|
7172
7235
|
*/
|
|
7173
7236
|
constructor(graphQLClient, knishIOClient) {
|
|
7174
7237
|
super(graphQLClient, knishIOClient);
|
|
7175
|
-
this.$__query = `query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
7238
|
+
this.$__query = core.gql`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
7176
7239
|
MetaTypeViaAtom(
|
|
7177
7240
|
metaTypes: $metaTypes
|
|
7178
7241
|
metaIds: $metaIds
|
|
@@ -7284,7 +7347,6 @@ init_Response();
|
|
|
7284
7347
|
init_Dot();
|
|
7285
7348
|
var ResponseProposeMolecule = class extends exports.Response {
|
|
7286
7349
|
$__clientMolecule;
|
|
7287
|
-
$__payload = null;
|
|
7288
7350
|
/**
|
|
7289
7351
|
* Class constructor
|
|
7290
7352
|
*/
|
|
@@ -7363,8 +7425,6 @@ var ResponseProposeMolecule = class extends exports.Response {
|
|
|
7363
7425
|
return this.$__payload;
|
|
7364
7426
|
}
|
|
7365
7427
|
};
|
|
7366
|
-
|
|
7367
|
-
// src/mutation/MutationProposeMolecule.ts
|
|
7368
7428
|
var MutationProposeMolecule = class extends Mutation {
|
|
7369
7429
|
$__molecule;
|
|
7370
7430
|
$__remainderWallet = null;
|
|
@@ -7375,7 +7435,7 @@ var MutationProposeMolecule = class extends Mutation {
|
|
|
7375
7435
|
super(graphQLClient, knishIOClient);
|
|
7376
7436
|
this.$__molecule = molecule;
|
|
7377
7437
|
this.$__remainderWallet = null;
|
|
7378
|
-
this.$__query = `
|
|
7438
|
+
this.$__query = core.gql`
|
|
7379
7439
|
mutation($molecule: MoleculeInput!) {
|
|
7380
7440
|
ProposeMolecule(molecule: $molecule) {
|
|
7381
7441
|
molecularHash,
|
|
@@ -8361,6 +8421,9 @@ var KnishIOClient = class {
|
|
|
8361
8421
|
* Get random uri from specified this.$__uris
|
|
8362
8422
|
*/
|
|
8363
8423
|
getRandomUri() {
|
|
8424
|
+
if (this.$__uris.length === 0) {
|
|
8425
|
+
throw new Error("No URIs configured");
|
|
8426
|
+
}
|
|
8364
8427
|
const rand = Math.floor(Math.random() * this.$__uris.length);
|
|
8365
8428
|
return this.$__uris[rand];
|
|
8366
8429
|
}
|
|
@@ -8521,8 +8584,8 @@ var KnishIOClient = class {
|
|
|
8521
8584
|
molecule = null
|
|
8522
8585
|
}) {
|
|
8523
8586
|
this.log("info", `KnishIOClient::createMoleculeMutation() - Creating a new ${mutationClass.name} query...`);
|
|
8524
|
-
molecule || await this.createMolecule({});
|
|
8525
|
-
const mutation = new mutationClass(this.client(), this);
|
|
8587
|
+
const _molecule = molecule || await this.createMolecule({});
|
|
8588
|
+
const mutation = new mutationClass(this.client(), this, _molecule);
|
|
8526
8589
|
if (!(mutation instanceof Mutation)) {
|
|
8527
8590
|
throw new CodeException(`${this.constructor.name}::createMoleculeMutation() - This method only accepts Mutation subclasses!`);
|
|
8528
8591
|
}
|
|
@@ -8571,68 +8634,74 @@ var KnishIOClient = class {
|
|
|
8571
8634
|
}
|
|
8572
8635
|
/**
|
|
8573
8636
|
* Transfer tokens between wallets
|
|
8574
|
-
*
|
|
8637
|
+
* Matches JavaScript SDK transferToken implementation exactly
|
|
8575
8638
|
*/
|
|
8576
|
-
async transferToken(
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
return {
|
|
8585
|
-
success: false,
|
|
8586
|
-
error: {
|
|
8587
|
-
code: "VALIDATION_ERROR",
|
|
8588
|
-
message: "Invalid transfer parameters",
|
|
8589
|
-
details: validationResult.error.details,
|
|
8590
|
-
context: "transferToken"
|
|
8591
|
-
}
|
|
8592
|
-
};
|
|
8593
|
-
}
|
|
8594
|
-
validationResult.data;
|
|
8595
|
-
let {
|
|
8596
|
-
bundleHash,
|
|
8597
|
-
token,
|
|
8598
|
-
amount = null,
|
|
8599
|
-
units = [],
|
|
8600
|
-
batchId = null,
|
|
8601
|
-
sourceWallet = null
|
|
8602
|
-
} = params;
|
|
8639
|
+
async transferToken({
|
|
8640
|
+
bundleHash,
|
|
8641
|
+
token,
|
|
8642
|
+
amount = null,
|
|
8643
|
+
units = [],
|
|
8644
|
+
batchId = null,
|
|
8645
|
+
sourceWallet = null
|
|
8646
|
+
}) {
|
|
8603
8647
|
if (units.length > 0) {
|
|
8604
|
-
if (amount && amount > 0) {
|
|
8605
|
-
throw new
|
|
8648
|
+
if (amount !== null && amount > 0) {
|
|
8649
|
+
throw new StackableUnitAmountException_default();
|
|
8606
8650
|
}
|
|
8607
8651
|
amount = units.length;
|
|
8608
8652
|
}
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
token,
|
|
8612
|
-
batchId
|
|
8613
|
-
});
|
|
8614
|
-
if (!sourceWallet) {
|
|
8615
|
-
sourceWallet = await this.getSourceWallet();
|
|
8653
|
+
if (amount === null) {
|
|
8654
|
+
amount = 0;
|
|
8616
8655
|
}
|
|
8617
|
-
if (
|
|
8656
|
+
if (sourceWallet === null) {
|
|
8657
|
+
sourceWallet = await this.querySourceWallet({
|
|
8658
|
+
token,
|
|
8659
|
+
amount
|
|
8660
|
+
});
|
|
8661
|
+
}
|
|
8662
|
+
if (sourceWallet === null || Decimal.cmp(sourceWallet.balance, amount) < 0) {
|
|
8618
8663
|
throw new exports.TransferBalanceException();
|
|
8619
8664
|
}
|
|
8665
|
+
const recipientWallet = Wallet.create({
|
|
8666
|
+
bundle: bundleHash,
|
|
8667
|
+
token
|
|
8668
|
+
});
|
|
8669
|
+
if (batchId !== null) {
|
|
8670
|
+
recipientWallet.batchId = batchId;
|
|
8671
|
+
} else {
|
|
8672
|
+
recipientWallet.initBatchId({
|
|
8673
|
+
sourceWallet
|
|
8674
|
+
});
|
|
8675
|
+
}
|
|
8620
8676
|
const remainderWallet = sourceWallet.createRemainder(this.getSecret());
|
|
8621
|
-
|
|
8677
|
+
sourceWallet.splitUnits(
|
|
8678
|
+
units,
|
|
8679
|
+
remainderWallet,
|
|
8680
|
+
recipientWallet
|
|
8681
|
+
);
|
|
8682
|
+
const molecule = await this.createMolecule({
|
|
8622
8683
|
sourceWallet,
|
|
8623
8684
|
remainderWallet
|
|
8624
8685
|
});
|
|
8625
|
-
|
|
8686
|
+
const query = await this.createMoleculeMutation({
|
|
8687
|
+
mutationClass: MutationTransferTokens,
|
|
8688
|
+
molecule
|
|
8689
|
+
});
|
|
8690
|
+
query.fillMolecule({
|
|
8691
|
+
recipientWallet,
|
|
8692
|
+
amount
|
|
8693
|
+
});
|
|
8694
|
+
return await this.executeQuery(query);
|
|
8626
8695
|
}
|
|
8627
8696
|
/**
|
|
8628
8697
|
* Request authorization token
|
|
8629
8698
|
*/
|
|
8630
8699
|
async requestAuthToken({
|
|
8631
|
-
secret = null,
|
|
8632
|
-
seed = null,
|
|
8633
|
-
cellSlug = null,
|
|
8634
|
-
encrypt = false
|
|
8635
|
-
}) {
|
|
8700
|
+
secret: _secret = null,
|
|
8701
|
+
seed: _seed = null,
|
|
8702
|
+
cellSlug: _cellSlug = null,
|
|
8703
|
+
encrypt: _encrypt = false
|
|
8704
|
+
} = {}) {
|
|
8636
8705
|
if (this.$__serverSdkVersion < 3) {
|
|
8637
8706
|
this.log("warn", "KnishIOClient::authorize() - Server SDK version does not require an authorization...");
|
|
8638
8707
|
return null;
|
|
@@ -8734,7 +8803,8 @@ var KnishIOClient = class {
|
|
|
8734
8803
|
type
|
|
8735
8804
|
});
|
|
8736
8805
|
const sourceWallet = response.payload();
|
|
8737
|
-
|
|
8806
|
+
const amountNum = typeof amount === "string" ? Number(amount) : amount;
|
|
8807
|
+
if (sourceWallet === null || Decimal.cmp(sourceWallet.balance || 0, amountNum) < 0) {
|
|
8738
8808
|
throw new exports.TransferBalanceException();
|
|
8739
8809
|
}
|
|
8740
8810
|
if (!sourceWallet.position || !sourceWallet.address) {
|
|
@@ -8764,7 +8834,7 @@ var KnishIOClient = class {
|
|
|
8764
8834
|
*/
|
|
8765
8835
|
async queryBundle({
|
|
8766
8836
|
bundle = null,
|
|
8767
|
-
fields = null,
|
|
8837
|
+
fields: _fields = null,
|
|
8768
8838
|
raw = false
|
|
8769
8839
|
} = {}) {
|
|
8770
8840
|
this.log("info", `KnishIOClient::queryBundle() - Querying wallet bundle metadata${bundle ? ` for ${bundle}` : ""}...`);
|
|
@@ -8798,7 +8868,7 @@ var KnishIOClient = class {
|
|
|
8798
8868
|
key = null,
|
|
8799
8869
|
value = null,
|
|
8800
8870
|
latest = null,
|
|
8801
|
-
fields = null,
|
|
8871
|
+
fields: _fields = null,
|
|
8802
8872
|
filter = null,
|
|
8803
8873
|
queryArgs = null,
|
|
8804
8874
|
count = null,
|
|
@@ -9104,21 +9174,22 @@ var KnishIOClient = class {
|
|
|
9104
9174
|
amount = null,
|
|
9105
9175
|
meta = null,
|
|
9106
9176
|
batchId = null,
|
|
9107
|
-
units = null
|
|
9177
|
+
units: _units = null
|
|
9108
9178
|
}) {
|
|
9109
9179
|
this.log("info", `KnishIOClient::createToken() - Creating token ${token}...`);
|
|
9110
|
-
const mutation = this.
|
|
9111
|
-
const
|
|
9112
|
-
|
|
9113
|
-
|
|
9180
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateToken });
|
|
9181
|
+
const recipientWallet = new Wallet({
|
|
9182
|
+
secret: this.getSecret(),
|
|
9183
|
+
bundle: this.getBundle(),
|
|
9114
9184
|
token: token.toUpperCase(),
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9185
|
+
batchId
|
|
9186
|
+
});
|
|
9187
|
+
await mutation.fillMolecule({
|
|
9188
|
+
recipientWallet,
|
|
9189
|
+
amount: amount ?? 0,
|
|
9190
|
+
meta
|
|
9119
9191
|
});
|
|
9120
|
-
const
|
|
9121
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9192
|
+
const response = await this.executeQuery(mutation);
|
|
9122
9193
|
if (!response) {
|
|
9123
9194
|
throw new CodeException("Token creation failed");
|
|
9124
9195
|
}
|
|
@@ -9131,24 +9202,21 @@ var KnishIOClient = class {
|
|
|
9131
9202
|
token,
|
|
9132
9203
|
to = null,
|
|
9133
9204
|
amount = null,
|
|
9134
|
-
units = null,
|
|
9205
|
+
units: _units = null,
|
|
9135
9206
|
meta = null,
|
|
9136
9207
|
batchId = null
|
|
9137
9208
|
}) {
|
|
9138
9209
|
this.log("info", `KnishIOClient::requestTokens() - Requesting ${amount || "units"} of ${token}...`);
|
|
9139
|
-
const mutation = this.
|
|
9140
|
-
const sourceWallet = await this.getSourceWallet();
|
|
9210
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationRequestTokens });
|
|
9141
9211
|
await mutation.fillMolecule({
|
|
9142
|
-
sourceWallet,
|
|
9143
9212
|
token: token.toUpperCase(),
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
|
|
9213
|
+
amount: amount ?? 0,
|
|
9214
|
+
metaType: to || "",
|
|
9215
|
+
metaId: to || "",
|
|
9147
9216
|
meta,
|
|
9148
9217
|
batchId
|
|
9149
9218
|
});
|
|
9150
|
-
const
|
|
9151
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9219
|
+
const response = await this.executeQuery(mutation);
|
|
9152
9220
|
if (!response) {
|
|
9153
9221
|
throw new CodeException("Token request failed");
|
|
9154
9222
|
}
|
|
@@ -9160,7 +9228,7 @@ var KnishIOClient = class {
|
|
|
9160
9228
|
async burnTokens({
|
|
9161
9229
|
token,
|
|
9162
9230
|
amount = null,
|
|
9163
|
-
units = null,
|
|
9231
|
+
units: _units = null,
|
|
9164
9232
|
sourceWallet = null
|
|
9165
9233
|
}) {
|
|
9166
9234
|
this.log("info", `KnishIOClient::burnTokens() - Burning ${amount || "units"} of ${token}...`);
|
|
@@ -9170,17 +9238,17 @@ var KnishIOClient = class {
|
|
|
9170
9238
|
amount: amount || 0
|
|
9171
9239
|
});
|
|
9172
9240
|
}
|
|
9173
|
-
const mutation = this.
|
|
9241
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationTransferTokens });
|
|
9242
|
+
const recipientWallet = new Wallet({
|
|
9243
|
+
secret: this.getSecret(),
|
|
9244
|
+
bundle: "0000000000000000000000000000000000000000000000000000000000000000",
|
|
9245
|
+
token: token.toUpperCase()
|
|
9246
|
+
});
|
|
9174
9247
|
await mutation.fillMolecule({
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
// Burn address
|
|
9178
|
-
token: token.toUpperCase(),
|
|
9179
|
-
amount,
|
|
9180
|
-
units
|
|
9248
|
+
recipientWallet,
|
|
9249
|
+
amount: amount ?? 0
|
|
9181
9250
|
});
|
|
9182
|
-
const
|
|
9183
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9251
|
+
const response = await this.executeQuery(mutation);
|
|
9184
9252
|
if (!response) {
|
|
9185
9253
|
throw new CodeException("Token burn failed");
|
|
9186
9254
|
}
|
|
@@ -9193,7 +9261,7 @@ var KnishIOClient = class {
|
|
|
9193
9261
|
token,
|
|
9194
9262
|
amount = null,
|
|
9195
9263
|
units = null,
|
|
9196
|
-
sourceWallet = null
|
|
9264
|
+
sourceWallet: _sourceWallet = null
|
|
9197
9265
|
}) {
|
|
9198
9266
|
this.log("info", `KnishIOClient::replenishToken() - Replenishing ${amount || "units"} of ${token}...`);
|
|
9199
9267
|
return this.requestTokens({
|
|
@@ -9206,11 +9274,11 @@ var KnishIOClient = class {
|
|
|
9206
9274
|
* Fuse token units
|
|
9207
9275
|
*/
|
|
9208
9276
|
async fuseToken({
|
|
9209
|
-
bundleHash,
|
|
9277
|
+
bundleHash: _bundleHash,
|
|
9210
9278
|
tokenSlug,
|
|
9211
|
-
newTokenUnit,
|
|
9212
|
-
fusedTokenUnitIds,
|
|
9213
|
-
sourceWallet = null
|
|
9279
|
+
newTokenUnit: _newTokenUnit,
|
|
9280
|
+
fusedTokenUnitIds: _fusedTokenUnitIds,
|
|
9281
|
+
sourceWallet: _sourceWallet = null
|
|
9214
9282
|
}) {
|
|
9215
9283
|
this.log("info", `KnishIOClient::fuseToken() - Fusing token units for ${tokenSlug}...`);
|
|
9216
9284
|
throw new CodeException("Token fusion not yet implemented");
|
|
@@ -9225,14 +9293,14 @@ var KnishIOClient = class {
|
|
|
9225
9293
|
token
|
|
9226
9294
|
}) {
|
|
9227
9295
|
this.log("info", `KnishIOClient::createWallet() - Creating wallet for token ${token}...`);
|
|
9228
|
-
const mutation = this.
|
|
9229
|
-
const
|
|
9230
|
-
|
|
9231
|
-
|
|
9296
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateWallet });
|
|
9297
|
+
const newWallet = new Wallet({
|
|
9298
|
+
secret: this.getSecret(),
|
|
9299
|
+
bundle: this.getBundle(),
|
|
9232
9300
|
token: token.toUpperCase()
|
|
9233
9301
|
});
|
|
9234
|
-
|
|
9235
|
-
const response = await this.executeQuery(
|
|
9302
|
+
await mutation.fillMolecule(newWallet);
|
|
9303
|
+
const response = await this.executeQuery(mutation);
|
|
9236
9304
|
if (!response) {
|
|
9237
9305
|
throw new CodeException("Wallet creation failed");
|
|
9238
9306
|
}
|
|
@@ -9244,7 +9312,7 @@ var KnishIOClient = class {
|
|
|
9244
9312
|
async claimShadowWallet({
|
|
9245
9313
|
token,
|
|
9246
9314
|
batchId = null,
|
|
9247
|
-
molecule = null
|
|
9315
|
+
molecule: _molecule = null
|
|
9248
9316
|
}) {
|
|
9249
9317
|
this.log("info", `KnishIOClient::claimShadowWallet() - Claiming shadow wallet for token ${token}...`);
|
|
9250
9318
|
const shadowWallets = await this.queryWallets({ token });
|
|
@@ -9258,15 +9326,12 @@ var KnishIOClient = class {
|
|
|
9258
9326
|
if (!shadowWallet.isShadow()) {
|
|
9259
9327
|
throw new WalletShadowException_default("Wallet is not a shadow wallet");
|
|
9260
9328
|
}
|
|
9261
|
-
const mutation = this.
|
|
9262
|
-
const sourceWallet = await this.getSourceWallet();
|
|
9329
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationClaimShadowWallet });
|
|
9263
9330
|
await mutation.fillMolecule({
|
|
9264
|
-
sourceWallet,
|
|
9265
9331
|
token: token.toUpperCase(),
|
|
9266
9332
|
batchId: shadowWallet.batchId
|
|
9267
9333
|
});
|
|
9268
|
-
const
|
|
9269
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9334
|
+
const response = await this.executeQuery(mutation);
|
|
9270
9335
|
if (!response) {
|
|
9271
9336
|
throw new CodeException("Shadow wallet claim failed");
|
|
9272
9337
|
}
|
|
@@ -9311,17 +9376,14 @@ var KnishIOClient = class {
|
|
|
9311
9376
|
policy = null
|
|
9312
9377
|
}) {
|
|
9313
9378
|
this.log("info", `KnishIOClient::createMeta() - Creating metadata for ${metaType}:${metaId}...`);
|
|
9314
|
-
const mutation = this.
|
|
9315
|
-
const sourceWallet = await this.getSourceWallet();
|
|
9379
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateMeta });
|
|
9316
9380
|
await mutation.fillMolecule({
|
|
9317
|
-
sourceWallet,
|
|
9318
9381
|
metaType: metaType.toUpperCase(),
|
|
9319
9382
|
metaId,
|
|
9320
9383
|
meta,
|
|
9321
9384
|
policy
|
|
9322
9385
|
});
|
|
9323
|
-
const
|
|
9324
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9386
|
+
const response = await this.executeQuery(mutation);
|
|
9325
9387
|
if (!response) {
|
|
9326
9388
|
throw new CodeException("Metadata creation failed");
|
|
9327
9389
|
}
|
|
@@ -9337,17 +9399,14 @@ var KnishIOClient = class {
|
|
|
9337
9399
|
policy = null
|
|
9338
9400
|
}) {
|
|
9339
9401
|
this.log("info", `KnishIOClient::createRule() - Creating rule for ${metaType}:${metaId}...`);
|
|
9340
|
-
const mutation = this.
|
|
9341
|
-
const sourceWallet = await this.getSourceWallet();
|
|
9402
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateRule });
|
|
9342
9403
|
await mutation.fillMolecule({
|
|
9343
|
-
sourceWallet,
|
|
9344
9404
|
metaType: metaType.toUpperCase(),
|
|
9345
9405
|
metaId,
|
|
9346
9406
|
rule,
|
|
9347
9407
|
policy
|
|
9348
9408
|
});
|
|
9349
|
-
const
|
|
9350
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9409
|
+
const response = await this.executeQuery(mutation);
|
|
9351
9410
|
if (!response) {
|
|
9352
9411
|
throw new CodeException("Rule creation failed");
|
|
9353
9412
|
}
|
|
@@ -9378,16 +9437,13 @@ var KnishIOClient = class {
|
|
|
9378
9437
|
code
|
|
9379
9438
|
}) {
|
|
9380
9439
|
this.log("info", `KnishIOClient::createIdentifier() - Creating identifier of type ${type}...`);
|
|
9381
|
-
const mutation = this.
|
|
9382
|
-
const sourceWallet = await this.getSourceWallet();
|
|
9440
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateIdentifier });
|
|
9383
9441
|
await mutation.fillMolecule({
|
|
9384
|
-
sourceWallet,
|
|
9385
9442
|
type,
|
|
9386
9443
|
contact,
|
|
9387
9444
|
code
|
|
9388
9445
|
});
|
|
9389
|
-
const
|
|
9390
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9446
|
+
const response = await this.executeQuery(mutation);
|
|
9391
9447
|
if (!response) {
|
|
9392
9448
|
throw new CodeException("Identifier creation failed");
|
|
9393
9449
|
}
|
|
@@ -9402,14 +9458,11 @@ var KnishIOClient = class {
|
|
|
9402
9458
|
}) {
|
|
9403
9459
|
this.log("info", `KnishIOClient::linkIdentifier() - Linking identifier of type ${type}...`);
|
|
9404
9460
|
const mutation = this.createQuery(MutationLinkIdentifier);
|
|
9405
|
-
const
|
|
9406
|
-
|
|
9407
|
-
sourceWallet,
|
|
9461
|
+
const response = await this.executeQuery(mutation, {
|
|
9462
|
+
bundle: this.getBundle(),
|
|
9408
9463
|
type,
|
|
9409
|
-
contact
|
|
9464
|
+
content: contact
|
|
9410
9465
|
});
|
|
9411
|
-
const moleculeMutation = await this.createMoleculeMutation({ mutationClass: mutation });
|
|
9412
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9413
9466
|
if (!response) {
|
|
9414
9467
|
throw new CodeException("Identifier linking failed");
|
|
9415
9468
|
}
|
|
@@ -9434,10 +9487,8 @@ var KnishIOClient = class {
|
|
|
9434
9487
|
}) {
|
|
9435
9488
|
this.log("info", `KnishIOClient::activeSession() - Declaring active session for ${metaType}:${metaId}...`);
|
|
9436
9489
|
const mutation = this.createQuery(MutationActiveSession);
|
|
9437
|
-
const
|
|
9438
|
-
|
|
9439
|
-
sourceWallet,
|
|
9440
|
-
bundle,
|
|
9490
|
+
const response = await this.executeQuery(mutation, {
|
|
9491
|
+
bundle: bundle || this.getBundle(),
|
|
9441
9492
|
metaType: metaType.toUpperCase(),
|
|
9442
9493
|
metaId,
|
|
9443
9494
|
ipAddress,
|
|
@@ -9447,8 +9498,6 @@ var KnishIOClient = class {
|
|
|
9447
9498
|
timeZone,
|
|
9448
9499
|
json
|
|
9449
9500
|
});
|
|
9450
|
-
const moleculeMutation = await this.createMoleculeMutation({ mutationClass: mutation });
|
|
9451
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9452
9501
|
if (!response) {
|
|
9453
9502
|
throw new CodeException("Active session declaration failed");
|
|
9454
9503
|
}
|
|
@@ -9470,15 +9519,12 @@ var KnishIOClient = class {
|
|
|
9470
9519
|
amount
|
|
9471
9520
|
});
|
|
9472
9521
|
}
|
|
9473
|
-
const mutation = this.
|
|
9522
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationDepositBufferToken });
|
|
9474
9523
|
await mutation.fillMolecule({
|
|
9475
|
-
|
|
9476
|
-
tokenSlug: tokenSlug.toUpperCase(),
|
|
9477
|
-
amount,
|
|
9524
|
+
amount: typeof amount === "string" ? Number(amount) : amount,
|
|
9478
9525
|
tradeRates
|
|
9479
9526
|
});
|
|
9480
|
-
const
|
|
9481
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9527
|
+
const response = await this.executeQuery(mutation);
|
|
9482
9528
|
if (!response) {
|
|
9483
9529
|
throw new CodeException("Buffer token deposit failed");
|
|
9484
9530
|
}
|
|
@@ -9497,15 +9543,15 @@ var KnishIOClient = class {
|
|
|
9497
9543
|
if (!sourceWallet) {
|
|
9498
9544
|
sourceWallet = await this.getSourceWallet();
|
|
9499
9545
|
}
|
|
9500
|
-
const mutation = this.
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
signingWallet
|
|
9506
|
-
}
|
|
9507
|
-
|
|
9508
|
-
const response = await this.executeQuery(
|
|
9546
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationWithdrawBufferToken });
|
|
9547
|
+
const recipients = {};
|
|
9548
|
+
recipients[this.getBundle()] = amount;
|
|
9549
|
+
const fillMoleculeParams = { recipients };
|
|
9550
|
+
if (signingWallet) {
|
|
9551
|
+
fillMoleculeParams.signingWallet = signingWallet;
|
|
9552
|
+
}
|
|
9553
|
+
await mutation.fillMolecule(fillMoleculeParams);
|
|
9554
|
+
const response = await this.executeQuery(mutation);
|
|
9509
9555
|
if (!response) {
|
|
9510
9556
|
throw new CodeException("Buffer token withdrawal failed");
|
|
9511
9557
|
}
|
|
@@ -9523,11 +9569,9 @@ var KnishIOClient = class {
|
|
|
9523
9569
|
} = {}) {
|
|
9524
9570
|
this.log("info", "KnishIOClient::requestGuestAuthToken() - Requesting guest auth token...");
|
|
9525
9571
|
const mutation = this.createQuery(MutationRequestAuthorizationGuest);
|
|
9526
|
-
await
|
|
9572
|
+
const response = await this.executeQuery(mutation, {
|
|
9527
9573
|
cellSlug: cellSlug || this.getCellSlug()
|
|
9528
9574
|
});
|
|
9529
|
-
const moleculeMutation = await this.createMoleculeMutation({ mutationClass: mutation });
|
|
9530
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9531
9575
|
if (!response) {
|
|
9532
9576
|
throw new CodeException("Guest auth token request failed");
|
|
9533
9577
|
}
|
|
@@ -9545,14 +9589,11 @@ var KnishIOClient = class {
|
|
|
9545
9589
|
}) {
|
|
9546
9590
|
this.log("info", "KnishIOClient::requestProfileAuthToken() - Requesting profile auth token...");
|
|
9547
9591
|
this.setSecret(secret);
|
|
9548
|
-
const mutation = this.
|
|
9549
|
-
const sourceWallet = await this.getSourceWallet();
|
|
9592
|
+
const mutation = await this.createMoleculeMutation({ mutationClass: MutationRequestAuthorization });
|
|
9550
9593
|
await mutation.fillMolecule({
|
|
9551
|
-
|
|
9552
|
-
cellSlug: this.getCellSlug()
|
|
9594
|
+
meta: { encrypt: encrypt ? "true" : "false" }
|
|
9553
9595
|
});
|
|
9554
|
-
const
|
|
9555
|
-
const response = await this.executeQuery(moleculeMutation);
|
|
9596
|
+
const response = await this.executeQuery(mutation);
|
|
9556
9597
|
if (!response) {
|
|
9557
9598
|
throw new CodeException("Profile auth token request failed");
|
|
9558
9599
|
}
|