@t2000/sdk 4.1.4 → 4.2.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/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +32 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -113
- package/dist/index.d.ts +14 -113
- package/dist/index.js +32 -6
- package/dist/index.js.map +1 -1
- package/dist/{types-CIclvR39.d.cts → types-8CNP74n6.d.cts} +1 -1
- package/dist/{types-B63ogqZZ.d.ts → types-BTbqE8AE.d.ts} +1 -1
- package/dist/{types-HJGbXJ37.d.cts → types-DUmk5ivZ.d.cts} +153 -2
- package/dist/{types-HJGbXJ37.d.ts → types-DUmk5ivZ.d.ts} +153 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -698,7 +698,23 @@ async function selectAndSplitCoin(tx, client, owner, coinType, amount, options =
|
|
|
698
698
|
const coin = transactions.coinWithBalance({ type: coinType, balance: effectiveAmount })(tx);
|
|
699
699
|
return { coin, effectiveAmount, swapAll };
|
|
700
700
|
}
|
|
701
|
-
async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowSwapAll) {
|
|
701
|
+
async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowSwapAll, mergeCache) {
|
|
702
|
+
const cached = mergeCache?.get(coinType);
|
|
703
|
+
if (cached) {
|
|
704
|
+
const requested2 = amount === "all" ? cached.remaining : amount;
|
|
705
|
+
if (cached.remaining === 0n || requested2 > cached.remaining) {
|
|
706
|
+
throw new exports.T2000Error(
|
|
707
|
+
"ADDRESS_BALANCE_UNSPONSORABLE",
|
|
708
|
+
`Not enough ${coinType} in coin objects to cover all legs of this sponsored bundle. The remaining funds are in your address balance, which sponsored transactions can't access yet.`,
|
|
709
|
+
{ remaining: cached.remaining.toString(), requested: requested2.toString(), coinType }
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
const swapAll2 = amount === "all" || requested2 >= cached.remaining;
|
|
713
|
+
const effectiveAmount2 = swapAll2 ? cached.remaining : requested2;
|
|
714
|
+
const coin2 = swapAll2 ? cached.primary : tx.splitCoins(cached.primary, [effectiveAmount2])[0];
|
|
715
|
+
cached.remaining -= effectiveAmount2;
|
|
716
|
+
return { coin: coin2, effectiveAmount: effectiveAmount2, swapAll: swapAll2 };
|
|
717
|
+
}
|
|
702
718
|
const objects = [];
|
|
703
719
|
let coinObjectTotal = 0n;
|
|
704
720
|
let cursor;
|
|
@@ -737,12 +753,16 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
|
|
|
737
753
|
);
|
|
738
754
|
}
|
|
739
755
|
const coin = swapAll ? primary : tx.splitCoins(primary, [effectiveAmount])[0];
|
|
756
|
+
mergeCache?.set(coinType, {
|
|
757
|
+
primary,
|
|
758
|
+
remaining: coinObjectTotal - effectiveAmount
|
|
759
|
+
});
|
|
740
760
|
return { coin, effectiveAmount, swapAll };
|
|
741
761
|
}
|
|
742
|
-
async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext) {
|
|
762
|
+
async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, mergeCache) {
|
|
743
763
|
if (sponsoredContext) {
|
|
744
764
|
const { SUI_TYPE: SUI_TYPE2 } = await Promise.resolve().then(() => (init_token_registry(), token_registry_exports));
|
|
745
|
-
return selectCoinObjectsOnly(tx, client, owner, SUI_TYPE2, amountMist, false);
|
|
765
|
+
return selectCoinObjectsOnly(tx, client, owner, SUI_TYPE2, amountMist, false, mergeCache);
|
|
746
766
|
}
|
|
747
767
|
const [coin] = tx.splitCoins(tx.gas, [amountMist]);
|
|
748
768
|
return { coin, effectiveAmount: amountMist, swapAll: false };
|
|
@@ -964,7 +984,8 @@ async function addSwapToTx(tx, client, address, input) {
|
|
|
964
984
|
client,
|
|
965
985
|
address,
|
|
966
986
|
requestedRaw,
|
|
967
|
-
input.sponsoredContext ?? false
|
|
987
|
+
input.sponsoredContext ?? false,
|
|
988
|
+
input.suiMergeCache
|
|
968
989
|
);
|
|
969
990
|
inputCoin = result.coin;
|
|
970
991
|
effectiveRaw = result.effectiveAmount;
|
|
@@ -8132,7 +8153,8 @@ var WRITE_APPENDER_REGISTRY = {
|
|
|
8132
8153
|
providers,
|
|
8133
8154
|
inputCoin: ctx.chainedCoin,
|
|
8134
8155
|
precomputedRoute: input.precomputedRoute,
|
|
8135
|
-
sponsoredContext: ctx.sponsoredContext
|
|
8156
|
+
sponsoredContext: ctx.sponsoredContext,
|
|
8157
|
+
suiMergeCache: ctx.suiMergeCache
|
|
8136
8158
|
});
|
|
8137
8159
|
if (!ctx.isOutputConsumed) {
|
|
8138
8160
|
tx.transferObjects([result.coin], ctx.sender);
|
|
@@ -8235,7 +8257,11 @@ async function composeTx(opts) {
|
|
|
8235
8257
|
sender: opts.sender,
|
|
8236
8258
|
sponsoredContext: opts.sponsoredContext ?? false,
|
|
8237
8259
|
overlayFee: opts.overlayFee,
|
|
8238
|
-
feeHooks: opts.feeHooks
|
|
8260
|
+
feeHooks: opts.feeHooks,
|
|
8261
|
+
// One cache per compose run — shared across all legs so multi-leg
|
|
8262
|
+
// sponsored bundles that source the same coin (e.g. two SUI swaps)
|
|
8263
|
+
// merge that coin's objects exactly once.
|
|
8264
|
+
suiMergeCache: /* @__PURE__ */ new Map()
|
|
8239
8265
|
};
|
|
8240
8266
|
const consumedSteps = /* @__PURE__ */ new Set();
|
|
8241
8267
|
for (let i = 0; i < opts.steps.length; i++) {
|