@portal-hq/utils 1.1.2 → 1.1.3
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/errors/cloud-storage-read-error.js +10 -0
- package/lib/commonjs/errors/index.js +3 -1
- package/lib/commonjs/index.js +2 -1
- package/lib/esm/errors/cloud-storage-read-error.js +8 -0
- package/lib/esm/errors/index.js +1 -0
- package/lib/esm/index.js +1 -1
- package/package.json +2 -2
- package/src/definitions/index.ts +12 -4
- package/src/errors/cloud-storage-read-error.ts +10 -0
- package/src/errors/index.ts +1 -0
- package/src/index.ts +1 -0
- package/types.d.ts +35 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class CloudStorageReadError extends Error {
|
|
4
|
+
constructor() {
|
|
5
|
+
super('[Portal] Unable to read from Cloud Storage.');
|
|
6
|
+
// Set the prototype explicitly.
|
|
7
|
+
Object.setPrototypeOf(this, CloudStorageReadError.prototype);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = CloudStorageReadError;
|
|
@@ -17,7 +17,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.RpcErrorCodes = exports.ProviderRpcError = exports.NoAddressError = exports.MpcSigningError = exports.MissingOptionError = exports.InvalidGatewayConfigError = exports.InvalidChainIdError = exports.InvalidApiKeyError = exports.HttpError = void 0;
|
|
20
|
+
exports.RpcErrorCodes = exports.ProviderRpcError = exports.NoAddressError = exports.MpcSigningError = exports.MissingOptionError = exports.InvalidGatewayConfigError = exports.InvalidChainIdError = exports.InvalidApiKeyError = exports.HttpError = exports.CloudStorageReadError = void 0;
|
|
21
|
+
var cloud_storage_read_error_1 = require("./cloud-storage-read-error");
|
|
22
|
+
Object.defineProperty(exports, "CloudStorageReadError", { enumerable: true, get: function () { return __importDefault(cloud_storage_read_error_1).default; } });
|
|
21
23
|
var http_error_1 = require("./http-error");
|
|
22
24
|
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return __importDefault(http_error_1).default; } });
|
|
23
25
|
var invalid_api_key_error_1 = require("./invalid-api-key-error");
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.HttpRequester = exports.HttpRequest = exports.parseRequest = exports.numberToHexString = 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.Storage = exports.MpcStatuses = exports.KeychainAdapter = exports.convert = exports.convertCryptoToLocal = exports.convertLocalToCrypto = exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = void 0;
|
|
6
|
+
exports.HttpRequester = exports.HttpRequest = exports.parseRequest = exports.numberToHexString = 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.MpcStatuses = exports.KeychainAdapter = exports.convert = exports.convertCryptoToLocal = exports.convertLocalToCrypto = exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = void 0;
|
|
7
7
|
var chains_1 = require("./chains");
|
|
8
8
|
Object.defineProperty(exports, "chainIdToName", { enumerable: true, get: function () { return chains_1.chainIdToName; } });
|
|
9
9
|
Object.defineProperty(exports, "chainNameToId", { enumerable: true, get: function () { return chains_1.chainNameToId; } });
|
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "KeychainAdapter", { enumerable: true, get: funct
|
|
|
18
18
|
Object.defineProperty(exports, "MpcStatuses", { enumerable: true, get: function () { return definitions_1.MpcStatuses; } });
|
|
19
19
|
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return definitions_1.Storage; } });
|
|
20
20
|
var errors_1 = require("./errors");
|
|
21
|
+
Object.defineProperty(exports, "CloudStorageReadError", { enumerable: true, get: function () { return errors_1.CloudStorageReadError; } });
|
|
21
22
|
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return errors_1.HttpError; } });
|
|
22
23
|
Object.defineProperty(exports, "InvalidApiKeyError", { enumerable: true, get: function () { return errors_1.InvalidApiKeyError; } });
|
|
23
24
|
Object.defineProperty(exports, "InvalidChainIdError", { enumerable: true, get: function () { return errors_1.InvalidChainIdError; } });
|
package/lib/esm/errors/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { default as CloudStorageReadError } from './cloud-storage-read-error';
|
|
1
2
|
export { default as HttpError } from './http-error';
|
|
2
3
|
export { default as InvalidApiKeyError } from './invalid-api-key-error';
|
|
3
4
|
export { default as InvalidChainIdError } from './invalid-chain-id-error';
|
package/lib/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { chainIdToName, chainNameToId, getChainIdForName, getChainNameForId, } from './chains';
|
|
2
2
|
export { convertLocalToCrypto, convertCryptoToLocal, convert } from './currency';
|
|
3
3
|
export { KeychainAdapter, MpcStatuses, Storage, } from './definitions';
|
|
4
|
-
export { HttpError, InvalidApiKeyError, InvalidChainIdError, InvalidGatewayConfigError, MissingOptionError, MpcSigningError, NoAddressError, PortalErrorCodes, PortalErrorCodeTypes, PortalMpcError, ProviderRpcError, RpcErrorCodes, } from './errors';
|
|
4
|
+
export { CloudStorageReadError, HttpError, InvalidApiKeyError, InvalidChainIdError, InvalidGatewayConfigError, MissingOptionError, MpcSigningError, NoAddressError, PortalErrorCodes, PortalErrorCodeTypes, PortalMpcError, ProviderRpcError, RpcErrorCodes, } from './errors';
|
|
5
5
|
export { default as Events } from './events';
|
|
6
6
|
export { numberToHexString, parseRequest } from './eth-requests';
|
|
7
7
|
export { default as HttpRequest } from './http-request';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
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": "169a9045d5cfb542b037a26d0ebcc53f51eec8dd"
|
|
30
30
|
}
|
package/src/definitions/index.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { HttpRequester } from '../requesters'
|
|
2
2
|
import type {
|
|
3
3
|
Balance,
|
|
4
|
-
QuoteArgs,
|
|
5
4
|
ClientWithCustodianData,
|
|
6
5
|
Dapp,
|
|
7
6
|
DkgData,
|
|
7
|
+
NFT,
|
|
8
8
|
Network,
|
|
9
9
|
ProgressCallback,
|
|
10
|
+
QuoteArgs,
|
|
10
11
|
QuoteResponse,
|
|
12
|
+
SimulateTransactionParam,
|
|
13
|
+
SimulatedTransaction,
|
|
11
14
|
Transaction,
|
|
12
|
-
NFT,
|
|
13
15
|
} from '../../types'
|
|
14
16
|
import PortalConnect from '@portal-hq/connect'
|
|
15
17
|
|
|
@@ -47,13 +49,19 @@ export interface IPortalApi {
|
|
|
47
49
|
getNFTs(): Promise<NFT[]>
|
|
48
50
|
getTransactions(): Promise<Transaction[]>
|
|
49
51
|
getBalances(): Promise<Balance[]>
|
|
52
|
+
simulateTransaction(
|
|
53
|
+
params: SimulateTransactionParam,
|
|
54
|
+
): Promise<SimulatedTransaction>
|
|
50
55
|
getQuote(apiKey: string, args: QuoteArgs): Promise<QuoteResponse>
|
|
51
56
|
getSources(apiKey: string): Promise<Record<string, string>>
|
|
52
57
|
storedClientSigningShare(options?: {
|
|
53
58
|
recoverSigning?: boolean
|
|
54
59
|
}): Promise<void>
|
|
55
|
-
storedClientBackupShareKey(backupMethod
|
|
56
|
-
storedClientBackupShare(
|
|
60
|
+
storedClientBackupShareKey(backupMethod?: string): Promise<void>
|
|
61
|
+
storedClientBackupShare(
|
|
62
|
+
success: boolean,
|
|
63
|
+
backupMethod?: string,
|
|
64
|
+
): Promise<void>
|
|
57
65
|
identify(traits?: Record<string, any>): Promise<{ success: boolean }>
|
|
58
66
|
track(
|
|
59
67
|
event: string,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class CloudStorageReadError extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super('[Portal] Unable to read from Cloud Storage.')
|
|
4
|
+
|
|
5
|
+
// Set the prototype explicitly.
|
|
6
|
+
Object.setPrototypeOf(this, CloudStorageReadError.prototype)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default CloudStorageReadError
|
package/src/errors/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { default as CloudStorageReadError } from './cloud-storage-read-error'
|
|
1
2
|
export { default as HttpError } from './http-error'
|
|
2
3
|
export { default as InvalidApiKeyError } from './invalid-api-key-error'
|
|
3
4
|
export { default as InvalidChainIdError } from './invalid-chain-id-error'
|
package/src/index.ts
CHANGED
package/types.d.ts
CHANGED
|
@@ -225,6 +225,41 @@ export interface Transaction {
|
|
|
225
225
|
value: number
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
export interface SimulateTransactionParam {
|
|
229
|
+
to: string
|
|
230
|
+
value?: string
|
|
231
|
+
data?: string
|
|
232
|
+
gas?: string
|
|
233
|
+
gasPrice?: string
|
|
234
|
+
maxFeePerGas?: string
|
|
235
|
+
maxPriorityFeePerGas?: string
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface SimulatedTransactionChange {
|
|
239
|
+
amount?: string
|
|
240
|
+
assetType?: string
|
|
241
|
+
changeType?: string
|
|
242
|
+
contractAddress?: string
|
|
243
|
+
decimals?: number
|
|
244
|
+
from?: string
|
|
245
|
+
name?: string
|
|
246
|
+
rawAmount?: string
|
|
247
|
+
symbol?: string
|
|
248
|
+
to?: string
|
|
249
|
+
tokenId?: number
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface SimulatedTransactionError {
|
|
253
|
+
message: string
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface SimulatedTransaction {
|
|
257
|
+
changes: SimulatedTransactionChange[]
|
|
258
|
+
gasUsed?: string
|
|
259
|
+
error?: SimulatedTransactionError
|
|
260
|
+
requestError?: SimulatedTransactionError
|
|
261
|
+
}
|
|
262
|
+
|
|
228
263
|
export interface Balance {
|
|
229
264
|
contractAddress: string
|
|
230
265
|
balance: string
|