@bitgo/public-types 7.6.1 → 7.6.3

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.
@@ -1,5 +1,4 @@
1
1
  import * as t from "io-ts";
2
- import { intentTypes } from "./intentType";
3
2
  export declare const BaseIntent: t.IntersectionC<[t.TypeC<{
4
3
  intentType: t.KeyofC<{
5
4
  payment: t.LiteralC<"payment">;
@@ -100,15 +99,105 @@ export declare const BaseIntent: t.IntersectionC<[t.TypeC<{
100
99
  nonce: t.UnionC<[t.Type<string | number, string | number, unknown>, t.UndefinedC]>;
101
100
  }>]>;
102
101
  export type BaseIntent = t.TypeOf<typeof BaseIntent>;
103
- declare const CATCH_ALL_EXCLUDED_INTENT_TYPES: readonly ["cantonGovernanceLockCreate", "cantonGovernanceLockUnlock", "cantonGovernanceLockProvisionalUnlock", "cantonGovernanceLockWithdraw", "cantonGovernanceLockProposeSubstitution", "cantonGovernanceLockProposeTransfer"];
104
- type CatchAllIntentTypesMap = Omit<typeof intentTypes, (typeof CATCH_ALL_EXCLUDED_INTENT_TYPES)[number]>;
105
- export declare const BaseIntentCatchAll: t.IntersectionC<[t.TypeC<{
106
- intentType: t.KeyofC<CatchAllIntentTypesMap>;
102
+ export declare const BaseIntentCatchAll: t.RefinementC<t.IntersectionC<[t.TypeC<{
103
+ intentType: t.KeyofC<{
104
+ payment: t.LiteralC<"payment">;
105
+ transferToken: t.LiteralC<"transferToken">;
106
+ consolidate: t.LiteralC<"consolidate">;
107
+ consolidateToken: t.LiteralC<"consolidateToken">;
108
+ fanout: t.LiteralC<"fanout">;
109
+ stake: t.LiteralC<"stake">;
110
+ unstake: t.LiteralC<"unstake">;
111
+ cancel: t.LiteralC<"cancel">;
112
+ delegate: t.LiteralC<"delegate">;
113
+ undelegate: t.LiteralC<"undelegate">;
114
+ switchValidator: t.LiteralC<"switchValidator">;
115
+ claim: t.LiteralC<"claim">;
116
+ stakeClaimRewards: t.LiteralC<"stakeClaimRewards">;
117
+ pledge: t.LiteralC<"pledge">;
118
+ voteDelegation: t.LiteralC<"voteDelegation">;
119
+ vote: t.LiteralC<"vote">;
120
+ createAccount: t.LiteralC<"createAccount">;
121
+ updateAccount: t.LiteralC<"updateAccount">;
122
+ addTrustLine: t.LiteralC<"addTrustLine">;
123
+ removeTrustLine: t.LiteralC<"removeTrustLine">;
124
+ signMessage: t.LiteralC<"signMessage">;
125
+ signTypedStructuredData: t.LiteralC<"signTypedStructuredData">;
126
+ enableToken: t.LiteralC<"enableToken">;
127
+ disableToken: t.LiteralC<"disableToken">;
128
+ authorize: t.LiteralC<"authorize">;
129
+ acceleration: t.LiteralC<"acceleration">;
130
+ fillNonce: t.LiteralC<"fillNonce">;
131
+ walletRecovery: t.LiteralC<"walletRecovery">;
132
+ contractCall: t.LiteralC<"contractCall">;
133
+ deactivate: t.LiteralC<"deactivate">;
134
+ customTx: t.LiteralC<"customTx">;
135
+ confidentialTransfer: t.LiteralC<"confidentialTransfer">;
136
+ closeAssociatedTokenAccount: t.LiteralC<"closeAssociatedTokenAccount">;
137
+ stakeWithCallData: t.LiteralC<"stakeWithCallData">;
138
+ unstakeWithCallData: t.LiteralC<"unstakeWithCallData">;
139
+ switchValidatorWithCallData: t.LiteralC<"switchValidatorWithCallData">;
140
+ feeAddressTransfer: t.LiteralC<"feeAddressTransfer">;
141
+ tokenApproval: t.LiteralC<"tokenApproval">;
142
+ transferStake: t.LiteralC<"transferStake">;
143
+ validatorRegistration: t.LiteralC<"validatorRegistration">;
144
+ increaseStake: t.LiteralC<"increaseStake">;
145
+ decreaseStake: t.LiteralC<"decreaseStake">;
146
+ signalExit: t.LiteralC<"signalExit">;
147
+ withdrawStake: t.LiteralC<"withdrawStake">;
148
+ spotTransfer: t.LiteralC<"spotTransfer">;
149
+ bridgeFunds: t.LiteralC<"bridgeFunds">;
150
+ enableBridging: t.LiteralC<"enableBridging">;
151
+ goUnstake: t.LiteralC<"goUnstake">;
152
+ createBtcDelegation: t.LiteralC<"createBtcDelegation">;
153
+ transferAccept: t.LiteralC<"transferAccept">;
154
+ transferReject: t.LiteralC<"transferReject">;
155
+ transferAcknowledge: t.LiteralC<"transferAcknowledge">;
156
+ transferOfferWithdrawn: t.LiteralC<"transferOfferWithdrawn">;
157
+ cosignDelegationProposal: t.LiteralC<"cosignDelegationProposal">;
158
+ cosignDelegationAccept: t.LiteralC<"cosignDelegationAccept">;
159
+ allocationRequest: t.LiteralC<"allocationRequest">;
160
+ cantonCommand: t.LiteralC<"cantonCommand">;
161
+ cantonBroadridgeStandingDelegation: t.LiteralC<"cantonBroadridgeStandingDelegation">;
162
+ allocationAllocate: t.LiteralC<"allocationAllocate">;
163
+ allocationOfferWithdrawn: t.LiteralC<"allocationOfferWithdrawn">;
164
+ allocationReject: t.LiteralC<"allocationReject">;
165
+ cantonEndInvestorOnboardingOffer: t.LiteralC<"cantonEndInvestorOnboardingOffer">;
166
+ cantonEndInvestorOnboardingAccept: t.LiteralC<"cantonEndInvestorOnboardingAccept">;
167
+ cantonEndInvestorOnboardingReject: t.LiteralC<"cantonEndInvestorOnboardingReject">;
168
+ cantonEndInvestorOnboardingCancel: t.LiteralC<"cantonEndInvestorOnboardingCancel">;
169
+ cantonEndInvestorOffboarding: t.LiteralC<"cantonEndInvestorOffboarding">;
170
+ cantonParticipantOnboardingRequest: t.LiteralC<"cantonParticipantOnboardingRequest">;
171
+ cantonParticipantAllowListAdd: t.LiteralC<"cantonParticipantAllowListAdd">;
172
+ cantonParticipantAllowListRemove: t.LiteralC<"cantonParticipantAllowListRemove">;
173
+ cantonGovernanceLockCreate: t.LiteralC<"cantonGovernanceLockCreate">;
174
+ cantonGovernanceLockUnlock: t.LiteralC<"cantonGovernanceLockUnlock">;
175
+ cantonGovernanceLockProvisionalUnlock: t.LiteralC<"cantonGovernanceLockProvisionalUnlock">;
176
+ cantonGovernanceLockWithdraw: t.LiteralC<"cantonGovernanceLockWithdraw">;
177
+ cantonGovernanceLockProposeSubstitution: t.LiteralC<"cantonGovernanceLockProposeSubstitution">;
178
+ cantonGovernanceLockProposeTransfer: t.LiteralC<"cantonGovernanceLockProposeTransfer">;
179
+ "defi-deposit": t.LiteralC<"defi-deposit">;
180
+ "defi-redeem": t.LiteralC<"defi-redeem">;
181
+ "defi-approve": t.LiteralC<"defi-approve">;
182
+ "defi-withdraw": t.LiteralC<"defi-withdraw">;
183
+ "wrap-native": t.LiteralC<"wrap-native">;
184
+ "unwrap-native": t.LiteralC<"unwrap-native">;
185
+ wrapApprove: t.LiteralC<"wrapApprove">;
186
+ wrap: t.LiteralC<"wrap">;
187
+ unwrap: t.LiteralC<"unwrap">;
188
+ finalizeUnwrap: t.LiteralC<"finalizeUnwrap">;
189
+ delegateResource: t.LiteralC<"delegateResource">;
190
+ undelegateResource: t.LiteralC<"undelegateResource">;
191
+ stacksRegisterForBond: t.LiteralC<"stacksRegisterForBond">;
192
+ export: t.LiteralC<"export">;
193
+ import: t.LiteralC<"import">;
194
+ importtoc: t.LiteralC<"importtoc">;
195
+ }>;
107
196
  }>, t.PartialC<{
108
197
  sequenceId: t.UnionC<[t.Type<string, string, unknown>, t.UndefinedC]>;
109
198
  comment: t.UnionC<[t.Type<string, string, unknown>, t.UndefinedC]>;
110
199
  nonce: t.UnionC<[t.Type<string | number, string | number, unknown>, t.UndefinedC]>;
111
- }>]>;
200
+ }>]>>;
112
201
  export type BaseIntentCatchAll = t.TypeOf<typeof BaseIntentCatchAll>;
113
202
  export declare const BaseIntentWithoutNonce: t.IntersectionC<[t.TypeC<{
114
203
  intentType: t.KeyofC<{
@@ -278,4 +367,3 @@ export declare const BaseIntentWithAmount: t.TypeC<{
278
367
  }>;
279
368
  }>;
280
369
  export type BaseIntentWithAmount = t.TypeOf<typeof BaseIntentWithAmount>;
281
- export {};
@@ -30,17 +30,15 @@ const utils_1 = require("../../../utils");
30
30
  const recipientEntry_1 = require("./recipientEntry");
31
31
  const tokenRecipientEntry_1 = require("./tokenRecipientEntry");
32
32
  const amount_1 = require("./amount");
33
- const BaseIntentRequired = t.type({
34
- intentType: intentType_1.IntentType,
35
- });
36
- const BaseIntentOptional = t.partial({
37
- sequenceId: utils_1.optionalString,
38
- comment: utils_1.optionalString,
39
- nonce: (0, utils_1.Optional)(t.union([t.string, t.number])),
40
- });
41
33
  exports.BaseIntent = t.intersection([
42
- BaseIntentRequired,
43
- BaseIntentOptional,
34
+ t.type({
35
+ intentType: intentType_1.IntentType,
36
+ }),
37
+ t.partial({
38
+ sequenceId: utils_1.optionalString,
39
+ comment: utils_1.optionalString,
40
+ nonce: (0, utils_1.Optional)(t.union([t.string, t.number])),
41
+ }),
44
42
  ]);
45
43
  const CATCH_ALL_EXCLUDED_INTENT_TYPES = [
46
44
  intentType_1.intentTypes.cantonGovernanceLockCreate.value,
@@ -50,13 +48,7 @@ const CATCH_ALL_EXCLUDED_INTENT_TYPES = [
50
48
  intentType_1.intentTypes.cantonGovernanceLockProposeSubstitution.value,
51
49
  intentType_1.intentTypes.cantonGovernanceLockProposeTransfer.value,
52
50
  ];
53
- const CatchAllIntentTypes = Object.fromEntries(Object.entries(intentType_1.intentTypes).filter(([key]) => !CATCH_ALL_EXCLUDED_INTENT_TYPES.includes(key)));
54
- exports.BaseIntentCatchAll = t.intersection([
55
- t.type({ intentType: t.keyof(CatchAllIntentTypes) }),
56
- BaseIntentOptional,
57
- ]);
58
- const _catchAllGuardsHold = [true, true];
59
- void _catchAllGuardsHold;
51
+ exports.BaseIntentCatchAll = t.refinement(exports.BaseIntent, (intent) => !CATCH_ALL_EXCLUDED_INTENT_TYPES.includes(intent.intentType), "BaseIntentCatchAll");
60
52
  exports.BaseIntentWithoutNonce = t.intersection([
61
53
  t.type({
62
54
  intentType: intentType_1.IntentType,
@@ -1 +1 @@
1
- {"version":3,"file":"baseIntent.js","sourceRoot":"","sources":["../../../../../src/schema/transactionRequest/intents/baseIntent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,6CAAuD;AACvD,0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CAAC;AACjB,KAAK,mBAAmB,CAAC;AAEZ,QAAA,sBAAsB,GAAG,CAAC,CAAC,YAAY,CAAC;IACnD,CAAC,CAAC,IAAI,CAAC;QACL,UAAU,EAAE,uBAAU;KACvB,CAAC;IACF,CAAC,CAAC,OAAO,CAAC;QAER,UAAU,EAAE,sBAAc;QAE1B,OAAO,EAAE,sBAAc;KACxB,CAAC;CACH,CAAC,CAAC;AAiCU,QAAA,wBAAwB,GAAG,CAAC,CAAC,IAAI,CAAC;IAE7C,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,+BAAc,CAAC;CACpC,CAAC,CAAC;AAoBU,QAAA,6BAA6B,GAAG,CAAC,CAAC,IAAI,CAAC;IAElD,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,yCAAmB,CAAC;CACzC,CAAC,CAAC;AAUU,QAAA,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC5C,UAAU,EAAE,CAAC,CAAC,KAAK,CACjB,CAAC,CAAC,OAAO,CAAC;QACR,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;YACnB,SAAS,EAAE,CAAC,CAAC,MAAM;SACpB,CAAC;KACH,CAAC,CACH;CACF,CAAC,CAAC;AAgBU,QAAA,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC;IAE5C,SAAS,EAAE,CAAC,CAAC,MAAM;CACpB,CAAC,CAAC;AAmBU,QAAA,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC;IAEzC,MAAM,EAAE,eAAM;CACf,CAAC,CAAC"}
1
+ {"version":3,"file":"baseIntent.js","sourceRoot":"","sources":["../../../../../src/schema/transactionRequest/intents/baseIntent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,6CAAuD;AACvD,0CAA0D;AAC1D,qDAAkD;AAClD,+DAA4D;AAC5D,qCAAkC;AAKrB,QAAA,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC;IACvC,CAAC,CAAC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,QAAA,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC5C,UAAU,EAAE,CAAC,CAAC,KAAK,CACjB,CAAC,CAAC,OAAO,CAAC;QACR,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;YACnB,SAAS,EAAE,CAAC,CAAC,MAAM;SACpB,CAAC;KACH,CAAC,CACH;CACF,CAAC,CAAC;AAgBU,QAAA,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC;IAE5C,SAAS,EAAE,CAAC,CAAC,MAAM;CACpB,CAAC,CAAC;AAmBU,QAAA,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC;IAEzC,MAAM,EAAE,eAAM;CACf,CAAC,CAAC"}
@@ -20359,7 +20359,7 @@ export declare const TransactionIntent: t.UnionC<[t.IntersectionC<[t.Intersectio
20359
20359
  isTestTransaction: t.BooleanC;
20360
20360
  }>]>]>, t.TypeC<{
20361
20361
  unifiedRecipientPreference: t.UnionC<[t.Type<"shielded" | "transparent", "shielded" | "transparent", unknown>, t.UndefinedC]>;
20362
- }>]>, t.IntersectionC<[t.TypeC<{
20362
+ }>]>, t.RefinementC<t.IntersectionC<[t.TypeC<{
20363
20363
  intentType: t.KeyofC<{
20364
20364
  payment: t.LiteralC<"payment">;
20365
20365
  transferToken: t.LiteralC<"transferToken">;
@@ -20430,6 +20430,12 @@ export declare const TransactionIntent: t.UnionC<[t.IntersectionC<[t.Intersectio
20430
20430
  cantonParticipantOnboardingRequest: t.LiteralC<"cantonParticipantOnboardingRequest">;
20431
20431
  cantonParticipantAllowListAdd: t.LiteralC<"cantonParticipantAllowListAdd">;
20432
20432
  cantonParticipantAllowListRemove: t.LiteralC<"cantonParticipantAllowListRemove">;
20433
+ cantonGovernanceLockCreate: t.LiteralC<"cantonGovernanceLockCreate">;
20434
+ cantonGovernanceLockUnlock: t.LiteralC<"cantonGovernanceLockUnlock">;
20435
+ cantonGovernanceLockProvisionalUnlock: t.LiteralC<"cantonGovernanceLockProvisionalUnlock">;
20436
+ cantonGovernanceLockWithdraw: t.LiteralC<"cantonGovernanceLockWithdraw">;
20437
+ cantonGovernanceLockProposeSubstitution: t.LiteralC<"cantonGovernanceLockProposeSubstitution">;
20438
+ cantonGovernanceLockProposeTransfer: t.LiteralC<"cantonGovernanceLockProposeTransfer">;
20433
20439
  "defi-deposit": t.LiteralC<"defi-deposit">;
20434
20440
  "defi-redeem": t.LiteralC<"defi-redeem">;
20435
20441
  "defi-approve": t.LiteralC<"defi-approve">;
@@ -20451,5 +20457,5 @@ export declare const TransactionIntent: t.UnionC<[t.IntersectionC<[t.Intersectio
20451
20457
  sequenceId: t.UnionC<[t.Type<string, string, unknown>, t.UndefinedC]>;
20452
20458
  comment: t.UnionC<[t.Type<string, string, unknown>, t.UndefinedC]>;
20453
20459
  nonce: t.UnionC<[t.Type<string | number, string | number, unknown>, t.UndefinedC]>;
20454
- }>]>]>;
20460
+ }>]>>]>;
20455
20461
  export type TransactionIntent = t.TypeOf<typeof TransactionIntent>;
@@ -20363,7 +20363,7 @@ export declare const TransactionIntentFullOnly: t.UnionC<[t.IntersectionC<[t.Int
20363
20363
  unifiedRecipientPreference: t.UnionC<[t.Type<"shielded" | "transparent", "shielded" | "transparent", unknown>, t.UndefinedC]>;
20364
20364
  }>]>]>;
20365
20365
  export type TransactionIntentFullOnly = t.TypeOf<typeof TransactionIntentFullOnly>;
20366
- export declare const TransactionIntentLiteOnly: t.IntersectionC<[t.TypeC<{
20366
+ export declare const TransactionIntentLiteOnly: t.RefinementC<t.IntersectionC<[t.TypeC<{
20367
20367
  intentType: t.KeyofC<{
20368
20368
  payment: t.LiteralC<"payment">;
20369
20369
  transferToken: t.LiteralC<"transferToken">;
@@ -20434,6 +20434,12 @@ export declare const TransactionIntentLiteOnly: t.IntersectionC<[t.TypeC<{
20434
20434
  cantonParticipantOnboardingRequest: t.LiteralC<"cantonParticipantOnboardingRequest">;
20435
20435
  cantonParticipantAllowListAdd: t.LiteralC<"cantonParticipantAllowListAdd">;
20436
20436
  cantonParticipantAllowListRemove: t.LiteralC<"cantonParticipantAllowListRemove">;
20437
+ cantonGovernanceLockCreate: t.LiteralC<"cantonGovernanceLockCreate">;
20438
+ cantonGovernanceLockUnlock: t.LiteralC<"cantonGovernanceLockUnlock">;
20439
+ cantonGovernanceLockProvisionalUnlock: t.LiteralC<"cantonGovernanceLockProvisionalUnlock">;
20440
+ cantonGovernanceLockWithdraw: t.LiteralC<"cantonGovernanceLockWithdraw">;
20441
+ cantonGovernanceLockProposeSubstitution: t.LiteralC<"cantonGovernanceLockProposeSubstitution">;
20442
+ cantonGovernanceLockProposeTransfer: t.LiteralC<"cantonGovernanceLockProposeTransfer">;
20437
20443
  "defi-deposit": t.LiteralC<"defi-deposit">;
20438
20444
  "defi-redeem": t.LiteralC<"defi-redeem">;
20439
20445
  "defi-approve": t.LiteralC<"defi-approve">;
@@ -20455,5 +20461,5 @@ export declare const TransactionIntentLiteOnly: t.IntersectionC<[t.TypeC<{
20455
20461
  sequenceId: t.UnionC<[t.Type<string, string, unknown>, t.UndefinedC]>;
20456
20462
  comment: t.UnionC<[t.Type<string, string, unknown>, t.UndefinedC]>;
20457
20463
  nonce: t.UnionC<[t.Type<string | number, string | number, unknown>, t.UndefinedC]>;
20458
- }>]>;
20464
+ }>]>>;
20459
20465
  export type TransactionIntentLiteOnly = t.TypeOf<typeof TransactionIntentLiteOnly>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitgo/public-types",
3
- "version": "7.6.1",
3
+ "version": "7.6.3",
4
4
  "description": "Collection of types exposed externally as part of the BitGo public API",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",
@@ -8,23 +8,18 @@ import { Amount } from "./amount";
8
8
  /**
9
9
  * @title Intent
10
10
  */
11
- /** Required fragment, split out so {@link BaseIntentCatchAll} can narrow `intentType`. */
12
- const BaseIntentRequired = t.type({
13
- intentType: IntentType,
14
- });
15
-
16
- const BaseIntentOptional = t.partial({
17
- /** Client-assigned sequence identifier for idempotency. */
18
- sequenceId: optionalString,
19
- /** Human-readable memo attached to the transaction. */
20
- comment: optionalString,
21
- /** Override the on-chain nonce for this transaction. */
22
- nonce: Optional(t.union([t.string, t.number])),
23
- });
24
-
25
11
  export const BaseIntent = t.intersection([
26
- BaseIntentRequired,
27
- BaseIntentOptional,
12
+ t.type({
13
+ intentType: IntentType,
14
+ }),
15
+ t.partial({
16
+ /** Client-assigned sequence identifier for idempotency. */
17
+ sequenceId: optionalString,
18
+ /** Human-readable memo attached to the transaction. */
19
+ comment: optionalString,
20
+ /** Override the on-chain nonce for this transaction. */
21
+ nonce: Optional(t.union([t.string, t.number])),
22
+ }),
28
23
  ]);
29
24
 
30
25
  export type BaseIntent = t.TypeOf<typeof BaseIntent>;
@@ -35,68 +30,35 @@ export type BaseIntent = t.TypeOf<typeof BaseIntent>;
35
30
  * of these intents (e.g. one carrying a forbidden protocol `memo`) would fall through the
36
31
  * dedicated codec and still decode as a plain `BaseIntent`.
37
32
  */
38
- const CATCH_ALL_EXCLUDED_INTENT_TYPES = [
33
+ const CATCH_ALL_EXCLUDED_INTENT_TYPES: ReadonlyArray<string> = [
39
34
  intentTypes.cantonGovernanceLockCreate.value,
40
35
  intentTypes.cantonGovernanceLockUnlock.value,
41
36
  intentTypes.cantonGovernanceLockProvisionalUnlock.value,
42
37
  intentTypes.cantonGovernanceLockWithdraw.value,
43
38
  intentTypes.cantonGovernanceLockProposeSubstitution.value,
44
39
  intentTypes.cantonGovernanceLockProposeTransfer.value,
45
- ] as const;
46
-
47
- /**
48
- * {@link intentTypes} minus every excluded key, keeping the literal codec types (`Omit` preserves
49
- * them, unlike `Object.fromEntries`'s widened index signature) so that `t.keyof` yields the finite
50
- * union of allowed `intentType` names rather than `string`.
51
- */
52
- type CatchAllIntentTypesMap = Omit<
53
- typeof intentTypes,
54
- (typeof CATCH_ALL_EXCLUDED_INTENT_TYPES)[number]
55
- >;
56
-
57
- const CatchAllIntentTypes = Object.fromEntries(
58
- (
59
- Object.entries(intentTypes) as Array<
60
- [keyof typeof intentTypes, (typeof intentTypes)[keyof typeof intentTypes]]
61
- >
62
- ).filter(
63
- ([key]) =>
64
- !(CATCH_ALL_EXCLUDED_INTENT_TYPES as ReadonlyArray<string>).includes(key),
65
- ),
66
- ) as CatchAllIntentTypesMap;
40
+ ];
67
41
 
68
42
  /**
69
43
  * Catch-all for intents that have no codec yet: `BaseIntent` minus every `intentType` that owns a
70
44
  * dedicated codec listed above. Use this, not `BaseIntent`, as the open fallback in intent unions.
45
+ *
46
+ * Uses {@link t.refinement} so the runtime rejects the excluded `intentType`s while
47
+ * `t.TypeOf` stays the plain full-width {@link BaseIntent} (no brand marker), keeping stored
48
+ * intents — whose unions span the full registry — assignable for decode AND encode.
49
+ *
50
+ * @assumes consumers that generate OpenAPI from this codec register a `refinement` handler in
51
+ * their `.openapi-generator.rc.js` that emits the inner schema (the wallet-platform sdk does);
52
+ * without it the generator emits an unresolvable `$ref` for the refinement.
71
53
  */
72
- export const BaseIntentCatchAll = t.intersection([
73
- t.type({ intentType: t.keyof(CatchAllIntentTypes) }),
74
- BaseIntentOptional,
75
- ]);
54
+ export const BaseIntentCatchAll = t.refinement(
55
+ BaseIntent,
56
+ (intent) => !CATCH_ALL_EXCLUDED_INTENT_TYPES.includes(intent.intentType),
57
+ "BaseIntentCatchAll",
58
+ );
76
59
 
77
60
  export type BaseIntentCatchAll = t.TypeOf<typeof BaseIntentCatchAll>;
78
61
 
79
- /**
80
- * Compile-time drift guards:
81
- * 1. The exclusion list may only contain registry keys — an unknown name fails to compile.
82
- * 2. The catch-all's allowed `intentType` names remain a subset of {@link IntentType}, so a
83
- * decoded catch-all intent's `intentType` still assigns to any API expecting a supported
84
- * intent name.
85
- */
86
- type ExcludedIntentType = (typeof CATCH_ALL_EXCLUDED_INTENT_TYPES)[number];
87
- type _ExcludedKeysAreRegistryKeys =
88
- ExcludedIntentType extends keyof typeof intentTypes ? true : never;
89
- type _CatchAllIntentTypeIsIntentType = t.TypeOf<
90
- typeof BaseIntentCatchAll
91
- >["intentType"] extends IntentType
92
- ? true
93
- : never;
94
- const _catchAllGuardsHold: [
95
- _ExcludedKeysAreRegistryKeys,
96
- _CatchAllIntentTypeIsIntentType,
97
- ] = [true, true];
98
- void _catchAllGuardsHold;
99
-
100
62
  export const BaseIntentWithoutNonce = t.intersection([
101
63
  t.type({
102
64
  intentType: IntentType,