-
Notifications
You must be signed in to change notification settings - Fork 14
/
sale.ts
109 lines (102 loc) · 2.61 KB
/
sale.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { TokenInfo } from '../../../types';
/**
* Enum representing possible Sale Widget event types.
*/
export enum SaleEventType {
CLOSE_WIDGET = 'close-widget',
SUCCESS = 'success',
FAILURE = 'failure',
REJECTED = 'rejected',
TRANSACTION_SUCCESS = 'transaction-success',
LANGUAGE_CHANGED = 'language-changed',
PAYMENT_METHOD = 'payment-method',
REQUEST_BRIDGE = 'request-bridge',
REQUEST_ONRAMP = 'request-onramp',
REQUEST_SWAP = 'request-swap',
PAYMENT_TOKEN = 'payment-token',
}
/**
* Represents a successful Sale transaction.
* @property {Array} transactions -
*/
export type SaleSuccess = {
/** Chosen payment method */
paymentMethod: SalePaymentTypes | undefined;
/** The minted items token ids */
tokenIds: string[];
/** The executed transactions */
transactions: {
method: string;
hash: string | undefined;
}[];
/** The order reference id, use it to trace order throughout flow */
transactionId: string;
[key: string]: unknown;
};
/**
* Type representing a Sale Widget with type FAILURE.
* @property {string} reason
* @property {number} timestamp
* @property {Array} transactions
*/
export type SaleFailed = {
/** The reason why sale transaction failed. */
reason: string;
/** The error object. */
error: Record<string, unknown>;
/** The timestamp of the failed swap. */
timestamp: number;
/** Chosen payment method */
paymentMethod: SalePaymentTypes | undefined;
/** The executed transactions */
transactions: {
method: string;
hash: string | undefined;
}[];
/** The order reference id, use it to trace order throughout flow */
transactionId: string;
};
/**
* Type representing a Sale Widget with type TRANSACTION_SUCCESS.
* @property {Object} transactions
*/
export type SaleTransactionSuccess = {
paymentMethod: SalePaymentTypes | undefined;
/** The executed transactions */
transactions: {
method: string;
hash: string | undefined;
}[];
};
/**
* Type representing a Sale Widget with type PAYMENT_METHOD.
* @property {Object} transactions
*/
export type SalePaymentMethod = {
/** Chosen payment method */
paymentMethod: SalePaymentTypes | undefined;
};
/**
* Type representing a Sale Widget with type PAYMENT_TOKEN.
* @property {Object} transactions
*/
export type SalePaymentToken = {
/** Chosen payment token */
type: string;
token: TokenInfo;
amount: string;
balance: string;
fiat: {
amount: string;
balance: string;
symbol: string;
}
};
/**
* Enum representing Sale Widget available payment types.
*/
export enum SalePaymentTypes {
CRYPTO = 'crypto',
DEBIT = 'debit',
CREDIT = 'credit',
}