@0xsquid/react-hooks 6.4.1-beta.5 → 6.4.1-onramp-beta.1

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.
Files changed (38) hide show
  1. package/dist/core/queries/queries-keys.d.ts +1 -1
  2. package/dist/core/queries/queries-keys.js +1 -5
  3. package/dist/core/queries/queries-keys.js.map +1 -1
  4. package/dist/core/types/event.d.ts +8 -0
  5. package/dist/core/types/history.d.ts +1 -0
  6. package/dist/core/types/history.js.map +1 -1
  7. package/dist/core/types/onramps/onramp.d.ts +82 -7
  8. package/dist/hooks/onramp/useFiatToCrypto.d.ts +58 -44
  9. package/dist/hooks/onramp/useFiatToCrypto.js +205 -76
  10. package/dist/hooks/onramp/useFiatToCrypto.js.map +1 -1
  11. package/dist/services/external/index.d.ts +0 -2
  12. package/dist/services/external/index.js +0 -2
  13. package/dist/services/external/index.js.map +1 -1
  14. package/dist/services/external/onrampAdapter.d.ts +12 -0
  15. package/dist/services/external/onrampAdapter.js +41 -0
  16. package/dist/services/external/onrampAdapter.js.map +1 -0
  17. package/dist/services/index.d.ts +1 -0
  18. package/dist/services/index.js +1 -0
  19. package/dist/services/index.js.map +1 -1
  20. package/dist/services/internal/eventService.d.ts +16 -0
  21. package/dist/services/internal/eventService.js +14 -0
  22. package/dist/services/internal/eventService.js.map +1 -1
  23. package/dist/services/internal/fiatToCryptoService.d.ts +1 -14
  24. package/dist/services/internal/fiatToCryptoService.js +0 -29
  25. package/dist/services/internal/fiatToCryptoService.js.map +1 -1
  26. package/package.json +1 -1
  27. package/dist/services/external/baseAdapter.d.ts +0 -31
  28. package/dist/services/external/baseAdapter.js +0 -20
  29. package/dist/services/external/baseAdapter.js.map +0 -1
  30. package/dist/services/external/onramperClientAdapter.d.ts +0 -15
  31. package/dist/services/external/onramperClientAdapter.js +0 -130
  32. package/dist/services/external/onramperClientAdapter.js.map +0 -1
  33. package/dist/services/external/revolutClientAdapter.d.ts +0 -30
  34. package/dist/services/external/revolutClientAdapter.js +0 -195
  35. package/dist/services/external/revolutClientAdapter.js.map +0 -1
  36. package/dist/tests/revolutClientAdapter.test.d.ts +0 -1
  37. package/dist/tests/revolutClientAdapter.test.js +0 -181
  38. package/dist/tests/revolutClientAdapter.test.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fiatToCryptoService.js","sourceRoot":"","sources":["../../../src/services/internal/fiatToCryptoService.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,qBAAqB,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,IAA8B,EAAE;IACjE,IAAI;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,GAAG,CAC9B,GAAG,0BAA0B,UAAU,CACxC,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO;YACL,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,oBAAoB;SAClC,CAAC;KACH;AACH,CAAC,CAAC;AAEF,MAAM,OAAO,mBAAmB;IACtB,QAAQ,CAAwB;IAExC,YAAY,QAA+B;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,QAA8B;QACnD,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,YAAoB,EACpB,gBAAwB,EACxB,MAAc,EACd,gBAAwB,MAAM,EAC9B,SAAiB,oBAAoB;QAErC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK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Y,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAE9B,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAC1C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,YAAY,CACvC,CAAC;IAEF,MAAM,WAAW,GAAG,cAAc,CAAC,YAAY,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;IAEpE,OAAO;QACL,YAAY,EAAE,YAAY;QAC1B,MAAM;QACN,IAAI,EAAE,YAAY,EAAE,IAAI;QACxB,OAAO,EAAE,WAAW,CAAC,OAAO;KAC7B,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"fiatToCryptoService.js","sourceRoot":"","sources":["../../../src/services/internal/fiatToCryptoService.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,qBAAqB,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,IAA8B,EAAE;IACjE,IAAI;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,GAAG,CAC9B,GAAG,0BAA0B,UAAU,CACxC,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO;YACL,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,oBAAoB;SAClC,CAAC;KACH;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,WAAmB;IAChD,MAAM,gBAAgB,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IACnD,MAAM,gBAAgB,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAEnD,OAAO;QACL,GAAG,SAAS,CAAC,gBAA0C,CAAC;QACxD,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,gBAAgB;YACvB,CAAC,CAAC,2BAA2B,gBAAgB,MAAM;YACnD,CAAC,CAAC,EAAE;KACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,YAAoB;IAEpB,MAAM,MAAM,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAE9B,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAC1C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,YAAY,CACvC,CAAC;IAEF,MAAM,WAAW,GAAG,cAAc,CAAC,YAAY,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;IAEpE,OAAO;QACL,YAAY,EAAE,YAAY;QAC1B,MAAM;QACN,IAAI,EAAE,YAAY,EAAE,IAAI;QACxB,OAAO,EAAE,WAAW,CAAC,OAAO;KAC7B,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsquid/react-hooks",
3
- "version": "6.4.1-beta.5",
3
+ "version": "6.4.1-onramp-beta.1",
4
4
  "description": "Squid hooks monorepo",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,31 +0,0 @@
1
- import { ChainData, Token } from "@0xsquid/squid-types";
2
- import { CountryWithCode, ExecuteFiatQuoteResult, ExecuteQuoteClient, FiatCurrencyEnhanced, FiatToCryptoConfig, OnRampQuoteResponse, OnRampTransactionStatus } from "../../core/types/onramps/onramp";
3
- export type ProviderInfo = {
4
- value: string;
5
- key: string;
6
- label: string;
7
- iconUrl: string;
8
- supportedPaymentMethods: readonly string[];
9
- };
10
- export declare abstract class BaseFiatToCryptoAdapter {
11
- abstract readonly key: string;
12
- abstract readonly label: string;
13
- abstract readonly supportedPaymentMethods: readonly string[];
14
- private readonly baseIconUrl;
15
- getInfo(): ProviderInfo;
16
- getCountryData(countryCode: string): CountryWithCode;
17
- getCurrencyData(currencyCode: string): FiatCurrencyEnhanced | undefined;
18
- abstract getQuote(fiatCurrency: string, cryptoCurrencyID: string, amount: number, paymentMethod?: string, region?: string): Promise<OnRampQuoteResponse>;
19
- abstract getTransactionStatus(transactionId: string, walletAddress?: string): Promise<OnRampTransactionStatus>;
20
- abstract executeQuote(executeQuoteRequest: ExecuteQuoteClient): Promise<ExecuteFiatQuoteResult>;
21
- abstract getConfiguration(squidConfig: {
22
- chains: ChainData[];
23
- tokens: Token[];
24
- }): Promise<FiatToCryptoConfig>;
25
- mapPaymentMethod?(method: string): string;
26
- mapConfigResponse?(data: any, squidConfig: {
27
- chains: ChainData[];
28
- tokens: Token[];
29
- }): FiatToCryptoConfig;
30
- mapQuoteResponse?(data: any, fiatCurrency: string, cryptoCurrencyID: string, originalAmount: number): OnRampQuoteResponse;
31
- }
@@ -1,20 +0,0 @@
1
- import { getCountryData, getCurrencyData, } from "../internal/fiatToCryptoService";
2
- export class BaseFiatToCryptoAdapter {
3
- baseIconUrl = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/onramps";
4
- getInfo() {
5
- return {
6
- value: this.key,
7
- key: this.key,
8
- label: this.label,
9
- supportedPaymentMethods: this.supportedPaymentMethods,
10
- iconUrl: `${this.baseIconUrl}/${this.key}.webp`,
11
- };
12
- }
13
- getCountryData(countryCode) {
14
- return getCountryData(countryCode);
15
- }
16
- getCurrencyData(currencyCode) {
17
- return getCurrencyData(currencyCode);
18
- }
19
- }
20
- //# sourceMappingURL=baseAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseAdapter.js","sourceRoot":"","sources":["../../../src/services/external/baseAdapter.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,cAAc,EACd,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAUzC,MAAM,OAAgB,uBAAuB;IAO1B,WAAW,GAC1B,8EAA8E,CAAC;IAEjF,OAAO;QACL,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,GAAG;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,OAAO,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,GAAG,OAAO;SAChD,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,WAAmB;QAChC,OAAO,cAAc,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;IAED,eAAe,CAAC,YAAoB;QAClC,OAAO,eAAe,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CAsCF"}
@@ -1,15 +0,0 @@
1
- import { ExecuteFiatQuoteResult, ExecuteQuoteClient, FiatToCryptoConfig, OnRampQuoteResponse, OnRampTransactionStatus } from "../../core/types/onramps/onramp";
2
- import { BaseFiatToCryptoAdapter } from "./baseAdapter";
3
- export declare class OnramperAdapter extends BaseFiatToCryptoAdapter {
4
- readonly key = "onramper";
5
- readonly label = "Onramper";
6
- readonly supportedPaymentMethods: readonly ["credit_card", "bank_transfer"];
7
- private readonly baseUrl;
8
- private readonly apiKey;
9
- private getHeaders;
10
- getQuote(fiatCurrency: string, cryptoCurrency: string, amount: number): Promise<OnRampQuoteResponse>;
11
- getTransactionStatus(transactionId: string): Promise<OnRampTransactionStatus>;
12
- executeQuote(executeQuoteRequest: ExecuteQuoteClient): Promise<ExecuteFiatQuoteResult>;
13
- private getCryptoNetwork;
14
- getConfiguration(): Promise<FiatToCryptoConfig>;
15
- }
@@ -1,130 +0,0 @@
1
- import axios from "axios";
2
- import { BaseFiatToCryptoAdapter } from "./baseAdapter";
3
- export class OnramperAdapter extends BaseFiatToCryptoAdapter {
4
- key = "onramper";
5
- label = "Onramper";
6
- supportedPaymentMethods = ["credit_card", "bank_transfer"];
7
- baseUrl = "https://api.onramper.com";
8
- apiKey = "ONRAMPER_API_KEY";
9
- getHeaders() {
10
- return {
11
- Authorization: this.apiKey,
12
- "Content-Type": "application/json",
13
- };
14
- }
15
- async getQuote(fiatCurrency, cryptoCurrency, amount) {
16
- try {
17
- const { data } = await axios.get(`${this.baseUrl}/quotes/${fiatCurrency.toLowerCase()}/${cryptoCurrency.toLowerCase()}`, {
18
- params: {
19
- amount,
20
- paymentMethod: "creditcard",
21
- },
22
- headers: this.getHeaders(),
23
- });
24
- // Get the best quote from available options
25
- const bestQuote = data[0];
26
- if (!bestQuote) {
27
- throw new Error("No quotes available from Onramper");
28
- }
29
- const totalFees = bestQuote.networkFee + bestQuote.transactionFee;
30
- const percentageFee = (totalFees / amount) * 100;
31
- return {
32
- fiatCurrency: fiatCurrency.toUpperCase(),
33
- cryptoCurrencyID: cryptoCurrency.toUpperCase(),
34
- amount,
35
- fees: {
36
- fixed: totalFees,
37
- percentage: percentageFee,
38
- },
39
- cryptoAmount: bestQuote.payout,
40
- };
41
- }
42
- catch (error) {
43
- if (axios.isAxiosError(error)) {
44
- throw new Error(error.response?.data?.message || "Failed to get quote from Onramper");
45
- }
46
- throw error;
47
- }
48
- }
49
- async getTransactionStatus(transactionId) {
50
- try {
51
- const { data } = await axios.get(`${this.baseUrl}/transactions/${transactionId}`, {
52
- headers: this.getHeaders(),
53
- });
54
- const statusMap = {
55
- pending: "processing",
56
- completed: "completed",
57
- failed: "failed",
58
- };
59
- return {
60
- transactionId: data.transactionId,
61
- status: statusMap[data.status] || "processing",
62
- createdAt: data.statusDate,
63
- updatedAt: data.statusDate,
64
- errorMessage: null,
65
- transactionHash: data.transactionHash || undefined,
66
- };
67
- }
68
- catch (error) {
69
- if (axios.isAxiosError(error)) {
70
- throw new Error(error.response?.data?.message ||
71
- "Failed to get transaction status from Onramper");
72
- }
73
- throw error;
74
- }
75
- }
76
- async executeQuote(executeQuoteRequest) {
77
- try {
78
- const { data } = await axios.post(`${this.baseUrl}/transactions`, {
79
- fiatCurrency: executeQuoteRequest.fiatCurrency,
80
- cryptoCurrency: executeQuoteRequest.cryptoCurrencyID,
81
- amount: executeQuoteRequest.amount,
82
- walletAddress: executeQuoteRequest.walletAddress,
83
- paymentMethod: executeQuoteRequest.paymentMethod,
84
- }, {
85
- headers: this.getHeaders(),
86
- });
87
- return {
88
- redirectUrl: data.redirectUrl,
89
- orderId: data.transactionId,
90
- };
91
- }
92
- catch (error) {
93
- if (axios.isAxiosError(error)) {
94
- throw new Error(error.response?.data?.message ||
95
- "Failed to execute quote with Onramper");
96
- }
97
- throw error;
98
- }
99
- }
100
- getCryptoNetwork(cryptoCurrency) {
101
- const networkMap = {
102
- BTC: "bitcoin",
103
- ETH: "ethereum",
104
- SOL: "solana",
105
- };
106
- return networkMap[cryptoCurrency.toUpperCase()] || "ethereum";
107
- }
108
- async getConfiguration() {
109
- try {
110
- const { data } = await axios.get(`${this.baseUrl}/config`, {
111
- headers: this.getHeaders(),
112
- });
113
- // Add flag URLs to country data
114
- return {
115
- supportedCountries: data.supportedCountries || [],
116
- supportedCurrencies: data.supportedCurrencies || [],
117
- supportedPaymentMethods: [...this.supportedPaymentMethods],
118
- supportedTokens: data.supportedTokens || [],
119
- };
120
- }
121
- catch (error) {
122
- if (axios.isAxiosError(error)) {
123
- throw new Error(error.response?.data?.message ||
124
- "Failed to fetch Onramper configuration");
125
- }
126
- throw error;
127
- }
128
- }
129
- }
130
- //# sourceMappingURL=onramperClientAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"onramperClientAdapter.js","sourceRoot":"","sources":["../../../src/services/external/onramperClientAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,MAAM,OAAO,eAAgB,SAAQ,uBAAuB;IACjD,GAAG,GAAG,UAAU,CAAC;IAEjB,KAAK,GAAG,UAAU,CAAC;IAEnB,uBAAuB,GAAG,CAAC,aAAa,EAAE,eAAe,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,MAAM,IAAI,KAAK,CACb,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO;oBAC3B,wCAAwC,CAC3C,CAAC;aACH;YACD,MAAM,KAAK,CAAC;SACb;IACH,CAAC;CACF"}
@@ -1,30 +0,0 @@
1
- import { ChainData, Token } from "@0xsquid/squid-types";
2
- import { ExecuteFiatQuoteResult, ExecuteQuoteClient, FiatToCryptoConfig, OnRampQuoteResponse, OnRampTransactionStatus } from "../../core/types/onramps/onramp";
3
- import { RevolutConfig, RevolutQuoteResponse } from "../../core/types/onramps/revolut";
4
- import { BaseFiatToCryptoAdapter } from "./baseAdapter";
5
- export declare class RevolutClientAdapter extends BaseFiatToCryptoAdapter {
6
- readonly key = "revolut";
7
- readonly label = "Revolut";
8
- readonly supportedPaymentMethods: readonly ["card", "revolut", "apple-pay", "google-pay"];
9
- private readonly baseUrl;
10
- private findMatchingChain;
11
- private findMatchingToken;
12
- private filterAndMapTokens;
13
- mapConfigResponse(data: RevolutConfig, squidConfig: {
14
- chains: ChainData[];
15
- tokens: Token[];
16
- }): FiatToCryptoConfig;
17
- mapQuoteResponse(data: RevolutQuoteResponse, fiatCurrency: string, cryptoCurrencyID: string, originalAmount: number): OnRampQuoteResponse;
18
- mapPaymentMethod(method: string): string;
19
- calculateTotalFees(data: RevolutQuoteResponse, amount: number): {
20
- totalFees: number;
21
- percentageFee: number;
22
- };
23
- getQuote(fiatCurrency: string, cryptoCurrencyID: string, amount: number, paymentMethod?: string, region?: string): Promise<OnRampQuoteResponse>;
24
- getTransactionStatus(transactionId: string, walletAddress: string): Promise<OnRampTransactionStatus>;
25
- executeQuote(params: ExecuteQuoteClient): Promise<ExecuteFiatQuoteResult>;
26
- getConfiguration(squidConfig: {
27
- chains: ChainData[];
28
- tokens: Token[];
29
- }): Promise<FiatToCryptoConfig>;
30
- }
@@ -1,195 +0,0 @@
1
- import axios from "axios";
2
- import { v4 as uuidv4 } from "uuid";
3
- import { BETA_INTERNAL_API_BASE_URL, DEFAULT_COUNTRY_CODE, nativeEvmTokenAddress, } from "../../core/constants";
4
- import { BaseFiatToCryptoAdapter } from "./baseAdapter";
5
- export class RevolutClientAdapter extends BaseFiatToCryptoAdapter {
6
- key = "revolut";
7
- label = "Revolut";
8
- supportedPaymentMethods = [
9
- "card",
10
- "revolut",
11
- "apple-pay",
12
- "google-pay",
13
- ];
14
- baseUrl = `${BETA_INTERNAL_API_BASE_URL}/fiat-to-crypto/revolut`;
15
- findMatchingChain(revolutBlockchain, chains) {
16
- return chains.find((c) => c.networkIdentifier.toUpperCase() === revolutBlockchain);
17
- }
18
- findMatchingToken(params) {
19
- const { revolutToken, chain, tokens } = params;
20
- // Filter tokens by chain first
21
- const chainTokens = tokens.filter((t) => t.chainId === chain.chainId);
22
- if (revolutToken.smartContractAddress) {
23
- // For tokens with contract address (EVM tokens)
24
- return chainTokens.find((t) => t.address?.toLowerCase() ===
25
- revolutToken.smartContractAddress?.toLowerCase());
26
- }
27
- // For native tokens (BTC, ETH, etc.)
28
- return chainTokens.find((t) => t.address?.toLowerCase() === nativeEvmTokenAddress &&
29
- t.symbol.toUpperCase() === revolutToken.currency.toUpperCase());
30
- }
31
- filterAndMapTokens(revolutTokens, squidConfig) {
32
- return revolutTokens
33
- .map((revolutToken) => {
34
- const chain = this.findMatchingChain(revolutToken.blockchain, squidConfig.chains);
35
- if (!chain)
36
- return null;
37
- const token = this.findMatchingToken({
38
- revolutToken,
39
- chain,
40
- tokens: squidConfig.tokens,
41
- });
42
- if (!token)
43
- return null;
44
- return { ...token, cryptoCurrencyID: revolutToken.id };
45
- })
46
- .filter((token) => token !== null);
47
- }
48
- mapConfigResponse(data, squidConfig) {
49
- try {
50
- // Transform country codes into enhanced country info
51
- const supportedCountries = data.countries
52
- .map((code) => this.getCountryData(code))
53
- .filter((country) => country !== null);
54
- // Transform currencies with additional data
55
- const currencies = (data.fiat || [])
56
- .map((fc) => {
57
- const currencyData = this.getCurrencyData(fc.currency);
58
- if (!currencyData)
59
- return null;
60
- return {
61
- ...currencyData,
62
- minLimit: fc.min_limit,
63
- maxLimit: fc.max_limit,
64
- };
65
- })
66
- .filter((currency) => currency !== null);
67
- // Filter and map tokens that exist in both systems
68
- const allowedTokens = this.filterAndMapTokens(data.crypto, squidConfig);
69
- return {
70
- supportedCountries,
71
- supportedCurrencies: currencies,
72
- supportedPaymentMethods: data.payment_methods,
73
- supportedTokens: allowedTokens,
74
- };
75
- }
76
- catch (error) {
77
- console.error("[Revolut Adapter] Error mapping config response:", error);
78
- // Return empty but valid config instead of throwing
79
- return {
80
- supportedCountries: [],
81
- supportedCurrencies: [],
82
- supportedPaymentMethods: [],
83
- supportedTokens: [],
84
- };
85
- }
86
- }
87
- mapQuoteResponse(data, fiatCurrency, cryptoCurrencyID, originalAmount) {
88
- const { totalFees, percentageFee } = this.calculateTotalFees(data, originalAmount);
89
- return {
90
- fiatCurrency,
91
- cryptoCurrencyID,
92
- amount: originalAmount,
93
- fees: {
94
- fixed: totalFees,
95
- percentage: percentageFee,
96
- },
97
- cryptoAmount: data.crypto.amount,
98
- };
99
- }
100
- mapPaymentMethod(method) {
101
- const methodMap = {
102
- credit_card: "card",
103
- bank_transfer: "revolut",
104
- apple_pay: "apple-pay",
105
- google_pay: "google-pay",
106
- };
107
- return methodMap[method] || "card";
108
- }
109
- calculateTotalFees(data, amount) {
110
- const totalFees = Number((data.service_fee.amount +
111
- data.network_fee.amount +
112
- data.partner_fee.amount).toFixed(2));
113
- const percentageFee = Number(((totalFees / amount) * 100).toFixed(2));
114
- return { totalFees, percentageFee };
115
- }
116
- async getQuote(fiatCurrency, cryptoCurrencyID, amount, paymentMethod = "card", region = DEFAULT_COUNTRY_CODE) {
117
- try {
118
- const { data } = await axios.get(`${this.baseUrl}/quote`, {
119
- params: {
120
- fiatCurrency,
121
- cryptoCurrencyID,
122
- amount,
123
- paymentMethod: this.mapPaymentMethod(paymentMethod),
124
- region,
125
- },
126
- });
127
- const { totalFees, percentageFee } = this.calculateTotalFees(data, amount);
128
- return {
129
- fiatCurrency,
130
- cryptoCurrencyID,
131
- amount,
132
- fees: {
133
- fixed: totalFees,
134
- percentage: percentageFee,
135
- },
136
- cryptoAmount: data.crypto.amount,
137
- };
138
- }
139
- catch (error) {
140
- throw new Error("Failed to get quote from Revolut");
141
- }
142
- }
143
- async getTransactionStatus(transactionId, walletAddress) {
144
- try {
145
- const { data } = await axios.get(`${this.baseUrl}/status/${transactionId}`, {
146
- params: {
147
- wallet: walletAddress,
148
- },
149
- });
150
- return {
151
- transactionId: data.transactionId,
152
- status: data.status,
153
- createdAt: data.createdAt,
154
- updatedAt: data.updatedAt,
155
- transactionHash: data.transactionHash,
156
- };
157
- }
158
- catch (error) {
159
- throw new Error("Failed to get transaction status");
160
- }
161
- }
162
- async executeQuote(params) {
163
- try {
164
- const orderId = uuidv4();
165
- const serverParams = {
166
- orderId,
167
- fiatCurrency: params.fiatCurrency,
168
- cryptoCurrencyID: params.cryptoCurrencyID,
169
- amount: params.amount,
170
- walletAddress: params.walletAddress,
171
- paymentMethod: this.mapPaymentMethod(params.paymentMethod),
172
- region: params.region || DEFAULT_COUNTRY_CODE,
173
- // partnerRedirectUrl: "",
174
- };
175
- const { data } = await axios.post(`${this.baseUrl}/execute`, serverParams);
176
- return {
177
- redirectUrl: data.redirectUrl,
178
- orderId,
179
- };
180
- }
181
- catch (error) {
182
- throw new Error("Failed to execute quote");
183
- }
184
- }
185
- async getConfiguration(squidConfig) {
186
- try {
187
- const { data } = await axios.get(`${this.baseUrl}/config`);
188
- return this.mapConfigResponse(data, squidConfig);
189
- }
190
- catch (error) {
191
- throw new Error("Failed to fetch Revolut configuration");
192
- }
193
- }
194
- }
195
- //# sourceMappingURL=revolutClientAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"revolutClientAdapter.js","sourceRoot":"","sources":["../../../src/services/external/revolutClientAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,EAAE,IAAI,M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AAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC5C;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,WAGtB;QACC,IAAI;YACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,GAAG,CAAgB,GAAG,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC;YAE1E,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SAClD;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;SAC1D;IACH,CAAC;CACF"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,181 +0,0 @@
1
- import { RevolutClientAdapter } from "../services/external/revolutClientAdapter";
2
- import { fetchNativeSquidData } from "./fetchSquidData";
3
- describe("RevolutClientAdapter", () => {
4
- let adapter;
5
- let realSquid = undefined;
6
- let REAL_CHAINS = [];
7
- let REAL_TOKENS = [];
8
- beforeAll(async () => {
9
- realSquid = await fetchNativeSquidData();
10
- REAL_CHAINS = realSquid?.chains ?? [];
11
- REAL_TOKENS = realSquid?.tokens ?? [];
12
- });
13
- beforeEach(() => {
14
- adapter = new RevolutClientAdapter();
15
- });
16
- describe("calculateTotalFees", () => {
17
- test("should correctly calculate total fees and percentage for EUR quote", () => {
18
- const mockQuoteResponse = {
19
- service_fee: {
20
- amount: 25.33,
21
- currency: "EUR",
22
- },
23
- network_fee: {
24
- amount: 0.29,
25
- currency: "EUR",
26
- },
27
- crypto: {
28
- amount: 1009.278933,
29
- currencyId: "USDC-ETH",
30
- },
31
- partner_fee: {
32
- amount: 9.74,
33
- currency: "EUR",
34
- },
35
- };
36
- const amount = 1000; // Original amount in EUR
37
- const { totalFees, percentageFee } = adapter.calculateTotalFees(mockQuoteResponse, amount);
38
- // Total fees should be 25.33 + 0.29 + 9.74 = 35.36
39
- expect(totalFees).toBe(35.36);
40
- // Percentage should be (35.36 / 1000) * 100 = 3.54%
41
- expect(percentageFee).toBe(3.54);
42
- });
43
- test("should handle zero fees", () => {
44
- const mockQuoteResponse = {
45
- service_fee: {
46
- amount: 0,
47
- currency: "EUR",
48
- },
49
- network_fee: {
50
- amount: 0,
51
- currency: "EUR",
52
- },
53
- crypto: {
54
- amount: 1000,
55
- currencyId: "USDC-ETH",
56
- },
57
- partner_fee: {
58
- amount: 0,
59
- currency: "EUR",
60
- },
61
- };
62
- const amount = 1000;
63
- const { totalFees, percentageFee } = adapter.calculateTotalFees(mockQuoteResponse, amount);
64
- expect(totalFees).toBe(0);
65
- expect(percentageFee).toBe(0);
66
- });
67
- test("should handle very small fees", () => {
68
- const mockQuoteResponse = {
69
- service_fee: {
70
- amount: 0.001,
71
- currency: "EUR",
72
- },
73
- network_fee: {
74
- amount: 0.002,
75
- currency: "EUR",
76
- },
77
- crypto: {
78
- amount: 100,
79
- currencyId: "USDC-ETH",
80
- },
81
- partner_fee: {
82
- amount: 0.003,
83
- currency: "EUR",
84
- },
85
- };
86
- const amount = 100;
87
- const { totalFees, percentageFee } = adapter.calculateTotalFees(mockQuoteResponse, amount);
88
- expect(totalFees).toBe(0.01); // 0.001 + 0.002 + 0.003 = 0.006, rounded to 0.01
89
- expect(percentageFee).toBe(0.01); // (0.01 / 100) * 100 = 0.01%
90
- });
91
- test("should handle different currencies with same calculation", () => {
92
- const mockQuoteResponse = {
93
- service_fee: {
94
- amount: 25.33,
95
- currency: "USD", // Changed to USD
96
- },
97
- network_fee: {
98
- amount: 0.29,
99
- currency: "USD",
100
- },
101
- crypto: {
102
- amount: 1009.278933,
103
- currencyId: "USDC-ETH",
104
- },
105
- partner_fee: {
106
- amount: 9.74,
107
- currency: "USD",
108
- },
109
- };
110
- const amount = 1000;
111
- const { totalFees, percentageFee } = adapter.calculateTotalFees(mockQuoteResponse, amount);
112
- expect(totalFees).toBe(35.36);
113
- expect(percentageFee).toBe(3.54);
114
- });
115
- });
116
- describe("mapConfigResponse", () => {
117
- test("should correctly map Revolut config to internal format", () => {
118
- const mockRevolutConfig = {
119
- version: "2.0",
120
- countries: ["GB", "FR", "DE"],
121
- fiat: [
122
- { currency: "EUR", min_limit: 10, max_limit: 1000 },
123
- { currency: "USD", min_limit: 10, max_limit: 1000 },
124
- ],
125
- crypto: [
126
- {
127
- id: "ETH",
128
- currency: "ETH",
129
- blockchain: "ETHEREUM",
130
- },
131
- {
132
- id: "USDC-ETH",
133
- currency: "USDC",
134
- blockchain: "ETHEREUM",
135
- smartContractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
136
- },
137
- ],
138
- payment_methods: ["card", "revolut"],
139
- };
140
- const result = adapter.mapConfigResponse(mockRevolutConfig, {
141
- chains: REAL_CHAINS,
142
- tokens: REAL_TOKENS,
143
- });
144
- expect(result.supportedCountries).toHaveLength(3);
145
- expect(result.supportedCurrencies).toHaveLength(2);
146
- expect(result.supportedTokens).toHaveLength(2);
147
- expect(result.supportedPaymentMethods).toEqual(["card", "revolut"]);
148
- });
149
- });
150
- describe("findMatchingToken", () => {
151
- test("should match both EVM native tokens and tokens with contract addresses", () => {
152
- const mockRevolutConfig = {
153
- version: "2.0",
154
- countries: ["GB"],
155
- fiat: [{ currency: "USD", min_limit: 10, max_limit: 1000 }],
156
- crypto: [
157
- {
158
- id: "ETH",
159
- currency: "ETH",
160
- blockchain: "ETHEREUM",
161
- },
162
- {
163
- id: "USDC-ETH",
164
- currency: "USDC",
165
- blockchain: "ETHEREUM",
166
- smartContractAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
167
- },
168
- ],
169
- payment_methods: ["card"],
170
- };
171
- const result = adapter.mapConfigResponse(mockRevolutConfig, {
172
- chains: REAL_CHAINS,
173
- tokens: REAL_TOKENS,
174
- });
175
- expect(result.supportedTokens).toHaveLength(2);
176
- expect(result.supportedTokens.find((t) => t.symbol === "ETH")).toBeDefined();
177
- expect(result.supportedTokens.find((t) => t.symbol === "USDC")).toBeDefined();
178
- });
179
- });
180
- });
181
- //# sourceMappingURL=revolutClientAdapter.test.js.map