@bitgo/public-types 2.20.0 → 2.21.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.
Files changed (112) hide show
  1. package/dist/src/index.d.ts +0 -1
  2. package/dist/src/schema/index.d.ts +0 -1
  3. package/dist/src/schema/keyGen/index.d.ts +0 -1
  4. package/dist/src/schema/keyGen/keyGenState.d.ts +0 -1
  5. package/dist/src/schema/keyGen/keyGenType.d.ts +0 -1
  6. package/dist/src/schema/mpcv2/common/index.d.ts +0 -1
  7. package/dist/src/schema/mpcv2/common/mpcv2BroadcastMessage.d.ts +0 -1
  8. package/dist/src/schema/mpcv2/common/mpcv2P2PMessage.d.ts +0 -1
  9. package/dist/src/schema/mpcv2/common/mpcv2PartyFromStringOrNumber.d.ts +0 -1
  10. package/dist/src/schema/mpcv2/index.d.ts +0 -1
  11. package/dist/src/schema/mpcv2/keyGen/index.d.ts +0 -1
  12. package/dist/src/schema/mpcv2/keyGen/keygenRound.d.ts +0 -1
  13. package/dist/src/schema/mpcv2/keyGen/mpcv2KeyGenState.d.ts +0 -1
  14. package/dist/src/schema/mpcv2/signing/index.d.ts +0 -1
  15. package/dist/src/schema/mpcv2/signing/mpcv2SigningState.d.ts +0 -1
  16. package/dist/src/schema/mpcv2/signing/signingRound.d.ts +0 -1
  17. package/dist/src/schema/transactionRequest/index.d.ts +0 -1
  18. package/dist/src/schema/transactionRequest/transactionRequestState.d.ts +0 -1
  19. package/dist/src/schema/transactionRequest/transactionState.d.ts +0 -1
  20. package/dist/src/schema/transactions/coinSpecific.d.ts +0 -1
  21. package/dist/src/schema/transactions/index.d.ts +0 -1
  22. package/dist/src/schema/transactions/sendTransactions.d.ts +0 -1
  23. package/dist/src/schema/wallet/index.d.ts +0 -1
  24. package/dist/src/schema/wallet/wallet.d.ts +0 -1
  25. package/dist/src/schema/webhook/addWalletWebhookRequest.d.ts +0 -1
  26. package/dist/src/schema/webhook/enterpriseWebhooks.d.ts +0 -1
  27. package/dist/src/schema/webhook/index.d.ts +0 -1
  28. package/dist/src/schema/webhook/webhook.d.ts +0 -1
  29. package/dist/src/schema/webhook/webhookNotification.d.ts +0 -1
  30. package/dist/src/schema/webhook/webhookScope.d.ts +0 -1
  31. package/dist/src/schema/webhook/webhookState.d.ts +0 -1
  32. package/dist/src/schema/webhook/webhookType.d.ts +0 -1
  33. package/dist/src/utils/arrayFromSingle.d.ts +0 -1
  34. package/dist/src/utils/index.d.ts +0 -1
  35. package/dist/src/utils/minMaxArray.d.ts +0 -1
  36. package/dist/src/utils/optional.d.ts +0 -1
  37. package/dist/src/utils/primitives.d.ts +0 -1
  38. package/package.json +4 -3
  39. package/src/index.ts +2 -0
  40. package/src/schema/index.ts +6 -0
  41. package/src/schema/keyGen/index.ts +2 -0
  42. package/src/schema/keyGen/keyGenState.ts +8 -0
  43. package/src/schema/keyGen/keyGenType.ts +7 -0
  44. package/src/schema/mpcv2/common/index.ts +3 -0
  45. package/src/schema/mpcv2/common/mpcv2BroadcastMessage.ts +24 -0
  46. package/src/schema/mpcv2/common/mpcv2P2PMessage.ts +14 -0
  47. package/src/schema/mpcv2/common/mpcv2PartyFromStringOrNumber.ts +13 -0
  48. package/src/schema/mpcv2/index.ts +3 -0
  49. package/src/schema/mpcv2/keyGen/index.ts +2 -0
  50. package/src/schema/mpcv2/keyGen/keygenRound.ts +70 -0
  51. package/src/schema/mpcv2/keyGen/mpcv2KeyGenState.ts +12 -0
  52. package/src/schema/mpcv2/signing/index.ts +2 -0
  53. package/src/schema/mpcv2/signing/mpcv2SigningState.ts +11 -0
  54. package/src/schema/mpcv2/signing/signingRound.ts +113 -0
  55. package/src/schema/transactionRequest/index.ts +2 -0
  56. package/src/schema/transactionRequest/transactionRequestState.ts +21 -0
  57. package/src/schema/transactionRequest/transactionState.ts +22 -0
  58. package/src/schema/transactions/coinSpecific.ts +59 -0
  59. package/src/schema/transactions/index.ts +1 -0
  60. package/src/schema/transactions/sendTransactions.ts +245 -0
  61. package/src/schema/wallet/index.ts +1 -0
  62. package/src/schema/wallet/wallet.ts +8 -0
  63. package/src/schema/webhook/addWalletWebhookRequest.ts +24 -0
  64. package/src/schema/webhook/enterpriseWebhooks.ts +44 -0
  65. package/src/schema/webhook/index.ts +7 -0
  66. package/src/schema/webhook/webhook.ts +35 -0
  67. package/src/schema/webhook/webhookNotification.ts +33 -0
  68. package/src/schema/webhook/webhookScope.ts +10 -0
  69. package/src/schema/webhook/webhookState.ts +9 -0
  70. package/src/schema/webhook/webhookType.ts +56 -0
  71. package/src/utils/arrayFromSingle.ts +19 -0
  72. package/src/utils/index.ts +4 -0
  73. package/src/utils/minMaxArray.ts +27 -0
  74. package/src/utils/optional.ts +5 -0
  75. package/src/utils/primitives.ts +11 -0
  76. package/dist/src/index.d.ts.map +0 -1
  77. package/dist/src/schema/index.d.ts.map +0 -1
  78. package/dist/src/schema/keyGen/index.d.ts.map +0 -1
  79. package/dist/src/schema/keyGen/keyGenState.d.ts.map +0 -1
  80. package/dist/src/schema/keyGen/keyGenType.d.ts.map +0 -1
  81. package/dist/src/schema/mpcv2/common/index.d.ts.map +0 -1
  82. package/dist/src/schema/mpcv2/common/mpcv2BroadcastMessage.d.ts.map +0 -1
  83. package/dist/src/schema/mpcv2/common/mpcv2P2PMessage.d.ts.map +0 -1
  84. package/dist/src/schema/mpcv2/common/mpcv2PartyFromStringOrNumber.d.ts.map +0 -1
  85. package/dist/src/schema/mpcv2/index.d.ts.map +0 -1
  86. package/dist/src/schema/mpcv2/keyGen/index.d.ts.map +0 -1
  87. package/dist/src/schema/mpcv2/keyGen/keygenRound.d.ts.map +0 -1
  88. package/dist/src/schema/mpcv2/keyGen/mpcv2KeyGenState.d.ts.map +0 -1
  89. package/dist/src/schema/mpcv2/signing/index.d.ts.map +0 -1
  90. package/dist/src/schema/mpcv2/signing/mpcv2SigningState.d.ts.map +0 -1
  91. package/dist/src/schema/mpcv2/signing/signingRound.d.ts.map +0 -1
  92. package/dist/src/schema/transactionRequest/index.d.ts.map +0 -1
  93. package/dist/src/schema/transactionRequest/transactionRequestState.d.ts.map +0 -1
  94. package/dist/src/schema/transactionRequest/transactionState.d.ts.map +0 -1
  95. package/dist/src/schema/transactions/coinSpecific.d.ts.map +0 -1
  96. package/dist/src/schema/transactions/index.d.ts.map +0 -1
  97. package/dist/src/schema/transactions/sendTransactions.d.ts.map +0 -1
  98. package/dist/src/schema/wallet/index.d.ts.map +0 -1
  99. package/dist/src/schema/wallet/wallet.d.ts.map +0 -1
  100. package/dist/src/schema/webhook/addWalletWebhookRequest.d.ts.map +0 -1
  101. package/dist/src/schema/webhook/enterpriseWebhooks.d.ts.map +0 -1
  102. package/dist/src/schema/webhook/index.d.ts.map +0 -1
  103. package/dist/src/schema/webhook/webhook.d.ts.map +0 -1
  104. package/dist/src/schema/webhook/webhookNotification.d.ts.map +0 -1
  105. package/dist/src/schema/webhook/webhookScope.d.ts.map +0 -1
  106. package/dist/src/schema/webhook/webhookState.d.ts.map +0 -1
  107. package/dist/src/schema/webhook/webhookType.d.ts.map +0 -1
  108. package/dist/src/utils/arrayFromSingle.d.ts.map +0 -1
  109. package/dist/src/utils/index.d.ts.map +0 -1
  110. package/dist/src/utils/minMaxArray.d.ts.map +0 -1
  111. package/dist/src/utils/optional.d.ts.map +0 -1
  112. package/dist/src/utils/primitives.d.ts.map +0 -1
