@txtcel/mcp 0.2.0 → 0.3.0

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 CHANGED
@@ -48043,7 +48043,8 @@ var InitThreadAccessInstr = import_zorsh.b.struct({
48043
48043
  var RequestAccessInstr = import_zorsh.b.struct({
48044
48044
  tag: import_zorsh.b.u8(),
48045
48045
  treasuryShardIdx: import_zorsh.b.u16(),
48046
- authorFeeShardIdx: import_zorsh.b.u8()
48046
+ authorFeeShardIdx: import_zorsh.b.u8(),
48047
+ maxFee: import_zorsh.b.u64()
48047
48048
  });
48048
48049
  var LikeContentInstr = import_zorsh.b.struct({
48049
48050
  tag: import_zorsh.b.u8(),
@@ -48057,7 +48058,8 @@ var AppendContentInstr = import_zorsh.b.struct({
48057
48058
  tag: import_zorsh.b.u8(),
48058
48059
  chunk: import_zorsh.b.bytes(),
48059
48060
  treasuryShardIdx: import_zorsh.b.u16(),
48060
- authorFeeShardIdx: import_zorsh.b.u8()
48061
+ authorFeeShardIdx: import_zorsh.b.u8(),
48062
+ maxFee: import_zorsh.b.u64()
48061
48063
  });
48062
48064
  var textDecoder = new TextDecoder();
48063
48065
  function decodeContent(pubkey, data) {
@@ -48408,7 +48410,7 @@ function buildPrepareAllocInstruction(programId, payer, seed, allocSeq) {
48408
48410
  }))
48409
48411
  });
48410
48412
  }
48411
- function buildAppendContentInstruction(programId, payer, contentAccount, threadAccount, settingsAccount, treasuryShard, authorFeeShard, chunk, treasuryShardIdx, authorFeeShardIdx) {
48413
+ function buildAppendContentInstruction(programId, payer, contentAccount, threadAccount, settingsAccount, treasuryShard, authorFeeShard, chunk, treasuryShardIdx, authorFeeShardIdx, maxFee) {
48412
48414
  return new TransactionInstruction({
48413
48415
  programId,
48414
48416
  keys: [
@@ -48424,7 +48426,8 @@ function buildAppendContentInstruction(programId, payer, contentAccount, threadA
48424
48426
  tag: Instruction.AppendContent,
48425
48427
  chunk,
48426
48428
  treasuryShardIdx,
48427
- authorFeeShardIdx
48429
+ authorFeeShardIdx,
48430
+ maxFee
48428
48431
  }))
48429
48432
  });
48430
48433
  }
@@ -48528,8 +48531,13 @@ async function buildSendMessageTransactions(connection, programId, payerKey, see
48528
48531
  const settingsPda = deriveSettingsPda(programId);
48529
48532
  const treasuryShardPda = deriveTreasuryShardPda(programId, treasuryShardIdx);
48530
48533
  const authorFeeShardPda = deriveAuthorFeePda(programId, seed, authorFeeShardIdx);
48534
+ const emptyRent = BigInt(await connection.getMinimumBalanceForRentExemption(0, "confirmed"));
48535
+ const oneByteRent = BigInt(await connection.getMinimumBalanceForRentExemption(1, "confirmed"));
48536
+ const rentPerByte = oneByteRent - emptyRent;
48531
48537
  for (let offset2 = 0; offset2 < remaining.length; offset2 += appendMax) {
48532
48538
  const chunk = remaining.subarray(offset2, offset2 + appendMax);
48539
+ const appendBaseFee = BigInt(chunk.length) * rentPerByte * baseFeeBps / 10000n;
48540
+ const appendMaxFee = appendBaseFee * MAX_FEE_SLIPPAGE_NUM + 1n;
48533
48541
  const appendIx = buildAppendContentInstruction(
48534
48542
  programId,
48535
48543
  payerKey,
@@ -48540,7 +48548,8 @@ async function buildSendMessageTransactions(connection, programId, payerKey, see
48540
48548
  authorFeeShardPda,
48541
48549
  chunk,
48542
48550
  treasuryShardIdx,
48543
- authorFeeShardIdx
48551
+ authorFeeShardIdx,
48552
+ appendMaxFee
48544
48553
  );
48545
48554
  transactions.push(new Transaction().add(appendIx));
48546
48555
  }
@@ -48605,16 +48614,13 @@ async function createRootAlloc(connection, programId, payer, messageFee = 0n, ti
48605
48614
  };
48606
48615
  }
48607
48616
  function buildCloseAccountInstruction(programId, payer, targetAccount, likesAccount) {
48608
- const keys = [
48609
- signerMeta(payer),
48610
- writableMeta(targetAccount)
48611
- ];
48612
- if (likesAccount) {
48613
- keys.push(writableMeta(likesAccount));
48614
- }
48615
48617
  return new TransactionInstruction({
48616
48618
  programId,
48617
- keys,
48619
+ keys: [
48620
+ signerMeta(payer),
48621
+ writableMeta(targetAccount),
48622
+ writableMeta(likesAccount)
48623
+ ],
48618
48624
  data: Buffer3.from(TagOnlyInstr.serialize({ tag: Instruction.CloseAccount }))
48619
48625
  });
48620
48626
  }
@@ -48683,7 +48689,7 @@ function buildSetThreadAccessInstruction(programId, authority, accessAccount, en
48683
48689
  }))
