@wishknish/knishio-client-ts 0.7.6 → 0.7.7
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 +44 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.iife.js +44 -6
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +44 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/KnishIOClient.ts +43 -4
- package/src/core/Molecule.ts +30 -6
package/dist/index.cjs
CHANGED
|
@@ -4809,6 +4809,7 @@ var Molecule = class _Molecule {
|
|
|
4809
4809
|
remainderWallet;
|
|
4810
4810
|
atoms;
|
|
4811
4811
|
version;
|
|
4812
|
+
continuIdPosition;
|
|
4812
4813
|
parentHashes;
|
|
4813
4814
|
local;
|
|
4814
4815
|
/**
|
|
@@ -4821,7 +4822,8 @@ var Molecule = class _Molecule {
|
|
|
4821
4822
|
sourceWallet = null,
|
|
4822
4823
|
remainderWallet = null,
|
|
4823
4824
|
cellSlug = null,
|
|
4824
|
-
version = null
|
|
4825
|
+
version = null,
|
|
4826
|
+
continuIdPosition = null
|
|
4825
4827
|
} = {}) {
|
|
4826
4828
|
this.status = null;
|
|
4827
4829
|
this.molecularHash = null;
|
|
@@ -4830,6 +4832,7 @@ var Molecule = class _Molecule {
|
|
|
4830
4832
|
this.secret = secret;
|
|
4831
4833
|
this.bundle = bundle;
|
|
4832
4834
|
this.sourceWallet = sourceWallet;
|
|
4835
|
+
this.continuIdPosition = continuIdPosition;
|
|
4833
4836
|
this.atoms = [];
|
|
4834
4837
|
this.parentHashes = [];
|
|
4835
4838
|
const versionRegistry = versions_default;
|
|
@@ -4907,7 +4910,9 @@ var Molecule = class _Molecule {
|
|
|
4907
4910
|
});
|
|
4908
4911
|
}
|
|
4909
4912
|
const continuIdMeta = {};
|
|
4910
|
-
if (this.
|
|
4913
|
+
if (this.continuIdPosition) {
|
|
4914
|
+
continuIdMeta.previousPosition = this.continuIdPosition;
|
|
4915
|
+
} else if (this.sourceWallet && this.sourceWallet.position) {
|
|
4911
4916
|
continuIdMeta.previousPosition = this.sourceWallet.position;
|
|
4912
4917
|
}
|
|
4913
4918
|
if (this.remainderWallet.pubkey) {
|
|
@@ -5251,10 +5256,21 @@ var Molecule = class _Molecule {
|
|
|
5251
5256
|
if (Number(this.sourceWallet.balance) - amount < 0) {
|
|
5252
5257
|
throw new BalanceInsufficientException();
|
|
5253
5258
|
}
|
|
5259
|
+
const burnWallet = new Wallet({
|
|
5260
|
+
bundle: "0000000000000000000000000000000000000000000000000000000000000000",
|
|
5261
|
+
token: this.sourceWallet.token
|
|
5262
|
+
});
|
|
5254
5263
|
this.addAtom(Atom.create({
|
|
5255
5264
|
isotope: "V",
|
|
5256
5265
|
wallet: this.sourceWallet,
|
|
5257
|
-
value: -
|
|
5266
|
+
value: -Number(this.sourceWallet.balance)
|
|
5267
|
+
}));
|
|
5268
|
+
this.addAtom(Atom.create({
|
|
5269
|
+
isotope: "V",
|
|
5270
|
+
wallet: burnWallet,
|
|
5271
|
+
value: amount,
|
|
5272
|
+
metaType: "walletBundle",
|
|
5273
|
+
metaId: burnWallet.bundle
|
|
5258
5274
|
}));
|
|
5259
5275
|
this.addAtom(Atom.create({
|
|
5260
5276
|
isotope: "V",
|
|
@@ -10144,6 +10160,17 @@ var KnishIOClient = class {
|
|
|
10144
10160
|
this.log("info", "KnishIOClient::createMolecule() - Creating a new molecule...");
|
|
10145
10161
|
secret = secret || this.getSecret();
|
|
10146
10162
|
bundle = bundle || this.getBundle();
|
|
10163
|
+
let continuIdPosition = null;
|
|
10164
|
+
if (sourceWallet && sourceWallet.token !== "USER") {
|
|
10165
|
+
if (this.lastMoleculeQuery && this.getRemainderWallet() && this.getRemainderWallet()?.token === "USER" && this.lastMoleculeQuery.response() && this.lastMoleculeQuery.response()?.success()) {
|
|
10166
|
+
continuIdPosition = this.getRemainderWallet()?.position || null;
|
|
10167
|
+
this.log("info", `KnishIOClient::createMolecule() - Captured USER ContinuID position ${continuIdPosition?.substring(0, 16)}... for non-USER source wallet`);
|
|
10168
|
+
} else {
|
|
10169
|
+
const userWallet = await this.getSourceWallet();
|
|
10170
|
+
continuIdPosition = userWallet?.position || null;
|
|
10171
|
+
this.log("info", `KnishIOClient::createMolecule() - Queried USER ContinuID position ${continuIdPosition?.substring(0, 16)}... for non-USER source wallet`);
|
|
10172
|
+
}
|
|
10173
|
+
}
|
|
10147
10174
|
if (!sourceWallet && this.lastMoleculeQuery && this.getRemainderWallet()?.token === "USER" && this.lastMoleculeQuery.response() && this.lastMoleculeQuery.response()?.success()) {
|
|
10148
10175
|
sourceWallet = this.getRemainderWallet();
|
|
10149
10176
|
this.log("info", `KnishIOClient::createMolecule() - Using carry-forward remainder wallet at position ${sourceWallet?.position?.substring(0, 16)}...`);
|
|
@@ -10163,7 +10190,8 @@ var KnishIOClient = class {
|
|
|
10163
10190
|
sourceWallet,
|
|
10164
10191
|
remainderWallet: this.getRemainderWallet(),
|
|
10165
10192
|
cellSlug: this.getCellSlug(),
|
|
10166
|
-
version: this.getServerSdkVersion()
|
|
10193
|
+
version: this.getServerSdkVersion(),
|
|
10194
|
+
continuIdPosition
|
|
10167
10195
|
});
|
|
10168
10196
|
}
|
|
10169
10197
|
/**
|
|
@@ -10894,8 +10922,10 @@ var KnishIOClient = class {
|
|
|
10894
10922
|
amount: amount || 0
|
|
10895
10923
|
});
|
|
10896
10924
|
}
|
|
10925
|
+
const remainderWallet = sourceWallet.createRemainder(this.getSecret());
|
|
10897
10926
|
const molecule = await this.createMolecule({
|
|
10898
|
-
sourceWallet
|
|
10927
|
+
sourceWallet,
|
|
10928
|
+
remainderWallet
|
|
10899
10929
|
});
|
|
10900
10930
|
const mutation = await this.createMoleculeMutation({
|
|
10901
10931
|
mutationClass: MutationTransferTokens,
|
|
@@ -11191,7 +11221,15 @@ var KnishIOClient = class {
|
|
|
11191
11221
|
amount
|
|
11192
11222
|
});
|
|
11193
11223
|
}
|
|
11194
|
-
const
|
|
11224
|
+
const remainderWallet = sourceWallet.createRemainder(this.getSecret());
|
|
11225
|
+
const molecule = await this.createMolecule({
|
|
11226
|
+
sourceWallet,
|
|
11227
|
+
remainderWallet
|
|
11228
|
+
});
|
|
11229
|
+
const mutation = await this.createMoleculeMutation({
|
|
11230
|
+
mutationClass: MutationDepositBufferToken,
|
|
11231
|
+
molecule
|
|
11232
|
+
});
|
|
11195
11233
|
await mutation.fillMolecule({
|
|
11196
11234
|
amount: typeof amount === "string" ? Number(amount) : amount,
|
|
11197
11235
|
tradeRates
|