@odisea-labs/pan 1.2.2 → 1.3.0

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/dist/index.d.mts CHANGED
@@ -1,4 +1,25 @@
1
- import { PanConfig as PanConfig$1, LendIntentParams as LendIntentParams$1, CreateIntentResponse as CreateIntentResponse$1, TransferIntentParams, WithdrawIntentParams, BridgeIntentParams, Intent as Intent$1 } from '@pan/types';
1
+ import { PanConfig as PanConfig$1, Network, LendIntentParams as LendIntentParams$1, CreateIntentResponse as CreateIntentResponse$1, TransferIntentParams, WithdrawIntentParams, BridgeIntentParams, Intent as Intent$1 } from '@pan/types';
2
+
3
+ declare class PanClient {
4
+ private apiKey;
5
+ private baseURL;
6
+ private debug;
7
+ private defaultNetwork;
8
+ constructor(config: PanConfig$1);
9
+ getDefaultNetwork(): Network;
10
+ request<T>(endpoint: string, options?: RequestInit): Promise<T>;
11
+ }
12
+ interface PanErrorData {
13
+ error?: string;
14
+ message?: string;
15
+ statusCode?: number;
16
+ }
17
+ declare class PanError$1 extends Error {
18
+ code: string;
19
+ statusCode: number;
20
+ details?: PanErrorData;
21
+ constructor(errorData: PanErrorData, statusCode?: number);
22
+ }
2
23
 
3
24
  type ChainType = "ethereum" | "tron";
