@wishknish/knishio-client-ts 0.8.2 → 0.9.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/dist/index.cjs +425 -263
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -17
- package/dist/index.d.ts +44 -17
- package/dist/index.iife.js +425 -265
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +447 -285
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/src/KnishIOClient.ts +180 -57
- package/src/constants.ts +1 -2
- package/src/core/Molecule.ts +53 -0
- package/src/core/Wallet.ts +84 -3
- package/src/libraries/Decimal.ts +1 -1
- package/src/libraries/GraphQLClient.ts +83 -0
- package/src/libraries/Hex.ts +4 -3
- package/src/libraries/UrqlClientWrapper.ts +13 -13
- package/src/libraries/crypto.ts +4 -4
- package/src/mutation/MutationClaimShadowWallet.ts +3 -1
- package/src/mutation/MutationTransferTokens.ts +18 -0
- package/src/query/QueryActiveSession.ts +0 -1
- package/src/query/QueryPolicy.ts +0 -1
- package/src/response/ResponseAuthorizationGuest.ts +2 -2
- package/src/response/ResponseBalance.ts +9 -6
- package/src/response/ResponseLinkIdentifier.ts +1 -1
- package/src/response/ResponseRequestAuthorizationGuest.ts +2 -2
- package/src/schemas/index.ts +2 -1
- package/src/subscribe/Subscribe.ts +3 -2
- package/src/types/assertions.ts +1 -6
- package/src/types/client.ts +12 -19
- package/src/types/guards.ts +2 -3
- package/src/types/index.ts +6 -0
- package/src/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts +3 -5
- package/src/validation/ValidationService.ts +6 -15
- package/src/validation/schemas.ts +5 -1
- package/src/versions/HashAtom.ts +11 -9
- package/src/query/QueryUserActivity.ts +0 -153
- package/src/response/ResponseQueryUserActivity.ts +0 -89
package/dist/index.cjs
CHANGED
|
@@ -945,9 +945,19 @@ var init_StackableUnitAmountException = __esm({
|
|
|
945
945
|
});
|
|
946
946
|
|
|
947
947
|
// src/exception/StackableUnitDecimalsException.ts
|
|
948
|
+
var StackableUnitDecimalsException, StackableUnitDecimalsException_default;
|
|
948
949
|
var init_StackableUnitDecimalsException = __esm({
|
|
949
950
|
"src/exception/StackableUnitDecimalsException.ts"() {
|
|
950
951
|
init_BaseException();
|
|
952
|
+
StackableUnitDecimalsException = class extends exports.BaseException {
|
|
953
|
+
/**
|
|
954
|
+
* Constructor using proper error type
|
|
955
|
+
*/
|
|
956
|
+
constructor(message = "Stackable tokens with unit IDs cannot have decimal places!") {
|
|
957
|
+
super("STACKABLE_UNIT_DECIMALS_ERROR", message);
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
StackableUnitDecimalsException_default = StackableUnitDecimalsException;
|
|
951
961
|
}
|
|
952
962
|
});
|
|
953
963
|
|
|
@@ -1929,9 +1939,6 @@ function generateSecret(seed = null, length = CRYPTO_CONSTANTS.SECRET_LENGTH) {
|
|
|
1929
1939
|
}
|
|
1930
1940
|
}
|
|
1931
1941
|
function generateBundleHash(secret, _source = null) {
|
|
1932
|
-
if (!secret || secret.length === 0) {
|
|
1933
|
-
throw new Error("Secret is required for bundle hash generation");
|
|
1934
|
-
}
|
|
1935
1942
|
const hash = shake256(secret, CRYPTO_CONSTANTS.BUNDLE_HASH_LENGTH * 4);
|
|
1936
1943
|
return hash;
|
|
1937
1944
|
}
|
|
@@ -3342,8 +3349,7 @@ var QUERY_TYPES = [
|
|
|
3342
3349
|
"Batch",
|
|
3343
3350
|
"ActiveSession",
|
|
3344
3351
|
"Policy",
|
|
3345
|
-
"Token"
|
|
3346
|
-
"UserActivity"
|
|
3352
|
+
"Token"
|
|
3347
3353
|
];
|
|
3348
3354
|
function createLookup(values) {
|
|
3349
3355
|
return values.reduce((acc, value) => {
|
|
@@ -3602,6 +3608,29 @@ var Wallet = class _Wallet {
|
|
|
3602
3608
|
}
|
|
3603
3609
|
remainderWallet.tokenUnits = remainderTokenUnits;
|
|
3604
3610
|
}
|
|
3611
|
+
/**
|
|
3612
|
+
* Split token units across MULTIPLE recipients (N-way sibling of splitUnits).
|
|
3613
|
+
*
|
|
3614
|
+
* The source retains the SENT union (all units leaving), each recipient gets its own
|
|
3615
|
+
* subset, and the remainder keeps the KEPT units (those not assigned to any recipient).
|
|
3616
|
+
* recipientUnitLists is parallel to recipientWallets. No-op when no units are sent.
|
|
3617
|
+
*
|
|
3618
|
+
* @param recipientUnitLists - per-recipient arrays of token unit IDs (parallel to recipientWallets)
|
|
3619
|
+
* @param recipientWallets - destination wallets
|
|
3620
|
+
* @param remainderWallet - wallet to receive the KEPT units
|
|
3621
|
+
*/
|
|
3622
|
+
splitUnitsMulti(recipientUnitLists, recipientWallets, remainderWallet) {
|
|
3623
|
+
const sentIds = new Set(recipientUnitLists.flat());
|
|
3624
|
+
if (sentIds.size === 0) {
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
recipientWallets.forEach((recipientWallet, i) => {
|
|
3628
|
+
const ids = recipientUnitLists[i] ?? [];
|
|
3629
|
+
recipientWallet.tokenUnits = this.tokenUnits.filter((tokenUnit) => ids.includes(tokenUnit.id));
|
|
3630
|
+
});
|
|
3631
|
+
remainderWallet.tokenUnits = this.tokenUnits.filter((tokenUnit) => !sentIds.has(tokenUnit.id));
|
|
3632
|
+
this.tokenUnits = this.tokenUnits.filter((tokenUnit) => sentIds.has(tokenUnit.id));
|
|
3633
|
+
}
|
|
3605
3634
|
/**
|
|
3606
3635
|
* Get token units data
|
|
3607
3636
|
* Stub for compatibility
|
|
@@ -3648,6 +3677,15 @@ var Wallet = class _Wallet {
|
|
|
3648
3677
|
};
|
|
3649
3678
|
}
|
|
3650
3679
|
async decryptMessage(encryptedData) {
|
|
3680
|
+
const decryptedString = await this._mlkemDecryptToString(encryptedData);
|
|
3681
|
+
return decryptedString === null ? null : JSON.parse(decryptedString);
|
|
3682
|
+
}
|
|
3683
|
+
/**
|
|
3684
|
+
* ML-KEM768 decapsulate + AES-256-GCM decrypt → the RAW decrypted UTF-8 string (no JSON.parse).
|
|
3685
|
+
* Shared by {@link decryptMessage} (which JSON.parses the result) and the PQ CipherHash transport
|
|
3686
|
+
* ({@link decryptMyMessageML768}, which needs the raw response JSON text). PQ-transport Phase E.
|
|
3687
|
+
*/
|
|
3688
|
+
async _mlkemDecryptToString(encryptedData) {
|
|
3651
3689
|
const { cipherText, encryptedMessage } = encryptedData;
|
|
3652
3690
|
let sharedSecret;
|
|
3653
3691
|
try {
|
|
@@ -3676,9 +3714,8 @@ var Wallet = class _Wallet {
|
|
|
3676
3714
|
console.info("Wallet::decryptMessage() - deserialized encrypted message", deserializedEncryptedMessage);
|
|
3677
3715
|
return null;
|
|
3678
3716
|
}
|
|
3679
|
-
let decryptedString;
|
|
3680
3717
|
try {
|
|
3681
|
-
|
|
3718
|
+
return new TextDecoder().decode(decryptedUint8);
|
|
3682
3719
|
} catch (e) {
|
|
3683
3720
|
console.warn("Wallet::decryptMessage() - Decoding failed", e);
|
|
3684
3721
|
console.info("Wallet::decryptMessage() - my public key", this.pubkey);
|
|
@@ -3687,7 +3724,40 @@ var Wallet = class _Wallet {
|
|
|
3687
3724
|
console.info("Wallet::decryptMessage() - decrypted Uint8Array", decryptedUint8);
|
|
3688
3725
|
return null;
|
|
3689
3726
|
}
|
|
3690
|
-
|
|
3727
|
+
}
|
|
3728
|
+
/**
|
|
3729
|
+
* Canonical cross-SDK hashShare for a public key: standard base64 of SHAKE256(pubkey_utf8, 8 bytes)
|
|
3730
|
+
* — byte-matches the validator's hash_share and the JS/Kotlin/PHP hashShare. `shake256(pubkey, 64)`
|
|
3731
|
+
* = 64 bits = 8 bytes (hex) → hex-decode → standard base64 via serializeKey. PQ-transport Phase E.
|
|
3732
|
+
*/
|
|
3733
|
+
hashShare(pubkey) {
|
|
3734
|
+
const hex = shake256(pubkey, 64);
|
|
3735
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
3736
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
3737
|
+
bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
|
|
3738
|
+
}
|
|
3739
|
+
return this.serializeKey(bytes);
|
|
3740
|
+
}
|
|
3741
|
+
/**
|
|
3742
|
+
* Post-quantum (ML-KEM768) CipherHash request envelope: a stringified single-recipient map
|
|
3743
|
+
* `{ "<hashShare(recipientPubkey)>": {cipherText, encryptedMessage} }` (object-valued, via
|
|
3744
|
+
* {@link encryptMessage}). Matches the Rust validator's CipherHash handler. PQ-transport Phase E.
|
|
3745
|
+
*/
|
|
3746
|
+
async encryptStringML768(message, recipientPubkey) {
|
|
3747
|
+
const envelope = await this.encryptMessage(message, recipientPubkey);
|
|
3748
|
+
return JSON.stringify({ [this.hashShare(recipientPubkey)]: envelope });
|
|
3749
|
+
}
|
|
3750
|
+
/**
|
|
3751
|
+
* Decrypt a CipherHash response map addressed to THIS wallet's ML-KEM pubkey
|
|
3752
|
+
* (`hashShare(this.pubkey)`) → the RAW decrypted GraphQL response JSON text (NOT JSON.parsed;
|
|
3753
|
+
* it replaces the HTTP response body for the normal parser). `null` if no entry / decrypt fails.
|
|
3754
|
+
*/
|
|
3755
|
+
async decryptMyMessageML768(map) {
|
|
3756
|
+
const envelope = map[this.hashShare(this.pubkey)];
|
|
3757
|
+
if (!envelope) {
|
|
3758
|
+
return null;
|
|
3759
|
+
}
|
|
3760
|
+
return this._mlkemDecryptToString(envelope);
|
|
3691
3761
|
}
|
|
3692
3762
|
// =============================================================================
|
|
3693
3763
|
// SYMMETRIC ENCRYPTION HELPERS (AES-GCM with shared secret)
|
|
@@ -3812,7 +3882,8 @@ zod.z.object({
|
|
|
3812
3882
|
client: zod.z.unknown().optional(),
|
|
3813
3883
|
socket: zod.z.unknown().optional(),
|
|
3814
3884
|
serverSdkVersion: zod.z.number().int().min(1).optional(),
|
|
3815
|
-
logging: zod.z.boolean().optional()
|
|
3885
|
+
logging: zod.z.boolean().optional(),
|
|
3886
|
+
defaultRequestPolicy: zod.z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
|
|
3816
3887
|
}).strict();
|
|
3817
3888
|
zod.z.object({
|
|
3818
3889
|
token: zod.z.string().min(1, "Auth token cannot be empty"),
|
|
@@ -4985,6 +5056,46 @@ var Molecule = class _Molecule {
|
|
|
4985
5056
|
}));
|
|
4986
5057
|
return this;
|
|
4987
5058
|
}
|
|
5059
|
+
/**
|
|
5060
|
+
* Initialize a MULTI-recipient V-type molecule: one source debits its FULL balance to fund
|
|
5061
|
+
* N recipients (each its own amount + stackable units) plus a remainder back to the sender.
|
|
5062
|
+
* Multi-recipient sibling of initValue (WP line 544: fund multiple recipients with one
|
|
5063
|
+
* transaction). recipientWallets is parallel to amounts.
|
|
5064
|
+
*/
|
|
5065
|
+
initValues({
|
|
5066
|
+
recipientWallets,
|
|
5067
|
+
amounts
|
|
5068
|
+
}) {
|
|
5069
|
+
if (!this.sourceWallet) {
|
|
5070
|
+
throw new Error("Source wallet required for value transfer");
|
|
5071
|
+
}
|
|
5072
|
+
const total = amounts.reduce((sum, amount) => sum + amount, 0);
|
|
5073
|
+
if (Number(this.sourceWallet.balance) - total < 0) {
|
|
5074
|
+
throw new BalanceInsufficientException();
|
|
5075
|
+
}
|
|
5076
|
+
this.addAtom(Atom.create({
|
|
5077
|
+
isotope: "V",
|
|
5078
|
+
wallet: this.sourceWallet,
|
|
5079
|
+
value: -Number(this.sourceWallet.balance)
|
|
5080
|
+
}));
|
|
5081
|
+
recipientWallets.forEach((recipientWallet, i) => {
|
|
5082
|
+
this.addAtom(Atom.create({
|
|
5083
|
+
isotope: "V",
|
|
5084
|
+
wallet: recipientWallet,
|
|
5085
|
+
value: amounts[i],
|
|
5086
|
+
metaType: "walletBundle",
|
|
5087
|
+
metaId: recipientWallet.bundle
|
|
5088
|
+
}));
|
|
5089
|
+
});
|
|
5090
|
+
this.addAtom(Atom.create({
|
|
5091
|
+
isotope: "V",
|
|
5092
|
+
wallet: this.remainderWallet,
|
|
5093
|
+
value: Number(this.sourceWallet.balance) - total,
|
|
5094
|
+
metaType: "walletBundle",
|
|
5095
|
+
metaId: this.remainderWallet.bundle
|
|
5096
|
+
}));
|
|
5097
|
+
return this;
|
|
5098
|
+
}
|
|
4988
5099
|
/**
|
|
4989
5100
|
* Sign the molecule with one-time signature
|
|
4990
5101
|
* Matches JavaScript SDK sign method
|
|
@@ -5742,7 +5853,7 @@ var Decimal = class _Decimal {
|
|
|
5742
5853
|
* @param debug Enable debug logging
|
|
5743
5854
|
* @returns 0 if equal, 1 if value1 > value2, -1 if value1 < value2
|
|
5744
5855
|
*/
|
|
5745
|
-
static cmp(value1, value2,
|
|
5856
|
+
static cmp(value1, value2, _debug = false) {
|
|
5746
5857
|
const val1 = _Decimal.val(value1) * MULTIPLIER;
|
|
5747
5858
|
const val2 = _Decimal.val(value2) * MULTIPLIER;
|
|
5748
5859
|
if (Math.abs(val1 - val2) < 1) {
|
|
@@ -5757,6 +5868,14 @@ var Decimal = class _Decimal {
|
|
|
5757
5868
|
return _Decimal.cmp(value1, value2) === 0;
|
|
5758
5869
|
}
|
|
5759
5870
|
};
|
|
5871
|
+
var CIPHER_HASH_QUERY = "query ( $Hash: String! ) { CipherHash ( Hash: $Hash ) { hash } }";
|
|
5872
|
+
function parseOperation(query) {
|
|
5873
|
+
const typeMatch = (query || "").match(/\b(query|mutation|subscription)\b/i);
|
|
5874
|
+
const type = typeMatch?.[1]?.toLowerCase() ?? "query";
|
|
5875
|
+
const braceIdx = (query || "").indexOf("{");
|
|
5876
|
+
const nameMatch = braceIdx >= 0 ? query.slice(braceIdx + 1).match(/[A-Za-z_][A-Za-z0-9_]*/) : null;
|
|
5877
|
+
return { type, name: nameMatch?.[0] ?? "" };
|
|
5878
|
+
}
|
|
5760
5879
|
var GraphQLClient = class {
|
|
5761
5880
|
$__client;
|
|
5762
5881
|
$__authToken = "";
|
|
@@ -5802,6 +5921,10 @@ var GraphQLClient = class {
|
|
|
5802
5921
|
return core.createClient({
|
|
5803
5922
|
url: serverUri,
|
|
5804
5923
|
exchanges,
|
|
5924
|
+
// PQ-transport Phase E: when encryption is on, route fetch through the CipherHash wrapper
|
|
5925
|
+
// (encrypt the request body to the validator's ML-KEM pubkey, decrypt the response).
|
|
5926
|
+
// Omitted → urql uses the global fetch (plaintext).
|
|
5927
|
+
...this.cipherLink ? { fetch: ((input, init) => this.cipherFetch(input, init)) } : {},
|
|
5805
5928
|
fetchOptions: () => ({
|
|
5806
5929
|
headers: {
|
|
5807
5930
|
"X-Auth-Token": this.$__authToken
|
|
@@ -5811,6 +5934,62 @@ var GraphQLClient = class {
|
|
|
5811
5934
|
})
|
|
5812
5935
|
});
|
|
5813
5936
|
}
|
|
5937
|
+
/**
|
|
5938
|
+
* Whether an outgoing GraphQL request body should be wrapped in CipherHash. Bypass (plaintext):
|
|
5939
|
+
* introspection `__schema`, `ContinuId`, the `AccessToken` mutation, and the U-isotope
|
|
5940
|
+
* `ProposeMolecule` (auth bootstrap — the key exchange itself can't be encrypted). Mirrors the
|
|
5941
|
+
* Kotlin/PHP/validator bypass set.
|
|
5942
|
+
*/
|
|
5943
|
+
shouldEncrypt(body) {
|
|
5944
|
+
let parsed;
|
|
5945
|
+
try {
|
|
5946
|
+
parsed = JSON.parse(body);
|
|
5947
|
+
} catch (e) {
|
|
5948
|
+
return false;
|
|
5949
|
+
}
|
|
5950
|
+
const { type, name } = parseOperation(parsed.query);
|
|
5951
|
+
if (type === "query" && (name === "__schema" || name === "ContinuId")) return false;
|
|
5952
|
+
if (type === "mutation" && name === "AccessToken") return false;
|
|
5953
|
+
if (type === "mutation" && name === "ProposeMolecule") {
|
|
5954
|
+
const isotope = parsed.variables?.molecule?.atoms?.[0]?.isotope;
|
|
5955
|
+
if (isotope === "U") return false;
|
|
5956
|
+
}
|
|
5957
|
+
return true;
|
|
5958
|
+
}
|
|
5959
|
+
/**
|
|
5960
|
+
* Custom `fetch` that wraps a GraphQL request in the ML-KEM CipherHash envelope and decrypts the
|
|
5961
|
+
* response (PQ-transport Phase E). Operates on the raw POST body (mirrors the JS/Kotlin transform).
|
|
5962
|
+
* Reads the CURRENT client wallet + validator pubkey from auth.
|
|
5963
|
+
*/
|
|
5964
|
+
async cipherFetch(input, init) {
|
|
5965
|
+
const wallet = this.$__wallet;
|
|
5966
|
+
const serverPubkey = this.$__pubkey;
|
|
5967
|
+
let encryptedRequest = false;
|
|
5968
|
+
let requestInit = init;
|
|
5969
|
+
if (wallet && serverPubkey && init && typeof init.body === "string" && this.shouldEncrypt(init.body)) {
|
|
5970
|
+
const hashVar = await wallet.encryptStringML768(init.body, serverPubkey);
|
|
5971
|
+
requestInit = { ...init, body: JSON.stringify({ query: CIPHER_HASH_QUERY, variables: { Hash: hashVar } }) };
|
|
5972
|
+
encryptedRequest = true;
|
|
5973
|
+
}
|
|
5974
|
+
const response = await fetch(input, requestInit);
|
|
5975
|
+
if (!encryptedRequest) {
|
|
5976
|
+
return response;
|
|
5977
|
+
}
|
|
5978
|
+
const text = await response.text();
|
|
5979
|
+
const init2 = { status: response.status, statusText: response.statusText, headers: response.headers };
|
|
5980
|
+
let parsed;
|
|
5981
|
+
try {
|
|
5982
|
+
parsed = JSON.parse(text);
|
|
5983
|
+
} catch (e) {
|
|
5984
|
+
return new Response(text, init2);
|
|
5985
|
+
}
|
|
5986
|
+
const hash = parsed?.data?.CipherHash?.hash;
|
|
5987
|
+
if (typeof hash !== "string") {
|
|
5988
|
+
return new Response(text, init2);
|
|
5989
|
+
}
|
|
5990
|
+
const decrypted = await wallet.decryptMyMessageML768(JSON.parse(hash));
|
|
5991
|
+
return new Response(decrypted != null ? decrypted : text, init2);
|
|
5992
|
+
}
|
|
5814
5993
|
setAuthData({
|
|
5815
5994
|
token,
|
|
5816
5995
|
pubkey,
|
|
@@ -6105,8 +6284,8 @@ var Query = class {
|
|
|
6105
6284
|
* Returns a Response object
|
|
6106
6285
|
*/
|
|
6107
6286
|
createResponse(json) {
|
|
6108
|
-
const
|
|
6109
|
-
return new
|
|
6287
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6288
|
+
return new Response3({
|
|
6110
6289
|
query: this,
|
|
6111
6290
|
json
|
|
6112
6291
|
});
|
|
@@ -6176,8 +6355,8 @@ var Query = class {
|
|
|
6176
6355
|
} catch (error) {
|
|
6177
6356
|
if (error.name === "AbortError") {
|
|
6178
6357
|
this.knishIOClient.log("warn", "Query was cancelled");
|
|
6179
|
-
const
|
|
6180
|
-
return new
|
|
6358
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6359
|
+
return new Response3({
|
|
6181
6360
|
query: this,
|
|
6182
6361
|
json: { data: null, errors: [{ message: "Query was cancelled" }] }
|
|
6183
6362
|
});
|
|
@@ -6221,8 +6400,8 @@ var Mutation = class extends Query {
|
|
|
6221
6400
|
} catch (error) {
|
|
6222
6401
|
if (error.name === "AbortError") {
|
|
6223
6402
|
this.knishIOClient.log("warn", "Mutation was cancelled");
|
|
6224
|
-
const
|
|
6225
|
-
return new
|
|
6403
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6404
|
+
return new Response3({
|
|
6226
6405
|
query: this,
|
|
6227
6406
|
json: { data: null, errors: [{ message: "Mutation was cancelled" }] }
|
|
6228
6407
|
});
|
|
@@ -6342,7 +6521,11 @@ var KnishIOClientConfigSchema2 = zod.z.object({
|
|
|
6342
6521
|
client: zod.z.unknown().optional(),
|
|
6343
6522
|
socket: zod.z.unknown().optional(),
|
|
6344
6523
|
serverSdkVersion: zod.z.number().int().min(1).max(10).default(4),
|
|
6345
|
-
logging: zod.z.boolean().default(false)
|
|
6524
|
+
logging: zod.z.boolean().default(false),
|
|
6525
|
+
// Optional default urql request policy for reads (server/sync clients pass
|
|
6526
|
+
// 'network-only'). Permitted by the strict schema so the constructor option
|
|
6527
|
+
// isn't rejected.
|
|
6528
|
+
defaultRequestPolicy: zod.z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
|
|
6346
6529
|
}).strict();
|
|
6347
6530
|
var EnvironmentConfigSchema = zod.z.object({
|
|
6348
6531
|
NODE_ENV: zod.z.enum(["development", "production", "test"]).default("development"),
|
|
@@ -7154,6 +7337,89 @@ var ConfigValidator = class _ConfigValidator {
|
|
|
7154
7337
|
|
|
7155
7338
|
// src/response/ResponseBalance.ts
|
|
7156
7339
|
init_Response();
|
|
7340
|
+
|
|
7341
|
+
// src/core/TokenUnit.ts
|
|
7342
|
+
var TokenUnit = class _TokenUnit {
|
|
7343
|
+
id;
|
|
7344
|
+
name;
|
|
7345
|
+
metas;
|
|
7346
|
+
/**
|
|
7347
|
+
* Create new TokenUnit instance
|
|
7348
|
+
* Matches JavaScript SDK constructor signature exactly
|
|
7349
|
+
*/
|
|
7350
|
+
constructor(id, name, metas) {
|
|
7351
|
+
this.id = id;
|
|
7352
|
+
this.name = name;
|
|
7353
|
+
this.metas = metas || {};
|
|
7354
|
+
}
|
|
7355
|
+
/**
|
|
7356
|
+
* Create TokenUnit from GraphQL response data
|
|
7357
|
+
* Matches JavaScript SDK createFromGraphQL method exactly
|
|
7358
|
+
*/
|
|
7359
|
+
static createFromGraphQL(data) {
|
|
7360
|
+
let metas = data.metas || {};
|
|
7361
|
+
if (Array.isArray(metas) && metas.length) {
|
|
7362
|
+
try {
|
|
7363
|
+
metas = JSON.parse(metas);
|
|
7364
|
+
if (!metas) {
|
|
7365
|
+
metas = {};
|
|
7366
|
+
}
|
|
7367
|
+
} catch (error) {
|
|
7368
|
+
metas = {};
|
|
7369
|
+
}
|
|
7370
|
+
}
|
|
7371
|
+
return new _TokenUnit(
|
|
7372
|
+
data.id,
|
|
7373
|
+
data.name,
|
|
7374
|
+
metas
|
|
7375
|
+
);
|
|
7376
|
+
}
|
|
7377
|
+
/**
|
|
7378
|
+
* Create TokenUnit from database array data
|
|
7379
|
+
* Matches JavaScript SDK createFromDB method exactly
|
|
7380
|
+
*/
|
|
7381
|
+
static createFromDB(data) {
|
|
7382
|
+
return new _TokenUnit(
|
|
7383
|
+
data[0],
|
|
7384
|
+
data[1],
|
|
7385
|
+
data.length > 2 ? data[2] : {}
|
|
7386
|
+
);
|
|
7387
|
+
}
|
|
7388
|
+
/**
|
|
7389
|
+
* Get fragment zone from metadata
|
|
7390
|
+
* Matches JavaScript SDK getFragmentZone method exactly
|
|
7391
|
+
*/
|
|
7392
|
+
getFragmentZone() {
|
|
7393
|
+
return this.metas.fragmentZone || null;
|
|
7394
|
+
}
|
|
7395
|
+
/**
|
|
7396
|
+
* Get fused token units from metadata
|
|
7397
|
+
* Matches JavaScript SDK getFusedTokenUnits method exactly
|
|
7398
|
+
*/
|
|
7399
|
+
getFusedTokenUnits() {
|
|
7400
|
+
return this.metas.fusedTokenUnits || null;
|
|
7401
|
+
}
|
|
7402
|
+
/**
|
|
7403
|
+
* Convert to data array format
|
|
7404
|
+
* Matches JavaScript SDK toData method exactly
|
|
7405
|
+
*/
|
|
7406
|
+
toData() {
|
|
7407
|
+
return [this.id, this.name, this.metas];
|
|
7408
|
+
}
|
|
7409
|
+
/**
|
|
7410
|
+
* Convert to GraphQL response format
|
|
7411
|
+
* Matches JavaScript SDK toGraphQLResponse method exactly
|
|
7412
|
+
*/
|
|
7413
|
+
toGraphQLResponse() {
|
|
7414
|
+
return {
|
|
7415
|
+
id: this.id,
|
|
7416
|
+
name: this.name,
|
|
7417
|
+
metas: JSON.stringify(this.metas)
|
|
7418
|
+
};
|
|
7419
|
+
}
|
|
7420
|
+
};
|
|
7421
|
+
|
|
7422
|
+
// src/response/ResponseBalance.ts
|
|
7157
7423
|
var ResponseBalance = class _ResponseBalance extends exports.Response {
|
|
7158
7424
|
/**
|
|
7159
7425
|
* Class constructor
|
|
@@ -7216,6 +7482,11 @@ var ResponseBalance = class _ResponseBalance extends exports.Response {
|
|
|
7216
7482
|
wallet.tokenSupply = data.token.supply;
|
|
7217
7483
|
wallet.tokenFungibility = data.token.fungibility;
|
|
7218
7484
|
}
|
|
7485
|
+
if (data.tokenUnits && data.tokenUnits.length) {
|
|
7486
|
+
for (const tokenUnitData of data.tokenUnits) {
|
|
7487
|
+
wallet.tokenUnits.push(TokenUnit.createFromGraphQL(tokenUnitData));
|
|
7488
|
+
}
|
|
7489
|
+
}
|
|
7219
7490
|
if (data.tradeRates && data.tradeRates.length) {
|
|
7220
7491
|
for (const tradeRate of data.tradeRates) {
|
|
7221
7492
|
wallet.tradeRates[tradeRate.tokenSlug] = tradeRate.amount;
|
|
@@ -7273,89 +7544,6 @@ var QueryBalance = class extends Query {
|
|
|
7273
7544
|
|
|
7274
7545
|
// src/response/ResponseWalletList.ts
|
|
7275
7546
|
init_Response();
|
|
7276
|
-
|
|
7277
|
-
// src/core/TokenUnit.ts
|
|
7278
|
-
var TokenUnit = class _TokenUnit {
|
|
7279
|
-
id;
|
|
7280
|
-
name;
|
|
7281
|
-
metas;
|
|
7282
|
-
/**
|
|
7283
|
-
* Create new TokenUnit instance
|
|
7284
|
-
* Matches JavaScript SDK constructor signature exactly
|
|
7285
|
-
*/
|
|
7286
|
-
constructor(id, name, metas) {
|
|
7287
|
-
this.id = id;
|
|
7288
|
-
this.name = name;
|
|
7289
|
-
this.metas = metas || {};
|
|
7290
|
-
}
|
|
7291
|
-
/**
|
|
7292
|
-
* Create TokenUnit from GraphQL response data
|
|
7293
|
-
* Matches JavaScript SDK createFromGraphQL method exactly
|
|
7294
|
-
*/
|
|
7295
|
-
static createFromGraphQL(data) {
|
|
7296
|
-
let metas = data.metas || {};
|
|
7297
|
-
if (Array.isArray(metas) && metas.length) {
|
|
7298
|
-
try {
|
|
7299
|
-
metas = JSON.parse(metas);
|
|
7300
|
-
if (!metas) {
|
|
7301
|
-
metas = {};
|
|
7302
|
-
}
|
|
7303
|
-
} catch (error) {
|
|
7304
|
-
metas = {};
|
|
7305
|
-
}
|
|
7306
|
-
}
|
|
7307
|
-
return new _TokenUnit(
|
|
7308
|
-
data.id,
|
|
7309
|
-
data.name,
|
|
7310
|
-
metas
|
|
7311
|
-
);
|
|
7312
|
-
}
|
|
7313
|
-
/**
|
|
7314
|
-
* Create TokenUnit from database array data
|
|
7315
|
-
* Matches JavaScript SDK createFromDB method exactly
|
|
7316
|
-
*/
|
|
7317
|
-
static createFromDB(data) {
|
|
7318
|
-
return new _TokenUnit(
|
|
7319
|
-
data[0],
|
|
7320
|
-
data[1],
|
|
7321
|
-
data.length > 2 ? data[2] : {}
|
|
7322
|
-
);
|
|
7323
|
-
}
|
|
7324
|
-
/**
|
|
7325
|
-
* Get fragment zone from metadata
|
|
7326
|
-
* Matches JavaScript SDK getFragmentZone method exactly
|
|
7327
|
-
*/
|
|
7328
|
-
getFragmentZone() {
|
|
7329
|
-
return this.metas.fragmentZone || null;
|
|
7330
|
-
}
|
|
7331
|
-
/**
|
|
7332
|
-
* Get fused token units from metadata
|
|
7333
|
-
* Matches JavaScript SDK getFusedTokenUnits method exactly
|
|
7334
|
-
*/
|
|
7335
|
-
getFusedTokenUnits() {
|
|
7336
|
-
return this.metas.fusedTokenUnits || null;
|
|
7337
|
-
}
|
|
7338
|
-
/**
|
|
7339
|
-
* Convert to data array format
|
|
7340
|
-
* Matches JavaScript SDK toData method exactly
|
|
7341
|
-
*/
|
|
7342
|
-
toData() {
|
|
7343
|
-
return [this.id, this.name, this.metas];
|
|
7344
|
-
}
|
|
7345
|
-
/**
|
|
7346
|
-
* Convert to GraphQL response format
|
|
7347
|
-
* Matches JavaScript SDK toGraphQLResponse method exactly
|
|
7348
|
-
*/
|
|
7349
|
-
toGraphQLResponse() {
|
|
7350
|
-
return {
|
|
7351
|
-
id: this.id,
|
|
7352
|
-
name: this.name,
|
|
7353
|
-
metas: JSON.stringify(this.metas)
|
|
7354
|
-
};
|
|
7355
|
-
}
|
|
7356
|
-
};
|
|
7357
|
-
|
|
7358
|
-
// src/response/ResponseWalletList.ts
|
|
7359
7547
|
var ResponseWalletList = class _ResponseWalletList extends exports.Response {
|
|
7360
7548
|
/**
|
|
7361
7549
|
* Class constructor
|
|
@@ -8279,131 +8467,6 @@ var QueryActiveSession = class extends Query {
|
|
|
8279
8467
|
}
|
|
8280
8468
|
};
|
|
8281
8469
|
|
|
8282
|
-
// src/response/ResponseQueryUserActivity.ts
|
|
8283
|
-
init_Response();
|
|
8284
|
-
var ResponseQueryUserActivity = class extends exports.Response {
|
|
8285
|
-
/**
|
|
8286
|
-
* Constructor
|
|
8287
|
-
*/
|
|
8288
|
-
constructor({
|
|
8289
|
-
query,
|
|
8290
|
-
json
|
|
8291
|
-
}) {
|
|
8292
|
-
super({
|
|
8293
|
-
query,
|
|
8294
|
-
json,
|
|
8295
|
-
dataKey: "data.UserActivity"
|
|
8296
|
-
});
|
|
8297
|
-
}
|
|
8298
|
-
/**
|
|
8299
|
-
* Returns processed user activity data
|
|
8300
|
-
*/
|
|
8301
|
-
payload() {
|
|
8302
|
-
const data = JSON.parse(JSON.stringify(this.data()));
|
|
8303
|
-
if (data.instances) {
|
|
8304
|
-
for (const datum of data.instances) {
|
|
8305
|
-
if (datum.jsonData) {
|
|
8306
|
-
datum.jsonData = JSON.parse(datum.jsonData);
|
|
8307
|
-
}
|
|
8308
|
-
}
|
|
8309
|
-
}
|
|
8310
|
-
return data;
|
|
8311
|
-
}
|
|
8312
|
-
};
|
|
8313
|
-
var QueryUserActivity = class extends Query {
|
|
8314
|
-
/**
|
|
8315
|
-
* Constructor
|
|
8316
|
-
*/
|
|
8317
|
-
constructor(graphQLClient, knishIOClient) {
|
|
8318
|
-
super(graphQLClient, knishIOClient);
|
|
8319
|
-
this.$__query = core.gql`
|
|
8320
|
-
query UserActivity(
|
|
8321
|
-
$bundleHash: String
|
|
8322
|
-
$metaType: String
|
|
8323
|
-
$metaId: String
|
|
8324
|
-
$ipAddress: String
|
|
8325
|
-
$browser: String
|
|
8326
|
-
$osCpu: String
|
|
8327
|
-
$resolution: String
|
|
8328
|
-
$timeZone: String
|
|
8329
|
-
$countBy: [CountByUserActivity]
|
|
8330
|
-
$interval: span
|
|
8331
|
-
) {
|
|
8332
|
-
UserActivity(
|
|
8333
|
-
bundleHash: $bundleHash
|
|
8334
|
-
metaType: $metaType
|
|
8335
|
-
metaId: $metaId
|
|
8336
|
-
ipAddress: $ipAddress
|
|
8337
|
-
browser: $browser
|
|
8338
|
-
osCpu: $osCpu
|
|
8339
|
-
resolution: $resolution
|
|
8340
|
-
timeZone: $timeZone
|
|
8341
|
-
countBy: $countBy
|
|
8342
|
-
interval: $interval
|
|
8343
|
-
) {
|
|
8344
|
-
createdAt
|
|
8345
|
-
bundleHash
|
|
8346
|
-
metaType
|
|
8347
|
-
metaId
|
|
8348
|
-
instances {
|
|
8349
|
-
bundleHash
|
|
8350
|
-
metaType
|
|
8351
|
-
metaId
|
|
8352
|
-
jsonData
|
|
8353
|
-
createdAt
|
|
8354
|
-
updatedAt
|
|
8355
|
-
}
|
|
8356
|
-
instanceCount {
|
|
8357
|
-
...SubFields
|
|
8358
|
-
...Recursive
|
|
8359
|
-
}
|
|
8360
|
-
}
|
|
8361
|
-
}
|
|
8362
|
-
|
|
8363
|
-
fragment SubFields on InstanceCountType {
|
|
8364
|
-
id
|
|
8365
|
-
count
|
|
8366
|
-
}
|
|
8367
|
-
|
|
8368
|
-
fragment Recursive on InstanceCountType {
|
|
8369
|
-
instances {
|
|
8370
|
-
...SubFields
|
|
8371
|
-
instances {
|
|
8372
|
-
...SubFields
|
|
8373
|
-
instances {
|
|
8374
|
-
...SubFields
|
|
8375
|
-
instances {
|
|
8376
|
-
...SubFields
|
|
8377
|
-
instances {
|
|
8378
|
-
...SubFields
|
|
8379
|
-
instances {
|
|
8380
|
-
...SubFields
|
|
8381
|
-
instances {
|
|
8382
|
-
...SubFields
|
|
8383
|
-
instances {
|
|
8384
|
-
...SubFields
|
|
8385
|
-
}
|
|
8386
|
-
}
|
|
8387
|
-
}
|
|
8388
|
-
}
|
|
8389
|
-
}
|
|
8390
|
-
}
|
|
8391
|
-
}
|
|
8392
|
-
}
|
|
8393
|
-
}
|
|
8394
|
-
`;
|
|
8395
|
-
}
|
|
8396
|
-
/**
|
|
8397
|
-
* Returns a Response object
|
|
8398
|
-
*/
|
|
8399
|
-
createResponse(json) {
|
|
8400
|
-
return new ResponseQueryUserActivity({
|
|
8401
|
-
query: this,
|
|
8402
|
-
json
|
|
8403
|
-
});
|
|
8404
|
-
}
|
|
8405
|
-
};
|
|
8406
|
-
|
|
8407
8470
|
// src/query/QueryToken.ts
|
|
8408
8471
|
init_Response();
|
|
8409
8472
|
var QueryToken = class extends Query {
|
|
@@ -9237,6 +9300,20 @@ var MutationTransferTokens = class extends MutationProposeMolecule {
|
|
|
9237
9300
|
this.$__molecule.sign({});
|
|
9238
9301
|
this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
9239
9302
|
}
|
|
9303
|
+
/**
|
|
9304
|
+
* Fills the Molecule for a MULTI-recipient transfer (one source funds N recipients)
|
|
9305
|
+
*/
|
|
9306
|
+
fillMoleculeMulti({
|
|
9307
|
+
recipientWallets,
|
|
9308
|
+
amounts
|
|
9309
|
+
}) {
|
|
9310
|
+
this.$__molecule.initValues({
|
|
9311
|
+
recipientWallets,
|
|
9312
|
+
amounts
|
|
9313
|
+
});
|
|
9314
|
+
this.$__molecule.sign({});
|
|
9315
|
+
this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
9316
|
+
}
|
|
9240
9317
|
/**
|
|
9241
9318
|
* Builds a Response object out of a JSON object
|
|
9242
9319
|
* Matches JavaScript SDK createResponse method signature exactly
|
|
@@ -9297,7 +9374,8 @@ var MutationClaimShadowWallet = class extends MutationProposeMolecule {
|
|
|
9297
9374
|
bundle: this.$__molecule.bundle,
|
|
9298
9375
|
token,
|
|
9299
9376
|
batchId
|
|
9300
|
-
})
|
|
9377
|
+
});
|
|
9378
|
+
this.$__molecule.initShadowWalletClaim(wallet);
|
|
9301
9379
|
this.$__molecule.sign({});
|
|
9302
9380
|
this.$__molecule.check();
|
|
9303
9381
|
}
|
|
@@ -10070,6 +10148,10 @@ var KnishIOClient = class {
|
|
|
10070
10148
|
$__client;
|
|
10071
10149
|
$__serverSdkVersion = 3;
|
|
10072
10150
|
$__logging = false;
|
|
10151
|
+
// Default urql request policy applied to reads when the caller doesn't pass
|
|
10152
|
+
// one. null = urql's default (cache-first). Server/sync clients set this to
|
|
10153
|
+
// 'network-only' so a long-lived client never serves a stale cached read.
|
|
10154
|
+
$__defaultRequestPolicy = null;
|
|
10073
10155
|
$__authTokenObjects = {};
|
|
10074
10156
|
$__authToken = null;
|
|
10075
10157
|
$__authInProcess = false;
|
|
@@ -10109,13 +10191,15 @@ var KnishIOClient = class {
|
|
|
10109
10191
|
serverSdkVersion = 3,
|
|
10110
10192
|
logging = false
|
|
10111
10193
|
} = validatedConfig;
|
|
10194
|
+
const defaultRequestPolicy = config.defaultRequestPolicy ?? null;
|
|
10112
10195
|
this.initialize({
|
|
10113
10196
|
uri,
|
|
10114
10197
|
cellSlug,
|
|
10115
10198
|
socket,
|
|
10116
10199
|
client,
|
|
10117
10200
|
serverSdkVersion,
|
|
10118
|
-
logging
|
|
10201
|
+
logging,
|
|
10202
|
+
defaultRequestPolicy
|
|
10119
10203
|
});
|
|
10120
10204
|
}
|
|
10121
10205
|
/**
|
|
@@ -10127,7 +10211,8 @@ var KnishIOClient = class {
|
|
|
10127
10211
|
socket = null,
|
|
10128
10212
|
client = null,
|
|
10129
10213
|
serverSdkVersion = 3,
|
|
10130
|
-
logging = false
|
|
10214
|
+
logging = false,
|
|
10215
|
+
defaultRequestPolicy = null
|
|
10131
10216
|
}) {
|
|
10132
10217
|
this.reset();
|
|
10133
10218
|
this.$__logging = logging;
|
|
@@ -10149,6 +10234,7 @@ var KnishIOClient = class {
|
|
|
10149
10234
|
encrypt: this.$__encrypt
|
|
10150
10235
|
});
|
|
10151
10236
|
this.$__serverSdkVersion = serverSdkVersion;
|
|
10237
|
+
this.$__defaultRequestPolicy = defaultRequestPolicy;
|
|
10152
10238
|
}
|
|
10153
10239
|
/**
|
|
10154
10240
|
* Get random uri from specified this.$__uris
|
|
@@ -10196,6 +10282,20 @@ var KnishIOClient = class {
|
|
|
10196
10282
|
getServerSdkVersion() {
|
|
10197
10283
|
return this.$__serverSdkVersion;
|
|
10198
10284
|
}
|
|
10285
|
+
/**
|
|
10286
|
+
* Gets the client's default urql request policy (null = urql default).
|
|
10287
|
+
*/
|
|
10288
|
+
getDefaultRequestPolicy() {
|
|
10289
|
+
return this.$__defaultRequestPolicy;
|
|
10290
|
+
}
|
|
10291
|
+
/**
|
|
10292
|
+
* Sets the default urql request policy applied to reads that don't specify
|
|
10293
|
+
* one. Pass 'network-only' on a long-lived server/sync client so it never
|
|
10294
|
+
* serves a stale cached read; null restores urql's default (cache-first).
|
|
10295
|
+
*/
|
|
10296
|
+
setDefaultRequestPolicy(policy) {
|
|
10297
|
+
this.$__defaultRequestPolicy = policy;
|
|
10298
|
+
}
|
|
10199
10299
|
/**
|
|
10200
10300
|
* Reset common properties
|
|
10201
10301
|
*/
|
|
@@ -10400,7 +10500,8 @@ var KnishIOClient = class {
|
|
|
10400
10500
|
return response;
|
|
10401
10501
|
});
|
|
10402
10502
|
}
|
|
10403
|
-
|
|
10503
|
+
const effectiveContext = this.$__defaultRequestPolicy && !context.requestPolicy ? { requestPolicy: this.$__defaultRequestPolicy, ...context } : context;
|
|
10504
|
+
return await query.execute({ variables: variables || {}, context: effectiveContext });
|
|
10404
10505
|
}
|
|
10405
10506
|
/**
|
|
10406
10507
|
* When a ProposeMolecule submission is rejected for a position-related
|
|
@@ -10520,6 +10621,75 @@ var KnishIOClient = class {
|
|
|
10520
10621
|
});
|
|
10521
10622
|
return await this.executeQuery(query);
|
|
10522
10623
|
}
|
|
10624
|
+
/**
|
|
10625
|
+
* Fund N recipients from a single source in ONE molecule (multi-recipient sibling of
|
|
10626
|
+
* transferToken). Each recipient gets its own subset of stackable units (or a fungible
|
|
10627
|
+
* amount); a remainder returns the rest to the sender. Conserves:
|
|
10628
|
+
* -balance + Σamounts + (balance - Σ) === 0.
|
|
10629
|
+
*
|
|
10630
|
+
* @param token - token slug
|
|
10631
|
+
* @param recipients - destinations (bundleHash + units OR amount + optional batchId)
|
|
10632
|
+
* @param sourceWallet - optional pre-resolved source (defaults to the client's own wallet)
|
|
10633
|
+
*/
|
|
10634
|
+
async transferTokens({
|
|
10635
|
+
token,
|
|
10636
|
+
recipients,
|
|
10637
|
+
sourceWallet = null
|
|
10638
|
+
}) {
|
|
10639
|
+
const amounts = recipients.map((recipient) => {
|
|
10640
|
+
const unitCount = recipient.units ? recipient.units.length : 0;
|
|
10641
|
+
if (unitCount > 0) {
|
|
10642
|
+
if (recipient.amount !== null && recipient.amount !== void 0 && recipient.amount > 0) {
|
|
10643
|
+
throw new StackableUnitAmountException_default();
|
|
10644
|
+
}
|
|
10645
|
+
return unitCount;
|
|
10646
|
+
}
|
|
10647
|
+
return recipient.amount ?? 0;
|
|
10648
|
+
});
|
|
10649
|
+
const total = amounts.reduce((sum, amount) => sum + amount, 0);
|
|
10650
|
+
if (sourceWallet === null) {
|
|
10651
|
+
sourceWallet = await this.querySourceWallet({
|
|
10652
|
+
token,
|
|
10653
|
+
amount: total
|
|
10654
|
+
});
|
|
10655
|
+
}
|
|
10656
|
+
if (sourceWallet === null || Decimal.cmp(Number(sourceWallet.balance), total) < 0) {
|
|
10657
|
+
throw new exports.TransferBalanceException();
|
|
10658
|
+
}
|
|
10659
|
+
const recipientWallets = recipients.map((recipient) => {
|
|
10660
|
+
const recipientWallet = Wallet.create({
|
|
10661
|
+
bundle: recipient.bundleHash,
|
|
10662
|
+
token
|
|
10663
|
+
});
|
|
10664
|
+
if (recipient.batchId !== null && recipient.batchId !== void 0) {
|
|
10665
|
+
recipientWallet.batchId = recipient.batchId;
|
|
10666
|
+
} else {
|
|
10667
|
+
recipientWallet.initBatchId({ sourceWallet });
|
|
10668
|
+
}
|
|
10669
|
+
return recipientWallet;
|
|
10670
|
+
});
|
|
10671
|
+
const remainderWallet = sourceWallet.createRemainder(this.getSecret());
|
|
10672
|
+
if (recipients.some((recipient) => recipient.units && recipient.units.length > 0)) {
|
|
10673
|
+
sourceWallet.splitUnitsMulti(
|
|
10674
|
+
recipients.map((recipient) => recipient.units ?? []),
|
|
10675
|
+
recipientWallets,
|
|
10676
|
+
remainderWallet
|
|
10677
|
+
);
|
|
10678
|
+
}
|
|
10679
|
+
const molecule = await this.createMolecule({
|
|
10680
|
+
sourceWallet,
|
|
10681
|
+
remainderWallet
|
|
10682
|
+
});
|
|
10683
|
+
const query = await this.createMoleculeMutation({
|
|
10684
|
+
mutationClass: MutationTransferTokens,
|
|
10685
|
+
molecule
|
|
10686
|
+
});
|
|
10687
|
+
query.fillMoleculeMulti({
|
|
10688
|
+
recipientWallets,
|
|
10689
|
+
amounts
|
|
10690
|
+
});
|
|
10691
|
+
return await this.executeQuery(query);
|
|
10692
|
+
}
|
|
10523
10693
|
/**
|
|
10524
10694
|
* Request authorization token (guest or profile)
|
|
10525
10695
|
*
|
|
@@ -10976,36 +11146,6 @@ var KnishIOClient = class {
|
|
|
10976
11146
|
metaId
|
|
10977
11147
|
});
|
|
10978
11148
|
}
|
|
10979
|
-
/**
|
|
10980
|
-
* Query user activity
|
|
10981
|
-
*/
|
|
10982
|
-
async queryUserActivity({
|
|
10983
|
-
bundleHash,
|
|
10984
|
-
metaType,
|
|
10985
|
-
metaId,
|
|
10986
|
-
ipAddress = null,
|
|
10987
|
-
browser = null,
|
|
10988
|
-
osCpu = null,
|
|
10989
|
-
resolution = null,
|
|
10990
|
-
timeZone = null,
|
|
10991
|
-
countBy = null,
|
|
10992
|
-
interval = null
|
|
10993
|
-
}) {
|
|
10994
|
-
const query = this.createQuery(QueryUserActivity);
|
|
10995
|
-
const variables = {
|
|
10996
|
-
bundleHash,
|
|
10997
|
-
metaType,
|
|
10998
|
-
metaId
|
|
10999
|
-
};
|
|
11000
|
-
if (ipAddress !== null) variables.ipAddress = ipAddress;
|
|
11001
|
-
if (browser !== null) variables.browser = browser;
|
|
11002
|
-
if (osCpu !== null) variables.osCpu = osCpu;
|
|
11003
|
-
if (resolution !== null) variables.resolution = resolution;
|
|
11004
|
-
if (timeZone !== null) variables.timeZone = timeZone;
|
|
11005
|
-
if (countBy !== null) variables.countBy = countBy;
|
|
11006
|
-
if (interval !== null) variables.interval = interval;
|
|
11007
|
-
return this.executeQuery(query, variables);
|
|
11008
|
-
}
|
|
11009
11149
|
/**
|
|
11010
11150
|
* Query token information
|
|
11011
11151
|
*/
|
|
@@ -11114,9 +11254,27 @@ var KnishIOClient = class {
|
|
|
11114
11254
|
amount = null,
|
|
11115
11255
|
meta = null,
|
|
11116
11256
|
batchId = null,
|
|
11117
|
-
units
|
|
11257
|
+
units = null
|
|
11118
11258
|
}) {
|
|
11119
11259
|
this.log("info", `KnishIOClient::createToken() - Creating token ${token}...`);
|
|
11260
|
+
const tokenMeta = meta || {};
|
|
11261
|
+
const fungibility = tokenMeta.fungibility;
|
|
11262
|
+
let resolvedAmount = amount ?? 0;
|
|
11263
|
+
if (fungibility === "stackable") {
|
|
11264
|
+
tokenMeta.batchId = batchId || generateBatchId({});
|
|
11265
|
+
}
|
|
11266
|
+
if ((fungibility === "stackable" || fungibility === "nonfungible" || fungibility === "non-fungible") && units && units.length > 0) {
|
|
11267
|
+
if (Number(tokenMeta.decimals ?? 0) > 0) {
|
|
11268
|
+
throw new StackableUnitDecimalsException_default();
|
|
11269
|
+
}
|
|
11270
|
+
if (Number(amount ?? 0) > 0) {
|
|
11271
|
+
throw new StackableUnitAmountException_default();
|
|
11272
|
+
}
|
|
11273
|
+
resolvedAmount = units.length;
|
|
11274
|
+
tokenMeta.splittable = "1";
|
|
11275
|
+
tokenMeta.decimals = "0";
|
|
11276
|
+
tokenMeta.tokenUnits = JSON.stringify(units);
|
|
11277
|
+
}
|
|
11120
11278
|
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateToken });
|
|
11121
11279
|
const recipientWallet = new Wallet({
|
|
11122
11280
|
secret: this.getSecret(),
|
|
@@ -11126,8 +11284,8 @@ var KnishIOClient = class {
|
|
|
11126
11284
|
});
|
|
11127
11285
|
await mutation.fillMolecule({
|
|
11128
11286
|
recipientWallet,
|
|
11129
|
-
amount:
|
|
11130
|
-
meta
|
|
11287
|
+
amount: resolvedAmount,
|
|
11288
|
+
meta: tokenMeta
|
|
11131
11289
|
});
|
|
11132
11290
|
const response = await this.executeQuery(mutation);
|
|
11133
11291
|
if (!response) {
|
|
@@ -11568,8 +11726,12 @@ var KnishIOClient = class {
|
|
|
11568
11726
|
mutationClass: MutationRequestAuthorization,
|
|
11569
11727
|
molecule
|
|
11570
11728
|
});
|
|
11729
|
+
const authMeta = { encrypt: encrypt ? "true" : "false" };
|
|
11730
|
+
if (wallet.pubkey) {
|
|
11731
|
+
authMeta.walletPubkey = wallet.pubkey;
|
|
11732
|
+
}
|
|
11571
11733
|
mutation.fillMolecule({
|
|
11572
|
-
meta:
|
|
11734
|
+
meta: authMeta
|
|
11573
11735
|
});
|
|
11574
11736
|
const response = await this.executeQuery(mutation);
|
|
11575
11737
|
if (!response) {
|