@derivexyz/derive-ts 3.0.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/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +193 -0
- package/codecs/package.json +7 -0
- package/dist/chunk-WR2IIVUC.js +289 -0
- package/dist/chunk-WR2IIVUC.js.map +1 -0
- package/dist/codecs/index.cjs +319 -0
- package/dist/codecs/index.cjs.map +1 -0
- package/dist/codecs/index.d.cts +264 -0
- package/dist/codecs/index.d.ts +264 -0
- package/dist/codecs/index.js +37 -0
- package/dist/codecs/index.js.map +1 -0
- package/dist/endpointMap-BBTkarIm.d.cts +45 -0
- package/dist/endpointMap-BOOWiqXf.d.ts +45 -0
- package/dist/generated-DwMaydIF.d.cts +5930 -0
- package/dist/generated-DwMaydIF.d.ts +5930 -0
- package/dist/index.cjs +2729 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1463 -0
- package/dist/index.d.ts +1463 -0
- package/dist/index.js +2405 -0
- package/dist/index.js.map +1 -0
- package/dist/scopes-RzGb3xH6.d.cts +108 -0
- package/dist/scopes-RzGb3xH6.d.ts +108 -0
- package/dist/types/endpoints.cjs +19 -0
- package/dist/types/endpoints.cjs.map +1 -0
- package/dist/types/endpoints.d.cts +2 -0
- package/dist/types/endpoints.d.ts +2 -0
- package/dist/types/endpoints.js +1 -0
- package/dist/types/endpoints.js.map +1 -0
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +7 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { D as DecimalLike, P as ProtocolScopeCode } from '../scopes-RzGb3xH6.js';
|
|
2
|
+
import { D as Direction } from '../generated-DwMaydIF.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Inputs to the trade (order) action payload, verified by the trade
|
|
6
|
+
* module (`network.modules.trade`).
|
|
7
|
+
*/
|
|
8
|
+
interface TradeActionFields {
|
|
9
|
+
/** Protocol asset contract of the instrument (`base_asset_address`). */
|
|
10
|
+
assetAddress: string;
|
|
11
|
+
/** Asset sub id (`base_asset_sub_id`): 0 for perps/spot, the option id for options. */
|
|
12
|
+
subId: string | number | bigint;
|
|
13
|
+
limitPrice: DecimalLike;
|
|
14
|
+
amount: DecimalLike;
|
|
15
|
+
/** Worst acceptable fee per unit traded the signature allows. */
|
|
16
|
+
maxFee: DecimalLike;
|
|
17
|
+
/** Subaccount credited with the fill — the trading subaccount itself. */
|
|
18
|
+
recipientSubaccountId: number | bigint;
|
|
19
|
+
isBid: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Encodes the order action data: seven static words — asset, subId,
|
|
23
|
+
* limitPrice, amount, maxFee, recipientId, isBid — with
|
|
24
|
+
* prices/amounts/fee e18-scaled.
|
|
25
|
+
*/
|
|
26
|
+
declare function encodeTradeData(fields: TradeActionFields): string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Spot transfer between subaccounts of the same owner, verified by the
|
|
30
|
+
* transfer module. Position transfers are booked as RFQ trades — this
|
|
31
|
+
* action only ever moves a single spot asset.
|
|
32
|
+
*/
|
|
33
|
+
interface TransferFields {
|
|
34
|
+
toSubaccountId: number | bigint;
|
|
35
|
+
/**
|
|
36
|
+
* Routing sentinel: 0 credits the existing `toSubaccountId`; non-zero
|
|
37
|
+
* creates a new subaccount under this manager id instead (the
|
|
38
|
+
* destination id is then ignored).
|
|
39
|
+
*/
|
|
40
|
+
newSubaccountManager: number | bigint;
|
|
41
|
+
/** Protocol spot-asset address (not the underlying ERC-20). */
|
|
42
|
+
asset: string;
|
|
43
|
+
subId: number | bigint;
|
|
44
|
+
/** Strictly positive; signed at e18. */
|
|
45
|
+
amount: DecimalLike;
|
|
46
|
+
/** Maximum fee the signer authorises, in USD; signed at e18. */
|
|
47
|
+
maxFeeUsd: DecimalLike;
|
|
48
|
+
}
|
|
49
|
+
/** ABI-encodes transfer action data: six static 32-byte words. */
|
|
50
|
+
declare function encodeTransfer(fields: TransferFields): string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Spot transfer to another owner's wallet, verified by the external
|
|
54
|
+
* transfer module: the six transfer words plus a seventh holding the
|
|
55
|
+
* recipient wallet.
|
|
56
|
+
*/
|
|
57
|
+
interface ExternalTransferFields extends TransferFields {
|
|
58
|
+
/**
|
|
59
|
+
* Destination owner wallet. `toSubaccountId` must be one of its existing
|
|
60
|
+
* subaccounts, or 0 to create one for it under `newSubaccountManager`.
|
|
61
|
+
*/
|
|
62
|
+
recipient: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* All seven words are static, so the encoding is exactly the transfer
|
|
66
|
+
* payload with the recipient appended as a left-padded address word.
|
|
67
|
+
*/
|
|
68
|
+
declare function encodeExternalTransfer(fields: ExternalTransferFields): string;
|
|
69
|
+
|
|
70
|
+
/** Withdrawal to L1, verified by the withdrawal module. */
|
|
71
|
+
interface WithdrawalFields {
|
|
72
|
+
/** Protocol asset contract address (not the underlying ERC-20). */
|
|
73
|
+
protocolAsset: string;
|
|
74
|
+
/** Maximum fee the signer authorises, in USD; signed at e18 like every other action value. */
|
|
75
|
+
maxFeeUsd: DecimalLike;
|
|
76
|
+
/** L1 payout recipient. The exchange only constructs withdrawals paying out to the action signer. */
|
|
77
|
+
recipient: string;
|
|
78
|
+
/**
|
|
79
|
+
* Withdrawal amount in the ERC-20's NATIVE decimals (USDC = 6) — the
|
|
80
|
+
* protocol's only never-scaled amount, since it is the L1 payout value.
|
|
81
|
+
*/
|
|
82
|
+
amount: DecimalLike;
|
|
83
|
+
/** The underlying ERC-20's decimals, used to scale `amount`. */
|
|
84
|
+
decimals: number;
|
|
85
|
+
/** Pay a higher fee for immediate batch proving. */
|
|
86
|
+
forceBatch: boolean;
|
|
87
|
+
}
|
|
88
|
+
/** ABI-encodes withdrawal action data: five static 32-byte words. */
|
|
89
|
+
declare function encodeWithdrawal(fields: WithdrawalFields): string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* RFQ action-data codecs.
|
|
93
|
+
*
|
|
94
|
+
* Maker and taker must hash byte-identical leg bundles: legs are sorted
|
|
95
|
+
* lexicographically by instrument name, and each signed leg amount is
|
|
96
|
+
* `amount × legDirectionSign × directionSign × perspectiveSign`. The maker
|
|
97
|
+
* encodes with their own quote direction (perspective +1); the taker
|
|
98
|
+
* executes with the opposite direction and perspective −1, which cancels
|
|
99
|
+
* back to the maker's exact values — the server rebuilds the taker's
|
|
100
|
+
* order hash from the maker's stored quote.
|
|
101
|
+
*/
|
|
102
|
+
/** A quoted leg carrying everything the signature commits to. */
|
|
103
|
+
interface RfqSignedLeg {
|
|
104
|
+
/** Canonical ordering key — both sides sign legs sorted by this. */
|
|
105
|
+
instrumentName: string;
|
|
106
|
+
/** Protocol asset contract for the instrument (option or perp). */
|
|
107
|
+
assetAddress: string;
|
|
108
|
+
/** Asset sub id: '0' for perps, the option's encoded sub id otherwise. */
|
|
109
|
+
subId: string | bigint;
|
|
110
|
+
/** Per-unit price, always positive; e18-scaled into the signed bytes. */
|
|
111
|
+
price: DecimalLike;
|
|
112
|
+
/** Unsigned size — direction carries the sign. */
|
|
113
|
+
amount: DecimalLike;
|
|
114
|
+
direction: Direction;
|
|
115
|
+
}
|
|
116
|
+
interface RfqQuoteFields {
|
|
117
|
+
/** Worst fee the signer accepts, in USD; e18 in the signed bytes. */
|
|
118
|
+
maxFee: DecimalLike;
|
|
119
|
+
/** The maker's quote direction (taker execute: the taker's own direction). */
|
|
120
|
+
direction: Direction;
|
|
121
|
+
legs: RfqSignedLeg[];
|
|
122
|
+
}
|
|
123
|
+
/** Sorts legs into the canonical order both counterparties sign and send. */
|
|
124
|
+
declare function sortRfqLegs<T extends {
|
|
125
|
+
instrumentName: string;
|
|
126
|
+
}>(legs: readonly T[]): T[];
|
|
127
|
+
/**
|
|
128
|
+
* Maker quote data: `abi.encode(RfqOrder{ maxFee, trades[] })` —
|
|
129
|
+
* `[0x20][maxFee][0x40][N][4 words per leg]`. Unlike the trade codec's
|
|
130
|
+
* low-16-byte i128 amount words, a negative leg amount here is a full
|
|
131
|
+
* sign-extended int256 (high 16 bytes 0xff), which is standard AbiCoder
|
|
132
|
+
* output.
|
|
133
|
+
*/
|
|
134
|
+
declare function encodeRfqQuote(fields: RfqQuoteFields): string;
|
|
135
|
+
/**
|
|
136
|
+
* Taker execute data: `abi.encode(bytes32 orderHash, uint256 maxFee)` where
|
|
137
|
+
* `orderHash = keccak256(abi.encode(trades[]))` — the maker's legs only,
|
|
138
|
+
* maker maxFee excluded. `fields.direction` is the TAKER's direction
|
|
139
|
+
* (opposite of the quote's); `fields.maxFee` is the taker's own fee cap.
|
|
140
|
+
*/
|
|
141
|
+
declare function encodeRfqExecute(fields: RfqQuoteFields): string;
|
|
142
|
+
|
|
143
|
+
/** Word-0 kind discriminators. */
|
|
144
|
+
declare const VAULT_ACTION_KIND: {
|
|
145
|
+
readonly create: 0;
|
|
146
|
+
readonly deposit: 1;
|
|
147
|
+
readonly withdraw: 2;
|
|
148
|
+
readonly cancel: 3;
|
|
149
|
+
readonly mintShares: 4;
|
|
150
|
+
readonly burnShares: 5;
|
|
151
|
+
};
|
|
152
|
+
interface VaultDepositFields {
|
|
153
|
+
vaultSubaccountId: number | bigint;
|
|
154
|
+
/** Must equal the vault's configured deposit asset (protocol spot-asset address). */
|
|
155
|
+
depositSpotAsset: string;
|
|
156
|
+
/** Deposit amount in the deposit asset's units; max 12 decimal places. */
|
|
157
|
+
amount: DecimalLike;
|
|
158
|
+
}
|
|
159
|
+
/** VaultDepositData (kind = 1, 4 words): [kind, vaultSubaccountId, depositSpotAsset, amountE18]. */
|
|
160
|
+
declare function encodeVaultDeposit(fields: VaultDepositFields): string;
|
|
161
|
+
interface VaultWithdrawFields {
|
|
162
|
+
vaultSubaccountId: number | bigint;
|
|
163
|
+
/** Vault shares to redeem; max 12 decimal places. */
|
|
164
|
+
sharesToBurn: DecimalLike;
|
|
165
|
+
}
|
|
166
|
+
/** VaultWithdrawData (kind = 2, 3 words): [kind, vaultSubaccountId, sharesToBurnE18]. */
|
|
167
|
+
declare function encodeVaultWithdraw(fields: VaultWithdrawFields): string;
|
|
168
|
+
/**
|
|
169
|
+
* VaultCancelData (kind = 3, 2 words): [kind, vaultSubaccountId].
|
|
170
|
+
* Invalidates ALL of the signer's pending intents for the vault by
|
|
171
|
+
* bumping their per-(vault, holder) nonce to the envelope's nonce.
|
|
172
|
+
*/
|
|
173
|
+
declare function encodeVaultCancel(vaultSubaccountId: number | bigint): string;
|
|
174
|
+
interface VaultCreateFields {
|
|
175
|
+
managerId: number;
|
|
176
|
+
depositSpotAsset: string;
|
|
177
|
+
/** Initial deposit moved funding subaccount → vault; max 12 decimal places. */
|
|
178
|
+
initialDeposit: DecimalLike;
|
|
179
|
+
managementFeeBps: number;
|
|
180
|
+
performanceFeeBps: number;
|
|
181
|
+
maxSlippageBps: number;
|
|
182
|
+
cooldownSec: number | bigint;
|
|
183
|
+
/** Maximum settlement fee authorised, in USD; max 12 decimal places. */
|
|
184
|
+
maxFeeUsd: DecimalLike;
|
|
185
|
+
/** Share price the vault is seeded at, in USD; max 12 decimal places. */
|
|
186
|
+
initialSharePriceUsd: DecimalLike;
|
|
187
|
+
/**
|
|
188
|
+
* Spot asset the high-water mark is denominated in. Omit for the
|
|
189
|
+
* feed-less USD default — presence drives the encoded hasBenchmark
|
|
190
|
+
* flag, exactly as the exchange derives it from the wire param.
|
|
191
|
+
*/
|
|
192
|
+
benchmarkAsset?: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Create-vault action data (kind = 0, 12 words):
|
|
196
|
+
* [kind, managerId, depositSpotAsset, initialDepositE18,
|
|
197
|
+
* managementFeeBps, performanceFeeBps, maxSlippageBps, cooldownSec,
|
|
198
|
+
* maxFeeUsdE18, initialSharePriceUsdE18, benchmarkAsset, hasBenchmark].
|
|
199
|
+
* bps rates and cooldownSec are plain integers, not e18.
|
|
200
|
+
*/
|
|
201
|
+
declare function encodeVaultCreate(fields: VaultCreateFields): string;
|
|
202
|
+
interface VaultMintSharesFields {
|
|
203
|
+
/** Quoted share price in USD per share; max 12 decimal places. */
|
|
204
|
+
sharePrice: DecimalLike;
|
|
205
|
+
/** keccak256 of the user's exact encoded deposit action (0x hex, 32 bytes). */
|
|
206
|
+
depositHash: string;
|
|
207
|
+
}
|
|
208
|
+
/** MintSharesActionData (kind = 4): the curator's approval to settle one queued deposit. */
|
|
209
|
+
declare function encodeVaultMintShares(fields: VaultMintSharesFields): string;
|
|
210
|
+
interface VaultBurnSharesFields {
|
|
211
|
+
/** Quoted share price in USD per share; max 12 decimal places. */
|
|
212
|
+
sharePrice: DecimalLike;
|
|
213
|
+
/** keccak256 of the user's exact encoded withdraw action (0x hex, 32 bytes). */
|
|
214
|
+
withdrawHash: string;
|
|
215
|
+
}
|
|
216
|
+
/** BurnSharesActionData (kind = 5): the curator's approval to settle one queued withdrawal. */
|
|
217
|
+
declare function encodeVaultBurnShares(fields: VaultBurnSharesFields): string;
|
|
218
|
+
|
|
219
|
+
interface CreateSessionKeyData {
|
|
220
|
+
/** Address of the key being authorized. */
|
|
221
|
+
sessionKey: string;
|
|
222
|
+
/**
|
|
223
|
+
* The KEY's lifetime as a unix-seconds timestamp — distinct from the
|
|
224
|
+
* envelope's signature expiry. The key stops working once `expirySec <= now`;
|
|
225
|
+
* pass 0 to deactivate an existing key of this address.
|
|
226
|
+
*/
|
|
227
|
+
expirySec: number;
|
|
228
|
+
/**
|
|
229
|
+
* Scope codes granted to the key (auth/scopes.ts). Typed as `number` at
|
|
230
|
+
* this low level so raw codes pass through — the typed
|
|
231
|
+
* `ProtocolScopeCode` enum guides callers, and the server is the
|
|
232
|
+
* authority on which codes are valid.
|
|
233
|
+
*/
|
|
234
|
+
scopes: readonly (ProtocolScopeCode | number)[];
|
|
235
|
+
/** Subaccounts the key may act on; empty = ALL current and future subaccounts. */
|
|
236
|
+
subaccountIds: readonly (number | bigint)[];
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Encodes the create-session-key action data.
|
|
240
|
+
*
|
|
241
|
+
* Hand-packed 32-byte words — NOT standard dynamic ABI (no offset or
|
|
242
|
+
* length-prefix head): `[session_key][expiry_sec][S][A][scope codes…]
|
|
243
|
+
* [subaccount ids…]`, every value right-aligned in its word.
|
|
244
|
+
*/
|
|
245
|
+
declare function encodeCreateSessionKeyActionData(data: CreateSessionKeyData): string;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Whitelisted-recipient delta, verified by the whitelisted-recipient
|
|
249
|
+
* module: the resulting list is `(current ∪ add) \ remove`.
|
|
250
|
+
*/
|
|
251
|
+
interface WhitelistedRecipientsFields {
|
|
252
|
+
add: string[];
|
|
253
|
+
remove: string[];
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Hand-packed layout (2 + A + R words), NOT standard ABI dynamic arrays:
|
|
257
|
+
* word 0 : add count A
|
|
258
|
+
* word 1 : remove count R
|
|
259
|
+
* word 2+i : add[i] (address, left-padded)
|
|
260
|
+
* word 2+A+j : remove[j] (address, left-padded)
|
|
261
|
+
*/
|
|
262
|
+
declare function encodeUpdateWhitelistedRecipients(fields: WhitelistedRecipientsFields): string;
|
|
263
|
+
|
|
264
|
+
export { type CreateSessionKeyData, type ExternalTransferFields, type RfqQuoteFields, type RfqSignedLeg, type TradeActionFields, type TransferFields, VAULT_ACTION_KIND, type VaultBurnSharesFields, type VaultCreateFields, type VaultDepositFields, type VaultMintSharesFields, type VaultWithdrawFields, type WhitelistedRecipientsFields, type WithdrawalFields, encodeCreateSessionKeyActionData, encodeExternalTransfer, encodeRfqExecute, encodeRfqQuote, encodeTradeData, encodeTransfer, encodeUpdateWhitelistedRecipients, encodeVaultBurnShares, encodeVaultCancel, encodeVaultCreate, encodeVaultDeposit, encodeVaultMintShares, encodeVaultWithdraw, encodeWithdrawal, sortRfqLegs };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VAULT_ACTION_KIND,
|
|
3
|
+
encodeCreateSessionKeyActionData,
|
|
4
|
+
encodeExternalTransfer,
|
|
5
|
+
encodeRfqExecute,
|
|
6
|
+
encodeRfqQuote,
|
|
7
|
+
encodeTradeData,
|
|
8
|
+
encodeTransfer,
|
|
9
|
+
encodeUpdateWhitelistedRecipients,
|
|
10
|
+
encodeVaultBurnShares,
|
|
11
|
+
encodeVaultCancel,
|
|
12
|
+
encodeVaultCreate,
|
|
13
|
+
encodeVaultDeposit,
|
|
14
|
+
encodeVaultMintShares,
|
|
15
|
+
encodeVaultWithdraw,
|
|
16
|
+
encodeWithdrawal,
|
|
17
|
+
sortRfqLegs
|
|
18
|
+
} from "../chunk-WR2IIVUC.js";
|
|
19
|
+
export {
|
|
20
|
+
VAULT_ACTION_KIND,
|
|
21
|
+
encodeCreateSessionKeyActionData,
|
|
22
|
+
encodeExternalTransfer,
|
|
23
|
+
encodeRfqExecute,
|
|
24
|
+
encodeRfqQuote,
|
|
25
|
+
encodeTradeData,
|
|
26
|
+
encodeTransfer,
|
|
27
|
+
encodeUpdateWhitelistedRecipients,
|
|
28
|
+
encodeVaultBurnShares,
|
|
29
|
+
encodeVaultCancel,
|
|
30
|
+
encodeVaultCreate,
|
|
31
|
+
encodeVaultDeposit,
|
|
32
|
+
encodeVaultMintShares,
|
|
33
|
+
encodeVaultWithdraw,
|
|
34
|
+
encodeWithdrawal,
|
|
35
|
+
sortRfqLegs
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ak as EndpointMap } from './generated-DwMaydIF.cjs';
|
|
2
|
+
|
|
3
|
+
/** Extracts the method literal from a EndpointMap entry. */
|
|
4
|
+
type MethodOf<T> = T extends {
|
|
5
|
+
request: {
|
|
6
|
+
method: infer M;
|
|
7
|
+
};
|
|
8
|
+
} ? M : never;
|
|
9
|
+
/** Extracts the request params type from a EndpointMap entry. */
|
|
10
|
+
type RequestParamsType<T> = T extends {
|
|
11
|
+
request: {
|
|
12
|
+
params: infer P;
|
|
13
|
+
};
|
|
14
|
+
} ? P : never;
|
|
15
|
+
/** Extracts the full response type (result-or-error union) from a EndpointMap entry. */
|
|
16
|
+
type ResponseType<T> = T extends {
|
|
17
|
+
response: infer S;
|
|
18
|
+
} ? S : never;
|
|
19
|
+
/** Extracts the response `result` payload from a EndpointMap entry. */
|
|
20
|
+
type ResultOf<T> = ResponseType<T> extends infer S ? (S extends {
|
|
21
|
+
result: infer R;
|
|
22
|
+
} ? R : never) : never;
|
|
23
|
+
/** Extracts the notification `data` payload from a ChannelSchemaMap entry. */
|
|
24
|
+
type ChannelDataOf<T> = T extends {
|
|
25
|
+
data: infer D;
|
|
26
|
+
} ? D : never;
|
|
27
|
+
/** Extracts the address params from a ChannelSchemaMap entry. */
|
|
28
|
+
type ChannelParamsOf<T> = T extends {
|
|
29
|
+
params: infer P;
|
|
30
|
+
} ? P : never;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The endpoint map — request/response type for every public RPC method,
|
|
34
|
+
* keyed by method string. Import this to get fully-typed params/results
|
|
35
|
+
* without pulling in the runtime client. See the "Type-only usage" README section.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** Every public RPC method literal. */
|
|
39
|
+
type RpcMethod = keyof EndpointMap & string;
|
|
40
|
+
/** Request params type for a method. */
|
|
41
|
+
type ParamsOf<M extends RpcMethod> = RequestParamsType<EndpointMap[M]>;
|
|
42
|
+
/** Result payload type for a method. */
|
|
43
|
+
type ResultFor<M extends RpcMethod> = ResultOf<EndpointMap[M]>;
|
|
44
|
+
|
|
45
|
+
export type { ChannelParamsOf as C, MethodOf as M, ParamsOf as P, RpcMethod as R, ResultFor as a, ChannelDataOf as b, RequestParamsType as c, ResponseType as d, ResultOf as e };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ak as EndpointMap } from './generated-DwMaydIF.js';
|
|
2
|
+
|
|
3
|
+
/** Extracts the method literal from a EndpointMap entry. */
|
|
4
|
+
type MethodOf<T> = T extends {
|
|
5
|
+
request: {
|
|
6
|
+
method: infer M;
|
|
7
|
+
};
|
|
8
|
+
} ? M : never;
|
|
9
|
+
/** Extracts the request params type from a EndpointMap entry. */
|
|
10
|
+
type RequestParamsType<T> = T extends {
|
|
11
|
+
request: {
|
|
12
|
+
params: infer P;
|
|
13
|
+
};
|
|
14
|
+
} ? P : never;
|
|
15
|
+
/** Extracts the full response type (result-or-error union) from a EndpointMap entry. */
|
|
16
|
+
type ResponseType<T> = T extends {
|
|
17
|
+
response: infer S;
|
|
18
|
+
} ? S : never;
|
|
19
|
+
/** Extracts the response `result` payload from a EndpointMap entry. */
|
|
20
|
+
type ResultOf<T> = ResponseType<T> extends infer S ? (S extends {
|
|
21
|
+
result: infer R;
|
|
22
|
+
} ? R : never) : never;
|
|
23
|
+
/** Extracts the notification `data` payload from a ChannelSchemaMap entry. */
|
|
24
|
+
type ChannelDataOf<T> = T extends {
|
|
25
|
+
data: infer D;
|
|
26
|
+
} ? D : never;
|
|
27
|
+
/** Extracts the address params from a ChannelSchemaMap entry. */
|
|
28
|
+
type ChannelParamsOf<T> = T extends {
|
|
29
|
+
params: infer P;
|
|
30
|
+
} ? P : never;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The endpoint map — request/response type for every public RPC method,
|
|
34
|
+
* keyed by method string. Import this to get fully-typed params/results
|
|
35
|
+
* without pulling in the runtime client. See the "Type-only usage" README section.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** Every public RPC method literal. */
|
|
39
|
+
type RpcMethod = keyof EndpointMap & string;
|
|
40
|
+
/** Request params type for a method. */
|
|
41
|
+
type ParamsOf<M extends RpcMethod> = RequestParamsType<EndpointMap[M]>;
|
|
42
|
+
/** Result payload type for a method. */
|
|
43
|
+
type ResultFor<M extends RpcMethod> = ResultOf<EndpointMap[M]>;
|
|
44
|
+
|
|
45
|
+
export type { ChannelParamsOf as C, MethodOf as M, ParamsOf as P, RpcMethod as R, ResultFor as a, ChannelDataOf as b, RequestParamsType as c, ResponseType as d, ResultOf as e };
|