@portal-hq/provider 4.1.2 → 4.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/lib/commonjs/signers/mpc.js +31 -7
- package/lib/esm/signers/mpc.js +28 -7
- package/package.json +6 -4
- package/src/signers/mpc.ts +27 -6
- package/types.d.ts +6 -0
|
@@ -8,10 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
const core_1 = require("@portal-hq/core");
|
|
13
16
|
const utils_1 = require("@portal-hq/utils");
|
|
14
17
|
const react_native_1 = require("react-native");
|
|
18
|
+
const react_native_uuid_1 = __importDefault(require("react-native-uuid"));
|
|
15
19
|
var Operation;
|
|
16
20
|
(function (Operation) {
|
|
17
21
|
Operation["SIGN"] = "sign";
|
|
@@ -60,9 +64,14 @@ class MpcSigner {
|
|
|
60
64
|
const shouldSendMetrics = this.featureFlags.enableSdkPerformanceMetrics === true;
|
|
61
65
|
const signStartTime = performance.now();
|
|
62
66
|
const preOperationStartTime = performance.now();
|
|
67
|
+
// Generate a traceId for this operation
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
69
|
+
const traceId = react_native_uuid_1.default.v4();
|
|
63
70
|
const metrics = {
|
|
64
|
-
operation: Operation.SIGN,
|
|
65
71
|
hasError: false,
|
|
72
|
+
operation: Operation.SIGN,
|
|
73
|
+
signingMethod: message.method,
|
|
74
|
+
traceId,
|
|
66
75
|
};
|
|
67
76
|
try {
|
|
68
77
|
const eip155Address = yield this.keychain.getEip155Address();
|
|
@@ -97,6 +106,8 @@ class MpcSigner {
|
|
|
97
106
|
curve,
|
|
98
107
|
chainId,
|
|
99
108
|
isRaw,
|
|
109
|
+
reqId: traceId,
|
|
110
|
+
connectionTracingEnabled: shouldSendMetrics,
|
|
100
111
|
};
|
|
101
112
|
const stringifiedMetadata = JSON.stringify(metadata);
|
|
102
113
|
let formattedParams;
|
|
@@ -127,11 +138,24 @@ class MpcSigner {
|
|
|
127
138
|
const { data, error, meta } = parsedResponse;
|
|
128
139
|
// Add binary metrics to our metrics object
|
|
129
140
|
if (meta === null || meta === void 0 ? void 0 : meta.metrics) {
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
const binaryMetrics = meta.metrics;
|
|
142
|
+
if (binaryMetrics.wsConnectDurationMs) {
|
|
143
|
+
metrics.sdkBinaryWSConnectMs = binaryMetrics.wsConnectDurationMs;
|
|
144
|
+
}
|
|
145
|
+
if (binaryMetrics.operationDurationMs) {
|
|
146
|
+
metrics.sdkBinaryOperationMs = binaryMetrics.operationDurationMs;
|
|
147
|
+
}
|
|
148
|
+
if (binaryMetrics.tlsHandshakeMs) {
|
|
149
|
+
metrics.sdkBinaryTlsHandshakeMs = binaryMetrics.tlsHandshakeMs;
|
|
132
150
|
}
|
|
133
|
-
if (
|
|
134
|
-
metrics.
|
|
151
|
+
if (binaryMetrics.firstResponseMs) {
|
|
152
|
+
metrics.sdkBinaryFirstResponseMs = binaryMetrics.firstResponseMs;
|
|
153
|
+
}
|
|
154
|
+
if (binaryMetrics.dnsLookupMs) {
|
|
155
|
+
metrics.sdkBinaryDnsLookupMs = binaryMetrics.dnsLookupMs;
|
|
156
|
+
}
|
|
157
|
+
if (binaryMetrics.connectMs) {
|
|
158
|
+
metrics.sdkBinaryConnectMs = binaryMetrics.connectMs;
|
|
135
159
|
}
|
|
136
160
|
}
|
|
137
161
|
if ((error === null || error === void 0 ? void 0 : error.code) > 0) {
|
|
@@ -146,7 +170,7 @@ class MpcSigner {
|
|
|
146
170
|
try {
|
|
147
171
|
yield this.sendMetrics(metrics, apiKey);
|
|
148
172
|
}
|
|
149
|
-
catch (
|
|
173
|
+
catch (err) {
|
|
150
174
|
// No-op
|
|
151
175
|
}
|
|
152
176
|
}
|
|
@@ -162,7 +186,7 @@ class MpcSigner {
|
|
|
162
186
|
try {
|
|
163
187
|
yield this.sendMetrics(metrics, apiKey);
|
|
164
188
|
}
|
|
165
|
-
catch (
|
|
189
|
+
catch (_a) {
|
|
166
190
|
// No-op
|
|
167
191
|
}
|
|
168
192
|
}
|
package/lib/esm/signers/mpc.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { PortalCurve } from '@portal-hq/core';
|
|
11
11
|
import { PortalMpcError, getClientPlatformVersion, } from '@portal-hq/utils';
|
|
12
12
|
import { NativeModules } from 'react-native';
|
|
13
|
+
import UUID from 'react-native-uuid';
|
|
13
14
|
var Operation;
|
|
14
15
|
(function (Operation) {
|
|
15
16
|
Operation["SIGN"] = "sign";
|
|
@@ -58,9 +59,14 @@ class MpcSigner {
|
|
|
58
59
|
const shouldSendMetrics = this.featureFlags.enableSdkPerformanceMetrics === true;
|
|
59
60
|
const signStartTime = performance.now();
|
|
60
61
|
const preOperationStartTime = performance.now();
|
|
62
|
+
// Generate a traceId for this operation
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
64
|
+
const traceId = UUID.v4();
|
|
61
65
|
const metrics = {
|
|
62
|
-
operation: Operation.SIGN,
|
|
63
66
|
hasError: false,
|
|
67
|
+
operation: Operation.SIGN,
|
|
68
|
+
signingMethod: message.method,
|
|
69
|
+
traceId,
|
|
64
70
|
};
|
|
65
71
|
try {
|
|
66
72
|
const eip155Address = yield this.keychain.getEip155Address();
|
|
@@ -95,6 +101,8 @@ class MpcSigner {
|
|
|
95
101
|
curve,
|
|
96
102
|
chainId,
|
|
97
103
|
isRaw,
|
|
104
|
+
reqId: traceId,
|
|
105
|
+
connectionTracingEnabled: shouldSendMetrics,
|
|
98
106
|
};
|
|
99
107
|
const stringifiedMetadata = JSON.stringify(metadata);
|
|
100
108
|
let formattedParams;
|
|
@@ -125,11 +133,24 @@ class MpcSigner {
|
|
|
125
133
|
const { data, error, meta } = parsedResponse;
|
|
126
134
|
// Add binary metrics to our metrics object
|
|
127
135
|
if (meta === null || meta === void 0 ? void 0 : meta.metrics) {
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
const binaryMetrics = meta.metrics;
|
|
137
|
+
if (binaryMetrics.wsConnectDurationMs) {
|
|
138
|
+
metrics.sdkBinaryWSConnectMs = binaryMetrics.wsConnectDurationMs;
|
|
139
|
+
}
|
|
140
|
+
if (binaryMetrics.operationDurationMs) {
|
|
141
|
+
metrics.sdkBinaryOperationMs = binaryMetrics.operationDurationMs;
|
|
142
|
+
}
|
|
143
|
+
if (binaryMetrics.tlsHandshakeMs) {
|
|
144
|
+
metrics.sdkBinaryTlsHandshakeMs = binaryMetrics.tlsHandshakeMs;
|
|
130
145
|
}
|
|
131
|
-
if (
|
|
132
|
-
metrics.
|
|
146
|
+
if (binaryMetrics.firstResponseMs) {
|
|
147
|
+
metrics.sdkBinaryFirstResponseMs = binaryMetrics.firstResponseMs;
|
|
148
|
+
}
|
|
149
|
+
if (binaryMetrics.dnsLookupMs) {
|
|
150
|
+
metrics.sdkBinaryDnsLookupMs = binaryMetrics.dnsLookupMs;
|
|
151
|
+
}
|
|
152
|
+
if (binaryMetrics.connectMs) {
|
|
153
|
+
metrics.sdkBinaryConnectMs = binaryMetrics.connectMs;
|
|
133
154
|
}
|
|
134
155
|
}
|
|
135
156
|
if ((error === null || error === void 0 ? void 0 : error.code) > 0) {
|
|
@@ -144,7 +165,7 @@ class MpcSigner {
|
|
|
144
165
|
try {
|
|
145
166
|
yield this.sendMetrics(metrics, apiKey);
|
|
146
167
|
}
|
|
147
|
-
catch (
|
|
168
|
+
catch (err) {
|
|
148
169
|
// No-op
|
|
149
170
|
}
|
|
150
171
|
}
|
|
@@ -160,7 +181,7 @@ class MpcSigner {
|
|
|
160
181
|
try {
|
|
161
182
|
yield this.sendMetrics(metrics, apiKey);
|
|
162
183
|
}
|
|
163
|
-
catch (
|
|
184
|
+
catch (_a) {
|
|
164
185
|
// No-op
|
|
165
186
|
}
|
|
166
187
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/provider",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/esm/index",
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
"test": "jest"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@portal-hq/connect": "^4.1.
|
|
23
|
-
"@portal-hq/utils": "^4.1.
|
|
22
|
+
"@portal-hq/connect": "^4.1.3",
|
|
23
|
+
"@portal-hq/utils": "^4.1.3",
|
|
24
|
+
"@types/react-native-uuid": "^2.0.0",
|
|
25
|
+
"react-native-uuid": "^2.0.3"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@babel/preset-typescript": "^7.18.6",
|
|
@@ -30,5 +32,5 @@
|
|
|
30
32
|
"ts-jest": "^29.0.3",
|
|
31
33
|
"typescript": "^4.8.4"
|
|
32
34
|
},
|
|
33
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "912b03f1152f4dbb7e017919c63bdc950ca867cf"
|
|
34
36
|
}
|
package/src/signers/mpc.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getClientPlatformVersion,
|
|
10
10
|
} from '@portal-hq/utils'
|
|
11
11
|
import { NativeModules } from 'react-native'
|
|
12
|
+
import UUID from 'react-native-uuid'
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
type MpcSignerOptions,
|
|
@@ -61,9 +62,14 @@ class MpcSigner implements Signer {
|
|
|
61
62
|
this.featureFlags.enableSdkPerformanceMetrics === true
|
|
62
63
|
const signStartTime = performance.now()
|
|
63
64
|
const preOperationStartTime = performance.now()
|
|
65
|
+
// Generate a traceId for this operation
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
67
|
+
const traceId = (UUID as any).v4() as string
|
|
64
68
|
const metrics: Record<string, number | string | boolean> = {
|
|
65
|
-
operation: Operation.SIGN,
|
|
66
69
|
hasError: false,
|
|
70
|
+
operation: Operation.SIGN,
|
|
71
|
+
signingMethod: message.method,
|
|
72
|
+
traceId,
|
|
67
73
|
}
|
|
68
74
|
try {
|
|
69
75
|
const eip155Address = await this.keychain.getEip155Address()
|
|
@@ -107,6 +113,8 @@ class MpcSigner implements Signer {
|
|
|
107
113
|
curve,
|
|
108
114
|
chainId,
|
|
109
115
|
isRaw,
|
|
116
|
+
reqId: traceId,
|
|
117
|
+
connectionTracingEnabled: shouldSendMetrics,
|
|
110
118
|
}
|
|
111
119
|
|
|
112
120
|
const stringifiedMetadata = JSON.stringify(metadata)
|
|
@@ -160,11 +168,24 @@ class MpcSigner implements Signer {
|
|
|
160
168
|
|
|
161
169
|
// Add binary metrics to our metrics object
|
|
162
170
|
if (meta?.metrics) {
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
const binaryMetrics = meta.metrics
|
|
172
|
+
if (binaryMetrics.wsConnectDurationMs) {
|
|
173
|
+
metrics.sdkBinaryWSConnectMs = binaryMetrics.wsConnectDurationMs
|
|
174
|
+
}
|
|
175
|
+
if (binaryMetrics.operationDurationMs) {
|
|
176
|
+
metrics.sdkBinaryOperationMs = binaryMetrics.operationDurationMs
|
|
177
|
+
}
|
|
178
|
+
if (binaryMetrics.tlsHandshakeMs) {
|
|
179
|
+
metrics.sdkBinaryTlsHandshakeMs = binaryMetrics.tlsHandshakeMs
|
|
165
180
|
}
|
|
166
|
-
if (
|
|
167
|
-
metrics.
|
|
181
|
+
if (binaryMetrics.firstResponseMs) {
|
|
182
|
+
metrics.sdkBinaryFirstResponseMs = binaryMetrics.firstResponseMs
|
|
183
|
+
}
|
|
184
|
+
if (binaryMetrics.dnsLookupMs) {
|
|
185
|
+
metrics.sdkBinaryDnsLookupMs = binaryMetrics.dnsLookupMs
|
|
186
|
+
}
|
|
187
|
+
if (binaryMetrics.connectMs) {
|
|
188
|
+
metrics.sdkBinaryConnectMs = binaryMetrics.connectMs
|
|
168
189
|
}
|
|
169
190
|
}
|
|
170
191
|
|
|
@@ -182,7 +203,7 @@ class MpcSigner implements Signer {
|
|
|
182
203
|
if (shouldSendMetrics && this.portalApi) {
|
|
183
204
|
try {
|
|
184
205
|
await this.sendMetrics(metrics, apiKey)
|
|
185
|
-
} catch {
|
|
206
|
+
} catch (err) {
|
|
186
207
|
// No-op
|
|
187
208
|
}
|
|
188
209
|
}
|
package/types.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export interface PortalMobileMpcMetadata {
|
|
|
45
45
|
mpcServerVersion: string
|
|
46
46
|
optimized: true
|
|
47
47
|
isRaw?: boolean
|
|
48
|
+
reqId?: string
|
|
49
|
+
connectionTracingEnabled?: boolean
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export interface PortalMobileMpc {
|
|
@@ -128,6 +130,10 @@ export interface SigningResponse {
|
|
|
128
130
|
metrics?: {
|
|
129
131
|
wsConnectDurationMs?: number
|
|
130
132
|
operationDurationMs?: number
|
|
133
|
+
tlsHandshakeMs?: number
|
|
134
|
+
firstResponseMs?: number
|
|
135
|
+
dnsLookupMs?: number
|
|
136
|
+
connectMs?: number
|
|
131
137
|
}
|
|
132
138
|
}
|
|
133
139
|
}
|