@ledgerhq/live-common 34.37.0-next.0 → 34.37.0-next.2
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/bridge.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +4 -0
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/bridge/impl.js +3 -40
- package/lib/bridge/impl.js.map +1 -1
- package/lib/config/index.d.ts +2 -3
- package/lib/config/index.d.ts.map +1 -1
- package/lib/config/index.js +1 -9
- package/lib/config/index.js.map +1 -1
- package/lib/config/sharedConfig.d.ts.map +1 -1
- package/lib/config/sharedConfig.js +0 -7
- package/lib/config/sharedConfig.js.map +1 -1
- package/lib/hw/connectAppEventMapper.d.ts.map +1 -1
- package/lib/hw/connectAppEventMapper.js +4 -4
- package/lib/hw/connectAppEventMapper.js.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +4 -0
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/bridge/impl.js +3 -40
- package/lib-es/bridge/impl.js.map +1 -1
- package/lib-es/config/index.d.ts +2 -3
- package/lib-es/config/index.d.ts.map +1 -1
- package/lib-es/config/index.js +1 -8
- package/lib-es/config/index.js.map +1 -1
- package/lib-es/config/sharedConfig.d.ts.map +1 -1
- package/lib-es/config/sharedConfig.js +0 -7
- package/lib-es/config/sharedConfig.js.map +1 -1
- package/lib-es/hw/connectAppEventMapper.d.ts.map +1 -1
- package/lib-es/hw/connectAppEventMapper.js +5 -5
- package/lib-es/hw/connectAppEventMapper.js.map +1 -1
- package/package.json +9 -9
- package/src/__tests__/test-helpers/bridge.ts +4 -1
- package/src/bridge/impl.ts +5 -64
- package/src/config/index.ts +2 -11
- package/src/config/sharedConfig.ts +0 -8
- package/src/hw/connectAppEventMapper.ts +4 -4
- package/lib/sanction/errors.d.ts +0 -13
- package/lib/sanction/errors.d.ts.map +0 -1
- package/lib/sanction/errors.js +0 -36
- package/lib/sanction/errors.js.map +0 -1
- package/lib/sanction/index.d.ts +0 -3
- package/lib/sanction/index.d.ts.map +0 -1
- package/lib/sanction/index.js +0 -51
- package/lib/sanction/index.js.map +0 -1
- package/lib-es/sanction/errors.d.ts +0 -13
- package/lib-es/sanction/errors.d.ts.map +0 -1
- package/lib-es/sanction/errors.js +0 -29
- package/lib-es/sanction/errors.js.map +0 -1
- package/lib-es/sanction/index.d.ts +0 -3
- package/lib-es/sanction/index.d.ts.map +0 -1
- package/lib-es/sanction/index.js +0 -44
- package/lib-es/sanction/index.js.map +0 -1
- package/src/sanction/errors.ts +0 -31
- package/src/sanction/index.ts +0 -59
package/lib-es/sanction/index.js
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
2
|
-
import axios from "axios";
|
3
|
-
import { hours, makeLRUCache } from "@ledgerhq/live-network/cache";
|
4
|
-
import { getCurrencyConfiguration, getSharedConfiguration } from "../config";
|
5
|
-
const cache = makeLRUCache(fetchSanctionedAddresses, () => "all_sanctioned_addresses", hours(12));
|
6
|
-
async function fetchSanctionedAddresses() {
|
7
|
-
const { data } = await axios.get("https://ofac-compliance.pages.dev/all_sanctioned_addresses.json");
|
8
|
-
return data;
|
9
|
-
}
|
10
|
-
export async function isAddressSanctioned(currency, address) {
|
11
|
-
if (!isCheckBlacklistAddressEnabled(currency)) {
|
12
|
-
return false;
|
13
|
-
}
|
14
|
-
// Only for testing, should be deleted after
|
15
|
-
const temporarySanctionedAddresses = LiveConfig.getValueByKey(`tmp_sanctioned_addresses`);
|
16
|
-
const data = await cache();
|
17
|
-
const addresses = data[currency.ticker] || [];
|
18
|
-
if (temporarySanctionedAddresses) {
|
19
|
-
return addresses.concat(temporarySanctionedAddresses).includes(address);
|
20
|
-
}
|
21
|
-
return addresses.includes(address);
|
22
|
-
}
|
23
|
-
function isCheckBlacklistAddressEnabled(currency) {
|
24
|
-
const currencyConfig = tryGetCurrencyConfig(currency);
|
25
|
-
if (currencyConfig && "checkBlacklistAddress" in currencyConfig) {
|
26
|
-
return currencyConfig.checkBlacklistAddress === true;
|
27
|
-
}
|
28
|
-
else {
|
29
|
-
const sharedConfiguration = getSharedConfiguration();
|
30
|
-
if ("checkBlacklistAddress" in sharedConfiguration) {
|
31
|
-
return sharedConfiguration.checkBlacklistAddress === true;
|
32
|
-
}
|
33
|
-
}
|
34
|
-
return false;
|
35
|
-
}
|
36
|
-
function tryGetCurrencyConfig(currency) {
|
37
|
-
try {
|
38
|
-
return getCurrencyConfiguration(currency);
|
39
|
-
}
|
40
|
-
catch (error) {
|
41
|
-
return undefined;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sanction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAG7E,MAAM,KAAK,GAAG,YAAY,CAAC,wBAAwB,EAAE,GAAG,EAAE,CAAC,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAElG,KAAK,UAAU,wBAAwB;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,GAAG,CAC9B,iEAAiE,CAClE,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAwB,EACxB,OAAe;IAEf,IAAI,CAAC,8BAA8B,CAAC,QAAQ,CAAC,EAAE;QAC7C,OAAO,KAAK,CAAC;KACd;IAED,4CAA4C;IAC5C,MAAM,4BAA4B,GAChC,UAAU,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC;IAEvD,MAAM,IAAI,GAA6B,MAAM,KAAK,EAAE,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAE9C,IAAI,4BAA4B,EAAE;QAChC,OAAO,SAAS,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KACzE;IAED,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,8BAA8B,CAAC,QAAwB;IAC9D,MAAM,cAAc,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,cAAc,IAAI,uBAAuB,IAAI,cAAc,EAAE;QAC/D,OAAO,cAAc,CAAC,qBAAqB,KAAK,IAAI,CAAC;KACtD;SAAM;QACL,MAAM,mBAAmB,GAAG,sBAAsB,EAAE,CAAC;QACrD,IAAI,uBAAuB,IAAI,mBAAmB,EAAE;YAClD,OAAO,mBAAmB,CAAC,qBAAqB,KAAK,IAAI,CAAC;SAC3D;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAwB;IACpD,IAAI;QACF,OAAO,wBAAwB,CAAC,QAAQ,CAAC,CAAC;KAC3C;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,SAAS,CAAC;KAClB;AACH,CAAC"}
|
package/src/sanction/errors.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
export class UserAddressSanctionedError extends Error {
|
2
|
-
constructor() {
|
3
|
-
super();
|
4
|
-
this.message = this.constructor.name;
|
5
|
-
this.name = this.constructor.name;
|
6
|
-
}
|
7
|
-
}
|
8
|
-
|
9
|
-
export class UserAddressSanctionedForSendError extends Error {
|
10
|
-
constructor() {
|
11
|
-
super();
|
12
|
-
this.message = this.constructor.name;
|
13
|
-
this.name = this.constructor.name;
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|
17
|
-
export class UserAddressSanctionedForStakingError extends Error {
|
18
|
-
constructor() {
|
19
|
-
super();
|
20
|
-
this.message = this.constructor.name;
|
21
|
-
this.name = this.constructor.name;
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
export class RecipientAddressSanctionedError extends Error {
|
26
|
-
constructor() {
|
27
|
-
super();
|
28
|
-
this.message = this.constructor.name;
|
29
|
-
this.name = this.constructor.name;
|
30
|
-
}
|
31
|
-
}
|
package/src/sanction/index.ts
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
2
|
-
import axios from "axios";
|
3
|
-
import { hours, makeLRUCache } from "@ledgerhq/live-network/cache";
|
4
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
5
|
-
import { getCurrencyConfiguration, getSharedConfiguration } from "../config";
|
6
|
-
import { CurrencyConfig } from "@ledgerhq/coin-framework/config";
|
7
|
-
|
8
|
-
const cache = makeLRUCache(fetchSanctionedAddresses, () => "all_sanctioned_addresses", hours(12));
|
9
|
-
|
10
|
-
async function fetchSanctionedAddresses(): Promise<Record<string, string[]>> {
|
11
|
-
const { data } = await axios.get(
|
12
|
-
"https://ofac-compliance.pages.dev/all_sanctioned_addresses.json",
|
13
|
-
);
|
14
|
-
return data;
|
15
|
-
}
|
16
|
-
|
17
|
-
export async function isAddressSanctioned(
|
18
|
-
currency: CryptoCurrency,
|
19
|
-
address: string,
|
20
|
-
): Promise<boolean> {
|
21
|
-
if (!isCheckBlacklistAddressEnabled(currency)) {
|
22
|
-
return false;
|
23
|
-
}
|
24
|
-
|
25
|
-
// Only for testing, should be deleted after
|
26
|
-
const temporarySanctionedAddresses: string[] | undefined =
|
27
|
-
LiveConfig.getValueByKey(`tmp_sanctioned_addresses`);
|
28
|
-
|
29
|
-
const data: Record<string, string[]> = await cache();
|
30
|
-
const addresses = data[currency.ticker] || [];
|
31
|
-
|
32
|
-
if (temporarySanctionedAddresses) {
|
33
|
-
return addresses.concat(temporarySanctionedAddresses).includes(address);
|
34
|
-
}
|
35
|
-
|
36
|
-
return addresses.includes(address);
|
37
|
-
}
|
38
|
-
|
39
|
-
function isCheckBlacklistAddressEnabled(currency: CryptoCurrency): boolean {
|
40
|
-
const currencyConfig = tryGetCurrencyConfig(currency);
|
41
|
-
if (currencyConfig && "checkBlacklistAddress" in currencyConfig) {
|
42
|
-
return currencyConfig.checkBlacklistAddress === true;
|
43
|
-
} else {
|
44
|
-
const sharedConfiguration = getSharedConfiguration();
|
45
|
-
if ("checkBlacklistAddress" in sharedConfiguration) {
|
46
|
-
return sharedConfiguration.checkBlacklistAddress === true;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
|
-
return false;
|
51
|
-
}
|
52
|
-
|
53
|
-
function tryGetCurrencyConfig(currency: CryptoCurrency): CurrencyConfig | undefined {
|
54
|
-
try {
|
55
|
-
return getCurrencyConfiguration(currency);
|
56
|
-
} catch (error) {
|
57
|
-
return undefined;
|
58
|
-
}
|
59
|
-
}
|