@portal-hq/provider 2.0.3 → 2.0.4
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.
|
@@ -32,7 +32,7 @@ class Provider {
|
|
|
32
32
|
// Required
|
|
33
33
|
apiKey, chainId, keychain, gatewayConfig,
|
|
34
34
|
// Optional
|
|
35
|
-
isSimulator = false, autoApprove = false, apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', version = 'v4', }) {
|
|
35
|
+
isSimulator = false, autoApprove = false, apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', version = 'v4', featureFlags = { optimized: false }, }) {
|
|
36
36
|
// Handle required fields
|
|
37
37
|
if (!apiKey || apiKey.length === 0) {
|
|
38
38
|
throw new utils_1.InvalidApiKeyError();
|
|
@@ -65,9 +65,10 @@ class Provider {
|
|
|
65
65
|
});
|
|
66
66
|
// Initialize an MpcSigner
|
|
67
67
|
this.signer = new signers_1.MpcSigner({
|
|
68
|
-
mpcHost
|
|
69
|
-
keychain
|
|
70
|
-
version
|
|
68
|
+
mpcHost,
|
|
69
|
+
keychain,
|
|
70
|
+
version,
|
|
71
|
+
featureFlags,
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
get address() {
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const react_native_1 = require("react-native");
|
|
13
13
|
const utils_1 = require("@portal-hq/utils");
|
|
14
14
|
class MpcSigner {
|
|
15
|
-
constructor({ keychain, isSimulator = false, mpcHost = 'mpc.portalhq.io', version = 'v4', }) {
|
|
15
|
+
constructor({ keychain, isSimulator = false, mpcHost = 'mpc.portalhq.io', version = 'v4', featureFlags = { optimized: false }, }) {
|
|
16
16
|
this.version = 'v4';
|
|
17
17
|
this.buildParams = (method, txParams) => {
|
|
18
18
|
let params = txParams;
|
|
@@ -37,6 +37,7 @@ class MpcSigner {
|
|
|
37
37
|
this.mpc = react_native_1.NativeModules.PortalMobileMpc;
|
|
38
38
|
this.mpcHost = mpcHost;
|
|
39
39
|
this.version = version;
|
|
40
|
+
this.featureFlags = featureFlags;
|
|
40
41
|
if (!this.mpc) {
|
|
41
42
|
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.`);
|
|
42
43
|
}
|
|
@@ -64,6 +65,7 @@ class MpcSigner {
|
|
|
64
65
|
const metadata = JSON.stringify({
|
|
65
66
|
clientPlatform: 'REACT_NATIVE',
|
|
66
67
|
mpcServerVersion: this.version,
|
|
68
|
+
optimized: this.featureFlags.optimized,
|
|
67
69
|
});
|
|
68
70
|
const result = yield this.mpc.sign(apiKey, this.mpcHost, signingShare, message.method, JSON.stringify(this.buildParams(method, params)), provider.gatewayUrl, provider.chainId.toString(), metadata);
|
|
69
71
|
const { data, error } = JSON.parse(String(result));
|
|
@@ -30,7 +30,7 @@ class Provider {
|
|
|
30
30
|
// Required
|
|
31
31
|
apiKey, chainId, keychain, gatewayConfig,
|
|
32
32
|
// Optional
|
|
33
|
-
isSimulator = false, autoApprove = false, apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', version = 'v4', }) {
|
|
33
|
+
isSimulator = false, autoApprove = false, apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', version = 'v4', featureFlags = { optimized: false }, }) {
|
|
34
34
|
// Handle required fields
|
|
35
35
|
if (!apiKey || apiKey.length === 0) {
|
|
36
36
|
throw new InvalidApiKeyError();
|
|
@@ -63,9 +63,10 @@ class Provider {
|
|
|
63
63
|
});
|
|
64
64
|
// Initialize an MpcSigner
|
|
65
65
|
this.signer = new MpcSigner({
|
|
66
|
-
mpcHost
|
|
67
|
-
keychain
|
|
68
|
-
version
|
|
66
|
+
mpcHost,
|
|
67
|
+
keychain,
|
|
68
|
+
version,
|
|
69
|
+
featureFlags,
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
get address() {
|
package/lib/esm/signers/mpc.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { NativeModules } from 'react-native';
|
|
11
11
|
import { PortalMpcError, } from '@portal-hq/utils';
|
|
12
12
|
class MpcSigner {
|
|
13
|
-
constructor({ keychain, isSimulator = false, mpcHost = 'mpc.portalhq.io', version = 'v4', }) {
|
|
13
|
+
constructor({ keychain, isSimulator = false, mpcHost = 'mpc.portalhq.io', version = 'v4', featureFlags = { optimized: false }, }) {
|
|
14
14
|
this.version = 'v4';
|
|
15
15
|
this.buildParams = (method, txParams) => {
|
|
16
16
|
let params = txParams;
|
|
@@ -35,6 +35,7 @@ class MpcSigner {
|
|
|
35
35
|
this.mpc = NativeModules.PortalMobileMpc;
|
|
36
36
|
this.mpcHost = mpcHost;
|
|
37
37
|
this.version = version;
|
|
38
|
+
this.featureFlags = featureFlags;
|
|
38
39
|
if (!this.mpc) {
|
|
39
40
|
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.`);
|
|
40
41
|
}
|
|
@@ -62,6 +63,7 @@ class MpcSigner {
|
|
|
62
63
|
const metadata = JSON.stringify({
|
|
63
64
|
clientPlatform: 'REACT_NATIVE',
|
|
64
65
|
mpcServerVersion: this.version,
|
|
66
|
+
optimized: this.featureFlags.optimized,
|
|
65
67
|
});
|
|
66
68
|
const result = yield this.mpc.sign(apiKey, this.mpcHost, signingShare, message.method, JSON.stringify(this.buildParams(method, params)), provider.gatewayUrl, provider.chainId.toString(), metadata);
|
|
67
69
|
const { data, error } = JSON.parse(String(result));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/provider",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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": "^2.0.
|
|
23
|
-
"@portal-hq/utils": "^2.0.
|
|
22
|
+
"@portal-hq/connect": "^2.0.4",
|
|
23
|
+
"@portal-hq/utils": "^2.0.4"
|
|
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": "2d2f1ef628bc8788fa4a9cd32cc44795e547b3a7"
|
|
34
34
|
}
|
package/src/providers/index.ts
CHANGED
|
@@ -74,6 +74,7 @@ class Provider implements IPortalProvider {
|
|
|
74
74
|
apiHost = 'api.portalhq.io',
|
|
75
75
|
mpcHost = 'mpc.portalhq.io',
|
|
76
76
|
version = 'v4',
|
|
77
|
+
featureFlags = { optimized: false },
|
|
77
78
|
}: ProviderOptions) {
|
|
78
79
|
// Handle required fields
|
|
79
80
|
if (!apiKey || apiKey.length === 0) {
|
|
@@ -112,9 +113,10 @@ class Provider implements IPortalProvider {
|
|
|
112
113
|
|
|
113
114
|
// Initialize an MpcSigner
|
|
114
115
|
this.signer = new MpcSigner({
|
|
115
|
-
mpcHost
|
|
116
|
-
keychain
|
|
117
|
-
version
|
|
116
|
+
mpcHost,
|
|
117
|
+
keychain,
|
|
118
|
+
version,
|
|
119
|
+
featureFlags,
|
|
118
120
|
})
|
|
119
121
|
}
|
|
120
122
|
|
package/src/signers/mpc.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type PortalMobileMpc,
|
|
14
14
|
type SigningResponse,
|
|
15
15
|
} from '../../types'
|
|
16
|
+
import { FeatureFlags } from '@portal-hq/core/types'
|
|
16
17
|
|
|
17
18
|
class MpcSigner implements Signer {
|
|
18
19
|
private isSimulator: boolean
|
|
@@ -20,6 +21,7 @@ class MpcSigner implements Signer {
|
|
|
20
21
|
private mpc: PortalMobileMpc
|
|
21
22
|
private mpcHost: string // should we add a default here mpc.portalhq.io
|
|
22
23
|
private version: string = 'v4'
|
|
24
|
+
private featureFlags: FeatureFlags
|
|
23
25
|
|
|
24
26
|
private get address(): Promise<string | undefined> {
|
|
25
27
|
return this.keychain.getAddress(this.isSimulator)
|
|
@@ -34,12 +36,14 @@ class MpcSigner implements Signer {
|
|
|
34
36
|
isSimulator = false,
|
|
35
37
|
mpcHost = 'mpc.portalhq.io',
|
|
36
38
|
version = 'v4',
|
|
39
|
+
featureFlags = { optimized: false },
|
|
37
40
|
}: MpcSignerOptions) {
|
|
38
41
|
this.isSimulator = isSimulator
|
|
39
42
|
this.keychain = keychain
|
|
40
43
|
this.mpc = NativeModules.PortalMobileMpc
|
|
41
44
|
this.mpcHost = mpcHost
|
|
42
45
|
this.version = version
|
|
46
|
+
this.featureFlags = featureFlags
|
|
43
47
|
|
|
44
48
|
if (!this.mpc) {
|
|
45
49
|
throw new Error(
|
|
@@ -71,6 +75,7 @@ class MpcSigner implements Signer {
|
|
|
71
75
|
const metadata = JSON.stringify({
|
|
72
76
|
clientPlatform: 'REACT_NATIVE',
|
|
73
77
|
mpcServerVersion: this.version,
|
|
78
|
+
optimized: this.featureFlags.optimized,
|
|
74
79
|
})
|
|
75
80
|
|
|
76
81
|
const result = await this.mpc.sign(
|
package/types.d.ts
CHANGED
|
@@ -22,11 +22,13 @@ export interface MpcSignerOptions extends SignerOptions {
|
|
|
22
22
|
isSimulator?: boolean
|
|
23
23
|
mpcHost?: string
|
|
24
24
|
version?: string
|
|
25
|
+
featureFlags?: FeatureFlags
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export interface PortalMobileMpcMetadata {
|
|
28
29
|
clientPlatform: string
|
|
29
30
|
mpcServerVersion: string
|
|
31
|
+
optimized: boolean
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export interface PortalMobileMpc {
|
|
@@ -67,6 +69,7 @@ export interface ProviderOptions {
|
|
|
67
69
|
apiHost?: string
|
|
68
70
|
mpcHost?: string
|
|
69
71
|
version?: string
|
|
72
|
+
featureFlags?: FeatureFlags
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
export interface RegisteredEventHandler {
|