@portal-hq/provider 4.1.4 → 4.1.5

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.
@@ -107,17 +107,24 @@ class EnclaveSigner {
107
107
  reqId: traceId,
108
108
  connectionTracingEnabled: shouldSendMetrics,
109
109
  };
110
+ // Build params
111
+ // Avoid double JSON encoding: if params is already a string (e.g. a hex message), pass it directly; otherwise stringify objects/arrays.
112
+ const params = this.buildParams(method, message.params);
110
113
  let formattedParams;
111
- let rpcUrl;
112
114
  if (isRaw) {
113
- formattedParams = JSON.stringify(this.buildParams(method, message.params));
114
- rpcUrl = '';
115
- metrics.operation = Operation.RAW_SIGN;
115
+ if (typeof params !== 'string') {
116
+ throw new Error('[Portal.Provider.EnclaveSigner] For raw signing, params must be a string (e.g., a hex-encoded message).');
117
+ }
118
+ formattedParams = params;
116
119
  }
117
120
  else {
118
- formattedParams = JSON.stringify(this.buildParams(method, message.params));
119
- rpcUrl = provider.getGatewayUrl(chainId);
121
+ formattedParams =
122
+ typeof params === 'string' ? params : JSON.stringify(params);
120
123
  }
124
+ // Get RPC URL
125
+ const rpcUrl = isRaw ? '' : provider.getGatewayUrl(chainId);
126
+ // Set metrics operation
127
+ metrics.operation = isRaw ? Operation.RAW_SIGN : Operation.SIGN;
121
128
  if (typeof formattedParams !== 'string') {
122
129
  throw new Error(`[Portal.Provider.EnclaveSigner] The formatted params for the signing request could not be converted to a string. The params were: ${formattedParams}`);
123
130
  }
@@ -102,17 +102,24 @@ class EnclaveSigner {
102
102
  reqId: traceId,
103
103
  connectionTracingEnabled: shouldSendMetrics,
104
104
  };
105
+ // Build params
106
+ // Avoid double JSON encoding: if params is already a string (e.g. a hex message), pass it directly; otherwise stringify objects/arrays.
107
+ const params = this.buildParams(method, message.params);
105
108
  let formattedParams;
106
- let rpcUrl;
107
109
  if (isRaw) {
108
- formattedParams = JSON.stringify(this.buildParams(method, message.params));
109
- rpcUrl = '';
110
- metrics.operation = Operation.RAW_SIGN;
110
+ if (typeof params !== 'string') {
111
+ throw new Error('[Portal.Provider.EnclaveSigner] For raw signing, params must be a string (e.g., a hex-encoded message).');
112
+ }
113
+ formattedParams = params;
111
114
  }
112
115
  else {
113
- formattedParams = JSON.stringify(this.buildParams(method, message.params));
114
- rpcUrl = provider.getGatewayUrl(chainId);
116
+ formattedParams =
117
+ typeof params === 'string' ? params : JSON.stringify(params);
115
118
  }
119
+ // Get RPC URL
120
+ const rpcUrl = isRaw ? '' : provider.getGatewayUrl(chainId);
121
+ // Set metrics operation
122
+ metrics.operation = isRaw ? Operation.RAW_SIGN : Operation.SIGN;
116
123
  if (typeof formattedParams !== 'string') {
117
124
  throw new Error(`[Portal.Provider.EnclaveSigner] The formatted params for the signing request could not be converted to a string. The params were: ${formattedParams}`);
118
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portal-hq/provider",
3
- "version": "4.1.4",
3
+ "version": "4.1.5",
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": "^4.1.4",
23
- "@portal-hq/utils": "^4.1.4",
22
+ "@portal-hq/connect": "^4.1.5",
23
+ "@portal-hq/utils": "^4.1.5",
24
24
  "@types/react-native-uuid": "^2.0.0",
25
25
  "react-native-uuid": "^2.0.3"
26
26
  },
@@ -32,5 +32,5 @@
32
32
  "ts-jest": "^29.0.3",
33
33
  "typescript": "^4.8.4"
34
34
  },
35
- "gitHead": "6507173bd858f430a4144bd9e700878a879cf286"
35
+ "gitHead": "5ba19390f12935fc74b6235a4b2655a1e1c7a07f"
36
36
  }
@@ -112,22 +112,29 @@ class EnclaveSigner implements Signer {
112
112
  connectionTracingEnabled: shouldSendMetrics,
113
113
  }
114
114
 
115
+ // Build params
116
+ // Avoid double JSON encoding: if params is already a string (e.g. a hex message), pass it directly; otherwise stringify objects/arrays.
117
+ const params = this.buildParams(method, message.params)
115
118
  let formattedParams: string
116
- let rpcUrl: string
117
119
 
118
120
  if (isRaw) {
119
- formattedParams = JSON.stringify(
120
- this.buildParams(method, message.params),
121
- )
122
- rpcUrl = ''
123
- metrics.operation = Operation.RAW_SIGN
121
+ if (typeof params !== 'string') {
122
+ throw new Error(
123
+ '[Portal.Provider.EnclaveSigner] For raw signing, params must be a string (e.g., a hex-encoded message).',
124
+ )
125
+ }
126
+ formattedParams = params
124
127
  } else {
125
- formattedParams = JSON.stringify(
126
- this.buildParams(method, message.params),
127
- )
128
- rpcUrl = provider.getGatewayUrl(chainId)
128
+ formattedParams =
129
+ typeof params === 'string' ? params : JSON.stringify(params)
129
130
  }
130
131
 
132
+ // Get RPC URL
133
+ const rpcUrl = isRaw ? '' : provider.getGatewayUrl(chainId)
134
+
135
+ // Set metrics operation
136
+ metrics.operation = isRaw ? Operation.RAW_SIGN : Operation.SIGN
137
+
131
138
  if (typeof formattedParams !== 'string') {
132
139
  throw new Error(
133
140
  `[Portal.Provider.EnclaveSigner] The formatted params for the signing request could not be converted to a string. The params were: ${formattedParams}`,