@pooflabs/core 0.0.44 → 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/client/config.d.ts +5 -0
- package/dist/index.js +58 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -49
- 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 +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3166,6 +3166,12 @@ async function genSolanaMessage(address, nonce) {
|
|
|
3166
3166
|
// Serialization Helpers
|
|
3167
3167
|
// ─────────────────────────────────────────────────────────────
|
|
3168
3168
|
function isHexString(value) {
|
|
3169
|
+
// Only strings can be hex-encoded. Numbers, BNs, and other shapes coming back
|
|
3170
|
+
// from the API for u64Val/i64Val should fall through to `new BN(value)` which
|
|
3171
|
+
// accepts those shapes natively. Without this guard, calling .startsWith on a
|
|
3172
|
+
// non-string blows up with TypeError.
|
|
3173
|
+
if (typeof value !== "string")
|
|
3174
|
+
return false;
|
|
3169
3175
|
// Matches strings containing only 0-9, a-f, or A-F (optionally prefixed with 0x)
|
|
3170
3176
|
let testValue = value;
|
|
3171
3177
|
// Handle negative values
|
|
@@ -3261,8 +3267,11 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
3261
3267
|
}
|
|
3262
3268
|
else if (idl.address === "poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZp") {
|
|
3263
3269
|
const program = new Program(idl, anchorProvider);
|
|
3270
|
+
// Targets `set_documents_v2` (Vec<u8> ra_indices). The on-chain program
|
|
3271
|
+
// also exposes the legacy `set_documents` (Vec<u64>) so SDKs already on npm
|
|
3272
|
+
// continue to work — but new releases of this SDK speak v2 only.
|
|
3264
3273
|
tx = await program.methods
|
|
3265
|
-
.
|
|
3274
|
+
.setDocumentsV2(args.app_id, prepareAnchorArgs(args.documents), args.delete_paths, args.txData, simulate)
|
|
3266
3275
|
.preInstructions(instructions)
|
|
3267
3276
|
.accounts({
|
|
3268
3277
|
payer: payerPublicKey
|
|
@@ -3617,11 +3626,17 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
3617
3626
|
if (_overrides === null || _overrides === void 0 ? void 0 : _overrides.headers) {
|
|
3618
3627
|
Object.assign(headers, _overrides.headers);
|
|
3619
3628
|
}
|
|
3629
|
+
// Writes (PUT/POST/DELETE) can take significantly longer than reads —
|
|
3630
|
+
// server-side they may trigger ad-hoc LUT creation (create + extend +
|
|
3631
|
+
// wait-for-finalization, ~15-30s on mainnet). Use a larger default for
|
|
3632
|
+
// non-GET so the SDK doesn't time out before client-api responds.
|
|
3633
|
+
const isRead = method.toUpperCase() === "GET";
|
|
3634
|
+
const defaultTimeout = isRead ? 30000 : 90000;
|
|
3620
3635
|
const requestConfig = {
|
|
3621
3636
|
method,
|
|
3622
3637
|
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
3623
3638
|
headers,
|
|
3624
|
-
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a :
|
|
3639
|
+
timeout: (_a = _overrides === null || _overrides === void 0 ? void 0 : _overrides.timeout) !== null && _a !== void 0 ? _a : defaultTimeout,
|
|
3625
3640
|
};
|
|
3626
3641
|
if (method !== "GET" && method !== "get") {
|
|
3627
3642
|
requestConfig.data = data ? JSON.stringify(data) : {};
|
|
@@ -3733,40 +3748,17 @@ async function getConfig() {
|
|
|
3733
3748
|
return clientConfig;
|
|
3734
3749
|
}
|
|
3735
3750
|
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3747
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3748
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
3749
|
-
***************************************************************************** */
|
|
3750
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
function __rest(s, e) {
|
|
3754
|
-
var t = {};
|
|
3755
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
3756
|
-
t[p] = s[p];
|
|
3757
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
3758
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
3759
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
3760
|
-
t[p[i]] = s[p[i]];
|
|
3761
|
-
}
|
|
3762
|
-
return t;
|
|
3763
|
-
}
|
|
3764
|
-
|
|
3765
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
3766
|
-
var e = new Error(message);
|
|
3767
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
3751
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
3752
|
+
var t = {};
|
|
3753
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
3754
|
+
t[p] = s[p];
|
|
3755
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
3756
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
3757
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
3758
|
+
t[p[i]] = s[p[i]];
|
|
3759
|
+
}
|
|
3760
|
+
return t;
|
|
3768
3761
|
};
|
|
3769
|
-
|
|
3770
3762
|
/**
|
|
3771
3763
|
* Thrown when a user's wallet doesn't have enough SOL to cover the transaction.
|
|
3772
3764
|
* Apps can catch this to trigger an onramp/funding flow.
|
|
@@ -4289,21 +4281,38 @@ async function setMany(many, options) {
|
|
|
4289
4281
|
setDocumentData: tx.transactionArgs.setDocumentData,
|
|
4290
4282
|
deletePaths: tx.transactionArgs.deletePaths,
|
|
4291
4283
|
idl: tx.idl,
|
|
4292
|
-
txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => {
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4284
|
+
txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => ({
|
|
4285
|
+
pluginFunctionKey: txData.pluginFunctionKey,
|
|
4286
|
+
txData: bufferExports.Buffer.from(txData.txData),
|
|
4287
|
+
// raIndices is Vec<u8> on-chain (serialized as Buffer/bytes). The server may send
|
|
4288
|
+
// it as a Buffer, a number[], a Uint8Array, or — over JSON — as Node's serialized
|
|
4289
|
+
// Buffer shape {type: "Buffer", data: number[]} (the default `JSON.stringify(buf)`
|
|
4290
|
+
// output). Normalise all of those to Buffer here. Each value must fit in u8 (matches
|
|
4291
|
+
// Solana's instruction-level account indexing); throw clearly if anything is out of range.
|
|
4292
|
+
raIndices: (() => {
|
|
4293
|
+
const raw = txData.raIndices;
|
|
4294
|
+
if (raw == null)
|
|
4295
|
+
return bufferExports.Buffer.alloc(0);
|
|
4296
|
+
if (bufferExports.Buffer.isBuffer(raw))
|
|
4297
|
+
return raw;
|
|
4298
|
+
if (raw instanceof Uint8Array)
|
|
4299
|
+
return bufferExports.Buffer.from(raw);
|
|
4300
|
+
// Node's JSON-serialised Buffer: {type: "Buffer", data: number[]}
|
|
4301
|
+
const arrayLike = Array.isArray(raw)
|
|
4302
|
+
? raw
|
|
4303
|
+
: (raw && typeof raw === 'object' && Array.isArray(raw.data))
|
|
4304
|
+
? raw.data
|
|
4305
|
+
: (() => { throw new Error(`raIndices has unexpected shape: ${typeof raw}`); })();
|
|
4306
|
+
const bytes = arrayLike.map((raIndex) => {
|
|
4307
|
+
const n = isHexString(raIndex) ? parseInt(raIndex, 16) : Number(raIndex);
|
|
4308
|
+
if (!Number.isInteger(n) || n < 0 || n > 255) {
|
|
4309
|
+
throw new Error(`raIndex ${raIndex} is not a valid u8 (must be integer in 0..255)`);
|
|
4300
4310
|
}
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
})) !== null && _b !== void 0 ? _b : [],
|
|
4311
|
+
return n;
|
|
4312
|
+
});
|
|
4313
|
+
return bufferExports.Buffer.from(bytes);
|
|
4314
|
+
})(),
|
|
4315
|
+
}))) !== null && _b !== void 0 ? _b : [],
|
|
4307
4316
|
};
|
|
4308
4317
|
const config = await getConfig();
|
|
4309
4318
|
const solTransaction = {
|