@indigo-labs/indigo-sdk 0.5.15 → 0.5.16

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.js CHANGED
@@ -10718,15 +10718,19 @@ async function initPyth(lucid) {
10718
10718
  alwaysSucceedValidator
10719
10719
  )
10720
10720
  );
10721
- await runAndAwaitTxBuilder(
10722
- lucid,
10723
- lucid.newTx().register.Stake(
10724
- (0, import_lucid63.credentialToRewardAddress)(lucid.config().network, {
10725
- hash: (0, import_lucid63.validatorToScriptHash)(alwaysSucceedValidator),
10726
- type: "Script"
10727
- })
10728
- )
10721
+ const alwaysSucceedRewardAddress = (0, import_lucid63.credentialToRewardAddress)(
10722
+ lucid.config().network,
10723
+ { hash: (0, import_lucid63.validatorToScriptHash)(alwaysSucceedValidator), type: "Script" }
10724
+ );
10725
+ const { registered } = await lucid.rewardAccountAt(
10726
+ alwaysSucceedRewardAddress
10729
10727
  );
10728
+ if (!registered) {
10729
+ await runAndAwaitTxBuilder(
10730
+ lucid,
10731
+ lucid.newTx().register.Stake(alwaysSucceedRewardAddress)
10732
+ );
10733
+ }
10730
10734
  return pythStateAsset;
10731
10735
  }
10732
10736
 
@@ -10751,23 +10755,18 @@ async function initPythConfig(lucid, initialAssets, pythStateAsset) {
10751
10755
  lucid,
10752
10756
  pythFeedValidator
10753
10757
  );
