@echoxyz/sonar-core 0.5.0 → 0.7.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 +16 -0
- package/README.md +8 -3
- package/dist/index.cjs +11 -6
- package/dist/index.d.cts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +11 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @echoxyz/sonar-core
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5b96860: Add listAvailableEntities / useSonarEntities
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- ef7e0f9: Switch to new ExchangeAuthorizationCodeV2 endpoint
|
|
12
|
+
|
|
13
|
+
## 0.6.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- f47a532: Replace EntityUUID + ObfuscatedEntityID in the API interface with a single EntityID
|
|
18
|
+
|
|
3
19
|
## 0.5.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -71,13 +71,18 @@ export async function completeOAuthFromCallback() {
|
|
|
71
71
|
// Call APIs (after token is set)
|
|
72
72
|
export async function exampleCalls() {
|
|
73
73
|
const { walletAddress } = useWallet(); // User's connected wallet.
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
// Read the entity for linked to the wallet for the configured sale.
|
|
76
|
+
// If the authenticated user has not yet linked the wallet on Sonar, this will return a 404.
|
|
75
77
|
const { Entity } = await client.readEntity({ saleUUID, walletAddress });
|
|
76
78
|
|
|
79
|
+
// List entities available to this user for the configured sale
|
|
80
|
+
const { Entities } = await client.listAvailableEntities({ saleUUD });
|
|
81
|
+
|
|
77
82
|
// Run a pre-purchase check
|
|
78
83
|
const pre = await client.prePurchaseCheck({
|
|
79
84
|
saleUUID,
|
|
80
|
-
|
|
85
|
+
entityID: Entity.EntityID,
|
|
81
86
|
walletAddress: "0x1234...abcd" as `0x${string}`,
|
|
82
87
|
});
|
|
83
88
|
|
|
@@ -85,7 +90,7 @@ export async function exampleCalls() {
|
|
|
85
90
|
// Generate a purchase permit
|
|
86
91
|
const permit = await client.generatePurchasePermit({
|
|
87
92
|
saleUUID,
|
|
88
|
-
|
|
93
|
+
entityID: Entity.EntityID,
|
|
89
94
|
walletAddress: "0x1234...abcd" as `0x${string}`,
|
|
90
95
|
});
|
|
91
96
|
console.log(permit.Signature, permit.Permit);
|
package/dist/index.cjs
CHANGED
|
@@ -265,11 +265,11 @@ var SonarClient = class {
|
|
|
265
265
|
}
|
|
266
266
|
async exchangeAuthorizationCode(args) {
|
|
267
267
|
return this.postJSON(
|
|
268
|
-
"/oauth.
|
|
268
|
+
"/oauth.ExchangeAuthorizationCodeV2",
|
|
269
269
|
{
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
270
|
+
code: args.code,
|
|
271
|
+
code_verifier: args.codeVerifier,
|
|
272
|
+
redirect_uri: args.redirectURI
|
|
273
273
|
},
|
|
274
274
|
{ includeAuth: false }
|
|
275
275
|
);
|
|
@@ -277,14 +277,14 @@ var SonarClient = class {
|
|
|
277
277
|
async prePurchaseCheck(args) {
|
|
278
278
|
return this.postJSON("/externalapi.PrePurchaseCheck", {
|
|
279
279
|
SaleUUID: args.saleUUID,
|
|
280
|
-
|
|
280
|
+
EntityID: args.entityID,
|
|
281
281
|
PurchasingWalletAddress: args.walletAddress
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
async generatePurchasePermit(args) {
|
|
285
285
|
return this.postJSON("/externalapi.GenerateSalePurchasePermit", {
|
|
286
286
|
SaleUUID: args.saleUUID,
|
|
287
|
-
|
|
287
|
+
EntityID: args.entityID,
|
|
288
288
|
PurchasingWalletAddress: args.walletAddress
|
|
289
289
|
});
|
|
290
290
|
}
|
|
@@ -300,6 +300,11 @@ var SonarClient = class {
|
|
|
300
300
|
WalletAddress: args.walletAddress
|
|
301
301
|
});
|
|
302
302
|
}
|
|
303
|
+
async listAvailableEntities(args) {
|
|
304
|
+
return this.postJSON("/externalapi.ListAvailableEntities", {
|
|
305
|
+
SaleUUID: args.saleUUID
|
|
306
|
+
});
|
|
307
|
+
}
|
|
303
308
|
};
|
|
304
309
|
var APIError = class extends Error {
|
|
305
310
|
status;
|
package/dist/index.d.cts
CHANGED
|
@@ -80,12 +80,11 @@ declare enum InvestingRegion {
|
|
|
80
80
|
}
|
|
81
81
|
type EntityDetails = {
|
|
82
82
|
Label: string;
|
|
83
|
-
|
|
83
|
+
EntityID: Hex;
|
|
84
84
|
EntityType: EntityType;
|
|
85
85
|
EntitySetupState: EntitySetupState;
|
|
86
86
|
SaleEligibility: SaleEligibility;
|
|
87
87
|
InvestingRegion: InvestingRegion;
|
|
88
|
-
ObfuscatedEntityID: `0x${string}`;
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
@@ -106,6 +105,9 @@ type AllocationResponse = {
|
|
|
106
105
|
type ReadEntityResponse = {
|
|
107
106
|
Entity: EntityDetails;
|
|
108
107
|
};
|
|
108
|
+
type ListAvailableEntitiesResponse = {
|
|
109
|
+
Entities: EntityDetails[];
|
|
110
|
+
};
|
|
109
111
|
type ClientOptions = {
|
|
110
112
|
auth?: AuthSession;
|
|
111
113
|
fetch?: FetchLike;
|
|
@@ -135,12 +137,12 @@ declare class SonarClient {
|
|
|
135
137
|
}>;
|
|
136
138
|
prePurchaseCheck(args: {
|
|
137
139
|
saleUUID: string;
|
|
138
|
-
|
|
140
|
+
entityID: Hex;
|
|
139
141
|
walletAddress: string;
|
|
140
142
|
}): Promise<PrePurchaseCheckResponse>;
|
|
141
143
|
generatePurchasePermit(args: {
|
|
142
144
|
saleUUID: string;
|
|
143
|
-
|
|
145
|
+
entityID: Hex;
|
|
144
146
|
walletAddress: string;
|
|
145
147
|
}): Promise<GeneratePurchasePermitResponse>;
|
|
146
148
|
fetchAllocation(args: {
|
|
@@ -151,6 +153,9 @@ declare class SonarClient {
|
|
|
151
153
|
saleUUID: string;
|
|
152
154
|
walletAddress: string;
|
|
153
155
|
}): Promise<ReadEntityResponse>;
|
|
156
|
+
listAvailableEntities(args: {
|
|
157
|
+
saleUUID: string;
|
|
158
|
+
}): Promise<ListAvailableEntitiesResponse>;
|
|
154
159
|
}
|
|
155
160
|
declare class APIError extends Error {
|
|
156
161
|
readonly status: number;
|
|
@@ -185,4 +190,4 @@ type CreateClientOptions = {
|
|
|
185
190
|
};
|
|
186
191
|
declare function createClient(options?: CreateClientOptions): SonarClient;
|
|
187
192
|
|
|
188
|
-
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 };
|
|
193
|
+
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 ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -80,12 +80,11 @@ declare enum InvestingRegion {
|
|
|
80
80
|
}
|
|
81
81
|
type EntityDetails = {
|
|
82
82
|
Label: string;
|
|
83
|
-
|
|
83
|
+
EntityID: Hex;
|
|
84
84
|
EntityType: EntityType;
|
|
85
85
|
EntitySetupState: EntitySetupState;
|
|
86
86
|
SaleEligibility: SaleEligibility;
|
|
87
87
|
InvestingRegion: InvestingRegion;
|
|
88
|
-
ObfuscatedEntityID: `0x${string}`;
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
@@ -106,6 +105,9 @@ type AllocationResponse = {
|
|
|
106
105
|
type ReadEntityResponse = {
|
|
107
106
|
Entity: EntityDetails;
|
|
108
107
|
};
|
|
108
|
+
type ListAvailableEntitiesResponse = {
|
|
109
|
+
Entities: EntityDetails[];
|
|
110
|
+
};
|
|
109
111
|
type ClientOptions = {
|
|
110
112
|
auth?: AuthSession;
|
|
111
113
|
fetch?: FetchLike;
|
|
@@ -135,12 +137,12 @@ declare class SonarClient {
|
|
|
135
137
|
}>;
|
|
136
138
|
prePurchaseCheck(args: {
|
|
137
139
|
saleUUID: string;
|
|
138
|
-
|
|
140
|
+
entityID: Hex;
|
|
139
141
|
walletAddress: string;
|
|
140
142
|
}): Promise<PrePurchaseCheckResponse>;
|
|
141
143
|
generatePurchasePermit(args: {
|
|
142
144
|
saleUUID: string;
|
|
143
|
-
|
|
145
|
+
entityID: Hex;
|
|
144
146
|
walletAddress: string;
|
|
145
147
|
}): Promise<GeneratePurchasePermitResponse>;
|
|
146
148
|
fetchAllocation(args: {
|
|
@@ -151,6 +153,9 @@ declare class SonarClient {
|
|
|
151
153
|
saleUUID: string;
|
|
152
154
|
walletAddress: string;
|
|
153
155
|
}): Promise<ReadEntityResponse>;
|
|
156
|
+
listAvailableEntities(args: {
|
|
157
|
+
saleUUID: string;
|
|
158
|
+
}): Promise<ListAvailableEntitiesResponse>;
|
|
154
159
|
}
|
|
155
160
|
declare class APIError extends Error {
|
|
156
161
|
readonly status: number;
|
|
@@ -185,4 +190,4 @@ type CreateClientOptions = {
|
|
|
185
190
|
};
|
|
186
191
|
declare function createClient(options?: CreateClientOptions): SonarClient;
|
|
187
192
|
|
|
188
|
-
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 };
|
|
193
|
+
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 ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
|
package/dist/index.js
CHANGED
|
@@ -228,11 +228,11 @@ var SonarClient = class {
|
|
|
228
228
|
}
|
|
229
229
|
async exchangeAuthorizationCode(args) {
|
|
230
230
|
return this.postJSON(
|
|
231
|
-
"/oauth.
|
|
231
|
+
"/oauth.ExchangeAuthorizationCodeV2",
|
|
232
232
|
{
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
code: args.code,
|
|
234
|
+
code_verifier: args.codeVerifier,
|
|
235
|
+
redirect_uri: args.redirectURI
|
|
236
236
|
},
|
|
237
237
|
{ includeAuth: false }
|
|
238
238
|
);
|
|
@@ -240,14 +240,14 @@ var SonarClient = class {
|
|
|
240
240
|
async prePurchaseCheck(args) {
|
|
241
241
|
return this.postJSON("/externalapi.PrePurchaseCheck", {
|
|
242
242
|
SaleUUID: args.saleUUID,
|
|
243
|
-
|
|
243
|
+
EntityID: args.entityID,
|
|
244
244
|
PurchasingWalletAddress: args.walletAddress
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
async generatePurchasePermit(args) {
|
|
248
248
|
return this.postJSON("/externalapi.GenerateSalePurchasePermit", {
|
|
249
249
|
SaleUUID: args.saleUUID,
|
|
250
|
-
|
|
250
|
+
EntityID: args.entityID,
|
|
251
251
|
PurchasingWalletAddress: args.walletAddress
|
|
252
252
|
});
|
|
253
253
|
}
|
|
@@ -263,6 +263,11 @@ var SonarClient = class {
|
|
|
263
263
|
WalletAddress: args.walletAddress
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
|
+
async listAvailableEntities(args) {
|
|
267
|
+
return this.postJSON("/externalapi.ListAvailableEntities", {
|
|
268
|
+
SaleUUID: args.saleUUID
|
|
269
|
+
});
|
|
270
|
+
}
|
|
266
271
|
};
|
|
267
272
|
var APIError = class extends Error {
|
|
268
273
|
status;
|