-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SWAP] Integrate SPL Token extra calls for AppExchange (#8517)
* feat: add trusted service calls Signed-off-by: Stéphane Prohaszka <[email protected]> * feat: add pki apdu calls Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: add more use case into test Signed-off-by: Stéphane Prohaszka <[email protected]> * feat: add spl token management in swap Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: add test url for services Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: rename integration test Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: move cal and trust services in their own package Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: reorg cal files Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: rename integ test files Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: extract loadPKI apdu to a bolos dedicated package Signed-off-by: Stéphane Prohaszka <[email protected]> * feat: expose different PKIError Signed-off-by: Stéphane Prohaszka <[email protected]> * feat: create dedicated error for loadPKI failure Signed-off-by: Stéphane Prohaszka <[email protected]> * fix: import issue Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: update lock file Signed-off-by: Stéphane Prohaszka <[email protected]> * fix: missing readme info and unit test failure Signed-off-by: Stéphane Prohaszka <[email protected]> * fix: remove unused function Signed-off-by: Stéphane Prohaszka <[email protected]> * fix: remove unused library Signed-off-by: Stéphane Prohaszka <[email protected]> * chore: feedback Signed-off-by: Stéphane Prohaszka <[email protected]> --------- Signed-off-by: Stéphane Prohaszka <[email protected]>
- Loading branch information
1 parent
49bd68b
commit 2673c1d
Showing
47 changed files
with
1,334 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@ledgerhq/hw-bolos": minor | ||
"@ledgerhq/ledger-trust-service": minor | ||
"@ledgerhq/ledger-cal-service": minor | ||
"@ledgerhq/live-common": minor | ||
--- | ||
|
||
Extract Ledger services (CAL and Trust) calls and expose new BOLOS APDU |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { getEnv } from "@ledgerhq/live-env"; | ||
import { getTestProviderInfo, type ExchangeProviderNameAndSignature } from "."; | ||
import { findCurrencyData, getProvidersCDNData, getProvidersData } from "../../cal"; | ||
import calService, { SWAP_DATA_CDN } from "@ledgerhq/ledger-cal-service"; | ||
import { isIntegrationTestEnv } from "../swap/utils/isIntegrationTestEnv"; | ||
|
||
export type SwapProviderConfig = { | ||
|
@@ -22,83 +22,6 @@ export type AdditionalProviderConfig = SwapProviderConfig & { type: "DEX" | "CEX | |
|
||
export type ProviderConfig = CEXProviderConfig | DEXProviderConfig; | ||
|
||
export const SWAP_DATA_CDN: Record<string, AdditionalProviderConfig> = { | ||
exodus: { | ||
type: "CEX", | ||
useInExchangeApp: true, | ||
displayName: "Exodus", | ||
termsOfUseUrl: "https://www.exodus.com/terms/", | ||
supportUrl: "mailto:[email protected]", | ||
mainUrl: "https://www.exodus.com/", | ||
needsKYC: false, | ||
version: 2, | ||
}, | ||
changelly: { | ||
type: "CEX", | ||
useInExchangeApp: true, | ||
displayName: "Changelly", | ||
termsOfUseUrl: "https://changelly.com/terms-of-use", | ||
supportUrl: "https://support.changelly.com/en/support/home", | ||
mainUrl: "https://changelly.com/", | ||
needsKYC: false, | ||
}, | ||
cic: { | ||
needsKYC: false, | ||
displayName: "CIC", | ||
type: "CEX", | ||
useInExchangeApp: true, | ||
termsOfUseUrl: "https://criptointercambio.com/terms-of-use", | ||
supportUrl: "https://criptointercambio.com/en/about", | ||
mainUrl: "https://criptointercambio.com/", | ||
}, | ||
moonpay: { | ||
needsKYC: true, | ||
displayName: "MoonPay", | ||
type: "CEX", | ||
useInExchangeApp: true, | ||
termsOfUseUrl: "https://www.moonpay.com/legal/terms_of_use_row", | ||
supportUrl: "https://support.moonpay.com/", | ||
mainUrl: "https://www.moonpay.com/", | ||
}, | ||
oneinch: { | ||
type: "DEX", | ||
needsKYC: false, | ||
useInExchangeApp: false, | ||
displayName: "1inch", | ||
termsOfUseUrl: "https://1inch.io/assets/1inch_network_terms_of_use.pdf", | ||
supportUrl: "https://help.1inch.io/en/", | ||
mainUrl: "https://1inch.io/", | ||
}, | ||
paraswap: { | ||
type: "DEX", | ||
needsKYC: false, | ||
useInExchangeApp: false, | ||
displayName: "Paraswap", | ||
termsOfUseUrl: "https://files.paraswap.io/tos_v4.pdf", | ||
supportUrl: "https://help.paraswap.io/en/", | ||
mainUrl: "https://www.paraswap.io/", | ||
}, | ||
thorswap: { | ||
type: "DEX", | ||
useInExchangeApp: true, | ||
displayName: "THORChain", | ||
termsOfUseUrl: "https://docs.thorswap.finance/thorswap/resources/terms-of-service", | ||
supportUrl: "https://ledgerhelp.swapkit.dev/", | ||
mainUrl: "https://www.thorswap.finance/", | ||
needsKYC: false, | ||
}, | ||
uniswap: { | ||
type: "DEX", | ||
useInExchangeApp: false, | ||
displayName: "Uniswap", | ||
termsOfUseUrl: | ||
"https://support.uniswap.org/hc/en-us/articles/30935100859661-Uniswap-Labs-Terms-of-Service", | ||
supportUrl: "mailto:[email protected]", | ||
mainUrl: "https://uniswap.org/", | ||
needsKYC: false, | ||
}, | ||
}; | ||
|
||
const DEFAULT_SWAP_PROVIDERS: Record<string, ProviderConfig & Partial<AdditionalProviderConfig>> = { | ||
changelly: { | ||
name: "Changelly", | ||
|
@@ -265,7 +188,7 @@ export const getSwapProvider = async ( | |
* @deprecated Use cal module `findCurrencyData` method. | ||
*/ | ||
export const findExchangeCurrencyData = async (currencyId: string): Promise<CurrencyData> => | ||
findCurrencyData(currencyId); | ||
calService.findCurrencyData(currencyId); | ||
|
||
export const fetchAndMergeProviderData = async env => { | ||
if (providerDataCache) { | ||
|
@@ -274,8 +197,8 @@ export const fetchAndMergeProviderData = async env => { | |
|
||
try { | ||
const [providersData, providersExtraData] = await Promise.all([ | ||
getProvidersData({ type: "swap", ...env }), | ||
getProvidersCDNData(), | ||
calService.getProvidersData({ type: "swap", ...env }), | ||
calService.getProvidersCDNData(), | ||
]); | ||
const finalProvidersData = mergeProviderData(providersData, providersExtraData); | ||
providerDataCache = finalProvidersData; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["src/**/*.test.ts"], | ||
env: { | ||
"jest/globals": true, | ||
}, | ||
plugins: ["jest"], | ||
}, | ||
], | ||
rules: { | ||
"no-console": ["error", { allow: ["warn", "error"] }], | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-explicit-any": "warn", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
// `workerThreads: true` is required for validating object with `bigint` values | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
testPathIgnorePatterns: ["lib/", "lib-es/", ".*\\.integ\\.test\\.[tj]s"], | ||
workerThreads: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
testRegex: ".integ.test.ts$", | ||
testPathIgnorePatterns: ["lib/", "lib-es/"], | ||
setupFiles: ["dotenv/config"], | ||
}; |
Oops, something went wrong.