@echoxyz/sonar-core 0.1.5 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @echoxyz/sonar-core
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - affa026: Add missing values to PrePurchaseFailureReason enum
8
+
9
+ ## 0.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - a043774: Replace listEntities with readEntity function
14
+
3
15
  ## 0.1.5
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -71,13 +71,14 @@ export async function completeOAuthFromCallback() {
71
71
 
72
72
  // Call APIs (after token is set)
73
73
  export async function exampleCalls() {
74
+ const { walletAddress } = useWallet(); // User's connected wallet.
74
75
  // List entities available to this user for the configured sale
75
- const { Entities } = await client.listAvailableEntities({ saleUUID });
76
+ const { Entity } = await client.readEntity({ saleUUID, walletAddress });
76
77
 
77
78
  // Run a pre-purchase check
78
79
  const pre = await client.prePurchaseCheck({
79
80
  saleUUID,
80
- entityUUID: Entities[0].EntityUUID,
81
+ entityUUID: Entity.EntityUUID,
81
82
  entityType: EntityType.USER, // or EntityType.ORGANIZATION
82
83
  walletAddress: "0x1234...abcd" as `0x${string}`,
83
84
  });
@@ -86,7 +87,7 @@ export async function exampleCalls() {
86
87
  // Generate a purchase permit
87
88
  const permit = await client.generatePurchasePermit({
88
89
  saleUUID,
89
- entityUUID: Entities[0].EntityUUID,
90
+ entityUUID: Entity.EntityUUID,
90
91
  entityType: EntityType.USER,
91
92
  walletAddress: "0x1234...abcd" as `0x${string}`,
92
93
  });
@@ -94,7 +95,7 @@ export async function exampleCalls() {
94
95
  }
95
96
 
96
97
  // Fetch allocation
97
- const alloc = await client.fetchAllocation({ saleUUID, walletAddress: "0x1234...abcd" as `0x${string}` });
98
+ const alloc = await client.fetchAllocation({ saleUUID, walletAddress });
98
99
  console.log(alloc);
99
100
  }
100
101
  ```
package/dist/index.cjs CHANGED
@@ -22,6 +22,7 @@ __export(index_exports, {
22
22
  APIError: () => APIError,
23
23
  EntitySetupState: () => EntitySetupState,
24
24
  EntityType: () => EntityType,
25
+ InvestingRegion: () => InvestingRegion,
25
26
  PrePurchaseFailureReason: () => PrePurchaseFailureReason,
26
27
  PurchasePermitType: () => PurchasePermitType,
27
28
  SaleEligibility: () => SaleEligibility,
@@ -295,11 +296,11 @@ var SonarClient = class {
295
296
  WalletAddress: args.walletAddress
296
297
  });
297
298
  }
298
- async listAvailableEntities(args) {
299
- const data = await this.postJSON("/externalapi.ListAvailableEntities", {
300
- SaleUUID: args.saleUUID
299
+ async readEntity(args) {
300
+ return this.postJSON("/externalapi.ReadEntity", {
301
+ SaleUUID: args.saleUUID,
302
+ WalletAddress: args.walletAddress
301
303
  });
302
- return data;
303
304
  }
304
305
  };
305
306
  var APIError = class extends Error {
@@ -376,6 +377,7 @@ var EntityType = /* @__PURE__ */ ((EntityType2) => {
376
377
  var EntitySetupState = /* @__PURE__ */ ((EntitySetupState2) => {
377
378
  EntitySetupState2["NOT_STARTED"] = "not-started";
378
379
  EntitySetupState2["IN_PROGRESS"] = "in-progress";
380
+ EntitySetupState2["READY_FOR_REVIEW"] = "ready-for-review";
379
381
  EntitySetupState2["IN_REVIEW"] = "in-review";
380
382
  EntitySetupState2["FAILURE"] = "failure";
381
383
  EntitySetupState2["FAILURE_FINAL"] = "failure-final";
@@ -399,8 +401,16 @@ var PrePurchaseFailureReason = /* @__PURE__ */ ((PrePurchaseFailureReason2) => {
399
401
  PrePurchaseFailureReason2["MAX_WALLETS_USED"] = "max-wallets-used";
400
402
  PrePurchaseFailureReason2["REQUIRES_LIVENESS"] = "requires-liveness";
401
403
  PrePurchaseFailureReason2["NO_RESERVED_ALLOCATION"] = "no-reserved-allocation";
404
+ PrePurchaseFailureReason2["SALE_NOT_ACTIVE"] = "sale-not-active";
405
+ PrePurchaseFailureReason2["WALLET_NOT_LINKED"] = "wallet-not-linked";
402
406
  return PrePurchaseFailureReason2;
403
407
  })(PrePurchaseFailureReason || {});
408
+ var InvestingRegion = /* @__PURE__ */ ((InvestingRegion2) => {
409
+ InvestingRegion2["UNKNOWN"] = "unknown";
410
+ InvestingRegion2["OTHER"] = "other";
411
+ InvestingRegion2["US"] = "us";
412
+ return InvestingRegion2;
413
+ })(InvestingRegion || {});
404
414
 
405
415
  // src/index.ts
406
416
  var DEFAULT_API_URL = "https://api.echo.xyz";
@@ -424,6 +434,7 @@ function createClient(options) {
424
434
  APIError,
425
435
  EntitySetupState,
426
436
  EntityType,
437
+ InvestingRegion,
427
438
  PrePurchaseFailureReason,
428
439
  PurchasePermitType,
429
440
  SaleEligibility,
package/dist/index.d.cts CHANGED
@@ -35,6 +35,7 @@ declare enum EntityType {
35
35
  declare enum EntitySetupState {
36
36
  NOT_STARTED = "not-started",
37
37
  IN_PROGRESS = "in-progress",
38
+ READY_FOR_REVIEW = "ready-for-review",
38
39
  IN_REVIEW = "in-review",
39
40
  FAILURE = "failure",
40
41
  FAILURE_FINAL = "failure-final",
@@ -67,15 +68,22 @@ declare enum PrePurchaseFailureReason {
67
68
  WALLET_RISK = "wallet-risk",
68
69
  MAX_WALLETS_USED = "max-wallets-used",
69
70
  REQUIRES_LIVENESS = "requires-liveness",
70
- NO_RESERVED_ALLOCATION = "no-reserved-allocation"
71
+ NO_RESERVED_ALLOCATION = "no-reserved-allocation",
72
+ SALE_NOT_ACTIVE = "sale-not-active",
73
+ WALLET_NOT_LINKED = "wallet-not-linked"
74
+ }
75
+ declare enum InvestingRegion {
76
+ UNKNOWN = "unknown",
77
+ OTHER = "other",
78
+ US = "us"
71
79
  }
72
80
  type EntityDetails = {
73
81
  Label: string;
74
82
  EntityUUID: string;
75
83
  EntityType: EntityType;
76
- EntitySetupState: string;
77
- SaleEligibility: string;
78
- InvestingRegion: string;
84
+ EntitySetupState: EntitySetupState;
85
+ SaleEligibility: SaleEligibility;
86
+ InvestingRegion: InvestingRegion;
79
87
  ObfuscatedEntityID: `0x${string}`;
80
88
  };
81
89
 
@@ -86,7 +94,7 @@ type PrePurchaseCheckResponse = {
86
94
  LivenessCheckURL: string;
87
95
  };
88
96
  type GeneratePurchasePermitResponse = {
89
- Permit: BasicPermit | AllocationPermit;
97
+ PermitJSON: BasicPermit | AllocationPermit;
90
98
  Signature: string;
91
99
  };
92
100
  type AllocationResponse = {
@@ -94,8 +102,8 @@ type AllocationResponse = {
94
102
  ReservedAmountUSD: string;
95
103
  MaxAmountUSD: string;
96
104
  };
97
- type ListAvailableEntitiesResponse = {
98
- Entities: EntityDetails[];
105
+ type ReadEntityResponse = {
106
+ Entity: EntityDetails;
99
107
  };
100
108
  type ClientOptions = {
101
109
  auth?: AuthSession;
@@ -140,9 +148,10 @@ declare class SonarClient {
140
148
  saleUUID: string;
141
149
  walletAddress: string;
142
150
  }): Promise<AllocationResponse>;
143
- listAvailableEntities(args: {
151
+ readEntity(args: {
144
152
  saleUUID: string;
145
- }): Promise<ListAvailableEntitiesResponse>;
153
+ walletAddress: string;
154
+ }): Promise<ReadEntityResponse>;
146
155
  }
147
156
  declare class APIError extends Error {
148
157
  readonly status: number;
@@ -179,4 +188,4 @@ type CreateClientOptions = {
179
188
  };
180
189
  declare function createClient(options: CreateClientOptions): SonarClient;
181
190
 
182
- export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, type ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
191
+ export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.d.ts CHANGED
@@ -35,6 +35,7 @@ declare enum EntityType {
35
35
  declare enum EntitySetupState {
36
36
  NOT_STARTED = "not-started",
37
37
  IN_PROGRESS = "in-progress",
38
+ READY_FOR_REVIEW = "ready-for-review",
38
39
  IN_REVIEW = "in-review",
39
40
  FAILURE = "failure",
40
41
  FAILURE_FINAL = "failure-final",
@@ -67,15 +68,22 @@ declare enum PrePurchaseFailureReason {
67
68
  WALLET_RISK = "wallet-risk",
68
69
  MAX_WALLETS_USED = "max-wallets-used",
69
70
  REQUIRES_LIVENESS = "requires-liveness",
70
- NO_RESERVED_ALLOCATION = "no-reserved-allocation"
71
+ NO_RESERVED_ALLOCATION = "no-reserved-allocation",
72
+ SALE_NOT_ACTIVE = "sale-not-active",
73
+ WALLET_NOT_LINKED = "wallet-not-linked"
74
+ }
75
+ declare enum InvestingRegion {
76
+ UNKNOWN = "unknown",
77
+ OTHER = "other",
78
+ US = "us"
71
79
  }
72
80
  type EntityDetails = {
73
81
  Label: string;
74
82
  EntityUUID: string;
75
83
  EntityType: EntityType;
76
- EntitySetupState: string;
77
- SaleEligibility: string;
78
- InvestingRegion: string;
84
+ EntitySetupState: EntitySetupState;
85
+ SaleEligibility: SaleEligibility;
86
+ InvestingRegion: InvestingRegion;
79
87
  ObfuscatedEntityID: `0x${string}`;
80
88
  };
81
89
 
@@ -86,7 +94,7 @@ type PrePurchaseCheckResponse = {
86
94
  LivenessCheckURL: string;
87
95
  };
88
96
  type GeneratePurchasePermitResponse = {
89
- Permit: BasicPermit | AllocationPermit;
97
+ PermitJSON: BasicPermit | AllocationPermit;
90
98
  Signature: string;
91
99
  };
92
100
  type AllocationResponse = {
@@ -94,8 +102,8 @@ type AllocationResponse = {
94
102
  ReservedAmountUSD: string;
95
103
  MaxAmountUSD: string;
96
104
  };
97
- type ListAvailableEntitiesResponse = {
98
- Entities: EntityDetails[];
105
+ type ReadEntityResponse = {
106
+ Entity: EntityDetails;
99
107
  };
100
108
  type ClientOptions = {
101
109
  auth?: AuthSession;
@@ -140,9 +148,10 @@ declare class SonarClient {
140
148
  saleUUID: string;
141
149
  walletAddress: string;
142
150
  }): Promise<AllocationResponse>;
143
- listAvailableEntities(args: {
151
+ readEntity(args: {
144
152
  saleUUID: string;
145
- }): Promise<ListAvailableEntitiesResponse>;
153
+ walletAddress: string;
154
+ }): Promise<ReadEntityResponse>;
146
155
  }
147
156
  declare class APIError extends Error {
148
157
  readonly status: number;
@@ -179,4 +188,4 @@ type CreateClientOptions = {
179
188
  };
180
189
  declare function createClient(options: CreateClientOptions): SonarClient;
181
190
 
182
- export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, type ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
191
+ export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.js CHANGED
@@ -259,11 +259,11 @@ var SonarClient = class {
259
259
  WalletAddress: args.walletAddress
260
260
  });
261
261
  }
262
- async listAvailableEntities(args) {
263
- const data = await this.postJSON("/externalapi.ListAvailableEntities", {
264
- SaleUUID: args.saleUUID
262
+ async readEntity(args) {
263
+ return this.postJSON("/externalapi.ReadEntity", {
264
+ SaleUUID: args.saleUUID,
265
+ WalletAddress: args.walletAddress
265
266
  });
266
- return data;
267
267
  }
268
268
  };
269
269
  var APIError = class extends Error {
@@ -340,6 +340,7 @@ var EntityType = /* @__PURE__ */ ((EntityType2) => {
340
340
  var EntitySetupState = /* @__PURE__ */ ((EntitySetupState2) => {
341
341
  EntitySetupState2["NOT_STARTED"] = "not-started";
342
342
  EntitySetupState2["IN_PROGRESS"] = "in-progress";
343
+ EntitySetupState2["READY_FOR_REVIEW"] = "ready-for-review";
343
344
  EntitySetupState2["IN_REVIEW"] = "in-review";
344
345
  EntitySetupState2["FAILURE"] = "failure";
345
346
  EntitySetupState2["FAILURE_FINAL"] = "failure-final";
@@ -363,8 +364,16 @@ var PrePurchaseFailureReason = /* @__PURE__ */ ((PrePurchaseFailureReason2) => {
363
364
  PrePurchaseFailureReason2["MAX_WALLETS_USED"] = "max-wallets-used";
364
365
  PrePurchaseFailureReason2["REQUIRES_LIVENESS"] = "requires-liveness";
365
366
  PrePurchaseFailureReason2["NO_RESERVED_ALLOCATION"] = "no-reserved-allocation";
367
+ PrePurchaseFailureReason2["SALE_NOT_ACTIVE"] = "sale-not-active";
368
+ PrePurchaseFailureReason2["WALLET_NOT_LINKED"] = "wallet-not-linked";
366
369
  return PrePurchaseFailureReason2;
367
370
  })(PrePurchaseFailureReason || {});
371
+ var InvestingRegion = /* @__PURE__ */ ((InvestingRegion2) => {
372
+ InvestingRegion2["UNKNOWN"] = "unknown";
373
+ InvestingRegion2["OTHER"] = "other";
374
+ InvestingRegion2["US"] = "us";
375
+ return InvestingRegion2;
376
+ })(InvestingRegion || {});
368
377
 
369
378
  // src/index.ts
370
379
  var DEFAULT_API_URL = "https://api.echo.xyz";
@@ -387,6 +396,7 @@ export {
387
396
  APIError,
388
397
  EntitySetupState,
389
398
  EntityType,
399
+ InvestingRegion,
390
400
  PrePurchaseFailureReason,
391
401
  PurchasePermitType,
392
402
  SaleEligibility,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echoxyz/sonar-core",
3
- "version": "0.1.5",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",