@echoxyz/sonar-core 0.12.0 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @echoxyz/sonar-core
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c551d7c: Add BasicPermitV3 type with OpensAt and ClosesAt fields for time-gated commitment windows:
8
+ - Add `BasicPermitV3` type with new `OpensAt` and `ClosesAt` fields
9
+ - Add `BASIC_V3` to `PurchasePermitType` enum
10
+ - Update `PurchasePermit` conditional type to handle V3
11
+ - Update `GeneratePurchasePermitResponse` to include `BasicPermitV3`
12
+ - Mark `BasicPermitV2` as deprecated
13
+
14
+ - b2cd697: Rename Allocation API to Limits API to match backend changes:
15
+ - `fetchAllocation` → `fetchLimits`
16
+ - `AllocationResponse` → `LimitsResponse`
17
+ - Response fields renamed: `HasReservedAllocation` → `HasCustomCommitmentAmountLimit`, `ReservedAmountUSD` removed, `MaxAmountUSD` → `MaxCommitmentAmount`, added `MinCommitmentAmount`
18
+ - `PrePurchaseFailureReason.NO_RESERVED_ALLOCATION` → `PrePurchaseFailureReason.NO_CUSTOM_COMMITMENT_AMOUNT_LIMIT`
19
+
20
+ ### Patch Changes
21
+
22
+ - e276112: Add `pnpm fmt` script for running prettier and format check to CI
23
+ - 171a0db: Added support for ReadEntityInvestmentHistory API
24
+
3
25
  ## 0.12.0
4
26
 
5
27
  ### Minor Changes
