@settlemint/sdk-portal 2.3.2 → 2.3.3
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/README.md +337 -19
- package/dist/browser/portal.d.ts +252 -0
- package/dist/browser/portal.js +294 -0
- package/dist/browser/portal.js.map +1 -0
- package/dist/portal.cjs +281 -172
- package/dist/portal.cjs.map +1 -1
- package/dist/portal.d.cts +145 -115
- package/dist/portal.d.ts +145 -115
- package/dist/portal.js +294 -0
- package/dist/portal.js.map +1 -0
- package/package.json +6 -6
- package/dist/portal.mjs +0 -188
- package/dist/portal.mjs.map +0 -1
package/dist/portal.d.cts
CHANGED
|
@@ -1,130 +1,94 @@
|
|
|
1
|
-
import { AbstractSetupSchema, initGraphQLTada } from
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import * as graphql_ws from 'graphql-ws';
|
|
1
|
+
import { AbstractSetupSchema, FragmentOf, ResultOf, VariablesOf, initGraphQLTada, readFragment } from "gql.tada";
|
|
2
|
+
import { GraphQLClient } from "graphql-request";
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
|
+
import { Address, Hex, TransactionReceipt as TransactionReceipt$1 } from "viem";
|
|
5
|
+
import * as graphql_ws0 from "graphql-ws";
|
|
7
6
|
|
|
7
|
+
//#region src/utils/websocket-client.d.ts
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* @property {GraphQLClient} portalClient - The portal client instance
|
|
14
|
-
* @property {initGraphQLTada<Setup>} portalGraphql - The GraphQL query builder
|
|
15
|
-
* @property {string} verificationId - The ID of the verification challenge
|
|
16
|
-
* @property {Address} userWalletAddress - The wallet address to verify
|
|
17
|
-
* @property {string | number} code - The verification code provided by the user
|
|
18
|
-
* @property {"otp" | "secret-code" | "pincode"} verificationType - The type of verification being performed
|
|
9
|
+
* Options for the GraphQL WebSocket client
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Options for the GraphQL WebSocket client
|
|
19
13
|
*/
|
|
20
|
-
interface
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
interface WebsocketClientOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The GraphQL endpoint URL for the Portal API
|
|
17
|
+
*/
|
|
18
|
+
portalGraphqlEndpoint: string;
|
|
19
|
+
/**
|
|
20
|
+
* The access token for authentication with the Portal API
|
|
21
|
+
*/
|
|
22
|
+
accessToken?: string;
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
25
|
+
* Creates a GraphQL WebSocket client for the Portal API
|
|
30
26
|
*
|
|
31
|
-
* @param options - The options for
|
|
32
|
-
* @returns
|
|
33
|
-
* @throws {ChallengeError} If the challenge cannot be created or is invalid
|
|
27
|
+
* @param {WebsocketClientOptions} options - The options for the client
|
|
28
|
+
* @returns {Client} The GraphQL WebSocket client
|
|
34
29
|
* @example
|
|
35
|
-
* import {
|
|
36
|
-
* import { handleWalletVerificationChallenge } from "@settlemint/sdk-portal";
|
|
30
|
+
* import { getWebsocketClient } from "@settlemint/sdk-portal";
|
|
37
31
|
*
|
|
38
|
-
* const
|
|
39
|
-
*
|
|
40
|
-
* accessToken: "your-access-token"
|
|
41
|
-
* });
|
|
42
|
-
*
|
|
43
|
-
* const result = await handleWalletVerificationChallenge({
|
|
44
|
-
* portalClient: client,
|
|
45
|
-
* portalGraphql: graphql,
|
|
46
|
-
* verificationId: "verification-123",
|
|
47
|
-
* userWalletAddress: "0x123...",
|
|
48
|
-
* code: "123456",
|
|
49
|
-
* verificationType: "otp"
|
|
32
|
+
* const client = getWebsocketClient({
|
|
33
|
+
* portalGraphqlEndpoint: "https://portal.settlemint.com/graphql",
|
|
34
|
+
* accessToken: "your-access-token",
|
|
50
35
|
* });
|
|
51
36
|
*/
|
|
52
|
-
declare function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
37
|
+
declare function getWebsocketClient({
|
|
38
|
+
portalGraphqlEndpoint,
|
|
39
|
+
accessToken
|
|
40
|
+
}: WebsocketClientOptions): graphql_ws0.Client;
|
|
56
41
|
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/utils/wait-for-transaction-receipt.d.ts
|
|
57
44
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @typedef {Object} WebsocketClientOptions
|
|
61
|
-
* @property {string} portalGraphqlEndpoint - The GraphQL endpoint URL for the Portal API
|
|
62
|
-
* @property {string} accessToken - The access token for authentication with the Portal API
|
|
45
|
+
* Represents an event emitted during a transaction execution
|
|
63
46
|
*/
|
|
64
|
-
interface
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
interface TransactionEvent {
|
|
48
|
+
/** The name of the event that was emitted */
|
|
49
|
+
eventName: string;
|
|
50
|
+
/** The arguments emitted by the event */
|
|
51
|
+
args: Record<string, unknown>;
|
|
52
|
+
/** Indexed event parameters used for filtering and searching */
|
|
53
|
+
topics: Hex[];
|
|
67
54
|
}
|
|
68
55
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @param {WebsocketClientOptions} options - The options for the client
|
|
72
|
-
* @param {string} options.portalGraphqlEndpoint - The GraphQL endpoint URL for the Portal API
|
|
73
|
-
* @param {string} options.accessToken - The access token for authentication with the Portal API
|
|
74
|
-
* @returns {Client} The GraphQL WebSocket client
|
|
56
|
+
* Represents the structure of a blockchain transaction receipt
|
|
75
57
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
interface TransactionReceipt extends TransactionReceipt$1<string, number, "Success" | "Reverted"> {
|
|
59
|
+
/** The raw reason for transaction reversion, if applicable */
|
|
60
|
+
revertReason: string;
|
|
61
|
+
/** Human-readable version of the revert reason */
|
|
62
|
+
revertReasonDecoded: string;
|
|
63
|
+
/** Array of events emitted during the transaction */
|
|
64
|
+
events: TransactionEvent[];
|
|
65
|
+
/** The address of the contract deployed in the transaction */
|
|
66
|
+
contractAddress: Address;
|
|
67
|
+
}
|
|
78
68
|
/**
|
|
79
69
|
* Represents the structure of a blockchain transaction with its receipt
|
|
80
|
-
*
|
|
81
|
-
* @typedef {Object} Transaction
|
|
82
|
-
* @property {Object} receipt - The transaction receipt details
|
|
83
|
-
* @property {string} receipt.transactionHash - The hash of the transaction
|
|
84
|
-
* @property {string} receipt.to - The recipient address of the transaction
|
|
85
|
-
* @property {string} receipt.status - The status of the transaction (success/failure)
|
|
86
|
-
* @property {string} receipt.from - The sender address of the transaction
|
|
87
|
-
* @property {string} receipt.type - The type of the transaction
|
|
88
|
-
* @property {string} receipt.revertReason - The reason for transaction reversion, if applicable
|
|
89
|
-
* @property {string} receipt.revertReasonDecoded - Human-readable version of the revert reason
|
|
90
|
-
* @property {string} receipt.contractAddress - The address of the contract deployed in the transaction
|
|
91
|
-
* @property {string[]} receipt.logs - Array of log entries generated by the transaction
|
|
92
|
-
* @property {string[]} receipt.events - Array of events emitted during the transaction
|
|
93
|
-
* @property {string} transactionHash - The hash of the transaction (duplicate of receipt.transactionHash)
|
|
94
|
-
* @property {string} from - The sender address (duplicate of receipt.from)
|
|
95
|
-
* @property {string} createdAt - Timestamp when the transaction was created
|
|
96
|
-
* @property {string} address - The contract address involved in the transaction
|
|
97
|
-
* @property {string} functionName - The name of the function called in the transaction
|
|
98
|
-
* @property {boolean} isContract - Whether the transaction is a contract deployment
|
|
99
70
|
*/
|
|
100
71
|
interface Transaction {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
from: string;
|
|
115
|
-
createdAt: string;
|
|
116
|
-
address: string;
|
|
117
|
-
functionName: string;
|
|
118
|
-
isContract: boolean;
|
|
72
|
+
receipt: TransactionReceipt;
|
|
73
|
+
/** The hash of the transaction (duplicate of receipt.transactionHash) */
|
|
74
|
+
transactionHash: string;
|
|
75
|
+
/** The sender address (duplicate of receipt.from) */
|
|
76
|
+
from: string;
|
|
77
|
+
/** Timestamp when the transaction was created */
|
|
78
|
+
createdAt: string;
|
|
79
|
+
/** The contract address involved in the transaction */
|
|
80
|
+
address: string;
|
|
81
|
+
/** The name of the function called in the transaction */
|
|
82
|
+
functionName: string;
|
|
83
|
+
/** Whether the transaction is a contract deployment */
|
|
84
|
+
isContract: boolean;
|
|
119
85
|
}
|
|
120
86
|
/**
|
|
121
87
|
* Options for waiting for a transaction receipt
|
|
122
|
-
*
|
|
123
|
-
* @typedef {Object} WaitForTransactionReceiptOptions
|
|
124
|
-
* @property {number} [timeout] - Optional timeout in milliseconds before the operation fails
|
|
125
88
|
*/
|
|
126
89
|
interface WaitForTransactionReceiptOptions extends WebsocketClientOptions {
|
|
127
|
-
|
|
90
|
+
/** Optional timeout in milliseconds before the operation fails */
|
|
91
|
+
timeout?: number;
|
|
128
92
|
}
|
|
129
93
|
/**
|
|
130
94
|
* Waits for a blockchain transaction receipt by subscribing to transaction updates via GraphQL.
|
|
@@ -146,6 +110,70 @@ interface WaitForTransactionReceiptOptions extends WebsocketClientOptions {
|
|
|
146
110
|
*/
|
|
147
111
|
declare function waitForTransactionReceipt(transactionHash: string, options: WaitForTransactionReceiptOptions): Promise<Transaction>;
|
|
148
112
|
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/utils/wallet-verification-challenge.d.ts
|
|
115
|
+
/**
|
|
116
|
+
* Custom error class for challenge-related errors
|
|
117
|
+
*/
|
|
118
|
+
declare class ChallengeError extends Error {
|
|
119
|
+
readonly code: string;
|
|
120
|
+
constructor(message: string, code: string);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Options for handling a wallet verification challenge
|
|
124
|
+
*/
|
|
125
|
+
interface HandleWalletVerificationChallengeOptions<Setup extends AbstractSetupSchema> {
|
|
126
|
+
/** The portal client instance */
|
|
127
|
+
portalClient: GraphQLClient;
|
|
128
|
+
/** The GraphQL query builder */
|
|
129
|
+
portalGraphql: initGraphQLTada<Setup>;
|
|
130
|
+
/** The ID of the verification challenge */
|
|
131
|
+
verificationId: string;
|
|
132
|
+
/** The wallet address to verify */
|
|
133
|
+
userWalletAddress: Address;
|
|
134
|
+
/** The verification code provided by the user */
|
|
135
|
+
code: string | number;
|
|
136
|
+
/** The type of verification being performed */
|
|
137
|
+
verificationType: "otp" | "secret-code" | "pincode";
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Handles a wallet verification challenge by generating an appropriate response
|
|
141
|
+
*
|
|
142
|
+
* @param options - The options for handling the wallet verification challenge
|
|
143
|
+
* @returns Promise resolving to an object containing the challenge response and optionally the verification ID
|
|
144
|
+
* @throws {ChallengeError} If the challenge cannot be created or is invalid
|
|
145
|
+
* @example
|
|
146
|
+
* import { createPortalClient } from "@settlemint/sdk-portal";
|
|
147
|
+
* import { handleWalletVerificationChallenge } from "@settlemint/sdk-portal";
|
|
148
|
+
*
|
|
149
|
+
* const { client, graphql } = createPortalClient({
|
|
150
|
+
* instance: "https://portal.example.com/graphql",
|
|
151
|
+
* accessToken: "your-access-token"
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* const result = await handleWalletVerificationChallenge({
|
|
155
|
+
* portalClient: client,
|
|
156
|
+
* portalGraphql: graphql,
|
|
157
|
+
* verificationId: "verification-123",
|
|
158
|
+
* userWalletAddress: "0x123...",
|
|
159
|
+
* code: "123456",
|
|
160
|
+
* verificationType: "otp"
|
|
161
|
+
* });
|
|
162
|
+
*/
|
|
163
|
+
declare function handleWalletVerificationChallenge<const Setup extends AbstractSetupSchema>({
|
|
164
|
+
portalClient,
|
|
165
|
+
portalGraphql,
|
|
166
|
+
verificationId,
|
|
167
|
+
userWalletAddress,
|
|
168
|
+
code,
|
|
169
|
+
verificationType
|
|
170
|
+
}: HandleWalletVerificationChallengeOptions<Setup>): Promise<{
|
|
171
|
+
challengeResponse: string;
|
|
172
|
+
verificationId?: string;
|
|
173
|
+
}>;
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/portal.d.ts
|
|
149
177
|
/**
|
|
150
178
|
* Configuration options for the GraphQL client, excluding 'url' and 'exchanges'.
|
|
151
179
|
*/
|
|
@@ -154,16 +182,16 @@ type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
|
|
|
154
182
|
* Schema for validating Portal client configuration options.
|
|
155
183
|
*/
|
|
156
184
|
declare const ClientOptionsSchema: z.ZodObject<{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
instance: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
186
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
187
|
+
cache: z.ZodOptional<z.ZodEnum<{
|
|
188
|
+
default: "default";
|
|
189
|
+
"force-cache": "force-cache";
|
|
190
|
+
"no-cache": "no-cache";
|
|
191
|
+
"no-store": "no-store";
|
|
192
|
+
"only-if-cached": "only-if-cached";
|
|
193
|
+
reload: "reload";
|
|
194
|
+
}>>;
|
|
167
195
|
}, z.core.$strip>;
|
|
168
196
|
/**
|
|
169
197
|
* Type representing the validated client options.
|
|
@@ -215,8 +243,10 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
215
243
|
* const result = await portalClient.request(query);
|
|
216
244
|
*/
|
|
217
245
|
declare function createPortalClient<const Setup extends AbstractSetupSchema>(options: ClientOptions, clientOptions?: RequestConfig): {
|
|
218
|
-
|
|
219
|
-
|
|
246
|
+
client: GraphQLClient;
|
|
247
|
+
graphql: initGraphQLTada<Setup>;
|
|
220
248
|
};
|
|
221
249
|
|
|
222
|
-
|
|
250
|
+
//#endregion
|
|
251
|
+
export { ClientOptions, ClientOptionsSchema, FragmentOf, HandleWalletVerificationChallengeOptions, RequestConfig, ResultOf, Transaction, TransactionEvent, TransactionReceipt, VariablesOf, WaitForTransactionReceiptOptions, WebsocketClientOptions, createPortalClient, getWebsocketClient, handleWalletVerificationChallenge, readFragment, waitForTransactionReceipt };
|
|
252
|
+
//# sourceMappingURL=portal.d.cts.map
|
package/dist/portal.d.ts
CHANGED
|
@@ -1,130 +1,94 @@
|
|
|
1
|
-
import { AbstractSetupSchema, initGraphQLTada } from
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { Address } from
|
|
6
|
-
import * as graphql_ws from 'graphql-ws';
|
|
1
|
+
import { AbstractSetupSchema, FragmentOf, ResultOf, VariablesOf, initGraphQLTada, readFragment } from "gql.tada";
|
|
2
|
+
import { GraphQLClient } from "graphql-request";
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
|
+
import * as graphql_ws0 from "graphql-ws";
|
|
5
|
+
import { Address, Hex, TransactionReceipt as TransactionReceipt$1 } from "viem";
|
|
7
6
|
|
|
7
|
+
//#region src/utils/websocket-client.d.ts
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* @property {GraphQLClient} portalClient - The portal client instance
|
|
14
|
-
* @property {initGraphQLTada<Setup>} portalGraphql - The GraphQL query builder
|
|
15
|
-
* @property {string} verificationId - The ID of the verification challenge
|
|
16
|
-
* @property {Address} userWalletAddress - The wallet address to verify
|
|
17
|
-
* @property {string | number} code - The verification code provided by the user
|
|
18
|
-
* @property {"otp" | "secret-code" | "pincode"} verificationType - The type of verification being performed
|
|
9
|
+
* Options for the GraphQL WebSocket client
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Options for the GraphQL WebSocket client
|
|
19
13
|
*/
|
|
20
|
-
interface
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
interface WebsocketClientOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The GraphQL endpoint URL for the Portal API
|
|
17
|
+
*/
|
|
18
|
+
portalGraphqlEndpoint: string;
|
|
19
|
+
/**
|
|
20
|
+
* The access token for authentication with the Portal API
|
|
21
|
+
*/
|
|
22
|
+
accessToken?: string;
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
25
|
+
* Creates a GraphQL WebSocket client for the Portal API
|
|
30
26
|
*
|
|
31
|
-
* @param options - The options for
|
|
32
|
-
* @returns
|
|
33
|
-
* @throws {ChallengeError} If the challenge cannot be created or is invalid
|
|
27
|
+
* @param {WebsocketClientOptions} options - The options for the client
|
|
28
|
+
* @returns {Client} The GraphQL WebSocket client
|
|
34
29
|
* @example
|
|
35
|
-
* import {
|
|
36
|
-
* import { handleWalletVerificationChallenge } from "@settlemint/sdk-portal";
|
|
30
|
+
* import { getWebsocketClient } from "@settlemint/sdk-portal";
|
|
37
31
|
*
|
|
38
|
-
* const
|
|
39
|
-
*
|
|
40
|
-
* accessToken: "your-access-token"
|
|
41
|
-
* });
|
|
42
|
-
*
|
|
43
|
-
* const result = await handleWalletVerificationChallenge({
|
|
44
|
-
* portalClient: client,
|
|
45
|
-
* portalGraphql: graphql,
|
|
46
|
-
* verificationId: "verification-123",
|
|
47
|
-
* userWalletAddress: "0x123...",
|
|
48
|
-
* code: "123456",
|
|
49
|
-
* verificationType: "otp"
|
|
32
|
+
* const client = getWebsocketClient({
|
|
33
|
+
* portalGraphqlEndpoint: "https://portal.settlemint.com/graphql",
|
|
34
|
+
* accessToken: "your-access-token",
|
|
50
35
|
* });
|
|
51
36
|
*/
|
|
52
|
-
declare function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
37
|
+
declare function getWebsocketClient({
|
|
38
|
+
portalGraphqlEndpoint,
|
|
39
|
+
accessToken
|
|
40
|
+
}: WebsocketClientOptions): graphql_ws0.Client;
|
|
56
41
|
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/utils/wait-for-transaction-receipt.d.ts
|
|
57
44
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @typedef {Object} WebsocketClientOptions
|
|
61
|
-
* @property {string} portalGraphqlEndpoint - The GraphQL endpoint URL for the Portal API
|
|
62
|
-
* @property {string} accessToken - The access token for authentication with the Portal API
|
|
45
|
+
* Represents an event emitted during a transaction execution
|
|
63
46
|
*/
|
|
64
|
-
interface
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
interface TransactionEvent {
|
|
48
|
+
/** The name of the event that was emitted */
|
|
49
|
+
eventName: string;
|
|
50
|
+
/** The arguments emitted by the event */
|
|
51
|
+
args: Record<string, unknown>;
|
|
52
|
+
/** Indexed event parameters used for filtering and searching */
|
|
53
|
+
topics: Hex[];
|
|
67
54
|
}
|
|
68
55
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @param {WebsocketClientOptions} options - The options for the client
|
|
72
|
-
* @param {string} options.portalGraphqlEndpoint - The GraphQL endpoint URL for the Portal API
|
|
73
|
-
* @param {string} options.accessToken - The access token for authentication with the Portal API
|
|
74
|
-
* @returns {Client} The GraphQL WebSocket client
|
|
56
|
+
* Represents the structure of a blockchain transaction receipt
|
|
75
57
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
interface TransactionReceipt extends TransactionReceipt$1<string, number, "Success" | "Reverted"> {
|
|
59
|
+
/** The raw reason for transaction reversion, if applicable */
|
|
60
|
+
revertReason: string;
|
|
61
|
+
/** Human-readable version of the revert reason */
|
|
62
|
+
revertReasonDecoded: string;
|
|
63
|
+
/** Array of events emitted during the transaction */
|
|
64
|
+
events: TransactionEvent[];
|
|
65
|
+
/** The address of the contract deployed in the transaction */
|
|
66
|
+
contractAddress: Address;
|
|
67
|
+
}
|
|
78
68
|
/**
|
|
79
69
|
* Represents the structure of a blockchain transaction with its receipt
|
|
80
|
-
*
|
|
81
|
-
* @typedef {Object} Transaction
|
|
82
|
-
* @property {Object} receipt - The transaction receipt details
|
|
83
|
-
* @property {string} receipt.transactionHash - The hash of the transaction
|
|
84
|
-
* @property {string} receipt.to - The recipient address of the transaction
|
|
85
|
-
* @property {string} receipt.status - The status of the transaction (success/failure)
|
|
86
|
-
* @property {string} receipt.from - The sender address of the transaction
|
|
87
|
-
* @property {string} receipt.type - The type of the transaction
|
|
88
|
-
* @property {string} receipt.revertReason - The reason for transaction reversion, if applicable
|
|
89
|
-
* @property {string} receipt.revertReasonDecoded - Human-readable version of the revert reason
|
|
90
|
-
* @property {string} receipt.contractAddress - The address of the contract deployed in the transaction
|
|
91
|
-
* @property {string[]} receipt.logs - Array of log entries generated by the transaction
|
|
92
|
-
* @property {string[]} receipt.events - Array of events emitted during the transaction
|
|
93
|
-
* @property {string} transactionHash - The hash of the transaction (duplicate of receipt.transactionHash)
|
|
94
|
-
* @property {string} from - The sender address (duplicate of receipt.from)
|
|
95
|
-
* @property {string} createdAt - Timestamp when the transaction was created
|
|
96
|
-
* @property {string} address - The contract address involved in the transaction
|
|
97
|
-
* @property {string} functionName - The name of the function called in the transaction
|
|
98
|
-
* @property {boolean} isContract - Whether the transaction is a contract deployment
|
|
99
70
|
*/
|
|
100
71
|
interface Transaction {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
from: string;
|
|
115
|
-
createdAt: string;
|
|
116
|
-
address: string;
|
|
117
|
-
functionName: string;
|
|
118
|
-
isContract: boolean;
|
|
72
|
+
receipt: TransactionReceipt;
|
|
73
|
+
/** The hash of the transaction (duplicate of receipt.transactionHash) */
|
|
74
|
+
transactionHash: string;
|
|
75
|
+
/** The sender address (duplicate of receipt.from) */
|
|
76
|
+
from: string;
|
|
77
|
+
/** Timestamp when the transaction was created */
|
|
78
|
+
createdAt: string;
|
|
79
|
+
/** The contract address involved in the transaction */
|
|
80
|
+
address: string;
|
|
81
|
+
/** The name of the function called in the transaction */
|
|
82
|
+
functionName: string;
|
|
83
|
+
/** Whether the transaction is a contract deployment */
|
|
84
|
+
isContract: boolean;
|
|
119
85
|
}
|
|
120
86
|
/**
|
|
121
87
|
* Options for waiting for a transaction receipt
|
|
122
|
-
*
|
|
123
|
-
* @typedef {Object} WaitForTransactionReceiptOptions
|
|
124
|
-
* @property {number} [timeout] - Optional timeout in milliseconds before the operation fails
|
|
125
88
|
*/
|
|
126
89
|
interface WaitForTransactionReceiptOptions extends WebsocketClientOptions {
|
|
127
|
-
|
|
90
|
+
/** Optional timeout in milliseconds before the operation fails */
|
|
91
|
+
timeout?: number;
|
|
128
92
|
}
|
|
129
93
|
/**
|
|
130
94
|
* Waits for a blockchain transaction receipt by subscribing to transaction updates via GraphQL.
|
|
@@ -146,6 +110,70 @@ interface WaitForTransactionReceiptOptions extends WebsocketClientOptions {
|
|
|
146
110
|
*/
|
|
147
111
|
declare function waitForTransactionReceipt(transactionHash: string, options: WaitForTransactionReceiptOptions): Promise<Transaction>;
|
|
148
112
|
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/utils/wallet-verification-challenge.d.ts
|
|
115
|
+
/**
|
|
116
|
+
* Custom error class for challenge-related errors
|
|
117
|
+
*/
|
|
118
|
+
declare class ChallengeError extends Error {
|
|
119
|
+
readonly code: string;
|
|
120
|
+
constructor(message: string, code: string);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Options for handling a wallet verification challenge
|
|
124
|
+
*/
|
|
125
|
+
interface HandleWalletVerificationChallengeOptions<Setup extends AbstractSetupSchema> {
|
|
126
|
+
/** The portal client instance */
|
|
127
|
+
portalClient: GraphQLClient;
|
|
128
|
+
/** The GraphQL query builder */
|
|
129
|
+
portalGraphql: initGraphQLTada<Setup>;
|
|
130
|
+
/** The ID of the verification challenge */
|
|
131
|
+
verificationId: string;
|
|
132
|
+
/** The wallet address to verify */
|
|
133
|
+
userWalletAddress: Address;
|
|
134
|
+
/** The verification code provided by the user */
|
|
135
|
+
code: string | number;
|
|
136
|
+
/** The type of verification being performed */
|
|
137
|
+
verificationType: "otp" | "secret-code" | "pincode";
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Handles a wallet verification challenge by generating an appropriate response
|
|
141
|
+
*
|
|
142
|
+
* @param options - The options for handling the wallet verification challenge
|
|
143
|
+
* @returns Promise resolving to an object containing the challenge response and optionally the verification ID
|
|
144
|
+
* @throws {ChallengeError} If the challenge cannot be created or is invalid
|
|
145
|
+
* @example
|
|
146
|
+
* import { createPortalClient } from "@settlemint/sdk-portal";
|
|
147
|
+
* import { handleWalletVerificationChallenge } from "@settlemint/sdk-portal";
|
|
148
|
+
*
|
|
149
|
+
* const { client, graphql } = createPortalClient({
|
|
150
|
+
* instance: "https://portal.example.com/graphql",
|
|
151
|
+
* accessToken: "your-access-token"
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* const result = await handleWalletVerificationChallenge({
|
|
155
|
+
* portalClient: client,
|
|
156
|
+
* portalGraphql: graphql,
|
|
157
|
+
* verificationId: "verification-123",
|
|
158
|
+
* userWalletAddress: "0x123...",
|
|
159
|
+
* code: "123456",
|
|
160
|
+
* verificationType: "otp"
|
|
161
|
+
* });
|
|
162
|
+
*/
|
|
163
|
+
declare function handleWalletVerificationChallenge<const Setup extends AbstractSetupSchema>({
|
|
164
|
+
portalClient,
|
|
165
|
+
portalGraphql,
|
|
166
|
+
verificationId,
|
|
167
|
+
userWalletAddress,
|
|
168
|
+
code,
|
|
169
|
+
verificationType
|
|
170
|
+
}: HandleWalletVerificationChallengeOptions<Setup>): Promise<{
|
|
171
|
+
challengeResponse: string;
|
|
172
|
+
verificationId?: string;
|
|
173
|
+
}>;
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/portal.d.ts
|
|
149
177
|
/**
|
|
150
178
|
* Configuration options for the GraphQL client, excluding 'url' and 'exchanges'.
|
|
151
179
|
*/
|
|
@@ -154,16 +182,16 @@ type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
|
|
|
154
182
|
* Schema for validating Portal client configuration options.
|
|
155
183
|
*/
|
|
156
184
|
declare const ClientOptionsSchema: z.ZodObject<{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
instance: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
186
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
187
|
+
cache: z.ZodOptional<z.ZodEnum<{
|
|
188
|
+
default: "default";
|
|
189
|
+
"force-cache": "force-cache";
|
|
190
|
+
"no-cache": "no-cache";
|
|
191
|
+
"no-store": "no-store";
|
|
192
|
+
"only-if-cached": "only-if-cached";
|
|
193
|
+
reload: "reload";
|
|
194
|
+
}>>;
|
|
167
195
|
}, z.core.$strip>;
|
|
168
196
|
/**
|
|
169
197
|
* Type representing the validated client options.
|
|
@@ -215,8 +243,10 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
215
243
|
* const result = await portalClient.request(query);
|
|
216
244
|
*/
|
|
217
245
|
declare function createPortalClient<const Setup extends AbstractSetupSchema>(options: ClientOptions, clientOptions?: RequestConfig): {
|
|
218
|
-
|
|
219
|
-
|
|
246
|
+
client: GraphQLClient;
|
|
247
|
+
graphql: initGraphQLTada<Setup>;
|
|
220
248
|
};
|
|
221
249
|
|
|
222
|
-
|
|
250
|
+
//#endregion
|
|
251
|
+
export { ClientOptions, ClientOptionsSchema, FragmentOf, HandleWalletVerificationChallengeOptions, RequestConfig, ResultOf, Transaction, TransactionEvent, TransactionReceipt, VariablesOf, WaitForTransactionReceiptOptions, WebsocketClientOptions, createPortalClient, getWebsocketClient, handleWalletVerificationChallenge, readFragment, waitForTransactionReceipt };
|
|
252
|
+
//# sourceMappingURL=portal.d.ts.map
|