@toon-protocol/core 3.0.0 → 3.1.1
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 +2 -133
- package/dist/index.js +27 -152
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { I as InvalidEventError, P as PeerDiscoveryError, a as ToonDecodeError,
|
|
|
3
3
|
import { NostrEvent, Event } from 'nostr-tools/pure';
|
|
4
4
|
import { SimplePool } from 'nostr-tools/pool';
|
|
5
5
|
import { TurboAuthenticatedClient } from '@ardrive/turbo-sdk';
|
|
6
|
+
export { balanceProofFieldsMina, balanceProofHashEvm, balanceProofHashSolana, bigintToBytes32BE, concatBytes, coopCloseHashEvm, eip712DomainSeparatorEvm, hexToBytes, minaHashToField } from '@toon-protocol/settlement-digest';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Nostr event kind constants for ILP-related events.
|
|
@@ -2483,138 +2484,6 @@ declare function negotiateSettlementChain(requesterChains: string[], responderCh
|
|
|
2483
2484
|
*/
|
|
2484
2485
|
declare function resolveTokenForChain(chain: string, requesterPreferredTokens?: Record<string, string>, responderPreferredTokens?: Record<string, string>): string | undefined;
|
|
2485
2486
|
|
|
2486
|
-
/**
|
|
2487
|
-
* Shared balance-proof hash helpers — the single source of truth for the
|
|
2488
|
-
* byte/field layout that ALL signers and verifiers across the monorepo depend
|
|
2489
|
-
* on:
|
|
2490
|
-
* - the Swap-side signer (`packages/swap/src/payment-channel-signer.ts`)
|
|
2491
|
-
* - the sender-side settlement verifier (`packages/sdk/src/settlement/{evm,solana,mina}.ts`)
|
|
2492
|
-
* - the client-side balance-proof signers (`packages/client/src/signing/{solana,mina}-signer.ts`)
|
|
2493
|
-
*
|
|
2494
|
-
* Originally extracted from the Swap signer (Story 12.4) into `@toon-protocol/sdk`
|
|
2495
|
-
* (Story 12.6 AC-6). Relocated here to `@toon-protocol/core` so the client can
|
|
2496
|
-
* consume the canonical hashes WITHOUT taking a dependency on `@toon-protocol/sdk`
|
|
2497
|
-
* (the client only depends on core). `@toon-protocol/sdk` re-exports these names
|
|
2498
|
-
* unchanged, so Swap and existing SDK consumers are unaffected.
|
|
2499
|
-
*
|
|
2500
|
-
* Any change to a hash layout here automatically applies to every signer AND
|
|
2501
|
-
* verifier — they cannot drift.
|
|
2502
|
-
*
|
|
2503
|
-
* @module
|
|
2504
|
-
*/
|
|
2505
|
-
/**
|
|
2506
|
-
* Convert a hex string (with or without `0x` prefix) to bytes. Rejects
|
|
2507
|
-
* odd-length and non-hex input.
|
|
2508
|
-
*/
|
|
2509
|
-
declare function hexToBytes(hex: string): Uint8Array;
|
|
2510
|
-
/**
|
|
2511
|
-
* Encode a non-negative bigint as 32-byte big-endian. Throws if negative or
|
|
2512
|
-
* exceeds 256 bits.
|
|
2513
|
-
*/
|
|
2514
|
-
declare function bigintToBytes32BE(x: bigint): Uint8Array;
|
|
2515
|
-
/**
|
|
2516
|
-
* Concat N Uint8Arrays into one new Uint8Array.
|
|
2517
|
-
*/
|
|
2518
|
-
declare function concatBytes(...parts: Uint8Array[]): Uint8Array;
|
|
2519
|
-
/**
|
|
2520
|
-
* Compute the EIP-712 domain separator for the RollingSwapChannel v2 domain:
|
|
2521
|
-
* keccak256(abi.encode(
|
|
2522
|
-
* EIP712DOMAIN_TYPEHASH,
|
|
2523
|
-
* keccak256("RollingSwapChannel"),
|
|
2524
|
-
* keccak256("2"),
|
|
2525
|
-
* chainId, // uint256, big-endian
|
|
2526
|
-
* verifyingContract // address, right-aligned in 32 bytes
|
|
2527
|
-
* ))
|
|
2528
|
-
*
|
|
2529
|
-
* `verifyingContractBytes` MUST be the 20-byte deployed RollingSwapChannel
|
|
2530
|
-
* address. Equivalent to OpenZeppelin `EIP712._domainSeparatorV4()`.
|
|
2531
|
-
*
|
|
2532
|
-
* @stable — every signer and verifier depends on the exact layout.
|
|
2533
|
-
*/
|
|
2534
|
-
declare function eip712DomainSeparatorEvm(chainId: bigint, verifyingContractBytes: Uint8Array): Uint8Array;
|
|
2535
|
-
/**
|
|
2536
|
-
* Compute the v2 EVM balance-proof (claim) digest — the 32-byte EIP-712 typed
|
|
2537
|
-
* digest the swap node signs and the on-chain `RollingSwapChannel` verifies:
|
|
2538
|
-
*
|
|
2539
|
-
* structHash = keccak256(abi.encode(
|
|
2540
|
-
* CLAIM_TYPEHASH, channelId, cumulativeAmount, nonce, recipient))
|
|
2541
|
-
* digest = keccak256(0x1901 || domainSeparator || structHash)
|
|
2542
|
-
*
|
|
2543
|
-
* with domain `EIP712Domain(name="RollingSwapChannel", version="2", chainId,
|
|
2544
|
-
* verifyingContract)`. `channelIdBytes` MUST be 32 bytes, `recipientBytes` MUST
|
|
2545
|
-
* be 20 bytes, `verifyingContractBytes` MUST be the 20-byte deployed contract
|
|
2546
|
-
* address. Equivalent to OZ `EIP712._hashTypedDataV4(claimStructHash)`.
|
|
2547
|
-
*
|
|
2548
|
-
* v2 REQUIRES `chainId` + `verifyingContract` — the two inputs v1 lacked. This
|
|
2549
|
-
* hash is what `EvmPaymentChannelSigner.signBalanceProof` signs and what
|
|
2550
|
-
* `recoverEvmSignerAddress` recovers against.
|
|
2551
|
-
*
|
|
2552
|
-
* @stable — signer and verifier depend on the exact byte layout.
|
|
2553
|
-
*/
|
|
2554
|
-
declare function balanceProofHashEvm(channelIdBytes: Uint8Array, cumulativeAmount: bigint, nonce: bigint, recipientBytes: Uint8Array, chainId: bigint, verifyingContractBytes: Uint8Array): Uint8Array;
|
|
2555
|
-
/**
|
|
2556
|
-
* Compute the v2 EVM cooperative-close digest — the 32-byte EIP-712 typed
|
|
2557
|
-
* digest the recipient signs to acknowledge a cooperative close:
|
|
2558
|
-
*
|
|
2559
|
-
* structHash = keccak256(abi.encode(
|
|
2560
|
-
* COOP_CLOSE_TYPEHASH, channelId, cumulativeAmount, nonce))
|
|
2561
|
-
* digest = keccak256(0x1901 || domainSeparator || structHash)
|
|
2562
|
-
*
|
|
2563
|
-
* Shares the SAME domain as the claim digest (so it is bound to
|
|
2564
|
-
* `chainId + verifyingContract` too), but the distinct `CooperativeClose`
|
|
2565
|
-
* type hash guarantees a close-ack can never be recovered as a balance-proof
|
|
2566
|
-
* claim (or vice-versa). `channelIdBytes` MUST be 32 bytes.
|
|
2567
|
-
*
|
|
2568
|
-
* @stable — signer and verifier depend on the exact byte layout.
|
|
2569
|
-
*/
|
|
2570
|
-
declare function coopCloseHashEvm(channelIdBytes: Uint8Array, cumulativeAmount: bigint, nonce: bigint, chainId: bigint, verifyingContractBytes: Uint8Array): Uint8Array;
|
|
2571
|
-
/**
|
|
2572
|
-
* Compute the Solana balance-proof message hash:
|
|
2573
|
-
* sha256(utf8(channelId) || cumulativeAmount(32BE) || nonce(32BE) || utf8(recipient))
|
|
2574
|
-
*
|
|
2575
|
-
* `channelId` and `recipient` are base58-encoded strings (ASCII-subset of
|
|
2576
|
-
* UTF-8). This hash is what `SolanaPaymentChannelSigner.signBalanceProof`
|
|
2577
|
-
* signs and what `verifyEd25519Signature` verifies against.
|
|
2578
|
-
*
|
|
2579
|
-
* @stable — signer and verifier depend on the exact byte layout.
|
|
2580
|
-
*/
|
|
2581
|
-
declare function balanceProofHashSolana(channelId: string, cumulativeAmount: bigint, nonce: bigint, recipient: string): Uint8Array;
|
|
2582
|
-
/**
|
|
2583
|
-
* Hash an arbitrary string to a Pallas-field-safe bigint.
|
|
2584
|
-
*
|
|
2585
|
-
* The Pallas base field order is slightly below 2^254, so we take the first
|
|
2586
|
-
* 240 bits (60 hex chars / 30 bytes) of `sha256(utf8(s))` as a conservative,
|
|
2587
|
-
* guaranteed-in-field representation. Used to fold the variable-length
|
|
2588
|
-
* `channelId` / `recipient` strings into the fixed field-element array a Mina
|
|
2589
|
-
* Schnorr signature is computed over.
|
|
2590
|
-
*
|
|
2591
|
-
* @stable — Swap signer and SDK verifier depend on the exact derivation.
|
|
2592
|
-
*/
|
|
2593
|
-
declare function minaHashToField(s: string): bigint;
|
|
2594
|
-
/**
|
|
2595
|
-
* Compute the Mina balance-proof field-element message:
|
|
2596
|
-
* [ minaHashToField(channelId),
|
|
2597
|
-
* cumulativeAmount,
|
|
2598
|
-
* nonce,
|
|
2599
|
-
* minaHashToField(recipient) ]
|
|
2600
|
-
*
|
|
2601
|
-
* This is the EXACT `fields` array that the Swap's `MinaPaymentChannelSigner`
|
|
2602
|
-
* passes to `mina-signer`'s `signFields(...)`, and that the sender-side
|
|
2603
|
-
* `verifyMinaSignature` re-derives and passes to `verifyFields(...)`. Keeping
|
|
2604
|
-
* the derivation here (shared across `@toon-protocol/swap`, `@toon-protocol/sdk`,
|
|
2605
|
-
* and `@toon-protocol/client`) prevents signer/verifier drift — mirroring the
|
|
2606
|
-
* EVM/Solana hash helpers above.
|
|
2607
|
-
*
|
|
2608
|
-
* NOTE: this is the Swap↔sender wire contract (a Schnorr signature over four
|
|
2609
|
-
* field elements), NOT the connector's on-chain `MinaPaymentChannelSDK`
|
|
2610
|
-
* Poseidon-commitment proof shape. The two are distinct; see
|
|
2611
|
-
* `packages/sdk/src/settlement/mina.ts` for the relationship + the
|
|
2612
|
-
* remaining on-chain-settlement gap.
|
|
2613
|
-
*
|
|
2614
|
-
* @stable — Swap signer and SDK verifier depend on the exact byte layout.
|
|
2615
|
-
*/
|
|
2616
|
-
declare function balanceProofFieldsMina(channelId: string, cumulativeAmount: bigint, nonce: bigint, recipient: string): bigint[];
|
|
2617
|
-
|
|
2618
2487
|
/**
|
|
2619
2488
|
* Base58 (Bitcoin/Solana alphabet) encode/decode.
|
|
2620
2489
|
*
|
|
@@ -4686,4 +4555,4 @@ declare function selectLatestAddressable<T extends Event>(events: T[]): T | unde
|
|
|
4686
4555
|
*/
|
|
4687
4556
|
declare const VERSION = "0.1.0";
|
|
4688
4557
|
|
|
4689
|
-
export { AddressRegistry, type AgentRuntimeClient, ArDrivePeerRegistry, AttestationBootstrap, type AttestationBootstrapConfig, type AttestationBootstrapEvent, type AttestationBootstrapEventListener, type AttestationBootstrapResult, type AttestationEventOptions, AttestationState, AttestationVerifier, type AttestationVerifierConfig, type AttestedResultVerificationOptions, type AttestedResultVerificationResult, AttestedResultVerifier, BLOB_STORAGE_REQUEST_KIND, BLOB_STORAGE_RESULT_KIND, type BlobStorageRequestParams, type BootstrapConfig, BootstrapError, type BootstrapEvent, type BootstrapEventListener, type BootstrapPhase, type BootstrapResult, BootstrapService, type BootstrapServiceConfig, type BtpHandshakeExtension, type BuildIlpPeerInfoOptions, type BuildIlpPrepareParams, CHAIN_PRESETS, type CalculateRouteAmountParams, type ChainName, type ChainPreset, type ChainProviderConfigEntry, type ChainType, type ChannelState, type ClientNetworkPresets, type ConnectorAdminClient, type ConnectorAdminLike, type ConnectorChannelClient, type ConnectorChannelLike, type ConnectorNodeLike, type CustomEndpoints, type DeriveFromKmsSeedOptions, type DeterminismReport, type DirectRuntimeClientConfig, type DiscoveredPeer, type DiscoveryTracker, type DiscoveryTrackerConfig, type DvmJobStatus, type EVMProviderConfigEntry, EXPIRATION_TAG, type EmbeddableConnectorLike, type ForbiddenPattern, type GenesisPeer, GenesisPeerLoader, type HandlePacketAcceptResponse, type HandlePacketRejectResponse, type HandlePacketRequest, type HandlePacketResponse, ILP_PEER_INFO_KIND, ILP_ROOT_PREFIX, ILP_TO_SEMANTIC, IMAGE_GENERATION_KIND, type IlpClient, type IlpPeerInfo, type IlpPreparePacket, type IlpSendResult, JOB_FEEDBACK_KIND, JOB_REQUEST_KIND_BASE, JOB_RESULT_KIND_BASE, JOB_REVIEW_KIND, type JobFeedbackParams, type JobRequestParams, type JobResultParams, type JobReviewParams, KmsIdentityError, type KmsKeypair, type KnownPeer, type LogEntry, type LogLevel, type Logger, type LoggerConfig, MINA_CHAIN_PRESETS, MOCK_USDC_ADDRESS, MOCK_USDC_CONFIG, type MinaChainName, type MinaChainPreset, type MinaProviderConfigEntry, type MockUsdcConfig, type MultiChainName, type NetworkFamilyStatus, type NetworkMode, type NetworkNodeEnv, type NetworkProfile, type NixBuildResult, NixBuilder, type NixBuilderConfig, NostrPeerDiscovery, type OpenChannelParams, type OpenChannelResult, PET_INTERACTION_EVENT_KIND, PET_INTERACTION_REQUEST_KIND, PET_INTERACTION_RESULT_KIND, PREFIX_CLAIM_KIND, PREFIX_GRANT_KIND, type PacketHandler, type ParsedAttestation, type ParsedBlobStorageRequest, type ParsedJobFeedback, type ParsedJobRequest, type ParsedJobResult, type ParsedJobReview, type ParsedSwarmRequest, type ParsedSwarmSelection, type ParsedWorkflowDefinition, type ParsedWotDeclaration, PcrReproducibilityError, type PcrReproducibilityResult, type PeerDescriptor, type PrefixClaimContent, type PrefixGrantContent, type PrefixValidationResult, type PublishSeedRelayConfig, RELAY_ONLY_CHAIN, type RegisterPeerParams, type ReputationScore, ReputationScoreCalculator, type ReputationSignals, type ResolveRouteFeesParams, type ResolveRouteFeesResult, SEED_RELAY_LIST_KIND, SERVICE_DISCOVERY_KIND, SOLANA_CHAIN_PRESETS, SeedRelayDiscovery, type SeedRelayDiscoveryConfig, type SeedRelayDiscoveryResult, type SeedRelayEntry, type SendPacketParams, type SendPacketResult, type ServiceDiscoveryContent, type SettlementConfig, type SkillDescriptor, type SocialDiscoveryEvent, type SocialDiscoveryEventListener, SocialPeerDiscovery, type SocialPeerDiscoveryConfig, type SolanaChainName, type SolanaChainPreset, type SolanaProviderConfigEntry, type Subscription, type SwapPair, type SwarmRequestParams, type SwarmSelectionParams, TEE_ATTESTATION_KIND, TEXT_GENERATION_KIND, TEXT_TO_SPEECH_KIND, TRANSLATION_KIND, type TeeAttestation, ToonError, type ToonNode, type ToonNodeConfig, type ToonNodeStartResult, UI_RENDERER_KIND, UI_TAG, USDC_DECIMALS, USDC_NAME, USDC_SYMBOL, type UiCoordinate, VERSION, type VerificationResult, type VerifyOptions, type Violation, WEB_OF_TRUST_KIND, WORKFLOW_CHAIN_KIND, type WorkflowDefinitionParams, type WorkflowStep, type WotDeclarationParams, analyzeDockerfileForNonDeterminism, assignAddressFromHandshake,
|
|
4558
|
+
export { AddressRegistry, type AgentRuntimeClient, ArDrivePeerRegistry, AttestationBootstrap, type AttestationBootstrapConfig, type AttestationBootstrapEvent, type AttestationBootstrapEventListener, type AttestationBootstrapResult, type AttestationEventOptions, AttestationState, AttestationVerifier, type AttestationVerifierConfig, type AttestedResultVerificationOptions, type AttestedResultVerificationResult, AttestedResultVerifier, BLOB_STORAGE_REQUEST_KIND, BLOB_STORAGE_RESULT_KIND, type BlobStorageRequestParams, type BootstrapConfig, BootstrapError, type BootstrapEvent, type BootstrapEventListener, type BootstrapPhase, type BootstrapResult, BootstrapService, type BootstrapServiceConfig, type BtpHandshakeExtension, type BuildIlpPeerInfoOptions, type BuildIlpPrepareParams, CHAIN_PRESETS, type CalculateRouteAmountParams, type ChainName, type ChainPreset, type ChainProviderConfigEntry, type ChainType, type ChannelState, type ClientNetworkPresets, type ConnectorAdminClient, type ConnectorAdminLike, type ConnectorChannelClient, type ConnectorChannelLike, type ConnectorNodeLike, type CustomEndpoints, type DeriveFromKmsSeedOptions, type DeterminismReport, type DirectRuntimeClientConfig, type DiscoveredPeer, type DiscoveryTracker, type DiscoveryTrackerConfig, type DvmJobStatus, type EVMProviderConfigEntry, EXPIRATION_TAG, type EmbeddableConnectorLike, type ForbiddenPattern, type GenesisPeer, GenesisPeerLoader, type HandlePacketAcceptResponse, type HandlePacketRejectResponse, type HandlePacketRequest, type HandlePacketResponse, ILP_PEER_INFO_KIND, ILP_ROOT_PREFIX, ILP_TO_SEMANTIC, IMAGE_GENERATION_KIND, type IlpClient, type IlpPeerInfo, type IlpPreparePacket, type IlpSendResult, JOB_FEEDBACK_KIND, JOB_REQUEST_KIND_BASE, JOB_RESULT_KIND_BASE, JOB_REVIEW_KIND, type JobFeedbackParams, type JobRequestParams, type JobResultParams, type JobReviewParams, KmsIdentityError, type KmsKeypair, type KnownPeer, type LogEntry, type LogLevel, type Logger, type LoggerConfig, MINA_CHAIN_PRESETS, MOCK_USDC_ADDRESS, MOCK_USDC_CONFIG, type MinaChainName, type MinaChainPreset, type MinaProviderConfigEntry, type MockUsdcConfig, type MultiChainName, type NetworkFamilyStatus, type NetworkMode, type NetworkNodeEnv, type NetworkProfile, type NixBuildResult, NixBuilder, type NixBuilderConfig, NostrPeerDiscovery, type OpenChannelParams, type OpenChannelResult, PET_INTERACTION_EVENT_KIND, PET_INTERACTION_REQUEST_KIND, PET_INTERACTION_RESULT_KIND, PREFIX_CLAIM_KIND, PREFIX_GRANT_KIND, type PacketHandler, type ParsedAttestation, type ParsedBlobStorageRequest, type ParsedJobFeedback, type ParsedJobRequest, type ParsedJobResult, type ParsedJobReview, type ParsedSwarmRequest, type ParsedSwarmSelection, type ParsedWorkflowDefinition, type ParsedWotDeclaration, PcrReproducibilityError, type PcrReproducibilityResult, type PeerDescriptor, type PrefixClaimContent, type PrefixGrantContent, type PrefixValidationResult, type PublishSeedRelayConfig, RELAY_ONLY_CHAIN, type RegisterPeerParams, type ReputationScore, ReputationScoreCalculator, type ReputationSignals, type ResolveRouteFeesParams, type ResolveRouteFeesResult, SEED_RELAY_LIST_KIND, SERVICE_DISCOVERY_KIND, SOLANA_CHAIN_PRESETS, SeedRelayDiscovery, type SeedRelayDiscoveryConfig, type SeedRelayDiscoveryResult, type SeedRelayEntry, type SendPacketParams, type SendPacketResult, type ServiceDiscoveryContent, type SettlementConfig, type SkillDescriptor, type SocialDiscoveryEvent, type SocialDiscoveryEventListener, SocialPeerDiscovery, type SocialPeerDiscoveryConfig, type SolanaChainName, type SolanaChainPreset, type SolanaProviderConfigEntry, type Subscription, type SwapPair, type SwarmRequestParams, type SwarmSelectionParams, TEE_ATTESTATION_KIND, TEXT_GENERATION_KIND, TEXT_TO_SPEECH_KIND, TRANSLATION_KIND, type TeeAttestation, ToonError, type ToonNode, type ToonNodeConfig, type ToonNodeStartResult, UI_RENDERER_KIND, UI_TAG, USDC_DECIMALS, USDC_NAME, USDC_SYMBOL, type UiCoordinate, VERSION, type VerificationResult, type VerifyOptions, type Violation, WEB_OF_TRUST_KIND, WORKFLOW_CHAIN_KIND, type WorkflowDefinitionParams, type WorkflowStep, type WotDeclarationParams, analyzeDockerfileForNonDeterminism, assignAddressFromHandshake, base58Decode, base58Encode, buildAttestationEvent, buildBlobStorageRequest, buildEip712Domain, buildEvmProviderEntry, buildIlpPeerInfoEvent, buildIlpPrepare, buildJobFeedbackEvent, buildJobRequestEvent, buildJobResultEvent, buildJobReviewEvent, buildMinaProviderEntry, buildPrefixClaimEvent, buildPrefixGrantEvent, buildPrefixHandshakeData, buildSeedRelayListEvent, buildServiceDiscoveryEvent, buildSolanaProviderEntry, buildSwarmRequestEvent, buildSwarmSelectionEvent, buildUiCoordinate, buildWorkflowDefinitionEvent, buildWotDeclarationEvent, calculateRouteAmount, checkAddressCollision, createAgentRuntimeClient, createDirectChannelClient, createDirectConnectorAdmin, createDirectIlpClient, createDirectRuntimeClient, createDiscoveryTracker, createHttpChannelClient, createHttpConnectorAdmin, createHttpIlpClient$1 as createHttpIlpClient, createHttpRuntimeClient, createHttpIlpClient as createHttpRuntimeClientV2, createLogger, createToonNode, deriveChildAddress, deriveFromKmsSeed, deriveMinaPublicKeyBase58, extractPrefixFromHandshake, getEventExpiration, getUiCoordinate, hasMinReputation, hasRequireAttestation, hexToMinaBase58PrivateKey, ilpCodeToSemantic, isEventExpired, isGenesisNode, isValidIlpAddressStructure, negotiateSettlementChain, parseAttestation, parseBlobStorageRequest, parseIlpPeerInfo, parseJobFeedback, parseJobRequest, parseJobResult, parseJobReview, parsePrefixClaimEvent, parsePrefixGrantEvent, parseSeedRelayList, parseServiceDiscovery, parseSwarmRequest, parseSwarmSelection, parseUiCoordinate, parseWorkflowDefinition, parseWotDeclaration, publishSeedRelayEntry, readDockerfileNix, resolveChainConfig, resolveClientNetwork, resolveMinaChainConfig, resolveNetworkProfile, resolveRouteFees, resolveSolanaChainConfig, resolveTokenForChain, selectLatestAddressable, validateChainId, validateIlpAddress, validatePrefix, validatePrefixConsistency, verifyPcrReproducibility };
|
package/dist/index.js
CHANGED
|
@@ -2948,150 +2948,17 @@ function resolveTokenForChain(chain, requesterPreferredTokens, responderPreferre
|
|
|
2948
2948
|
}
|
|
2949
2949
|
|
|
2950
2950
|
// src/settlement/hashes.ts
|
|
2951
|
-
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
2952
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2953
2951
|
import {
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
}
|
|
2964
|
-
function bigintToBytes32BE(x) {
|
|
2965
|
-
if (x < 0n) {
|
|
2966
|
-
throw new Error("bigint must be non-negative for balance-proof encoding");
|
|
2967
|
-
}
|
|
2968
|
-
const out = new Uint8Array(32);
|
|
2969
|
-
let v = x;
|
|
2970
|
-
for (let i = 31; i >= 0; i--) {
|
|
2971
|
-
out[i] = Number(v & 0xffn);
|
|
2972
|
-
v >>= 8n;
|
|
2973
|
-
}
|
|
2974
|
-
if (v !== 0n) {
|
|
2975
|
-
throw new Error("bigint exceeds 256 bits");
|
|
2976
|
-
}
|
|
2977
|
-
return out;
|
|
2978
|
-
}
|
|
2979
|
-
function concatBytes(...parts) {
|
|
2980
|
-
let len = 0;
|
|
2981
|
-
for (const p of parts) len += p.length;
|
|
2982
|
-
const out = new Uint8Array(len);
|
|
2983
|
-
let o = 0;
|
|
2984
|
-
for (const p of parts) {
|
|
2985
|
-
out.set(p, o);
|
|
2986
|
-
o += p.length;
|
|
2987
|
-
}
|
|
2988
|
-
return out;
|
|
2989
|
-
}
|
|
2990
|
-
var EIP712_PREFIX = new Uint8Array([25, 1]);
|
|
2991
|
-
var EIP712DOMAIN_TYPEHASH = keccak_256(
|
|
2992
|
-
new TextEncoder().encode(
|
|
2993
|
-
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
|
|
2994
|
-
)
|
|
2995
|
-
);
|
|
2996
|
-
var DOMAIN_NAME_HASH = keccak_256(new TextEncoder().encode("RollingSwapChannel"));
|
|
2997
|
-
var DOMAIN_VERSION_HASH = keccak_256(new TextEncoder().encode("2"));
|
|
2998
|
-
var CLAIM_TYPEHASH = keccak_256(
|
|
2999
|
-
new TextEncoder().encode(
|
|
3000
|
-
"ClaimBalanceProof(bytes32 channelId,uint256 cumulativeAmount,uint256 nonce,address recipient)"
|
|
3001
|
-
)
|
|
3002
|
-
);
|
|
3003
|
-
var COOP_CLOSE_TYPEHASH = keccak_256(
|
|
3004
|
-
new TextEncoder().encode(
|
|
3005
|
-
"CooperativeClose(bytes32 channelId,uint256 cumulativeAmount,uint256 nonce)"
|
|
3006
|
-
)
|
|
3007
|
-
);
|
|
3008
|
-
function leftPad32(bytes) {
|
|
3009
|
-
if (bytes.length > 32) {
|
|
3010
|
-
throw new Error(`cannot left-pad ${bytes.length} bytes into 32`);
|
|
3011
|
-
}
|
|
3012
|
-
const out = new Uint8Array(32);
|
|
3013
|
-
out.set(bytes, 32 - bytes.length);
|
|
3014
|
-
return out;
|
|
3015
|
-
}
|
|
3016
|
-
function eip712DomainSeparatorEvm(chainId, verifyingContractBytes) {
|
|
3017
|
-
if (verifyingContractBytes.length !== 20) {
|
|
3018
|
-
throw new Error(
|
|
3019
|
-
`verifyingContract must be 20 bytes (got ${verifyingContractBytes.length})`
|
|
3020
|
-
);
|
|
3021
|
-
}
|
|
3022
|
-
return keccak_256(
|
|
3023
|
-
concatBytes(
|
|
3024
|
-
EIP712DOMAIN_TYPEHASH,
|
|
3025
|
-
DOMAIN_NAME_HASH,
|
|
3026
|
-
DOMAIN_VERSION_HASH,
|
|
3027
|
-
bigintToBytes32BE(chainId),
|
|
3028
|
-
leftPad32(verifyingContractBytes)
|
|
3029
|
-
)
|
|
3030
|
-
);
|
|
3031
|
-
}
|
|
3032
|
-
function eip712Digest(domainSeparator, structHash) {
|
|
3033
|
-
return keccak_256(concatBytes(EIP712_PREFIX, domainSeparator, structHash));
|
|
3034
|
-
}
|
|
3035
|
-
function balanceProofHashEvm(channelIdBytes, cumulativeAmount, nonce, recipientBytes, chainId, verifyingContractBytes) {
|
|
3036
|
-
if (channelIdBytes.length !== 32) {
|
|
3037
|
-
throw new Error(`channelId must be 32 bytes (got ${channelIdBytes.length})`);
|
|
3038
|
-
}
|
|
3039
|
-
if (recipientBytes.length !== 20) {
|
|
3040
|
-
throw new Error(`recipient must be 20 bytes (got ${recipientBytes.length})`);
|
|
3041
|
-
}
|
|
3042
|
-
const structHash = keccak_256(
|
|
3043
|
-
concatBytes(
|
|
3044
|
-
CLAIM_TYPEHASH,
|
|
3045
|
-
channelIdBytes,
|
|
3046
|
-
bigintToBytes32BE(cumulativeAmount),
|
|
3047
|
-
bigintToBytes32BE(nonce),
|
|
3048
|
-
leftPad32(recipientBytes)
|
|
3049
|
-
)
|
|
3050
|
-
);
|
|
3051
|
-
return eip712Digest(
|
|
3052
|
-
eip712DomainSeparatorEvm(chainId, verifyingContractBytes),
|
|
3053
|
-
structHash
|
|
3054
|
-
);
|
|
3055
|
-
}
|
|
3056
|
-
function coopCloseHashEvm(channelIdBytes, cumulativeAmount, nonce, chainId, verifyingContractBytes) {
|
|
3057
|
-
if (channelIdBytes.length !== 32) {
|
|
3058
|
-
throw new Error(`channelId must be 32 bytes (got ${channelIdBytes.length})`);
|
|
3059
|
-
}
|
|
3060
|
-
const structHash = keccak_256(
|
|
3061
|
-
concatBytes(
|
|
3062
|
-
COOP_CLOSE_TYPEHASH,
|
|
3063
|
-
channelIdBytes,
|
|
3064
|
-
bigintToBytes32BE(cumulativeAmount),
|
|
3065
|
-
bigintToBytes32BE(nonce)
|
|
3066
|
-
)
|
|
3067
|
-
);
|
|
3068
|
-
return eip712Digest(
|
|
3069
|
-
eip712DomainSeparatorEvm(chainId, verifyingContractBytes),
|
|
3070
|
-
structHash
|
|
3071
|
-
);
|
|
3072
|
-
}
|
|
3073
|
-
function balanceProofHashSolana(channelId, cumulativeAmount, nonce, recipient) {
|
|
3074
|
-
return sha256(
|
|
3075
|
-
concatBytes(
|
|
3076
|
-
new TextEncoder().encode(channelId),
|
|
3077
|
-
bigintToBytes32BE(cumulativeAmount),
|
|
3078
|
-
bigintToBytes32BE(nonce),
|
|
3079
|
-
new TextEncoder().encode(recipient)
|
|
3080
|
-
)
|
|
3081
|
-
);
|
|
3082
|
-
}
|
|
3083
|
-
function minaHashToField(s) {
|
|
3084
|
-
const digestHex = bytesToHex(sha256(new TextEncoder().encode(s)));
|
|
3085
|
-
return BigInt("0x" + digestHex.slice(0, 60));
|
|
3086
|
-
}
|
|
3087
|
-
function balanceProofFieldsMina(channelId, cumulativeAmount, nonce, recipient) {
|
|
3088
|
-
return [
|
|
3089
|
-
minaHashToField(channelId),
|
|
3090
|
-
cumulativeAmount,
|
|
3091
|
-
nonce,
|
|
3092
|
-
minaHashToField(recipient)
|
|
3093
|
-
];
|
|
3094
|
-
}
|
|
2952
|
+
hexToBytes,
|
|
2953
|
+
bigintToBytes32BE,
|
|
2954
|
+
concatBytes,
|
|
2955
|
+
eip712DomainSeparatorEvm,
|
|
2956
|
+
balanceProofHashEvm,
|
|
2957
|
+
coopCloseHashEvm,
|
|
2958
|
+
balanceProofHashSolana,
|
|
2959
|
+
minaHashToField,
|
|
2960
|
+
balanceProofFieldsMina
|
|
2961
|
+
} from "@toon-protocol/settlement-digest";
|
|
3095
2962
|
|
|
3096
2963
|
// src/settlement/base58.ts
|
|
3097
2964
|
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -3133,7 +3000,7 @@ function base58Decode(str) {
|
|
|
3133
3000
|
}
|
|
3134
3001
|
|
|
3135
3002
|
// src/settlement/mina-key.ts
|
|
3136
|
-
import { sha256
|
|
3003
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
3137
3004
|
var MINA_PRIVATE_KEY_VERSION = 90;
|
|
3138
3005
|
function hexToMinaBase58PrivateKey(privateKey) {
|
|
3139
3006
|
if (!/^(0x)?[0-9a-fA-F]{64}$/.test(privateKey)) {
|
|
@@ -3145,7 +3012,7 @@ function hexToMinaBase58PrivateKey(privateKey) {
|
|
|
3145
3012
|
Uint8Array.from([MINA_PRIVATE_KEY_VERSION, 1]),
|
|
3146
3013
|
leScalar
|
|
3147
3014
|
);
|
|
3148
|
-
const checksum =
|
|
3015
|
+
const checksum = sha256(sha256(payload)).slice(0, 4);
|
|
3149
3016
|
return base58Encode(concatBytes(payload, checksum));
|
|
3150
3017
|
}
|
|
3151
3018
|
async function deriveMinaPublicKeyBase58(privateKey) {
|
|
@@ -4692,9 +4559,13 @@ var CHAIN_PRESETS = {
|
|
|
4692
4559
|
name: "base-sepolia",
|
|
4693
4560
|
chainId: 84532,
|
|
4694
4561
|
rpcUrl: "https://sepolia.base.org",
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4562
|
+
// Post-2026-07-19 public-chain cutover addresses (source of truth: toon-meta
|
|
4563
|
+
// docs/deployment.md). USDC is a 6-decimal mock with an ungated mint; the
|
|
4564
|
+
// retired e2e deployment (18-decimal USDC 0xac806…, TokenNetwork 0x47616F4b…,
|
|
4565
|
+
// registry 0xb9516c…) is still on-chain but MUST NOT be used.
|
|
4566
|
+
usdcAddress: "0x49beE1Bca5d15Fb0963117923403F9498119a9Ce",
|
|
4567
|
+
tokenNetworkAddress: "0x1E95493fEF46707E034b4a1945f25a8C76A1823D",
|
|
4568
|
+
registryAddress: "0xcC9079adE929b168B54145f6d25262b64FAB9D5b"
|
|
4698
4569
|
},
|
|
4699
4570
|
// Base mainnet (public). USDC is Circle's native USDC on Base.
|
|
4700
4571
|
// TOON TokenNetwork/registry not deployed yet → settlement relay-only.
|
|
@@ -4849,8 +4720,12 @@ var EVM_TIER = {
|
|
|
4849
4720
|
var SOLANA_DEPLOYED_DEVNET = {
|
|
4850
4721
|
rpcUrl: "https://api.devnet.solana.com",
|
|
4851
4722
|
cluster: "devnet",
|
|
4852
|
-
|
|
4853
|
-
|
|
4723
|
+
// Post-2026-07-19 public-chain cutover (source of truth: toon-meta
|
|
4724
|
+
// docs/deployment.md). USDC mint authority is the faucet treasury
|
|
4725
|
+
// AEPoA5xT…; the pre-cutover self-hosted-validator values (mint
|
|
4726
|
+
// 9FtYCX…, program EdJxYPD…) are retired and MUST NOT be used.
|
|
4727
|
+
usdcMint: "xyc5J8MgKFiEN13PnfftdXxUzYH34FEvw1LCrFwN7in",
|
|
4728
|
+
programId: "2aEVJ8koKD8LTZrLRSGtAtU7LBt4e7QjjCgf1kzQ7Rip"
|
|
4854
4729
|
};
|
|
4855
4730
|
var SOLANA_TIER = {
|
|
4856
4731
|
mainnet: {
|
|
@@ -5226,8 +5101,8 @@ var NixBuilder = class {
|
|
|
5226
5101
|
);
|
|
5227
5102
|
}
|
|
5228
5103
|
const imageData = await readFile(imagePath);
|
|
5229
|
-
const
|
|
5230
|
-
const imageHash = `sha256:${
|
|
5104
|
+
const sha2562 = createHash("sha256").update(imageData).digest("hex");
|
|
5105
|
+
const imageHash = `sha256:${sha2562}`;
|
|
5231
5106
|
const pcr0 = createHash("sha384").update(imageData).digest("hex");
|
|
5232
5107
|
const KERNEL_REGION_SIZE = 1024 * 1024;
|
|
5233
5108
|
const kernelRegion = imageData.subarray(
|