@portal-hq/utils 2.1.2 → 3.0.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.
@@ -8,17 +8,19 @@ var Events;
8
8
  Events["WalletCreated"] = "Wallet Created";
9
9
  Events["WalletRecovered"] = "Wallet Recovered";
10
10
  // API Method events
11
+ Events["GetBackupShareMetadata"] = "Get Backup Share Metadata";
12
+ Events["GetBalances"] = "Get Balances";
11
13
  Events["GetClient"] = "Get Client";
12
14
  Events["GetEnabledDapps"] = "Get Enabled Dapps";
15
+ Events["GetNFTs"] = "Get NFTs";
13
16
  Events["GetNetworks"] = "Get Networks";
14
17
  Events["GetQuote"] = "Get Quote";
18
+ Events["GetSigningSharePairs"] = "Get Signing Share Pairs";
15
19
  Events["GetSources"] = "Get Sources";
16
- Events["GetNFTs"] = "Get NFTs";
17
20
  Events["GetTransactions"] = "Get Transactions";
18
- Events["GetBalances"] = "Get Balances";
19
21
  Events["SimulateTransaction"] = "Simulate Transaction";
20
- Events["StoredClientSigningShare"] = "Stored Client Signing Share";
21
- Events["StoredClientBackupShareKey"] = "Stored Client Backup Share Key";
22
22
  Events["StoredClientBackupShare"] = "Stored Client Backup Share";
23
+ Events["StoredClientBackupShareKey"] = "Stored Client Backup Share Key";
24
+ Events["StoredClientSigningShare"] = "Stored Client Signing Share";
23
25
  })(Events || (Events = {}));
24
26
  exports.default = Events;
@@ -6,17 +6,19 @@ var Events;
6
6
  Events["WalletCreated"] = "Wallet Created";
7
7
  Events["WalletRecovered"] = "Wallet Recovered";
8
8
  // API Method events
9
+ Events["GetBackupShareMetadata"] = "Get Backup Share Metadata";
10
+ Events["GetBalances"] = "Get Balances";
9
11
  Events["GetClient"] = "Get Client";
10
12
  Events["GetEnabledDapps"] = "Get Enabled Dapps";
13
+ Events["GetNFTs"] = "Get NFTs";
11
14
  Events["GetNetworks"] = "Get Networks";
12
15
  Events["GetQuote"] = "Get Quote";
16
+ Events["GetSigningSharePairs"] = "Get Signing Share Pairs";
13
17
  Events["GetSources"] = "Get Sources";
14
- Events["GetNFTs"] = "Get NFTs";
15
18
  Events["GetTransactions"] = "Get Transactions";
16
- Events["GetBalances"] = "Get Balances";
17
19
  Events["SimulateTransaction"] = "Simulate Transaction";
18
- Events["StoredClientSigningShare"] = "Stored Client Signing Share";
19
- Events["StoredClientBackupShareKey"] = "Stored Client Backup Share Key";
20
20
  Events["StoredClientBackupShare"] = "Stored Client Backup Share";
21
+ Events["StoredClientBackupShareKey"] = "Stored Client Backup Share Key";
22
+ Events["StoredClientSigningShare"] = "Stored Client Signing Share";
21
23
  })(Events || (Events = {}));
22
24
  export default Events;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portal-hq/utils",
3
- "version": "2.1.2",
3
+ "version": "3.0.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": "17a0445191c1399577154042e09fa8759edf194f"
29
+ "gitHead": "1f49bc43f0778a40089e1d736fbb63eb952b6001"
30
30
  }
@@ -1,5 +1,6 @@
1
1
  import { HttpRequester } from '../requesters'
