@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.d.cts CHANGED
@@ -652,15 +652,17 @@ declare class Molecule {
652
652
  remainderWallet: Wallet | null;
653
653
  atoms: Atom[];
654
654
  version: string | null | undefined;
655
+ continuIdPosition: string | null;
655
656
  parentHashes: string[];
656
657
  local?: number;
657
- constructor({ secret, bundle, sourceWallet, remainderWallet, cellSlug, version }?: {
658
+ constructor({ secret, bundle, sourceWallet, remainderWallet, cellSlug, version, continuIdPosition }?: {
658
659
  secret?: string | null;
659
660
  bundle?: string | null;
660
661
  sourceWallet?: Wallet | null;
661
662
  remainderWallet?: Wallet | null;
662
663
  cellSlug?: string | null;
663
664
  version?: string | number | null;
665
+ continuIdPosition?: string | null;
664
666
  });
665
667
  get cellSlugDelimiter(): string;
666
668
  getIsotopes(isotopes: AtomIsotope | AtomIsotope[]): Atom[];
package/dist/index.d.ts CHANGED
@@ -652,15 +652,17 @@ declare class Molecule {
652
652
  remainderWallet: Wallet | null;
653
653
  atoms: Atom[];
654
654
  version: string | null | undefined;
655
+ continuIdPosition: string | null;
655
656
  parentHashes: string[];
656
657
  local?: number;
657
- constructor({ secret, bundle, sourceWallet, remainderWallet, cellSlug, version }?: {
658
+ constructor({ secret, bundle, sourceWallet, remainderWallet, cellSlug, version, continuIdPosition }?: {
658
659
  secret?: string | null;
659
660
  bundle?: string | null;
660
661
  sourceWallet?: Wallet | null;
661
662
  remainderWallet?: Wallet | null;
662
663
  cellSlug?: string | null;
663
664
  version?: string | number | null;
665
+ continuIdPosition?: string | null;
664
666
  });
665
667
  get cellSlugDelimiter(): string;
666
668
  getIsotopes(isotopes: AtomIsotope | AtomIsotope[]): Atom[];
@@ -25043,6 +25043,7 @@ ${operationTypes.join("\n")}
25043
25043
  remainderWallet;
25044
25044
  atoms;
25045
25045
  version;
25046
+ continuIdPosition;
25046
25047
  parentHashes;
25047
25048
  local;
25048
25049
  /**
@@ -25055,7 +25056,8 @@ ${operationTypes.join("\n")}
25055
25056
  sourceWallet = null,
25056
25057
  remainderWallet = null,
25057
25058
  cellSlug = null,
25058
- version: version2 = null
25059
+ version: version2 = null,
25060
+ continuIdPosition = null
25059
25061
  } = {}) {
25060
25062
  this.status = null;
25061
25063
  this.molecularHash = null;
@@ -25064,6 +25066,7 @@ ${operationTypes.join("\n")}
25064
25066
  this.secret = secret;
25065
25067
  this.bundle = bundle;
25066
25068
  this.sourceWallet = sourceWallet;
25069
+ this.continuIdPosition = continuIdPosition;
25067
25070
  this.atoms = [];
25068
25071
  this.parentHashes = [];
25069
25072
  const versionRegistry = versions_default;
@@ -25141,7 +25144,9 @@ ${operationTypes.join("\n")}
25141
25144
  });
25142
25145
  }
25143
25146
  const continuIdMeta = {};
25144
- if (this.sourceWallet && this.sourceWallet.position) {
25147
+ if (this.continuIdPosition) {
25148
+ continuIdMeta.previousPosition = this.continuIdPosition;
25149
+ } else if (this.sourceWallet && this.sourceWallet.position) {
25145
25150
  continuIdMeta.previousPosition = this.sourceWallet.position;
25146
25151
  }
25147
25152
  if (this.remainderWallet.pubkey) {
@@ -25485,10 +25490,21 @@ ${operationTypes.join("\n")}
25485
25490
  if (Number(this.sourceWallet.balance) - amount < 0) {
25486
25491
  throw new BalanceInsufficientException();
25487
25492
  }
25493
+ const burnWallet = new Wallet({
25494
+ bundle: "0000000000000000000000000000000000000000000000000000000000000000",
25495
+ token: this.sourceWallet.token
25496
+ });
25488
25497
  this.addAtom(Atom.create({
25489
25498
  isotope: "V",
25490
25499
  wallet: this.sourceWallet,
25491
- value: -amount
25500
+ value: -Number(this.sourceWallet.balance)
25501
+ }));
25502
+ this.addAtom(Atom.create({
25503
+ isotope: "V",
25504
+ wallet: burnWallet,
25505
+ value: amount,
25506
+ metaType: "walletBundle",
25507
+ metaId: burnWallet.bundle
25492
25508
  }));
25493
25509
  this.addAtom(Atom.create({
25494
25510
  isotope: "V",
@@ -32845,6 +32861,17 @@ ${operationTypes.join("\n")}
32845
32861
  this.log("info", "KnishIOClient::createMolecule() - Creating a new molecule...");
32846
32862
  secret = secret || this.getSecret();
32847
32863
  bundle = bundle || this.getBundle();
32864
+ let continuIdPosition = null;
32865
+ if (sourceWallet && sourceWallet.token !== "USER") {
32866
+ if (this.lastMoleculeQuery && this.getRemainderWallet() && this.getRemainderWallet()?.token === "USER" && this.lastMoleculeQuery.response() && this.lastMoleculeQuery.response()?.success()) {
32867
+ continuIdPosition = this.getRemainderWallet()?.position || null;
32868
+ this.log("info", `KnishIOClient::createMolecule() - Captured USER ContinuID position ${continuIdPosition?.substring(0, 16)}... for non-USER source wallet`);
32869
+ } else {
32870
+ const userWallet = await this.getSourceWallet();
32871
+ continuIdPosition = userWallet?.position || null;
32872
+ this.log("info", `KnishIOClient::createMolecule() - Queried USER ContinuID position ${continuIdPosition?.substring(0, 16)}... for non-USER source wallet`);
32873
+ }
32874
+ }
32848
32875
  if (!sourceWallet && this.lastMoleculeQuery && this.getRemainderWallet()?.token === "USER" && this.lastMoleculeQuery.response() && this.lastMoleculeQuery.response()?.success()) {
32849
32876
  sourceWallet = this.getRemainderWallet();
32850
32877
  this.log("info", `KnishIOClient::createMolecule() - Using carry-forward remainder wallet at position ${sourceWallet?.position?.substring(0, 16)}...`);
@@ -32864,7 +32891,8 @@ ${operationTypes.join("\n")}
32864
32891
  sourceWallet,
32865
32892
  remainderWallet: this.getRemainderWallet(),
32866
32893
  cellSlug: this.getCellSlug(),
32867
- version: this.getServerSdkVersion()
32894
+ version: this.getServerSdkVersion(),
32895
+ continuIdPosition
32868
32896
  });
32869
32897
  }
32870
32898
  /**
@@ -33595,8 +33623,10 @@ ${operationTypes.join("\n")}
33595
33623
  amount: amount || 0
33596
33624
  });
33597
33625
  }
33626
+ const remainderWallet = sourceWallet.createRemainder(this.getSecret());
33598
33627
  const molecule = await this.createMolecule({
33599
- sourceWallet
33628
+ sourceWallet,
33629
+ remainderWallet
33600
33630
  });
33601
33631
  const mutation = await this.createMoleculeMutation({
33602
33632
  mutationClass: MutationTransferTokens,
@@ -33892,7 +33922,15 @@ ${operationTypes.join("\n")}
33892
33922
  amount
33893
33923
  });
33894
33924
  }
33895
- const mutation = await this.createMoleculeMutation({ mutationClass: MutationDepositBufferToken });
33925
+ const remainderWallet = sourceWallet.createRemainder(this.getSecret());
33926
+ const molecule = await this.createMolecule({
33927
+ sourceWallet,
33928
+ remainderWallet
33929
+ });
33930
+ const mutation = await this.createMoleculeMutation({
33931
+ mutationClass: MutationDepositBufferToken,
33932
+ molecule
33933
+ });
33896
33934
  await mutation.fillMolecule({
33897
33935
  amount: typeof amount === "string" ? Number(amount) : amount,
33898
33936
  tradeRates