@portal-hq/utils 0.2.11 → 0.2.12
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 +247 -0
- package/lib/commonjs/currency/countries/index.js +10 -0
- package/lib/commonjs/currency/index.js +29 -0
- package/lib/commonjs/definitions/index.js +33 -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/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 +93 -0
- package/lib/commonjs/http-request/index.js +72 -0
- package/lib/commonjs/index.js +28 -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 +245 -0
- package/lib/esm/currency/countries/index.js +2 -0
- package/lib/esm/currency/index.js +25 -0
- package/lib/esm/definitions/index.js +28 -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/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 +89 -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 +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RpcErrorCodes = void 0;
|
|
4
|
+
var RpcErrorCodes;
|
|
5
|
+
(function (RpcErrorCodes) {
|
|
6
|
+
RpcErrorCodes[RpcErrorCodes["UserRejectedRequest"] = 4001] = "UserRejectedRequest";
|
|
7
|
+
RpcErrorCodes[RpcErrorCodes["Unauthorized"] = 4100] = "Unauthorized";
|
|
8
|
+
RpcErrorCodes[RpcErrorCodes["UnsupportedMethod"] = 4200] = "UnsupportedMethod";
|
|
9
|
+
RpcErrorCodes[RpcErrorCodes["Disconnected"] = 4900] = "Disconnected";
|
|
10
|
+
RpcErrorCodes[RpcErrorCodes["ChainDisconnected"] = 4901] = "ChainDisconnected";
|
|
11
|
+
})(RpcErrorCodes = exports.RpcErrorCodes || (exports.RpcErrorCodes = {}));
|
|
12
|
+
const providerErrors = {
|
|
13
|
+
4001: {
|
|
14
|
+
name: 'User Rejected Request',
|
|
15
|
+
description: 'The user rejected the request.',
|
|
16
|
+
},
|
|
17
|
+
4100: {
|
|
18
|
+
name: 'Unauthorized',
|
|
19
|
+
description: 'The requested method and/or account has not been authorized by the user.',
|
|
20
|
+
},
|
|
21
|
+
4200: {
|
|
22
|
+
name: 'Unsupported Method',
|
|
23
|
+
description: 'The Provider does not support the requested method.',
|
|
24
|
+
},
|
|
25
|
+
4900: {
|
|
26
|
+
name: 'Disconnected',
|
|
27
|
+
description: 'The Provider is disconnected from all chains.',
|
|
28
|
+
},
|
|
29
|
+
4901: {
|
|
30
|
+
name: 'Chain Disconnected',
|
|
31
|
+
description: 'The Provider is not connected to the requested chain.',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
class ProviderRpcError extends Error {
|
|
35
|
+
constructor({ code, data }) {
|
|
36
|
+
const log = console;
|
|
37
|
+
const definition = providerErrors[code];
|
|
38
|
+
if (!definition) {
|
|
39
|
+
log.warn(`[Portal] ProviderRpcError instantiated with unknown error code ${code}. Attempting to continue with limited context.`);
|
|
40
|
+
}
|
|
41
|
+
const message = definition
|
|
42
|
+
? `${definition.name} - ${definition.description}`
|
|
43
|
+
: '';
|
|
44
|
+
super(`[Portal] RPC Error: ${code} ${message}`);
|
|
45
|
+
// Set the prototype explicitly.
|
|
46
|
+
Object.setPrototypeOf(this, ProviderRpcError.prototype);
|
|
47
|
+
this.code = code;
|
|
48
|
+
this.data = data;
|
|
49
|
+
this.definition = definition;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.default = ProviderRpcError;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.parseRequest = void 0;
|
|
13
|
+
const currency_1 = require("../currency");
|
|
14
|
+
const hexStringToString = (hexInput) => {
|
|
15
|
+
// Get the proper hex string
|
|
16
|
+
const byteArray = Array.from(hexStringToByteArray(hexInput.replace('0x', '')));
|
|
17
|
+
// Create an array of characters
|
|
18
|
+
const stringArray = byteArray.reduce((acc, charCode) => {
|
|
19
|
+
// Add the character matching the charCode
|
|
20
|
+
acc.push(String.fromCharCode(charCode));
|
|
21
|
+
// Return the accumulator
|
|
22
|
+
return acc;
|
|
23
|
+
}, []);
|
|
24
|
+
// Join the array of characters
|
|
25
|
+
const string = stringArray.join('');
|
|
26
|
+
// Return the final string
|
|
27
|
+
return string;
|
|
28
|
+
};
|
|
29
|
+
const hexStringToByteArray = (hexString) => {
|
|
30
|
+
// Verify the length of the string
|
|
31
|
+
if (hexString.length % 2 !== 0) {
|
|
32
|
+
throw Error('[Portal] hexStringToByteArray() detected invalid input lenth for hexString.');
|
|
33
|
+
}
|
|
34
|
+
// Get the total bytes
|
|
35
|
+
const totalBytes = hexString.length / 2;
|
|
36
|
+
// Initialize a Uint8Array with a length matching totalBytes
|
|
37
|
+
const byteArray = new Uint8Array(totalBytes);
|
|
38
|
+
// Loop of the resulting array
|
|
39
|
+
for (let i = 0; i < totalBytes; i++) {
|
|
40
|
+
// Get the byte at the current index
|
|
41
|
+
const substring = hexString.substring(i * 2, i * 2 + 2).toLowerCase();
|
|
42
|
+
// Get the integer matching the current byte and push to the array
|
|
43
|
+
byteArray[i] = parseInt(substring, 16);
|
|
44
|
+
}
|
|
45
|
+
// Return a byte array
|
|
46
|
+
return byteArray;
|
|
47
|
+
};
|
|
48
|
+
const hexStringToNumber = (hexBalance) => {
|
|
49
|
+
const balanceNumber = Number(hexBalance);
|
|
50
|
+
console.log(`balanceNumber`, balanceNumber);
|
|
51
|
+
const balance = Math.round((balanceNumber / 1e18) * 1000000) / 1000000;
|
|
52
|
+
return balance;
|
|
53
|
+
};
|
|
54
|
+
const parseRequest = (method, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
let requestData;
|
|
56
|
+
console.log(`Request: `, JSON.stringify({ method, params }));
|
|
57
|
+
const txParam0 = Array.isArray(params) ? params[0] : params;
|
|
58
|
+
switch (method) {
|
|
59
|
+
case 'eth_sendTransaction':
|
|
60
|
+
case 'eth_signTransaction':
|
|
61
|
+
const payload = txParam0;
|
|
62
|
+
const value = hexStringToNumber(payload.value);
|
|
63
|
+
requestData = {
|
|
64
|
+
data: payload.data,
|
|
65
|
+
from: payload.from,
|
|
66
|
+
to: payload.to,
|
|
67
|
+
value,
|
|
68
|
+
valueConverted: yield (0, currency_1.convert)(value),
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
method,
|
|
72
|
+
data: requestData,
|
|
73
|
+
};
|
|
74
|
+
case 'eth_sign':
|
|
75
|
+
case 'personal_sign':
|
|
76
|
+
requestData = {
|
|
77
|
+
message: hexStringToString(txParam0),
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
method,
|
|
81
|
+
data: requestData,
|
|
82
|
+
};
|
|
83
|
+
default:
|
|
84
|
+
return {
|
|
85
|
+
method,
|
|
86
|
+
data: {
|
|
87
|
+
message: 'NO_DATA_PROVIDED',
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
exports.parseRequest = parseRequest;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const errors_1 = require("../errors");
|
|
4
|
+
class HttpRequest {
|
|
5
|
+
constructor({ body = {}, headers = {}, method, url }) {
|
|
6
|
+
this.body = body;
|
|
7
|
+
this.headers = headers;
|
|
8
|
+
this.method = method;
|
|
9
|
+
this.url = url;
|
|
10
|
+
this.request = new XMLHttpRequest();
|
|
11
|
+
this.request.open(this.method, this.url, true);
|
|
12
|
+
}
|
|
13
|
+
send() {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
// Sets headers on the request
|
|
16
|
+
this.prepareRequest();
|
|
17
|
+
// Sends the request with a formatted request body
|
|
18
|
+
const body = this.prepareBody();
|
|
19
|
+
this.request.send(body);
|
|
20
|
+
// Adds an event listener for when the request state changes
|
|
21
|
+
this.request.onreadystatechange = () => {
|
|
22
|
+
if (this.request.readyState === 4) {
|
|
23
|
+
// readyState 4 means the request has completed
|
|
24
|
+
if (this.request.status !== 200) {
|
|
25
|
+
// If we didn't get an 'OK' status, error out
|
|
26
|
+
reject(new errors_1.HttpError({
|
|
27
|
+
message: this.request.responseText,
|
|
28
|
+
status: this.request.status,
|
|
29
|
+
statusText: this.request.statusText,
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Otherwise, resolve a parsed response object
|
|
34
|
+
resolve(this.buildResponse());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
buildResponse() {
|
|
41
|
+
try {
|
|
42
|
+
// Try parsing the response body into a JSON object
|
|
43
|
+
const response = JSON.parse(this.request.response);
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
catch (_a) {
|
|
47
|
+
// If JSON parsing doesn't work, just return the response body however it came back
|
|
48
|
+
return this.request.response;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
prepareBody() {
|
|
52
|
+
if (this.headers['Content-Type'] === 'application/json') {
|
|
53
|
+
// Stringify if we're declaring this request to be a JSON request
|
|
54
|
+
return JSON.stringify(this.body);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// Otherwise, build a serialized string
|
|
58
|
+
const params = [];
|
|
59
|
+
for (const [key, value] of Object.entries(this.body)) {
|
|
60
|
+
params.push(`${key}=${value}`);
|
|
61
|
+
}
|
|
62
|
+
return params.join('&');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
prepareRequest() {
|
|
66
|
+
// Add all of the defined headers to the request
|
|
67
|
+
for (const [key, value] of Object.entries(this.headers)) {
|
|
68
|
+
this.request.setRequestHeader(key, value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.default = HttpRequest;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HttpRequester = exports.HttpRequest = exports.parseRequest = exports.RpcErrorCodes = exports.ProviderRpcError = exports.NoAddressError = exports.MpcSigningError = exports.MissingOptionError = exports.InvalidGatewayConfigError = exports.InvalidChainIdError = exports.InvalidApiKeyError = exports.HttpError = exports.Storage = exports.PortalApi = exports.KeychainAdapter = exports.convert = void 0;
|
|
7
|
+
var currency_1 = require("./currency");
|
|
8
|
+
Object.defineProperty(exports, "convert", { enumerable: true, get: function () { return currency_1.convert; } });
|
|
9
|
+
var definitions_1 = require("./definitions");
|
|
10
|
+
Object.defineProperty(exports, "KeychainAdapter", { enumerable: true, get: function () { return definitions_1.KeychainAdapter; } });
|
|
11
|
+
Object.defineProperty(exports, "PortalApi", { enumerable: true, get: function () { return definitions_1.PortalApi; } });
|
|
12
|
+
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return definitions_1.Storage; } });
|
|
13
|
+
var errors_1 = require("./errors");
|
|
14
|
+
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return errors_1.HttpError; } });
|
|
15
|
+
Object.defineProperty(exports, "InvalidApiKeyError", { enumerable: true, get: function () { return errors_1.InvalidApiKeyError; } });
|
|
16
|
+
Object.defineProperty(exports, "InvalidChainIdError", { enumerable: true, get: function () { return errors_1.InvalidChainIdError; } });
|
|
17
|
+
Object.defineProperty(exports, "InvalidGatewayConfigError", { enumerable: true, get: function () { return errors_1.InvalidGatewayConfigError; } });
|
|
18
|
+
Object.defineProperty(exports, "MissingOptionError", { enumerable: true, get: function () { return errors_1.MissingOptionError; } });
|
|
19
|
+
Object.defineProperty(exports, "MpcSigningError", { enumerable: true, get: function () { return errors_1.MpcSigningError; } });
|
|
20
|
+
Object.defineProperty(exports, "NoAddressError", { enumerable: true, get: function () { return errors_1.NoAddressError; } });
|
|
21
|
+
Object.defineProperty(exports, "ProviderRpcError", { enumerable: true, get: function () { return errors_1.ProviderRpcError; } });
|
|
22
|
+
Object.defineProperty(exports, "RpcErrorCodes", { enumerable: true, get: function () { return errors_1.RpcErrorCodes; } });
|
|
23
|
+
var eth_requests_1 = require("./eth-requests");
|
|
24
|
+
Object.defineProperty(exports, "parseRequest", { enumerable: true, get: function () { return eth_requests_1.parseRequest; } });
|
|
25
|
+
var http_request_1 = require("./http-request");
|
|
26
|
+
Object.defineProperty(exports, "HttpRequest", { enumerable: true, get: function () { return __importDefault(http_request_1).default; } });
|
|
27
|
+
var requesters_1 = require("./requesters");
|
|
28
|
+
Object.defineProperty(exports, "HttpRequester", { enumerable: true, get: function () { return requesters_1.HttpRequester; } });
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const index_1 = require("../index");
|
|
13
|
+
class HttpRequester {
|
|
14
|
+
constructor({ baseUrl }) {
|
|
15
|
+
this.baseUrl = baseUrl.startsWith('https://')
|
|
16
|
+
? baseUrl
|
|
17
|
+
: `https://${baseUrl}`;
|
|
18
|
+
}
|
|
19
|
+
get(path, options) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const requestOptions = {
|
|
22
|
+
method: 'GET',
|
|
23
|
+
url: `${this.baseUrl}${path}`,
|
|
24
|
+
};
|
|
25
|
+
if (options && options.headers) {
|
|
26
|
+
requestOptions.headers = this.buildHeaders(options.headers);
|
|
27
|
+
}
|
|
28
|
+
const request = new index_1.HttpRequest(requestOptions);
|
|
29
|
+
const response = (yield request.send());
|
|
30
|
+
return response;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
post(path, options) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const requestOptions = {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
url: `${this.baseUrl}${path}`,
|
|
38
|
+
};
|
|
39
|
+
requestOptions.headers = this.buildHeaders(options && options.headers ? options.headers : {});
|
|
40
|
+
if (options && options.body) {
|
|
41
|
+
requestOptions.body = options.body;
|
|
42
|
+
}
|
|
43
|
+
const request = new index_1.HttpRequest(requestOptions);
|
|
44
|
+
const response = (yield request.send());
|
|
45
|
+
return response;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
buildHeaders(headers) {
|
|
49
|
+
return Object.assign({ 'Content-Type': 'application/json' }, headers);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.default = HttpRequester;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HttpRequester = void 0;
|
|
7
|
+
var http_1 = require("./http");
|
|
8
|
+
Object.defineProperty(exports, "HttpRequester", { enumerable: true, get: function () { return __importDefault(http_1).default; } });
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
const countryCodes = {
|
|
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
|
+
export default countryCodes;
|