@portal-hq/provider 0.2.0-beta8 → 0.2.1
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.
|
@@ -27,10 +27,15 @@ const signerMethods = [
|
|
|
27
27
|
'eth_signTypedData',
|
|
28
28
|
'personal_sign',
|
|
29
29
|
];
|
|
30
|
+
const solanaSignerMethods = [
|
|
31
|
+
'requestAirdrop',
|
|
32
|
+
'sendTransaction',
|
|
33
|
+
'simulateTransaction',
|
|
34
|
+
];
|
|
30
35
|
class Provider {
|
|
31
36
|
constructor({
|
|
32
37
|
// Required options
|
|
33
|
-
apiKey, chainId,
|
|
38
|
+
apiKey, chainId, keychain,
|
|
34
39
|
// Optional options
|
|
35
40
|
apiUrl = 'api.portalhq.io', autoApprove = false, enableMpc = true, mpcUrl = 'mpc.portalhq.io', gatewayConfig = {}, }) {
|
|
36
41
|
// Handle required fields
|
|
@@ -50,6 +55,7 @@ class Provider {
|
|
|
50
55
|
this.chainId = chainId;
|
|
51
56
|
this.events = {};
|
|
52
57
|
this.isMPC = enableMpc;
|
|
58
|
+
this.keychain = keychain;
|
|
53
59
|
this.log = console;
|
|
54
60
|
this.mpcUrl = mpcUrl;
|
|
55
61
|
this.portal = new requesters_1.HttpRequester({
|
|
@@ -64,6 +70,7 @@ class Provider {
|
|
|
64
70
|
// If MPC is enabled, initialize an MpcSigner
|
|
65
71
|
this.signer = new signers_1.MpcSigner({
|
|
66
72
|
mpcUrl: this.mpcUrl,
|
|
73
|
+
keychain: this.keychain,
|
|
67
74
|
});
|
|
68
75
|
}
|
|
69
76
|
else {
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const react_native_1 = require("react-native");
|
|
13
|
-
const keychain_1 = require("@portal-hq/keychain");
|
|
14
13
|
const utils_1 = require("@portal-hq/utils");
|
|
15
14
|
class MpcSigner {
|
|
16
15
|
constructor(opts) {
|
|
@@ -30,12 +29,12 @@ class MpcSigner {
|
|
|
30
29
|
}
|
|
31
30
|
return params;
|
|
32
31
|
};
|
|
32
|
+
this.keychain = opts.keychain;
|
|
33
33
|
this.mpc = react_native_1.NativeModules.PortalMobileMpc;
|
|
34
34
|
this.mpcUrl = opts.mpcUrl;
|
|
35
35
|
if (!this.mpc) {
|
|
36
36
|
throw new Error(`[Portal.Provider.MpcSigner] The MPC module could not be found by the signer. This is usually an issue with React Native linking. Please verify that the 'PortalReactNative' module is properly linked to this project.`);
|
|
37
37
|
}
|
|
38
|
-
this.keychain = new keychain_1.Keychain();
|
|
39
38
|
}
|
|
40
39
|
get address() {
|
|
41
40
|
return (() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -25,10 +25,15 @@ const signerMethods = [
|
|
|
25
25
|
'eth_signTypedData',
|
|
26
26
|
'personal_sign',
|
|
27
27
|
];
|
|
28
|
+
const solanaSignerMethods = [
|
|
29
|
+
'requestAirdrop',
|
|
30
|
+
'sendTransaction',
|
|
31
|
+
'simulateTransaction',
|
|
32
|
+
];
|
|
28
33
|
class Provider {
|
|
29
34
|
constructor({
|
|
30
35
|
// Required options
|
|
31
|
-
apiKey, chainId,
|
|
36
|
+
apiKey, chainId, keychain,
|
|
32
37
|
// Optional options
|
|
33
38
|
apiUrl = 'api.portalhq.io', autoApprove = false, enableMpc = true, mpcUrl = 'mpc.portalhq.io', gatewayConfig = {}, }) {
|
|
34
39
|
// Handle required fields
|
|
@@ -48,6 +53,7 @@ class Provider {
|
|
|
48
53
|
this.chainId = chainId;
|
|
49
54
|
this.events = {};
|
|
50
55
|
this.isMPC = enableMpc;
|
|
56
|
+
this.keychain = keychain;
|
|
51
57
|
this.log = console;
|
|
52
58
|
this.mpcUrl = mpcUrl;
|
|
53
59
|
this.portal = new HttpRequester({
|
|
@@ -62,6 +68,7 @@ class Provider {
|
|
|
62
68
|
// If MPC is enabled, initialize an MpcSigner
|
|
63
69
|
this.signer = new MpcSigner({
|
|
64
70
|
mpcUrl: this.mpcUrl,
|
|
71
|
+
keychain: this.keychain,
|
|
65
72
|
});
|
|
66
73
|
}
|
|
67
74
|
else {
|
package/lib/esm/signers/mpc.js
CHANGED
|
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { NativeModules } from 'react-native';
|
|
11
|
-
import { Keychain } from '@portal-hq/keychain';
|
|
12
11
|
import { MpcSigningError } from '@portal-hq/utils';
|
|
13
12
|
class MpcSigner {
|
|
14
13
|
constructor(opts) {
|
|
@@ -28,12 +27,12 @@ class MpcSigner {
|
|
|
28
27
|
}
|
|
29
28
|
return params;
|
|
30
29
|
};
|
|
30
|
+
this.keychain = opts.keychain;
|
|
31
31
|
this.mpc = NativeModules.PortalMobileMpc;
|
|
32
32
|
this.mpcUrl = opts.mpcUrl;
|
|
33
33
|
if (!this.mpc) {
|
|
34
34
|
throw new Error(`[Portal.Provider.MpcSigner] The MPC module could not be found by the signer. This is usually an issue with React Native linking. Please verify that the 'PortalReactNative' module is properly linked to this project.`);
|
|
35
35
|
}
|
|
36
|
-
this.keychain = new Keychain();
|
|
37
36
|
}
|
|
38
37
|
get address() {
|
|
39
38
|
return (() => __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/provider",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
"prepare:esm": "tsc --outDir lib/esm --module es2015 --target es2015"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@portal-hq/
|
|
21
|
-
"@portal-hq/utils": "^0.2.0-beta8"
|
|
20
|
+
"@portal-hq/utils": "^0.2.1"
|
|
22
21
|
},
|
|
23
22
|
"devDependencies": {
|
|
24
23
|
"typescript": "^4.8.4"
|
package/src/providers/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
InvalidApiKeyError,
|
|
3
3
|
InvalidChainIdError,
|
|
4
4
|
InvalidGatewayConfigError,
|
|
5
|
+
KeychainAdapter,
|
|
5
6
|
ProviderRpcError,
|
|
6
7
|
RpcErrorCodes,
|
|
7
8
|
} from '@portal-hq/utils'
|
|
@@ -34,6 +35,12 @@ const signerMethods = [
|
|
|
34
35
|
'personal_sign',
|
|
35
36
|
]
|
|
36
37
|
|
|
38
|
+
const solanaSignerMethods = [
|
|
39
|
+
'requestAirdrop',
|
|
40
|
+
'sendTransaction',
|
|
41
|
+
'simulateTransaction',
|
|
42
|
+
]
|
|
43
|
+
|
|
37
44
|
class Provider {
|
|
38
45
|
public readonly mpcUrl: string
|
|
39
46
|
public readonly portal: HttpRequester
|
|
@@ -46,6 +53,7 @@ class Provider {
|
|
|
46
53
|
private apiUrl: string
|
|
47
54
|
private autoApprove?: boolean
|
|
48
55
|
private events: Record<string, RegisteredEventHandler[]>
|
|
56
|
+
private keychain: KeychainAdapter
|
|
49
57
|
private log: Console
|
|
50
58
|
private gatewayConfig: GatewayLike
|
|
51
59
|
private rpc: HttpRequester
|
|
@@ -56,6 +64,7 @@ class Provider {
|
|
|
56
64
|
// Required options
|
|
57
65
|
apiKey,
|
|
58
66
|
chainId,
|
|
67
|
+
keychain,
|
|
59
68
|
|
|
60
69
|
// Optional options
|
|
61
70
|
apiUrl = 'api.portalhq.io',
|
|
@@ -82,6 +91,7 @@ class Provider {
|
|
|
82
91
|
this.chainId = chainId
|
|
83
92
|
this.events = {}
|
|
84
93
|
this.isMPC = enableMpc
|
|
94
|
+
this.keychain = keychain
|
|
85
95
|
this.log = console
|
|
86
96
|
this.mpcUrl = mpcUrl
|
|
87
97
|
this.portal = new HttpRequester({
|
|
@@ -99,6 +109,7 @@ class Provider {
|
|
|
99
109
|
// If MPC is enabled, initialize an MpcSigner
|
|
100
110
|
this.signer = new MpcSigner({
|
|
101
111
|
mpcUrl: this.mpcUrl,
|
|
112
|
+
keychain: this.keychain,
|
|
102
113
|
})
|
|
103
114
|
} else {
|
|
104
115
|
// If MPC is disabled, initialize an HttpSigner, talking to whatever httpHost was provided
|
package/src/signers/mpc.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native'
|
|
2
|
-
import {
|
|
3
|
-
import { MpcSigningError } from '@portal-hq/utils'
|
|
2
|
+
import { KeychainAdapter, MpcSigningError } from '@portal-hq/utils'
|
|
4
3
|
|
|
5
4
|
import { Provider } from '../index'
|
|
6
5
|
import Signer from './abstract'
|
|
@@ -14,11 +13,12 @@ import {
|
|
|
14
13
|
|
|
15
14
|
class MpcSigner implements Signer {
|
|
16
15
|
public _address: string
|
|
17
|
-
private keychain:
|
|
16
|
+
private keychain: KeychainAdapter
|
|
18
17
|
private mpc: PortalMobileMpc
|
|
19
18
|
private mpcUrl: string
|
|
20
19
|
|
|
21
20
|
constructor(opts: MpcSignerOptions) {
|
|
21
|
+
this.keychain = opts.keychain
|
|
22
22
|
this.mpc = NativeModules.PortalMobileMpc
|
|
23
23
|
this.mpcUrl = opts.mpcUrl
|
|
24
24
|
|
|
@@ -27,8 +27,6 @@ class MpcSigner implements Signer {
|
|
|
27
27
|
`[Portal.Provider.MpcSigner] The MPC module could not be found by the signer. This is usually an issue with React Native linking. Please verify that the 'PortalReactNative' module is properly linked to this project.`,
|
|
28
28
|
)
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
this.keychain = new Keychain()
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
public get address() {
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Types
|
|
2
2
|
|
|
3
|
+
import { KeychainAdapter } from '@portal-hq/utils'
|
|
4
|
+
|
|
3
5
|
export type EventHandler = (data: any) => void
|
|
4
6
|
|
|
5
7
|
export type GatewayLike = GatewayConfig | string
|
|
@@ -21,6 +23,7 @@ export interface HttpSignerOptions extends SignerOptions {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export interface MpcSignerOptions extends SignerOptions {
|
|
26
|
+
keychain: KeychainAdapter
|
|
24
27
|
mpcUrl: string
|
|
25
28
|
}
|
|
26
29
|
|
|
@@ -47,6 +50,7 @@ export interface ProviderOptions {
|
|
|
47
50
|
// Required options
|
|
48
51
|
apiKey: string
|
|
49
52
|
chainId: number
|
|
53
|
+
keychain: KeychainAdapter
|
|
50
54
|
gatewayConfig: GatewayLike
|
|
51
55
|
|
|
52
56
|
// Optional options
|