@toon-protocol/client 3.3.0 → 4.0.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/{chunk-PTTRHLYV.js → chunk-2DGVNDKA.js} +2 -2
- package/dist/{chunk-G36D22II.js → chunk-CG3OXV74.js} +4379 -4912
- package/dist/chunk-CG3OXV74.js.map +1 -0
- package/dist/{chunk-O6KX7MHD.js → chunk-WJKJ6Y4N.js} +17 -8
- package/dist/{chunk-O6KX7MHD.js.map → chunk-WJKJ6Y4N.js.map} +1 -1
- package/dist/cli/main.js +134 -118
- package/dist/cli/main.js.map +1 -1
- package/dist/{client-FFEFAMJ4.js → client-7YIJOR5K.js} +7 -7
- package/dist/{hidden-service-BsBH2HNi.d.ts → hidden-service-BtIv3u0L.d.ts} +2 -123
- package/dist/index.d.ts +2743 -2972
- package/dist/index.js +125 -188
- package/dist/index.js.map +1 -1
- package/dist/transport/hidden-service.d.ts +1 -1
- package/package.json +2 -1
- package/dist/chunk-G36D22II.js.map +0 -1
- /package/dist/{chunk-PTTRHLYV.js.map → chunk-2DGVNDKA.js.map} +0 -0
- /package/dist/{client-FFEFAMJ4.js.map → client-7YIJOR5K.js.map} +0 -0
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
ConfigError,
|
|
10
10
|
ConnectorError,
|
|
11
11
|
DEFAULT_DEPOSIT,
|
|
12
|
-
DEFAULT_SETTLEMENT_TIMEOUT,
|
|
13
12
|
DEFAULT_TIMEOUT_MS,
|
|
13
|
+
FacilitatorError,
|
|
14
14
|
InsufficientBalanceError,
|
|
15
15
|
InvalidAddressError,
|
|
16
16
|
NetworkError,
|
|
17
17
|
PaymentRequiredError,
|
|
18
18
|
RouteNotPricedError,
|
|
19
|
+
SponsorRefusedError,
|
|
19
20
|
StaleRpcReadError,
|
|
20
21
|
ToonClient,
|
|
21
22
|
ToonClientError,
|
|
@@ -30,10 +31,9 @@ import {
|
|
|
30
31
|
isInsufficientGasError,
|
|
31
32
|
resolveConfig,
|
|
32
33
|
send,
|
|
33
|
-
settlementToTerms,
|
|
34
34
|
toEnvelopeRequest
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import "./chunk-
|
|
35
|
+
} from "./chunk-CG3OXV74.js";
|
|
36
|
+
import "./chunk-WJKJ6Y4N.js";
|
|
37
37
|
import "./chunk-32MD3CXE.js";
|
|
38
38
|
export {
|
|
39
39
|
BeforePayRefusedError,
|
|
@@ -46,13 +46,14 @@ export {
|
|
|
46
46
|
ConfigError,
|
|
47
47
|
ConnectorError,
|
|
48
48
|
DEFAULT_DEPOSIT,
|
|
49
|
-
DEFAULT_SETTLEMENT_TIMEOUT,
|
|
50
49
|
DEFAULT_TIMEOUT_MS,
|
|
50
|
+
FacilitatorError,
|
|
51
51
|
InsufficientBalanceError,
|
|
52
52
|
InvalidAddressError,
|
|
53
53
|
NetworkError,
|
|
54
54
|
PaymentRequiredError,
|
|
55
55
|
RouteNotPricedError,
|
|
56
|
+
SponsorRefusedError,
|
|
56
57
|
StaleRpcReadError,
|
|
57
58
|
ToonClient,
|
|
58
59
|
ToonClientError,
|
|
@@ -67,7 +68,6 @@ export {
|
|
|
67
68
|
isInsufficientGasError,
|
|
68
69
|
resolveConfig,
|
|
69
70
|
send,
|
|
70
|
-
settlementToTerms,
|
|
71
71
|
toEnvelopeRequest
|
|
72
72
|
};
|
|
73
|
-
//# sourceMappingURL=client-
|
|
73
|
+
//# sourceMappingURL=client-7YIJOR5K.js.map
|
|
@@ -1,126 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The on-chain channel port: what the client needs a chain to be able to do,
|
|
3
|
-
* independent of which chain it is.
|
|
4
|
-
*
|
|
5
|
-
* These types were `@toon-protocol/core`'s `ConnectorChannelClient` family,
|
|
6
|
-
* whose names still carried the retired admin-API model — a channel opened by
|
|
7
|
-
* `POST /admin/channels` on the connector. That is not how a channel comes into
|
|
8
|
-
* existence any more, and the naming mattered: **a connector has no endpoint
|
|
9
|
-
* that opens a channel** (`self-description-spec.md` ND-03). The client opens,
|
|
10
|
-
* funds, closes and settles the channel itself, directly on chain, and the
|
|
11
|
-
* connector discovers it by reading the chain
|
|
12
|
-
* ([ADR 0052](https://github.com/toon-protocol/connector/blob/main/docs/adr/0052-permissionless-payment-is-guaranteed-and-a-claim-is-what-authorises.md)).
|
|
13
|
-
* So this is a port over *chains*, not over the connector.
|
|
14
|
-
*/
|
|
15
|
-
/** Which settlement family a channel lives in. Mina is gone (connector ADR 0002). */
|
|
1
|
+
/** Which chain family a channel, a key or a payment lives on. */
|
|
16
2
|
type ChainKind = 'evm' | 'solana';
|
|
17
|
-
/**
|
|
18
|
-
* Everything needed to open one channel, as read off the connector's own
|
|
19
|
-
* self-description (`GET /ilp` → `settlements[]`) rather than configured.
|
|
20
|
-
*
|
|
21
|
-
* The connector proved each of these against a live chain at startup
|
|
22
|
-
* (`self-description-spec.md` ND-07), which is why they are taken from the
|
|
23
|
-
* document instead of from a preset: two declarations of one fact is how a
|
|
24
|
-
* mainnet node comes to describe itself as devnet.
|
|
25
|
-
*/
|
|
26
|
-
interface ChannelTerms {
|
|
27
|
-
kind: ChainKind;
|
|
28
|
-
/** The chain key exactly as published: `evm:84532`, or `solana`. */
|
|
29
|
-
chain: string;
|
|
30
|
-
/** EVM only: the numeric chain id parsed out of `chain`. The EIP-712 domain's `chainId`. */
|
|
31
|
-
chainId?: number;
|
|
32
|
-
/**
|
|
33
|
-
* The connector's own settlement address — the counterparty this channel is
|
|
34
|
-
* opened *with*. `0x…` on EVM, base58 on Solana.
|
|
35
|
-
*/
|
|
36
|
-
counterparty: string;
|
|
37
|
-
/** ERC-20 address, or the SPL mint. */
|
|
38
|
-
token: string;
|
|
39
|
-
/** Base units per whole token, as the connector reports it. */
|
|
40
|
-
decimals: number;
|
|
41
|
-
/** EVM: the `TokenNetwork` — the EIP-712 `verifyingContract` a claim is signed under. */
|
|
42
|
-
tokenNetwork?: string;
|
|
43
|
-
/** EVM: the `TokenNetworkRegistry` that minted the `TokenNetwork`; the stable address. */
|
|
44
|
-
tokenNetworkRegistry?: string;
|
|
45
|
-
/** Solana: the settlement program the channel account lives under, bound into every claim (ADR 0053). */
|
|
46
|
-
programId?: string;
|
|
47
|
-
}
|
|
48
|
-
/** Parameters for opening a channel on chain. */
|
|
49
|
-
interface OpenChannelParams {
|
|
50
|
-
terms: ChannelTerms;
|
|
51
|
-
/** Initial collateral, in the token's base units. */
|
|
52
|
-
initialDeposit?: bigint;
|
|
53
|
-
/**
|
|
54
|
-
* Challenge period in seconds. The EVM `TokenNetwork` enforces a one-hour
|
|
55
|
-
* floor; the Solana program takes it as the channel's `challenge_duration`.
|
|
56
|
-
*/
|
|
57
|
-
settlementTimeout?: number;
|
|
58
|
-
}
|
|
59
|
-
/** What opening produced. */
|
|
60
|
-
interface OpenChannelResult {
|
|
61
|
-
/** `0x…` 32 bytes on EVM; the channel account's base58 pubkey on Solana. */
|
|
62
|
-
channelId: string;
|
|
63
|
-
status: ChannelStatus;
|
|
64
|
-
/** The transaction that opened it. Absent when an existing channel was adopted. */
|
|
65
|
-
txHash?: string;
|
|
66
|
-
/** On-chain collateral after opening, when the opener read it back. */
|
|
67
|
-
depositTotal?: bigint;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Where a channel is in its lifecycle.
|
|
71
|
-
*
|
|
72
|
-
* `opening` is real and worth distinguishing: the opening transaction is
|
|
73
|
-
* submitted but not yet confirmed, so the channel does not exist for anyone
|
|
74
|
-
* reading the chain — including the connector, which resolves a claim's channel
|
|
75
|
-
* by reading it. A claim signed in that window is refused as naming an unknown
|
|
76
|
-
* channel, and the remedy is to wait rather than to re-sign.
|
|
77
|
-
*/
|
|
78
|
-
type ChannelStatus = 'opening' | 'open' | 'closed' | 'settled' | 'missing';
|
|
79
|
-
/** A channel as the chain currently reports it. */
|
|
80
|
-
interface OnChainChannelStatus {
|
|
81
|
-
channelId: string;
|
|
82
|
-
status: ChannelStatus;
|
|
83
|
-
/** The chain key this channel lives on, when the reader knows it. */
|
|
84
|
-
chain?: string;
|
|
85
|
-
/** This participant's collateral, in base units. */
|
|
86
|
-
deposit?: bigint;
|
|
87
|
-
/** Unix seconds the channel was closed, when it is closed. */
|
|
88
|
-
closedAt?: bigint;
|
|
89
|
-
/** Unix seconds after which `settle` is permitted. */
|
|
90
|
-
settleableAt?: bigint;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* One chain's implementation of the lifecycle.
|
|
94
|
-
*
|
|
95
|
-
* Every method here is a transaction the *client* signs and pays gas for. None
|
|
96
|
-
* of them talks to a connector.
|
|
97
|
-
*/
|
|
98
|
-
interface ChannelClient {
|
|
99
|
-
openChannel(params: OpenChannelParams): Promise<OpenChannelResult>;
|
|
100
|
-
/**
|
|
101
|
-
* Add collateral. `currentDeposit` is the channel's present total, which EVM
|
|
102
|
-
* needs because `setTotalDeposit` takes the new cumulative figure rather than
|
|
103
|
-
* a delta — a contract shape that makes a lost or duplicated call harmless.
|
|
104
|
-
*/
|
|
105
|
-
depositToChannel(channelId: string, amount: bigint, opts: {
|
|
106
|
-
currentDeposit: bigint;
|
|
107
|
-
}): Promise<{
|
|
108
|
-
txHash?: string;
|
|
109
|
-
depositTotal: bigint;
|
|
110
|
-
}>;
|
|
111
|
-
/** Start the challenge period. */
|
|
112
|
-
closeChannel(channelId: string): Promise<{
|
|
113
|
-
txHash?: string;
|
|
114
|
-
closedAt: bigint;
|
|
115
|
-
settlementTimeout: bigint;
|
|
116
|
-
settleableAt: bigint;
|
|
117
|
-
}>;
|
|
118
|
-
/** Pay out and finish. Only permitted once the challenge period has elapsed. */
|
|
119
|
-
settleChannel(channelId: string): Promise<{
|
|
120
|
-
txHash?: string;
|
|
121
|
-
}>;
|
|
122
|
-
getChannelState(channelId: string): Promise<OnChainChannelStatus>;
|
|
123
|
-
}
|
|
124
3
|
|
|
125
4
|
/**
|
|
126
5
|
* `socks5h://` URL parsing, kept apart from the transport that uses it.
|
|
@@ -298,4 +177,4 @@ declare function createChainRpcTransport(socksProxy: string, chain: ChainKind):
|
|
|
298
177
|
*/
|
|
299
178
|
declare function probeSocks5Proxy(socksProxy: string, timeoutMs?: number): Promise<void>;
|
|
300
179
|
|
|
301
|
-
export { type ChainKind as C, DEFAULT_HS_CONNECT_TIMEOUT_MS as D, type HiddenServiceTransport as H,
|
|
180
|
+
export { type ChainKind as C, DEFAULT_HS_CONNECT_TIMEOUT_MS as D, type HiddenServiceTransport as H, RPC_POOL_IDLE_TIMEOUT_MS as R, type HiddenServiceTransportOptions as a, DEFAULT_RPC_CONNECT_TIMEOUT_MS as b, RPC_SOCKS_USERNAMES as c, createChainRpcTransport as d, createHiddenServiceTransport as e, probeSocks5Proxy as p, validateSocks5hUrl as v };
|