@portal-hq/webview 4.2.9 → 4.2.13
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/index.js +5 -4
- package/lib/esm/index.js +5 -4
- package/package.json +5 -5
- package/src/index.tsx +5 -4
package/lib/commonjs/index.js
CHANGED
|
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
// Relative modules.
|
|
40
40
|
const core_1 = require("@portal-hq/core");
|
|
41
41
|
const injected_provider_1 = require("@portal-hq/injected-provider");
|
|
42
|
+
const utils_1 = require("@portal-hq/utils");
|
|
42
43
|
const react_1 = __importStar(require("react"));
|
|
43
44
|
const react_native_1 = require("react-native");
|
|
44
45
|
const react_native_webview_1 = __importDefault(require("react-native-webview"));
|
|
@@ -55,15 +56,15 @@ const Webview = (0, react_1.memo)((0, react_1.forwardRef)(({ onNavigationStateCh
|
|
|
55
56
|
// Derive state.
|
|
56
57
|
const [currentUrl, setCurrentUrl] = (0, react_1.useState)(url);
|
|
57
58
|
const [walletAddress, setWalletAddress] = (0, react_1.useState)();
|
|
58
|
-
const [chainId, setChainId] = (0, react_1.useState)((_a = portal.chainId) !== null && _a !== void 0 ? _a :
|
|
59
|
+
const [chainId, setChainId] = (0, react_1.useState)((_a = portal.chainId) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_CHAIN_ID_NUMERIC);
|
|
59
60
|
const source = (0, react_1.useMemo)(() => ({
|
|
60
61
|
uri: currentUrl,
|
|
61
62
|
}), [currentUrl]);
|
|
62
63
|
// Filter out "eip155:" from the gateway config.
|
|
63
64
|
const onlyEip155GatewayConfig = {};
|
|
64
65
|
Object.entries(portal.gatewayConfig).forEach(([key, value]) => {
|
|
65
|
-
if (key.startsWith(
|
|
66
|
-
onlyEip155GatewayConfig[key.replace(
|
|
66
|
+
if (key.startsWith(`${utils_1.CHAIN_NAMESPACES.EIP155}:`)) {
|
|
67
|
+
onlyEip155GatewayConfig[key.replace(`${utils_1.CHAIN_NAMESPACES.EIP155}:`, '')] = value;
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
const scriptToInject = (0, injected_provider_1.injectionScript)({
|
|
@@ -98,7 +99,7 @@ const Webview = (0, react_1.memo)((0, react_1.forwardRef)(({ onNavigationStateCh
|
|
|
98
99
|
const { method, params, options } = data;
|
|
99
100
|
switch (type) {
|
|
100
101
|
case 'portal_sign':
|
|
101
|
-
yield portal.request(method, params,
|
|
102
|
+
yield portal.request(method, params, `${utils_1.CHAIN_NAMESPACES.EIP155}:${chainId}`, options);
|
|
102
103
|
break;
|
|
103
104
|
}
|
|
104
105
|
});
|
package/lib/esm/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
// Relative modules.
|
|
12
12
|
import { usePortal } from '@portal-hq/core';
|
|
13
13
|
import { injectionScript, } from '@portal-hq/injected-provider';
|
|
14
|
+
import { CHAIN_NAMESPACES, DEFAULT_CHAIN_ID_NUMERIC } from '@portal-hq/utils';
|
|
14
15
|
import React, { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
15
16
|
import { BackHandler, Platform, StyleSheet, View } from 'react-native';
|
|
16
17
|
import WebView from 'react-native-webview';
|
|
@@ -27,15 +28,15 @@ const Webview = memo(forwardRef(({ onNavigationStateChange, onSigningRequested,
|
|
|
27
28
|
// Derive state.
|
|
28
29
|
const [currentUrl, setCurrentUrl] = useState(url);
|
|
29
30
|
const [walletAddress, setWalletAddress] = useState();
|
|
30
|
-
const [chainId, setChainId] = useState((_a = portal.chainId) !== null && _a !== void 0 ? _a :
|
|
31
|
+
const [chainId, setChainId] = useState((_a = portal.chainId) !== null && _a !== void 0 ? _a : DEFAULT_CHAIN_ID_NUMERIC);
|
|
31
32
|
const source = useMemo(() => ({
|
|
32
33
|
uri: currentUrl,
|
|
33
34
|
}), [currentUrl]);
|
|
34
35
|
// Filter out "eip155:" from the gateway config.
|
|
35
36
|
const onlyEip155GatewayConfig = {};
|
|
36
37
|
Object.entries(portal.gatewayConfig).forEach(([key, value]) => {
|
|
37
|
-
if (key.startsWith(
|
|
38
|
-
onlyEip155GatewayConfig[key.replace(
|
|
38
|
+
if (key.startsWith(`${CHAIN_NAMESPACES.EIP155}:`)) {
|
|
39
|
+
onlyEip155GatewayConfig[key.replace(`${CHAIN_NAMESPACES.EIP155}:`, '')] = value;
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
42
|
const scriptToInject = injectionScript({
|
|
@@ -70,7 +71,7 @@ const Webview = memo(forwardRef(({ onNavigationStateChange, onSigningRequested,
|
|
|
70
71
|
const { method, params, options } = data;
|
|
71
72
|
switch (type) {
|
|
72
73
|
case 'portal_sign':
|
|
73
|
-
yield portal.request(method, params,
|
|
74
|
+
yield portal.request(method, params, `${CHAIN_NAMESPACES.EIP155}:${chainId}`, options);
|
|
74
75
|
break;
|
|
75
76
|
}
|
|
76
77
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/webview",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/esm/index",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"test": "jest --passWithNoTests"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@portal-hq/core": "^4.2.
|
|
22
|
-
"@portal-hq/injected-provider": "^4.2.
|
|
23
|
-
"@portal-hq/utils": "^4.2.
|
|
21
|
+
"@portal-hq/core": "^4.2.13",
|
|
22
|
+
"@portal-hq/injected-provider": "^4.2.13",
|
|
23
|
+
"@portal-hq/utils": "^4.2.13"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/jest": "^29.2.0",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"react-native": "*",
|
|
37
37
|
"react-native-webview": "*"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "cd2865d204185bcfedd02b94487afc46f4922780"
|
|
40
40
|
}
|
package/src/index.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type RequestArguments,
|
|
6
6
|
injectionScript,
|
|
7
7
|
} from '@portal-hq/injected-provider'
|
|
8
|
+
import { CHAIN_NAMESPACES, DEFAULT_CHAIN_ID_NUMERIC } from '@portal-hq/utils'
|
|
8
9
|
import React, {
|
|
9
10
|
FC,
|
|
10
11
|
MutableRefObject,
|
|
@@ -46,7 +47,7 @@ const Webview = memo(
|
|
|
46
47
|
const [currentUrl, setCurrentUrl] = useState<string>(url)
|
|
47
48
|
const [walletAddress, setWalletAddress] = useState<string>()
|
|
48
49
|
const [chainId, setChainId] = useState<number>(
|
|
49
|
-
portal.chainId ??
|
|
50
|
+
portal.chainId ?? DEFAULT_CHAIN_ID_NUMERIC,
|
|
50
51
|
)
|
|
51
52
|
|
|
52
53
|
const source = useMemo(
|
|
@@ -59,8 +60,8 @@ const Webview = memo(
|
|
|
59
60
|
// Filter out "eip155:" from the gateway config.
|
|
60
61
|
const onlyEip155GatewayConfig: typeof portal.gatewayConfig = {}
|
|
61
62
|
Object.entries(portal.gatewayConfig).forEach(([key, value]) => {
|
|
62
|
-
if (key.startsWith(
|
|
63
|
-
onlyEip155GatewayConfig[key.replace(
|
|
63
|
+
if (key.startsWith(`${CHAIN_NAMESPACES.EIP155}:`)) {
|
|
64
|
+
onlyEip155GatewayConfig[key.replace(`${CHAIN_NAMESPACES.EIP155}:`, '')] = value
|
|
64
65
|
}
|
|
65
66
|
})
|
|
66
67
|
|
|
@@ -104,7 +105,7 @@ const Webview = memo(
|
|
|
104
105
|
await portal.request(
|
|
105
106
|
method,
|
|
106
107
|
params as unknown[],
|
|
107
|
-
|
|
108
|
+
`${CHAIN_NAMESPACES.EIP155}:${chainId}`,
|
|
108
109
|
options,
|
|
109
110
|
)
|
|
110
111
|
break
|