@ledgerhq/live-common 34.52.0-nightly.20251101023821 → 34.52.0-nightly.20251105023815
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/__tests__/test-helpers/setup.js +3 -5
- package/lib/__tests__/test-helpers/setup.js.map +1 -1
- package/lib/api/ofacGeoBlockApi.d.ts +4 -0
- package/lib/api/ofacGeoBlockApi.d.ts.map +1 -0
- package/lib/api/ofacGeoBlockApi.js +21 -0
- package/lib/api/ofacGeoBlockApi.js.map +1 -0
- package/lib/apps/config.d.ts.map +1 -1
- package/lib/apps/config.js +1 -0
- package/lib/apps/config.js.map +1 -1
- package/lib/e2e/index.d.ts +2 -6
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.js +1 -1
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/families/tron/data.mock.d.ts.map +1 -1
- package/lib/families/tron/data.mock.js +1 -0
- package/lib/families/tron/data.mock.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +1 -3
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/utils/addressUtils.d.ts +15 -0
- package/lib/utils/addressUtils.d.ts.map +1 -0
- package/lib/utils/addressUtils.js +39 -0
- package/lib/utils/addressUtils.js.map +1 -0
- package/lib-es/__tests__/test-helpers/setup.js +3 -5
- package/lib-es/__tests__/test-helpers/setup.js.map +1 -1
- package/lib-es/api/ofacGeoBlockApi.d.ts +4 -0
- package/lib-es/api/ofacGeoBlockApi.d.ts.map +1 -0
- package/lib-es/api/ofacGeoBlockApi.js +18 -0
- package/lib-es/api/ofacGeoBlockApi.js.map +1 -0
- package/lib-es/apps/config.d.ts.map +1 -1
- package/lib-es/apps/config.js +1 -0
- package/lib-es/apps/config.js.map +1 -1
- package/lib-es/e2e/index.d.ts +2 -6
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +1 -1
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/families/tron/data.mock.d.ts.map +1 -1
- package/lib-es/families/tron/data.mock.js +1 -0
- package/lib-es/families/tron/data.mock.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +1 -3
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/utils/addressUtils.d.ts +15 -0
- package/lib-es/utils/addressUtils.d.ts.map +1 -0
- package/lib-es/utils/addressUtils.js +35 -0
- package/lib-es/utils/addressUtils.js.map +1 -0
- package/package.json +72 -72
- package/src/DataModel.test.ts +1 -0
- package/src/__tests__/test-helpers/setup.ts +3 -6
- package/src/api/ofacGeoBlockApi.ts +19 -0
- package/src/apps/config.ts +1 -0
- package/src/deposit/deposit.integration.test.ts +15 -0
- package/src/e2e/speculos.ts +1 -1
- package/src/families/tron/data.mock.ts +1 -0
- package/src/featureFlags/defaultFeatures.ts +1 -3
- package/src/utils/__tests__/addressUtils.test.ts +229 -0
- package/src/utils/addressUtils.ts +40 -0
- package/lib/hooks/useOFACGeoBlockCheck.d.ts +0 -8
- package/lib/hooks/useOFACGeoBlockCheck.d.ts.map +0 -1
- package/lib/hooks/useOFACGeoBlockCheck.js +0 -32
- package/lib/hooks/useOFACGeoBlockCheck.js.map +0 -1
- package/lib-es/hooks/useOFACGeoBlockCheck.d.ts +0 -8
- package/lib-es/hooks/useOFACGeoBlockCheck.d.ts.map +0 -1
- package/lib-es/hooks/useOFACGeoBlockCheck.js +0 -28
- package/lib-es/hooks/useOFACGeoBlockCheck.js.map +0 -1
- package/src/hooks/useOFACGeoBlockCheck.ts +0 -37
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { addressSplit } from "../addressUtils";
|
|
2
|
+
|
|
3
|
+
describe("addressSplit", () => {
|
|
4
|
+
describe("Basic functionality", () => {
|
|
5
|
+
it("should split a simple address correctly", () => {
|
|
6
|
+
const result = addressSplit("HelloWorld", 2);
|
|
7
|
+
expect(result).toEqual({
|
|
8
|
+
start: "He",
|
|
9
|
+
middle: "lloWor",
|
|
10
|
+
end: "ld",
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should split a longer address with size 4", () => {
|
|
15
|
+
const result = addressSplit("0x1234567890abcdef", 4);
|
|
16
|
+
expect(result).toEqual({
|
|
17
|
+
start: "0x12",
|
|
18
|
+
middle: "34567890ab",
|
|
19
|
+
end: "cdef",
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("Boundary conditions", () => {
|
|
25
|
+
it("should handle exact boundary where size * 2 equals address length", () => {
|
|
26
|
+
const result = addressSplit("ABCDEF", 3);
|
|
27
|
+
expect(result).toEqual({
|
|
28
|
+
start: "ABC",
|
|
29
|
+
middle: "",
|
|
30
|
+
end: "DEF",
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should handle size equal to half address length", () => {
|
|
35
|
+
const result = addressSplit("ABCDEFGH", 4);
|
|
36
|
+
expect(result).toEqual({
|
|
37
|
+
start: "ABCD",
|
|
38
|
+
middle: "",
|
|
39
|
+
end: "EFGH",
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should handle odd-length address with equal split", () => {
|
|
44
|
+
const result = addressSplit("ABCDE", 2);
|
|
45
|
+
expect(result).toEqual({
|
|
46
|
+
start: "AB",
|
|
47
|
+
middle: "C",
|
|
48
|
+
end: "DE",
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should handle very long address", () => {
|
|
53
|
+
const longAddress = "A".repeat(1000);
|
|
54
|
+
const result = addressSplit(longAddress, 10);
|
|
55
|
+
expect(result).toEqual({
|
|
56
|
+
start: "A".repeat(10),
|
|
57
|
+
middle: "A".repeat(980),
|
|
58
|
+
end: "A".repeat(10),
|
|
59
|
+
});
|
|
60
|
+
expect(result.start.length + result.middle.length + result.end.length).toBe(1000);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe("Edge cases - size variations", () => {
|
|
65
|
+
it("should handle size of 0", () => {
|
|
66
|
+
const result = addressSplit("HelloWorld", 0);
|
|
67
|
+
expect(result).toEqual({
|
|
68
|
+
start: "",
|
|
69
|
+
middle: "HelloWorld",
|
|
70
|
+
end: "",
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should handle size of 1", () => {
|
|
75
|
+
const result = addressSplit("HelloWorld", 1);
|
|
76
|
+
expect(result).toEqual({
|
|
77
|
+
start: "H",
|
|
78
|
+
middle: "elloWorl",
|
|
79
|
+
end: "d",
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should handle negative size", () => {
|
|
84
|
+
const result = addressSplit("HelloWorld", -5);
|
|
85
|
+
expect(result).toEqual({
|
|
86
|
+
start: "",
|
|
87
|
+
middle: "HelloWorld",
|
|
88
|
+
end: "",
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("should handle size larger than half the address length", () => {
|
|
93
|
+
const result = addressSplit("Hello", 3);
|
|
94
|
+
expect(result).toEqual({
|
|
95
|
+
start: "He",
|
|
96
|
+
middle: "",
|
|
97
|
+
end: "llo",
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should handle size equal to address length", () => {
|
|
102
|
+
const result = addressSplit("Hello", 5);
|
|
103
|
+
expect(result).toEqual({
|
|
104
|
+
start: "He",
|
|
105
|
+
middle: "",
|
|
106
|
+
end: "llo",
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("should handle size larger than address length", () => {
|
|
111
|
+
const result = addressSplit("Hello", 10);
|
|
112
|
+
expect(result).toEqual({
|
|
113
|
+
start: "He",
|
|
114
|
+
middle: "",
|
|
115
|
+
end: "llo",
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("Edge cases - address variations", () => {
|
|
121
|
+
it("should handle empty string", () => {
|
|
122
|
+
const result = addressSplit("", 2);
|
|
123
|
+
expect(result).toEqual({
|
|
124
|
+
start: "",
|
|
125
|
+
middle: "",
|
|
126
|
+
end: "",
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("should handle single character address", () => {
|
|
131
|
+
const result = addressSplit("A", 1);
|
|
132
|
+
expect(result).toEqual({
|
|
133
|
+
start: "",
|
|
134
|
+
middle: "",
|
|
135
|
+
end: "A",
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("should handle two character address", () => {
|
|
140
|
+
const result = addressSplit("AB", 1);
|
|
141
|
+
expect(result).toEqual({
|
|
142
|
+
start: "A",
|
|
143
|
+
middle: "",
|
|
144
|
+
end: "B",
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("should handle three character address with size 1", () => {
|
|
149
|
+
const result = addressSplit("ABC", 1);
|
|
150
|
+
expect(result).toEqual({
|
|
151
|
+
start: "A",
|
|
152
|
+
middle: "B",
|
|
153
|
+
end: "C",
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe("Real-world cryptocurrency addresses", () => {
|
|
159
|
+
it("should split a Bitcoin address correctly", () => {
|
|
160
|
+
const bitcoinAddress = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";
|
|
161
|
+
const result = addressSplit(bitcoinAddress, 5);
|
|
162
|
+
expect(result).toEqual({
|
|
163
|
+
start: "1A1zP",
|
|
164
|
+
middle: "1eP5QGefi2DMPTfTL5SLmv7D",
|
|
165
|
+
end: "ivfNa",
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("should split an Ethereum address correctly", () => {
|
|
170
|
+
const ethAddress = "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb";
|
|
171
|
+
const result = addressSplit(ethAddress, 6);
|
|
172
|
+
expect(result).toEqual({
|
|
173
|
+
start: "0x742d",
|
|
174
|
+
middle: "35Cc6634C0532925a3b844Bc9e759",
|
|
175
|
+
end: "5f0bEb",
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("should handle a Solana address", () => {
|
|
180
|
+
const solanaAddress = "7EqQdEULxWcraVx3mXKFjc84LhCkMGZCkRuDpvcMwJeK";
|
|
181
|
+
const result = addressSplit(solanaAddress, 4);
|
|
182
|
+
expect(result).toEqual({
|
|
183
|
+
start: "7EqQ",
|
|
184
|
+
middle: "dEULxWcraVx3mXKFjc84LhCkMGZCkRuDpvcM",
|
|
185
|
+
end: "wJeK",
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("should handle a Polkadot address", () => {
|
|
190
|
+
const polkadotAddress = "15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5";
|
|
191
|
+
const result = addressSplit(polkadotAddress, 6);
|
|
192
|
+
expect(result).toEqual({
|
|
193
|
+
start: "15oF4u",
|
|
194
|
+
middle: "VJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMN",
|
|
195
|
+
end: "Hr6Sp5",
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("should handle a Cardano address", () => {
|
|
200
|
+
const cardanoAddress =
|
|
201
|
+
"addr1qxy3w7depgr3wle7kqwzz8u4h5f6gxqe9q0rk8w3n0d7wqxqk0n7n8s3w3w3w3w3w3w3w3w3w3w3w3w3w3w";
|
|
202
|
+
const result = addressSplit(cardanoAddress, 8);
|
|
203
|
+
expect(result).toEqual({
|
|
204
|
+
start: "addr1qxy",
|
|
205
|
+
middle: "3w7depgr3wle7kqwzz8u4h5f6gxqe9q0rk8w3n0d7wqxqk0n7n8s3w3w3w3w3w3w3w3w3w3w",
|
|
206
|
+
end: "3w3w3w3w",
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("should handle a Near protocol address", () => {
|
|
211
|
+
const nearAddress = "alice.near";
|
|
212
|
+
const result = addressSplit(nearAddress, 3);
|
|
213
|
+
expect(result).toEqual({
|
|
214
|
+
start: "ali",
|
|
215
|
+
middle: "ce.n",
|
|
216
|
+
end: "ear",
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
describe("Data integrity", () => {
|
|
222
|
+
it("should preserve the entire address when concatenated", () => {
|
|
223
|
+
const address = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";
|
|
224
|
+
const result = addressSplit(address, 5);
|
|
225
|
+
const reconstructed = result.start + result.middle + result.end;
|
|
226
|
+
expect(reconstructed).toBe(address);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split an address into start, middle, and end sections
|
|
3
|
+
*
|
|
4
|
+
* @param address - The address string to split
|
|
5
|
+
* @param size - The number of characters to include in the start and end sections
|
|
6
|
+
* @returns An object containing the start, middle, and end portions of the address
|
|
7
|
+
* @example
|
|
8
|
+
* addressSplit("HelloWorld", 2) // => { start: "He", middle: "lloWor", end: "ld" }
|
|
9
|
+
*/
|
|
10
|
+
export function addressSplit(
|
|
11
|
+
address: string,
|
|
12
|
+
size: number,
|
|
13
|
+
): { start: string; middle: string; end: string } {
|
|
14
|
+
if (!address) {
|
|
15
|
+
return { start: "", middle: "", end: "" };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (size < 0) {
|
|
19
|
+
return { start: "", middle: address, end: "" };
|
|
20
|
+
} else if (size === 0) {
|
|
21
|
+
return { start: "", middle: address, end: "" };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Handle edge case of address length smaller than or equal to size * 2
|
|
25
|
+
// In this case, we can't extract both start and end without overlapping
|
|
26
|
+
if (address.length <= size * 2) {
|
|
27
|
+
const halfLength = Math.floor(address.length / 2);
|
|
28
|
+
return {
|
|
29
|
+
start: address.slice(0, halfLength),
|
|
30
|
+
middle: "",
|
|
31
|
+
end: address.slice(halfLength),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const start = address.slice(0, size);
|
|
36
|
+
const end = address.slice(-size);
|
|
37
|
+
const middle = address.slice(size, -size);
|
|
38
|
+
|
|
39
|
+
return { start, middle, end };
|
|
40
|
+
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const useOFACGeoBlockCheck: ({ onFinish, geoBlockingFeatureFlagKey, }: {
|
|
2
|
-
onFinish?: (() => void) | undefined;
|
|
3
|
-
geoBlockingFeatureFlagKey: "llmOfacGeoBlocking" | "lldOfacGeoBlocking";
|
|
4
|
-
}) => {
|
|
5
|
-
blocked: boolean;
|
|
6
|
-
isLoading: boolean;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=useOFACGeoBlockCheck.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOFACGeoBlockCheck.d.ts","sourceRoot":"","sources":["../../src/hooks/useOFACGeoBlockCheck.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,oBAAoB;sBAId,IAAI;+BACM,oBAAoB,GAAG,oBAAoB;;;;CAwBvE,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useOFACGeoBlockCheck = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const featureFlags_1 = require("../featureFlags");
|
|
6
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
7
|
-
const live_env_1 = require("@ledgerhq/live-env");
|
|
8
|
-
const baseURL = () => (0, live_env_1.getEnv)("LEDGER_COUNTERVALUES_API");
|
|
9
|
-
const useOFACGeoBlockCheck = ({ onFinish, geoBlockingFeatureFlagKey, }) => {
|
|
10
|
-
const [blocked, setBlocked] = (0, react_1.useState)(false);
|
|
11
|
-
const platformOfacGeoBlocking = (0, featureFlags_1.useFeature)(geoBlockingFeatureFlagKey);
|
|
12
|
-
const { data, isLoading } = (0, react_query_1.useQuery)({
|
|
13
|
-
queryKey: ["ofac-geo-block", geoBlockingFeatureFlagKey],
|
|
14
|
-
queryFn: async () => {
|
|
15
|
-
if (!platformOfacGeoBlocking?.enabled)
|
|
16
|
-
return false;
|
|
17
|
-
const res = await fetch(`${baseURL()}/v3/markets`);
|
|
18
|
-
return res.status === 451;
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
(0, react_1.useEffect)(() => {
|
|
22
|
-
if (!platformOfacGeoBlocking?.enabled)
|
|
23
|
-
return;
|
|
24
|
-
setBlocked(data ?? false);
|
|
25
|
-
if (typeof onFinish === "function") {
|
|
26
|
-
onFinish();
|
|
27
|
-
}
|
|
28
|
-
}, [data, onFinish, platformOfacGeoBlocking]);
|
|
29
|
-
return { blocked, isLoading };
|
|
30
|
-
};
|
|
31
|
-
exports.useOFACGeoBlockCheck = useOFACGeoBlockCheck;
|
|
32
|
-
//# sourceMappingURL=useOFACGeoBlockCheck.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOFACGeoBlockCheck.js","sourceRoot":"","sources":["../../src/hooks/useOFACGeoBlockCheck.ts"],"names":[],"mappings":";;;AAAA,iCAA4C;AAC5C,kDAA6C;AAC7C,uDAAiD;AACjD,iDAA4C;AAE5C,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAA,iBAAM,EAAC,0BAA0B,CAAC,CAAC;AAElD,MAAM,oBAAoB,GAAG,CAAC,EACnC,QAAQ,EACR,yBAAyB,GAI1B,EAAE,EAAE;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IAEvD,MAAM,uBAAuB,GAAG,IAAA,yBAAU,EAAC,yBAAyB,CAAC,CAAC;IAEtE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAA,sBAAQ,EAAC;QACnC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,yBAAyB,CAAC;QACvD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,uBAAuB,EAAE,OAAO;gBAAE,OAAO,KAAK,CAAC;YACpD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC;QAC5B,CAAC;KACF,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,uBAAuB,EAAE,OAAO;YAAE,OAAO;QAC9C,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;QAC1B,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YAClC,QAAQ,EAAE,CAAC;SACZ;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAE9C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC,CAAC;AA7BW,QAAA,oBAAoB,wBA6B/B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const useOFACGeoBlockCheck: ({ onFinish, geoBlockingFeatureFlagKey, }: {
|
|
2
|
-
onFinish?: (() => void) | undefined;
|
|
3
|
-
geoBlockingFeatureFlagKey: "llmOfacGeoBlocking" | "lldOfacGeoBlocking";
|
|
4
|
-
}) => {
|
|
5
|
-
blocked: boolean;
|
|
6
|
-
isLoading: boolean;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=useOFACGeoBlockCheck.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOFACGeoBlockCheck.d.ts","sourceRoot":"","sources":["../../src/hooks/useOFACGeoBlockCheck.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,oBAAoB;sBAId,IAAI;+BACM,oBAAoB,GAAG,oBAAoB;;;;CAwBvE,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useFeature } from "../featureFlags";
|
|
3
|
-
import { useQuery } from "@tanstack/react-query";
|
|
4
|
-
import { getEnv } from "@ledgerhq/live-env";
|
|
5
|
-
const baseURL = () => getEnv("LEDGER_COUNTERVALUES_API");
|
|
6
|
-
export const useOFACGeoBlockCheck = ({ onFinish, geoBlockingFeatureFlagKey, }) => {
|
|
7
|
-
const [blocked, setBlocked] = useState(false);
|
|
8
|
-
const platformOfacGeoBlocking = useFeature(geoBlockingFeatureFlagKey);
|
|
9
|
-
const { data, isLoading } = useQuery({
|
|
10
|
-
queryKey: ["ofac-geo-block", geoBlockingFeatureFlagKey],
|
|
11
|
-
queryFn: async () => {
|
|
12
|
-
if (!platformOfacGeoBlocking?.enabled)
|
|
13
|
-
return false;
|
|
14
|
-
const res = await fetch(`${baseURL()}/v3/markets`);
|
|
15
|
-
return res.status === 451;
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!platformOfacGeoBlocking?.enabled)
|
|
20
|
-
return;
|
|
21
|
-
setBlocked(data ?? false);
|
|
22
|
-
if (typeof onFinish === "function") {
|
|
23
|
-
onFinish();
|
|
24
|
-
}
|
|
25
|
-
}, [data, onFinish, platformOfacGeoBlocking]);
|
|
26
|
-
return { blocked, isLoading };
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=useOFACGeoBlockCheck.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOFACGeoBlockCheck.js","sourceRoot":"","sources":["../../src/hooks/useOFACGeoBlockCheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACnC,QAAQ,EACR,yBAAyB,GAI1B,EAAE,EAAE;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAEvD,MAAM,uBAAuB,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAC;IAEtE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;QACnC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,yBAAyB,CAAC;QACvD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,uBAAuB,EAAE,OAAO;gBAAE,OAAO,KAAK,CAAC;YACpD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC;QAC5B,CAAC;KACF,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,uBAAuB,EAAE,OAAO;YAAE,OAAO;QAC9C,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;QAC1B,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YAClC,QAAQ,EAAE,CAAC;SACZ;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAE9C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useFeature } from "../featureFlags";
|
|
3
|
-
import { useQuery } from "@tanstack/react-query";
|
|
4
|
-
import { getEnv } from "@ledgerhq/live-env";
|
|
5
|
-
|
|
6
|
-
const baseURL = () => getEnv("LEDGER_COUNTERVALUES_API");
|
|
7
|
-
|
|
8
|
-
export const useOFACGeoBlockCheck = ({
|
|
9
|
-
onFinish,
|
|
10
|
-
geoBlockingFeatureFlagKey,
|
|
11
|
-
}: {
|
|
12
|
-
onFinish?: () => void;
|
|
13
|
-
geoBlockingFeatureFlagKey: "llmOfacGeoBlocking" | "lldOfacGeoBlocking";
|
|
14
|
-
}) => {
|
|
15
|
-
const [blocked, setBlocked] = useState<boolean>(false);
|
|
16
|
-
|
|
17
|
-
const platformOfacGeoBlocking = useFeature(geoBlockingFeatureFlagKey);
|
|
18
|
-
|
|
19
|
-
const { data, isLoading } = useQuery({
|
|
20
|
-
queryKey: ["ofac-geo-block", geoBlockingFeatureFlagKey],
|
|
21
|
-
queryFn: async () => {
|
|
22
|
-
if (!platformOfacGeoBlocking?.enabled) return false;
|
|
23
|
-
const res = await fetch(`${baseURL()}/v3/markets`);
|
|
24
|
-
return res.status === 451;
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (!platformOfacGeoBlocking?.enabled) return;
|
|
30
|
-
setBlocked(data ?? false);
|
|
31
|
-
if (typeof onFinish === "function") {
|
|
32
|
-
onFinish();
|
|
33
|
-
}
|
|
34
|
-
}, [data, onFinish, platformOfacGeoBlocking]);
|
|
35
|
-
|
|
36
|
-
return { blocked, isLoading };
|
|
37
|
-
};
|