10754
- try {
10758
+ const pythFeedRewardAddress = (0, import_lucid64.credentialToRewardAddress)(
10759
+ lucid.config().network,
10760
+ { hash: (0, import_lucid64.validatorToScriptHash)(pythFeedValidator), type: "Script" }
10761
+ );
10762
+ const { registered } = await lucid.rewardAccountAt(
10763
+ pythFeedRewardAddress
10764
+ );
10765
+ if (!registered) {
10755
10766
  await runAndAwaitTxBuilder(
10756
10767
  lucid,
10757
- lucid.newTx().register.Stake(
10758
- (0, import_lucid64.credentialToRewardAddress)(lucid.config().network, {
10759
- hash: (0, import_lucid64.validatorToScriptHash)(pythFeedValidator),
10760
- type: "Script"
10761
- })
10762
- )
10768
+ lucid.newTx().register.Stake(pythFeedRewardAddress)
10763
10769
  );
10764
- } catch (error) {
10765
- const message = error instanceof Error ? error.message : String(error);
10766
- if (!message.includes("StakeKeyRegisteredDELEG") && !message.includes(
10767
- "Trying to re-register some already known credentials."
10768
- )) {
10769
- throw error;
10770
- }
10771
10770
  }
10772
10771
  const key = `${asset.name}/${(0, import_lucid64.toHex)(collateral.collateralAsset.currencySymbol)}.${(0, import_lucid64.toHex)(collateral.collateralAsset.tokenName)}`;
10773
10772
  return {
@@ -10958,16 +10957,12 @@ async function init(lucid, defaultInitialAssets, mkPythBasedAssets = () => [], p
10958
10957
  lucid.config().network,
10959
10958
  (0, import_lucid64.scriptHashToCredential)(cdpRedeemValHash)
10960
10959
  );
10961
- try {
10960
+ const { registered: cdpRedeemRegistered } = await lucid.rewardAccountAt(cdpRedeemRewardAddr);
10961
+ if (!cdpRedeemRegistered) {
10962
10962
  await runAndAwaitTxBuilder(
10963
10963
  lucid,
10964
10964
  lucid.newTx().register.Stake(cdpRedeemRewardAddr)
10965
10965
  );
10966
- } catch (error) {
10967
- const message = error instanceof Error ? error.message : String(error);
10968
- if (!message.includes("StakeKeyRegisteredDELEG") && !message.includes("Trying to re-register some already known credentials.")) {
10969
- throw error;
10970
- }
10971
10966
  }
10972
10967
  const cdpParams = {
10973
10968
  cdpAuthToken: toSystemParamsAsset(cdpToken),
package/dist/index.mjs CHANGED
@@ -10593,15 +10593,19 @@ async function initPyth(lucid) {
10593
10593
  alwaysSucceedValidator
10594
10594
  )
10595
10595
  );
10596
- await runAndAwaitTxBuilder(
10597
- lucid,
10598
- lucid.newTx().register.Stake(
10599
- credentialToRewardAddress3(lucid.config().network, {
10600
- hash: validatorToScriptHash4(alwaysSucceedValidator),
10601
- type: "Script"
10602
- })
10603
- )
10596
+ const alwaysSucceedRewardAddress = credentialToRewardAddress3(
10597
+ lucid.config().network,
10598
+ { hash: validatorToScriptHash4(alwaysSucceedValidator), type: "Script" }
10599
+ );
10600
+ const { registered } = await lucid.rewardAccountAt(
10601
+ alwaysSucceedRewardAddress
10604
10602
  );
10603
+ if (!registered) {
10604
+ await runAndAwaitTxBuilder(
10605
+ lucid,
10606
+ lucid.newTx().register.Stake(alwaysSucceedRewardAddress)
10607
+ );
10608
+ }
10605
10609
  return pythStateAsset;
10606
10610
  }
10607
10611
 
@@ -10626,23 +10630,18 @@ async function initPythConfig(lucid, initialAssets, pythStateAsset) {
10626
10630
  lucid,
10627
10631
  pythFeedValidator
10628
10632
  );
10629
- try {
10633
+ const pythFeedRewardAddress = credentialToRewardAddress4(
10634
+ lucid.config().network,
10635
+ { hash: validatorToScriptHash5(pythFeedValidator), type: "Script" }
10636
+ );
10637
+ const { registered } = await lucid.rewardAccountAt(
10638
+ pythFeedRewardAddress
10639
+ );
10640
+ if (!registered) {
10630
10641
  await runAndAwaitTxBuilder(
10631
10642
  lucid,
10632
- lucid.newTx().register.Stake(
10633
- credentialToRewardAddress4(lucid.config().network, {
10634
- hash: validatorToScriptHash5(pythFeedValidator),
10635
- type: "Script"
10636
- })
10637
- )
10643
+ lucid.newTx().register.Stake(pythFeedRewardAddress)
10638
10644
  );
10639
- } catch (error) {
10640
- const message = error instanceof Error ? error.message : String(error);
10641
- if (!message.includes("StakeKeyRegisteredDELEG") && !message.includes(
10642
- "Trying to re-register some already known credentials."
10643
- )) {
10644
- throw error;
10645
- }
10646
10645
  }
10647
10646
  const key = `${asset.name}/${toHex17(collateral.collateralAsset.currencySymbol)}.${toHex17(collateral.collateralAsset.tokenName)}`;
10648
10647
  return {
@@ -10833,16 +10832,12 @@ async function init(lucid, defaultInitialAssets, mkPythBasedAssets = () => [], p
10833
10832
  lucid.config().network,
10834
10833
  scriptHashToCredential4(cdpRedeemValHash)
10835
10834
  );
10836
- try {
10835
+ const { registered: cdpRedeemRegistered } = await lucid.rewardAccountAt(cdpRedeemRewardAddr);
10836
+ if (!cdpRedeemRegistered) {
10837
10837
  await runAndAwaitTxBuilder(
10838
10838
  lucid,
10839
10839
  lucid.newTx().register.Stake(cdpRedeemRewardAddr)
10840
10840
  );
10841
- } catch (error) {
10842
- const message = error instanceof Error ? error.message : String(error);
10843
- if (!message.includes("StakeKeyRegisteredDELEG") && !message.includes("Trying to re-register some already known credentials.")) {
10844
- throw error;
10845
- }
10846
10841
  }
10847
10842
  const cdpParams = {
10848
10843
  cdpAuthToken: toSystemParamsAsset(cdpToken),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.5.15",
3
+ "version": "0.5.16",
4
4
  "description": "Indigo SDK for interacting with Indigo endpoints via lucid-evolution",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",