@@ -0,0 +1,59 @@
1
+ import * as t from "io-ts";
2
+ import {
3
+ optionalStringOrNumber,
4
+ optionalString,
5
+ optionalNumber,
6
+ optionalStringArray,
7
+ optionalBoolean,
8
+ optionalUnknown,
9
+ } from "../../utils";
10
+
11
+ const BaseBuildParams = {
12
+ type: t.string,
13
+ nonce: optionalNumber,
14
+ memo: t.partial({
15
+ type: optionalString,
16
+ value: optionalString,
17
+ }),
18
+ comment: optionalString,
19
+ ledgerSequenceDelta: optionalNumber,
20
+ lastLedgerSequence: optionalNumber,
21
+ feeRate: optionalStringOrNumber,
22
+ messageKey: optionalString,
23
+ previewPendingTxs: optionalBoolean,
24
+ pendingApprovalId: optionalString,
25
+ sequenceId: optionalString,
26
+ };
27
+
28
+ const ConsolidateBuildParams = {
29
+ ...BaseBuildParams,
30
+ consolidateId: optionalString,
31
+ senderAddress: optionalString,
32
+ };
33
+
34
+ // Coin Specific Build Params
35
+ export const CoinSpecificBuildParams = {
36
+ avaxp: {
37
+ locktime: optionalNumber,
38
+ sourceChain: optionalString,
39
+ destinationChain: optionalString,
40
+ unspents: optionalStringArray,
41
+ },
42
+ dot: {
43
+ ...ConsolidateBuildParams,
44
+ sequenceId: optionalString,
45
+ senderAddressIndex: optionalNumber,
46
+ nonce: optionalNumber,
47
+ proxyType: optionalString,
48
+ forceProxyType: optionalString,
49
+ owner: optionalUnknown,
50
+ delay: optionalUnknown,
51
+ index: optionalUnknown,
52
+ validityWindow: optionalUnknown,
53
+ version: optionalUnknown,
54
+ referenceBlock: optionalUnknown,
55
+ },
56
+ sol: {
57
+ tokenName: optionalString,
58
+ },
59
+ };
@@ -0,0 +1 @@
1
+ export * from "./sendTransactions";
@@ -0,0 +1,245 @@
1
+ import * as t from "io-ts";
2
+ import {
3
+ Optional,
4
+ optionalString,
5
+ optionalBoolean,
6
+ optionalNumber,
7
+ optionalStringOrNumber,
8
+ optionalUnknown,
9
+ } from "../../utils";
10
+ import { CoinSpecificBuildParams } from "./coinSpecific";
11
+
12
+ const recipient = t.partial({
13
+ address: t.string,
14
+ amount: t.union([t.string, t.number]),
15
+ feeLimit: optionalString,
16
+ data: optionalString,
17
+ memo: optionalString,
18
+ tokenName: optionalString,
19
+ });
20
+ export type TransactionRecipient = t.TypeOf<typeof recipient>;
21
+ const recipients = t.array(recipient);
22
+
23
+ const eip1559 = t.partial({
24
+ maxPriorityFeePerGas: optionalString,
25
+ maxFeePerGas: optionalString,
26
+ });
27
+
28
+ const lightningPaymentRequest = t.intersection([
29
+ t.type({
30
+ invoice: t.string,
31
+ }),
32
+ t.partial({
33
+ amount: t.number,
34
+ sequenceId: t.string,
35
+ feeLimit: t.number,
36
+ feeLimitRatio: t.number,
37
+ }),
38
+ ]);
39
+ export type LightningPaymentRequest = t.TypeOf<typeof lightningPaymentRequest>;
40
+
41
+ const halfSigned = t.partial({
42
+ txHex: optionalString,
43
+ recipients: Optional(recipients),
44
+ eip1559: Optional(eip1559),
45
+ isBatch: optionalBoolean,
46
+ expireTime: optionalNumber,
47
+ contractSequenceId: optionalNumber,
48
+ nextContractSequenceId: optionalNumber,
49
+ operationHash: optionalString,
50
+ signedChildPsbt: optionalString,
51
+ signature: optionalString,
52
+ lightningPaymentRequest: Optional(lightningPaymentRequest),
53
+ });
54
+ export type HalfSignedTransaction = t.TypeOf<typeof halfSigned>;
55
+
56
+ export const memo = t.partial({
57
+ type: optionalString,
58
+ value: optionalString,
59
+ });
60
+
61
+ const feeOptions = {
62
+ amount: optionalStringOrNumber,
63
+ unit: Optional(
64
+ t.union([t.literal("baseUnit"), t.literal("cpu"), t.literal("ram")]),
65
+ ),
66
+ formula: Optional(
67
+ t.union([
68
+ t.literal("fixed"),
69
+ t.literal("feeRate"),
70
+ t.literal("perKB"),
71
+ t.literal("custom"),
72
+ ]),
73
+ ),
74
+ type: Optional(
75
+ t.union([t.literal("base"), t.literal("max"), t.literal("tip")]),
76
+ ),
77
+ };
78
+
79
+ export const txSendBody = {
80
+ comment: optionalString,
81
+ consolidateId: optionalString,
82
+ halfSigned: Optional(halfSigned),
83
+ invoice: optionalString,
84
+ memo: Optional(memo),
85
+ otp: optionalString,
86
+ recipients: Optional(recipients),
87
+ suppressBroadcast: optionalBoolean,
88
+ txHex: optionalString,
89
+ txRequestId: optionalString,
90
+ videoApprovers: Optional(t.array(t.string)),
91
+
92
+ numBlocks: optionalNumber,
93
+ feeRate: optionalNumber,
94
+ maxFeeRate: optionalNumber,
95
+ minConfirms: optionalNumber,
96
+ enforceMinConfirmsForChange: optionalBoolean,
97
+ targetWalletUnspents: optionalNumber,
98
+ message: optionalString,
99
+ minValue: optionalStringOrNumber,
100
+ maxValue: optionalStringOrNumber,
101
+ sequenceId: optionalStringOrNumber,
102
+ lastLedgerSequence: optionalNumber,
103
+ ledgerSequenceDelta: optionalNumber,
104
+ gasPrice: optionalNumber,
105
+ noSplitChange: optionalBoolean,
106
+ unspents: t.array(t.string),
107
+ changeAddress: optionalString,
108
+ instant: optionalBoolean,
109
+ transferId: optionalNumber,
110
+ gasLimit: optionalNumber,
111
+ custodianTransactionId: optionalString,
112
+
113
+ cpfpTxIds: Optional(t.array(t.string)),
114
+ cpfpFeeRate: optionalNumber,
115
+ noCpfpFeeRate: optionalBoolean,
116
+ maxFee: optionalNumber,
117
+ noMaxFee: optionalBoolean,
118
+
119
+ /// all other props from wp whitelist
120
+ feeMultiplier: optionalNumber,
121
+ addressType: optionalString,
122
+ changeAddressType: optionalString,
123
+ strategy: optionalString,
124
+ strategyAllowFallback: optionalBoolean,
125
+ fee: t.union([optionalString, t.partial(feeOptions)]),
126
+ timeBounds: Optional(
127
+ t.partial({
128
+ minTime: optionalStringOrNumber,
129
+ maxTime: optionalStringOrNumber,
130
+ }),
131
+ ),
132
+ idfSignedTimestamp: optionalString,
133
+ idfVersion: optionalNumber,
134
+ idfUserId: optionalString,
135
+ hopParams: t.partial({
136
+ gasPriceMax: optionalNumber,
137
+ paymentId: optionalString,
138
+ userReqSig: optionalString,
139
+ }),
140
+ validFromBlock: optionalNumber,
141
+ validToBlock: optionalNumber,
142
+ type: optionalString,
143
+ trustlines: t.partial({
144
+ token: optionalString,
145
+ action: optionalString,
146
+ limit: optionalString,
147
+ }),
148
+ reservation: t.partial({
149
+ expireTime: optionalString,
150
+ pendingApprovalId: optionalString,
151
+ }),
152
+ delayMs: optionalNumber,
153
+ messageKey: optionalString,
154
+ senderAddress: optionalString,
155
+ startTime: optionalString,
156
+ nonParticipation: optionalBoolean,
157
+ keyregTxBase64: optionalString,
158
+ closeRemainderTo: optionalString,
159
+ stateProofKey: optionalString,
160
+ contractName: optionalString,
161
+ functionName: optionalString,
162
+ eip1559: Optional(eip1559),
163
+ maxChangeOutputs: optionalNumber,
164
+ smallestChangeSplitSize: optionalNumber,
165
+ emergency: optionalBoolean,
166
+ sourceChain: optionalString,
167
+ destinationChain: optionalString,
168
+ txFormat: optionalString,
169
+ previewPendingTxs: optionalBoolean,
170
+ pendingApprovalId: optionalString,
171
+ stakingOptions: optionalUnknown,
172
+ unstakingOptions: optionalUnknown,
173
+ refundOptions: optionalUnknown,
174
+ stakingParams: t.partial({
175
+ actionType: optionalString,
176
+ validator: optionalString,
177
+ coin: optionalString,
178
+ amount: optionalString,
179
+ }),
180
+ isReplaceableByFee: optionalBoolean,
181
+ rbfTxIds: Optional(t.array(t.string)),
182
+ };
183
+
184
+ export const TxSendBody = t.exact(
185
+ t.intersection([
186
+ t.partial(txSendBody, "TxSendBody"),
187
+ t.partial(CoinSpecificBuildParams.avaxp),
188
+ t.partial(CoinSpecificBuildParams.dot),
189
+ t.partial(CoinSpecificBuildParams.sol),
190
+ ]),
191
+ );
192
+ export type TxSendBody = t.TypeOf<typeof TxSendBody>;
193
+
194
+ const entry = t.partial({
195
+ address: t.string,
196
+ wallet: t.string,
197
+ value: t.number,
198
+ valueString: t.string,
199
+ isChange: t.boolean,
200
+ isPayGo: t.boolean,
201
+ });
202
+ const historyItem = t.partial({
203
+ date: t.string,
204
+ action: t.string,
205
+ user: t.string,
206
+ });
207
+
208
+ export const TxSendResponse = t.partial({
209
+ baseValue: t.number,
210
+ baseValueString: t.string,
211
+ coin: t.string,
212
+ coinSpecific: t.record(t.string, t.unknown),
213
+ createdTime: t.string,
214
+ date: t.string,
215
+ enterprise: t.string,
216
+ entries: t.array(entry),
217
+ feeString: t.string,
218
+ height: t.number,
219
+ heightId: t.string,
220
+ history: t.array(historyItem),
221
+ id: t.string,
222
+ instant: t.boolean,
223
+ intendedValueString: t.string,
224
+ isFee: t.boolean,
225
+ isReward: t.boolean,
226
+ metadata: t.record(t.string, t.unknown),
227
+ payGoFee: t.number,
228
+ payGoFeeString: t.string,
229
+ signedDate: t.string,
230
+ signedTime: t.string,
231
+ state: t.string,
232
+ tags: t.array(t.string),
233
+ txid: t.string,
234
+ txidType: t.string,
235
+ txRequestId: t.string,
236
+ type: t.string,
237
+ usd: t.number,
238
+ usdRate: t.number,
239
+ value: t.number,
240
+ valueString: t.string,
241
+ vSize: t.number,
242
+ wallet: t.string,
243
+ walletType: t.string,
244
+ });
245
+ export type TxSendResponse = t.TypeOf<typeof TxSendResponse>;
@@ -0,0 +1 @@
1
+ export * from "./wallet";
@@ -0,0 +1,8 @@
1
+ import * as t from "io-ts";
2
+
3
+ export const WalletUser = t.type({
4
+ user: t.string,
5
+ permissions: t.array(t.string),
6
+ });
7
+
8
+ export type WalletUser = t.TypeOf<typeof WalletUser>;
@@ -0,0 +1,24 @@
1
+ import * as t from "io-ts";
2
+ import { NonEmptyString, NumberFromString } from "io-ts-types";
3
+ import { Optional } from "../../utils/optional";
4
+ import { TransactionRequestState } from "../transactionRequest/transactionRequestState";
5
+ import { TransactionState } from "../transactionRequest/transactionState";
6
+ import { WalletWebhookType } from "./webhookType";
7
+
8
+ export const AddWalletWebhookRequestBody = {
9
+ type: WalletWebhookType,
10
+ url: NonEmptyString,
11
+ label: Optional(t.string),
12
+ numConfirmations: t.union([t.number, NumberFromString, t.undefined]),
13
+ allToken: Optional(t.boolean),
14
+ listenToFailureStates: Optional(t.boolean),
15
+ txRequestStates: Optional(t.array(TransactionRequestState)),
16
+ txRequestTransactionStates: Optional(t.array(TransactionState)),
17
+ };
18
+ export const AddWalletWebhookRequestBodyC = t.type({
19
+ ...AddWalletWebhookRequestBody,
20
+ });
21
+
22
+ export type AddWalletWebhookRequestBody = t.TypeOf<
23
+ typeof AddWalletWebhookRequestBodyC
24
+ >;
@@ -0,0 +1,44 @@
1
+ import { EnterpriseWebhookType } from "./webhookType";
2
+ import { NonEmptyString } from "io-ts-types";
3
+ import { Optional, optionalString, optionalStringOrNumber } from "../../utils";
4
+ import * as t from "io-ts";
5
+ import { Webhook } from "./webhook";
6
+
7
+ export const AddEnterpriseWebhookRequestBody = {
8
+ type: EnterpriseWebhookType,
9
+ url: NonEmptyString,
10
+ label: Optional(t.string),
11
+ };
12
+ export const AddEnterpriseWebhookRequestBodyC = t.type({
13
+ ...AddEnterpriseWebhookRequestBody,
14
+ });
15
+
16
+ export type AddEnterpriseWebhookRequestBody = t.TypeOf<
17
+ typeof AddEnterpriseWebhookRequestBodyC
18
+ >;
19
+
20
+ export const ListEnterpriseWebhooksRequestBody = {
21
+ type: Optional(EnterpriseWebhookType),
22
+ limit: optionalStringOrNumber,
23
+ prevId: optionalString,
24
+ };
25
+
26
+ export const ListEnterpriseWebhooksRequestBodyC = t.type({
27
+ ...ListEnterpriseWebhooksRequestBody,
28
+ });
29
+
30
+ export type ListEnterpriseWebhooksRequestBody = t.TypeOf<
31
+ typeof ListEnterpriseWebhooksRequestBodyC
32
+ >;
33
+
34
+ export const ListEnterpriseWebhooksResponse = t.intersection([
35
+ t.type({
36
+ webhooks: t.array(Webhook),
37
+ }),
38
+ t.partial({
39
+ nextBatchPrevId: Optional(t.union([t.string, t.undefined])),
40
+ }),
41
+ ]);
42
+ export type ListEnterpriseWebhooksResponse = t.TypeOf<
43
+ typeof ListEnterpriseWebhooksResponse
44
+ >;
@@ -0,0 +1,7 @@
1
+ export * from "./enterpriseWebhooks";
2
+ export * from "./addWalletWebhookRequest";
3
+ export * from "./webhook";
4
+ export * from "./webhookNotification";
5
+ export * from "./webhookScope";
6
+ export * from "./webhookState";
7
+ export * from "./webhookType";
@@ -0,0 +1,35 @@
1
+ import * as t from "io-ts";
2
+ import { DateFromISOString } from "io-ts-types";
3
+ import { TransactionRequestState } from "../transactionRequest/transactionRequestState";
4
+ import { TransactionState } from "../transactionRequest/transactionState";
5
+ import { WebhookState } from "./webhookState";
6
+ import { WebhookType } from "./webhookType";
7
+ import { WebhookScope } from "./webhookScope";
8
+
9
+ export const Webhook = t.intersection([
10
+ t.type({
11
+ id: t.string,
12
+ created: DateFromISOString,
13
+ coin: t.string,
14
+ url: t.string,
15
+ version: t.number,
16
+ state: WebhookState,
17
+ successiveFailedAttempts: t.number,
18
+ listenToFailureStates: t.boolean,
19
+ }),
20
+ t.partial({
21
+ label: t.string,
22
+ walletId: t.string,
23
+ enterpriseId: t.string,
24
+ organizationId: t.string,
25
+ scope: WebhookScope,
26
+ userId: t.string,
27
+ type: WebhookType,
28
+ numConfirmations: t.number,
29
+ lastAttempt: DateFromISOString,
30
+ failingSince: DateFromISOString,
31
+ allToken: t.boolean,
32
+ txRequestStates: t.array(TransactionRequestState),
33
+ txRequestTransactionStates: t.array(TransactionState),
34
+ }),
35
+ ]);
@@ -0,0 +1,33 @@
1
+ import * as t from "io-ts";
2
+ import { DateFromISOString } from "io-ts-types";
3
+
4
+ export const WebhookNotification = t.intersection([
5
+ t.type({
6
+ id: t.string,
7
+ }),
8
+ t.partial({
9
+ type: t.string,
10
+ wallet: t.string,
11
+ url: t.string,
12
+ hash: t.string,
13
+ coin: t.string,
14
+ coinChain: t.string,
15
+ transfer: t.string,
16
+ state: t.string,
17
+ simulation: t.boolean,
18
+ retries: t.number,
19
+ webhook: t.string,
20
+ updatedAt: DateFromISOString,
21
+ nextAttempt: DateFromISOString,
22
+ version: t.number,
23
+ allowBlockedHosts: t.boolean,
24
+ heightToConfirm: t.number,
25
+ payload: t.string,
26
+ response: t.partial({
27
+ code: t.unknown,
28
+ type: t.string,
29
+ body: t.string,
30
+ error: t.string,
31
+ }),
32
+ }),
33
+ ]);
@@ -0,0 +1,10 @@
1
+ import * as t from "io-ts";
2
+
3
+ export enum WebhookScopeEnum {
4
+ "wallet" = "wallet",
5
+ "enterprise" = "enterprise",
6
+ "organization" = "organization",
7
+ }
8
+
9
+ export const WebhookScope = t.keyof(WebhookScopeEnum, "WebhookScope");
10
+ export type WebhookScope = t.TypeOf<typeof WebhookScope>;
@@ -0,0 +1,9 @@
1
+ import * as t from "io-ts";
2
+
3
+ export enum WebhookStateEnum {
4
+ "active" = "active",
5
+ "suspended" = "suspended",
6
+ }
7
+
8
+ export const WebhookState = t.keyof(WebhookStateEnum, "WebhookState");
9
+ export type WebhookState = t.TypeOf<typeof WebhookState>;
@@ -0,0 +1,56 @@
1
+ import * as t from "io-ts";
2
+
3
+ export enum WebhookTypeEnum {
4
+ // Webhook for txRequest.state changes
5
+ "txRequest" = "txRequest",
6
+ // Webhook for any txRequest.transactions[].state changes
7
+ "txRequestTransaction" = "txRequestTransaction",
8
+ "transfer" = "transfer",
9
+ "transaction" = "transaction",
10
+ "transactionRemoved" = "transactionRemoved",
11
+ "transactionExpire" = "transactionExpire",
12
+ "pendingapproval" = "pendingapproval",
13
+ "block" = "block",
14
+ "admin" = "admin",
15
+ "address_confirmation" = "address_confirmation",
16
+ "lowFee" = "lowFee",
17
+
18
+ // Specific to User Webhooks
19
+ "wallet_confirmation" = "wallet_confirmation",
20
+
21
+ "wireWithdrawal" = "wireWithdrawal",
22
+ "bankAccount" = "bankAccount",
23
+ }
24
+
25
+ export const WebhookType = t.keyof(WebhookTypeEnum, "WebhookType");
26
+ export type WebhookType = t.TypeOf<typeof WebhookType>;
27
+
28
+ export enum WalletWebhookTypeEnum {
29
+ "txRequest" = "txRequest",
30
+ "txRequestTransaction" = "txRequestTransaction",
31
+ "transfer" = "transfer",
32
+ "transaction" = "transaction",
33
+ "transactionRemoved" = "transactionRemoved",
34
+ "transactionExpire" = "transactionExpire",
35
+ "pendingapproval" = "pendingapproval",
36
+ "block" = "block",
37
+ "admin" = "admin",
38
+ "address_confirmation" = "address_confirmation",
39
+ "lowFee" = "lowFee",
40
+ "wireWithdrawal" = "wireWithdrawal",
41
+ }
42
+
43
+ export const WalletWebhookType = t.keyof(
44
+ WalletWebhookTypeEnum,
45
+ "WalletWebhookType",
46
+ );
47
+ export type WalletWebhookType = t.TypeOf<typeof WalletWebhookType>;
48
+
49
+ export enum EnterpriseWebhookTypeEnum {
50
+ "bankAccount" = "bankAccount",
51
+ }
52
+ export const EnterpriseWebhookType = t.keyof(
53
+ EnterpriseWebhookTypeEnum,
54
+ "EnterpriseWebhookType",
55
+ );
56
+ export type EnterpriseWebhookType = t.TypeOf<typeof EnterpriseWebhookType>;
@@ -0,0 +1,19 @@
1
+ import * as t from "io-ts";
2
+ import { pipe } from "fp-ts/function";
3
+ import { chain } from "fp-ts/lib/Either";
4
+
5
+ export function arrayFromSingle<C extends t.Mixed>(
6
+ codec: C,
7
+ name: string = `ArrayFromSingle<${codec.name}>`,
8
+ ) {
9
+ return new t.Type(
10
+ name,
11
+ t.array(codec).is,
12
+ (u, c) =>
13
+ pipe(
14
+ codec.validate(u, c),
15
+ chain((as) => t.array(codec).validate([as], c)),
16
+ ),
17
+ t.identity,
18
+ );
19
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./optional";
2
+ export * from "./primitives";
3
+ export * from "./arrayFromSingle";
4
+ export * from "./minMaxArray";
@@ -0,0 +1,27 @@
1
+ import * as t from "io-ts";
2
+
3
+ export interface IMinMaxArray<T> extends Array<T> {
4
+ readonly minMaxArray: unique symbol;
5
+ }
6
+
7
+ /**
8
+ * A helper that creates an array codec that limits the length of the array between [min, max]
9
+ * @param codec
10
+ * @param {min, max}
11
+ */
12
+ export const minMaxArray = <C extends t.Mixed>(
13
+ codec: C,
14
+ {
15
+ min,
16
+ max,
17
+ }: {
18
+ min?: number;
19
+ max?: number;
20
+ } = {},
21
+ ) =>
22
+ t.brand(
23
+ t.array(codec),
24
+ (n: C[]): n is t.Branded<C[], IMinMaxArray<C>> =>
25
+ (!min || min <= n.length) && (!max || n.length <= max),
26
+ "minMaxArray",
27
+ );
@@ -0,0 +1,5 @@
1
+ import * as t from "io-ts";
2
+
3
+ export function Optional<T>(type: t.Type<T>) {
4
+ return t.union([type, t.undefined]);
5
+ }
@@ -0,0 +1,11 @@
1
+ import * as t from "io-ts";
2
+ import { Optional } from "./optional";
3
+
4
+ export const optionalString = Optional(t.string);
5
+ export const optionalStringArray = Optional(t.array(t.string));
6
+ export const optionalBoolean = Optional(t.boolean);
7
+ export const optionalNumber = Optional(t.number);
8
+ export const optionalStringOrNumber = Optional(t.union([t.string, t.number]));
9
+ export const optionalUnknown = Optional(
10
+ t.intersection([t.unknown, t.partial({})]),
11
+ );
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/schema/keyGen/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyGenState.d.ts","sourceRoot":"","sources":["../../../../src/schema/keyGen/keyGenState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,eAAO,MAAM,eAAe;;;;CAE3B,CAAC;AACF,eAAO,MAAM,WAAW;;;;EAA2B,CAAC;AACpD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyGenType.d.ts","sourceRoot":"","sources":["../../../../src/schema/keyGen/keyGenType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,oBAAY,cAAc;IACxB,KAAK,UAAU;CAChB;AACD,eAAO,MAAM,UAAU,iCAA0B,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mpcv2BroadcastMessage.d.ts","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/common/mpcv2BroadcastMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAG3B,eAAO,MAAM,qBAAqB;;;;EAOjC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE3E,eAAO,MAAM,mCAAmC;;;;;;IAK9C,CAAC;AAEH,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,MAAM,CACxD,OAAO,mCAAmC,CAC3C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mpcv2P2PMessage.d.ts","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/common/mpcv2P2PMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAG3B,eAAO,MAAM,eAAe;;;;;EAQ3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mpcv2PartyFromStringOrNumber.d.ts","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/common/mpcv2PartyFromStringOrNumber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAK3B,eAAO,MAAM,4BAA4B,yGAGxC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CACjD,OAAO,4BAA4B,CACpC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/schema/mpcv2/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/keyGen/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"keygenRound.d.ts","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/keyGen/keygenRound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAI3B,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;EAKnC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,wBAAwB,CAChC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;EAKpC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAC9C,OAAO,yBAAyB,CACjC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;EAMnC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,wBAAwB,CAChC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EAKpC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAC9C,OAAO,yBAAyB,CACjC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;EAMnC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,wBAAwB,CAChC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;EAIpC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAC9C,OAAO,yBAAyB,CACjC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mpcv2KeyGenState.d.ts","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/keyGen/mpcv2KeyGenState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,oBAAY,oBAAoB;IAC9B,UAAU,aAAa;IACvB,UAAU,aAAa;IACvB,UAAU,aAAa;CACxB;AACD,eAAO,MAAM,gBAAgB,uCAG5B,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/signing/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}