@pooflabs/core 0.0.47-rc1 → 0.0.48
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
|
@@ -3208,6 +3208,12 @@ async function genSolanaMessage(address, nonce) {
|
|
|
3208
3208
|
// Serialization Helpers
|
|
3209
3209
|
// ─────────────────────────────────────────────────────────────
|
|
3210
3210
|
function isHexString(value) {
|
|
3211
|
+
// Only strings can be hex-encoded. Numbers, BNs, and other shapes coming back
|
|
3212
|
+
// from the API for u64Val/i64Val should fall through to `new BN(value)` which
|
|
3213
|
+
// accepts those shapes natively. Without this guard, calling .startsWith on a
|
|
3214
|
+
// non-string blows up with TypeError.
|
|
3215
|
+
if (typeof value !== "string")
|
|
3216
|
+
return false;
|
|
3211
3217
|
// Matches strings containing only 0-9, a-f, or A-F (optionally prefixed with 0x)
|
|
3212
3218
|
let testValue = value;
|
|
3213
3219
|
// Handle negative values
|
|
@@ -3303,8 +3309,11 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
3303
3309
|
}
|
|
3304
3310
|
else if (idl.address === "poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZp") {
|
|
3305
3311
|
const program = new anchor.Program(idl, anchorProvider);
|
|
3312
|
+
// Targets `set_documents_v2` (Vec<u8> ra_indices). The on-chain program
|
|
3313
|
+
// also exposes the legacy `set_documents` (Vec<u64>) so SDKs already on npm
|
|
3314
|
+
// continue to work — but new releases of this SDK speak v2 only.
|
|
3306
3315
|
tx = await program.methods
|
|
3307
|
-
.
|
|
3316
|
+
.setDocumentsV2(args.app_id, prepareAnchorArgs(args.documents), args.delete_paths, args.txData, simulate)
|
|
3308
3317
|
.preInstructions(instructions)
|
|
3309
3318
|
.accounts({
|
|
3310
3319
|
payer: payerPublicKey
|
|
@@ -3659,11 +3668,17 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
3659
3668
|
if (_overrides === null || _overrides === void 0 ? void 0 : _overrides.headers) {
|
|
3660
3669
|
Object.assign(headers, _overrides.headers);
|
|
3661
3670
|
}
|
|
3671
|
+
// Writes (PUT/POST/DELETE) can take significantly longer than reads —
|
|
3672
|
+
// server-side they may trigger ad-hoc LUT creation (create + extend +
|
|
3673
|
+
// wait-for-finalization, ~15-30s on mainnet). Use a larger default for
|
|
3674
|
+
// non-GET so the SDK doesn't time out before client-api responds.
|
|
3675
|
+
const isRead = method.toUpperCase() === "GET";
|
|
3676
|
+
const defaultTimeout = isRead ? 30000 : 90000;
|
|
3662
3677
|
const requestConfig = {
|
|
3663
3678
|
method,
|
|
3664
3679
|
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
3665
3680
|
headers,
|
|
3666
|
-
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a :
|
|
3681
|
+
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a : defaultTimeout,
|
|
3667
3682
|
};
|
|
3668
3683
|
if (method !== "GET" && method !== "get") {
|
|
3669
3684
|
requestConfig.data = data ? JSON.stringify(data) : {};
|
|
@@ -4308,21 +4323,38 @@ async function setMany(many, options) {
|
|
|
4308
4323
|
setDocumentData: tx.transactionArgs.setDocumentData,
|
|
4309
4324
|
deletePaths: tx.transactionArgs.deletePaths,
|
|
4310
4325
|
idl: tx.idl,
|
|
4311
|
-
txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => {
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4326
|
+
txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => ({
|
|
4327
|
+
pluginFunctionKey: txData.pluginFunctionKey,
|
|
4328
|
+
txData: bufferExports.Buffer.from(txData.txData),
|
|
4329
|
+
// raIndices is Vec<u8> on-chain (serialized as Buffer/bytes). The server may send
|
|
4330
|
+
// it as a Buffer, a number[], a Uint8Array, or — over JSON — as Node's serialized
|
|
4331
|
+
// Buffer shape {type: "Buffer", data: number[]} (the default `JSON.stringify(buf)`
|
|
4332
|
+
// output). Normalise all of those to Buffer here. Each value must fit in u8 (matches
|
|
4333
|
+
// Solana's instruction-level account indexing); throw clearly if anything is out of range.
|
|
4334
|
+
raIndices: (() => {
|
|
4335
|
+
const raw = txData.raIndices;
|
|
4336
|
+
if (raw == null)
|
|
4337
|
+
return bufferExports.Buffer.alloc(0);
|
|
4338
|
+
if (bufferExports.Buffer.isBuffer(raw))
|
|
4339
|
+
return raw;
|
|
4340
|
+
if (raw instanceof Uint8Array)
|
|
4341
|
+
return bufferExports.Buffer.from(raw);
|
|
4342
|
+
// Node's JSON-serialised Buffer: {type: "Buffer", data: number[]}
|
|
4343
|
+
const arrayLike = Array.isArray(raw)
|
|
4344
|
+
? raw
|
|
4345
|
+
: (raw && typeof raw === 'object' && Array.isArray(raw.data))
|
|
4346
|
+
? raw.data
|
|
4347
|
+
: (() => { throw new Error(`raIndices has unexpected shape: ${typeof raw}`); })();
|
|
4348
|
+
const bytes = arrayLike.map((raIndex) => {
|
|
4349
|
+
const n = isHexString(raIndex) ? parseInt(raIndex, 16) : Number(raIndex);
|
|
4350
|
+
if (!Number.isInteger(n) || n < 0 || n > 255) {
|
|
4351
|
+
throw new Error(`raIndex ${raIndex} is not a valid u8 (must be integer in 0..255)`);
|
|
4319
4352
|
}
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
})) !== null && _b !== void 0 ? _b : [],
|
|
4353
|
+
return n;
|
|
4354
|
+
});
|
|
4355
|
+
return bufferExports.Buffer.from(bytes);
|
|
4356
|
+
})(),
|
|
4357
|
+
}))) !== null && _b !== void 0 ? _b : [],
|
|
4326
4358
|
};
|
|
4327
4359
|
const config = await getConfig();
|
|
4328
4360
|
const solTransaction = {
|