@wishknish/knishio-client-ts 0.8.3 → 0.9.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 +399 -258
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -16
- package/dist/index.d.ts +37 -16
- package/dist/index.iife.js +3700 -602
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +421 -280
- package/dist/index.js.map +1 -1
- package/package.json +18 -20
- package/src/KnishIOClient.ts +135 -53
- package/src/constants.ts +1 -2
- package/src/core/Molecule.ts +53 -0
- package/src/core/Wallet.ts +96 -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/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/validation/UNIVERSAL_CONFIGURATION_INTERFACES.ts +3 -5
- package/src/validation/ValidationService.ts +6 -15
- package/src/versions/HashAtom.ts +11 -9
- package/src/query/QueryUserActivity.ts +0 -153
- package/src/response/ResponseQueryUserActivity.ts +0 -89
package/dist/index.js
CHANGED
|
@@ -939,9 +939,19 @@ var init_StackableUnitAmountException = __esm({
|
|
|
939
939
|
});
|
|
940
940
|
|
|
941
941
|
// src/exception/StackableUnitDecimalsException.ts
|
|
942
|
+
var StackableUnitDecimalsException, StackableUnitDecimalsException_default;
|
|
942
943
|
var init_StackableUnitDecimalsException = __esm({
|
|
943
944
|
"src/exception/StackableUnitDecimalsException.ts"() {
|
|
944
945
|
init_BaseException();
|
|
946
|
+
StackableUnitDecimalsException = class extends BaseException {
|
|
947
|
+
/**
|
|
948
|
+
* Constructor using proper error type
|
|
949
|
+
*/
|
|
950
|
+
constructor(message = "Stackable tokens with unit IDs cannot have decimal places!") {
|
|
951
|
+
super("STACKABLE_UNIT_DECIMALS_ERROR", message);
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
StackableUnitDecimalsException_default = StackableUnitDecimalsException;
|
|
945
955
|
}
|
|
946
956
|
});
|
|
947
957
|
|
|
@@ -1560,15 +1570,15 @@ var init_EnhancedResponse = __esm({
|
|
|
1560
1570
|
// src/response/Response.ts
|
|
1561
1571
|
var Response_exports = {};
|
|
1562
1572
|
__export(Response_exports, {
|
|
1563
|
-
default: () =>
|
|
1573
|
+
default: () => Response2
|
|
1564
1574
|
});
|
|
1565
|
-
var
|
|
1575
|
+
var Response2;
|
|
1566
1576
|
var init_Response = __esm({
|
|
1567
1577
|
"src/response/Response.ts"() {
|
|
1568
1578
|
init_exception();
|
|
1569
1579
|
init_Dot();
|
|
1570
1580
|
init_EnhancedResponse();
|
|
1571
|
-
|
|
1581
|
+
Response2 = class {
|
|
1572
1582
|
dataKey;
|
|
1573
1583
|
errorKey = "exception";
|
|
1574
1584
|
$__payload = null;
|
|
@@ -1923,9 +1933,6 @@ function generateSecret(seed = null, length = CRYPTO_CONSTANTS.SECRET_LENGTH) {
|
|
|
1923
1933
|
}
|
|
1924
1934
|
}
|
|
1925
1935
|
function generateBundleHash(secret, _source = null) {
|
|
1926
|
-
if (!secret || secret.length === 0) {
|
|
1927
|
-
throw new Error("Secret is required for bundle hash generation");
|
|
1928
|
-
}
|
|
1929
1936
|
const hash = shake256(secret, CRYPTO_CONSTANTS.BUNDLE_HASH_LENGTH * 4);
|
|
1930
1937
|
return hash;
|
|
1931
1938
|
}
|
|
@@ -3336,8 +3343,7 @@ var QUERY_TYPES = [
|
|
|
3336
3343
|
"Batch",
|
|
3337
3344
|
"ActiveSession",
|
|
3338
3345
|
"Policy",
|
|
3339
|
-
"Token"
|
|
3340
|
-
"UserActivity"
|
|
3346
|
+
"Token"
|
|
3341
3347
|
];
|
|
3342
3348
|
function createLookup(values) {
|
|
3343
3349
|
return values.reduce((acc, value) => {
|
|
@@ -3596,6 +3602,29 @@ var Wallet = class _Wallet {
|
|
|
3596
3602
|
}
|
|
3597
3603
|
remainderWallet.tokenUnits = remainderTokenUnits;
|
|
3598
3604
|
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Split token units across MULTIPLE recipients (N-way sibling of splitUnits).
|
|
3607
|
+
*
|
|
3608
|
+
* The source retains the SENT union (all units leaving), each recipient gets its own
|
|
3609
|
+
* subset, and the remainder keeps the KEPT units (those not assigned to any recipient).
|
|
3610
|
+
* recipientUnitLists is parallel to recipientWallets. No-op when no units are sent.
|
|
3611
|
+
*
|
|
3612
|
+
* @param recipientUnitLists - per-recipient arrays of token unit IDs (parallel to recipientWallets)
|
|
3613
|
+
* @param recipientWallets - destination wallets
|
|
3614
|
+
* @param remainderWallet - wallet to receive the KEPT units
|
|
3615
|
+
*/
|
|
3616
|
+
splitUnitsMulti(recipientUnitLists, recipientWallets, remainderWallet) {
|
|
3617
|
+
const sentIds = new Set(recipientUnitLists.flat());
|
|
3618
|
+
if (sentIds.size === 0) {
|
|
3619
|
+
return;
|
|
3620
|
+
}
|
|
3621
|
+
recipientWallets.forEach((recipientWallet, i) => {
|
|
3622
|
+
const ids = recipientUnitLists[i] ?? [];
|
|
3623
|
+
recipientWallet.tokenUnits = this.tokenUnits.filter((tokenUnit) => ids.includes(tokenUnit.id));
|
|
3624
|
+
});
|
|
3625
|
+
remainderWallet.tokenUnits = this.tokenUnits.filter((tokenUnit) => !sentIds.has(tokenUnit.id));
|
|
3626
|
+
this.tokenUnits = this.tokenUnits.filter((tokenUnit) => sentIds.has(tokenUnit.id));
|
|
3627
|
+
}
|
|
3599
3628
|
/**
|
|
3600
3629
|
* Get token units data
|
|
3601
3630
|
* Stub for compatibility
|
|
@@ -3634,6 +3663,12 @@ var Wallet = class _Wallet {
|
|
|
3634
3663
|
const messageString = JSON.stringify(message);
|
|
3635
3664
|
const messageUint8 = new TextEncoder().encode(messageString);
|
|
3636
3665
|
const deserializedPubkey = this.deserializeKey(recipientPubkey);
|
|
3666
|
+
const ML_KEM_768_PUBLIC_KEY_BYTES = 1184;
|
|
3667
|
+
if (deserializedPubkey.length !== ML_KEM_768_PUBLIC_KEY_BYTES) {
|
|
3668
|
+
throw new Error(
|
|
3669
|
+
`KnishIO: cannot ML-KEM-encrypt \u2014 recipient public key is ${deserializedPubkey.length} bytes, expected ${ML_KEM_768_PUBLIC_KEY_BYTES} (ML-KEM-768). The node likely did not advertise an ML-KEM public key (upgrade the validator to a PQ-transport build), or authenticate with { encrypt: false }.`
|
|
3670
|
+
);
|
|
3671
|
+
}
|
|
3637
3672
|
const { cipherText, sharedSecret } = ml_kem768.encapsulate(deserializedPubkey);
|
|
3638
3673
|
const encryptedMessage = await this.encryptWithSharedSecret(messageUint8, sharedSecret);
|
|
3639
3674
|
return {
|
|
@@ -3642,6 +3677,15 @@ var Wallet = class _Wallet {
|
|
|
3642
3677
|
};
|
|
3643
3678
|
}
|
|
3644
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) {
|
|
3645
3689
|
const { cipherText, encryptedMessage } = encryptedData;
|
|
3646
3690
|
let sharedSecret;
|
|
3647
3691
|
try {
|
|
@@ -3670,9 +3714,8 @@ var Wallet = class _Wallet {
|
|
|
3670
3714
|
console.info("Wallet::decryptMessage() - deserialized encrypted message", deserializedEncryptedMessage);
|
|
3671
3715
|
return null;
|
|
3672
3716
|
}
|
|
3673
|
-
let decryptedString;
|
|
3674
3717
|
try {
|
|
3675
|
-
|
|
3718
|
+
return new TextDecoder().decode(decryptedUint8);
|
|
3676
3719
|
} catch (e) {
|
|
3677
3720
|
console.warn("Wallet::decryptMessage() - Decoding failed", e);
|
|
3678
3721
|
console.info("Wallet::decryptMessage() - my public key", this.pubkey);
|
|
@@ -3681,7 +3724,40 @@ var Wallet = class _Wallet {
|
|
|
3681
3724
|
console.info("Wallet::decryptMessage() - decrypted Uint8Array", decryptedUint8);
|
|
3682
3725
|
return null;
|
|
3683
3726
|
}
|
|
3684
|
-
|
|
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);
|
|
3685
3761
|
}
|
|
3686
3762
|
// =============================================================================
|
|
3687
3763
|
// SYMMETRIC ENCRYPTION HELPERS (AES-GCM with shared secret)
|
|
@@ -4980,6 +5056,46 @@ var Molecule = class _Molecule {
|
|
|
4980
5056
|
}));
|
|
4981
5057
|
return this;
|
|
4982
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
|
+
}
|
|
4983
5099
|
/**
|
|
4984
5100
|
* Sign the molecule with one-time signature
|
|
4985
5101
|
* Matches JavaScript SDK sign method
|
|
@@ -5737,7 +5853,7 @@ var Decimal = class _Decimal {
|
|
|
5737
5853
|
* @param debug Enable debug logging
|
|
5738
5854
|
* @returns 0 if equal, 1 if value1 > value2, -1 if value1 < value2
|
|
5739
5855
|
*/
|
|
5740
|
-
static cmp(value1, value2,
|
|
5856
|
+
static cmp(value1, value2, _debug = false) {
|
|
5741
5857
|
const val1 = _Decimal.val(value1) * MULTIPLIER;
|
|
5742
5858
|
const val2 = _Decimal.val(value2) * MULTIPLIER;
|
|
5743
5859
|
if (Math.abs(val1 - val2) < 1) {
|
|
@@ -5752,6 +5868,14 @@ var Decimal = class _Decimal {
|
|
|
5752
5868
|
return _Decimal.cmp(value1, value2) === 0;
|
|
5753
5869
|
}
|
|
5754
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
|
+
}
|
|
5755
5879
|
var GraphQLClient = class {
|
|
5756
5880
|
$__client;
|
|
5757
5881
|
$__authToken = "";
|
|
@@ -5797,6 +5921,10 @@ var GraphQLClient = class {
|
|
|
5797
5921
|
return createClient$1({
|
|
5798
5922
|
url: serverUri,
|
|
5799
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)) } : {},
|
|
5800
5928
|
fetchOptions: () => ({
|
|
5801
5929
|
headers: {
|
|
5802
5930
|
"X-Auth-Token": this.$__authToken
|
|
@@ -5806,6 +5934,62 @@ var GraphQLClient = class {
|
|
|
5806
5934
|
})
|
|
5807
5935
|
});
|
|
5808
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
|
+
}
|
|
5809
5993
|
setAuthData({
|
|
5810
5994
|
token,
|
|
5811
5995
|
pubkey,
|
|
@@ -6100,8 +6284,8 @@ var Query = class {
|
|
|
6100
6284
|
* Returns a Response object
|
|
6101
6285
|
*/
|
|
6102
6286
|
createResponse(json) {
|
|
6103
|
-
const
|
|
6104
|
-
return new
|
|
6287
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6288
|
+
return new Response3({
|
|
6105
6289
|
query: this,
|
|
6106
6290
|
json
|
|
6107
6291
|
});
|
|
@@ -6171,8 +6355,8 @@ var Query = class {
|
|
|
6171
6355
|
} catch (error) {
|
|
6172
6356
|
if (error.name === "AbortError") {
|
|
6173
6357
|
this.knishIOClient.log("warn", "Query was cancelled");
|
|
6174
|
-
const
|
|
6175
|
-
return new
|
|
6358
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6359
|
+
return new Response3({
|
|
6176
6360
|
query: this,
|
|
6177
6361
|
json: { data: null, errors: [{ message: "Query was cancelled" }] }
|
|
6178
6362
|
});
|
|
@@ -6216,8 +6400,8 @@ var Mutation = class extends Query {
|
|
|
6216
6400
|
} catch (error) {
|
|
6217
6401
|
if (error.name === "AbortError") {
|
|
6218
6402
|
this.knishIOClient.log("warn", "Mutation was cancelled");
|
|
6219
|
-
const
|
|
6220
|
-
return new
|
|
6403
|
+
const Response3 = (init_Response(), __toCommonJS(Response_exports)).default;
|
|
6404
|
+
return new Response3({
|
|
6221
6405
|
query: this,
|
|
6222
6406
|
json: { data: null, errors: [{ message: "Mutation was cancelled" }] }
|
|
6223
6407
|
});
|
|
@@ -6823,6 +7007,7 @@ var ValidationChainBuilder = class {
|
|
|
6823
7007
|
constructor(service) {
|
|
6824
7008
|
this.service = service;
|
|
6825
7009
|
}
|
|
7010
|
+
service;
|
|
6826
7011
|
validators = [];
|
|
6827
7012
|
/**
|
|
6828
7013
|
* Add a schema validation step
|
|
@@ -7153,7 +7338,90 @@ var ConfigValidator = class _ConfigValidator {
|
|
|
7153
7338
|
|
|
7154
7339
|
// src/response/ResponseBalance.ts
|
|
7155
7340
|
init_Response();
|
|
7156
|
-
|
|
7341
|
+
|
|
7342
|
+
// src/core/TokenUnit.ts
|
|
7343
|
+
var TokenUnit = class _TokenUnit {
|
|
7344
|
+
id;
|
|
7345
|
+
name;
|
|
7346
|
+
metas;
|
|
7347
|
+
/**
|
|
7348
|
+
* Create new TokenUnit instance
|
|
7349
|
+
* Matches JavaScript SDK constructor signature exactly
|
|
7350
|
+
*/
|
|
7351
|
+
constructor(id, name, metas) {
|
|
7352
|
+
this.id = id;
|
|
7353
|
+
this.name = name;
|
|
7354
|
+
this.metas = metas || {};
|
|
7355
|
+
}
|
|
7356
|
+
/**
|
|
7357
|
+
* Create TokenUnit from GraphQL response data
|
|
7358
|
+
* Matches JavaScript SDK createFromGraphQL method exactly
|
|
7359
|
+
*/
|
|
7360
|
+
static createFromGraphQL(data) {
|
|
7361
|
+
let metas = data.metas || {};
|
|
7362
|
+
if (Array.isArray(metas) && metas.length) {
|
|
7363
|
+
try {
|
|
7364
|
+
metas = JSON.parse(metas);
|
|
7365
|
+
if (!metas) {
|
|
7366
|
+
metas = {};
|
|
7367
|
+
}
|
|
7368
|
+
} catch (error) {
|
|
7369
|
+
metas = {};
|
|
7370
|
+
}
|
|
7371
|
+
}
|
|
7372
|
+
return new _TokenUnit(
|
|
7373
|
+
data.id,
|
|
7374
|
+
data.name,
|
|
7375
|
+
metas
|
|
7376
|
+
);
|
|
7377
|
+
}
|
|
7378
|
+
/**
|
|
7379
|
+
* Create TokenUnit from database array data
|
|
7380
|
+
* Matches JavaScript SDK createFromDB method exactly
|
|
7381
|
+
*/
|
|
7382
|
+
static createFromDB(data) {
|
|
7383
|
+
return new _TokenUnit(
|
|
7384
|
+
data[0],
|
|
7385
|
+
data[1],
|
|
7386
|
+
data.length > 2 ? data[2] : {}
|
|
7387
|
+
);
|
|
7388
|
+
}
|
|
7389
|
+
/**
|
|
7390
|
+
* Get fragment zone from metadata
|
|
7391
|
+
* Matches JavaScript SDK getFragmentZone method exactly
|
|
7392
|
+
*/
|
|
7393
|
+
getFragmentZone() {
|
|
7394
|
+
return this.metas.fragmentZone || null;
|
|
7395
|
+
}
|
|
7396
|
+
/**
|
|
7397
|
+
* Get fused token units from metadata
|
|
7398
|
+
* Matches JavaScript SDK getFusedTokenUnits method exactly
|
|
7399
|
+
*/
|
|
7400
|
+
getFusedTokenUnits() {
|
|
7401
|
+
return this.metas.fusedTokenUnits || null;
|
|
7402
|
+
}
|
|
7403
|
+
/**
|
|
7404
|
+
* Convert to data array format
|
|
7405
|
+
* Matches JavaScript SDK toData method exactly
|
|
7406
|
+
*/
|
|
7407
|
+
toData() {
|
|
7408
|
+
return [this.id, this.name, this.metas];
|
|
7409
|
+
}
|
|
7410
|
+
/**
|
|
7411
|
+
* Convert to GraphQL response format
|
|
7412
|
+
* Matches JavaScript SDK toGraphQLResponse method exactly
|
|
7413
|
+
*/
|
|
7414
|
+
toGraphQLResponse() {
|
|
7415
|
+
return {
|
|
7416
|
+
id: this.id,
|
|
7417
|
+
name: this.name,
|
|
7418
|
+
metas: JSON.stringify(this.metas)
|
|
7419
|
+
};
|
|
7420
|
+
}
|
|
7421
|
+
};
|
|
7422
|
+
|
|
7423
|
+
// src/response/ResponseBalance.ts
|
|
7424
|
+
var ResponseBalance = class _ResponseBalance extends Response2 {
|
|
7157
7425
|
/**
|
|
7158
7426
|
* Class constructor
|
|
7159
7427
|
*/
|
|
@@ -7215,6 +7483,11 @@ var ResponseBalance = class _ResponseBalance extends Response {
|
|
|
7215
7483
|
wallet.tokenSupply = data.token.supply;
|
|
7216
7484
|
wallet.tokenFungibility = data.token.fungibility;
|
|
7217
7485
|
}
|
|
7486
|
+
if (data.tokenUnits && data.tokenUnits.length) {
|
|
7487
|
+
for (const tokenUnitData of data.tokenUnits) {
|
|
7488
|
+
wallet.tokenUnits.push(TokenUnit.createFromGraphQL(tokenUnitData));
|
|
7489
|
+
}
|
|
7490
|
+
}
|
|
7218
7491
|
if (data.tradeRates && data.tradeRates.length) {
|
|
7219
7492
|
for (const tradeRate of data.tradeRates) {
|
|
7220
7493
|
wallet.tradeRates[tradeRate.tokenSlug] = tradeRate.amount;
|
|
@@ -7272,90 +7545,7 @@ var QueryBalance = class extends Query {
|
|
|
7272
7545
|
|
|
7273
7546
|
// src/response/ResponseWalletList.ts
|
|
7274
7547
|
init_Response();
|
|
7275
|
-
|
|
7276
|
-
// src/core/TokenUnit.ts
|
|
7277
|
-
var TokenUnit = class _TokenUnit {
|
|
7278
|
-
id;
|
|
7279
|
-
name;
|
|
7280
|
-
metas;
|
|
7281
|
-
/**
|
|
7282
|
-
* Create new TokenUnit instance
|
|
7283
|
-
* Matches JavaScript SDK constructor signature exactly
|
|
7284
|
-
*/
|
|
7285
|
-
constructor(id, name, metas) {
|
|
7286
|
-
this.id = id;
|
|
7287
|
-
this.name = name;
|
|
7288
|
-
this.metas = metas || {};
|
|
7289
|
-
}
|
|
7290
|
-
/**
|
|
7291
|
-
* Create TokenUnit from GraphQL response data
|
|
7292
|
-
* Matches JavaScript SDK createFromGraphQL method exactly
|
|
7293
|
-
*/
|
|
7294
|
-
static createFromGraphQL(data) {
|
|
7295
|
-
let metas = data.metas || {};
|
|
7296
|
-
if (Array.isArray(metas) && metas.length) {
|
|
7297
|
-
try {
|
|
7298
|
-
metas = JSON.parse(metas);
|
|
7299
|
-
if (!metas) {
|
|
7300
|
-
metas = {};
|
|
7301
|
-
}
|
|
7302
|
-
} catch (error) {
|
|
7303
|
-
metas = {};
|
|
7304
|
-
}
|
|
7305
|
-
}
|
|
7306
|
-
return new _TokenUnit(
|
|
7307
|
-
data.id,
|
|
7308
|
-
data.name,
|
|
7309
|
-
metas
|
|
7310
|
-
);
|
|
7311
|
-
}
|
|
7312
|
-
/**
|
|
7313
|
-
* Create TokenUnit from database array data
|
|
7314
|
-
* Matches JavaScript SDK createFromDB method exactly
|
|
7315
|
-
*/
|
|
7316
|
-
static createFromDB(data) {
|
|
7317
|
-
return new _TokenUnit(
|
|
7318
|
-
data[0],
|
|
7319
|
-
data[1],
|
|
7320
|
-
data.length > 2 ? data[2] : {}
|
|
7321
|
-
);
|
|
7322
|
-
}
|
|
7323
|
-
/**
|
|
7324
|
-
* Get fragment zone from metadata
|
|
7325
|
-
* Matches JavaScript SDK getFragmentZone method exactly
|
|
7326
|
-
*/
|
|
7327
|
-
getFragmentZone() {
|
|
7328
|
-
return this.metas.fragmentZone || null;
|
|
7329
|
-
}
|
|
7330
|
-
/**
|
|
7331
|
-
* Get fused token units from metadata
|
|
7332
|
-
* Matches JavaScript SDK getFusedTokenUnits method exactly
|
|
7333
|
-
*/
|
|
7334
|
-
getFusedTokenUnits() {
|
|
7335
|
-
return this.metas.fusedTokenUnits || null;
|
|
7336
|
-
}
|
|
7337
|
-
/**
|
|
7338
|
-
* Convert to data array format
|
|
7339
|
-
* Matches JavaScript SDK toData method exactly
|
|
7340
|
-
*/
|
|
7341
|
-
toData() {
|
|
7342
|
-
return [this.id, this.name, this.metas];
|
|
7343
|
-
}
|
|
7344
|
-
/**
|
|
7345
|
-
* Convert to GraphQL response format
|
|
7346
|
-
* Matches JavaScript SDK toGraphQLResponse method exactly
|
|
7347
|
-
*/
|
|
7348
|
-
toGraphQLResponse() {
|
|
7349
|
-
return {
|
|
7350
|
-
id: this.id,
|
|
7351
|
-
name: this.name,
|
|
7352
|
-
metas: JSON.stringify(this.metas)
|
|
7353
|
-
};
|
|
7354
|
-
}
|
|
7355
|
-
};
|
|
7356
|
-
|
|
7357
|
-
// src/response/ResponseWalletList.ts
|
|
7358
|
-
var ResponseWalletList = class _ResponseWalletList extends Response {
|
|
7548
|
+
var ResponseWalletList = class _ResponseWalletList extends Response2 {
|
|
7359
7549
|
/**
|
|
7360
7550
|
* Class constructor
|
|
7361
7551
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -7494,7 +7684,7 @@ var QueryWalletList = class extends Query {
|
|
|
7494
7684
|
|
|
7495
7685
|
// src/response/ResponseWalletBundle.ts
|
|
7496
7686
|
init_Response();
|
|
7497
|
-
var ResponseWalletBundle = class extends
|
|
7687
|
+
var ResponseWalletBundle = class extends Response2 {
|
|
7498
7688
|
/**
|
|
7499
7689
|
* Class constructor
|
|
7500
7690
|
*/
|
|
@@ -7561,7 +7751,7 @@ var QueryWalletBundle = class extends Query {
|
|
|
7561
7751
|
|
|
7562
7752
|
// src/response/ResponseContinuId.ts
|
|
7563
7753
|
init_Response();
|
|
7564
|
-
var ResponseContinuId = class extends
|
|
7754
|
+
var ResponseContinuId = class extends Response2 {
|
|
7565
7755
|
/**
|
|
7566
7756
|
* Class constructor
|
|
7567
7757
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -7641,7 +7831,7 @@ var QueryContinuId = class extends Query {
|
|
|
7641
7831
|
|
|
7642
7832
|
// src/response/ResponseMetaType.ts
|
|
7643
7833
|
init_Response();
|
|
7644
|
-
var ResponseMetaType = class extends
|
|
7834
|
+
var ResponseMetaType = class extends Response2 {
|
|
7645
7835
|
/**
|
|
7646
7836
|
* Class constructor
|
|
7647
7837
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -7866,7 +8056,7 @@ var QueryBatch = class _QueryBatch extends Query {
|
|
|
7866
8056
|
* Matches JavaScript SDK createResponse method exactly
|
|
7867
8057
|
*/
|
|
7868
8058
|
createResponse(json) {
|
|
7869
|
-
const responseObject = new
|
|
8059
|
+
const responseObject = new Response2({
|
|
7870
8060
|
query: this,
|
|
7871
8061
|
json
|
|
7872
8062
|
});
|
|
@@ -7895,7 +8085,7 @@ var QueryBatchHistory = class extends Query {
|
|
|
7895
8085
|
* Returns a Response object
|
|
7896
8086
|
*/
|
|
7897
8087
|
createResponse(json) {
|
|
7898
|
-
const responseObject = new
|
|
8088
|
+
const responseObject = new Response2({
|
|
7899
8089
|
query: this,
|
|
7900
8090
|
json
|
|
7901
8091
|
});
|
|
@@ -7906,7 +8096,7 @@ var QueryBatchHistory = class extends Query {
|
|
|
7906
8096
|
|
|
7907
8097
|
// src/response/ResponseAtom.ts
|
|
7908
8098
|
init_Response();
|
|
7909
|
-
var ResponseAtom = class extends
|
|
8099
|
+
var ResponseAtom = class extends Response2 {
|
|
7910
8100
|
/**
|
|
7911
8101
|
* Class constructor
|
|
7912
8102
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -8147,7 +8337,7 @@ var QueryAtom = class extends Query {
|
|
|
8147
8337
|
|
|
8148
8338
|
// src/response/ResponsePolicy.ts
|
|
8149
8339
|
init_Response();
|
|
8150
|
-
var ResponsePolicy = class extends
|
|
8340
|
+
var ResponsePolicy = class extends Response2 {
|
|
8151
8341
|
/**
|
|
8152
8342
|
* Constructor
|
|
8153
8343
|
*/
|
|
@@ -8209,7 +8399,7 @@ var QueryPolicy = class extends Query {
|
|
|
8209
8399
|
|
|
8210
8400
|
// src/response/ResponseQueryActiveSession.ts
|
|
8211
8401
|
init_Response();
|
|
8212
|
-
var ResponseQueryActiveSession = class extends
|
|
8402
|
+
var ResponseQueryActiveSession = class extends Response2 {
|
|
8213
8403
|
/**
|
|
8214
8404
|
* Constructor
|
|
8215
8405
|
*/
|
|
@@ -8278,131 +8468,6 @@ var QueryActiveSession = class extends Query {
|
|
|
8278
8468
|
}
|
|
8279
8469
|
};
|
|
8280
8470
|
|
|
8281
|
-
// src/response/ResponseQueryUserActivity.ts
|
|
8282
|
-
init_Response();
|
|
8283
|
-
var ResponseQueryUserActivity = class extends Response {
|
|
8284
|
-
/**
|
|
8285
|
-
* Constructor
|
|
8286
|
-
*/
|
|
8287
|
-
constructor({
|
|
8288
|
-
query,
|
|
8289
|
-
json
|
|
8290
|
-
}) {
|
|
8291
|
-
super({
|
|
8292
|
-
query,
|
|
8293
|
-
json,
|
|
8294
|
-
dataKey: "data.UserActivity"
|
|
8295
|
-
});
|
|
8296
|
-
}
|
|
8297
|
-
/**
|
|
8298
|
-
* Returns processed user activity data
|
|
8299
|
-
*/
|
|
8300
|
-
payload() {
|
|
8301
|
-
const data = JSON.parse(JSON.stringify(this.data()));
|
|
8302
|
-
if (data.instances) {
|
|
8303
|
-
for (const datum of data.instances) {
|
|
8304
|
-
if (datum.jsonData) {
|
|
8305
|
-
datum.jsonData = JSON.parse(datum.jsonData);
|
|
8306
|
-
}
|
|
8307
|
-
}
|
|
8308
|
-
}
|
|
8309
|
-
return data;
|
|
8310
|
-
}
|
|
8311
|
-
};
|
|
8312
|
-
var QueryUserActivity = class extends Query {
|
|
8313
|
-
/**
|
|
8314
|
-
* Constructor
|
|
8315
|
-
*/
|
|
8316
|
-
constructor(graphQLClient, knishIOClient) {
|
|
8317
|
-
super(graphQLClient, knishIOClient);
|
|
8318
|
-
this.$__query = gql`
|
|
8319
|
-
query UserActivity(
|
|
8320
|
-
$bundleHash: String
|
|
8321
|
-
$metaType: String
|
|
8322
|
-
$metaId: String
|
|
8323
|
-
$ipAddress: String
|
|
8324
|
-
$browser: String
|
|
8325
|
-
$osCpu: String
|
|
8326
|
-
$resolution: String
|
|
8327
|
-
$timeZone: String
|
|
8328
|
-
$countBy: [CountByUserActivity]
|
|
8329
|
-
$interval: span
|
|
8330
|
-
) {
|
|
8331
|
-
UserActivity(
|
|
8332
|
-
bundleHash: $bundleHash
|
|
8333
|
-
metaType: $metaType
|
|
8334
|
-
metaId: $metaId
|
|
8335
|
-
ipAddress: $ipAddress
|
|
8336
|
-
browser: $browser
|
|
8337
|
-
osCpu: $osCpu
|
|
8338
|
-
resolution: $resolution
|
|
8339
|
-
timeZone: $timeZone
|
|
8340
|
-
countBy: $countBy
|
|
8341
|
-
interval: $interval
|
|
8342
|
-
) {
|
|
8343
|
-
createdAt
|
|
8344
|
-
bundleHash
|
|
8345
|
-
metaType
|
|
8346
|
-
metaId
|
|
8347
|
-
instances {
|
|
8348
|
-
bundleHash
|
|
8349
|
-
metaType
|
|
8350
|
-
metaId
|
|
8351
|
-
jsonData
|
|
8352
|
-
createdAt
|
|
8353
|
-
updatedAt
|
|
8354
|
-
}
|
|
8355
|
-
instanceCount {
|
|
8356
|
-
...SubFields
|
|
8357
|
-
...Recursive
|
|
8358
|
-
}
|
|
8359
|
-
}
|
|
8360
|
-
}
|
|
8361
|
-
|
|
8362
|
-
fragment SubFields on InstanceCountType {
|
|
8363
|
-
id
|
|
8364
|
-
count
|
|
8365
|
-
}
|
|
8366
|
-
|
|
8367
|
-
fragment Recursive on InstanceCountType {
|
|
8368
|
-
instances {
|
|
8369
|
-
...SubFields
|
|
8370
|
-
instances {
|
|
8371
|
-
...SubFields
|
|
8372
|
-
instances {
|
|
8373
|
-
...SubFields
|
|
8374
|
-
instances {
|
|
8375
|
-
...SubFields
|
|
8376
|
-
instances {
|
|
8377
|
-
...SubFields
|
|
8378
|
-
instances {
|
|
8379
|
-
...SubFields
|
|
8380
|
-
instances {
|
|
8381
|
-
...SubFields
|
|
8382
|
-
instances {
|
|
8383
|
-
...SubFields
|
|
8384
|
-
}
|
|
8385
|
-
}
|
|
8386
|
-
}
|
|
8387
|
-
}
|
|
8388
|
-
}
|
|
8389
|
-
}
|
|
8390
|
-
}
|
|
8391
|
-
}
|
|
8392
|
-
}
|
|
8393
|
-
`;
|
|
8394
|
-
}
|
|
8395
|
-
/**
|
|
8396
|
-
* Returns a Response object
|
|
8397
|
-
*/
|
|
8398
|
-
createResponse(json) {
|
|
8399
|
-
return new ResponseQueryUserActivity({
|
|
8400
|
-
query: this,
|
|
8401
|
-
json
|
|
8402
|
-
});
|
|
8403
|
-
}
|
|
8404
|
-
};
|
|
8405
|
-
|
|
8406
8471
|
// src/query/QueryToken.ts
|
|
8407
8472
|
init_Response();
|
|
8408
8473
|
var QueryToken = class extends Query {
|
|
@@ -8429,7 +8494,7 @@ var QueryToken = class extends Query {
|
|
|
8429
8494
|
* Creates a Response object
|
|
8430
8495
|
*/
|
|
8431
8496
|
createResponse(json) {
|
|
8432
|
-
return new
|
|
8497
|
+
return new Response2({
|
|
8433
8498
|
query: this,
|
|
8434
8499
|
json,
|
|
8435
8500
|
dataKey: "data.Token"
|
|
@@ -8439,7 +8504,7 @@ var QueryToken = class extends Query {
|
|
|
8439
8504
|
|
|
8440
8505
|
// src/response/ResponseMetaTypeViaAtom.ts
|
|
8441
8506
|
init_Response();
|
|
8442
|
-
var ResponseMetaTypeViaAtom = class extends
|
|
8507
|
+
var ResponseMetaTypeViaAtom = class extends Response2 {
|
|
8443
8508
|
/**
|
|
8444
8509
|
* Class constructor
|
|
8445
8510
|
* Matches JavaScript SDK constructor signature exactly
|
|
@@ -8597,7 +8662,7 @@ var QueryMetaTypeViaAtom = class extends Query {
|
|
|
8597
8662
|
|
|
8598
8663
|
// src/response/ResponseMetaTypeViaMolecule.ts
|
|
8599
8664
|
init_Response();
|
|
8600
|
-
var ResponseMetaTypeViaMolecule = class _ResponseMetaTypeViaMolecule extends
|
|
8665
|
+
var ResponseMetaTypeViaMolecule = class _ResponseMetaTypeViaMolecule extends Response2 {
|
|
8601
8666
|
/**
|
|
8602
8667
|
* Class constructor
|
|
8603
8668
|
*/
|
|
@@ -8843,7 +8908,7 @@ var QueryMetaTypeViaMolecule = class extends Query {
|
|
|
8843
8908
|
|
|
8844
8909
|
// src/response/ResponseEmbeddingStatus.ts
|
|
8845
8910
|
init_Response();
|
|
8846
|
-
var ResponseEmbeddingStatus = class extends
|
|
8911
|
+
var ResponseEmbeddingStatus = class extends Response2 {
|
|
8847
8912
|
/**
|
|
8848
8913
|
* Class constructor
|
|
8849
8914
|
*/
|
|
@@ -8926,7 +8991,7 @@ init_Dot();
|
|
|
8926
8991
|
init_MolecularHashMismatchException();
|
|
8927
8992
|
init_SignatureMismatchException();
|
|
8928
8993
|
init_AtomIndexException();
|
|
8929
|
-
var ResponseProposeMolecule = class extends
|
|
8994
|
+
var ResponseProposeMolecule = class extends Response2 {
|
|
8930
8995
|
$__clientMolecule;
|
|
8931
8996
|
/**
|
|
8932
8997
|
* Class constructor
|
|
@@ -9236,6 +9301,20 @@ var MutationTransferTokens = class extends MutationProposeMolecule {
|
|
|
9236
9301
|
this.$__molecule.sign({});
|
|
9237
9302
|
this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
9238
9303
|
}
|
|
9304
|
+
/**
|
|
9305
|
+
* Fills the Molecule for a MULTI-recipient transfer (one source funds N recipients)
|
|
9306
|
+
*/
|
|
9307
|
+
fillMoleculeMulti({
|
|
9308
|
+
recipientWallets,
|
|
9309
|
+
amounts
|
|
9310
|
+
}) {
|
|
9311
|
+
this.$__molecule.initValues({
|
|
9312
|
+
recipientWallets,
|
|
9313
|
+
amounts
|
|
9314
|
+
});
|
|
9315
|
+
this.$__molecule.sign({});
|
|
9316
|
+
this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
9317
|
+
}
|
|
9239
9318
|
/**
|
|
9240
9319
|
* Builds a Response object out of a JSON object
|
|
9241
9320
|
* Matches JavaScript SDK createResponse method signature exactly
|
|
@@ -9296,7 +9375,8 @@ var MutationClaimShadowWallet = class extends MutationProposeMolecule {
|
|
|
9296
9375
|
bundle: this.$__molecule.bundle,
|
|
9297
9376
|
token,
|
|
9298
9377
|
batchId
|
|
9299
|
-
})
|
|
9378
|
+
});
|
|
9379
|
+
this.$__molecule.initShadowWalletClaim(wallet);
|
|
9300
9380
|
this.$__molecule.sign({});
|
|
9301
9381
|
this.$__molecule.check();
|
|
9302
9382
|
}
|
|
@@ -9422,7 +9502,7 @@ var MutationCreateIdentifier = class extends MutationProposeMolecule {
|
|
|
9422
9502
|
|
|
9423
9503
|
// src/response/ResponseActiveSession.ts
|
|
9424
9504
|
init_Response();
|
|
9425
|
-
var ResponseActiveSession = class extends
|
|
9505
|
+
var ResponseActiveSession = class extends Response2 {
|
|
9426
9506
|
/**
|
|
9427
9507
|
* Constructor
|
|
9428
9508
|
*/
|
|
@@ -9613,7 +9693,7 @@ var MutationRequestAuthorization = class extends MutationProposeMolecule {
|
|
|
9613
9693
|
init_Response();
|
|
9614
9694
|
init_Dot();
|
|
9615
9695
|
init_exception();
|
|
9616
|
-
var ResponseRequestAuthorizationGuest = class extends
|
|
9696
|
+
var ResponseRequestAuthorizationGuest = class extends Response2 {
|
|
9617
9697
|
/**
|
|
9618
9698
|
* Constructor
|
|
9619
9699
|
*/
|
|
@@ -9729,7 +9809,7 @@ var MutationRequestAuthorizationGuest = class extends Mutation {
|
|
|
9729
9809
|
// src/response/ResponseLinkIdentifier.ts
|
|
9730
9810
|
init_Response();
|
|
9731
9811
|
init_Dot();
|
|
9732
|
-
var ResponseLinkIdentifier = class extends
|
|
9812
|
+
var ResponseLinkIdentifier = class extends Response2 {
|
|
9733
9813
|
/**
|
|
9734
9814
|
* Constructor
|
|
9735
9815
|
*/
|
|
@@ -10542,6 +10622,75 @@ var KnishIOClient = class {
|
|
|
10542
10622
|
});
|
|
10543
10623
|
return await this.executeQuery(query);
|
|
10544
10624
|
}
|
|
10625
|
+
/**
|
|
10626
|
+
* Fund N recipients from a single source in ONE molecule (multi-recipient sibling of
|
|
10627
|
+
* transferToken). Each recipient gets its own subset of stackable units (or a fungible
|
|
10628
|
+
* amount); a remainder returns the rest to the sender. Conserves:
|
|
10629
|
+
* -balance + Σamounts + (balance - Σ) === 0.
|
|
10630
|
+
*
|
|
10631
|
+
* @param token - token slug
|
|
10632
|
+
* @param recipients - destinations (bundleHash + units OR amount + optional batchId)
|
|
10633
|
+
* @param sourceWallet - optional pre-resolved source (defaults to the client's own wallet)
|
|
10634
|
+
*/
|
|
10635
|
+
async transferTokens({
|
|
10636
|
+
token,
|
|
10637
|
+
recipients,
|
|
10638
|
+
sourceWallet = null
|
|
10639
|
+
}) {
|
|
10640
|
+
const amounts = recipients.map((recipient) => {
|
|
10641
|
+
const unitCount = recipient.units ? recipient.units.length : 0;
|
|
10642
|
+
if (unitCount > 0) {
|
|
10643
|
+
if (recipient.amount !== null && recipient.amount !== void 0 && recipient.amount > 0) {
|
|
10644
|
+
throw new StackableUnitAmountException_default();
|
|
10645
|
+
}
|
|
10646
|
+
return unitCount;
|
|
10647
|
+
}
|
|
10648
|
+
return recipient.amount ?? 0;
|
|
10649
|
+
});
|
|
10650
|
+
const total = amounts.reduce((sum, amount) => sum + amount, 0);
|
|
10651
|
+
if (sourceWallet === null) {
|
|
10652
|
+
sourceWallet = await this.querySourceWallet({
|
|
10653
|
+
token,
|
|
10654
|
+
amount: total
|
|
10655
|
+
});
|
|
10656
|
+
}
|
|
10657
|
+
if (sourceWallet === null || Decimal.cmp(Number(sourceWallet.balance), total) < 0) {
|
|
10658
|
+
throw new TransferBalanceException();
|
|
10659
|
+
}
|
|
10660
|
+
const recipientWallets = recipients.map((recipient) => {
|
|
10661
|
+
const recipientWallet = Wallet.create({
|
|
10662
|
+
bundle: recipient.bundleHash,
|
|
10663
|
+
token
|
|
10664
|
+
});
|
|
10665
|
+
if (recipient.batchId !== null && recipient.batchId !== void 0) {
|
|
10666
|
+
recipientWallet.batchId = recipient.batchId;
|
|
10667
|
+
} else {
|
|
10668
|
+
recipientWallet.initBatchId({ sourceWallet });
|
|
10669
|
+
}
|
|
10670
|
+
return recipientWallet;
|
|
10671
|
+
});
|
|
10672
|
+
const remainderWallet = sourceWallet.createRemainder(this.getSecret());
|
|
10673
|
+
if (recipients.some((recipient) => recipient.units && recipient.units.length > 0)) {
|
|
10674
|
+
sourceWallet.splitUnitsMulti(
|
|
10675
|
+
recipients.map((recipient) => recipient.units ?? []),
|
|
10676
|
+
recipientWallets,
|
|
10677
|
+
remainderWallet
|
|
10678
|
+
);
|
|
10679
|
+
}
|
|
10680
|
+
const molecule = await this.createMolecule({
|
|
10681
|
+
sourceWallet,
|
|
10682
|
+
remainderWallet
|
|
10683
|
+
});
|
|
10684
|
+
const query = await this.createMoleculeMutation({
|
|
10685
|
+
mutationClass: MutationTransferTokens,
|
|
10686
|
+
molecule
|
|
10687
|
+
});
|
|
10688
|
+
query.fillMoleculeMulti({
|
|
10689
|
+
recipientWallets,
|
|
10690
|
+
amounts
|
|
10691
|
+
});
|
|
10692
|
+
return await this.executeQuery(query);
|
|
10693
|
+
}
|
|
10545
10694
|
/**
|
|
10546
10695
|
* Request authorization token (guest or profile)
|
|
10547
10696
|
*
|
|
@@ -10998,36 +11147,6 @@ var KnishIOClient = class {
|
|
|
10998
11147
|
metaId
|
|
10999
11148
|
});
|
|
11000
11149
|
}
|
|
11001
|
-
/**
|
|
11002
|
-
* Query user activity
|
|
11003
|
-
*/
|
|
11004
|
-
async queryUserActivity({
|
|
11005
|
-
bundleHash,
|
|
11006
|
-
metaType,
|
|
11007
|
-
metaId,
|
|
11008
|
-
ipAddress = null,
|
|
11009
|
-
browser = null,
|
|
11010
|
-
osCpu = null,
|
|
11011
|
-
resolution = null,
|
|
11012
|
-
timeZone = null,
|
|
11013
|
-
countBy = null,
|
|
11014
|
-
interval = null
|
|
11015
|
-
}) {
|
|
11016
|
-
const query = this.createQuery(QueryUserActivity);
|
|
11017
|
-
const variables = {
|
|
11018
|
-
bundleHash,
|
|
11019
|
-
metaType,
|
|
11020
|
-
metaId
|
|
11021
|
-
};
|
|
11022
|
-
if (ipAddress !== null) variables.ipAddress = ipAddress;
|
|
11023
|
-
if (browser !== null) variables.browser = browser;
|
|
11024
|
-
if (osCpu !== null) variables.osCpu = osCpu;
|
|
11025
|
-
if (resolution !== null) variables.resolution = resolution;
|
|
11026
|
-
if (timeZone !== null) variables.timeZone = timeZone;
|
|
11027
|
-
if (countBy !== null) variables.countBy = countBy;
|
|
11028
|
-
if (interval !== null) variables.interval = interval;
|
|
11029
|
-
return this.executeQuery(query, variables);
|
|
11030
|
-
}
|
|
11031
11150
|
/**
|
|
11032
11151
|
* Query token information
|
|
11033
11152
|
*/
|
|
@@ -11136,9 +11255,27 @@ var KnishIOClient = class {
|
|
|
11136
11255
|
amount = null,
|
|
11137
11256
|
meta = null,
|
|
11138
11257
|
batchId = null,
|
|
11139
|
-
units
|
|
11258
|
+
units = null
|
|
11140
11259
|
}) {
|
|
11141
11260
|
this.log("info", `KnishIOClient::createToken() - Creating token ${token}...`);
|
|
11261
|
+
const tokenMeta = meta || {};
|
|
11262
|
+
const fungibility = tokenMeta.fungibility;
|
|
11263
|
+
let resolvedAmount = amount ?? 0;
|
|
11264
|
+
if (fungibility === "stackable") {
|
|
11265
|
+
tokenMeta.batchId = batchId || generateBatchId({});
|
|
11266
|
+
}
|
|
11267
|
+
if ((fungibility === "stackable" || fungibility === "nonfungible" || fungibility === "non-fungible") && units && units.length > 0) {
|
|
11268
|
+
if (Number(tokenMeta.decimals ?? 0) > 0) {
|
|
11269
|
+
throw new StackableUnitDecimalsException_default();
|
|
11270
|
+
}
|
|
11271
|
+
if (Number(amount ?? 0) > 0) {
|
|
11272
|
+
throw new StackableUnitAmountException_default();
|
|
11273
|
+
}
|
|
11274
|
+
resolvedAmount = units.length;
|
|
11275
|
+
tokenMeta.splittable = "1";
|
|
11276
|
+
tokenMeta.decimals = "0";
|
|
11277
|
+
tokenMeta.tokenUnits = JSON.stringify(units);
|
|
11278
|
+
}
|
|
11142
11279
|
const mutation = await this.createMoleculeMutation({ mutationClass: MutationCreateToken });
|
|
11143
11280
|
const recipientWallet = new Wallet({
|
|
11144
11281
|
secret: this.getSecret(),
|
|
@@ -11148,8 +11285,8 @@ var KnishIOClient = class {
|
|
|
11148
11285
|
});
|
|
11149
11286
|
await mutation.fillMolecule({
|
|
11150
11287
|
recipientWallet,
|
|
11151
|
-
amount:
|
|
11152
|
-
meta
|
|
11288
|
+
amount: resolvedAmount,
|
|
11289
|
+
meta: tokenMeta
|
|
11153
11290
|
});
|
|
11154
11291
|
const response = await this.executeQuery(mutation);
|
|
11155
11292
|
if (!response) {
|
|
@@ -11590,8 +11727,12 @@ var KnishIOClient = class {
|
|
|
11590
11727
|
mutationClass: MutationRequestAuthorization,
|
|
11591
11728
|
molecule
|
|
11592
11729
|
});
|
|
11730
|
+
const authMeta = { encrypt: encrypt ? "true" : "false" };
|
|
11731
|
+
if (wallet.pubkey) {
|
|
11732
|
+
authMeta.walletPubkey = wallet.pubkey;
|
|
11733
|
+
}
|
|
11593
11734
|
mutation.fillMolecule({
|
|
11594
|
-
meta:
|
|
11735
|
+
meta: authMeta
|
|
11595
11736
|
});
|
|
11596
11737
|
const response = await this.executeQuery(mutation);
|
|
11597
11738
|
if (!response) {
|
|
@@ -11843,6 +11984,6 @@ var KnishIO = {
|
|
|
11843
11984
|
SDK_INFO
|
|
11844
11985
|
};
|
|
11845
11986
|
|
|
11846
|
-
export { Atom, AtomIndexException, AtomMeta, AtomsMissingException, AuthToken, BaseException, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, CheckMolecule, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, ExceptionFactory, GraphQLClient, InvalidResponseException, KnishIO, KnishIOClient, Meta, MolecularHashMismatchException, Molecule, Mutation, MutationAppendRequest, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, MutationPeering, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, QueryWalletBundle, QueryWalletList, Response, ResponseAppendRequest, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseEmbeddingStatus, ResponseMetaType, ResponseMetaTypeViaAtom, ResponsePeering, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, SDK_INFO, SDK_NAME, SDK_VERSION, SignatureMismatchException, TokenUnit, TransferBalanceException, Wallet, WalletCredentialException, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, convertToBase17, createBundleHash, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition2 as isPosition, isWalletAddress2 as isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature };
|
|
11987
|
+
export { Atom, AtomIndexException, AtomMeta, AtomsMissingException, AuthToken, BaseException, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, CheckMolecule, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, ExceptionFactory, GraphQLClient, InvalidResponseException, KnishIO, KnishIOClient, Meta, MolecularHashMismatchException, Molecule, Mutation, MutationAppendRequest, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, MutationPeering, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, QueryWalletBundle, QueryWalletList, Response2 as Response, ResponseAppendRequest, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseEmbeddingStatus, ResponseMetaType, ResponseMetaTypeViaAtom, ResponsePeering, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, SDK_INFO, SDK_NAME, SDK_VERSION, SignatureMismatchException, TokenUnit, TransferBalanceException, Wallet, WalletCredentialException, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, convertToBase17, createBundleHash, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition2 as isPosition, isWalletAddress2 as isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature };
|
|
11847
11988
|
//# sourceMappingURL=index.js.map
|
|
11848
11989
|
//# sourceMappingURL=index.js.map
|