package/README.md CHANGED
@@ -72,6 +72,13 @@ export async function completeOAuthFromCallback() {
72
72
  export async function exampleCalls() {
73
73
  const { walletAddress } = useWallet(); // User's connected wallet.
74
74
 
75
+ // Get the authenticated user's profile information
76
+ const profile = await client.myProfile();
77
+ console.log(profile.EntityID); // Entity ID for the authenticated user
78
+ if (profile.EmailAddress) {
79
+ console.log(profile.EmailAddress); // Email address (only present if authorized with contact:email scope)
80
+ }
81
+
75
82
  // Read the entity for linked to the wallet for the configured sale.
76
83
  // If the authenticated user has not yet linked the wallet on Sonar, this will return a 404.
77
84
  const { Entity } = await client.readEntity({ saleUUID, walletAddress });
@@ -96,9 +103,9 @@ export async function exampleCalls() {
96
103
  console.log(permit.Signature, permit.Permit);
97
104
  }
98
105
 
99
- // Fetch allocation
100
- const alloc = await client.fetchAllocation({ saleUUID, walletAddress });
101
- console.log(alloc);
106
+ // Fetch limits
107
+ const limits = await client.fetchLimits({ saleUUID, walletAddress });
108
+ console.log(limits);
102
109
  }
103
110
  ```
104
111
 
package/dist/index.cjs CHANGED
@@ -279,6 +279,12 @@ var SonarClient = class {
279
279
  refresh_token: args.refreshToken
280
280
  });
281
281
  }
282
+ async myProfile() {
283
+ return this.postJSON("/externalapi.MyProfile", {});
284
+ }
285
+ async readEntityInvestmentHistory() {
286
+ return this.postJSON("/externalapi.ReadEntityInvestmentHistory", {});
287
+ }
282
288
  async prePurchaseCheck(args) {
283
289
  return this.postJSON("/externalapi.PrePurchaseCheck", {
284
290
  SaleUUID: args.saleUUID,
@@ -293,8 +299,8 @@ var SonarClient = class {
293
299
  PurchasingWalletAddress: args.walletAddress
294
300
  });
295
301
  }
296
- async fetchAllocation(args) {
297
- return this.postJSON("/externalapi.Allocation", {
302
+ async fetchLimits(args) {
303
+ return this.postJSON("/externalapi.Limits", {
298
304
  SaleUUID: args.saleUUID,
299
305
  WalletAddress: args.walletAddress
300
306
  });
@@ -400,6 +406,7 @@ var SaleEligibility = /* @__PURE__ */ ((SaleEligibility2) => {
400
406
  var PurchasePermitType = /* @__PURE__ */ ((PurchasePermitType2) => {
401
407
  PurchasePermitType2["BASIC"] = "basic";
402
408
  PurchasePermitType2["BASIC_V2"] = "basic-v2";
409
+ PurchasePermitType2["BASIC_V3"] = "basic-v3";
403
410
  PurchasePermitType2["ALLOCATION"] = "allocation";
404
411
  return PurchasePermitType2;
405
412
  })(PurchasePermitType || {});
@@ -408,7 +415,6 @@ var PrePurchaseFailureReason = /* @__PURE__ */ ((PrePurchaseFailureReason2) => {
408
415
  PrePurchaseFailureReason2["WALLET_RISK"] = "wallet-risk";
409
416
  PrePurchaseFailureReason2["MAX_WALLETS_USED"] = "max-wallets-used";
410
417
  PrePurchaseFailureReason2["REQUIRES_LIVENESS"] = "requires-liveness";
411
- PrePurchaseFailureReason2["NO_RESERVED_ALLOCATION"] = "no-reserved-allocation";
412
418
  PrePurchaseFailureReason2["SALE_NOT_ACTIVE"] = "sale-not-active";
413
419
  PrePurchaseFailureReason2["WALLET_NOT_LINKED"] = "wallet-not-linked";
414
420
  return PrePurchaseFailureReason2;
package/dist/index.d.cts CHANGED
@@ -72,18 +72,31 @@ type BasicPermitV2 = {
72
72
  MaxPrice: number;
73
73
  Payload: Hex;
74
74
  };
75
+ type BasicPermitV3 = {
76
+ SaleSpecificEntityID: Hex;
77
+ SaleUUID: Hex;
78
+ Wallet: Hex;
79
+ ExpiresAt: number;
80
+ MinAmount: string;
81
+ MaxAmount: string;
82
+ MinPrice: number;
83
+ MaxPrice: number;
84
+ OpensAt: number;
85
+ ClosesAt: number;
86
+ Payload: Hex;
87
+ };
75
88
  declare enum PurchasePermitType {
76
89
  BASIC = "basic",
77
90
  BASIC_V2 = "basic-v2",
91
+ BASIC_V3 = "basic-v3",
78
92
  ALLOCATION = "allocation"
79
93
  }
80
- type PurchasePermit<T extends PurchasePermitType> = T extends PurchasePermitType.BASIC ? BasicPermit : T extends PurchasePermitType.BASIC_V2 ? BasicPermitV2 : T extends PurchasePermitType.ALLOCATION ? AllocationPermit : never;
94
+ type PurchasePermit<T extends PurchasePermitType> = T extends PurchasePermitType.BASIC ? BasicPermit : T extends PurchasePermitType.BASIC_V2 ? BasicPermitV2 : T extends PurchasePermitType.BASIC_V3 ? BasicPermitV3 : T extends PurchasePermitType.ALLOCATION ? AllocationPermit : never;
81
95
  declare enum PrePurchaseFailureReason {
82
96
  UNKNOWN = "unknown",
83
97
  WALLET_RISK = "wallet-risk",
84
98
  MAX_WALLETS_USED = "max-wallets-used",
85
99
  REQUIRES_LIVENESS = "requires-liveness",
86
- NO_RESERVED_ALLOCATION = "no-reserved-allocation",
87
100
  SALE_NOT_ACTIVE = "sale-not-active",
88
101
  WALLET_NOT_LINKED = "wallet-not-linked"
89
102
  }
@@ -101,6 +114,18 @@ type EntityDetails = {
101
114
  SaleEligibility: SaleEligibility;
102
115
  InvestingRegion: InvestingRegion;
103
116
  };
117
+ type MyProfileResponse = {
118
+ EntityID: string;
119
+ EmailAddress?: string;
120
+ };
121
+ type EntityInvestment = {
122
+ CompanyName: string;
123
+ Round: string;
124
+ InvestedOn: string;
125
+ };
126
+ type EntityInvestmentHistoryResponse = {
127
+ Investments: EntityInvestment[];
128
+ };
104
129
 
105
130
  type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
106
131
  type PrePurchaseCheckResponse = {
@@ -109,13 +134,13 @@ type PrePurchaseCheckResponse = {
109
134
  LivenessCheckURL: string;
110
135
  };
111
136
  type GeneratePurchasePermitResponse = {
112
- PermitJSON: BasicPermit | BasicPermitV2 | AllocationPermit;
137
+ PermitJSON: BasicPermit | BasicPermitV2 | BasicPermitV3 | AllocationPermit;
113
138
  Signature: Hex;
114
139
  };
115
- type AllocationResponse = {
116
- HasReservedAllocation: boolean;
117
- ReservedAmountUSD: string;
118
- MaxAmountUSD: string;
140
+ type LimitsResponse = {
141
+ HasCustomCommitmentAmountLimit: boolean;
142
+ MinCommitmentAmount: string;
143
+ MaxCommitmentAmount: string;
119
144
  };
120
145
  type ReadEntityResponse = {
121
146
  Entity: EntityDetails;
@@ -157,6 +182,8 @@ declare class SonarClient {
157
182
  refreshToken(args: {
158
183
  refreshToken: string;
159
184
  }): Promise<TokenResponse>;
185
+ myProfile(): Promise<MyProfileResponse>;
186
+ readEntityInvestmentHistory(): Promise<EntityInvestmentHistoryResponse>;
160
187
  prePurchaseCheck(args: {
161
188
  saleUUID: string;
162
189
  entityID: EntityID;
@@ -167,10 +194,10 @@ declare class SonarClient {
167
194
  entityID: EntityID;
168
195
  walletAddress: string;
169
196
  }): Promise<GeneratePurchasePermitResponse>;
170
- fetchAllocation(args: {
197
+ fetchLimits(args: {
171
198
  saleUUID: string;
172
199
  walletAddress: string;
173
- }): Promise<AllocationResponse>;
200
+ }): Promise<LimitsResponse>;
174
201
  readEntity(args: {
175
202
  saleUUID: string;
176
203
  walletAddress: string;
@@ -212,4 +239,4 @@ type CreateClientOptions = {
212
239
  };
213
240
  declare function createClient(options?: CreateClientOptions): SonarClient;
214
241
 
215
- export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BasicPermitV2, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, type EntityID, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
242
+ export { APIError, type AllocationPermit, type BasicPermit, type BasicPermitV2, type BasicPermitV3, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, type EntityID, type EntityInvestment, type EntityInvestmentHistoryResponse, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type LimitsResponse, type ListAvailableEntitiesResponse, type MyProfileResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.d.ts CHANGED
@@ -72,18 +72,31 @@ type BasicPermitV2 = {
72
72
  MaxPrice: number;
73
73
  Payload: Hex;
74
74
  };
75
+ type BasicPermitV3 = {
76
+ SaleSpecificEntityID: Hex;
77
+ SaleUUID: Hex;
78
+ Wallet: Hex;
79
+ ExpiresAt: number;
80
+ MinAmount: string;
81
+ MaxAmount: string;
82
+ MinPrice: number;
83
+ MaxPrice: number;
84
+ OpensAt: number;
85
+ ClosesAt: number;
86
+ Payload: Hex;
87
+ };
75
88
  declare enum PurchasePermitType {
76
89
  BASIC = "basic",
77
90
  BASIC_V2 = "basic-v2",
91
+ BASIC_V3 = "basic-v3",
78
92
  ALLOCATION = "allocation"
79
93
  }
80
- type PurchasePermit<T extends PurchasePermitType> = T extends PurchasePermitType.BASIC ? BasicPermit : T extends PurchasePermitType.BASIC_V2 ? BasicPermitV2 : T extends PurchasePermitType.ALLOCATION ? AllocationPermit : never;
94
+ type PurchasePermit<T extends PurchasePermitType> = T extends PurchasePermitType.BASIC ? BasicPermit : T extends PurchasePermitType.BASIC_V2 ? BasicPermitV2 : T extends PurchasePermitType.BASIC_V3 ? BasicPermitV3 : T extends PurchasePermitType.ALLOCATION ? AllocationPermit : never;
81
95
  declare enum PrePurchaseFailureReason {
82
96
  UNKNOWN = "unknown",
83
97
  WALLET_RISK = "wallet-risk",
84
98
  MAX_WALLETS_USED = "max-wallets-used",
85
99
  REQUIRES_LIVENESS = "requires-liveness",
86
- NO_RESERVED_ALLOCATION = "no-reserved-allocation",
87
100
  SALE_NOT_ACTIVE = "sale-not-active",
88
101
  WALLET_NOT_LINKED = "wallet-not-linked"
89
102
  }
@@ -101,6 +114,18 @@ type EntityDetails = {
101
114
  SaleEligibility: SaleEligibility;
102
115
  InvestingRegion: InvestingRegion;
103
116
  };
117
+ type MyProfileResponse = {
118
+ EntityID: string;
119
+ EmailAddress?: string;
120
+ };
121
+ type EntityInvestment = {
122
+ CompanyName: string;
123
+ Round: string;
124
+ InvestedOn: string;
125
+ };
126
+ type EntityInvestmentHistoryResponse = {
127
+ Investments: EntityInvestment[];
128
+ };
104
129
 
105
130
  type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
106
131
  type PrePurchaseCheckResponse = {
@@ -109,13 +134,13 @@ type PrePurchaseCheckResponse = {
109
134
  LivenessCheckURL: string;
110
135
  };
111
136
  type GeneratePurchasePermitResponse = {
112
- PermitJSON: BasicPermit | BasicPermitV2 | AllocationPermit;
137
+ PermitJSON: BasicPermit | BasicPermitV2 | BasicPermitV3 | AllocationPermit;
113
138
  Signature: Hex;
114
139
  };
115
- type AllocationResponse = {
116
- HasReservedAllocation: boolean;
117
- ReservedAmountUSD: string;
118
- MaxAmountUSD: string;
140
+ type LimitsResponse = {
141
+ HasCustomCommitmentAmountLimit: boolean;
142
+ MinCommitmentAmount: string;
143
+ MaxCommitmentAmount: string;
119
144
  };
120
145
  type ReadEntityResponse = {
121
146
  Entity: EntityDetails;
@@ -157,6 +182,8 @@ declare class SonarClient {
157
182
  refreshToken(args: {
158
183
  refreshToken: string;
159
184
  }): Promise<TokenResponse>;
185
+ myProfile(): Promise<MyProfileResponse>;
186
+ readEntityInvestmentHistory(): Promise<EntityInvestmentHistoryResponse>;
160
187
  prePurchaseCheck(args: {
161
188
  saleUUID: string;
162
189
  entityID: EntityID;
@@ -167,10 +194,10 @@ declare class SonarClient {
167
194
  entityID: EntityID;
168
195
  walletAddress: string;
169
196
  }): Promise<GeneratePurchasePermitResponse>;
170
- fetchAllocation(args: {
197
+ fetchLimits(args: {
171
198
  saleUUID: string;
172
199
  walletAddress: string;
173
- }): Promise<AllocationResponse>;
200
+ }): Promise<LimitsResponse>;
174
201
  readEntity(args: {
175
202
  saleUUID: string;
176
203
  walletAddress: string;
@@ -212,4 +239,4 @@ type CreateClientOptions = {
212
239
  };
213
240
  declare function createClient(options?: CreateClientOptions): SonarClient;
214
241
 
215
- export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BasicPermitV2, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, type EntityID, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
242
+ export { APIError, type AllocationPermit, type BasicPermit, type BasicPermitV2, type BasicPermitV3, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, type EntityID, type EntityInvestment, type EntityInvestmentHistoryResponse, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type LimitsResponse, type ListAvailableEntitiesResponse, type MyProfileResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.js CHANGED
@@ -242,6 +242,12 @@ var SonarClient = class {
242
242
  refresh_token: args.refreshToken
243
243
  });
244
244
  }
245
+ async myProfile() {
246
+ return this.postJSON("/externalapi.MyProfile", {});
247
+ }
248
+ async readEntityInvestmentHistory() {
249
+ return this.postJSON("/externalapi.ReadEntityInvestmentHistory", {});
250
+ }
245
251
  async prePurchaseCheck(args) {
246
252
  return this.postJSON("/externalapi.PrePurchaseCheck", {
247
253
  SaleUUID: args.saleUUID,
@@ -256,8 +262,8 @@ var SonarClient = class {
256
262
  PurchasingWalletAddress: args.walletAddress
257
263
  });
258
264
  }
259
- async fetchAllocation(args) {
260
- return this.postJSON("/externalapi.Allocation", {
265
+ async fetchLimits(args) {
266
+ return this.postJSON("/externalapi.Limits", {
261
267
  SaleUUID: args.saleUUID,
262
268
  WalletAddress: args.walletAddress
263
269
  });
@@ -363,6 +369,7 @@ var SaleEligibility = /* @__PURE__ */ ((SaleEligibility2) => {
363
369
  var PurchasePermitType = /* @__PURE__ */ ((PurchasePermitType2) => {
364
370
  PurchasePermitType2["BASIC"] = "basic";
365
371
  PurchasePermitType2["BASIC_V2"] = "basic-v2";
372
+ PurchasePermitType2["BASIC_V3"] = "basic-v3";
366
373
  PurchasePermitType2["ALLOCATION"] = "allocation";
367
374
  return PurchasePermitType2;
368
375
  })(PurchasePermitType || {});
@@ -371,7 +378,6 @@ var PrePurchaseFailureReason = /* @__PURE__ */ ((PrePurchaseFailureReason2) => {
371
378
  PrePurchaseFailureReason2["WALLET_RISK"] = "wallet-risk";
372
379
  PrePurchaseFailureReason2["MAX_WALLETS_USED"] = "max-wallets-used";
373
380
  PrePurchaseFailureReason2["REQUIRES_LIVENESS"] = "requires-liveness";
374
- PrePurchaseFailureReason2["NO_RESERVED_ALLOCATION"] = "no-reserved-allocation";
375
381
  PrePurchaseFailureReason2["SALE_NOT_ACTIVE"] = "sale-not-active";
376
382
  PrePurchaseFailureReason2["WALLET_NOT_LINKED"] = "wallet-not-linked";
377
383
  return PrePurchaseFailureReason2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echoxyz/sonar-core",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",