@toon-protocol/client-mcp 0.9.1 → 0.10.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.
@@ -1173,7 +1173,7 @@ var BootstrapService = class {
1173
1173
  };
1174
1174
  console.log(`[Bootstrap] Query filter:`, JSON.stringify(filter));
1175
1175
  console.log(`[Bootstrap] Connecting to ${knownPeer.relayUrl}...`);
1176
- return new Promise((resolve, reject) => {
1176
+ return new Promise((resolve2, reject) => {
1177
1177
  const events = [];
1178
1178
  const timeout = this.config.queryTimeout ?? 5e3;
1179
1179
  const ws = new WebSocket22(knownPeer.relayUrl);
@@ -1267,7 +1267,7 @@ var BootstrapService = class {
1267
1267
  const peerInfo = parseIlpPeerInfo(
1268
1268
  mostRecent
1269
1269
  );
1270
- resolve(peerInfo);
1270
+ resolve2(peerInfo);
1271
1271
  } catch (error) {
1272
1272
  reject(
1273
1273
  new BootstrapError(
@@ -1314,7 +1314,7 @@ var BootstrapService = class {
1314
1314
  const peerInfo = parseIlpPeerInfo(
1315
1315
  mostRecent
1316
1316
  );
1317
- resolve(peerInfo);
1317
+ resolve2(peerInfo);
1318
1318
  } catch (error) {
1319
1319
  reject(
1320
1320
  new BootstrapError(
@@ -7021,7 +7021,7 @@ async function withRetry(operation, options) {
7021
7021
  throw lastError;
7022
7022
  }
7023
7023
  const currentDelay = exponentialBackoff ? Math.min(retryDelay * Math.pow(2, attempt), maxDelay) : retryDelay;
7024
- await new Promise((resolve) => setTimeout(resolve, currentDelay));
7024
+ await new Promise((resolve2) => setTimeout(resolve2, currentDelay));
7025
7025
  }
7026
7026
  }
7027
7027
  throw lastError ?? new Error("Unknown error during retry");
@@ -7429,7 +7429,7 @@ var IsomorphicBtpClient = class {
7429
7429
  }
7430
7430
  async connect() {
7431
7431
  if (this._isConnected) return;
7432
- return new Promise((resolve, reject) => {
7432
+ return new Promise((resolve2, reject) => {
7433
7433
  try {
7434
7434
  this.ws = this.config.createWebSocket ? this.config.createWebSocket(this.config.url) : new WebSocket(this.config.url);
7435
7435
  this.ws.binaryType = "arraybuffer";
@@ -7445,7 +7445,7 @@ var IsomorphicBtpClient = class {
7445
7445
  try {
7446
7446
  await this.authenticate();
7447
7447
  this._isConnected = true;
7448
- resolve();
7448
+ resolve2();
7449
7449
  } catch (err) {
7450
7450
  this._isConnected = false;
7451
7451
  this.ws?.close();
@@ -7510,12 +7510,12 @@ var IsomorphicBtpClient = class {
7510
7510
  const remaining = packet.expiresAt.getTime() - Date.now();
7511
7511
  timeoutMs = Math.max(remaining - 500, 1e3);
7512
7512
  }
7513
- return new Promise((resolve, reject) => {
7513
+ return new Promise((resolve2, reject) => {
7514
7514
  const timeoutId = setTimeout(() => {
7515
7515
  this.pendingRequests.delete(requestId);
7516
7516
  reject(new BtpConnectionError(`Packet send timeout (${timeoutMs}ms)`));
7517
7517
  }, timeoutMs);
7518
- this.pendingRequests.set(requestId, { resolve, reject, timeoutId });
7518
+ this.pendingRequests.set(requestId, { resolve: resolve2, reject, timeoutId });
7519
7519
  });
7520
7520
  }
7521
7521
  /**
@@ -7564,7 +7564,7 @@ var IsomorphicBtpClient = class {
7564
7564
  ilpPacket: new Uint8Array(0)
7565
7565
  }
7566
7566
  });
7567
- return new Promise((resolve, reject) => {
7567
+ return new Promise((resolve2, reject) => {
7568
7568
  const timeout = setTimeout(() => {
7569
7569
  reject(new BtpAuthError("Authentication timeout"));
7570
7570
  }, this.config.authTimeoutMs);
@@ -7590,7 +7590,7 @@ var IsomorphicBtpClient = class {
7590
7590
  )
7591
7591
  );
7592
7592
  } else if (message.type === BTPMessageType.RESPONSE) {
7593
- resolve();
7593
+ resolve2();
7594
7594
  }
7595
7595
  }
7596
7596
  } catch (err) {
@@ -8445,29 +8445,44 @@ async function openSolanaChannel(params) {
8445
8445
  ]);
8446
8446
  let depositTxSignature;
8447
8447
  if (params.deposit && params.deposit.amount > 0n) {
8448
- const depositData = new Uint8Array(16);
8449
- depositData.set(IX_DEPOSIT, 0);
8450
- writeU64LE(depositData, 8, params.deposit.amount);
8451
- depositTxSignature = await buildAndSendTransaction(rpcUrl, payer, [
8452
- {
8453
- programId,
8454
- keys: [
8455
- { pubkey: payerPubkey, isSigner: true, isWritable: false },
8456
- {
8457
- pubkey: params.deposit.payerTokenAccount,
8458
- isSigner: false,
8459
- isWritable: true
8460
- },
8461
- { pubkey: vaultPDA, isSigner: false, isWritable: true },
8462
- { pubkey: channelPDA, isSigner: false, isWritable: true },
8463
- { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }
8464
- ],
8465
- data: depositData
8466
- }
8467
- ]);
8448
+ ({ depositTxSignature } = await depositSolanaChannel({
8449
+ rpcUrl,
8450
+ programId,
8451
+ channelPDA,
8452
+ payerSeed,
8453
+ payerPubkey,
8454
+ payerTokenAccount: params.deposit.payerTokenAccount,
8455
+ amount: params.deposit.amount
8456
+ }));
8468
8457
  }
8469
8458
  return { channelPDA, opened: true, initTxSignature, depositTxSignature };
8470
8459
  }
8460
+ async function depositSolanaChannel(params) {
8461
+ const { rpcUrl, programId, channelPDA, payerSeed, payerPubkey, payerTokenAccount, amount } = params;
8462
+ if (amount <= 0n) throw new Error("Solana deposit amount must be positive.");
8463
+ const payer = {
8464
+ publicKey: padTo32(base58Decode(payerPubkey)),
8465
+ privateKey: payerSeed
8466
+ };
8467
+ const { pda: vaultPDA } = deriveVaultPDA(channelPDA, programId);
8468
+ const depositData = new Uint8Array(16);
8469
+ depositData.set(IX_DEPOSIT, 0);
8470
+ writeU64LE(depositData, 8, amount);
8471
+ const depositTxSignature = await buildAndSendTransaction(rpcUrl, payer, [
8472
+ {
8473
+ programId,
8474
+ keys: [
8475
+ { pubkey: payerPubkey, isSigner: true, isWritable: false },
8476
+ { pubkey: payerTokenAccount, isSigner: false, isWritable: true },
8477
+ { pubkey: vaultPDA, isSigner: false, isWritable: true },
8478
+ { pubkey: channelPDA, isSigner: false, isWritable: true },
8479
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }
8480
+ ],
8481
+ data: depositData
8482
+ }
8483
+ ]);
8484
+ return { depositTxSignature };
8485
+ }
8471
8486
  var cachedO1js = null;
8472
8487
  var cachedPaymentChannel = null;
8473
8488
  var compiledContract = null;
@@ -8834,12 +8849,43 @@ var OnChainChannelClient = class {
8834
8849
  );
8835
8850
  }
8836
8851
  const chainPrefix = ctx.chain.split(":")[0];
8837
- if (chainPrefix === "solana" || chainPrefix === "mina") {
8852
+ if (chainPrefix === "solana") {
8853
+ return this.depositSolana(channelId, amount, opts.currentDeposit);
8854
+ }
8855
+ if (chainPrefix === "mina") {
8856
+ throw new Error("Deposit on mina is not yet supported (EVM + Solana today; Mina follow-up).");
8857
+ }
8858
+ return this.depositEvm(channelId, amount, opts.currentDeposit, ctx);
8859
+ }
8860
+ /**
8861
+ * Solana deposit: fire the standalone `deposit` instruction against the channel
8862
+ * vault. Incremental on-chain (the program adds `amount`), so the new total is
8863
+ * the caller-tracked current plus the delta. Requires the funded payer token
8864
+ * account (the funded ATA) from the Solana channel config.
8865
+ */
8866
+ async depositSolana(channelId, amount, currentDeposit) {
8867
+ if (!this.solanaConfig) {
8868
+ throw new Error("Solana channel config not set \u2014 cannot deposit.");
8869
+ }
8870
+ const cfg = this.solanaConfig;
8871
+ const payerTokenAccount = cfg.deposit?.payerTokenAccount;
8872
+ if (!payerTokenAccount) {
8838
8873
  throw new Error(
8839
- `Deposit on ${chainPrefix} is not yet supported (EVM only; follow-up PR adds it).`
8874
+ "Solana deposit requires solanaConfig.deposit.payerTokenAccount (the funded SPL token account)."
8840
8875
  );
8841
8876
  }
8842
- return this.depositEvm(channelId, amount, opts.currentDeposit, ctx);
8877
+ const payerSeed = cfg.keypair.slice(0, 32);
8878
+ const payerPubkey = base58Encode(new Uint8Array(ed25519.getPublicKey(payerSeed)));
8879
+ const { depositTxSignature } = await depositSolanaChannel({
8880
+ rpcUrl: cfg.rpcUrl,
8881
+ programId: cfg.programId,
8882
+ channelPDA: channelId,
8883
+ payerSeed,
8884
+ payerPubkey,
8885
+ payerTokenAccount,
8886
+ amount
8887
+ });
8888
+ return { txHash: depositTxSignature, depositTotal: currentDeposit + amount };
8843
8889
  }
8844
8890
  /**
8845
8891
  * EVM deposit: approve the token-network for the delta if the allowance is
@@ -11482,7 +11528,7 @@ function writeKeystoreFile(path, keystore) {
11482
11528
  // src/daemon/config.ts
11483
11529
  import { readFileSync as readFileSync3 } from "fs";
11484
11530
  import { homedir } from "os";
11485
- import { join as join2 } from "path";
11531
+ import { join as join2, resolve } from "path";
11486
11532
 
11487
11533
  // ../../node_modules/.pnpm/@toon-protocol+core@1.4.2_@toon-protocol+connector@3.13.0_typescript@5.9.3/node_modules/@toon-protocol/core/dist/chunk-5WT7ISKC.js
11488
11534
  import { encode as encode2 } from "@toon-format/toon";
@@ -12113,6 +12159,8 @@ function resolveConfig(file) {
12113
12159
  const storeDestination = process.env["TOON_CLIENT_STORE_DESTINATION"] ?? file.storeDestination ?? routes.store;
12114
12160
  const feePerEvent = BigInt(file.feePerEvent ?? "1");
12115
12161
  const arweaveGateways = parseCsvEnv(process.env["TOON_CLIENT_ARWEAVE_GATEWAYS"]) ?? file.arweaveGateways ?? [...ARWEAVE_GATEWAYS];
12162
+ const uploadRoot = process.env["TOON_CLIENT_UPLOAD_ROOT"] ?? file.uploadAllowedRoot;
12163
+ const uploadAllowedRoot = uploadRoot ? resolve(uploadRoot) : void 0;
12116
12164
  const network = process.env["TOON_CLIENT_NETWORK"] ?? file.network;
12117
12165
  const chain2 = process.env["TOON_CLIENT_CHAIN"] ?? file.chain ?? "evm";
12118
12166
  const apex = file.apexChains?.[chain2] ?? file.apex ?? buildProxyApexNegotiation(file, chain2, destination);
@@ -12168,7 +12216,8 @@ function resolveConfig(file) {
12168
12216
  apexChannelStorePath,
12169
12217
  toonClientConfig,
12170
12218
  network,
12171
- arweaveGateways
12219
+ arweaveGateways,
12220
+ ...uploadAllowedRoot ? { uploadAllowedRoot } : {}
12172
12221
  };
12173
12222
  }
12174
12223
  function defaultChainKey(chain2, chainId) {
@@ -12491,4 +12540,4 @@ export {
12491
12540
  @scure/bip32/lib/esm/index.js:
12492
12541
  (*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
12493
12542
  */
12494
- //# sourceMappingURL=chunk-WAE4H47W.js.map
12543
+ //# sourceMappingURL=chunk-5Z74D23J.js.map