@pooflabs/core 0.0.40 → 0.0.42
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/README.md +10 -0
- package/dist/client/operations.d.ts +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +108 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -10
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/utils/sol/sol-utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2957,7 +2957,7 @@ function convertRemainingAccounts(remainingAccounts) {
|
|
|
2957
2957
|
// ─────────────────────────────────────────────────────────────
|
|
2958
2958
|
// Updated Transaction Builder: It now accepts a PublicKey for the payer
|
|
2959
2959
|
// ─────────────────────────────────────────────────────────────
|
|
2960
|
-
async function buildSetDocumentsTransaction(connection, idl, anchorProvider, payerPublicKey, args, remainingAccounts, lutKey, preInstructions, simulate) {
|
|
2960
|
+
async function buildSetDocumentsTransaction(connection, idl, anchorProvider, payerPublicKey, args, remainingAccounts, lutKey, preInstructions, simulate, additionalLutAddresses) {
|
|
2961
2961
|
const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({
|
|
2962
2962
|
units: 1400000,
|
|
2963
2963
|
});
|
|
@@ -2998,8 +2998,25 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
2998
2998
|
tx.feePayer = payerPublicKey;
|
|
2999
2999
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
3000
3000
|
tx.recentBlockhash = blockhash;
|
|
3001
|
-
|
|
3002
|
-
|
|
3001
|
+
// Resolve LUTs: additionalLutAddresses (when present) is the authoritative set.
|
|
3002
|
+
// Falls back to lutKey alone for backwards compatibility.
|
|
3003
|
+
const lookupTables = [];
|
|
3004
|
+
const isSurfnet = anchorProvider.connection.rpcEndpoint == "https://surfpool.fly.dev";
|
|
3005
|
+
if (additionalLutAddresses && additionalLutAddresses.length > 0) {
|
|
3006
|
+
const results = await Promise.all(additionalLutAddresses.map(addr => connection.getAddressLookupTable(new PublicKey(addr)).catch(() => null)));
|
|
3007
|
+
for (const result of results) {
|
|
3008
|
+
if (result === null || result === void 0 ? void 0 : result.value) {
|
|
3009
|
+
lookupTables.push(result.value);
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
else if (lutKey != null) {
|
|
3014
|
+
const { value: table } = await connection.getAddressLookupTable(new PublicKey(lutKey));
|
|
3015
|
+
if (!table)
|
|
3016
|
+
throw new Error('LUT not found after creation/extend');
|
|
3017
|
+
lookupTables.push(table);
|
|
3018
|
+
}
|
|
3019
|
+
if (lookupTables.length === 0) {
|
|
3003
3020
|
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, []);
|
|
3004
3021
|
const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({
|
|
3005
3022
|
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
@@ -3007,11 +3024,7 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
3007
3024
|
tx.instructions[0] = computeBudgetIxOptimized;
|
|
3008
3025
|
return { tx, blockhash, lastValidBlockHeight };
|
|
3009
3026
|
}
|
|
3010
|
-
const
|
|
3011
|
-
if (!table)
|
|
3012
|
-
throw new Error('LUT not found after creation/extend');
|
|
3013
|
-
const isSurfnet = anchorProvider.connection.rpcEndpoint == "https://surfpool.fly.dev";
|
|
3014
|
-
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, [table]);
|
|
3027
|
+
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, lookupTables);
|
|
3015
3028
|
const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({
|
|
3016
3029
|
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
3017
3030
|
}); // 20% buffer
|
|
@@ -3020,7 +3033,7 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
3020
3033
|
payerKey: payerPublicKey,
|
|
3021
3034
|
recentBlockhash: blockhash,
|
|
3022
3035
|
instructions: tx.instructions,
|
|
3023
|
-
}).compileToV0Message(
|
|
3036
|
+
}).compileToV0Message(lookupTables);
|
|
3024
3037
|
const vTx = new anchor.web3.VersionedTransaction(msgV0);
|
|
3025
3038
|
return { tx: vTx, blockhash, lastValidBlockHeight };
|
|
3026
3039
|
}
|
|
@@ -3715,6 +3728,90 @@ function cleanupExpiredCache() {
|
|
|
3715
3728
|
});
|
|
3716
3729
|
lastCacheCleanup = now;
|
|
3717
3730
|
}
|
|
3731
|
+
async function getMany(paths, opts = {}) {
|
|
3732
|
+
if (paths.length === 0) {
|
|
3733
|
+
return [];
|
|
3734
|
+
}
|
|
3735
|
+
if (paths.length > 30) {
|
|
3736
|
+
throw new Error('Cannot fetch more than 30 documents at once');
|
|
3737
|
+
}
|
|
3738
|
+
const normalizedPaths = [];
|
|
3739
|
+
for (const path of paths) {
|
|
3740
|
+
let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
3741
|
+
if (normalizedPath.endsWith("*") && normalizedPath.length > 1) {
|
|
3742
|
+
normalizedPath = normalizedPath.slice(0, -1);
|
|
3743
|
+
}
|
|
3744
|
+
if (!normalizedPath || normalizedPath.length === 0) {
|
|
3745
|
+
throw new Error(`Invalid path provided: ${path}`);
|
|
3746
|
+
}
|
|
3747
|
+
const pathIsDocument = normalizedPath.split("/").length % 2 === 0;
|
|
3748
|
+
if (!pathIsDocument) {
|
|
3749
|
+
throw new Error(`Path must point to a document (even number of segments): ${path}`);
|
|
3750
|
+
}
|
|
3751
|
+
normalizedPaths.push(normalizedPath);
|
|
3752
|
+
}
|
|
3753
|
+
const now = Date.now();
|
|
3754
|
+
const results = new Array(paths.length);
|
|
3755
|
+
const uncachedIndices = [];
|
|
3756
|
+
const uncachedPaths = [];
|
|
3757
|
+
for (let i = 0; i < normalizedPaths.length; i++) {
|
|
3758
|
+
const normalizedPath = normalizedPaths[i];
|
|
3759
|
+
const cacheKey = `${normalizedPath}:`;
|
|
3760
|
+
if (!opts.bypassCache && getCache[cacheKey] && now < getCache[cacheKey].expiresAt) {
|
|
3761
|
+
results[i] = { path: normalizedPath, data: getCache[cacheKey].data };
|
|
3762
|
+
}
|
|
3763
|
+
else {
|
|
3764
|
+
uncachedIndices.push(i);
|
|
3765
|
+
uncachedPaths.push(normalizedPath);
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
if (uncachedPaths.length > 0) {
|
|
3769
|
+
try {
|
|
3770
|
+
const response = await makeApiRequest('POST', 'items/batch', { paths: uncachedPaths }, opts._overrides);
|
|
3771
|
+
const serverResults = response.data.results;
|
|
3772
|
+
const serverResultsMap = new Map();
|
|
3773
|
+
for (const result of serverResults) {
|
|
3774
|
+
serverResultsMap.set(result.path, result);
|
|
3775
|
+
}
|
|
3776
|
+
for (let i = 0; i < uncachedIndices.length; i++) {
|
|
3777
|
+
const originalIndex = uncachedIndices[i];
|
|
3778
|
+
const normalizedPath = uncachedPaths[i];
|
|
3779
|
+
const serverResult = serverResultsMap.get(normalizedPath);
|
|
3780
|
+
if (serverResult) {
|
|
3781
|
+
results[originalIndex] = serverResult;
|
|
3782
|
+
if (!serverResult.error && !opts.bypassCache) {
|
|
3783
|
+
const cacheKey = `${normalizedPath}:`;
|
|
3784
|
+
getCache[cacheKey] = {
|
|
3785
|
+
data: serverResult.data,
|
|
3786
|
+
expiresAt: now + GET_CACHE_TTL
|
|
3787
|
+
};
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
else {
|
|
3791
|
+
results[originalIndex] = {
|
|
3792
|
+
path: normalizedPath,
|
|
3793
|
+
data: null,
|
|
3794
|
+
error: { code: 'NOT_FOUND', message: `No result returned for path ${normalizedPath}` }
|
|
3795
|
+
};
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
if (now - lastCacheCleanup > 5000) {
|
|
3799
|
+
cleanupExpiredCache();
|
|
3800
|
+
lastCacheCleanup = now;
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
catch (error) {
|
|
3804
|
+
for (const originalIndex of uncachedIndices) {
|
|
3805
|
+
results[originalIndex] = {
|
|
3806
|
+
path: normalizedPaths[originalIndex],
|
|
3807
|
+
data: null,
|
|
3808
|
+
error: { code: 'NOT_FOUND', message: error instanceof Error ? error.message : 'Unknown error' }
|
|
3809
|
+
};
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
}
|
|
3813
|
+
return results;
|
|
3814
|
+
}
|
|
3718
3815
|
async function runQuery(absolutePath, queryName, queryArgs, opts) {
|
|
3719
3816
|
const result = await runQueryMany([{ absolutePath, queryName, queryArgs }], opts);
|
|
3720
3817
|
return result[0];
|
|
@@ -3904,6 +4001,7 @@ async function setMany(many, options) {
|
|
|
3904
4001
|
appId: config.appId,
|
|
3905
4002
|
txArgs: [solTransactionData],
|
|
3906
4003
|
lutKey: (_c = tx.lutAddress) !== null && _c !== void 0 ? _c : null,
|
|
4004
|
+
additionalLutAddresses: tx.additionalLutAddresses,
|
|
3907
4005
|
network: tx.network,
|
|
3908
4006
|
preInstructions: (_e = (_d = tx.preInstructions) === null || _d === void 0 ? void 0 : _d.map((ix) => {
|
|
3909
4007
|
var _a;
|
|
@@ -4954,5 +5052,5 @@ class ReactNativeSessionManager {
|
|
|
4954
5052
|
}
|
|
4955
5053
|
ReactNativeSessionManager.TAROBASE_SESSION_STORAGE_KEY = "tarobase_session_storage";
|
|
4956
5054
|
|
|
4957
|
-
export { InsufficientBalanceError, ReactNativeSessionManager, ServerSessionManager, WebSessionManager, aggregate, buildSetDocumentsTransaction, clearCache, closeAllSubscriptions, convertRemainingAccounts, count, createSessionWithPrivy, createSessionWithSignature, genAuthNonce, genSolanaMessage, get, getCachedData, getConfig, getFiles, getIdToken, init, reconnectWithNewAuth, refreshSession, runExpression, runExpressionMany, runQuery, runQueryMany, set, setFile, setMany, signAndSubmitTransaction, signMessage, signSessionCreateMessage, signTransaction, subscribe };
|
|
5055
|
+
export { InsufficientBalanceError, ReactNativeSessionManager, ServerSessionManager, WebSessionManager, aggregate, buildSetDocumentsTransaction, clearCache, closeAllSubscriptions, convertRemainingAccounts, count, createSessionWithPrivy, createSessionWithSignature, genAuthNonce, genSolanaMessage, get, getCachedData, getConfig, getFiles, getIdToken, getMany, init, reconnectWithNewAuth, refreshSession, runExpression, runExpressionMany, runQuery, runQueryMany, set, setFile, setMany, signAndSubmitTransaction, signMessage, signSessionCreateMessage, signTransaction, subscribe };
|
|
4958
5056
|
//# sourceMappingURL=index.mjs.map
|