@portal-hq/utils 0.2.7 → 0.2.8

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.
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Storage = exports.KeychainAdapter = void 0;
4
+ class KeychainAdapter {
5
+ }
6
+ exports.KeychainAdapter = KeychainAdapter;
7
+ class Storage {
8
+ }
9
+ exports.Storage = Storage;
@@ -3,9 +3,13 @@ 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.Storage = exports.KeychainAdapter = 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.convert = void 0;
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
7
  var currency_1 = require("./currency");
8
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; } });
9
13
  var errors_1 = require("./errors");
10
14
  Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return errors_1.HttpError; } });
11
15
  Object.defineProperty(exports, "InvalidApiKeyError", { enumerable: true, get: function () { return errors_1.InvalidApiKeyError; } });
@@ -22,6 +26,3 @@ var http_request_1 = require("./http-request");
22
26
  Object.defineProperty(exports, "HttpRequest", { enumerable: true, get: function () { return __importDefault(http_request_1).default; } });
23
27
  var requesters_1 = require("./requesters");
24
28
  Object.defineProperty(exports, "HttpRequester", { enumerable: true, get: function () { return requesters_1.HttpRequester; } });
25
- var types_1 = require("../types");
26
- Object.defineProperty(exports, "KeychainAdapter", { enumerable: true, get: function () { return types_1.KeychainAdapter; } });
27
- Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return types_1.Storage; } });
@@ -0,0 +1,4 @@
1
+ export class KeychainAdapter {
2
+ }
3
+ export class Storage {
4
+ }
package/lib/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { convert } from './currency';
2
+ export { KeychainAdapter, PortalApi, Storage } from './definitions';
2
3
  export { HttpError, InvalidApiKeyError, InvalidChainIdError, InvalidGatewayConfigError, MissingOptionError, MpcSigningError, NoAddressError, ProviderRpcError, RpcErrorCodes, } from './errors';
3
4
  export { parseRequest } from './eth-requests';
4
5
  export { default as HttpRequest } from './http-request';
5
6
  export { HttpRequester } from './requesters';
6
- export { KeychainAdapter, Storage, } from '../types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portal-hq/utils",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "main": "lib/commonjs/index",
5
5
  "module": "lib/esm/index",
6
6
  "source": "src/index",
@@ -0,0 +1,23 @@
1
+ import { ClientWithCustodianData, Dapp, DkgData, Network } from '../../types'
2
+
3
+ export abstract class KeychainAdapter {
4
+ deleteAddress: () => Promise<boolean>
5
+ deleteDkgResult: () => Promise<boolean>
6
+ getAddress: (isSim?: boolean) => Promise<string>
7
+ getDkgResult: (isSim?: boolean) => Promise<string>
8
+ storeAddress: (address: string, isSim?: boolean) => Promise<void>
9
+ storeDkgResult: (result: DkgData, isSim?: boolean) => Promise<void>
10
+ }
11
+
12
+ export declare class PortalApi {
13
+ getClient(): Promise<ClientWithCustodianData>
14
+ getEnabledDapps(): Promise<Dapp[]>
15
+ getNetworks(): Promise<Network[]>
16
+ }
17
+
18
+ export abstract class Storage {
19
+ public api: PortalApi
20
+
21
+ read: () => Promise<string>
22
+ write: (privateKey: string) => Promise<string>
23
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { convert } from './currency'
2
2
 
3
+ export { KeychainAdapter, PortalApi, Storage } from './definitions'
4
+
3
5
  export {
4
6
  HttpError,
5
7
  InvalidApiKeyError,
@@ -19,12 +21,16 @@ export { default as HttpRequest } from './http-request'
19
21
  export { HttpRequester } from './requesters'
20
22
 
21
23
  export {
22
- KeychainAdapter,
23
- Storage,
24
+ type ClientWithCustodianData,
25
+ type Contract,
26
+ type Dapp,
27
+ type DappImage,
28
+ type DkgData,
24
29
  type HttpOptions,
25
30
  type HttpRequesterOptions,
26
31
  type HttpRequestOptions,
27
32
  type MessageData,
33
+ type Network,
28
34
  type OutgoingRequest,
29
35
  type OutgoingRequestData,
30
36
  type SignableTransactionData,
package/types.d.ts CHANGED
@@ -4,6 +4,47 @@ export type ValidHttpRequestMethods = 'DELETE' | 'GET' | 'POST' | 'PUT'
4
4
 
5
5
  export type ValidRpcErrorCodes = 4001 | 4100 | 4200 | 4900 | 4901
6
6
 
7
+ export interface Bk {
8
+ X: string
9
+ Rank: number
10
+ }
11
+
12
+ export interface ClientWithCustodianData {
13
+ id: string
14
+ address: string
15
+ clientApiKey: string
16
+ custodian: {
17
+ id: string
18
+ name: string
19
+ }
20
+ }
21
+
22
+ export interface Contract {
23
+ id: string
24
+ contractAddress: string
25
+ clientUrl: string
26
+ network: Network
27
+ }
28
+
29
+ export interface Dapp {
30
+ id: string
31
+ contracts: Contract[]
32
+ name: string
33
+ image: DappImage
34
+ }
35
+
36
+ export interface DappImage {
37
+ id: string
38
+ filename: string
39
+ data: string
40
+ }
41
+
42
+ export interface DkgData {
43
+ share: string
44
+ pubkey: Pubkey
45
+ bks: Bk[]
46
+ }
47
+
7
48
  export interface HttpErrorOptions {
8
49
  message: string
9
50
  status: number
@@ -35,11 +76,22 @@ export interface MissingOptionErrorOptions {
35
76
  option: string
36
77
  }
37
78
 
79
+ export interface Network {
80
+ id: string
81
+ chainId: string
82
+ name: string
83
+ }
84
+
38
85
  export interface OutgoingRequest {
39
86
  method: string
40
87
  data: OutgoingRequestData
41
88
  }
42
89
 
90
+ export interface Pubkey {
91
+ X: string
92
+ Y: string
93
+ }
94
+
43
95
  export interface RequesterOptions {}
44
96
 
45
97
  export interface RpcErrorDefinition {
@@ -59,21 +111,3 @@ export interface SignableTransactionData {
59
111
  value: number
60
112
  valueConverted: number
61
113
  }
62
-
63
- // Classes
64
-
65
- export declare class KeychainAdapter {
66
- deleteAddress: () => Promise<boolean>
67
- deleteDkgResult: () => Promise<boolean>
68
- getAddress: (isSim?: boolean) => Promise<string>
69
- getDkgResult: (isSim?: boolean) => Promise<string>
70
- storeAddress: (address: string, isSim?: boolean) => Promise<void>
71
- storeDkgResult: (result: DkgData, isSim?: boolean) => Promise<void>
72
- }
73
-
74
- export declare class Storage {
75
- public api: PortalApi
76
-
77
- read(): Promise<string>
78
- write(privateKey: string): Promise<string>
79
- }