@pooflabs/core 0.0.45 → 0.0.46
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 +48 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -16
- package/dist/index.mjs.map +1 -1
- package/dist/utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpDevnet-program.d.ts +137 -1
- package/dist/utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpMainnet-program.d.ts +227 -31
- package/dist/utils/sol/sol-utils.d.ts +2 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3186,6 +3186,12 @@ async function genSolanaMessage(address, nonce) {
|
|
|
3186
3186
|
// Serialization Helpers
|
|
3187
3187
|
// ─────────────────────────────────────────────────────────────
|
|
3188
3188
|
function isHexString(value) {
|
|
3189
|
+
// Only strings can be hex-encoded. Numbers, BNs, and other shapes coming back
|
|
3190
|
+
// from the API for u64Val/i64Val should fall through to `new BN(value)` which
|
|
3191
|
+
// accepts those shapes natively. Without this guard, calling .startsWith on a
|
|
3192
|
+
// non-string blows up with TypeError.
|
|
3193
|
+
if (typeof value !== "string")
|
|
3194
|
+
return false;
|
|
3189
3195
|
// Matches strings containing only 0-9, a-f, or A-F (optionally prefixed with 0x)
|
|
3190
3196
|
let testValue = value;
|
|
3191
3197
|
// Handle negative values
|
|
@@ -3281,8 +3287,11 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
3281
3287
|
}
|
|
3282
3288
|
else if (idl.address === "poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZp") {
|
|
3283
3289
|
const program = new anchor.Program(idl, anchorProvider);
|
|
3290
|
+
// Targets `set_documents_v2` (Vec<u8> ra_indices). The on-chain program
|
|
3291
|
+
// also exposes the legacy `set_documents` (Vec<u64>) so SDKs already on npm
|
|
3292
|
+
// continue to work — but new releases of this SDK speak v2 only.
|
|
3284
3293
|
tx = await program.methods
|
|
3285
|
-
.
|
|
3294
|
+
.setDocumentsV2(args.app_id, prepareAnchorArgs(args.documents), args.delete_paths, args.txData, simulate)
|
|
3286
3295
|
.preInstructions(instructions)
|
|
3287
3296
|
.accounts({
|
|
3288
3297
|
payer: payerPublicKey
|
|
@@ -3637,11 +3646,17 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
3637
3646
|
if (_overrides === null || _overrides === void 0 ? void 0 : _overrides.headers) {
|
|
3638
3647
|
Object.assign(headers, _overrides.headers);
|
|
3639
3648
|
}
|
|
3649
|
+
// Writes (PUT/POST/DELETE) can take significantly longer than reads —
|
|
3650
|
+
// server-side they may trigger ad-hoc LUT creation (create + extend +
|
|
3651
|
+
// wait-for-finalization, ~15-30s on mainnet). Use a larger default for
|
|
3652
|
+
// non-GET so the SDK doesn't time out before client-api responds.
|
|
3653
|
+
const isRead = method.toUpperCase() === "GET";
|
|
3654
|
+
const defaultTimeout = isRead ? 30000 : 90000;
|
|
3640
3655
|
const requestConfig = {
|
|
3641
3656
|
method,
|
|
3642
3657
|
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
3643
3658
|
headers,
|
|
3644
|
-
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a :
|
|
3659
|
+
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a : defaultTimeout,
|
|
3645
3660
|
};
|
|
3646
3661
|
if (method !== "GET" && method !== "get") {
|
|
3647
3662
|
requestConfig.data = data ? JSON.stringify(data) : {};
|
|
@@ -4286,21 +4301,38 @@ async function setMany(many, options) {
|
|
|
4286
4301
|
setDocumentData: tx.transactionArgs.setDocumentData,
|
|
4287
4302
|
deletePaths: tx.transactionArgs.deletePaths,
|
|
4288
4303
|
idl: tx.idl,
|
|
4289
|
-
txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => {
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4304
|
+
txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => ({
|
|
4305
|
+
pluginFunctionKey: txData.pluginFunctionKey,
|
|
4306
|
+
txData: bufferExports.Buffer.from(txData.txData),
|
|
4307
|
+
// raIndices is Vec<u8> on-chain (serialized as Buffer/bytes). The server may send
|
|
4308
|
+
// it as a Buffer, a number[], a Uint8Array, or — over JSON — as Node's serialized
|
|
4309
|
+
// Buffer shape {type: "Buffer", data: number[]} (the default `JSON.stringify(buf)`
|
|
4310
|
+
// output). Normalise all of those to Buffer here. Each value must fit in u8 (matches
|
|
4311
|
+
// Solana's instruction-level account indexing); throw clearly if anything is out of range.
|
|
4312
|
+
raIndices: (() => {
|
|
4313
|
+
const raw = txData.raIndices;
|
|
4314
|
+
if (raw == null)
|
|
4315
|
+
return bufferExports.Buffer.alloc(0);
|
|
4316
|
+
if (bufferExports.Buffer.isBuffer(raw))
|
|
4317
|
+
return raw;
|
|
4318
|
+
if (raw instanceof Uint8Array)
|
|
4319
|
+
return bufferExports.Buffer.from(raw);
|
|
4320
|
+
// Node's JSON-serialised Buffer: {type: "Buffer", data: number[]}
|
|
4321
|
+
const arrayLike = Array.isArray(raw)
|
|
4322
|
+
? raw
|
|
4323
|
+
: (raw && typeof raw === 'object' && Array.isArray(raw.data))
|
|
4324
|
+
? raw.data
|
|
4325
|
+
: (() => { throw new Error(`raIndices has unexpected shape: ${typeof raw}`); })();
|
|
4326
|
+
const bytes = arrayLike.map((raIndex) => {
|
|
4327
|
+
const n = isHexString(raIndex) ? parseInt(raIndex, 16) : Number(raIndex);
|
|
4328
|
+
if (!Number.isInteger(n) || n < 0 || n > 255) {
|
|
4329
|
+
throw new Error(`raIndex ${raIndex} is not a valid u8 (must be integer in 0..255)`);
|
|
4297
4330
|
}
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
})) !== null && _b !== void 0 ? _b : [],
|
|
4331
|
+
return n;
|
|
4332
|
+
});
|
|
4333
|
+
return bufferExports.Buffer.from(bytes);
|
|
4334
|
+
})(),
|
|
4335
|
+
}))) !== null && _b !== void 0 ? _b : [],
|
|
4304
4336
|
};
|
|
4305
4337
|
const config = await getConfig();
|
|
4306
4338
|
const solTransaction = {
|