@0xtorch/core 0.0.30 → 0.0.31
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/.DS_Store +0 -0
- package/_cjs/actions/index.js +17 -13
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/utils/createEvidenceNoneAccountActions.js +323 -0
- package/_cjs/actions/utils/createEvidenceNoneAccountActions.js.map +1 -0
- package/_cjs/actions/utils/parseBaseAccountActionToAccountAction.js +680 -0
- package/_cjs/actions/utils/parseBaseAccountActionToAccountAction.js.map +1 -0
- package/_cjs/actions/utils/parseBaseNormalActionToNormalAction.js +609 -0
- package/_cjs/actions/utils/parseBaseNormalActionToNormalAction.js.map +1 -0
- package/_cjs/actions/utils/transfer.js +22 -0
- package/_cjs/actions/utils/transfer.js.map +1 -0
- package/_cjs/index.js +4 -3
- package/_cjs/index.js.map +1 -1
- package/_esm/actions/index.js +4 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/utils/createEvidenceNoneAccountActions.js +336 -0
- package/_esm/actions/utils/createEvidenceNoneAccountActions.js.map +1 -0
- package/_esm/actions/{utils.js → utils/parseBaseAccountActionToAccountAction.js} +2 -613
- package/_esm/actions/utils/parseBaseAccountActionToAccountAction.js.map +1 -0
- package/_esm/actions/utils/parseBaseNormalActionToNormalAction.js +605 -0
- package/_esm/actions/utils/parseBaseNormalActionToNormalAction.js.map +1 -0
- package/_esm/actions/utils/transfer.js +10 -0
- package/_esm/actions/utils/transfer.js.map +1 -0
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_types/actions/index.d.ts +4 -1
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/utils/createEvidenceNoneAccountActions.d.ts +10 -0
- package/_types/actions/utils/createEvidenceNoneAccountActions.d.ts.map +1 -0
- package/_types/actions/utils/parseBaseAccountActionToAccountAction.d.ts +3 -0
- package/_types/actions/utils/parseBaseAccountActionToAccountAction.d.ts.map +1 -0
- package/_types/actions/utils/parseBaseNormalActionToNormalAction.d.ts +3 -0
- package/_types/actions/utils/parseBaseNormalActionToNormalAction.d.ts.map +1 -0
- package/_types/actions/{utils.d.ts → utils/transfer.d.ts} +2 -5
- package/_types/actions/utils/transfer.d.ts.map +1 -0
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/actions/.DS_Store +0 -0
- package/actions/index.ts +4 -3
- package/actions/utils/createEvidenceNoneAccountActions.ts +470 -0
- package/actions/{utils.ts → utils/parseBaseAccountActionToAccountAction.ts} +10 -913
- package/actions/utils/parseBaseNormalActionToNormalAction.ts +874 -0
- package/actions/utils/transfer.ts +57 -0
- package/assets/.DS_Store +0 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/_cjs/actions/utils.js +0 -1301
- package/_cjs/actions/utils.js.map +0 -1
- package/_esm/actions/utils.js.map +0 -1
- package/_types/actions/utils.d.ts.map +0 -1
|
@@ -44,925 +44,22 @@ import type {
|
|
|
44
44
|
AccountActionWithdraw,
|
|
45
45
|
AccountActionWithdrawWithBond,
|
|
46
46
|
AccountActionWrap,
|
|
47
|
-
NormalActionAddLiquidity,
|
|
48
|
-
NormalActionApprove,
|
|
49
|
-
NormalActionAtomicArbitrage,
|
|
50
|
-
NormalActionBorrow,
|
|
51
|
-
NormalActionBridgeFrom,
|
|
52
|
-
NormalActionBridgeTo,
|
|
53
|
-
NormalActionBuyCrypto,
|
|
54
|
-
NormalActionBuyNft,
|
|
55
|
-
NormalActionCrossReplace,
|
|
56
|
-
NormalActionCrossTrade,
|
|
57
|
-
NormalActionDeposit,
|
|
58
|
-
NormalActionDepositWithBond,
|
|
59
|
-
NormalActionFailTx,
|
|
60
|
-
NormalActionFee,
|
|
61
|
-
NormalActionFreeMintNft,
|
|
62
|
-
NormalActionIncome,
|
|
63
|
-
NormalActionMintNft,
|
|
64
|
-
NormalActionReceiveFromCex,
|
|
65
|
-
NormalActionRemoveLiquidity,
|
|
66
|
-
NormalActionRepayment,
|
|
67
|
-
NormalActionRepaymentWithDebt,
|
|
68
|
-
NormalActionReplace,
|
|
69
|
-
NormalActionRevoke,
|
|
70
|
-
NormalActionSellCrypto,
|
|
71
|
-
NormalActionSellNft,
|
|
72
|
-
NormalActionSendToCex,
|
|
73
|
-
NormalActionSpam,
|
|
74
|
-
NormalActionStake,
|
|
75
|
-
NormalActionSwapNft,
|
|
76
|
-
NormalActionTrade,
|
|
77
|
-
NormalActionTransactionFee,
|
|
78
|
-
NormalActionTransfer,
|
|
79
|
-
NormalActionUnstake,
|
|
80
|
-
NormalActionUnwrap,
|
|
81
|
-
NormalActionValuedown,
|
|
82
|
-
NormalActionValueup,
|
|
83
|
-
NormalActionWithdraw,
|
|
84
|
-
NormalActionWithdrawWithBond,
|
|
85
|
-
NormalActionWrap,
|
|
86
|
-
Transfer,
|
|
87
47
|
TransferCryptoCurrencyIn,
|
|
88
|
-
TransferCryptoCurrencyNone,
|
|
89
48
|
TransferCryptoCurrencyOut,
|
|
90
49
|
TransferFiatCurrencyIn,
|
|
91
|
-
TransferFiatCurrencyNone,
|
|
92
50
|
TransferFiatCurrencyOut,
|
|
93
51
|
TransferNftIn,
|
|
94
|
-
TransferNftNone,
|
|
95
52
|
TransferNftOut,
|
|
96
|
-
} from '
|
|
97
|
-
import type {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
): transfer is TransferCryptoCurrencyIn =>
|
|
107
|
-
transfer.direction === 'in' && transfer.asset.type === 'CryptoCurrency'
|
|
108
|
-
|
|
109
|
-
export const isTransferCryptoCurrencyOut = (
|
|
110
|
-
transfer: Transfer,
|
|
111
|
-
): transfer is TransferCryptoCurrencyOut =>
|
|
112
|
-
transfer.direction === 'out' && transfer.asset.type === 'CryptoCurrency'
|
|
113
|
-
|
|
114
|
-
export const isTransferCryptoCurrencyNone = (
|
|
115
|
-
transfer: Transfer,
|
|
116
|
-
): transfer is TransferCryptoCurrencyNone =>
|
|
117
|
-
transfer.direction === 'none' && transfer.asset.type === 'CryptoCurrency'
|
|
118
|
-
|
|
119
|
-
export const isTransferNftIn = (
|
|
120
|
-
transfer: Transfer,
|
|
121
|
-
): transfer is TransferNftIn =>
|
|
122
|
-
transfer.direction === 'in' && transfer.asset.type === 'Nft'
|
|
123
|
-
|
|
124
|
-
export const isTransferNftOut = (
|
|
125
|
-
transfer: Transfer,
|
|
126
|
-
): transfer is TransferNftOut =>
|
|
127
|
-
transfer.direction === 'out' && transfer.asset.type === 'Nft'
|
|
128
|
-
|
|
129
|
-
export const isTransferNftNone = (
|
|
130
|
-
transfer: Transfer,
|
|
131
|
-
): transfer is TransferNftNone =>
|
|
132
|
-
transfer.direction === 'none' && transfer.asset.type === 'Nft'
|
|
133
|
-
|
|
134
|
-
export const isTransferFiatCurrencyIn = (
|
|
135
|
-
transfer: Transfer,
|
|
136
|
-
): transfer is TransferFiatCurrencyIn =>
|
|
137
|
-
transfer.direction === 'in' && transfer.asset.type === 'FiatCurrency'
|
|
138
|
-
|
|
139
|
-
export const isTransferFiatCurrencyOut = (
|
|
140
|
-
transfer: Transfer,
|
|
141
|
-
): transfer is TransferFiatCurrencyOut =>
|
|
142
|
-
transfer.direction === 'out' && transfer.asset.type === 'FiatCurrency'
|
|
143
|
-
|
|
144
|
-
export const isTransferFiatCurrencyNone = (
|
|
145
|
-
transfer: Transfer,
|
|
146
|
-
): transfer is TransferFiatCurrencyNone =>
|
|
147
|
-
transfer.direction === 'none' && transfer.asset.type === 'FiatCurrency'
|
|
148
|
-
|
|
149
|
-
export const parseBaseNormalActionToNormalAction = (
|
|
150
|
-
action: BaseNormalAction,
|
|
151
|
-
): NormalAction => {
|
|
152
|
-
switch (action.action) {
|
|
153
|
-
case 'add-liquidity': {
|
|
154
|
-
const transfers = action.transfers.filter(
|
|
155
|
-
(
|
|
156
|
-
transfer,
|
|
157
|
-
): transfer is
|
|
158
|
-
| TransferCryptoCurrencyIn
|
|
159
|
-
| TransferNftIn
|
|
160
|
-
| TransferCryptoCurrencyOut
|
|
161
|
-
| TransferNftOut =>
|
|
162
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
163
|
-
isTransferNftIn(transfer) ||
|
|
164
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
165
|
-
isTransferNftOut(transfer),
|
|
166
|
-
)
|
|
167
|
-
if (transfers.length !== action.transfers.length) {
|
|
168
|
-
throw new Error('Invalid action.transfers for add-liquidity')
|
|
169
|
-
}
|
|
170
|
-
if (action.loanId === undefined) {
|
|
171
|
-
throw new Error('action.loandId is required for add-liquidity')
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
...action,
|
|
175
|
-
type: 'LoanNormalAction',
|
|
176
|
-
action: 'add-liquidity',
|
|
177
|
-
loanId: action.loanId,
|
|
178
|
-
transfers,
|
|
179
|
-
} satisfies NormalActionAddLiquidity
|
|
180
|
-
}
|
|
181
|
-
case 'approve': {
|
|
182
|
-
if (action.transfers.length > 0) {
|
|
183
|
-
throw new Error('Invalid action.transfers for approve')
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
...action,
|
|
187
|
-
type: 'NormalAction',
|
|
188
|
-
action: 'approve',
|
|
189
|
-
transfers: [],
|
|
190
|
-
} satisfies NormalActionApprove
|
|
191
|
-
}
|
|
192
|
-
case 'atomic-arbitrage': {
|
|
193
|
-
const transfers = action.transfers.filter(
|
|
194
|
-
(
|
|
195
|
-
transfer,
|
|
196
|
-
): transfer is TransferCryptoCurrencyIn | TransferCryptoCurrencyOut =>
|
|
197
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
198
|
-
isTransferCryptoCurrencyOut(transfer),
|
|
199
|
-
)
|
|
200
|
-
if (transfers.length !== action.transfers.length) {
|
|
201
|
-
throw new Error('Invalid action.transfers for atomic-arbitrage')
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
...action,
|
|
205
|
-
type: 'NormalAction',
|
|
206
|
-
action: 'atomic-arbitrage',
|
|
207
|
-
transfers,
|
|
208
|
-
} satisfies NormalActionAtomicArbitrage
|
|
209
|
-
}
|
|
210
|
-
case 'borrow': {
|
|
211
|
-
const transfers = action.transfers.filter(
|
|
212
|
-
(transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
|
|
213
|
-
isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
|
|
214
|
-
)
|
|
215
|
-
if (transfers.length !== action.transfers.length) {
|
|
216
|
-
throw new Error('Invalid action.transfers for borrow')
|
|
217
|
-
}
|
|
218
|
-
if (action.loanId === undefined) {
|
|
219
|
-
throw new Error('action.loandId is required for borrow')
|
|
220
|
-
}
|
|
221
|
-
return {
|
|
222
|
-
...action,
|
|
223
|
-
type: 'LoanNormalAction',
|
|
224
|
-
action: 'borrow',
|
|
225
|
-
loanId: action.loanId,
|
|
226
|
-
transfers,
|
|
227
|
-
} satisfies NormalActionBorrow
|
|
228
|
-
}
|
|
229
|
-
case 'bridge-from': {
|
|
230
|
-
const transfers = action.transfers.filter(
|
|
231
|
-
(transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
|
|
232
|
-
isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
|
|
233
|
-
)
|
|
234
|
-
if (transfers.length !== action.transfers.length) {
|
|
235
|
-
throw new Error('Invalid action.transfers for bridge-from')
|
|
236
|
-
}
|
|
237
|
-
if (action.crossId === undefined) {
|
|
238
|
-
throw new Error('action.crossId is required for bridge-from')
|
|
239
|
-
}
|
|
240
|
-
if (action.crossType === undefined) {
|
|
241
|
-
throw new Error('action.crossType is required for bridge-from')
|
|
242
|
-
}
|
|
243
|
-
return {
|
|
244
|
-
...action,
|
|
245
|
-
type: 'CrossNormalAction',
|
|
246
|
-
action: 'bridge-from',
|
|
247
|
-
crossId: action.crossId,
|
|
248
|
-
crossType: action.crossType,
|
|
249
|
-
transfers,
|
|
250
|
-
} satisfies NormalActionBridgeFrom
|
|
251
|
-
}
|
|
252
|
-
case 'bridge-to': {
|
|
253
|
-
const transfers = action.transfers.filter(
|
|
254
|
-
(transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
|
|
255
|
-
isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
|
|
256
|
-
)
|
|
257
|
-
if (transfers.length !== action.transfers.length) {
|
|
258
|
-
throw new Error('Invalid action.transfers for bridge-to')
|
|
259
|
-
}
|
|
260
|
-
if (action.crossId === undefined) {
|
|
261
|
-
throw new Error('action.crossId is required for bridge-to')
|
|
262
|
-
}
|
|
263
|
-
if (action.crossType === undefined) {
|
|
264
|
-
throw new Error('action.crossType is required for bridge-to')
|
|
265
|
-
}
|
|
266
|
-
return {
|
|
267
|
-
...action,
|
|
268
|
-
type: 'CrossNormalAction',
|
|
269
|
-
action: 'bridge-to',
|
|
270
|
-
crossId: action.crossId,
|
|
271
|
-
crossType: action.crossType,
|
|
272
|
-
transfers,
|
|
273
|
-
} satisfies NormalActionBridgeTo
|
|
274
|
-
}
|
|
275
|
-
case 'buy-crypto': {
|
|
276
|
-
const transfers = action.transfers.filter(
|
|
277
|
-
(
|
|
278
|
-
transfer,
|
|
279
|
-
): transfer is TransferCryptoCurrencyIn | TransferFiatCurrencyOut =>
|
|
280
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
281
|
-
isTransferFiatCurrencyOut(transfer),
|
|
282
|
-
)
|
|
283
|
-
if (transfers.length !== action.transfers.length) {
|
|
284
|
-
throw new Error('Invalid action.transfers for buy-crypto')
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
...action,
|
|
288
|
-
type: 'NormalAction',
|
|
289
|
-
action: 'buy-crypto',
|
|
290
|
-
transfers,
|
|
291
|
-
} satisfies NormalActionBuyCrypto
|
|
292
|
-
}
|
|
293
|
-
case 'buy-nft': {
|
|
294
|
-
const transfers = action.transfers.filter(
|
|
295
|
-
(
|
|
296
|
-
transfer,
|
|
297
|
-
): transfer is
|
|
298
|
-
| TransferNftIn
|
|
299
|
-
| TransferFiatCurrencyOut
|
|
300
|
-
| TransferCryptoCurrencyOut =>
|
|
301
|
-
isTransferNftIn(transfer) ||
|
|
302
|
-
isTransferFiatCurrencyOut(transfer) ||
|
|
303
|
-
isTransferCryptoCurrencyOut(transfer),
|
|
304
|
-
)
|
|
305
|
-
if (transfers.length !== action.transfers.length) {
|
|
306
|
-
throw new Error('Invalid action.transfers for buy-nft')
|
|
307
|
-
}
|
|
308
|
-
return {
|
|
309
|
-
...action,
|
|
310
|
-
type: 'NormalAction',
|
|
311
|
-
action: 'buy-nft',
|
|
312
|
-
transfers,
|
|
313
|
-
} satisfies NormalActionBuyNft
|
|
314
|
-
}
|
|
315
|
-
case 'cross-replace': {
|
|
316
|
-
const transfers = action.transfers.filter(
|
|
317
|
-
(
|
|
318
|
-
transfer,
|
|
319
|
-
): transfer is
|
|
320
|
-
| TransferCryptoCurrencyIn
|
|
321
|
-
| TransferNftIn
|
|
322
|
-
| TransferFiatCurrencyIn
|
|
323
|
-
| TransferCryptoCurrencyOut
|
|
324
|
-
| TransferNftOut
|
|
325
|
-
| TransferFiatCurrencyOut =>
|
|
326
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
327
|
-
isTransferNftIn(transfer) ||
|
|
328
|
-
isTransferFiatCurrencyIn(transfer) ||
|
|
329
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
330
|
-
isTransferNftOut(transfer) ||
|
|
331
|
-
isTransferFiatCurrencyOut(transfer),
|
|
332
|
-
)
|
|
333
|
-
if (transfers.length !== action.transfers.length) {
|
|
334
|
-
throw new Error('Invalid action.transfers for cross-replace')
|
|
335
|
-
}
|
|
336
|
-
if (action.crossId === undefined) {
|
|
337
|
-
throw new Error('action.crossId is required for cross-replace')
|
|
338
|
-
}
|
|
339
|
-
if (action.crossType === undefined) {
|
|
340
|
-
throw new Error('action.crossType is required for cross-replace')
|
|
341
|
-
}
|
|
342
|
-
return {
|
|
343
|
-
...action,
|
|
344
|
-
type: 'CrossNormalAction',
|
|
345
|
-
action: 'cross-replace',
|
|
346
|
-
crossId: action.crossId,
|
|
347
|
-
crossType: action.crossType,
|
|
348
|
-
transfers,
|
|
349
|
-
} satisfies NormalActionCrossReplace
|
|
350
|
-
}
|
|
351
|
-
case 'cross-trade': {
|
|
352
|
-
const transfers = action.transfers.filter(
|
|
353
|
-
(
|
|
354
|
-
transfer,
|
|
355
|
-
): transfer is
|
|
356
|
-
| TransferCryptoCurrencyIn
|
|
357
|
-
| TransferNftIn
|
|
358
|
-
| TransferFiatCurrencyIn
|
|
359
|
-
| TransferCryptoCurrencyOut
|
|
360
|
-
| TransferNftOut
|
|
361
|
-
| TransferFiatCurrencyOut =>
|
|
362
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
363
|
-
isTransferNftIn(transfer) ||
|
|
364
|
-
isTransferFiatCurrencyIn(transfer) ||
|
|
365
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
366
|
-
isTransferNftOut(transfer) ||
|
|
367
|
-
isTransferFiatCurrencyOut(transfer),
|
|
368
|
-
)
|
|
369
|
-
if (transfers.length !== action.transfers.length) {
|
|
370
|
-
throw new Error('Invalid action.transfers for cross-trade')
|
|
371
|
-
}
|
|
372
|
-
if (action.crossId === undefined) {
|
|
373
|
-
throw new Error('action.crossId is required for cross-trade')
|
|
374
|
-
}
|
|
375
|
-
if (action.crossType === undefined) {
|
|
376
|
-
throw new Error('action.crossType is required for cross-trade')
|
|
377
|
-
}
|
|
378
|
-
return {
|
|
379
|
-
...action,
|
|
380
|
-
type: 'CrossNormalAction',
|
|
381
|
-
action: 'cross-trade',
|
|
382
|
-
crossId: action.crossId,
|
|
383
|
-
crossType: action.crossType,
|
|
384
|
-
transfers,
|
|
385
|
-
} satisfies NormalActionCrossTrade
|
|
386
|
-
}
|
|
387
|
-
case 'deposit': {
|
|
388
|
-
const transfers = action.transfers.filter(
|
|
389
|
-
(transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
|
|
390
|
-
isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
|
|
391
|
-
)
|
|
392
|
-
if (transfers.length !== action.transfers.length) {
|
|
393
|
-
throw new Error('Invalid action.transfers for deposit')
|
|
394
|
-
}
|
|
395
|
-
if (action.loanId === undefined) {
|
|
396
|
-
throw new Error('action.loandId is required for deposit')
|
|
397
|
-
}
|
|
398
|
-
return {
|
|
399
|
-
...action,
|
|
400
|
-
type: 'LoanNormalAction',
|
|
401
|
-
action: 'deposit',
|
|
402
|
-
loanId: action.loanId,
|
|
403
|
-
transfers,
|
|
404
|
-
} satisfies NormalActionDeposit
|
|
405
|
-
}
|
|
406
|
-
case 'deposit-with-bond': {
|
|
407
|
-
const transfers = action.transfers.filter(
|
|
408
|
-
(
|
|
409
|
-
transfer,
|
|
410
|
-
): transfer is
|
|
411
|
-
| TransferCryptoCurrencyIn
|
|
412
|
-
| TransferNftIn
|
|
413
|
-
| TransferCryptoCurrencyOut
|
|
414
|
-
| TransferNftOut =>
|
|
415
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
416
|
-
isTransferNftIn(transfer) ||
|
|
417
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
418
|
-
isTransferNftOut(transfer),
|
|
419
|
-
)
|
|
420
|
-
if (transfers.length !== action.transfers.length) {
|
|
421
|
-
throw new Error('Invalid action.transfers for deposit-with-bond')
|
|
422
|
-
}
|
|
423
|
-
if (action.loanId === undefined) {
|
|
424
|
-
throw new Error('action.loandId is required for deposit-with-bond')
|
|
425
|
-
}
|
|
426
|
-
return {
|
|
427
|
-
...action,
|
|
428
|
-
type: 'LoanNormalAction',
|
|
429
|
-
action: 'deposit-with-bond',
|
|
430
|
-
loanId: action.loanId,
|
|
431
|
-
transfers,
|
|
432
|
-
} satisfies NormalActionDepositWithBond
|
|
433
|
-
}
|
|
434
|
-
case 'fail-tx': {
|
|
435
|
-
if (action.transfers.length > 0) {
|
|
436
|
-
throw new Error('Invalid action.transfers for fail-tx')
|
|
437
|
-
}
|
|
438
|
-
return {
|
|
439
|
-
...action,
|
|
440
|
-
type: 'NormalAction',
|
|
441
|
-
action: 'fail-tx',
|
|
442
|
-
transfers: [],
|
|
443
|
-
} satisfies NormalActionFailTx
|
|
444
|
-
}
|
|
445
|
-
case 'fee': {
|
|
446
|
-
const transfers = action.transfers.filter(
|
|
447
|
-
(
|
|
448
|
-
transfer,
|
|
449
|
-
): transfer is TransferCryptoCurrencyOut | TransferFiatCurrencyOut =>
|
|
450
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
451
|
-
isTransferFiatCurrencyOut(transfer),
|
|
452
|
-
)
|
|
453
|
-
if (transfers.length !== action.transfers.length) {
|
|
454
|
-
throw new Error('Invalid action.transfers for fee')
|
|
455
|
-
}
|
|
456
|
-
return {
|
|
457
|
-
...action,
|
|
458
|
-
type: 'NormalAction',
|
|
459
|
-
action: 'fee',
|
|
460
|
-
transfers,
|
|
461
|
-
} satisfies NormalActionFee
|
|
462
|
-
}
|
|
463
|
-
case 'free-mint-nft': {
|
|
464
|
-
const transfers = action.transfers.filter(
|
|
465
|
-
(transfer): transfer is TransferNftIn => isTransferNftIn(transfer),
|
|
466
|
-
)
|
|
467
|
-
if (transfers.length !== action.transfers.length) {
|
|
468
|
-
throw new Error('Invalid action.transfers for free-mint-nft')
|
|
469
|
-
}
|
|
470
|
-
return {
|
|
471
|
-
...action,
|
|
472
|
-
type: 'NormalAction',
|
|
473
|
-
action: 'free-mint-nft',
|
|
474
|
-
transfers,
|
|
475
|
-
} satisfies NormalActionFreeMintNft
|
|
476
|
-
}
|
|
477
|
-
case 'income': {
|
|
478
|
-
const transfers = action.transfers.filter(
|
|
479
|
-
(
|
|
480
|
-
transfer,
|
|
481
|
-
): transfer is
|
|
482
|
-
| TransferCryptoCurrencyIn
|
|
483
|
-
| TransferNftIn
|
|
484
|
-
| TransferFiatCurrencyIn =>
|
|
485
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
486
|
-
isTransferNftIn(transfer) ||
|
|
487
|
-
isTransferFiatCurrencyIn(transfer),
|
|
488
|
-
)
|
|
489
|
-
if (transfers.length !== action.transfers.length) {
|
|
490
|
-
throw new Error('Invalid action.transfers for income')
|
|
491
|
-
}
|
|
492
|
-
return {
|
|
493
|
-
...action,
|
|
494
|
-
type: 'NormalAction',
|
|
495
|
-
action: 'income',
|
|
496
|
-
transfers,
|
|
497
|
-
} satisfies NormalActionIncome
|
|
498
|
-
}
|
|
499
|
-
case 'mint-nft': {
|
|
500
|
-
const transfers = action.transfers.filter(
|
|
501
|
-
(
|
|
502
|
-
transfer,
|
|
503
|
-
): transfer is
|
|
504
|
-
| TransferNftIn
|
|
505
|
-
| TransferFiatCurrencyOut
|
|
506
|
-
| TransferCryptoCurrencyOut =>
|
|
507
|
-
isTransferNftIn(transfer) ||
|
|
508
|
-
isTransferFiatCurrencyOut(transfer) ||
|
|
509
|
-
isTransferCryptoCurrencyOut(transfer),
|
|
510
|
-
)
|
|
511
|
-
if (transfers.length !== action.transfers.length) {
|
|
512
|
-
throw new Error('Invalid action.transfers for mint-nft')
|
|
513
|
-
}
|
|
514
|
-
return {
|
|
515
|
-
...action,
|
|
516
|
-
type: 'NormalAction',
|
|
517
|
-
action: 'mint-nft',
|
|
518
|
-
transfers,
|
|
519
|
-
} satisfies NormalActionMintNft
|
|
520
|
-
}
|
|
521
|
-
case 'receive-from-cex': {
|
|
522
|
-
const transfers = action.transfers.filter(
|
|
523
|
-
(transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
|
|
524
|
-
isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
|
|
525
|
-
)
|
|
526
|
-
if (transfers.length !== action.transfers.length) {
|
|
527
|
-
throw new Error('Invalid action.transfers for receive-from-cex')
|
|
528
|
-
}
|
|
529
|
-
return {
|
|
530
|
-
...action,
|
|
531
|
-
type: 'NormalAction',
|
|
532
|
-
action: 'receive-from-cex',
|
|
533
|
-
transfers,
|
|
534
|
-
} satisfies NormalActionReceiveFromCex
|
|
535
|
-
}
|
|
536
|
-
case 'remove-liquidity': {
|
|
537
|
-
const transfers = action.transfers.filter(
|
|
538
|
-
(
|
|
539
|
-
transfer,
|
|
540
|
-
): transfer is
|
|
541
|
-
| TransferCryptoCurrencyIn
|
|
542
|
-
| TransferNftIn
|
|
543
|
-
| TransferCryptoCurrencyOut
|
|
544
|
-
| TransferNftOut =>
|
|
545
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
546
|
-
isTransferNftIn(transfer) ||
|
|
547
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
548
|
-
isTransferNftOut(transfer),
|
|
549
|
-
)
|
|
550
|
-
if (transfers.length !== action.transfers.length) {
|
|
551
|
-
throw new Error('Invalid action.transfers for remove-liquidity')
|
|
552
|
-
}
|
|
553
|
-
if (action.loanId === undefined) {
|
|
554
|
-
throw new Error('action.loandId is required for remove-liquidity')
|
|
555
|
-
}
|
|
556
|
-
return {
|
|
557
|
-
...action,
|
|
558
|
-
type: 'LoanNormalAction',
|
|
559
|
-
action: 'remove-liquidity',
|
|
560
|
-
loanId: action.loanId,
|
|
561
|
-
transfers,
|
|
562
|
-
} satisfies NormalActionRemoveLiquidity
|
|
563
|
-
}
|
|
564
|
-
case 'repayment': {
|
|
565
|
-
const transfers = action.transfers.filter(
|
|
566
|
-
(transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
|
|
567
|
-
isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
|
|
568
|
-
)
|
|
569
|
-
if (transfers.length !== action.transfers.length) {
|
|
570
|
-
throw new Error('Invalid action.transfers for repayment')
|
|
571
|
-
}
|
|
572
|
-
if (action.loanId === undefined) {
|
|
573
|
-
throw new Error('action.loandId is required for repayment')
|
|
574
|
-
}
|
|
575
|
-
return {
|
|
576
|
-
...action,
|
|
577
|
-
type: 'LoanNormalAction',
|
|
578
|
-
action: 'repayment',
|
|
579
|
-
loanId: action.loanId,
|
|
580
|
-
transfers,
|
|
581
|
-
} satisfies NormalActionRepayment
|
|
582
|
-
}
|
|
583
|
-
case 'repayment-with-debt': {
|
|
584
|
-
const transfers = action.transfers.filter(
|
|
585
|
-
(
|
|
586
|
-
transfer,
|
|
587
|
-
): transfer is
|
|
588
|
-
| TransferCryptoCurrencyIn
|
|
589
|
-
| TransferNftIn
|
|
590
|
-
| TransferCryptoCurrencyOut
|
|
591
|
-
| TransferNftOut =>
|
|
592
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
593
|
-
isTransferNftIn(transfer) ||
|
|
594
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
595
|
-
isTransferNftOut(transfer),
|
|
596
|
-
)
|
|
597
|
-
if (transfers.length !== action.transfers.length) {
|
|
598
|
-
throw new Error('Invalid action.transfers for repayment-with-debt')
|
|
599
|
-
}
|
|
600
|
-
if (action.loanId === undefined) {
|
|
601
|
-
throw new Error('action.loandId is required for repayment-with-debt')
|
|
602
|
-
}
|
|
603
|
-
return {
|
|
604
|
-
...action,
|
|
605
|
-
type: 'LoanNormalAction',
|
|
606
|
-
action: 'repayment-with-debt',
|
|
607
|
-
loanId: action.loanId,
|
|
608
|
-
transfers,
|
|
609
|
-
} satisfies NormalActionRepaymentWithDebt
|
|
610
|
-
}
|
|
611
|
-
case 'replace': {
|
|
612
|
-
const transfers = action.transfers.filter(
|
|
613
|
-
(
|
|
614
|
-
transfer,
|
|
615
|
-
): transfer is
|
|
616
|
-
| TransferCryptoCurrencyIn
|
|
617
|
-
| TransferNftIn
|
|
618
|
-
| TransferCryptoCurrencyOut
|
|
619
|
-
| TransferNftOut =>
|
|
620
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
621
|
-
isTransferNftIn(transfer) ||
|
|
622
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
623
|
-
isTransferNftOut(transfer),
|
|
624
|
-
)
|
|
625
|
-
if (transfers.length !== action.transfers.length) {
|
|
626
|
-
throw new Error('Invalid action.transfers for replace')
|
|
627
|
-
}
|
|
628
|
-
return {
|
|
629
|
-
...action,
|
|
630
|
-
type: 'NormalAction',
|
|
631
|
-
action: 'replace',
|
|
632
|
-
transfers,
|
|
633
|
-
} satisfies NormalActionReplace
|
|
634
|
-
}
|
|
635
|
-
case 'revoke': {
|
|
636
|
-
if (action.transfers.length > 0) {
|
|
637
|
-
throw new Error('Invalid action.transfers for revoke')
|
|
638
|
-
}
|
|
639
|
-
return {
|
|
640
|
-
...action,
|
|
641
|
-
type: 'NormalAction',
|
|
642
|
-
action: 'revoke',
|
|
643
|
-
transfers: [],
|
|
644
|
-
} satisfies NormalActionRevoke
|
|
645
|
-
}
|
|
646
|
-
case 'sell-crypto': {
|
|
647
|
-
const transfers = action.transfers.filter(
|
|
648
|
-
(
|
|
649
|
-
transfer,
|
|
650
|
-
): transfer is TransferFiatCurrencyIn | TransferCryptoCurrencyOut =>
|
|
651
|
-
isTransferFiatCurrencyIn(transfer) ||
|
|
652
|
-
isTransferCryptoCurrencyOut(transfer),
|
|
653
|
-
)
|
|
654
|
-
if (transfers.length !== action.transfers.length) {
|
|
655
|
-
throw new Error('Invalid action.transfers for sell-crypto')
|
|
656
|
-
}
|
|
657
|
-
return {
|
|
658
|
-
...action,
|
|
659
|
-
type: 'NormalAction',
|
|
660
|
-
action: 'sell-crypto',
|
|
661
|
-
transfers,
|
|
662
|
-
} satisfies NormalActionSellCrypto
|
|
663
|
-
}
|
|
664
|
-
case 'sell-nft': {
|
|
665
|
-
const transfers = action.transfers.filter(
|
|
666
|
-
(
|
|
667
|
-
transfer,
|
|
668
|
-
): transfer is
|
|
669
|
-
| TransferFiatCurrencyIn
|
|
670
|
-
| TransferCryptoCurrencyIn
|
|
671
|
-
| TransferNftOut =>
|
|
672
|
-
isTransferFiatCurrencyIn(transfer) ||
|
|
673
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
674
|
-
isTransferNftOut(transfer),
|
|
675
|
-
)
|
|
676
|
-
if (transfers.length !== action.transfers.length) {
|
|
677
|
-
throw new Error('Invalid action.transfers for sell-nft')
|
|
678
|
-
}
|
|
679
|
-
return {
|
|
680
|
-
...action,
|
|
681
|
-
type: 'NormalAction',
|
|
682
|
-
action: 'sell-nft',
|
|
683
|
-
transfers,
|
|
684
|
-
} satisfies NormalActionSellNft
|
|
685
|
-
}
|
|
686
|
-
case 'send-to-cex': {
|
|
687
|
-
const transfers = action.transfers.filter(
|
|
688
|
-
(transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
|
|
689
|
-
isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
|
|
690
|
-
)
|
|
691
|
-
if (transfers.length !== action.transfers.length) {
|
|
692
|
-
throw new Error('Invalid action.transfers for send-to-cex')
|
|
693
|
-
}
|
|
694
|
-
return {
|
|
695
|
-
...action,
|
|
696
|
-
type: 'NormalAction',
|
|
697
|
-
action: 'send-to-cex',
|
|
698
|
-
transfers,
|
|
699
|
-
} satisfies NormalActionSendToCex
|
|
700
|
-
}
|
|
701
|
-
case 'spam': {
|
|
702
|
-
const transfers = action.transfers.filter(
|
|
703
|
-
(
|
|
704
|
-
transfer,
|
|
705
|
-
): transfer is
|
|
706
|
-
| TransferCryptoCurrencyIn
|
|
707
|
-
| TransferNftIn
|
|
708
|
-
| TransferCryptoCurrencyOut
|
|
709
|
-
| TransferNftOut =>
|
|
710
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
711
|
-
isTransferNftIn(transfer) ||
|
|
712
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
713
|
-
isTransferNftOut(transfer),
|
|
714
|
-
)
|
|
715
|
-
if (transfers.length !== action.transfers.length) {
|
|
716
|
-
throw new Error('Invalid action.transfers for spam')
|
|
717
|
-
}
|
|
718
|
-
return {
|
|
719
|
-
...action,
|
|
720
|
-
type: 'NormalAction',
|
|
721
|
-
action: 'spam',
|
|
722
|
-
transfers,
|
|
723
|
-
} satisfies NormalActionSpam
|
|
724
|
-
}
|
|
725
|
-
case 'stake': {
|
|
726
|
-
const transfers = action.transfers.filter(
|
|
727
|
-
(transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
|
|
728
|
-
isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
|
|
729
|
-
)
|
|
730
|
-
if (transfers.length !== action.transfers.length) {
|
|
731
|
-
throw new Error('Invalid action.transfers for stake')
|
|
732
|
-
}
|
|
733
|
-
if (action.loanId === undefined) {
|
|
734
|
-
throw new Error('action.loandId is required for stake')
|
|
735
|
-
}
|
|
736
|
-
return {
|
|
737
|
-
...action,
|
|
738
|
-
type: 'LoanNormalAction',
|
|
739
|
-
action: 'stake',
|
|
740
|
-
loanId: action.loanId,
|
|
741
|
-
transfers,
|
|
742
|
-
} satisfies NormalActionStake
|
|
743
|
-
}
|
|
744
|
-
case 'swap-nft': {
|
|
745
|
-
const transfers = action.transfers.filter(
|
|
746
|
-
(transfer): transfer is TransferNftIn | TransferNftOut =>
|
|
747
|
-
isTransferNftIn(transfer) || isTransferNftOut(transfer),
|
|
748
|
-
)
|
|
749
|
-
if (transfers.length !== action.transfers.length) {
|
|
750
|
-
throw new Error('Invalid action.transfers for swap-nft')
|
|
751
|
-
}
|
|
752
|
-
return {
|
|
753
|
-
...action,
|
|
754
|
-
type: 'NormalAction',
|
|
755
|
-
action: 'swap-nft',
|
|
756
|
-
transfers,
|
|
757
|
-
} satisfies NormalActionSwapNft
|
|
758
|
-
}
|
|
759
|
-
case 'transaction-fee': {
|
|
760
|
-
const transfers = action.transfers.filter(
|
|
761
|
-
(transfer): transfer is TransferCryptoCurrencyOut =>
|
|
762
|
-
isTransferCryptoCurrencyOut(transfer),
|
|
763
|
-
)
|
|
764
|
-
if (transfers.length !== action.transfers.length) {
|
|
765
|
-
throw new Error('Invalid action.transfers for transaction-fee')
|
|
766
|
-
}
|
|
767
|
-
return {
|
|
768
|
-
...action,
|
|
769
|
-
type: 'NormalAction',
|
|
770
|
-
action: 'transaction-fee',
|
|
771
|
-
transfers,
|
|
772
|
-
} satisfies NormalActionTransactionFee
|
|
773
|
-
}
|
|
774
|
-
case 'trade': {
|
|
775
|
-
const transfers = action.transfers.filter(
|
|
776
|
-
(
|
|
777
|
-
transfer,
|
|
778
|
-
): transfer is
|
|
779
|
-
| TransferCryptoCurrencyIn
|
|
780
|
-
| TransferNftIn
|
|
781
|
-
| TransferFiatCurrencyIn
|
|
782
|
-
| TransferCryptoCurrencyOut
|
|
783
|
-
| TransferNftOut
|
|
784
|
-
| TransferFiatCurrencyOut =>
|
|
785
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
786
|
-
isTransferNftIn(transfer) ||
|
|
787
|
-
isTransferFiatCurrencyIn(transfer) ||
|
|
788
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
789
|
-
isTransferNftOut(transfer) ||
|
|
790
|
-
isTransferFiatCurrencyOut(transfer),
|
|
791
|
-
)
|
|
792
|
-
if (transfers.length !== action.transfers.length) {
|
|
793
|
-
throw new Error('Invalid action.transfers for trade')
|
|
794
|
-
}
|
|
795
|
-
return {
|
|
796
|
-
...action,
|
|
797
|
-
type: 'NormalAction',
|
|
798
|
-
action: 'trade',
|
|
799
|
-
transfers,
|
|
800
|
-
} satisfies NormalActionTrade
|
|
801
|
-
}
|
|
802
|
-
case 'transfer': {
|
|
803
|
-
return {
|
|
804
|
-
...action,
|
|
805
|
-
type: 'NormalAction',
|
|
806
|
-
action: 'transfer',
|
|
807
|
-
transfers: [...action.transfers],
|
|
808
|
-
} satisfies NormalActionTransfer
|
|
809
|
-
}
|
|
810
|
-
case 'unstake': {
|
|
811
|
-
const transfers = action.transfers.filter(
|
|
812
|
-
(transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
|
|
813
|
-
isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
|
|
814
|
-
)
|
|
815
|
-
if (transfers.length !== action.transfers.length) {
|
|
816
|
-
throw new Error('Invalid action.transfers for unstake')
|
|
817
|
-
}
|
|
818
|
-
if (action.loanId === undefined) {
|
|
819
|
-
throw new Error('action.loandId is required for unstake')
|
|
820
|
-
}
|
|
821
|
-
return {
|
|
822
|
-
...action,
|
|
823
|
-
type: 'LoanNormalAction',
|
|
824
|
-
action: 'unstake',
|
|
825
|
-
loanId: action.loanId,
|
|
826
|
-
transfers,
|
|
827
|
-
} satisfies NormalActionUnstake
|
|
828
|
-
}
|
|
829
|
-
case 'unwrap': {
|
|
830
|
-
const transfers = action.transfers.filter(
|
|
831
|
-
(
|
|
832
|
-
transfer,
|
|
833
|
-
): transfer is TransferCryptoCurrencyIn | TransferCryptoCurrencyOut =>
|
|
834
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
835
|
-
isTransferCryptoCurrencyOut(transfer),
|
|
836
|
-
)
|
|
837
|
-
if (transfers.length !== action.transfers.length) {
|
|
838
|
-
throw new Error('Invalid action.transfers for unwrap')
|
|
839
|
-
}
|
|
840
|
-
return {
|
|
841
|
-
...action,
|
|
842
|
-
type: 'NormalAction',
|
|
843
|
-
action: 'unwrap',
|
|
844
|
-
transfers,
|
|
845
|
-
} satisfies NormalActionUnwrap
|
|
846
|
-
}
|
|
847
|
-
case 'valuedown': {
|
|
848
|
-
const transfers = action.transfers.filter(
|
|
849
|
-
(
|
|
850
|
-
transfer,
|
|
851
|
-
): transfer is
|
|
852
|
-
| TransferCryptoCurrencyIn
|
|
853
|
-
| TransferNftIn
|
|
854
|
-
| TransferFiatCurrencyIn =>
|
|
855
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
856
|
-
isTransferNftIn(transfer) ||
|
|
857
|
-
isTransferFiatCurrencyIn(transfer),
|
|
858
|
-
)
|
|
859
|
-
if (transfers.length !== action.transfers.length) {
|
|
860
|
-
throw new Error('Invalid action.transfers for valuedown')
|
|
861
|
-
}
|
|
862
|
-
if (action.target === undefined) {
|
|
863
|
-
throw new Error('action.target is required for valuedown')
|
|
864
|
-
}
|
|
865
|
-
return {
|
|
866
|
-
...action,
|
|
867
|
-
type: 'NormalAction',
|
|
868
|
-
action: 'valuedown',
|
|
869
|
-
target: action.target,
|
|
870
|
-
transfers,
|
|
871
|
-
} satisfies NormalActionValuedown
|
|
872
|
-
}
|
|
873
|
-
case 'valueup': {
|
|
874
|
-
const transfers = action.transfers.filter(
|
|
875
|
-
(
|
|
876
|
-
transfer,
|
|
877
|
-
): transfer is
|
|
878
|
-
| TransferCryptoCurrencyOut
|
|
879
|
-
| TransferNftOut
|
|
880
|
-
| TransferFiatCurrencyOut =>
|
|
881
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
882
|
-
isTransferNftOut(transfer) ||
|
|
883
|
-
isTransferFiatCurrencyOut(transfer),
|
|
884
|
-
)
|
|
885
|
-
if (transfers.length !== action.transfers.length) {
|
|
886
|
-
throw new Error('Invalid action.transfers for valueup')
|
|
887
|
-
}
|
|
888
|
-
if (action.target === undefined) {
|
|
889
|
-
throw new Error('action.target is required for valueup')
|
|
890
|
-
}
|
|
891
|
-
return {
|
|
892
|
-
...action,
|
|
893
|
-
type: 'NormalAction',
|
|
894
|
-
action: 'valueup',
|
|
895
|
-
target: action.target,
|
|
896
|
-
transfers,
|
|
897
|
-
} satisfies NormalActionValueup
|
|
898
|
-
}
|
|
899
|
-
case 'withdraw': {
|
|
900
|
-
const transfers = action.transfers.filter(
|
|
901
|
-
(transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
|
|
902
|
-
isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
|
|
903
|
-
)
|
|
904
|
-
if (transfers.length !== action.transfers.length) {
|
|
905
|
-
throw new Error('Invalid action.transfers for withdraw')
|
|
906
|
-
}
|
|
907
|
-
if (action.loanId === undefined) {
|
|
908
|
-
throw new Error('action.loandId is required for withdraw')
|
|
909
|
-
}
|
|
910
|
-
return {
|
|
911
|
-
...action,
|
|
912
|
-
type: 'LoanNormalAction',
|
|
913
|
-
action: 'withdraw',
|
|
914
|
-
loanId: action.loanId,
|
|
915
|
-
transfers,
|
|
916
|
-
} satisfies NormalActionWithdraw
|
|
917
|
-
}
|
|
918
|
-
case 'withdraw-with-bond': {
|
|
919
|
-
const transfers = action.transfers.filter(
|
|
920
|
-
(
|
|
921
|
-
transfer,
|
|
922
|
-
): transfer is
|
|
923
|
-
| TransferCryptoCurrencyIn
|
|
924
|
-
| TransferNftIn
|
|
925
|
-
| TransferCryptoCurrencyOut
|
|
926
|
-
| TransferNftOut =>
|
|
927
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
928
|
-
isTransferNftIn(transfer) ||
|
|
929
|
-
isTransferCryptoCurrencyOut(transfer) ||
|
|
930
|
-
isTransferNftOut(transfer),
|
|
931
|
-
)
|
|
932
|
-
if (transfers.length !== action.transfers.length) {
|
|
933
|
-
throw new Error('Invalid action.transfers for withdraw-with-bond')
|
|
934
|
-
}
|
|
935
|
-
if (action.loanId === undefined) {
|
|
936
|
-
throw new Error('action.loandId is required for withdraw-with-bond')
|
|
937
|
-
}
|
|
938
|
-
return {
|
|
939
|
-
...action,
|
|
940
|
-
type: 'LoanNormalAction',
|
|
941
|
-
action: 'withdraw-with-bond',
|
|
942
|
-
loanId: action.loanId,
|
|
943
|
-
transfers,
|
|
944
|
-
} satisfies NormalActionWithdrawWithBond
|
|
945
|
-
}
|
|
946
|
-
case 'wrap': {
|
|
947
|
-
const transfers = action.transfers.filter(
|
|
948
|
-
(
|
|
949
|
-
transfer,
|
|
950
|
-
): transfer is TransferCryptoCurrencyIn | TransferCryptoCurrencyOut =>
|
|
951
|
-
isTransferCryptoCurrencyIn(transfer) ||
|
|
952
|
-
isTransferCryptoCurrencyOut(transfer),
|
|
953
|
-
)
|
|
954
|
-
if (transfers.length !== action.transfers.length) {
|
|
955
|
-
throw new Error('Invalid action.transfers for wrap')
|
|
956
|
-
}
|
|
957
|
-
return {
|
|
958
|
-
...action,
|
|
959
|
-
type: 'NormalAction',
|
|
960
|
-
action: 'wrap',
|
|
961
|
-
transfers,
|
|
962
|
-
} satisfies NormalActionWrap
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
}
|
|
53
|
+
} from '../types'
|
|
54
|
+
import type { AccountAction, BaseAccountAction } from '../types/action'
|
|
55
|
+
import {
|
|
56
|
+
isTransferCryptoCurrencyIn,
|
|
57
|
+
isTransferCryptoCurrencyOut,
|
|
58
|
+
isTransferFiatCurrencyIn,
|
|
59
|
+
isTransferFiatCurrencyOut,
|
|
60
|
+
isTransferNftIn,
|
|
61
|
+
isTransferNftOut,
|
|
62
|
+
} from './transfer'
|
|
966
63
|
|
|
967
64
|
export const parseBaseAccountActionToAccountAction = (
|
|
968
65
|
action: BaseAccountAction,
|