48684
48690
  });
48685
48691
  }
48686
- function buildRequestAccessInstruction(programId, payer, seed) {
48692
+ function buildRequestAccessInstruction(programId, payer, seed, maxFee) {
48687
48693
  const accessAccount = deriveAccessPda(programId, seed);
48688
48694
  const entryAccount = deriveAccessEntryPda(programId, seed, payer);
48689
48695
  const threadAccount = deriveThreadPda(programId, seed);
@@ -48707,7 +48713,8 @@ function buildRequestAccessInstruction(programId, payer, seed) {
48707
48713
  data: Buffer3.from(RequestAccessInstr.serialize({
48708
48714
  tag: Instruction.RequestAccess,
48709
48715
  treasuryShardIdx,
48710
- authorFeeShardIdx
48716
+ authorFeeShardIdx,
48717
+ maxFee
48711
48718
  }))
48712
48719
  });
48713
48720
  }
@@ -49076,15 +49083,17 @@ function registerMessagingTools(server) {
49076
49083
  channel: channelArg,
49077
49084
  allocSeq: external_exports.number().int().describe("allocSeq of the target message."),
49078
49085
  slot: external_exports.number().int().describe("slot of the target message."),
49079
- text: external_exports.string().min(1).describe("Text chunk to append.")
49086
+ text: external_exports.string().min(1).describe("Text chunk to append."),
49087
+ maxFee: external_exports.union([external_exports.number(), external_exports.string()]).optional().describe("Max base fee in lamports willing to pay for the append (slippage cap). Default 100000000 (0.1 SOL).")
49080
49088
  }
49081
49089
  },
49082
- handler(async ({ channel, allocSeq, slot, text }) => {
49090
+ handler(async ({ channel, allocSeq, slot, text, maxFee }) => {
49083
49091
  const { programId } = loadConfig();
49084
49092
  const payer = loadWallet();
49085
49093
  const seed = resolveSeed(channel);
49086
49094
  const treasuryShardIdx = randomTreasuryShard();
49087
49095
  const authorFeeShardIdx = randomAuthorFeeShard();
49096
+ const cap = maxFee === void 0 ? 100000000n : toLamports(maxFee);
49088
49097
  const ix = buildAppendContentInstruction(
49089
49098
  programId,
49090
49099
  payer.publicKey,
@@ -49095,7 +49104,8 @@ function registerMessagingTools(server) {
49095
49104
  deriveAuthorFeePda(programId, seed, authorFeeShardIdx),
49096
49105
  new TextEncoder().encode(text),
49097
49106
  treasuryShardIdx,
49098
- authorFeeShardIdx
49107
+ authorFeeShardIdx,
49108
+ cap
49099
49109
  );
49100
49110
  const signature = await sendInstructions(payer, [ix]);
49101
49111
  return jsonResult({ signature, explorer: explorerTx(signature) });
@@ -49171,14 +49181,18 @@ function registerMessagingTools(server) {
49171
49181
  "request_access",
49172
49182
  {
49173
49183
  title: "Request channel access",
49174
- description: "Pay the entry fee to join a gated channel so the agent wallet can post in it.",
49175
- inputSchema: { channel: channelArg }
49184
+ description: "Pay the entry fee to join a gated channel so the agent wallet can post in it. The current on-chain entry fee is used as the slippage cap unless maxFee is given.",
49185
+ inputSchema: {
49186
+ channel: channelArg,
49187
+ maxFee: external_exports.union([external_exports.number(), external_exports.string()]).optional().describe("Max entry fee in lamports willing to pay (slippage cap). Defaults to the current on-chain entry fee.")
49188
+ }
49176
49189
  },
49177
- handler(async ({ channel }) => {
49178
- const { programId } = loadConfig();
49190
+ handler(async ({ channel, maxFee }) => {
49191
+ const { connection, programId } = loadConfig();
49179
49192
  const payer = loadWallet();
49180
49193
  const seed = resolveSeed(channel);
49181
- const ix = buildRequestAccessInstruction(programId, payer.publicKey, seed);
49194
+ const cap = maxFee === void 0 ? (await loadThreadAccess(connection, programId, deriveAccessPda(programId, seed))).entryFee : toLamports(maxFee);
49195
+ const ix = buildRequestAccessInstruction(programId, payer.publicKey, seed, cap);
49182
49196
  const signature = await sendInstructions(payer, [ix]);
49183
49197
  return jsonResult({ signature, explorer: explorerTx(signature) });
49184
49198
  })