@portal-hq/utils 0.2.0-beta1
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/lib/commonjs/currency/countries/country-codes.js +250 -0
- package/lib/commonjs/currency/countries/currency-codes.js +248 -0
- package/lib/commonjs/currency/countries/index.js +10 -0
- package/lib/commonjs/currency/index.js +29 -0
- package/lib/commonjs/errors/http-error.js +10 -0
- package/lib/commonjs/errors/index.js +23 -0
- package/lib/commonjs/errors/invalid-api-key-error.js +10 -0
- package/lib/commonjs/errors/invalid-chain-id-error.js +10 -0
- package/lib/commonjs/errors/invalid-gateway-config-error.js +10 -0
- package/lib/commonjs/errors/invalid-rpc-config-error.js +10 -0
- package/lib/commonjs/errors/missing-option-error.js +10 -0
- package/lib/commonjs/errors/mpc-signing-error.js +10 -0
- package/lib/commonjs/errors/no-address-error.js +10 -0
- package/lib/commonjs/errors/provider-rpc-error.js +52 -0
- package/lib/commonjs/eth-requests/index.js +87 -0
- package/lib/commonjs/http-request/index.js +72 -0
- package/lib/commonjs/index.js +46 -0
- package/lib/commonjs/requesters/http.js +52 -0
- package/lib/commonjs/requesters/index.js +8 -0
- package/lib/esm/currency/countries/country-codes.js +248 -0
- package/lib/esm/currency/countries/currency-codes.js +246 -0
- package/lib/esm/currency/countries/index.js +2 -0
- package/lib/esm/currency/index.js +25 -0
- package/lib/esm/errors/http-error.js +8 -0
- package/lib/esm/errors/index.js +8 -0
- package/lib/esm/errors/invalid-api-key-error.js +8 -0
- package/lib/esm/errors/invalid-chain-id-error.js +8 -0
- package/lib/esm/errors/invalid-gateway-config-error.js +8 -0
- package/lib/esm/errors/invalid-rpc-config-error.js +26 -0
- package/lib/esm/errors/missing-option-error.js +8 -0
- package/lib/esm/errors/mpc-signing-error.js +8 -0
- package/lib/esm/errors/no-address-error.js +8 -0
- package/lib/esm/errors/provider-rpc-error.js +49 -0
- package/lib/esm/eth-requests/index.js +83 -0
- package/lib/esm/http-request/index.js +70 -0
- package/lib/esm/index.js +6 -0
- package/lib/esm/requesters/http.js +50 -0
- package/lib/esm/requesters/index.js +1 -0
- package/package.json +22 -0
- package/src/currency/countries/country-codes.ts +249 -0
- package/src/currency/countries/currency-codes.ts +247 -0
- package/src/currency/countries/index.ts +2 -0
- package/src/currency/index.ts +28 -0
- package/src/errors/http-error.ts +12 -0
- package/src/errors/index.ts +11 -0
- package/src/errors/invalid-api-key-error.ts +10 -0
- package/src/errors/invalid-chain-id-error.ts +10 -0
- package/src/errors/invalid-gateway-config-error.ts +10 -0
- package/src/errors/missing-option-error.ts +14 -0
- package/src/errors/mpc-signing-error.ts +10 -0
- package/src/errors/no-address-error.ts +10 -0
- package/src/errors/provider-rpc-error.ts +69 -0
- package/src/eth-requests/index.ts +109 -0
- package/src/http-request/index.ts +90 -0
- package/src/index.ts +25 -0
- package/src/requesters/http.ts +62 -0
- package/src/requesters/index.ts +1 -0
- package/types.d.ts +61 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
const countryCodes: Record<string, string> = {
|
|
2
|
+
AD: 'Andorra',
|
|
3
|
+
AE: 'United Arab Emirates',
|
|
4
|
+
AF: 'Afghanistan',
|
|
5
|
+
AG: 'Antigua and Barbuda',
|
|
6
|
+
AI: 'Anguilla',
|
|
7
|
+
AL: 'Albania',
|
|
8
|
+
AM: 'Armenia',
|
|
9
|
+
AN: 'Netherlands Antilles',
|
|
10
|
+
AO: 'Angola',
|
|
11
|
+
AQ: 'Antarctica',
|
|
12
|
+
AR: 'Argentina',
|
|
13
|
+
AS: 'American Samoa',
|
|
14
|
+
AT: 'Austria',
|
|
15
|
+
AU: 'Australia',
|
|
16
|
+
AW: 'Aruba',
|
|
17
|
+
AZ: 'Azerbaijan',
|
|
18
|
+
BA: 'Bosnia and Herzegovina',
|
|
19
|
+
BB: 'Barbados',
|
|
20
|
+
BD: 'Bangladesh',
|
|
21
|
+
BE: 'Belgium',
|
|
22
|
+
BF: 'Burkina Faso',
|
|
23
|
+
BG: 'Bulgaria',
|
|
24
|
+
BH: 'Bahrain',
|
|
25
|
+
BI: 'Burundi',
|
|
26
|
+
BJ: 'Benin',
|
|
27
|
+
BM: 'Bermuda',
|
|
28
|
+
BN: 'Brunei',
|
|
29
|
+
BO: 'Bolivia',
|
|
30
|
+
BR: 'Brazil',
|
|
31
|
+
BS: 'Bahamas',
|
|
32
|
+
BT: 'Bhutan',
|
|
33
|
+
BV: 'Bouvet Island',
|
|
34
|
+
BW: 'Botswana',
|
|
35
|
+
BY: 'Belarus',
|
|
36
|
+
BZ: 'Belize',
|
|
37
|
+
CA: 'Canada',
|
|
38
|
+
CC: 'Cocos (Keeling) Islands',
|
|
39
|
+
CD: 'The Democratic Republic of Congo',
|
|
40
|
+
CF: 'Central African Republic',
|
|
41
|
+
CG: 'Congo',
|
|
42
|
+
CH: 'Switzerland',
|
|
43
|
+
CI: 'Ivory Coast',
|
|
44
|
+
CK: 'Cook Islands',
|
|
45
|
+
CL: 'Chile',
|
|
46
|
+
CM: 'Cameroon',
|
|
47
|
+
CN: 'China',
|
|
48
|
+
CO: 'Colombia',
|
|
49
|
+
CR: 'Costa Rica',
|
|
50
|
+
CU: 'Cuba',
|
|
51
|
+
CV: 'Cape Verde',
|
|
52
|
+
CX: 'Christmas Island',
|
|
53
|
+
CY: 'Cyprus',
|
|
54
|
+
CZ: 'Czech Republic',
|
|
55
|
+
DE: 'Germany',
|
|
56
|
+
DJ: 'Djibouti',
|
|
57
|
+
DK: 'Denmark',
|
|
58
|
+
DM: 'Dominica',
|
|
59
|
+
DO: 'Dominican Republic',
|
|
60
|
+
DZ: 'Algeria',
|
|
61
|
+
EC: 'Ecuador',
|
|
62
|
+
EE: 'Estonia',
|
|
63
|
+
EG: 'Egypt',
|
|
64
|
+
EH: 'Western Sahara',
|
|
65
|
+
ER: 'Eritrea',
|
|
66
|
+
ES: 'Spain',
|
|
67
|
+
ET: 'Ethiopia',
|
|
68
|
+
FI: 'Finland',
|
|
69
|
+
FJ: 'Fiji Islands',
|
|
70
|
+
FK: 'Falkland Islands',
|
|
71
|
+
FM: 'Micronesia, Federated States of',
|
|
72
|
+
FO: 'Faroe Islands',
|
|
73
|
+
FR: 'France',
|
|
74
|
+
GA: 'Gabon',
|
|
75
|
+
GB: 'Northern Ireland',
|
|
76
|
+
GD: 'Grenada',
|
|
77
|
+
GE: 'Georgia',
|
|
78
|
+
GF: 'French Guiana',
|
|
79
|
+
GG: 'Guernsey',
|
|
80
|
+
GH: 'Ghana',
|
|
81
|
+
GI: 'Gibraltar',
|
|
82
|
+
GL: 'Greenland',
|
|
83
|
+
GM: 'Gambia',
|
|
84
|
+
GN: 'Guinea',
|
|
85
|
+
GP: 'Guadeloupe',
|
|
86
|
+
GQ: 'Equatorial Guinea',
|
|
87
|
+
GR: 'Greece',
|
|
88
|
+
GS: 'South Georgia and the South Sandwich Islands',
|
|
89
|
+
GT: 'Guatemala',
|
|
90
|
+
GU: 'Guam',
|
|
91
|
+
GW: 'Guinea-Bissau',
|
|
92
|
+
GY: 'Guyana',
|
|
93
|
+
HK: 'Hong Kong',
|
|
94
|
+
HM: 'Heard Island and McDonald Islands',
|
|
95
|
+
HN: 'Honduras',
|
|
96
|
+
HR: 'Croatia',
|
|
97
|
+
HT: 'Haiti',
|
|
98
|
+
HU: 'Hungary',
|
|
99
|
+
ID: 'Indonesia',
|
|
100
|
+
IE: 'Ireland',
|
|
101
|
+
IL: 'Israel',
|
|
102
|
+
IM: 'Isle of Man',
|
|
103
|
+
IN: 'India',
|
|
104
|
+
IO: 'British Indian Ocean Territory',
|
|
105
|
+
IQ: 'Iraq',
|
|
106
|
+
IR: 'Iran',
|
|
107
|
+
IS: 'Iceland',
|
|
108
|
+
IT: 'Italy',
|
|
109
|
+
JE: 'Jersey',
|
|
110
|
+
JM: 'Jamaica',
|
|
111
|
+
JO: 'Jordan',
|
|
112
|
+
JP: 'Japan',
|
|
113
|
+
KE: 'Kenya',
|
|
114
|
+
KG: 'Kyrgyzstan',
|
|
115
|
+
KH: 'Cambodia',
|
|
116
|
+
KI: 'Kiribati',
|
|
117
|
+
KM: 'Comoros',
|
|
118
|
+
KN: 'Saint Kitts and Nevis',
|
|
119
|
+
KP: 'North Korea',
|
|
120
|
+
KR: 'South Korea',
|
|
121
|
+
KW: 'Kuwait',
|
|
122
|
+
KY: 'Cayman Islands',
|
|
123
|
+
KZ: 'Kazakhstan',
|
|
124
|
+
LA: 'Laos',
|
|
125
|
+
LB: 'Lebanon',
|
|
126
|
+
LC: 'Saint Lucia',
|
|
127
|
+
LI: 'Liechtenstein',
|
|
128
|
+
LK: 'Sri Lanka',
|
|
129
|
+
LR: 'Liberia',
|
|
130
|
+
LS: 'Lesotho',
|
|
131
|
+
LT: 'Lithuania',
|
|
132
|
+
LU: 'Luxembourg',
|
|
133
|
+
LV: 'Latvia',
|
|
134
|
+
LY: 'Libyan Arab Jamahiriya',
|
|
135
|
+
MA: 'Morocco',
|
|
136
|
+
MC: 'Monaco',
|
|
137
|
+
MD: 'Moldova',
|
|
138
|
+
ME: 'Montenegro',
|
|
139
|
+
MG: 'Madagascar',
|
|
140
|
+
MH: 'Marshall Islands',
|
|
141
|
+
MK: 'North Macedonia',
|
|
142
|
+
ML: 'Mali',
|
|
143
|
+
MM: 'Myanmar',
|
|
144
|
+
MN: 'Mongolia',
|
|
145
|
+
MO: 'Macao',
|
|
146
|
+
MP: 'Northern Mariana Islands',
|
|
147
|
+
MQ: 'Martinique',
|
|
148
|
+
MR: 'Mauritania',
|
|
149
|
+
MS: 'Montserrat',
|
|
150
|
+
MT: 'Malta',
|
|
151
|
+
MU: 'Mauritius',
|
|
152
|
+
MV: 'Maldives',
|
|
153
|
+
MW: 'Malawi',
|
|
154
|
+
MX: 'Mexico',
|
|
155
|
+
MY: 'Malaysia',
|
|
156
|
+
MZ: 'Mozambique',
|
|
157
|
+
NA: 'Namibia',
|
|
158
|
+
NC: 'New Caledonia',
|
|
159
|
+
NE: 'Niger',
|
|
160
|
+
NF: 'Norfolk Island',
|
|
161
|
+
NG: 'Nigeria',
|
|
162
|
+
NI: 'Nicaragua',
|
|
163
|
+
NL: 'Netherlands',
|
|
164
|
+
NO: 'Norway',
|
|
165
|
+
NP: 'Nepal',
|
|
166
|
+
NR: 'Nauru',
|
|
167
|
+
NU: 'Niue',
|
|
168
|
+
NZ: 'New Zealand',
|
|
169
|
+
OM: 'Oman',
|
|
170
|
+
PA: 'Panama',
|
|
171
|
+
PE: 'Peru',
|
|
172
|
+
PF: 'French Polynesia',
|
|
173
|
+
PG: 'Papua New Guinea',
|
|
174
|
+
PH: 'Philippines',
|
|
175
|
+
PK: 'Pakistan',
|
|
176
|
+
PL: 'Poland',
|
|
177
|
+
PM: 'Saint Pierre and Miquelon',
|
|
178
|
+
PN: 'Pitcairn',
|
|
179
|
+
PR: 'Puerto Rico',
|
|
180
|
+
PS: 'Palestine',
|
|
181
|
+
PT: 'Portugal',
|
|
182
|
+
PW: 'Palau',
|
|
183
|
+
PY: 'Paraguay',
|
|
184
|
+
QA: 'Qatar',
|
|
185
|
+
RE: 'Reunion',
|
|
186
|
+
RO: 'Romania',
|
|
187
|
+
RS: 'Serbia',
|
|
188
|
+
RU: 'Russian Federation',
|
|
189
|
+
RW: 'Rwanda',
|
|
190
|
+
SA: 'Saudi Arabia',
|
|
191
|
+
SB: 'Solomon Islands',
|
|
192
|
+
SC: 'Seychelles',
|
|
193
|
+
SD: 'Sudan',
|
|
194
|
+
SE: 'Sweden',
|
|
195
|
+
SG: 'Singapore',
|
|
196
|
+
SH: 'Saint Helena',
|
|
197
|
+
SI: 'Slovenia',
|
|
198
|
+
SJ: 'Svalbard and Jan Mayen',
|
|
199
|
+
SK: 'Slovakia',
|
|
200
|
+
SL: 'Sierra Leone',
|
|
201
|
+
SM: 'San Marino',
|
|
202
|
+
SN: 'Senegal',
|
|
203
|
+
SO: 'Somalia',
|
|
204
|
+
SR: 'Suriname',
|
|
205
|
+
SS: 'South Sudan',
|
|
206
|
+
ST: 'Sao Tome and Principe',
|
|
207
|
+
SV: 'El Salvador',
|
|
208
|
+
SY: 'Syria',
|
|
209
|
+
SZ: 'Swaziland',
|
|
210
|
+
TC: 'Turks and Caicos Islands',
|
|
211
|
+
TD: 'Chad',
|
|
212
|
+
TF: 'French Southern territories',
|
|
213
|
+
TG: 'Togo',
|
|
214
|
+
TH: 'Thailand',
|
|
215
|
+
TJ: 'Tajikistan',
|
|
216
|
+
TK: 'Tokelau',
|
|
217
|
+
TL: 'Timor-Leste',
|
|
218
|
+
TM: 'Turkmenistan',
|
|
219
|
+
TN: 'Tunisia',
|
|
220
|
+
TO: 'Tonga',
|
|
221
|
+
TP: 'East Timor',
|
|
222
|
+
TR: 'Turkey',
|
|
223
|
+
TT: 'Trinidad and Tobago',
|
|
224
|
+
TV: 'Tuvalu',
|
|
225
|
+
TZ: 'Tanzania',
|
|
226
|
+
UA: 'Ukraine',
|
|
227
|
+
UG: 'Uganda',
|
|
228
|
+
UK: 'United Kingdom',
|
|
229
|
+
UM: 'United States Minor Outlying Islands',
|
|
230
|
+
US: 'United States',
|
|
231
|
+
UY: 'Uruguay',
|
|
232
|
+
UZ: 'Uzbekistan',
|
|
233
|
+
VA: 'Holy See (Vatican City State)',
|
|
234
|
+
VC: 'Saint Vincent and the Grenadines',
|
|
235
|
+
VE: 'Venezuela',
|
|
236
|
+
VG: 'Virgin Islands, British',
|
|
237
|
+
VI: 'Virgin Islands, U.S.',
|
|
238
|
+
VN: 'Vietnam',
|
|
239
|
+
VU: 'Vanuatu',
|
|
240
|
+
WF: 'Wallis and Futuna',
|
|
241
|
+
WS: 'Samoa',
|
|
242
|
+
YE: 'Yemen',
|
|
243
|
+
YT: 'Mayotte',
|
|
244
|
+
ZA: 'South Africa',
|
|
245
|
+
ZM: 'Zambia',
|
|
246
|
+
ZW: 'Zimbabwe',
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export default countryCodes
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
const currencyCodes: Record<string, string> = {
|
|
2
|
+
Afghanistan: 'AFN',
|
|
3
|
+
Albania: 'ALL',
|
|
4
|
+
Algeria: 'DZD',
|
|
5
|
+
'American Samoa': 'USD',
|
|
6
|
+
Andorra: 'EUR',
|
|
7
|
+
Angola: 'AOA',
|
|
8
|
+
Anguilla: 'XCD',
|
|
9
|
+
Antarctica: 'XCD',
|
|
10
|
+
'Antigua and Barbuda': 'XCD',
|
|
11
|
+
Argentina: 'ARS',
|
|
12
|
+
Armenia: 'AMD',
|
|
13
|
+
Aruba: 'AWG',
|
|
14
|
+
Australia: 'AUD',
|
|
15
|
+
Austria: 'EUR',
|
|
16
|
+
Azerbaijan: 'AZN',
|
|
17
|
+
Bahamas: 'BSD',
|
|
18
|
+
Bahrain: 'BHD',
|
|
19
|
+
Bangladesh: 'BDT',
|
|
20
|
+
Barbados: 'BBD',
|
|
21
|
+
Belarus: 'BYR',
|
|
22
|
+
Belgium: 'EUR',
|
|
23
|
+
Belize: 'BZD',
|
|
24
|
+
Benin: 'XOF',
|
|
25
|
+
Bermuda: 'BMD',
|
|
26
|
+
Bhutan: 'BTN',
|
|
27
|
+
Bolivia: 'BOB',
|
|
28
|
+
'Bosnia and Herzegovina': 'BAM',
|
|
29
|
+
Botswana: 'BWP',
|
|
30
|
+
'Bouvet Island': 'NOK',
|
|
31
|
+
Brazil: 'BRL',
|
|
32
|
+
'British Indian Ocean Territory': 'USD',
|
|
33
|
+
Brunei: 'BND',
|
|
34
|
+
Bulgaria: 'BGN',
|
|
35
|
+
'Burkina Faso': 'XOF',
|
|
36
|
+
Burundi: 'BIF',
|
|
37
|
+
Cambodia: 'KHR',
|
|
38
|
+
Cameroon: 'XAF',
|
|
39
|
+
Canada: 'CAD',
|
|
40
|
+
'Cape Verde': 'CVE',
|
|
41
|
+
'Cayman Islands': 'KYD',
|
|
42
|
+
'Central African Republic': 'XAF',
|
|
43
|
+
Chad: 'XAF',
|
|
44
|
+
Chile: 'CLP',
|
|
45
|
+
China: 'CNY',
|
|
46
|
+
'Christmas Island': 'AUD',
|
|
47
|
+
'Cocos (Keeling) Islands': 'AUD',
|
|
48
|
+
Colombia: 'COP',
|
|
49
|
+
Comoros: 'KMF',
|
|
50
|
+
Congo: 'XAF',
|
|
51
|
+
'Cook Islands': 'NZD',
|
|
52
|
+
'Costa Rica': 'CRC',
|
|
53
|
+
Croatia: 'HRK',
|
|
54
|
+
Cuba: 'CUP',
|
|
55
|
+
Cyprus: 'EUR',
|
|
56
|
+
'Czech Republic': 'CZK',
|
|
57
|
+
Denmark: 'DKK',
|
|
58
|
+
Djibouti: 'DJF',
|
|
59
|
+
Dominica: 'XCD',
|
|
60
|
+
'Dominican Republic': 'DOP',
|
|
61
|
+
'East Timor': 'USD',
|
|
62
|
+
Ecuador: 'ECS',
|
|
63
|
+
Egypt: 'EGP',
|
|
64
|
+
'El Salvador': 'SVC',
|
|
65
|
+
England: 'GBP',
|
|
66
|
+
'Equatorial Guinea': 'XAF',
|
|
67
|
+
Eritrea: 'ERN',
|
|
68
|
+
Estonia: 'EUR',
|
|
69
|
+
Ethiopia: 'ETB',
|
|
70
|
+
'Falkland Islands': 'FKP',
|
|
71
|
+
'Faroe Islands': 'DKK',
|
|
72
|
+
'Fiji Islands': 'FJD',
|
|
73
|
+
Finland: 'EUR',
|
|
74
|
+
France: 'EUR',
|
|
75
|
+
'French Guiana': 'EUR',
|
|
76
|
+
'French Polynesia': 'XPF',
|
|
77
|
+
'French Southern territories': 'EUR',
|
|
78
|
+
Gabon: 'XAF',
|
|
79
|
+
Gambia: 'GMD',
|
|
80
|
+
Georgia: 'GEL',
|
|
81
|
+
Germany: 'EUR',
|
|
82
|
+
Ghana: 'GHS',
|
|
83
|
+
Gibraltar: 'GIP',
|
|
84
|
+
Greece: 'EUR',
|
|
85
|
+
Greenland: 'DKK',
|
|
86
|
+
Grenada: 'XCD',
|
|
87
|
+
Guadeloupe: 'EUR',
|
|
88
|
+
Guam: 'USD',
|
|
89
|
+
Guatemala: 'QTQ',
|
|
90
|
+
Guinea: 'GNF',
|
|
91
|
+
'Guinea-Bissau': 'CFA',
|
|
92
|
+
Guyana: 'GYD',
|
|
93
|
+
Haiti: 'HTG',
|
|
94
|
+
'Heard Island and McDonald Islands': 'AUD',
|
|
95
|
+
'Holy See (Vatican City State)': 'EUR',
|
|
96
|
+
Honduras: 'HNL',
|
|
97
|
+
'Hong Kong': 'HKD',
|
|
98
|
+
Hungary: 'HUF',
|
|
99
|
+
Iceland: 'ISK',
|
|
100
|
+
India: 'INR',
|
|
101
|
+
Indonesia: 'IDR',
|
|
102
|
+
Iran: 'IRR',
|
|
103
|
+
Iraq: 'IQD',
|
|
104
|
+
Ireland: 'EUR',
|
|
105
|
+
Israel: 'ILS',
|
|
106
|
+
Italy: 'EUR',
|
|
107
|
+
'Ivory Coast': 'XOF',
|
|
108
|
+
Jamaica: 'JMD',
|
|
109
|
+
Japan: 'JPY',
|
|
110
|
+
Jordan: 'JOD',
|
|
111
|
+
Kazakhstan: 'KZT',
|
|
112
|
+
Kenya: 'KES',
|
|
113
|
+
Kiribati: 'AUD',
|
|
114
|
+
Kuwait: 'KWD',
|
|
115
|
+
Kyrgyzstan: 'KGS',
|
|
116
|
+
Laos: 'LAK',
|
|
117
|
+
Latvia: 'LVL',
|
|
118
|
+
Lebanon: 'LBP',
|
|
119
|
+
Lesotho: 'LSL',
|
|
120
|
+
Liberia: 'LRD',
|
|
121
|
+
'Libyan Arab Jamahiriya': 'LYD',
|
|
122
|
+
Liechtenstein: 'CHF',
|
|
123
|
+
Lithuania: 'LTL',
|
|
124
|
+
Luxembourg: 'EUR',
|
|
125
|
+
Macao: 'MOP',
|
|
126
|
+
'North Macedonia': 'MKD',
|
|
127
|
+
Madagascar: 'MGF',
|
|
128
|
+
Malawi: 'MWK',
|
|
129
|
+
Malaysia: 'MYR',
|
|
130
|
+
Maldives: 'MVR',
|
|
131
|
+
Mali: 'XOF',
|
|
132
|
+
Malta: 'EUR',
|
|
133
|
+
'Marshall Islands': 'USD',
|
|
134
|
+
Martinique: 'EUR',
|
|
135
|
+
Mauritania: 'MRO',
|
|
136
|
+
Mauritius: 'MUR',
|
|
137
|
+
Mayotte: 'EUR',
|
|
138
|
+
Mexico: 'MXN',
|
|
139
|
+
'Micronesia, Federated States of': 'USD',
|
|
140
|
+
Moldova: 'MDL',
|
|
141
|
+
Monaco: 'EUR',
|
|
142
|
+
Mongolia: 'MNT',
|
|
143
|
+
Montserrat: 'XCD',
|
|
144
|
+
Morocco: 'MAD',
|
|
145
|
+
Mozambique: 'MZN',
|
|
146
|
+
Myanmar: 'MMR',
|
|
147
|
+
Namibia: 'NAD',
|
|
148
|
+
Nauru: 'AUD',
|
|
149
|
+
Nepal: 'NPR',
|
|
150
|
+
Netherlands: 'EUR',
|
|
151
|
+
'Netherlands Antilles': 'ANG',
|
|
152
|
+
'New Caledonia': 'XPF',
|
|
153
|
+
'New Zealand': 'NZD',
|
|
154
|
+
Nicaragua: 'NIO',
|
|
155
|
+
Niger: 'XOF',
|
|
156
|
+
Nigeria: 'NGN',
|
|
157
|
+
Niue: 'NZD',
|
|
158
|
+
'Norfolk Island': 'AUD',
|
|
159
|
+
'North Korea': 'KPW',
|
|
160
|
+
'Northern Ireland': 'GBP',
|
|
161
|
+
'Northern Mariana Islands': 'USD',
|
|
162
|
+
Norway: 'NOK',
|
|
163
|
+
Oman: 'OMR',
|
|
164
|
+
Pakistan: 'PKR',
|
|
165
|
+
Palau: 'USD',
|
|
166
|
+
Palestine: null,
|
|
167
|
+
Panama: 'PAB',
|
|
168
|
+
'Papua New Guinea': 'PGK',
|
|
169
|
+
Paraguay: 'PYG',
|
|
170
|
+
Peru: 'PEN',
|
|
171
|
+
Philippines: 'PHP',
|
|
172
|
+
Pitcairn: 'NZD',
|
|
173
|
+
Poland: 'PLN',
|
|
174
|
+
Portugal: 'EUR',
|
|
175
|
+
'Puerto Rico': 'USD',
|
|
176
|
+
Qatar: 'QAR',
|
|
177
|
+
Reunion: 'EUR',
|
|
178
|
+
Romania: 'RON',
|
|
179
|
+
'Russian Federation': 'RUB',
|
|
180
|
+
Rwanda: 'RWF',
|
|
181
|
+
'Saint Helena': 'SHP',
|
|
182
|
+
'Saint Kitts and Nevis': 'XCD',
|
|
183
|
+
'Saint Lucia': 'XCD',
|
|
184
|
+
'Saint Pierre and Miquelon': 'EUR',
|
|
185
|
+
'Saint Vincent and the Grenadines': 'XCD',
|
|
186
|
+
Samoa: 'WST',
|
|
187
|
+
'San Marino': 'EUR',
|
|
188
|
+
'Sao Tome and Principe': 'STD',
|
|
189
|
+
'Saudi Arabia': 'SAR',
|
|
190
|
+
Scotland: 'GBP',
|
|
191
|
+
Senegal: 'XOF',
|
|
192
|
+
Serbia: 'RSD',
|
|
193
|
+
Seychelles: 'SCR',
|
|
194
|
+
'Sierra Leone': 'SLL',
|
|
195
|
+
Singapore: 'SGD',
|
|
196
|
+
Slovakia: 'EUR',
|
|
197
|
+
Slovenia: 'EUR',
|
|
198
|
+
'Solomon Islands': 'SBD',
|
|
199
|
+
Somalia: 'SOS',
|
|
200
|
+
'South Africa': 'ZAR',
|
|
201
|
+
'South Georgia and the South Sandwich Islands': 'GBP',
|
|
202
|
+
'South Korea': 'KRW',
|
|
203
|
+
'South Sudan': 'SSP',
|
|
204
|
+
Spain: 'EUR',
|
|
205
|
+
'Sri Lanka': 'LKR',
|
|
206
|
+
Sudan: 'SDG',
|
|
207
|
+
Suriname: 'SRD',
|
|
208
|
+
'Svalbard and Jan Mayen': 'NOK',
|
|
209
|
+
Swaziland: 'SZL',
|
|
210
|
+
Sweden: 'SEK',
|
|
211
|
+
Switzerland: 'CHF',
|
|
212
|
+
Syria: 'SYP',
|
|
213
|
+
Tajikistan: 'TJS',
|
|
214
|
+
Tanzania: 'TZS',
|
|
215
|
+
Thailand: 'THB',
|
|
216
|
+
'The Democratic Republic of Congo': 'CDF',
|
|
217
|
+
Togo: 'XOF',
|
|
218
|
+
Tokelau: 'NZD',
|
|
219
|
+
Tonga: 'TOP',
|
|
220
|
+
'Trinidad and Tobago': 'TTD',
|
|
221
|
+
Tunisia: 'TND',
|
|
222
|
+
Turkey: 'TRY',
|
|
223
|
+
Turkmenistan: 'TMT',
|
|
224
|
+
'Turks and Caicos Islands': 'USD',
|
|
225
|
+
Tuvalu: 'AUD',
|
|
226
|
+
Uganda: 'UGX',
|
|
227
|
+
Ukraine: 'UAH',
|
|
228
|
+
'United Arab Emirates': 'AED',
|
|
229
|
+
'United Kingdom': 'GBP',
|
|
230
|
+
'United States': 'USD',
|
|
231
|
+
'United States Minor Outlying Islands': 'USD',
|
|
232
|
+
Uruguay: 'UYU',
|
|
233
|
+
Uzbekistan: 'UZS',
|
|
234
|
+
Vanuatu: 'VUV',
|
|
235
|
+
Venezuela: 'VEF',
|
|
236
|
+
Vietnam: 'VND',
|
|
237
|
+
'Virgin Islands, British': 'USD',
|
|
238
|
+
'Virgin Islands, U.S.': 'USD',
|
|
239
|
+
Wales: 'GBP',
|
|
240
|
+
'Wallis and Futuna': 'XPF',
|
|
241
|
+
'Western Sahara': 'MAD',
|
|
242
|
+
Yemen: 'YER',
|
|
243
|
+
Zambia: 'ZMW',
|
|
244
|
+
Zimbabwe: 'ZWD',
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export default currencyCodes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { countryCodes, currencyCodes } from './countries'
|
|
2
|
+
|
|
3
|
+
export const convert = async (
|
|
4
|
+
value: number,
|
|
5
|
+
from: string = 'ETH',
|
|
6
|
+
countryCode?: string
|
|
7
|
+
): Promise<number> => {
|
|
8
|
+
const country = countryCodes[countryCode || 'US']
|
|
9
|
+
if (!country) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`Unable to find country name for country code: ${countryCode}.`
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const to = currencyCodes[country]
|
|
16
|
+
if (!to) {
|
|
17
|
+
throw new Error(`Unable to find currency code for country: ${country}.`)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const url = `https://min-api.cryptocompare.com/data/price?fsym=${from}&tsyms=${from},${to}`
|
|
21
|
+
const response = await fetch(url)
|
|
22
|
+
const data = await response.json()
|
|
23
|
+
|
|
24
|
+
const convertedValue =
|
|
25
|
+
Math.round((value / (1 / data[to]) + Number.EPSILON) * 100) / 100
|
|
26
|
+
|
|
27
|
+
return convertedValue
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type HttpErrorOptions } from '../../types'
|
|
2
|
+
|
|
3
|
+
class HttpError extends Error {
|
|
4
|
+
constructor({ message, status, statusText }: HttpErrorOptions) {
|
|
5
|
+
super(`${status} - ${statusText}: ${message}`)
|
|
6
|
+
|
|
7
|
+
// Set the prototype explicitly.
|
|
8
|
+
Object.setPrototypeOf(this, HttpError.prototype)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default HttpError
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as HttpError } from './http-error'
|
|
2
|
+
export { default as InvalidApiKeyError } from './invalid-api-key-error'
|
|
3
|
+
export { default as InvalidChainIdError } from './invalid-chain-id-error'
|
|
4
|
+
export { default as InvalidGatewayConfigError } from './invalid-gateway-config-error'
|
|
5
|
+
export { default as MissingOptionError } from './missing-option-error'
|
|
6
|
+
export { default as MpcSigningError } from './mpc-signing-error'
|
|
7
|
+
export { default as NoAddressError } from './no-address-error'
|
|
8
|
+
export {
|
|
9
|
+
default as ProviderRpcError,
|
|
10
|
+
RpcErrorCodes,
|
|
11
|
+
} from './provider-rpc-error'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class InvalidApiKeyError extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super('[Portal] A valid Portal Client API Key was not provided.')
|
|
4
|
+
|
|
5
|
+
// Set the prototype explicitly.
|
|
6
|
+
Object.setPrototypeOf(this, InvalidApiKeyError.prototype)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default InvalidApiKeyError
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class InvalidChainIdError extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super('[Portal] A valid Ethereum Chain ID was not provided.')
|
|
4
|
+
|
|
5
|
+
// Set the prototype explicitly.
|
|
6
|
+
Object.setPrototypeOf(this, InvalidChainIdError.prototype)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default InvalidChainIdError
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class InvalidGatewayConfigError extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super('[Portal] A valid Gateway configuration was not provided.')
|
|
4
|
+
|
|
5
|
+
// Set the prototype explicitly.
|
|
6
|
+
Object.setPrototypeOf(this, InvalidGatewayConfigError.prototype)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default InvalidGatewayConfigError
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type MissingOptionErrorOptions } from '../../types'
|
|
2
|
+
|
|
3
|
+
class MissingOptionError extends Error {
|
|
4
|
+
constructor({ className, option }: MissingOptionErrorOptions) {
|
|
5
|
+
super(
|
|
6
|
+
`[Portal] Instance option '${option}' is required when instantiating ${className}.`,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// Set the prototype explicitly.
|
|
10
|
+
Object.setPrototypeOf(this, MissingOptionError.prototype)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default MissingOptionError
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class MpcSigningError extends Error {
|
|
2
|
+
constructor(message: string) {
|
|
3
|
+
super(`[Portal] An error occurred in the MPC signing process: ${message}`)
|
|
4
|
+
|
|
5
|
+
// Set the prototype explicitly.
|
|
6
|
+
Object.setPrototypeOf(this, MpcSigningError.prototype)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default MpcSigningError
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RpcErrorDefinition,
|
|
3
|
+
RpcErrorOptions,
|
|
4
|
+
ValidRpcErrorCodes,
|
|
5
|
+
} from '../../types'
|
|
6
|
+
|
|
7
|
+
export enum RpcErrorCodes {
|
|
8
|
+
UserRejectedRequest = 4001,
|
|
9
|
+
Unauthorized = 4100,
|
|
10
|
+
UnsupportedMethod = 4200,
|
|
11
|
+
Disconnected = 4900,
|
|
12
|
+
ChainDisconnected = 4901,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const providerErrors = {
|
|
16
|
+
4001: {
|
|
17
|
+
name: 'User Rejected Request',
|
|
18
|
+
description: 'The user rejected the request.',
|
|
19
|
+
},
|
|
20
|
+
4100: {
|
|
21
|
+
name: 'Unauthorized',
|
|
22
|
+
description:
|
|
23
|
+
'The requested method and/or account has not been authorized by the user.',
|
|
24
|
+
},
|
|
25
|
+
4200: {
|
|
26
|
+
name: 'Unsupported Method',
|
|
27
|
+
description: 'The Provider does not support the requested method.',
|
|
28
|
+
},
|
|
29
|
+
4900: {
|
|
30
|
+
name: 'Disconnected',
|
|
31
|
+
description: 'The Provider is disconnected from all chains.',
|
|
32
|
+
},
|
|
33
|
+
4901: {
|
|
34
|
+
name: 'Chain Disconnected',
|
|
35
|
+
description: 'The Provider is not connected to the requested chain.',
|
|
36
|
+
},
|
|
37
|
+
} as Record<ValidRpcErrorCodes, RpcErrorDefinition>
|
|
38
|
+
|
|
39
|
+
class ProviderRpcError extends Error {
|
|
40
|
+
public code: ValidRpcErrorCodes
|
|
41
|
+
public definition?: RpcErrorDefinition
|
|
42
|
+
public data?: unknown
|
|
43
|
+
|
|
44
|
+
constructor({ code, data }: RpcErrorOptions) {
|
|
45
|
+
const log = console
|
|
46
|
+
const definition = providerErrors[code]
|
|
47
|
+
|
|
48
|
+
if (!definition) {
|
|
49
|
+
log.warn(
|
|
50
|
+
`[Portal] ProviderRpcError instantiated with unknown error code ${code}. Attempting to continue with limited context.`,
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const message = definition
|
|
55
|
+
? `${definition.name} - ${definition.description}`
|
|
56
|
+
: ''
|
|
57
|
+
|
|
58
|
+
super(`[Portal] RPC Error: ${code} ${message}`)
|
|
59
|
+
|
|
60
|
+
// Set the prototype explicitly.
|
|
61
|
+
Object.setPrototypeOf(this, ProviderRpcError.prototype)
|
|
62
|
+
|
|
63
|
+
this.code = code
|
|
64
|
+
this.data = data
|
|
65
|
+
this.definition = definition
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default ProviderRpcError
|