4
25
  interface Wallet {
@@ -19,11 +40,11 @@ interface PanConfig {
19
40
  baseURL?: string;
20
41
  debug?: boolean;
21
42
  }
22
- interface PanError$1 {
43
+ interface PanError {
23
44
  error: string;
24
45
  message: string;
25
46
  }
26
- interface RateLimitError extends PanError$1 {
47
+ interface RateLimitError extends PanError {
27
48
  current: number;
28
49
  limit: number;
29
50
  }
@@ -147,20 +168,6 @@ interface AllYieldsResponse {
147
168
  updatedAt: string;
148
169
  }
149
170
 
150
- declare class PanClient {
151
- private apiKey;
152
- private baseURL;
153
- private debug;
154
- constructor(config: PanConfig);
155
- request<T>(endpoint: string, options?: RequestInit): Promise<T>;
156
- }
157
- declare class PanError extends Error {
158
- code: string;
159
- statusCode: number;
160
- details?: unknown;
161
- constructor(errorData: any, statusCode?: number);
162
- }
163
-
164
171
  declare class WalletManager {
165
172
  private client;
166
173
  constructor(client: PanClient);
@@ -187,4 +194,4 @@ declare class Pan {
187
194
  getIntent(intentId: string): Promise<Intent$1>;
188
195
  }
189
196
 
190
- export { type AllYieldsResponse, type AnyExecutionStep, type BridgeStep, type ChainBalance, type ChainType, type ConsolidateStep, type CreateIntentParams, type CreateIntentResponse, type CreateWalletParams, type DepositStep, type ExecutionPlan, type ExecutionResult, type ExecutionStep, type ExecutionStepType, type Intent, type LendIntentParams, Pan, PanClient, type PanConfig, PanError, type RateLimitError, type RecommendedYield, type SwapStep, type TokenBalance, type Wallet, type WalletBalances, WalletManager, YieldManager, type YieldOption };
197
+ export { type AllYieldsResponse, type AnyExecutionStep, type BridgeStep, type ChainBalance, type ChainType, type ConsolidateStep, type CreateIntentParams, type CreateIntentResponse, type CreateWalletParams, type DepositStep, type ExecutionPlan, type ExecutionResult, type ExecutionStep, type ExecutionStepType, type Intent, type LendIntentParams, Pan, PanClient, type PanConfig, PanError$1 as PanError, type RateLimitError, type RecommendedYield, type SwapStep, type TokenBalance, type Wallet, type WalletBalances, WalletManager, YieldManager, type YieldOption };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,25 @@
1
- import { PanConfig as PanConfig$1, LendIntentParams as LendIntentParams$1, CreateIntentResponse as CreateIntentResponse$1, TransferIntentParams, WithdrawIntentParams, BridgeIntentParams, Intent as Intent$1 } from '@pan/types';
1
+ import { PanConfig as PanConfig$1, Network, LendIntentParams as LendIntentParams$1, CreateIntentResponse as CreateIntentResponse$1, TransferIntentParams, WithdrawIntentParams, BridgeIntentParams, Intent as Intent$1 } from '@pan/types';
2
+
3
+ declare class PanClient {
4
+ private apiKey;
5
+ private baseURL;
6
+ private debug;
7
+ private defaultNetwork;
8
+ constructor(config: PanConfig$1);
9
+ getDefaultNetwork(): Network;
10
+ request<T>(endpoint: string, options?: RequestInit): Promise<T>;
11
+ }
12
+ interface PanErrorData {
13
+ error?: string;
14
+ message?: string;
15
+ statusCode?: number;
16
+ }
17
+ declare class PanError$1 extends Error {
18
+ code: string;
19
+ statusCode: number;
20
+ details?: PanErrorData;
21
+ constructor(errorData: PanErrorData, statusCode?: number);
22
+ }
2
23
 
3
24
  type ChainType = "ethereum" | "tron";
4
25
  interface Wallet {
@@ -19,11 +40,11 @@ interface PanConfig {
19
40
  baseURL?: string;
20
41
  debug?: boolean;
21
42
  }
22
- interface PanError$1 {
43
+ interface PanError {
23
44
  error: string;
24
45
  message: string;
25
46
  }
26
- interface RateLimitError extends PanError$1 {
47
+ interface RateLimitError extends PanError {
27
48
  current: number;
28
49
  limit: number;
29
50
  }
@@ -147,20 +168,6 @@ interface AllYieldsResponse {
147
168
  updatedAt: string;
148
169
  }
149
170
 
150
- declare class PanClient {
151
- private apiKey;
152
- private baseURL;
153
- private debug;
154
- constructor(config: PanConfig);
155
- request<T>(endpoint: string, options?: RequestInit): Promise<T>;
156
- }
157
- declare class PanError extends Error {
158
- code: string;
159
- statusCode: number;
160
- details?: unknown;
161
- constructor(errorData: any, statusCode?: number);
162
- }
163
-
164
171
  declare class WalletManager {
165
172
  private client;
166
173
  constructor(client: PanClient);
@@ -187,4 +194,4 @@ declare class Pan {
187
194
  getIntent(intentId: string): Promise<Intent$1>;
188
195
  }
189
196
 
190
- export { type AllYieldsResponse, type AnyExecutionStep, type BridgeStep, type ChainBalance, type ChainType, type ConsolidateStep, type CreateIntentParams, type CreateIntentResponse, type CreateWalletParams, type DepositStep, type ExecutionPlan, type ExecutionResult, type ExecutionStep, type ExecutionStepType, type Intent, type LendIntentParams, Pan, PanClient, type PanConfig, PanError, type RateLimitError, type RecommendedYield, type SwapStep, type TokenBalance, type Wallet, type WalletBalances, WalletManager, YieldManager, type YieldOption };
197
+ export { type AllYieldsResponse, type AnyExecutionStep, type BridgeStep, type ChainBalance, type ChainType, type ConsolidateStep, type CreateIntentParams, type CreateIntentResponse, type CreateWalletParams, type DepositStep, type ExecutionPlan, type ExecutionResult, type ExecutionStep, type ExecutionStepType, type Intent, type LendIntentParams, Pan, PanClient, type PanConfig, PanError$1 as PanError, type RateLimitError, type RecommendedYield, type SwapStep, type TokenBalance, type Wallet, type WalletBalances, WalletManager, YieldManager, type YieldOption };
package/dist/index.js CHANGED
@@ -31,9 +31,22 @@ module.exports = __toCommonJS(index_exports);
31
31
  // src/client.ts
32
32
  var PanClient = class {
33
33
  constructor(config) {
34
- this.apiKey = config.apiKey;
35
- this.baseURL = config.baseURL || "https://api.pan.com";
36
- this.debug = config.debug || false;
34
+ const {
35
+ apiKey,
36
+ baseURL = "https://api.pan.com",
37
+ debug = false,
38
+ network = "mainnet"
39
+ } = config;
40
+ if (network !== "mainnet" && network !== "testnet") {
41
+ throw new Error("Network must be 'mainnet' or 'testnet'");
42
+ }
43
+ this.apiKey = apiKey;
44
+ this.baseURL = baseURL;
45
+ this.debug = debug;
46
+ this.defaultNetwork = network;
47
+ }
48
+ getDefaultNetwork() {
49
+ return this.defaultNetwork;
37
50
  }
38
51
  async request(endpoint, options = {}) {
39
52
  const url = `${this.baseURL}${endpoint}`;
@@ -129,16 +142,19 @@ var Pan = class {
129
142
  this.yields = new YieldManager(this.client);
130
143
  }
131
144
  async lend(params) {
145
+ const network = params.network || this.client.getDefaultNetwork();
132
146
  return this.client.request("/api/v1/intents", {
133
147
  method: "POST",
134
148
  body: JSON.stringify({
135
149
  walletId: params.walletId,
136
150
  action: "lend",
137
- amount: params.amount
151
+ amount: params.amount,
152
+ network
138
153
  })
139
154
  });
140
155
  }
141
156
  async transfer(params) {
157
+ const network = params.network || this.client.getDefaultNetwork();
142
158
  return this.client.request("/api/v1/intents", {
143
159
  method: "POST",
144
160
  body: JSON.stringify({
@@ -147,11 +163,13 @@ var Pan = class {
147
163
  to: params.to,
148
164
  amount: params.amount,
149
165
  asset: params.asset,
150
- chain: params.chain
166
+ chain: params.chain,
167
+ network
151
168
  })
152
169
  });
153
170
  }
154
171
  async withdraw(params) {
172
+ const network = params.network || this.client.getDefaultNetwork();
155
173
  return this.client.request("/api/v1/intents", {
156
174
  method: "POST",
157
175
  body: JSON.stringify({
@@ -159,11 +177,13 @@ var Pan = class {
159
177
  action: "withdraw",
160
178
  amount: params.amount,
161
179
  asset: params.asset || "USDC",
162
- chain: params.chain
180
+ chain: params.chain,
181
+ network
163
182
  })
164
183
  });
165
184
  }
166
185
  async bridge(params) {
186
+ const network = params.network || this.client.getDefaultNetwork();
167
187
  return this.client.request("/api/v1/intents", {
168
188
  method: "POST",
169
189
  body: JSON.stringify({
@@ -172,7 +192,8 @@ var Pan = class {
172
192
  amount: params.amount,
173
193
  asset: params.asset || "USDC",
174
194
  fromChain: params.fromChain,
175
- toChain: params.toChain
195
+ toChain: params.toChain,
196
+ network
176
197
  })
177
198
  });
178
199
  }
package/dist/index.mjs CHANGED
@@ -1,9 +1,22 @@
1
1
  // src/client.ts
2
2
  var PanClient = class {
3
3
  constructor(config) {
4
- this.apiKey = config.apiKey;
5
- this.baseURL = config.baseURL || "https://api.pan.com";
6
- this.debug = config.debug || false;
4
+ const {
5
+ apiKey,
6
+ baseURL = "https://api.pan.com",
7
+ debug = false,
8
+ network = "mainnet"
9
+ } = config;
10
+ if (network !== "mainnet" && network !== "testnet") {
11
+ throw new Error("Network must be 'mainnet' or 'testnet'");
12
+ }
13
+ this.apiKey = apiKey;
14
+ this.baseURL = baseURL;
15
+ this.debug = debug;
16
+ this.defaultNetwork = network;
17
+ }
18
+ getDefaultNetwork() {
19
+ return this.defaultNetwork;
7
20
  }
8
21
  async request(endpoint, options = {}) {
9
22
  const url = `${this.baseURL}${endpoint}`;
@@ -99,16 +112,19 @@ var Pan = class {
99
112
  this.yields = new YieldManager(this.client);
100
113
  }
101
114
  async lend(params) {
115
+ const network = params.network || this.client.getDefaultNetwork();
102
116
  return this.client.request("/api/v1/intents", {
103
117
  method: "POST",
104
118
  body: JSON.stringify({
105
119
  walletId: params.walletId,
106
120
  action: "lend",
107
- amount: params.amount
121
+ amount: params.amount,
122
+ network
108
123
  })
109
124
  });
110
125
  }
111
126
  async transfer(params) {
127
+ const network = params.network || this.client.getDefaultNetwork();
112
128
  return this.client.request("/api/v1/intents", {
113
129
  method: "POST",
114
130
  body: JSON.stringify({
@@ -117,11 +133,13 @@ var Pan = class {
117
133
  to: params.to,
118
134
  amount: params.amount,
119
135
  asset: params.asset,
120
- chain: params.chain
136
+ chain: params.chain,
137
+ network
121
138
  })
122
139
  });
123
140
  }
124
141
  async withdraw(params) {
142
+ const network = params.network || this.client.getDefaultNetwork();
125
143
  return this.client.request("/api/v1/intents", {
126
144
  method: "POST",
127
145
  body: JSON.stringify({
@@ -129,11 +147,13 @@ var Pan = class {
129
147
  action: "withdraw",
130
148
  amount: params.amount,
131
149
  asset: params.asset || "USDC",
132
- chain: params.chain
150
+ chain: params.chain,
151
+ network
133
152
  })
134
153
  });
135
154
  }
136
155
  async bridge(params) {
156
+ const network = params.network || this.client.getDefaultNetwork();
137
157
  return this.client.request("/api/v1/intents", {
138
158
  method: "POST",
139
159
  body: JSON.stringify({
@@ -142,7 +162,8 @@ var Pan = class {
142
162
  amount: params.amount,
143
163
  asset: params.asset || "USDC",
144
164
  fromChain: params.fromChain,
145
- toChain: params.toChain
165
+ toChain: params.toChain,
166
+ network
146
167
  })
147
168
  });
148
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odisea-labs/pan",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "Intent-based DeFi API SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",