@toon-protocol/core 3.1.3 → 3.1.4
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 +3 -3
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
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 {
|
|
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:
|
|
3452
|
-
* toonDecoder:
|
|
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
|
-
|
|
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(
|
|
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
|
|
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
|
|
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(
|
|
340
|
+
const toResult = validateAsset(to, "to");
|
|
339
341
|
if (!toResult.valid) return toResult;
|
|
340
|
-
if (typeof
|
|
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 (
|
|
348
|
-
if (typeof
|
|
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 (
|
|
357
|
-
if (typeof
|
|
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 (
|
|
366
|
-
if (BigInt(
|
|
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,7 +2236,7 @@ var NostrPeerDiscovery = class {
|
|
|
2234
2236
|
// src/discovery/genesis-peers.json
|
|
2235
2237
|
var genesis_peers_default = [
|
|
2236
2238
|
{
|
|
2237
|
-
pubkey: "
|
|
2239
|
+
pubkey: "3f12da6d0cf10c91094894b88fc520757fc2860a1a5efb6664d3340ff97cfe40",
|
|
2238
2240
|
relayUrl: "wss://relay-ws.devnet.toonprotocol.dev",
|
|
2239
2241
|
ilpAddress: "g.proxy",
|
|
2240
2242
|
btpEndpoint: "wss://proxy.devnet.toonprotocol.dev:443"
|