2
2
  import type {
3
+ BackupSharePairMetadata,
3
4
  Balance,
4
5
  ClientWithCustodianData,
5
6
  Dapp,
@@ -10,6 +11,7 @@ import type {
10
11
  ProgressCallback,
11
12
  QuoteArgs,
12
13
  QuoteResponse,
14
+ SigningSharePairMetadata,
13
15
  SimulateTransactionParam,
14
16
  SimulatedTransaction,
15
17
  Transaction,
@@ -45,32 +47,49 @@ export interface IPortalApi {
45
47
  apiUrl: string
46
48
  requests: HttpRequester
47
49
 
50
+ getBackupShareMetadata(): Promise<BackupSharePairMetadata[]>
51
+ getBalances(): Promise<Balance[]>
48
52
  getClient(): Promise<ClientWithCustodianData>
49
53
  getEnabledDapps(): Promise<Dapp[]>
50
- getNetworks(): Promise<Network[]>
51
54
  getNFTs(): Promise<NFT[]>
55
+ getNetworks(): Promise<Network[]>
56
+ getQuote(apiKey: string, args: QuoteArgs): Promise<QuoteResponse>
57
+ getSigningSharePairs(): Promise<SigningSharePairMetadata[]>
58
+ getSources(apiKey: string): Promise<Record<string, string>>
52
59
  getTransactions(
53
60
  limit?: number,
54
61
  offset?: number,
55
62
  order?: GetTransactionsOrder,
56
- chainId?: number
63
+ chainId?: number,
57
64
  ): Promise<Transaction[]>
58
- getBalances(): Promise<Balance[]>
65
+ identify(traits?: Record<string, any>): Promise<{ success: boolean }>
59
66
  simulateTransaction(
60
- params: SimulateTransactionParam
67
+ params: SimulateTransactionParam,
61
68
  ): Promise<SimulatedTransaction>
62
- getQuote(apiKey: string, args: QuoteArgs): Promise<QuoteResponse>
63
- getSources(apiKey: string): Promise<Record<string, string>>
64
- storedClientSigningShare(signingSharePairId: string): Promise<void>
65
- storedClientBackupShareKey(backupMethod?: string): Promise<void>
66
69
  storedClientBackupShare(
67
70
  success: boolean,
68
- backupMethod?: string
71
+ backupMethod:
72
+ | 'CUSTOM'
73
+ | 'GDRIVE'
74
+ | 'ICLOUD'
75
+ | 'PASSKEY'
76
+ | 'PASSWORD'
77
+ | 'UNKNOWN',
69
78
  ): Promise<void>
70
- identify(traits?: Record<string, any>): Promise<{ success: boolean }>
79
+ storedClientBackupShareKey(
80
+ success: boolean,
81
+ backupMethod:
82
+ | 'CUSTOM'
83
+ | 'GDRIVE'
84
+ | 'ICLOUD'
85
+ | 'PASSKEY'
86
+ | 'PASSWORD'
87
+ | 'UNKNOWN',
88
+ ): Promise<void>
89
+ storedClientSigningShare(signingSharePairId: string): Promise<void>
71
90
  track(
72
91
  event: string,
73
- properties?: Record<string, any>
92
+ properties?: Record<string, any>,
74
93
  ): Promise<{ success: boolean }>
75
94
  }
76
95
 
@@ -110,32 +129,32 @@ export abstract class KeychainAdapter {
110
129
 
111
130
  deleteAddress(): Promise<boolean> {
112
131
  throw new Error(
113
- '[Portal] KeychainAdapter method deleteAddress cannot be called directly. Please extend KeychainAdapter.'
132
+ '[Portal] KeychainAdapter method deleteAddress cannot be called directly. Please extend KeychainAdapter.',
114
133
  )
115
134
  }
116
135
  deleteDkgResult(): Promise<boolean> {
117
136
  throw new Error(
118
- '[Portal] KeychainAdapter method deleteDkgResult cannot be called directly. Please extend KeychainAdapter.'
137
+ '[Portal] KeychainAdapter method deleteDkgResult cannot be called directly. Please extend KeychainAdapter.',
119
138
  )
120
139
  }
121
140
  getAddress(isSim?: boolean): Promise<string> {
122
141
  throw new Error(
123
- `[Portal] KeychainAdapter method getAddress(${isSim}) cannot be called directly. Please extend KeychainAdapter.`
142
+ `[Portal] KeychainAdapter method getAddress(${isSim}) cannot be called directly. Please extend KeychainAdapter.`,
124
143
  )
125
144
  }
126
145
  getDkgResult(
127
146
  isSim?: boolean,
128
147
  _progress: ProgressCallback = () => {
129
148
  // Noop
130
- }
149
+ },
131
150
  ): Promise<string> {
132
151
  throw new Error(
133
- `[Portal] KeychainAdapter method getDkgResult(${isSim}) cannot be called directly. Please extend KeychainAdapter.`
152
+ `[Portal] KeychainAdapter method getDkgResult(${isSim}) cannot be called directly. Please extend KeychainAdapter.`,
134
153
  )
135
154
  }
136
155
  storeAddress(address: string, isSim?: boolean): Promise<void> {
137
156
  throw new Error(
138
- `[Portal] KeychainAdapter method storeAddress(${address}, ${isSim}) cannot be called directly. Please extend KeychainAdapter.`
157
+ `[Portal] KeychainAdapter method storeAddress(${address}, ${isSim}) cannot be called directly. Please extend KeychainAdapter.`,
139
158
  )
140
159
  }
141
160
  storeDkgResult(
@@ -143,15 +162,15 @@ export abstract class KeychainAdapter {
143
162
  isSim?: boolean,
144
163
  _progress: ProgressCallback = () => {
145
164
  // Noop
146
- }
165
+ },
147
166
  ): Promise<void> {
148
167
  throw new Error(
149
- `[Portal] KeychainAdapter method storeDkgResult(${result}, ${isSim}) cannot be called directly. Please extend KeychainAdapter.`
168
+ `[Portal] KeychainAdapter method storeDkgResult(${result}, ${isSim}) cannot be called directly. Please extend KeychainAdapter.`,
150
169
  )
151
170
  }
152
171
  validateOperations(): Promise<boolean> {
153
172
  throw new Error(
154
- `[Portal] KeychainAdapter method validateOperations() cannot be called directly. Please extend KeychainAdapter.`
173
+ `[Portal] KeychainAdapter method validateOperations() cannot be called directly. Please extend KeychainAdapter.`,
155
174
  )
156
175
  }
157
176
  }
@@ -173,25 +192,25 @@ export abstract class Storage {
173
192
 
174
193
  delete(): Promise<boolean> {
175
194
  throw new Error(
176
- '[Portal] Storage method delete cannot be called directly. Please extend Storage.'
195
+ '[Portal] Storage method delete cannot be called directly. Please extend Storage.',
177
196
  )
178
197
  }
179
198
 
180
199
  read(): Promise<string> {
181
200
  throw new Error(
182
- '[Portal] Storage method read cannot be called directly. Please extend Storage.'
201
+ '[Portal] Storage method read cannot be called directly. Please extend Storage.',
183
202
  )
184
203
  }
185
204
 
186
205
  write(privateKey: string): Promise<string> {
187
206
  throw new Error(
188
- `[Portal] Storage method write(${privateKey}) cannot be called directly. Please extend Storage.`
207
+ `[Portal] Storage method write(${privateKey}) cannot be called directly. Please extend Storage.`,
189
208
  )
190
209
  }
191
210
 
192
211
  validateOperations(): Promise<boolean> {
193
212
  throw new Error(
194
- `[Portal] Storage method validateOperations() cannot be called directly. Please extend Storage.`
213
+ `[Portal] Storage method validateOperations() cannot be called directly. Please extend Storage.`,
195
214
  )
196
215
  }
197
216
  }
@@ -6,18 +6,20 @@ enum Events {
6
6
  WalletRecovered = 'Wallet Recovered',
7
7
 
8
8
  // API Method events
9
+ GetBackupShareMetadata = 'Get Backup Share Metadata',
10
+ GetBalances = 'Get Balances',
9
11
  GetClient = 'Get Client',
10
12
  GetEnabledDapps = 'Get Enabled Dapps',
13
+ GetNFTs = 'Get NFTs',
11
14
  GetNetworks = 'Get Networks',
12
15
  GetQuote = 'Get Quote',
16
+ GetSigningSharePairs = 'Get Signing Share Pairs',
13
17
  GetSources = 'Get Sources',
14
- GetNFTs = 'Get NFTs',
15
18
  GetTransactions = 'Get Transactions',
16
- GetBalances = 'Get Balances',
17
19
  SimulateTransaction = 'Simulate Transaction',
18
- StoredClientSigningShare = 'Stored Client Signing Share',
19
- StoredClientBackupShareKey = 'Stored Client Backup Share Key',
20
20
  StoredClientBackupShare = 'Stored Client Backup Share',
21
+ StoredClientBackupShareKey = 'Stored Client Backup Share Key',
22
+ StoredClientSigningShare = 'Stored Client Signing Share',
21
23
  }
22
24
 
23
25
  export default Events
package/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { BackupMethods } from '@portal-hq/core'
1
2
  import { MpcStatuses } from './src/definitions'
2
3
 
3
4
  export type MpcMember = 'client' | 'server'
@@ -264,6 +265,17 @@ export interface SimulatedTransaction {
264
265
  requestError?: SimulatedTransactionError
265
266
  }
266
267
 
268
+ export interface SigningSharePairMetadata {
269
+ createdAt: string
270
+ id: string
271
+ }
272
+
273
+ export interface BackupSharePairMetadata {
274
+ backupMethod: BackupMethods
275
+ createdAt: string
276
+ id: string
277
+ }
278
+
267
279
  export interface Balance {
268
280
  contractAddress: string
269
281
  balance: string