swaply-sdk-ts 0.0.8 → 0.0.9

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.
@@ -6,6 +6,7 @@ export declare class SwaplyApiClient {
6
6
  getQuote(sourceChain: number, sourceToken: string, destChain: number, destToken: string, amount: number, slippageBps: bigint, swapType: SwapType, retailUserId?: string | null): Promise<Quote>;
7
7
  createIntent(quoteId: string, userSourcePublicKey: string | null, userSourceAddress: string, userDestinationAddress: string, refundAddress: string): Promise<CreateIntentData>;
8
8
  addApproval(signedData: SignedApproval, intentId: string): Promise<void>;
9
+ getIntent(intentId: string): Promise<PublicSwapWithAdditionalInfo>;
9
10
  getIntentStatus(intentId: string): Promise<IntentStatus>;
10
11
  listRetailUserHistory(walletAddressOrRetailId: string): Promise<PaginatedResponse<PublicSwapWithAdditionalInfo>>;
11
12
  getSwapByIntentId(intentId: string): Promise<PublicSwapWithAdditionalInfo>;
package/dist/apiClient.js CHANGED
@@ -2,13 +2,15 @@ import axios from 'axios';
2
2
  export class SwaplyApiClient {
3
3
  client;
4
4
  constructor(apiUrl, apiKey, axiosInstance, config) {
5
- this.client = axiosInstance || axios.create({
6
- baseURL: apiUrl,
7
- headers: {
8
- 'x-api-key': apiKey,
9
- },
10
- ...config,
11
- });
5
+ this.client =
6
+ axiosInstance ||
7
+ axios.create({
8
+ baseURL: apiUrl,
9
+ headers: {
10
+ 'x-api-key': apiKey,
11
+ },
12
+ ...config,
13
+ });
12
14
  }
13
15
  async getQuote(sourceChain, sourceToken, destChain, destToken, amount, slippageBps, swapType, retailUserId = null) {
14
16
  const response = await this.client.post('/quotes/best', {
@@ -36,6 +38,10 @@ export class SwaplyApiClient {
36
38
  async addApproval(signedData, intentId) {
37
39
  await this.client.post(`/intents/${intentId}/approvals`, signedData);
38
40
  }
41
+ async getIntent(intentId) {
42
+ const response = await this.client.get(`/intents/${intentId}`);
43
+ return response.data;
44
+ }
39
45
  async getIntentStatus(intentId) {
40
46
  const response = await this.client.get(`/intents/${intentId}/status`);
41
47
  return response.data.status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swaply-sdk-ts",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist",
package/src/apiClient.ts CHANGED
@@ -15,14 +15,21 @@ import type {
15
15
  export class SwaplyApiClient {
16
16
  private client: AxiosInstance;
17
17
 
18
- constructor(apiUrl: string, apiKey: string, axiosInstance?: AxiosInstance, config?: AxiosRequestConfig) {
19
- this.client = axiosInstance || axios.create({
20
- baseURL: apiUrl,
21
- headers: {
22
- 'x-api-key': apiKey,
23
- },
24
- ...config,
25
- });
18
+ constructor(
19
+ apiUrl: string,
20
+ apiKey: string,
21
+ axiosInstance?: AxiosInstance,
22
+ config?: AxiosRequestConfig,
23
+ ) {
24
+ this.client =
25
+ axiosInstance ||
26
+ axios.create({
27
+ baseURL: apiUrl,
28
+ headers: {
29
+ 'x-api-key': apiKey,
30
+ },
31
+ ...config,
32
+ });
26
33
  }
27
34
 
28
35
  async getQuote(
@@ -72,6 +79,13 @@ export class SwaplyApiClient {
72
79
  await this.client.post(`/intents/${intentId}/approvals`, signedData);
73
80
  }
74
81
 
82
+ async getIntent(intentId: string): Promise<PublicSwapWithAdditionalInfo> {
83
+ const response: AxiosResponse<PublicSwapWithAdditionalInfo> = await this.client.get(
84
+ `/intents/${intentId}`,
85
+ );
86
+ return response.data;
87
+ }
88
+
75
89
  async getIntentStatus(intentId: string): Promise<IntentStatus> {
76
90
  const response: AxiosResponse<{ status: IntentStatus }> = await this.client.get(
77
91
  `/intents/${intentId}/status`,