@portal-hq/provider 1.1.1 → 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/package.json +4 -4
- package/src/providers/index.ts +6 -5
- package/src/signers/mpc.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/esm/index",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"test": "jest"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@portal-hq/connect": "^1.1.
|
|
23
|
-
"@portal-hq/utils": "^1.1.
|
|
22
|
+
"@portal-hq/connect": "^1.1.3",
|
|
23
|
+
"@portal-hq/utils": "^1.1.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/preset-typescript": "^7.18.6",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"ts-jest": "^29.0.3",
|
|
31
31
|
"typescript": "^4.8.4"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "169a9045d5cfb542b037a26d0ebcc53f51eec8dd"
|
|
34
34
|
}
|
package/src/providers/index.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Events,
|
|
3
3
|
HttpRequester,
|
|
4
|
+
IPortalProvider,
|
|
4
5
|
InvalidApiKeyError,
|
|
5
6
|
InvalidChainIdError,
|
|
6
7
|
InvalidGatewayConfigError,
|
|
7
8
|
KeychainAdapter,
|
|
8
9
|
ProviderRpcError,
|
|
10
|
+
type RequestArguments,
|
|
9
11
|
RpcErrorCodes,
|
|
10
12
|
} from '@portal-hq/utils'
|
|
11
13
|
|
|
@@ -15,7 +17,6 @@ import {
|
|
|
15
17
|
type GatewayLike,
|
|
16
18
|
type ProviderOptions,
|
|
17
19
|
type RegisteredEventHandler,
|
|
18
|
-
type RequestArguments,
|
|
19
20
|
type SwitchEthereumChainParameter,
|
|
20
21
|
} from '../../types'
|
|
21
22
|
import PortalConnect from '@portal-hq/connect'
|
|
@@ -38,7 +39,7 @@ const signerMethods = [
|
|
|
38
39
|
'personal_sign',
|
|
39
40
|
]
|
|
40
41
|
|
|
41
|
-
class Provider {
|
|
42
|
+
class Provider implements IPortalProvider {
|
|
42
43
|
public apiKey: string
|
|
43
44
|
public autoApprove: boolean
|
|
44
45
|
public chainId: number
|
|
@@ -125,7 +126,7 @@ class Provider {
|
|
|
125
126
|
* @param data The data to be passed to registered event handlers
|
|
126
127
|
* @returns BaseProvider
|
|
127
128
|
*/
|
|
128
|
-
public emit(event: string, data: any):
|
|
129
|
+
public emit(event: string, data: any): IPortalProvider {
|
|
129
130
|
// Grab the registered event handlers if any are available
|
|
130
131
|
const handlers = this.events[event] || []
|
|
131
132
|
|
|
@@ -179,7 +180,7 @@ class Provider {
|
|
|
179
180
|
* @param callback The callback to be invoked when the event is emitted
|
|
180
181
|
* @returns BaseProvider
|
|
181
182
|
*/
|
|
182
|
-
public on(event: string, callback: EventHandler):
|
|
183
|
+
public on(event: string, callback: EventHandler): IPortalProvider {
|
|
183
184
|
// If no handlers are registered for this event, create an entry for the event
|
|
184
185
|
if (!this.events[event]) {
|
|
185
186
|
this.events[event] = []
|
|
@@ -203,7 +204,7 @@ class Provider {
|
|
|
203
204
|
* @param callback The callback to be invoked the next time the event is emitted
|
|
204
205
|
* @returns BaseProvider
|
|
205
206
|
*/
|
|
206
|
-
public once(event: string, callback: EventHandler):
|
|
207
|
+
public once(event: string, callback: EventHandler): IPortalProvider {
|
|
207
208
|
// If no handlers are registered for this event, create an entry for the event
|
|
208
209
|
if (!this.events[event]) {
|
|
209
210
|
this.events[event] = []
|
package/src/signers/mpc.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native'
|
|
2
2
|
import {
|
|
3
|
+
IPortalProvider,
|
|
3
4
|
KeychainAdapter,
|
|
4
5
|
PortalMpcError,
|
|
5
6
|
type SigningRequestArguments,
|
|
6
7
|
} from '@portal-hq/utils'
|
|
7
8
|
|
|
8
|
-
import { Provider } from '../index'
|
|
9
9
|
import Signer from './abstract'
|
|
10
10
|
|
|
11
11
|
import {
|
|
@@ -50,7 +50,7 @@ class MpcSigner implements Signer {
|
|
|
50
50
|
|
|
51
51
|
public async sign(
|
|
52
52
|
message: SigningRequestArguments,
|
|
53
|
-
provider:
|
|
53
|
+
provider: IPortalProvider,
|
|
54
54
|
): Promise<any> {
|
|
55
55
|
const address = await this.address
|
|
56
56
|
const apiKey = provider.apiKey
|