@portal-hq/utils 1.1.1 → 1.1.2
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/package.json +2 -2
- package/src/definitions/index.ts +94 -14
- package/src/index.ts +4 -1
- package/types.d.ts +38 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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": "fe11c271c1d85aca8f4e323a5a69b277483dbe89"
|
|
30
30
|
}
|
package/src/definitions/index.ts
CHANGED
|
@@ -1,13 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { HttpRequester } from '../requesters'
|
|
2
|
+
import type {
|
|
3
|
+
Balance,
|
|
4
|
+
QuoteArgs,
|
|
5
|
+
ClientWithCustodianData,
|
|
6
|
+
Dapp,
|
|
7
|
+
DkgData,
|
|
8
|
+
Network,
|
|
9
|
+
ProgressCallback,
|
|
10
|
+
QuoteResponse,
|
|
11
|
+
Transaction,
|
|
12
|
+
NFT,
|
|
7
13
|
} from '../../types'
|
|
14
|
+
import PortalConnect from '@portal-hq/connect'
|
|
15
|
+
|
|
16
|
+
export type EventHandler = (data: any) => void
|
|
17
|
+
|
|
18
|
+
export interface Eip1559 {
|
|
19
|
+
gasLimit?: string
|
|
20
|
+
maxPriorityFeePerGas?: string
|
|
21
|
+
maxFeePerGas?: string
|
|
22
|
+
[key: string]: any
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface LegacyTx {
|
|
26
|
+
gasLimit?: string
|
|
27
|
+
gasPrice?: string
|
|
28
|
+
[key: string]: any
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RequestArguments {
|
|
32
|
+
method: string
|
|
33
|
+
params?: unknown[] | SigningRequestParams
|
|
34
|
+
connect?: PortalConnect
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type SigningRequestParams = Eip1559 | LegacyTx
|
|
38
|
+
|
|
39
|
+
export interface IPortalApi {
|
|
40
|
+
apiKey: string
|
|
41
|
+
apiUrl: string
|
|
42
|
+
requests: HttpRequester
|
|
43
|
+
|
|
44
|
+
getClient(): Promise<ClientWithCustodianData>
|
|
45
|
+
getEnabledDapps(): Promise<Dapp[]>
|
|
46
|
+
getNetworks(): Promise<Network[]>
|
|
47
|
+
getNFTs(): Promise<NFT[]>
|
|
48
|
+
getTransactions(): Promise<Transaction[]>
|
|
49
|
+
getBalances(): Promise<Balance[]>
|
|
50
|
+
getQuote(apiKey: string, args: QuoteArgs): Promise<QuoteResponse>
|
|
51
|
+
getSources(apiKey: string): Promise<Record<string, string>>
|
|
52
|
+
storedClientSigningShare(options?: {
|
|
53
|
+
recoverSigning?: boolean
|
|
54
|
+
}): Promise<void>
|
|
55
|
+
storedClientBackupShareKey(backupMethod: string): Promise<void>
|
|
56
|
+
storedClientBackupShare(success: boolean): Promise<void>
|
|
57
|
+
identify(traits?: Record<string, any>): Promise<{ success: boolean }>
|
|
58
|
+
track(
|
|
59
|
+
event: string,
|
|
60
|
+
properties?: Record<string, any>,
|
|
61
|
+
): Promise<{ success: boolean }>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IPortalConnect {
|
|
65
|
+
connected: boolean
|
|
66
|
+
connect(uri: string): Promise<void>
|
|
67
|
+
deinit(): void
|
|
68
|
+
disconnect(): void
|
|
69
|
+
emit(event: string, data: any): PortalConnect
|
|
70
|
+
on(event: string, callback: EventHandler): PortalConnect
|
|
71
|
+
once(event: string, callback: EventHandler): PortalConnect
|
|
72
|
+
removeEventListener(event: string, listenerToRemove?: EventHandler): void
|
|
73
|
+
setChainId(chainId: number): Promise<void>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface IPortalProvider {
|
|
77
|
+
apiKey: string
|
|
78
|
+
autoApprove: boolean
|
|
79
|
+
chainId: number
|
|
80
|
+
log: Console
|
|
81
|
+
gateway: HttpRequester
|
|
82
|
+
|
|
83
|
+
address: Promise<string | undefined>
|
|
84
|
+
gatewayUrl: string
|
|
85
|
+
|
|
86
|
+
emit(event: string, data: any): IPortalProvider
|
|
87
|
+
getGatewayUrl(): string
|
|
88
|
+
on(event: string, callback: EventHandler): IPortalProvider
|
|
89
|
+
once(event: string, callback: EventHandler): IPortalProvider
|
|
90
|
+
removeEventListener(event: string, listenerToRemove?: EventHandler): void
|
|
91
|
+
request(args: RequestArguments): Promise<any>
|
|
92
|
+
setChainId(chainId: number, connect?: PortalConnect): Promise<IPortalProvider>
|
|
93
|
+
}
|
|
8
94
|
|
|
9
95
|
export abstract class KeychainAdapter {
|
|
10
|
-
public api?:
|
|
96
|
+
public api?: IPortalApi
|
|
11
97
|
|
|
12
98
|
deleteAddress(): Promise<boolean> {
|
|
13
99
|
throw new Error(
|
|
@@ -65,14 +151,8 @@ export enum MpcStatuses {
|
|
|
65
151
|
StoringShare = 'Storing share',
|
|
66
152
|
}
|
|
67
153
|
|
|
68
|
-
export declare class PortalApi {
|
|
69
|
-
getClient(): Promise<ClientWithCustodianData>
|
|
70
|
-
getEnabledDapps(): Promise<Dapp[]>
|
|
71
|
-
getNetworks(): Promise<Network[]>
|
|
72
|
-
}
|
|
73
|
-
|
|
74
154
|
export abstract class Storage {
|
|
75
|
-
public api?:
|
|
155
|
+
public api?: IPortalApi
|
|
76
156
|
|
|
77
157
|
delete(): Promise<boolean> {
|
|
78
158
|
throw new Error(
|
package/src/index.ts
CHANGED
|
@@ -8,9 +8,12 @@ export {
|
|
|
8
8
|
export { convertLocalToCrypto, convertCryptoToLocal, convert } from './currency'
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
|
+
type IPortalApi,
|
|
12
|
+
type IPortalConnect,
|
|
13
|
+
type IPortalProvider,
|
|
11
14
|
KeychainAdapter,
|
|
12
15
|
MpcStatuses,
|
|
13
|
-
type
|
|
16
|
+
type RequestArguments,
|
|
14
17
|
Storage,
|
|
15
18
|
} from './definitions'
|
|
16
19
|
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { MpcStatuses } from './src/definitions'
|
|
2
2
|
|
|
3
|
+
export type MpcMember = 'client' | 'server'
|
|
4
|
+
|
|
3
5
|
export type OutgoingRequestData = MessageData | SignableTransactionData
|
|
4
6
|
|
|
5
7
|
export type ProgressCallback = (status: MpcStatus) => void | Promise<void>
|
|
@@ -57,12 +59,20 @@ export interface DkgData {
|
|
|
57
59
|
share: string
|
|
58
60
|
ssid: string
|
|
59
61
|
pubkey: Pubkey
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
partialPubkey: {
|
|
63
|
+
[key: MpcMember]: Pubkey
|
|
64
|
+
}
|
|
65
|
+
allY: {
|
|
66
|
+
[key: MpcMember]: Pubkey
|
|
67
|
+
}
|
|
62
68
|
p: string
|
|
63
69
|
q: string
|
|
64
|
-
pederson:
|
|
65
|
-
|
|
70
|
+
pederson: {
|
|
71
|
+
[key: MpcMember]: PedersonParams
|
|
72
|
+
}
|
|
73
|
+
bks: {
|
|
74
|
+
[key: MpcMember]: Bk
|
|
75
|
+
}
|
|
66
76
|
}
|
|
67
77
|
|
|
68
78
|
export interface PedersonParams {
|
|
@@ -123,6 +133,30 @@ export interface Pubkey {
|
|
|
123
133
|
Y: string
|
|
124
134
|
}
|
|
125
135
|
|
|
136
|
+
export interface QuoteArgs {
|
|
137
|
+
affiliateAddress?: string
|
|
138
|
+
buyAmount?: number
|
|
139
|
+
buyToken: string
|
|
140
|
+
buyTokenPercentageFee?: number
|
|
141
|
+
enableSlippageProtection?: boolean
|
|
142
|
+
excludedSources?: string
|
|
143
|
+
feeRecipient?: string
|
|
144
|
+
gasPrice?: number
|
|
145
|
+
includedSources?: string
|
|
146
|
+
intentOnFilling?: boolean
|
|
147
|
+
priceImpactProtectionPercentage?: number
|
|
148
|
+
sellAmount?: number
|
|
149
|
+
sellToken: string
|
|
150
|
+
skipValidation?: boolean
|
|
151
|
+
slippagePercentage?: number
|
|
152
|
+
takerAddress?: string
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface QuoteResponse {
|
|
156
|
+
cost: string
|
|
157
|
+
transaction: Eip1559 | LegacyTx
|
|
158
|
+
}
|
|
159
|
+
|
|
126
160
|
export interface RequesterOptions {}
|
|
127
161
|
|
|
128
162
|
export interface RpcErrorDefinition {
|