@coinlist-co/react 0.3.0 → 0.4.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/{RequirementItem-BvwsFu9e.d.cts → RequirementItem-B-MvcxSr.d.cts} +3 -3
- package/dist/{RequirementItem-BpkJQep8.d.ts → RequirementItem-DcYot2uC.d.ts} +3 -3
- package/dist/{chunk-IDCROXPS.js → chunk-EHZ6PIGN.js} +6 -4
- package/dist/chunk-EHZ6PIGN.js.map +1 -0
- package/dist/chunk-NC45IO63.js +777 -0
- package/dist/chunk-NC45IO63.js.map +1 -0
- package/dist/chunk-RIFATQB5.js +257 -0
- package/dist/chunk-RIFATQB5.js.map +1 -0
- package/dist/chunk-UGJUTRXC.js +304 -0
- package/dist/chunk-UGJUTRXC.js.map +1 -0
- package/dist/client/components/index.cjs +60 -59
- package/dist/client/components/index.cjs.map +1 -1
- package/dist/client/components/index.d.cts +40 -22
- package/dist/client/components/index.d.ts +40 -22
- package/dist/client/components/index.js +34 -62
- package/dist/client/components/index.js.map +1 -1
- package/dist/client/core/index.cjs +308 -222
- package/dist/client/core/index.cjs.map +1 -1
- package/dist/client/core/index.d.cts +4 -4
- package/dist/client/core/index.d.ts +4 -4
- package/dist/client/core/index.js +14 -14
- package/dist/client/hooks/index.cjs +87 -13
- package/dist/client/hooks/index.cjs.map +1 -1
- package/dist/client/hooks/index.d.cts +102 -9
- package/dist/client/hooks/index.d.ts +102 -9
- package/dist/client/hooks/index.js +9 -9
- package/dist/client/index.cjs +465 -237
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +7 -8
- package/dist/client/index.d.ts +7 -8
- package/dist/client/index.js +24 -18
- package/dist/{coinlist-client-B_dJkbwB.d.ts → coinlist-client-BSxpqylo.d.ts} +13 -138
- package/dist/{coinlist-client-DBKa6j3f.d.cts → coinlist-client-Cah5c_aF.d.cts} +13 -138
- package/dist/participation-DMMEDxON.d.cts +185 -0
- package/dist/participation-E-bT-GXJ.d.ts +185 -0
- package/dist/{requirement-CxbdY8l4.d.cts → requirement-XWT0T_zO.d.cts} +5 -2
- package/dist/{requirement-fJsQ3f9_.d.ts → requirement-XWT0T_zO.d.ts} +5 -2
- package/dist/server/index.cjs +519 -14
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +73 -4
- package/dist/server/index.d.ts +73 -4
- package/dist/server/index.js +116 -20
- package/dist/server/index.js.map +1 -1
- package/dist/useCoinListRequirements-B5-ZPOMz.d.ts +80 -0
- package/dist/useCoinListRequirements-Cuc32Tqw.d.cts +80 -0
- package/package.json +1 -1
- package/dist/chunk-GRVV7NLV.js +0 -282
- package/dist/chunk-GRVV7NLV.js.map +0 -1
- package/dist/chunk-IADBIDY6.js +0 -76
- package/dist/chunk-IADBIDY6.js.map +0 -1
- package/dist/chunk-IDCROXPS.js.map +0 -1
- package/dist/chunk-P4DTIPEX.js +0 -623
- package/dist/chunk-P4DTIPEX.js.map +0 -1
- package/dist/chunk-V5M7SA3C.js +0 -161
- package/dist/chunk-V5M7SA3C.js.map +0 -1
- package/dist/newtype-yKTvFdg_.d.cts +0 -6
- package/dist/newtype-yKTvFdg_.d.ts +0 -6
- package/dist/oauth-session-DgItaMKN.d.cts +0 -56
- package/dist/oauth-session-DnKDI5ou.d.ts +0 -56
- package/dist/useCoinListOffers-C5lBlzcC.d.ts +0 -27
- package/dist/useCoinListOffers-CguwXaCX.d.cts +0 -27
- package/dist/useCoinListRequirements-BECx1cIw.d.ts +0 -31
- package/dist/useCoinListRequirements-CX2gV9gJ.d.cts +0 -31
- package/dist/useCompleteCoinListOAuth-BRhAqD4_.d.cts +0 -55
- package/dist/useCompleteCoinListOAuth-DEZpHjd6.d.ts +0 -55
package/dist/client/index.js
CHANGED
|
@@ -2,20 +2,35 @@ import {
|
|
|
2
2
|
ChecklistStatus,
|
|
3
3
|
RequirementStatus,
|
|
4
4
|
RequirementVariant
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-EHZ6PIGN.js";
|
|
6
6
|
import {
|
|
7
7
|
CoinListProvider,
|
|
8
8
|
useCoinList,
|
|
9
|
+
useCoinListOfferDetails,
|
|
10
|
+
useCoinListOffers,
|
|
9
11
|
useCoinListRequirements,
|
|
10
|
-
useCompleteCoinListOAuth
|
|
11
|
-
|
|
12
|
+
useCompleteCoinListOAuth,
|
|
13
|
+
useParticipations
|
|
14
|
+
} from "../chunk-UGJUTRXC.js";
|
|
12
15
|
import {
|
|
13
16
|
User,
|
|
14
17
|
UserEmail,
|
|
15
18
|
UserId
|
|
16
19
|
} from "../chunk-YJQMJFA7.js";
|
|
17
20
|
import {
|
|
21
|
+
createCoinListClient
|
|
22
|
+
} from "../chunk-RIFATQB5.js";
|
|
23
|
+
import {
|
|
24
|
+
OAuthRefreshToken,
|
|
25
|
+
OAuthSession
|
|
26
|
+
} from "../chunk-5E3P7AMH.js";
|
|
27
|
+
import {
|
|
28
|
+
AuthorizationCode,
|
|
18
29
|
Blockchain,
|
|
30
|
+
ClientId,
|
|
31
|
+
ClientSecret,
|
|
32
|
+
CodeChallenge,
|
|
33
|
+
CodeVerifier,
|
|
19
34
|
CreateParticipationParams,
|
|
20
35
|
Cursor,
|
|
21
36
|
FaqItem,
|
|
@@ -33,26 +48,14 @@ import {
|
|
|
33
48
|
Participation,
|
|
34
49
|
ParticipationId,
|
|
35
50
|
ParticipationsPaginationParams,
|
|
51
|
+
RedirectUri,
|
|
36
52
|
Requirement,
|
|
37
53
|
RequirementId,
|
|
38
54
|
RequirementStatusInfo,
|
|
39
55
|
TermItem,
|
|
40
56
|
WalletAddress,
|
|
41
|
-
createCoinListClient,
|
|
42
57
|
fetchAllPages
|
|
43
|
-
} from "../chunk-
|
|
44
|
-
import {
|
|
45
|
-
OAuthRefreshToken,
|
|
46
|
-
OAuthSession
|
|
47
|
-
} from "../chunk-5E3P7AMH.js";
|
|
48
|
-
import {
|
|
49
|
-
AuthorizationCode,
|
|
50
|
-
ClientId,
|
|
51
|
-
ClientSecret,
|
|
52
|
-
CodeChallenge,
|
|
53
|
-
CodeVerifier,
|
|
54
|
-
RedirectUri
|
|
55
|
-
} from "../chunk-GRVV7NLV.js";
|
|
58
|
+
} from "../chunk-NC45IO63.js";
|
|
56
59
|
export {
|
|
57
60
|
AuthorizationCode,
|
|
58
61
|
Blockchain,
|
|
@@ -95,7 +98,10 @@ export {
|
|
|
95
98
|
createCoinListClient,
|
|
96
99
|
fetchAllPages,
|
|
97
100
|
useCoinList,
|
|
101
|
+
useCoinListOfferDetails,
|
|
102
|
+
useCoinListOffers,
|
|
98
103
|
useCoinListRequirements,
|
|
99
|
-
useCompleteCoinListOAuth
|
|
104
|
+
useCompleteCoinListOAuth,
|
|
105
|
+
useParticipations
|
|
100
106
|
};
|
|
101
107
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { A as AuthorizationCode, c as CodeVerifier,
|
|
2
|
-
import {
|
|
3
|
-
import { A as AssetDto, b as OfferId, d as OfferOptionId, k as Asset, l as AssetId, O as Offer, a as OfferDetail, R as Requirement, h as RequirementStatusInfo } from './requirement-fJsQ3f9_.js';
|
|
1
|
+
import { A as AuthorizationCode, c as CodeVerifier, o as Config, O as OAuthAccessToken, i as PaginationParams, P as PaginatedResponse, j as Participation, m as ParticipationsPaginationParams, k as ParticipationId, d as CreateParticipationParams } from './participation-E-bT-GXJ.js';
|
|
2
|
+
import { O as Offer, b as OfferId, a as OfferDetail, d as OfferOptionId, R as Requirement, h as RequirementStatusInfo } from './requirement-XWT0T_zO.js';
|
|
4
3
|
|
|
5
4
|
type AuthState = 'unknown' | 'logged-in' | 'logged-out';
|
|
6
5
|
/** Discriminated error reasons from {@link CoinListClient.completeOAuth}. */
|
|
@@ -14,135 +13,6 @@ type OauthClientResult = {
|
|
|
14
13
|
reason: OauthClientErrorReason;
|
|
15
14
|
};
|
|
16
15
|
|
|
17
|
-
type QueryParamValue = string | number | boolean | null | undefined;
|
|
18
|
-
|
|
19
|
-
type Cursor = Newtype<string, 'Cursor'>;
|
|
20
|
-
declare const Cursor: (value: string) => Cursor;
|
|
21
|
-
interface PaginatedResponseDto<T> {
|
|
22
|
-
data: T[];
|
|
23
|
-
starting_after?: string;
|
|
24
|
-
starting_before?: string;
|
|
25
|
-
}
|
|
26
|
-
declare function fetchAllPages<A, P extends PaginationParams = PaginationParams>(fetchPage: (params: P) => Promise<PaginatedResponse<A>>, baseParams?: Omit<P, keyof PaginationParams>): Promise<A[]>;
|
|
27
|
-
interface PaginatedResponse<T> {
|
|
28
|
-
data: T[];
|
|
29
|
-
startingAfter: Cursor | null;
|
|
30
|
-
startingBefore: Cursor | null;
|
|
31
|
-
}
|
|
32
|
-
declare const PaginatedResponse: {
|
|
33
|
-
fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Cursor-based pagination input used when requesting paginated API resources.
|
|
37
|
-
* Set `after` or `before` to navigate relative to a known cursor, and `limit`
|
|
38
|
-
* to control the maximum number of returned items.
|
|
39
|
-
*/
|
|
40
|
-
interface PaginationParams {
|
|
41
|
-
before?: Cursor;
|
|
42
|
-
after?: Cursor;
|
|
43
|
-
limit?: number;
|
|
44
|
-
}
|
|
45
|
-
declare const PaginationParams: {
|
|
46
|
-
toQueryParams: (params: PaginationParams) => Record<string, QueryParamValue>;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
type ParticipationStatusDto = 'prepared' | 'pending' | 'submitted' | 'completed' | 'failed' | 'remit_submitted' | 'remitted' | 'remit_failed';
|
|
50
|
-
type ParticipationDto = {
|
|
51
|
-
object: 'participation';
|
|
52
|
-
id: string;
|
|
53
|
-
offer_id: string;
|
|
54
|
-
offer_option_id: string;
|
|
55
|
-
status: ParticipationStatusDto;
|
|
56
|
-
amount: string;
|
|
57
|
-
amount_string: string;
|
|
58
|
-
asset: AssetDto;
|
|
59
|
-
chain: string;
|
|
60
|
-
inserted_at: string | null | undefined;
|
|
61
|
-
updated_at: string | null | undefined;
|
|
62
|
-
wallet_address: string | null | undefined;
|
|
63
|
-
};
|
|
64
|
-
type CreateParticipationDto = {
|
|
65
|
-
offer_id: string;
|
|
66
|
-
offer_option_id: string;
|
|
67
|
-
chain: string;
|
|
68
|
-
wallet_address: string;
|
|
69
|
-
amount: string;
|
|
70
|
-
asset_id: string;
|
|
71
|
-
approval_transaction_hash: string | null | undefined;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/** Unique identifier for a participation. */
|
|
75
|
-
type ParticipationId = Newtype<string, 'ParticipationId'>;
|
|
76
|
-
/** Casts a string into a typed {@link ParticipationId}. */
|
|
77
|
-
declare const ParticipationId: (value: string) => ParticipationId;
|
|
78
|
-
/** Blockchain identifier for where a participation is funded. */
|
|
79
|
-
type Blockchain = Newtype<string, 'Blockchain'>;
|
|
80
|
-
/** Casts a string into a typed {@link Blockchain}. */
|
|
81
|
-
declare const Blockchain: (value: string) => Blockchain;
|
|
82
|
-
/** Wallet address used for a participation. */
|
|
83
|
-
type WalletAddress = Newtype<string, 'WalletAddress'>;
|
|
84
|
-
/** Casts a string into a typed {@link WalletAddress}. */
|
|
85
|
-
declare const WalletAddress: (value: string) => WalletAddress;
|
|
86
|
-
/** Possible participation lifecycle states returned by the API. */
|
|
87
|
-
type ParticipationStatus = ParticipationStatusDto;
|
|
88
|
-
/** Pagination params for listing participations, with an optional offer filter. */
|
|
89
|
-
interface ParticipationsPaginationParams extends PaginationParams {
|
|
90
|
-
offerId?: OfferId;
|
|
91
|
-
}
|
|
92
|
-
declare const ParticipationsPaginationParams: {
|
|
93
|
-
toQueryParams: (params: ParticipationsPaginationParams) => Record<string, QueryParamValue>;
|
|
94
|
-
};
|
|
95
|
-
/** Domain model for a participation returned by CoinList APIs. */
|
|
96
|
-
type Participation = {
|
|
97
|
-
/** Unique participation id. */
|
|
98
|
-
id: ParticipationId;
|
|
99
|
-
/** Parent offer id. */
|
|
100
|
-
offerId: OfferId;
|
|
101
|
-
/** Selected offer option id. */
|
|
102
|
-
offerOptionId: OfferOptionId;
|
|
103
|
-
/** Current processing status. */
|
|
104
|
-
status: ParticipationStatus;
|
|
105
|
-
/** Raw participation amount from API. */
|
|
106
|
-
amount: string;
|
|
107
|
-
/** Human-readable formatted amount from API. */
|
|
108
|
-
displayAmount: string;
|
|
109
|
-
/** Asset metadata for the participation amount. */
|
|
110
|
-
asset: Asset;
|
|
111
|
-
/** Funding chain identifier. */
|
|
112
|
-
chain: Blockchain;
|
|
113
|
-
/** Creation timestamp, if returned by API. */
|
|
114
|
-
insertedAt: Date | null;
|
|
115
|
-
/** Last update timestamp, if returned by API. */
|
|
116
|
-
updatedAt: Date | null;
|
|
117
|
-
/** Wallet used for participation, blank values normalized to null. */
|
|
118
|
-
walletAddress: WalletAddress | null;
|
|
119
|
-
};
|
|
120
|
-
declare const Participation: {
|
|
121
|
-
/** Maps API DTO shape into the SDK participation domain model. */
|
|
122
|
-
fromDto: (dto: ParticipationDto) => Participation;
|
|
123
|
-
};
|
|
124
|
-
/** Parameters required to create a new participation. */
|
|
125
|
-
type CreateParticipationParams = {
|
|
126
|
-
/** Offer to participate in. */
|
|
127
|
-
offerId: OfferId;
|
|
128
|
-
/** Offer option selected for participation. */
|
|
129
|
-
offerOptionId: OfferOptionId;
|
|
130
|
-
/** Blockchain for funding. */
|
|
131
|
-
chain: Blockchain;
|
|
132
|
-
/** Wallet address that funds the participation. */
|
|
133
|
-
walletAddress: WalletAddress;
|
|
134
|
-
/** Raw amount to participate with. */
|
|
135
|
-
amount: string;
|
|
136
|
-
/** Funding asset id. */
|
|
137
|
-
assetId: AssetId;
|
|
138
|
-
/** Optional approval transaction hash, if applicable. */
|
|
139
|
-
approvalTransactionHash?: string | null;
|
|
140
|
-
};
|
|
141
|
-
declare const CreateParticipationParams: {
|
|
142
|
-
/** Maps participation creation params into API DTO payload. */
|
|
143
|
-
toDto: (params: CreateParticipationParams) => CreateParticipationDto;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
16
|
interface ClientConfig extends Config {
|
|
147
17
|
/**
|
|
148
18
|
* The SDK user must provide this function. It is responsible for fetching a
|
|
@@ -155,11 +25,7 @@ interface ClientConfig extends Config {
|
|
|
155
25
|
* Recommended to leave undefined. Used to change the CoinList environment;
|
|
156
26
|
* default is production.
|
|
157
27
|
*/
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Whether the SDK should enable sandbox mode (adds `sandbox=true` when listing offers).
|
|
161
|
-
*/
|
|
162
|
-
sandbox?: boolean;
|
|
28
|
+
coinlistBaseUrl?: string;
|
|
163
29
|
}
|
|
164
30
|
interface CoinListClient {
|
|
165
31
|
/**
|
|
@@ -277,7 +143,16 @@ interface CoinListClient {
|
|
|
277
143
|
* {@link NotAuthenticatedError}.
|
|
278
144
|
*/
|
|
279
145
|
fetchRequirementStatuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
|
|
146
|
+
/**
|
|
147
|
+
* Opens the CoinList page for completing a given requirement in a new tab.
|
|
148
|
+
* For `jurisdiction` requirements there is no CTA, so this is a no-op.
|
|
149
|
+
*/
|
|
150
|
+
handleRequirement(requirement: Requirement): void;
|
|
151
|
+
/**
|
|
152
|
+
* Opens the CoinList support ticket page in a new tab.
|
|
153
|
+
*/
|
|
154
|
+
contactSupport(): void;
|
|
280
155
|
}
|
|
281
156
|
declare function createCoinListClient(config: ClientConfig): CoinListClient;
|
|
282
157
|
|
|
283
|
-
export { type AuthState as A,
|
|
158
|
+
export { type AuthState as A, type ClientConfig as C, type OauthClientErrorReason as O, type CoinListClient as a, type OauthClientResult as b, createCoinListClient as c };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { A as AuthorizationCode, c as CodeVerifier,
|
|
2
|
-
import {
|
|
3
|
-
import { A as AssetDto, b as OfferId, d as OfferOptionId, k as Asset, l as AssetId, O as Offer, a as OfferDetail, R as Requirement, h as RequirementStatusInfo } from './requirement-CxbdY8l4.cjs';
|
|
1
|
+
import { A as AuthorizationCode, c as CodeVerifier, o as Config, O as OAuthAccessToken, i as PaginationParams, P as PaginatedResponse, j as Participation, m as ParticipationsPaginationParams, k as ParticipationId, d as CreateParticipationParams } from './participation-DMMEDxON.cjs';
|
|
2
|
+
import { O as Offer, b as OfferId, a as OfferDetail, d as OfferOptionId, R as Requirement, h as RequirementStatusInfo } from './requirement-XWT0T_zO.cjs';
|
|
4
3
|
|
|
5
4
|
type AuthState = 'unknown' | 'logged-in' | 'logged-out';
|
|
6
5
|
/** Discriminated error reasons from {@link CoinListClient.completeOAuth}. */
|
|
@@ -14,135 +13,6 @@ type OauthClientResult = {
|
|
|
14
13
|
reason: OauthClientErrorReason;
|
|
15
14
|
};
|
|
16
15
|
|
|
17
|
-
type QueryParamValue = string | number | boolean | null | undefined;
|
|
18
|
-
|
|
19
|
-
type Cursor = Newtype<string, 'Cursor'>;
|
|
20
|
-
declare const Cursor: (value: string) => Cursor;
|
|
21
|
-
interface PaginatedResponseDto<T> {
|
|
22
|
-
data: T[];
|
|
23
|
-
starting_after?: string;
|
|
24
|
-
starting_before?: string;
|
|
25
|
-
}
|
|
26
|
-
declare function fetchAllPages<A, P extends PaginationParams = PaginationParams>(fetchPage: (params: P) => Promise<PaginatedResponse<A>>, baseParams?: Omit<P, keyof PaginationParams>): Promise<A[]>;
|
|
27
|
-
interface PaginatedResponse<T> {
|
|
28
|
-
data: T[];
|
|
29
|
-
startingAfter: Cursor | null;
|
|
30
|
-
startingBefore: Cursor | null;
|
|
31
|
-
}
|
|
32
|
-
declare const PaginatedResponse: {
|
|
33
|
-
fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Cursor-based pagination input used when requesting paginated API resources.
|
|
37
|
-
* Set `after` or `before` to navigate relative to a known cursor, and `limit`
|
|
38
|
-
* to control the maximum number of returned items.
|
|
39
|
-
*/
|
|
40
|
-
interface PaginationParams {
|
|
41
|
-
before?: Cursor;
|
|
42
|
-
after?: Cursor;
|
|
43
|
-
limit?: number;
|
|
44
|
-
}
|
|
45
|
-
declare const PaginationParams: {
|
|
46
|
-
toQueryParams: (params: PaginationParams) => Record<string, QueryParamValue>;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
type ParticipationStatusDto = 'prepared' | 'pending' | 'submitted' | 'completed' | 'failed' | 'remit_submitted' | 'remitted' | 'remit_failed';
|
|
50
|
-
type ParticipationDto = {
|
|
51
|
-
object: 'participation';
|
|
52
|
-
id: string;
|
|
53
|
-
offer_id: string;
|
|
54
|
-
offer_option_id: string;
|
|
55
|
-
status: ParticipationStatusDto;
|
|
56
|
-
amount: string;
|
|
57
|
-
amount_string: string;
|
|
58
|
-
asset: AssetDto;
|
|
59
|
-
chain: string;
|
|
60
|
-
inserted_at: string | null | undefined;
|
|
61
|
-
updated_at: string | null | undefined;
|
|
62
|
-
wallet_address: string | null | undefined;
|
|
63
|
-
};
|
|
64
|
-
type CreateParticipationDto = {
|
|
65
|
-
offer_id: string;
|
|
66
|
-
offer_option_id: string;
|
|
67
|
-
chain: string;
|
|
68
|
-
wallet_address: string;
|
|
69
|
-
amount: string;
|
|
70
|
-
asset_id: string;
|
|
71
|
-
approval_transaction_hash: string | null | undefined;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/** Unique identifier for a participation. */
|
|
75
|
-
type ParticipationId = Newtype<string, 'ParticipationId'>;
|
|
76
|
-
/** Casts a string into a typed {@link ParticipationId}. */
|
|
77
|
-
declare const ParticipationId: (value: string) => ParticipationId;
|
|
78
|
-
/** Blockchain identifier for where a participation is funded. */
|
|
79
|
-
type Blockchain = Newtype<string, 'Blockchain'>;
|
|
80
|
-
/** Casts a string into a typed {@link Blockchain}. */
|
|
81
|
-
declare const Blockchain: (value: string) => Blockchain;
|
|
82
|
-
/** Wallet address used for a participation. */
|
|
83
|
-
type WalletAddress = Newtype<string, 'WalletAddress'>;
|
|
84
|
-
/** Casts a string into a typed {@link WalletAddress}. */
|
|
85
|
-
declare const WalletAddress: (value: string) => WalletAddress;
|
|
86
|
-
/** Possible participation lifecycle states returned by the API. */
|
|
87
|
-
type ParticipationStatus = ParticipationStatusDto;
|
|
88
|
-
/** Pagination params for listing participations, with an optional offer filter. */
|
|
89
|
-
interface ParticipationsPaginationParams extends PaginationParams {
|
|
90
|
-
offerId?: OfferId;
|
|
91
|
-
}
|
|
92
|
-
declare const ParticipationsPaginationParams: {
|
|
93
|
-
toQueryParams: (params: ParticipationsPaginationParams) => Record<string, QueryParamValue>;
|
|
94
|
-
};
|
|
95
|
-
/** Domain model for a participation returned by CoinList APIs. */
|
|
96
|
-
type Participation = {
|
|
97
|
-
/** Unique participation id. */
|
|
98
|
-
id: ParticipationId;
|
|
99
|
-
/** Parent offer id. */
|
|
100
|
-
offerId: OfferId;
|
|
101
|
-
/** Selected offer option id. */
|
|
102
|
-
offerOptionId: OfferOptionId;
|
|
103
|
-
/** Current processing status. */
|
|
104
|
-
status: ParticipationStatus;
|
|
105
|
-
/** Raw participation amount from API. */
|
|
106
|
-
amount: string;
|
|
107
|
-
/** Human-readable formatted amount from API. */
|
|
108
|
-
displayAmount: string;
|
|
109
|
-
/** Asset metadata for the participation amount. */
|
|
110
|
-
asset: Asset;
|
|
111
|
-
/** Funding chain identifier. */
|
|
112
|
-
chain: Blockchain;
|
|
113
|
-
/** Creation timestamp, if returned by API. */
|
|
114
|
-
insertedAt: Date | null;
|
|
115
|
-
/** Last update timestamp, if returned by API. */
|
|
116
|
-
updatedAt: Date | null;
|
|
117
|
-
/** Wallet used for participation, blank values normalized to null. */
|
|
118
|
-
walletAddress: WalletAddress | null;
|
|
119
|
-
};
|
|
120
|
-
declare const Participation: {
|
|
121
|
-
/** Maps API DTO shape into the SDK participation domain model. */
|
|
122
|
-
fromDto: (dto: ParticipationDto) => Participation;
|
|
123
|
-
};
|
|
124
|
-
/** Parameters required to create a new participation. */
|
|
125
|
-
type CreateParticipationParams = {
|
|
126
|
-
/** Offer to participate in. */
|
|
127
|
-
offerId: OfferId;
|
|
128
|
-
/** Offer option selected for participation. */
|
|
129
|
-
offerOptionId: OfferOptionId;
|
|
130
|
-
/** Blockchain for funding. */
|
|
131
|
-
chain: Blockchain;
|
|
132
|
-
/** Wallet address that funds the participation. */
|
|
133
|
-
walletAddress: WalletAddress;
|
|
134
|
-
/** Raw amount to participate with. */
|
|
135
|
-
amount: string;
|
|
136
|
-
/** Funding asset id. */
|
|
137
|
-
assetId: AssetId;
|
|
138
|
-
/** Optional approval transaction hash, if applicable. */
|
|
139
|
-
approvalTransactionHash?: string | null;
|
|
140
|
-
};
|
|
141
|
-
declare const CreateParticipationParams: {
|
|
142
|
-
/** Maps participation creation params into API DTO payload. */
|
|
143
|
-
toDto: (params: CreateParticipationParams) => CreateParticipationDto;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
16
|
interface ClientConfig extends Config {
|
|
147
17
|
/**
|
|
148
18
|
* The SDK user must provide this function. It is responsible for fetching a
|
|
@@ -155,11 +25,7 @@ interface ClientConfig extends Config {
|
|
|
155
25
|
* Recommended to leave undefined. Used to change the CoinList environment;
|
|
156
26
|
* default is production.
|
|
157
27
|
*/
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Whether the SDK should enable sandbox mode (adds `sandbox=true` when listing offers).
|
|
161
|
-
*/
|
|
162
|
-
sandbox?: boolean;
|
|
28
|
+
coinlistBaseUrl?: string;
|
|
163
29
|
}
|
|
164
30
|
interface CoinListClient {
|
|
165
31
|
/**
|
|
@@ -277,7 +143,16 @@ interface CoinListClient {
|
|
|
277
143
|
* {@link NotAuthenticatedError}.
|
|
278
144
|
*/
|
|
279
145
|
fetchRequirementStatuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
|
|
146
|
+
/**
|
|
147
|
+
* Opens the CoinList page for completing a given requirement in a new tab.
|
|
148
|
+
* For `jurisdiction` requirements there is no CTA, so this is a no-op.
|
|
149
|
+
*/
|
|
150
|
+
handleRequirement(requirement: Requirement): void;
|
|
151
|
+
/**
|
|
152
|
+
* Opens the CoinList support ticket page in a new tab.
|
|
153
|
+
*/
|
|
154
|
+
contactSupport(): void;
|
|
280
155
|
}
|
|
281
156
|
declare function createCoinListClient(config: ClientConfig): CoinListClient;
|
|
282
157
|
|
|
283
|
-
export { type AuthState as A,
|
|
158
|
+
export { type AuthState as A, type ClientConfig as C, type OauthClientErrorReason as O, type CoinListClient as a, type OauthClientResult as b, createCoinListClient as c };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { N as Newtype, A as AssetDto, b as OfferId, d as OfferOptionId, k as Asset, l as AssetId } from './requirement-XWT0T_zO.cjs';
|
|
2
|
+
|
|
3
|
+
type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;
|
|
4
|
+
declare const AuthorizationCode: (value: string) => AuthorizationCode;
|
|
5
|
+
type CodeVerifier = Newtype<string, 'CodeVerifier'>;
|
|
6
|
+
declare const CodeVerifier: (value: string) => CodeVerifier;
|
|
7
|
+
type CodeChallenge = Newtype<string, 'CodeChallenge'>;
|
|
8
|
+
declare const CodeChallenge: (value: string) => CodeChallenge;
|
|
9
|
+
type RedirectUri = Newtype<string, 'RedirectUri'>;
|
|
10
|
+
declare const RedirectUri: (value: string) => RedirectUri;
|
|
11
|
+
type ClientId = Newtype<string, 'ClientId'>;
|
|
12
|
+
declare const ClientId: (value: string) => ClientId;
|
|
13
|
+
type ClientSecret = Newtype<string, 'ClientSecret'>;
|
|
14
|
+
declare const ClientSecret: (value: string) => ClientSecret;
|
|
15
|
+
|
|
16
|
+
type QueryParamValue = string | number | boolean | null | undefined;
|
|
17
|
+
|
|
18
|
+
type Cursor = Newtype<string, 'Cursor'>;
|
|
19
|
+
declare const Cursor: (value: string) => Cursor;
|
|
20
|
+
interface PaginatedResponseDto<T> {
|
|
21
|
+
data: T[];
|
|
22
|
+
starting_after?: string;
|
|
23
|
+
starting_before?: string;
|
|
24
|
+
}
|
|
25
|
+
declare function fetchAllPages<A, P extends PaginationParams = PaginationParams>(fetchPage: (params: P) => Promise<PaginatedResponse<A>>, baseParams?: Omit<P, keyof PaginationParams>): Promise<A[]>;
|
|
26
|
+
interface PaginatedResponse<T> {
|
|
27
|
+
data: T[];
|
|
28
|
+
startingAfter: Cursor | null;
|
|
29
|
+
startingBefore: Cursor | null;
|
|
30
|
+
}
|
|
31
|
+
declare const PaginatedResponse: {
|
|
32
|
+
fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Cursor-based pagination input used when requesting paginated API resources.
|
|
36
|
+
* Set `after` or `before` to navigate relative to a known cursor, and `limit`
|
|
37
|
+
* to control the maximum number of returned items.
|
|
38
|
+
*/
|
|
39
|
+
interface PaginationParams {
|
|
40
|
+
before?: Cursor;
|
|
41
|
+
after?: Cursor;
|
|
42
|
+
limit?: number;
|
|
43
|
+
}
|
|
44
|
+
declare const PaginationParams: {
|
|
45
|
+
toQueryParams: (params: PaginationParams) => Record<string, QueryParamValue>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
interface Config {
|
|
49
|
+
/** OAuth2 public identifier. */
|
|
50
|
+
readonly clientId: ClientId;
|
|
51
|
+
/**
|
|
52
|
+
* OAuth2 redirect URI. Recommended to point to a frontend page where
|
|
53
|
+
* {@link CoinListClient#completeOauth} can be called to complete the PKCE
|
|
54
|
+
* flow on the client side.
|
|
55
|
+
*/
|
|
56
|
+
readonly redirectUri: RedirectUri;
|
|
57
|
+
/**
|
|
58
|
+
* Recommended to leave undefined. Used to change the CoinList environment;
|
|
59
|
+
* default is production.
|
|
60
|
+
*/
|
|
61
|
+
readonly baseUrl?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* OAuth 2.0 token response (RFC 6749 §5.1).
|
|
66
|
+
* Maps to OpenAPI schema OauthToken.
|
|
67
|
+
*/
|
|
68
|
+
type OAuthSessionDto = {
|
|
69
|
+
access_token: string;
|
|
70
|
+
expires_in: number;
|
|
71
|
+
refresh_token?: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type OAuthAccessToken = {
|
|
75
|
+
value: string;
|
|
76
|
+
expiresAt: Date;
|
|
77
|
+
};
|
|
78
|
+
type OAuthRefreshToken = Newtype<string, 'OAuthRefreshToken'>;
|
|
79
|
+
declare const OAuthRefreshToken: (value: string) => OAuthRefreshToken;
|
|
80
|
+
type OAuthSession = {
|
|
81
|
+
accessToken: OAuthAccessToken;
|
|
82
|
+
refreshToken?: OAuthRefreshToken;
|
|
83
|
+
};
|
|
84
|
+
declare const OAuthSession: {
|
|
85
|
+
fromDto: (dto: OAuthSessionDto) => OAuthSession;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
type ParticipationStatusDto = 'prepared' | 'pending' | 'submitted' | 'completed' | 'failed' | 'remit_submitted' | 'remitted' | 'remit_failed';
|
|
89
|
+
type ParticipationDto = {
|
|
90
|
+
object: 'participation';
|
|
91
|
+
id: string;
|
|
92
|
+
offer_id: string;
|
|
93
|
+
offer_option_id: string;
|
|
94
|
+
status: ParticipationStatusDto;
|
|
95
|
+
amount: string;
|
|
96
|
+
amount_string: string;
|
|
97
|
+
asset: AssetDto;
|
|
98
|
+
chain: string;
|
|
99
|
+
inserted_at: string | null | undefined;
|
|
100
|
+
updated_at: string | null | undefined;
|
|
101
|
+
wallet_address: string | null | undefined;
|
|
102
|
+
};
|
|
103
|
+
type CreateParticipationDto = {
|
|
104
|
+
offer_id: string;
|
|
105
|
+
offer_option_id: string;
|
|
106
|
+
chain: string;
|
|
107
|
+
wallet_address: string;
|
|
108
|
+
amount: string;
|
|
109
|
+
asset_id: string;
|
|
110
|
+
approval_transaction_hash: string | null | undefined;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Unique identifier for a participation. */
|
|
114
|
+
type ParticipationId = Newtype<string, 'ParticipationId'>;
|
|
115
|
+
/** Casts a string into a typed {@link ParticipationId}. */
|
|
116
|
+
declare const ParticipationId: (value: string) => ParticipationId;
|
|
117
|
+
/** Blockchain identifier for where a participation is funded. */
|
|
118
|
+
type Blockchain = Newtype<string, 'Blockchain'>;
|
|
119
|
+
/** Casts a string into a typed {@link Blockchain}. */
|
|
120
|
+
declare const Blockchain: (value: string) => Blockchain;
|
|
121
|
+
/** Wallet address used for a participation. */
|
|
122
|
+
type WalletAddress = Newtype<string, 'WalletAddress'>;
|
|
123
|
+
/** Casts a string into a typed {@link WalletAddress}. */
|
|
124
|
+
declare const WalletAddress: (value: string) => WalletAddress;
|
|
125
|
+
/** Possible participation lifecycle states returned by the API. */
|
|
126
|
+
type ParticipationStatus = ParticipationStatusDto;
|
|
127
|
+
/** Pagination params for listing participations, with an optional offer filter. */
|
|
128
|
+
interface ParticipationsPaginationParams extends PaginationParams {
|
|
129
|
+
offerId?: OfferId;
|
|
130
|
+
}
|
|
131
|
+
declare const ParticipationsPaginationParams: {
|
|
132
|
+
toQueryParams: (params: ParticipationsPaginationParams) => Record<string, QueryParamValue>;
|
|
133
|
+
};
|
|
134
|
+
/** Domain model for a participation returned by CoinList APIs. */
|
|
135
|
+
type Participation = {
|
|
136
|
+
/** Unique participation id. */
|
|
137
|
+
id: ParticipationId;
|
|
138
|
+
/** Parent offer id. */
|
|
139
|
+
offerId: OfferId;
|
|
140
|
+
/** Selected offer option id. */
|
|
141
|
+
offerOptionId: OfferOptionId;
|
|
142
|
+
/** Current processing status. */
|
|
143
|
+
status: ParticipationStatus;
|
|
144
|
+
/** Raw participation amount from API. */
|
|
145
|
+
amount: string;
|
|
146
|
+
/** Human-readable formatted amount from API. */
|
|
147
|
+
displayAmount: string;
|
|
148
|
+
/** Asset metadata for the participation amount. */
|
|
149
|
+
asset: Asset;
|
|
150
|
+
/** Funding chain identifier. */
|
|
151
|
+
chain: Blockchain;
|
|
152
|
+
/** Creation timestamp, if returned by API. */
|
|
153
|
+
insertedAt: Date | null;
|
|
154
|
+
/** Last update timestamp, if returned by API. */
|
|
155
|
+
updatedAt: Date | null;
|
|
156
|
+
/** Wallet used for participation, blank values normalized to null. */
|
|
157
|
+
walletAddress: WalletAddress | null;
|
|
158
|
+
};
|
|
159
|
+
declare const Participation: {
|
|
160
|
+
/** Maps API DTO shape into the SDK participation domain model. */
|
|
161
|
+
fromDto: (dto: ParticipationDto) => Participation;
|
|
162
|
+
};
|
|
163
|
+
/** Parameters required to create a new participation. */
|
|
164
|
+
type CreateParticipationParams = {
|
|
165
|
+
/** Offer to participate in. */
|
|
166
|
+
offerId: OfferId;
|
|
167
|
+
/** Offer option selected for participation. */
|
|
168
|
+
offerOptionId: OfferOptionId;
|
|
169
|
+
/** Blockchain for funding. */
|
|
170
|
+
chain: Blockchain;
|
|
171
|
+
/** Wallet address that funds the participation. */
|
|
172
|
+
walletAddress: WalletAddress;
|
|
173
|
+
/** Raw amount to participate with. */
|
|
174
|
+
amount: string;
|
|
175
|
+
/** Funding asset id. */
|
|
176
|
+
assetId: AssetId;
|
|
177
|
+
/** Optional approval transaction hash, if applicable. */
|
|
178
|
+
approvalTransactionHash?: string | null;
|
|
179
|
+
};
|
|
180
|
+
declare const CreateParticipationParams: {
|
|
181
|
+
/** Maps participation creation params into API DTO payload. */
|
|
182
|
+
toDto: (params: CreateParticipationParams) => CreateParticipationDto;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export { AuthorizationCode as A, Blockchain as B, ClientId as C, type OAuthAccessToken as O, PaginatedResponse as P, RedirectUri as R, WalletAddress as W, ClientSecret as a, CodeChallenge as b, CodeVerifier as c, CreateParticipationParams as d, Cursor as e, OAuthRefreshToken as f, OAuthSession as g, type PaginatedResponseDto as h, PaginationParams as i, Participation as j, ParticipationId as k, type ParticipationStatus as l, ParticipationsPaginationParams as m, fetchAllPages as n, type Config as o };
|