@portal-hq/utils 4.7.0 → 4.8.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.
- package/lib/commonjs/chains/index.js +5 -2
- package/lib/commonjs/config/index.js +31 -1
- package/lib/commonjs/events/index.js +17 -0
- package/lib/commonjs/index.js +4 -1
- package/lib/commonjs/version/version.json +1 -1
- package/lib/esm/chains/index.js +4 -1
- package/lib/esm/config/index.js +29 -0
- package/lib/esm/events/index.js +17 -0
- package/lib/esm/index.js +2 -2
- package/lib/esm/version/version.json +1 -1
- package/package.json +2 -2
- package/src/chains/index.ts +5 -0
- package/src/config/index.ts +39 -0
- package/src/definitions/index.ts +4 -0
- package/src/events/index.ts +18 -0
- package/src/index.ts +2 -1
- package/src/version/version.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = exports.CAIP2_CHAIN_ID_REGEX = exports.DEFAULT_CHAIN_ID_CAIP2 = exports.DEFAULT_CHAIN_ID_NUMERIC = exports.SUPPORTED_BITCOIN_P2WPKH_CHAINS = exports.FRIENDLY_CHAIN_NAME_TO_CAIP2 = exports.ALL_CHAIN_IDS = exports.BITCOIN_CHAIN_IDS = exports.SOLANA_CHAIN_IDS = exports.EVM_CHAIN_IDS = exports.NAMESPACE_TO_CURVE = exports.CHAIN_NAMESPACES = void 0;
|
|
3
|
+
exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = exports.CAIP2_CHAIN_ID_REGEX = exports.DEFAULT_CHAIN_ID_CAIP2 = exports.DEFAULT_CHAIN_ID_NUMERIC = exports.SUPPORTED_BITCOIN_P2WPKH_CHAINS = exports.FRIENDLY_CHAIN_NAME_TO_CAIP2 = exports.ALL_CHAIN_IDS = exports.BITCOIN_CHAIN_IDS = exports.TRON_CHAIN_IDS = exports.SOLANA_CHAIN_IDS = exports.EVM_CHAIN_IDS = exports.NAMESPACE_TO_CURVE = exports.CHAIN_NAMESPACES = void 0;
|
|
4
4
|
exports.CHAIN_NAMESPACES = {
|
|
5
5
|
EIP155: 'eip155',
|
|
6
6
|
SOLANA: 'solana',
|
|
@@ -34,11 +34,14 @@ exports.SOLANA_CHAIN_IDS = {
|
|
|
34
34
|
SOLANA_MAINNET: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
35
35
|
SOLANA_DEVNET: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
36
36
|
};
|
|
37
|
+
exports.TRON_CHAIN_IDS = {
|
|
38
|
+
TRON_MAINNET: 'tron:mainnet',
|
|
39
|
+
};
|
|
37
40
|
exports.BITCOIN_CHAIN_IDS = {
|
|
38
41
|
BITCOIN_P2WPKH_MAINNET: 'bip122:000000000019d6689c085ae165831e93-p2wpkh',
|
|
39
42
|
BITCOIN_P2WPKH_TESTNET: 'bip122:000000000933ea01ad0ee984209779ba-p2wpkh',
|
|
40
43
|
};
|
|
41
|
-
exports.ALL_CHAIN_IDS = Object.assign(Object.assign(Object.assign({}, exports.EVM_CHAIN_IDS), exports.SOLANA_CHAIN_IDS), exports.BITCOIN_CHAIN_IDS);
|
|
44
|
+
exports.ALL_CHAIN_IDS = Object.assign(Object.assign(Object.assign(Object.assign({}, exports.EVM_CHAIN_IDS), exports.SOLANA_CHAIN_IDS), exports.BITCOIN_CHAIN_IDS), exports.TRON_CHAIN_IDS);
|
|
42
45
|
exports.FRIENDLY_CHAIN_NAME_TO_CAIP2 = {
|
|
43
46
|
// EVM chains
|
|
44
47
|
ethereum: exports.EVM_CHAIN_IDS.ETHEREUM_MAINNET,
|
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_HOSTS = void 0;
|
|
3
|
+
exports.buildDefaultGatewayConfig = exports.SUPPORTED_CHAINS = exports.DEFAULT_HOSTS = void 0;
|
|
4
4
|
exports.DEFAULT_HOSTS = {
|
|
5
5
|
API: 'api.portalhq.io',
|
|
6
6
|
MPC: 'mpc.portalhq.io',
|
|
7
7
|
ENCLAVE_MPC: 'mpc-client.portalhq.io',
|
|
8
8
|
WEBSOCKET: 'connect.portalhq.io',
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Canonical list of chains covered by the default gateway config. Single
|
|
12
|
+
* source of truth for both `buildDefaultGatewayConfig` and its tests.
|
|
13
|
+
*/
|
|
14
|
+
exports.SUPPORTED_CHAINS = [
|
|
15
|
+
{ namespace: 'eip155', reference: '1' },
|
|
16
|
+
{ namespace: 'eip155', reference: '11155111' },
|
|
17
|
+
{ namespace: 'eip155', reference: '137' },
|
|
18
|
+
{ namespace: 'eip155', reference: '80002' },
|
|
19
|
+
{ namespace: 'eip155', reference: '8453' },
|
|
20
|
+
{ namespace: 'eip155', reference: '84532' },
|
|
21
|
+
{ namespace: 'eip155', reference: '143' },
|
|
22
|
+
{ namespace: 'eip155', reference: '10143' },
|
|
23
|
+
{ namespace: 'solana', reference: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' },
|
|
24
|
+
{ namespace: 'solana', reference: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1' },
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Builds a gateway config map for all Portal-supported chains using the given API host.
|
|
28
|
+
* Used as the default when no gatewayConfig is supplied to the Portal constructor.
|
|
29
|
+
*/
|
|
30
|
+
function buildDefaultGatewayConfig(apiHost) {
|
|
31
|
+
const host = apiHost.replace(/\/$/, '');
|
|
32
|
+
const protocol = host.startsWith('localhost') ? 'http' : 'https';
|
|
33
|
+
const base = `${protocol}://${host}/rpc/v1`;
|
|
34
|
+
return exports.SUPPORTED_CHAINS.reduce((config, { namespace, reference }) => {
|
|
35
|
+
config[`${namespace}:${reference}`] = `${base}/${namespace}/${reference}`;
|
|
36
|
+
return config;
|
|
37
|
+
}, {});
|
|
38
|
+
}
|
|
39
|
+
exports.buildDefaultGatewayConfig = buildDefaultGatewayConfig;
|
|
@@ -52,6 +52,7 @@ var Events;
|
|
|
52
52
|
Events["HypernativeScanURL"] = "Hypernative Scan URL";
|
|
53
53
|
Events["BlockaidScanEVMTx"] = "Blockaid Scan EVM Transaction";
|
|
54
54
|
Events["BlockaidScanSolanaTx"] = "Blockaid Scan Solana Transaction";
|
|
55
|
+
Events["BlockaidScanTronTx"] = "Blockaid Scan Tron Transaction";
|
|
55
56
|
Events["BlockaidScanAddress"] = "Blockaid Scan Address";
|
|
56
57
|
Events["BlockaidScanTokens"] = "Blockaid Scan Tokens";
|
|
57
58
|
Events["BlockaidScanURL"] = "Blockaid Scan URL";
|
|
@@ -72,5 +73,21 @@ var Events;
|
|
|
72
73
|
Events["NoahGetPayoutQuote"] = "Noah Get Payout Quote";
|
|
73
74
|
Events["NoahInitiatePayout"] = "Noah Initiate Payout";
|
|
74
75
|
Events["NoahGetPaymentMethods"] = "Noah Get Payment Methods";
|
|
76
|
+
Events["MeldCreateCustomer"] = "Meld Create Customer";
|
|
77
|
+
Events["MeldSearchCustomer"] = "Meld Search Customer";
|
|
78
|
+
Events["MeldGetRetailQuote"] = "Meld Get Retail Quote";
|
|
79
|
+
Events["MeldCreateRetailWidget"] = "Meld Create Retail Widget";
|
|
80
|
+
Events["MeldSearchRetailTransactions"] = "Meld Search Retail Transactions";
|
|
81
|
+
Events["MeldGetRetailTransaction"] = "Meld Get Retail Transaction";
|
|
82
|
+
Events["MeldGetRetailTransactionBySession"] = "Meld Get Retail Transaction By Session";
|
|
83
|
+
Events["MeldGetServiceProviders"] = "Meld Get Service Providers";
|
|
84
|
+
Events["MeldGetCountries"] = "Meld Get Countries";
|
|
85
|
+
Events["MeldGetFiatCurrencies"] = "Meld Get Fiat Currencies";
|
|
86
|
+
Events["MeldGetCryptoCurrencies"] = "Meld Get Crypto Currencies";
|
|
87
|
+
Events["MeldGetPaymentMethods"] = "Meld Get Payment Methods";
|
|
88
|
+
Events["MeldGetDefaults"] = "Meld Get Defaults";
|
|
89
|
+
Events["MeldGetBuyLimits"] = "Meld Get Buy Limits";
|
|
90
|
+
Events["MeldGetSellLimits"] = "Meld Get Sell Limits";
|
|
91
|
+
Events["MeldGetKycLimits"] = "Meld Get Kyc Limits";
|
|
75
92
|
})(Events || (Events = {}));
|
|
76
93
|
exports.default = Events;
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.TRACE_ID_HEADER = exports.createExecutionContext = exports.generateTraceId = exports.EvaluateTransactionOperationType = exports.HttpRequester = exports.PortalRequests = exports.HttpRequest = exports.parseRequest = exports.numberToHexString = exports.getClientPlatformVersion = exports.Events = exports.RpcErrorCodes = exports.ProviderRpcError = exports.PortalMpcError = exports.PortalErrorCodeTypes = exports.PortalErrorCodes = exports.NoAddressError = exports.MpcSigningError = exports.MissingOptionError = exports.InvalidGatewayConfigError = exports.InvalidChainIdError = exports.InvalidApiKeyError = exports.HttpError = exports.CloudStorageReadError = exports.Storage = exports.PortalRequestMethod = exports.PasswordStorage = exports.MpcStatuses = exports.KeychainAdapter = exports.convert = exports.convertCryptoToLocal = exports.convertLocalToCrypto = exports.DEFAULT_HOSTS = exports.buildDefaultGatewayConfig = exports.NAMESPACE_TO_CURVE = exports.ALL_CHAIN_IDS = exports.BITCOIN_CHAIN_IDS = exports.TRON_CHAIN_IDS = exports.SOLANA_CHAIN_IDS = exports.EVM_CHAIN_IDS = exports.DEFAULT_CHAIN_ID_CAIP2 = exports.DEFAULT_CHAIN_ID_NUMERIC = exports.CAIP2_CHAIN_ID_REGEX = exports.FRIENDLY_CHAIN_NAME_TO_CAIP2 = exports.SUPPORTED_BITCOIN_P2WPKH_CHAINS = exports.CHAIN_NAMESPACES = exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = void 0;
|
|
7
|
+
exports.sdkLogger = exports.UUID_V4_REGEX = void 0;
|
|
7
8
|
var chains_1 = require("./chains");
|
|
8
9
|
Object.defineProperty(exports, "chainIdToName", { enumerable: true, get: function () { return chains_1.chainIdToName; } });
|
|
9
10
|
Object.defineProperty(exports, "chainNameToId", { enumerable: true, get: function () { return chains_1.chainNameToId; } });
|
|
@@ -17,10 +18,12 @@ Object.defineProperty(exports, "DEFAULT_CHAIN_ID_NUMERIC", { enumerable: true, g
|
|
|
17
18
|
Object.defineProperty(exports, "DEFAULT_CHAIN_ID_CAIP2", { enumerable: true, get: function () { return chains_1.DEFAULT_CHAIN_ID_CAIP2; } });
|
|
18
19
|
Object.defineProperty(exports, "EVM_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.EVM_CHAIN_IDS; } });
|
|
19
20
|
Object.defineProperty(exports, "SOLANA_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.SOLANA_CHAIN_IDS; } });
|
|
21
|
+
Object.defineProperty(exports, "TRON_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.TRON_CHAIN_IDS; } });
|
|
20
22
|
Object.defineProperty(exports, "BITCOIN_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.BITCOIN_CHAIN_IDS; } });
|
|
21
23
|
Object.defineProperty(exports, "ALL_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.ALL_CHAIN_IDS; } });
|
|
22
24
|
Object.defineProperty(exports, "NAMESPACE_TO_CURVE", { enumerable: true, get: function () { return chains_1.NAMESPACE_TO_CURVE; } });
|
|
23
25
|
var config_1 = require("./config");
|
|
26
|
+
Object.defineProperty(exports, "buildDefaultGatewayConfig", { enumerable: true, get: function () { return config_1.buildDefaultGatewayConfig; } });
|
|
24
27
|
Object.defineProperty(exports, "DEFAULT_HOSTS", { enumerable: true, get: function () { return config_1.DEFAULT_HOSTS; } });
|
|
25
28
|
var currency_1 = require("./currency");
|
|
26
29
|
Object.defineProperty(exports, "convertLocalToCrypto", { enumerable: true, get: function () { return currency_1.convertLocalToCrypto; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "version": "4.
|
|
1
|
+
{ "version": "4.8.0" }
|
package/lib/esm/chains/index.js
CHANGED
|
@@ -31,11 +31,14 @@ export const SOLANA_CHAIN_IDS = {
|
|
|
31
31
|
SOLANA_MAINNET: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
32
32
|
SOLANA_DEVNET: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
33
33
|
};
|
|
34
|
+
export const TRON_CHAIN_IDS = {
|
|
35
|
+
TRON_MAINNET: 'tron:mainnet',
|
|
36
|
+
};
|
|
34
37
|
export const BITCOIN_CHAIN_IDS = {
|
|
35
38
|
BITCOIN_P2WPKH_MAINNET: 'bip122:000000000019d6689c085ae165831e93-p2wpkh',
|
|
36
39
|
BITCOIN_P2WPKH_TESTNET: 'bip122:000000000933ea01ad0ee984209779ba-p2wpkh',
|
|
37
40
|
};
|
|
38
|
-
export const ALL_CHAIN_IDS = Object.assign(Object.assign(Object.assign({}, EVM_CHAIN_IDS), SOLANA_CHAIN_IDS), BITCOIN_CHAIN_IDS);
|
|
41
|
+
export const ALL_CHAIN_IDS = Object.assign(Object.assign(Object.assign(Object.assign({}, EVM_CHAIN_IDS), SOLANA_CHAIN_IDS), BITCOIN_CHAIN_IDS), TRON_CHAIN_IDS);
|
|
39
42
|
export const FRIENDLY_CHAIN_NAME_TO_CAIP2 = {
|
|
40
43
|
// EVM chains
|
|
41
44
|
ethereum: EVM_CHAIN_IDS.ETHEREUM_MAINNET,
|
package/lib/esm/config/index.js
CHANGED
|
@@ -4,3 +4,32 @@ export const DEFAULT_HOSTS = {
|
|
|
4
4
|
ENCLAVE_MPC: 'mpc-client.portalhq.io',
|
|
5
5
|
WEBSOCKET: 'connect.portalhq.io',
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Canonical list of chains covered by the default gateway config. Single
|
|
9
|
+
* source of truth for both `buildDefaultGatewayConfig` and its tests.
|
|
10
|
+
*/
|
|
11
|
+
export const SUPPORTED_CHAINS = [
|
|
12
|
+
{ namespace: 'eip155', reference: '1' },
|
|
13
|
+
{ namespace: 'eip155', reference: '11155111' },
|
|
14
|
+
{ namespace: 'eip155', reference: '137' },
|
|
15
|
+
{ namespace: 'eip155', reference: '80002' },
|
|
16
|
+
{ namespace: 'eip155', reference: '8453' },
|
|
17
|
+
{ namespace: 'eip155', reference: '84532' },
|
|
18
|
+
{ namespace: 'eip155', reference: '143' },
|
|
19
|
+
{ namespace: 'eip155', reference: '10143' },
|
|
20
|
+
{ namespace: 'solana', reference: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' },
|
|
21
|
+
{ namespace: 'solana', reference: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1' },
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Builds a gateway config map for all Portal-supported chains using the given API host.
|
|
25
|
+
* Used as the default when no gatewayConfig is supplied to the Portal constructor.
|
|
26
|
+
*/
|
|
27
|
+
export function buildDefaultGatewayConfig(apiHost) {
|
|
28
|
+
const host = apiHost.replace(/\/$/, '');
|
|
29
|
+
const protocol = host.startsWith('localhost') ? 'http' : 'https';
|
|
30
|
+
const base = `${protocol}://${host}/rpc/v1`;
|
|
31
|
+
return SUPPORTED_CHAINS.reduce((config, { namespace, reference }) => {
|
|
32
|
+
config[`${namespace}:${reference}`] = `${base}/${namespace}/${reference}`;
|
|
33
|
+
return config;
|
|
34
|
+
}, {});
|
|
35
|
+
}
|
package/lib/esm/events/index.js
CHANGED
|
@@ -50,6 +50,7 @@ var Events;
|
|
|
50
50
|
Events["HypernativeScanURL"] = "Hypernative Scan URL";
|
|
51
51
|
Events["BlockaidScanEVMTx"] = "Blockaid Scan EVM Transaction";
|
|
52
52
|
Events["BlockaidScanSolanaTx"] = "Blockaid Scan Solana Transaction";
|
|
53
|
+
Events["BlockaidScanTronTx"] = "Blockaid Scan Tron Transaction";
|
|
53
54
|
Events["BlockaidScanAddress"] = "Blockaid Scan Address";
|
|
54
55
|
Events["BlockaidScanTokens"] = "Blockaid Scan Tokens";
|
|
55
56
|
Events["BlockaidScanURL"] = "Blockaid Scan URL";
|
|
@@ -70,5 +71,21 @@ var Events;
|
|
|
70
71
|
Events["NoahGetPayoutQuote"] = "Noah Get Payout Quote";
|
|
71
72
|
Events["NoahInitiatePayout"] = "Noah Initiate Payout";
|
|
72
73
|
Events["NoahGetPaymentMethods"] = "Noah Get Payment Methods";
|
|
74
|
+
Events["MeldCreateCustomer"] = "Meld Create Customer";
|
|
75
|
+
Events["MeldSearchCustomer"] = "Meld Search Customer";
|
|
76
|
+
Events["MeldGetRetailQuote"] = "Meld Get Retail Quote";
|
|
77
|
+
Events["MeldCreateRetailWidget"] = "Meld Create Retail Widget";
|
|
78
|
+
Events["MeldSearchRetailTransactions"] = "Meld Search Retail Transactions";
|
|
79
|
+
Events["MeldGetRetailTransaction"] = "Meld Get Retail Transaction";
|
|
80
|
+
Events["MeldGetRetailTransactionBySession"] = "Meld Get Retail Transaction By Session";
|
|
81
|
+
Events["MeldGetServiceProviders"] = "Meld Get Service Providers";
|
|
82
|
+
Events["MeldGetCountries"] = "Meld Get Countries";
|
|
83
|
+
Events["MeldGetFiatCurrencies"] = "Meld Get Fiat Currencies";
|
|
84
|
+
Events["MeldGetCryptoCurrencies"] = "Meld Get Crypto Currencies";
|
|
85
|
+
Events["MeldGetPaymentMethods"] = "Meld Get Payment Methods";
|
|
86
|
+
Events["MeldGetDefaults"] = "Meld Get Defaults";
|
|
87
|
+
Events["MeldGetBuyLimits"] = "Meld Get Buy Limits";
|
|
88
|
+
Events["MeldGetSellLimits"] = "Meld Get Sell Limits";
|
|
89
|
+
Events["MeldGetKycLimits"] = "Meld Get Kyc Limits";
|
|
73
90
|
})(Events || (Events = {}));
|
|
74
91
|
export default Events;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { chainIdToName, chainNameToId, getChainIdForName, getChainNameForId, CHAIN_NAMESPACES, SUPPORTED_BITCOIN_P2WPKH_CHAINS, FRIENDLY_CHAIN_NAME_TO_CAIP2, CAIP2_CHAIN_ID_REGEX, DEFAULT_CHAIN_ID_NUMERIC, DEFAULT_CHAIN_ID_CAIP2, EVM_CHAIN_IDS, SOLANA_CHAIN_IDS, BITCOIN_CHAIN_IDS, ALL_CHAIN_IDS, NAMESPACE_TO_CURVE, } from './chains';
|
|
2
|
-
export { DEFAULT_HOSTS } from './config';
|
|
1
|
+
export { chainIdToName, chainNameToId, getChainIdForName, getChainNameForId, CHAIN_NAMESPACES, SUPPORTED_BITCOIN_P2WPKH_CHAINS, FRIENDLY_CHAIN_NAME_TO_CAIP2, CAIP2_CHAIN_ID_REGEX, DEFAULT_CHAIN_ID_NUMERIC, DEFAULT_CHAIN_ID_CAIP2, EVM_CHAIN_IDS, SOLANA_CHAIN_IDS, TRON_CHAIN_IDS, BITCOIN_CHAIN_IDS, ALL_CHAIN_IDS, NAMESPACE_TO_CURVE, } from './chains';
|
|
2
|
+
export { buildDefaultGatewayConfig, DEFAULT_HOSTS } from './config';
|
|
3
3
|
export { convertLocalToCrypto, convertCryptoToLocal, convert } from './currency';
|
|
4
4
|
export { KeychainAdapter, MpcStatuses, PasswordStorage, PortalRequestMethod, Storage, } from './definitions';
|
|
5
5
|
export { CloudStorageReadError, HttpError, InvalidApiKeyError, InvalidChainIdError, InvalidGatewayConfigError, MissingOptionError, MpcSigningError, NoAddressError, PortalErrorCodes, PortalErrorCodeTypes, PortalMpcError, ProviderRpcError, RpcErrorCodes, } from './errors';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "version": "4.
|
|
1
|
+
{ "version": "4.8.0" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"main": "lib/commonjs/index",
|
|
5
5
|
"module": "lib/esm/index",
|
|
6
6
|
"source": "src/index",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"ts-jest": "^29.0.3",
|
|
27
27
|
"typescript": "^4.8.4"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "c67b5068d5245eeab6b760ee01298d88965bf386"
|
|
30
30
|
}
|
package/src/chains/index.ts
CHANGED
|
@@ -38,6 +38,10 @@ export const SOLANA_CHAIN_IDS = {
|
|
|
38
38
|
SOLANA_DEVNET: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
39
39
|
} as const
|
|
40
40
|
|
|
41
|
+
export const TRON_CHAIN_IDS = {
|
|
42
|
+
TRON_MAINNET: 'tron:mainnet',
|
|
43
|
+
} as const
|
|
44
|
+
|
|
41
45
|
export const BITCOIN_CHAIN_IDS = {
|
|
42
46
|
BITCOIN_P2WPKH_MAINNET: 'bip122:000000000019d6689c085ae165831e93-p2wpkh',
|
|
43
47
|
BITCOIN_P2WPKH_TESTNET: 'bip122:000000000933ea01ad0ee984209779ba-p2wpkh',
|
|
@@ -47,6 +51,7 @@ export const ALL_CHAIN_IDS = {
|
|
|
47
51
|
...EVM_CHAIN_IDS,
|
|
48
52
|
...SOLANA_CHAIN_IDS,
|
|
49
53
|
...BITCOIN_CHAIN_IDS,
|
|
54
|
+
...TRON_CHAIN_IDS,
|
|
50
55
|
} as const
|
|
51
56
|
|
|
52
57
|
export const FRIENDLY_CHAIN_NAME_TO_CAIP2 = {
|
package/src/config/index.ts
CHANGED
|
@@ -4,3 +4,42 @@ export const DEFAULT_HOSTS = {
|
|
|
4
4
|
ENCLAVE_MPC: 'mpc-client.portalhq.io',
|
|
5
5
|
WEBSOCKET: 'connect.portalhq.io',
|
|
6
6
|
} as const
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Canonical list of chains covered by the default gateway config. Single
|
|
10
|
+
* source of truth for both `buildDefaultGatewayConfig` and its tests.
|
|
11
|
+
*/
|
|
12
|
+
export const SUPPORTED_CHAINS: ReadonlyArray<{
|
|
13
|
+
namespace: string
|
|
14
|
+
reference: string
|
|
15
|
+
}> = [
|
|
16
|
+
{ namespace: 'eip155', reference: '1' },
|
|
17
|
+
{ namespace: 'eip155', reference: '11155111' },
|
|
18
|
+
{ namespace: 'eip155', reference: '137' },
|
|
19
|
+
{ namespace: 'eip155', reference: '80002' },
|
|
20
|
+
{ namespace: 'eip155', reference: '8453' },
|
|
21
|
+
{ namespace: 'eip155', reference: '84532' },
|
|
22
|
+
{ namespace: 'eip155', reference: '143' },
|
|
23
|
+
{ namespace: 'eip155', reference: '10143' },
|
|
24
|
+
{ namespace: 'solana', reference: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' },
|
|
25
|
+
{ namespace: 'solana', reference: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1' },
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Builds a gateway config map for all Portal-supported chains using the given API host.
|
|
30
|
+
* Used as the default when no gatewayConfig is supplied to the Portal constructor.
|
|
31
|
+
*/
|
|
32
|
+
export function buildDefaultGatewayConfig(
|
|
33
|
+
apiHost: string,
|
|
34
|
+
): Record<string, string> {
|
|
35
|
+
const host = apiHost.replace(/\/$/, '')
|
|
36
|
+
const protocol = host.startsWith('localhost') ? 'http' : 'https'
|
|
37
|
+
const base = `${protocol}://${host}/rpc/v1`
|
|
38
|
+
return SUPPORTED_CHAINS.reduce<Record<string, string>>(
|
|
39
|
+
(config, { namespace, reference }) => {
|
|
40
|
+
config[`${namespace}:${reference}`] = `${base}/${namespace}/${reference}`
|
|
41
|
+
return config
|
|
42
|
+
},
|
|
43
|
+
{},
|
|
44
|
+
)
|
|
45
|
+
}
|
package/src/definitions/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
BuildSolanaTransactionResponse,
|
|
10
10
|
FundParams,
|
|
11
11
|
FundResponse,
|
|
12
|
+
NFTAsset,
|
|
12
13
|
YieldXyzEnterRequest,
|
|
13
14
|
YieldXyzEnterYieldResponse,
|
|
14
15
|
YieldXyzExitRequest,
|
|
@@ -236,6 +237,7 @@ export interface IPortalApi {
|
|
|
236
237
|
getClientCipherText(backupSharePairId: string): Promise<string>
|
|
237
238
|
getEnabledDapps(): Promise<Dapp[]>
|
|
238
239
|
getNFTs(chainId?: string, traceId?: string): Promise<NFT[]>
|
|
240
|
+
getNftAssets(chainId: string, traceId?: string): Promise<NFTAsset[]>
|
|
239
241
|
getNetworks(): Promise<Network[]>
|
|
240
242
|
getQuote(
|
|
241
243
|
apiKey: string,
|
|
@@ -336,10 +338,12 @@ export interface IPortalApi {
|
|
|
336
338
|
buildBitcoinP2wpkhTransaction(
|
|
337
339
|
chainId: string,
|
|
338
340
|
params: { to: string; token: string; amount: string },
|
|
341
|
+
traceId?: string,
|
|
339
342
|
): Promise<BuildBitcoinP2wpkhTransactionResponse>
|
|
340
343
|
broadcastBitcoinP2wpkhTransaction(
|
|
341
344
|
chainId: string,
|
|
342
345
|
params: BroadcastParam,
|
|
346
|
+
traceId?: string,
|
|
343
347
|
): Promise<BroadcastBitcoinP2wpkhTransactionResponse>
|
|
344
348
|
rawSign?(
|
|
345
349
|
message: string,
|
package/src/events/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ enum Events {
|
|
|
53
53
|
|
|
54
54
|
BlockaidScanEVMTx = 'Blockaid Scan EVM Transaction',
|
|
55
55
|
BlockaidScanSolanaTx = 'Blockaid Scan Solana Transaction',
|
|
56
|
+
BlockaidScanTronTx = 'Blockaid Scan Tron Transaction',
|
|
56
57
|
BlockaidScanAddress = 'Blockaid Scan Address',
|
|
57
58
|
BlockaidScanTokens = 'Blockaid Scan Tokens',
|
|
58
59
|
BlockaidScanURL = 'Blockaid Scan URL',
|
|
@@ -76,6 +77,23 @@ enum Events {
|
|
|
76
77
|
NoahGetPayoutQuote = 'Noah Get Payout Quote',
|
|
77
78
|
NoahInitiatePayout = 'Noah Initiate Payout',
|
|
78
79
|
NoahGetPaymentMethods = 'Noah Get Payment Methods',
|
|
80
|
+
|
|
81
|
+
MeldCreateCustomer = 'Meld Create Customer',
|
|
82
|
+
MeldSearchCustomer = 'Meld Search Customer',
|
|
83
|
+
MeldGetRetailQuote = 'Meld Get Retail Quote',
|
|
84
|
+
MeldCreateRetailWidget = 'Meld Create Retail Widget',
|
|
85
|
+
MeldSearchRetailTransactions = 'Meld Search Retail Transactions',
|
|
86
|
+
MeldGetRetailTransaction = 'Meld Get Retail Transaction',
|
|
87
|
+
MeldGetRetailTransactionBySession = 'Meld Get Retail Transaction By Session',
|
|
88
|
+
MeldGetServiceProviders = 'Meld Get Service Providers',
|
|
89
|
+
MeldGetCountries = 'Meld Get Countries',
|
|
90
|
+
MeldGetFiatCurrencies = 'Meld Get Fiat Currencies',
|
|
91
|
+
MeldGetCryptoCurrencies = 'Meld Get Crypto Currencies',
|
|
92
|
+
MeldGetPaymentMethods = 'Meld Get Payment Methods',
|
|
93
|
+
MeldGetDefaults = 'Meld Get Defaults',
|
|
94
|
+
MeldGetBuyLimits = 'Meld Get Buy Limits',
|
|
95
|
+
MeldGetSellLimits = 'Meld Get Sell Limits',
|
|
96
|
+
MeldGetKycLimits = 'Meld Get Kyc Limits',
|
|
79
97
|
}
|
|
80
98
|
|
|
81
99
|
export default Events
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
DEFAULT_CHAIN_ID_CAIP2,
|
|
12
12
|
EVM_CHAIN_IDS,
|
|
13
13
|
SOLANA_CHAIN_IDS,
|
|
14
|
+
TRON_CHAIN_IDS,
|
|
14
15
|
BITCOIN_CHAIN_IDS,
|
|
15
16
|
ALL_CHAIN_IDS,
|
|
16
17
|
NAMESPACE_TO_CURVE,
|
|
@@ -18,7 +19,7 @@ export {
|
|
|
18
19
|
type FriendlyChainName,
|
|
19
20
|
} from './chains'
|
|
20
21
|
|
|
21
|
-
export { DEFAULT_HOSTS } from './config'
|
|
22
|
+
export { buildDefaultGatewayConfig, DEFAULT_HOSTS } from './config'
|
|
22
23
|
|
|
23
24
|
export { convertLocalToCrypto, convertCryptoToLocal, convert } from './currency'
|
|
24
25
|
|
package/src/version/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "version": "4.
|
|
1
|
+
{ "version": "4.8.0" }
|