@toon-protocol/core 3.1.3 → 3.2.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.d.ts CHANGED
@@ -3439,7 +3439,7 @@ interface ToonNode {
3439
3439
  * ```typescript
3440
3440
  * import { ConnectorNode } from '@toon-protocol/connector';
3441
3441
  * import { createToonNode } from '@toon-protocol/core/compose';
3442
- * import { encodeEvent, decodeEvent } from '@toon-protocol/relay';
3442
+ * import { encodeEventToToon, decodeEventFromToon } from '@toon-protocol/core/toon';
3443
3443
  *
3444
3444
  * const connector = new ConnectorNode({ ... });
3445
3445
  *
@@ -3448,8 +3448,8 @@ interface ToonNode {
3448
3448
  * handlePacket: async (req) => { ... },
3449
3449
  * secretKey: new Uint8Array(32),
3450
3450
  * ilpInfo: { ilpAddress: 'g.example', ... },
3451
- * toonEncoder: encodeEvent,
3452
- * toonDecoder: decodeEvent,
3451
+ * toonEncoder: encodeEventToToon,
3452
+ * toonDecoder: decodeEventFromToon,
3453
3453
  * });
3454
3454
  *
3455
3455
  * // Attach event listeners before start
package/dist/index.js CHANGED
@@ -306,21 +306,22 @@ function validateAsset(asset, side) {
306
306
  field: side
307
307
  };
308
308
  }
309
- if (!isNonEmptyString(asset.assetCode)) {
309
+ const { assetCode, assetScale, chain } = asset;
310
+ if (!isNonEmptyString(assetCode)) {
310
311
  return {
311
312
  valid: false,
312
313
  reason: `${side}.assetCode must be a non-empty string`,
313
314
  field: `${side}.assetCode`
314
315
  };
315
316
  }
316
- if (!isNonNegativeInteger(asset.assetScale)) {
317
+ if (!isNonNegativeInteger(assetScale)) {
317
318
  return {
318
319
  valid: false,
319
320
  reason: `${side}.assetScale must be a non-negative integer`,
320
321
  field: `${side}.assetScale`
321
322
  };
322
323
  }
323
- if (typeof asset.chain !== "string" || !validateChainId(asset.chain)) {
324
+ if (typeof chain !== "string" || !validateChainId(chain)) {
324
325
  return {
325
326
  valid: false,
326
327
  reason: `${side}.chain must be a valid chain identifier (e.g., "evm:base:8453")`,
@@ -333,19 +334,20 @@ function isValidSwapPair(pair) {
333
334
  if (!isObject(pair)) {
334
335
  return { valid: false, reason: "pair must be an object", field: "" };
335
336
  }
336
- const fromResult = validateAsset(pair.from, "from");
337
+ const { from, to, rate, minAmount, maxAmount } = pair;
338
+ const fromResult = validateAsset(from, "from");
337
339
  if (!fromResult.valid) return fromResult;
338
- const toResult = validateAsset(pair.to, "to");
340
+ const toResult = validateAsset(to, "to");
339
341
  if (!toResult.valid) return toResult;
340
- if (typeof pair.rate !== "string" || pair.rate.length > MAX_NUMERIC_STRING_LENGTH || !RATE_REGEX.test(pair.rate)) {
342
+ if (typeof rate !== "string" || rate.length > MAX_NUMERIC_STRING_LENGTH || !RATE_REGEX.test(rate)) {
341
343
  return {
342
344
  valid: false,
343
345
  reason: `rate must be a non-negative decimal string (no leading zeros, no exponent, max ${MAX_NUMERIC_STRING_LENGTH} chars)`,
344
346
  field: "rate"
345
347
  };
346
348
  }
347
- if (pair.minAmount !== void 0) {
348
- if (typeof pair.minAmount !== "string" || pair.minAmount.length > MAX_NUMERIC_STRING_LENGTH || !AMOUNT_REGEX.test(pair.minAmount)) {
349
+ if (minAmount !== void 0) {
350
+ if (typeof minAmount !== "string" || minAmount.length > MAX_NUMERIC_STRING_LENGTH || !AMOUNT_REGEX.test(minAmount)) {
349
351
  return {
350
352
  valid: false,
351
353
  reason: `minAmount must be a non-negative integer string (max ${MAX_NUMERIC_STRING_LENGTH} digits)`,
@@ -353,8 +355,8 @@ function isValidSwapPair(pair) {
353
355
  };
354
356
  }
355
357
  }
356
- if (pair.maxAmount !== void 0) {
357
- if (typeof pair.maxAmount !== "string" || pair.maxAmount.length > MAX_NUMERIC_STRING_LENGTH || !AMOUNT_REGEX.test(pair.maxAmount)) {
358
+ if (maxAmount !== void 0) {
359
+ if (typeof maxAmount !== "string" || maxAmount.length > MAX_NUMERIC_STRING_LENGTH || !AMOUNT_REGEX.test(maxAmount)) {
358
360
  return {
359
361
  valid: false,
360
362
  reason: `maxAmount must be a non-negative integer string (max ${MAX_NUMERIC_STRING_LENGTH} digits)`,
@@ -362,8 +364,8 @@ function isValidSwapPair(pair) {
362
364
  };
363
365
  }
364
366
  }
365
- if (pair.minAmount !== void 0 && pair.maxAmount !== void 0) {
366
- if (BigInt(pair.minAmount) > BigInt(pair.maxAmount)) {
367
+ if (minAmount !== void 0 && maxAmount !== void 0) {
368
+ if (BigInt(minAmount) > BigInt(maxAmount)) {
367
369
  return {
368
370
  valid: false,
369
371
  reason: "minAmount must not exceed maxAmount",
@@ -2234,10 +2236,10 @@ var NostrPeerDiscovery = class {
2234
2236
  // src/discovery/genesis-peers.json
2235
2237
  var genesis_peers_default = [
2236
2238
  {
2237
- pubkey: "2813187eb66741f9509de2055161f328a0f04e01e1fc20188610b8dbd0591ea5",
2239
+ pubkey: "30fdd01d55c3efeb4c19c2cbeda8247cbc40ae9b15c026e9a301a263001fa7a9",
2238
2240
  relayUrl: "wss://relay-ws.devnet.toonprotocol.dev",
2239
- ilpAddress: "g.proxy",
2240
- btpEndpoint: "wss://proxy.devnet.toonprotocol.dev:443"
2241
+ ilpAddress: "g.toon",
2242
+ btpEndpoint: "wss://proxy.devnet.toonprotocol.dev/ilp/btp"
2241
2243
  }
2242
2244
  ];
2243
2245