@settlemint/sdk-portal 2.2.0 → 2.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/README.md +461 -21
- package/dist/portal.cjs +137 -2
- package/dist/portal.cjs.map +1 -1
- package/dist/portal.d.cts +142 -12
- package/dist/portal.d.ts +142 -12
- package/dist/portal.mjs +134 -1
- package/dist/portal.mjs.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -27,9 +27,19 @@
|
|
|
27
27
|
## Table of Contents
|
|
28
28
|
|
|
29
29
|
- [About](#about)
|
|
30
|
+
- [Examples](#examples)
|
|
31
|
+
- [Deploy contract](#deploy-contract)
|
|
32
|
+
- [Get pending transactions](#get-pending-transactions)
|
|
33
|
+
- [Send transaction using hd wallet](#send-transaction-using-hd-wallet)
|
|
30
34
|
- [API Reference](#api-reference)
|
|
31
35
|
- [Functions](#functions)
|
|
32
36
|
- [createPortalClient()](#createportalclient)
|
|
37
|
+
- [handleWalletVerificationChallenge()](#handlewalletverificationchallenge)
|
|
38
|
+
- [waitForTransactionReceipt()](#waitfortransactionreceipt)
|
|
39
|
+
- [Interfaces](#interfaces)
|
|
40
|
+
- [HandleWalletVerificationChallengeOptions\<Setup\>](#handlewalletverificationchallengeoptionssetup)
|
|
41
|
+
- [Transaction](#transaction)
|
|
42
|
+
- [WaitForTransactionReceiptOptions](#waitfortransactionreceiptoptions)
|
|
33
43
|
- [Type Aliases](#type-aliases)
|
|
34
44
|
- [ClientOptions](#clientoptions)
|
|
35
45
|
- [RequestConfig](#requestconfig)
|
|
@@ -43,8 +53,310 @@
|
|
|
43
53
|
The SettleMint Smart Contract Portal SDK provides a seamless way to interact with the Smart Contract Portal Middleware API. It enables you to easily interact with your smart contracts using a REST or GraphQL API.
|
|
44
54
|
|
|
45
55
|
The SDK offers a type-safe interface for all Portal API operations, with comprehensive error handling and validation. It integrates smoothly with modern TypeScript applications while providing a simple and intuitive developer experience.
|
|
56
|
+
## Examples
|
|
46
57
|
|
|
47
|
-
|
|
58
|
+
### Deploy contract
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
/**
|
|
62
|
+
* This example demonstrates how to deploy a contract.
|
|
63
|
+
*
|
|
64
|
+
* The process involves:
|
|
65
|
+
* 1. Creating a portal client
|
|
66
|
+
* 2. Deploying a forwarder contract
|
|
67
|
+
* 3. Waiting for the forwarder contract deployment to be finalized
|
|
68
|
+
* 4. Deploying a stablecoin factory contract
|
|
69
|
+
* 5. Getting all contracts and filtering by ABI name
|
|
70
|
+
*
|
|
71
|
+
* This pattern is useful for applications that need to deploy smart contracts
|
|
72
|
+
* in the SettleMint Portal, providing a way to track the progress of blockchain operations.
|
|
73
|
+
*/
|
|
74
|
+
import { loadEnv } from "@settlemint/sdk-utils/environment";
|
|
75
|
+
import { createLogger, requestLogger } from "@settlemint/sdk-utils/logging";
|
|
76
|
+
import { getAddress } from "viem";
|
|
77
|
+
import { createPortalClient } from "../portal.js"; // Replace this path with "@settlemint/sdk-portal"
|
|
78
|
+
import { waitForTransactionReceipt } from "../utils/wait-for-transaction-receipt.js";
|
|
79
|
+
import type { introspection } from "./schemas/portal-env.d.ts"; // Replace this path with the generated introspection type
|
|
80
|
+
|
|
81
|
+
const env = await loadEnv(false, false);
|
|
82
|
+
const logger = createLogger();
|
|
83
|
+
|
|
84
|
+
const { client: portalClient, graphql: portalGraphql } = createPortalClient<{
|
|
85
|
+
introspection: introspection;
|
|
86
|
+
disableMasking: true;
|
|
87
|
+
scalars: {
|
|
88
|
+
// Change unknown to the type you are using to store metadata
|
|
89
|
+
JSON: unknown;
|
|
90
|
+
};
|
|
91
|
+
}>(
|
|
92
|
+
{
|
|
93
|
+
instance: env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
|
|
94
|
+
accessToken: env.SETTLEMINT_ACCESS_TOKEN!,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
fetch: requestLogger(logger, "portal", fetch) as typeof fetch,
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// Replace with the address of your private key which you use to deploy smart contracts
|
|
102
|
+
const FROM = getAddress("0x4B03331cF2db1497ec58CAa4AFD8b93611906960");
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Deploy a forwarder contract
|
|
106
|
+
*/
|
|
107
|
+
const deployForwarder = await portalClient.request(
|
|
108
|
+
portalGraphql(`
|
|
109
|
+
mutation DeployContractForwarder($from: String!) {
|
|
110
|
+
DeployContractForwarder(from: $from, gasLimit: "0x3d0900") {
|
|
111
|
+
transactionHash
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
`),
|
|
115
|
+
{
|
|
116
|
+
from: FROM,
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Wait for the forwarder contract deployment to be finalized
|
|
122
|
+
*/
|
|
123
|
+
const transaction = await waitForTransactionReceipt(deployForwarder.DeployContractForwarder?.transactionHash!, {
|
|
124
|
+
portalGraphqlEndpoint: env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
|
|
125
|
+
accessToken: env.SETTLEMINT_ACCESS_TOKEN!,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Deploy a stablecoin factory contract
|
|
130
|
+
*/
|
|
131
|
+
const deployStableCoinFactory = await portalClient.request(
|
|
132
|
+
portalGraphql(`
|
|
133
|
+
mutation DeployContractStableCoinFactory($from: String!, $constructorArguments: DeployContractStableCoinFactoryInput!) {
|
|
134
|
+
DeployContractStableCoinFactory(from: $from, constructorArguments: $constructorArguments, gasLimit: "0x3d0900") {
|
|
135
|
+
transactionHash
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
`),
|
|
139
|
+
{
|
|
140
|
+
from: FROM,
|
|
141
|
+
constructorArguments: {
|
|
142
|
+
forwarder: getAddress(transaction?.receipt.contractAddress!),
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
console.log(deployStableCoinFactory?.DeployContractStableCoinFactory?.transactionHash);
|
|
148
|
+
|
|
149
|
+
const contractAddresses = await portalClient.request(
|
|
150
|
+
portalGraphql(`
|
|
151
|
+
query GetContracts {
|
|
152
|
+
getContracts {
|
|
153
|
+
count
|
|
154
|
+
records {
|
|
155
|
+
address
|
|
156
|
+
abiName
|
|
157
|
+
createdAt
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
`),
|
|
162
|
+
);
|
|
163
|
+
// Print total count
|
|
164
|
+
console.log(`Total contracts: ${contractAddresses.getContracts?.count}`);
|
|
165
|
+
|
|
166
|
+
// Contracts for StableCoinFactory
|
|
167
|
+
console.log(contractAddresses.getContracts?.records.filter((record) => record.abiName === "StableCoinFactory"));
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
### Get pending transactions
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
/**
|
|
174
|
+
* This example demonstrates how to get the number of pending transactions.
|
|
175
|
+
*
|
|
176
|
+
* The process involves:
|
|
177
|
+
* 1. Creating a portal client
|
|
178
|
+
* 2. Making a GraphQL query to get the number of pending transactions
|
|
179
|
+
*
|
|
180
|
+
* This pattern is useful for applications that need to monitor the status of pending transactions
|
|
181
|
+
* in the SettleMint Portal, providing a way to track the progress of blockchain operations.
|
|
182
|
+
*/
|
|
183
|
+
import { loadEnv } from "@settlemint/sdk-utils/environment";
|
|
184
|
+
import { createLogger, requestLogger } from "@settlemint/sdk-utils/logging";
|
|
185
|
+
import { createPortalClient } from "../portal.js"; // Replace this path with "@settlemint/sdk-portal"
|
|
186
|
+
import type { introspection } from "./schemas/portal-env.d.ts"; // Replace this path with the generated introspection type
|
|
187
|
+
|
|
188
|
+
const env = await loadEnv(false, false);
|
|
189
|
+
const logger = createLogger();
|
|
190
|
+
|
|
191
|
+
const { client: portalClient, graphql: portalGraphql } = createPortalClient<{
|
|
192
|
+
introspection: introspection;
|
|
193
|
+
disableMasking: true;
|
|
194
|
+
scalars: {
|
|
195
|
+
// Change unknown to the type you are using to store metadata
|
|
196
|
+
JSON: unknown;
|
|
197
|
+
};
|
|
198
|
+
}>(
|
|
199
|
+
{
|
|
200
|
+
instance: env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
|
|
201
|
+
accessToken: env.SETTLEMINT_ACCESS_TOKEN!,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
fetch: requestLogger(logger, "portal", fetch) as typeof fetch,
|
|
205
|
+
},
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
// Making GraphQL queries
|
|
209
|
+
const query = portalGraphql(`
|
|
210
|
+
query GetPendingTransactions {
|
|
211
|
+
getPendingTransactions {
|
|
212
|
+
count
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
`);
|
|
216
|
+
|
|
217
|
+
const result = await portalClient.request(query);
|
|
218
|
+
console.log(`There are ${result.getPendingTransactions?.count} pending transactions`);
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
### Send transaction using hd wallet
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
/**
|
|
225
|
+
* This example demonstrates how to send a transaction using an HD wallet.
|
|
226
|
+
*
|
|
227
|
+
* The process involves:
|
|
228
|
+
* 1. Creating a wallet for a user using the HD private key
|
|
229
|
+
* 2. Setting up a pincode for wallet verification
|
|
230
|
+
* 3. Handling the wallet verification challenge
|
|
231
|
+
* 4. Sending a transaction to the blockchain
|
|
232
|
+
*
|
|
233
|
+
* This pattern is useful for applications that need to manage multiple user wallets
|
|
234
|
+
* derived from a single HD wallet, providing a secure and scalable approach to
|
|
235
|
+
* blockchain interactions in enterprise applications.
|
|
236
|
+
*/
|
|
237
|
+
import { loadEnv } from "@settlemint/sdk-utils/environment";
|
|
238
|
+
import { createLogger, requestLogger } from "@settlemint/sdk-utils/logging";
|
|
239
|
+
import type { Address } from "viem";
|
|
240
|
+
import { createPortalClient } from "../portal.js"; // Replace this path with "@settlemint/sdk-portal"
|
|
241
|
+
import { handleWalletVerificationChallenge } from "../utils/wallet-verification-challenge.js"; // Replace this path with "@settlemint/sdk-portal"
|
|
242
|
+
import type { introspection } from "./schemas/portal-env.js"; // Replace this path with the generated introspection type
|
|
243
|
+
|
|
244
|
+
const env = await loadEnv(false, false);
|
|
245
|
+
const logger = createLogger();
|
|
246
|
+
|
|
247
|
+
const { client: portalClient, graphql: portalGraphql } = createPortalClient<{
|
|
248
|
+
introspection: introspection;
|
|
249
|
+
disableMasking: true;
|
|
250
|
+
scalars: {
|
|
251
|
+
// Change unknown to the type you are using to store metadata
|
|
252
|
+
JSON: unknown;
|
|
253
|
+
};
|
|
254
|
+
}>(
|
|
255
|
+
{
|
|
256
|
+
instance: env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
|
|
257
|
+
accessToken: env.SETTLEMINT_ACCESS_TOKEN!,
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
fetch: requestLogger(logger, "portal", fetch) as typeof fetch,
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* First create a wallet using the HD private key, this needs to be done for every user that is using your app
|
|
266
|
+
*/
|
|
267
|
+
const wallet = await portalClient.request(
|
|
268
|
+
portalGraphql(`
|
|
269
|
+
mutation createUserWallet($keyVaultId: String!, $name: String!) {
|
|
270
|
+
createWallet(keyVaultId: $keyVaultId, walletInfo: { name: $name }) {
|
|
271
|
+
address
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
`),
|
|
275
|
+
{
|
|
276
|
+
keyVaultId: env.SETTLEMINT_HD_PRIVATE_KEY!,
|
|
277
|
+
name: "My Wallet",
|
|
278
|
+
},
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Set a pincode for the wallet, this is used to verify the wallet when the user is sending a transaction to the chain
|
|
283
|
+
*/
|
|
284
|
+
const pincodeVerification = await portalClient.request(
|
|
285
|
+
portalGraphql(`
|
|
286
|
+
mutation setPinCode($address: String!, $pincode: String!) {
|
|
287
|
+
createWalletVerification(
|
|
288
|
+
userWalletAddress: $address
|
|
289
|
+
verificationInfo: {pincode: {name: "PINCODE", pincode: $pincode}}
|
|
290
|
+
) {
|
|
291
|
+
id
|
|
292
|
+
name
|
|
293
|
+
parameters
|
|
294
|
+
verificationType
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
`),
|
|
298
|
+
{
|
|
299
|
+
address: wallet.createWallet?.address!,
|
|
300
|
+
pincode: "123456",
|
|
301
|
+
},
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Generate a challenge response for the pincode verification
|
|
306
|
+
*/
|
|
307
|
+
const challengeResponse = await handleWalletVerificationChallenge({
|
|
308
|
+
portalClient,
|
|
309
|
+
portalGraphql,
|
|
310
|
+
verificationId: pincodeVerification.createWalletVerification?.id!,
|
|
311
|
+
userWalletAddress: wallet.createWallet?.address! as Address,
|
|
312
|
+
code: "123456",
|
|
313
|
+
verificationType: "pincode",
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Send a transaction to the chain
|
|
318
|
+
* This is a sample of how to send a transaction to the chain using the portal client and the asset tokenization kit
|
|
319
|
+
* The challenge response is generated using the handleWalletVerificationChallenge function, this is used to verifiy wallet access
|
|
320
|
+
* @see https://github.com/settlemint/asset-tokenization-kit
|
|
321
|
+
*/
|
|
322
|
+
const result = await portalClient.request(
|
|
323
|
+
portalGraphql(`
|
|
324
|
+
mutation StableCoinFactoryCreate(
|
|
325
|
+
$challengeResponse: String!
|
|
326
|
+
$verificationId: String
|
|
327
|
+
$address: String!
|
|
328
|
+
$from: String!
|
|
329
|
+
$input: StableCoinFactoryCreateInput!
|
|
330
|
+
) {
|
|
331
|
+
StableCoinFactoryCreate(
|
|
332
|
+
challengeResponse: $challengeResponse
|
|
333
|
+
verificationId: $verificationId
|
|
334
|
+
address: $address
|
|
335
|
+
from: $from
|
|
336
|
+
input: $input
|
|
337
|
+
) {
|
|
338
|
+
transactionHash
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
`),
|
|
342
|
+
{
|
|
343
|
+
challengeResponse: challengeResponse.challengeResponse,
|
|
344
|
+
verificationId: pincodeVerification.createWalletVerification?.id!,
|
|
345
|
+
address: "0x5e771e1417100000000000000000000000000004",
|
|
346
|
+
from: wallet.createWallet?.address!,
|
|
347
|
+
input: {
|
|
348
|
+
name: "Test Coin",
|
|
349
|
+
symbol: "TEST",
|
|
350
|
+
decimals: 18,
|
|
351
|
+
collateralLivenessSeconds: 3_600,
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
// Log the transaction hash
|
|
357
|
+
console.log("Transaction hash:", result.StableCoinFactoryCreate?.transactionHash);
|
|
358
|
+
|
|
359
|
+
```
|
|
48
360
|
|
|
49
361
|
## API Reference
|
|
50
362
|
|
|
@@ -54,7 +366,7 @@ For detailed information about using the Smart Contract Portal Middleware, check
|
|
|
54
366
|
|
|
55
367
|
> **createPortalClient**\<`Setup`\>(`options`, `clientOptions?`): `object`
|
|
56
368
|
|
|
57
|
-
Defined in: [sdk/portal/src/portal.ts:
|
|
369
|
+
Defined in: [sdk/portal/src/portal.ts:71](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L71)
|
|
58
370
|
|
|
59
371
|
Creates a Portal GraphQL client with the provided configuration.
|
|
60
372
|
|
|
@@ -82,8 +394,8 @@ An object containing the configured GraphQL client and graphql helper function
|
|
|
82
394
|
|
|
83
395
|
| Name | Type | Defined in |
|
|
84
396
|
| ------ | ------ | ------ |
|
|
85
|
-
| `client` | `GraphQLClient` | [sdk/portal/src/portal.ts:
|
|
86
|
-
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/portal/src/portal.ts:
|
|
397
|
+
| `client` | `GraphQLClient` | [sdk/portal/src/portal.ts:75](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L75) |
|
|
398
|
+
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/portal/src/portal.ts:76](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L76) |
|
|
87
399
|
|
|
88
400
|
##### Throws
|
|
89
401
|
|
|
@@ -92,28 +404,33 @@ If the provided options fail validation
|
|
|
92
404
|
##### Example
|
|
93
405
|
|
|
94
406
|
```ts
|
|
95
|
-
import { createPortalClient } from
|
|
407
|
+
import { createPortalClient } from "@settlemint/sdk-portal";
|
|
408
|
+
import { loadEnv } from "@settlemint/sdk-utils/environment";
|
|
409
|
+
import { createLogger, requestLogger } from "@settlemint/sdk-utils/logging";
|
|
96
410
|
import type { introspection } from "@schemas/portal-env";
|
|
97
|
-
import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';
|
|
98
411
|
|
|
412
|
+
const env = await loadEnv(false, false);
|
|
99
413
|
const logger = createLogger();
|
|
100
414
|
|
|
101
|
-
|
|
415
|
+
const { client: portalClient, graphql: portalGraphql } = createPortalClient<{
|
|
102
416
|
introspection: introspection;
|
|
103
417
|
disableMasking: true;
|
|
104
418
|
scalars: {
|
|
105
419
|
// Change unknown to the type you are using to store metadata
|
|
106
420
|
JSON: unknown;
|
|
107
421
|
};
|
|
108
|
-
}>(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
422
|
+
}>(
|
|
423
|
+
{
|
|
424
|
+
instance: env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
|
|
425
|
+
accessToken: env.SETTLEMINT_ACCESS_TOKEN!,
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
fetch: requestLogger(logger, "portal", fetch) as typeof fetch,
|
|
429
|
+
},
|
|
430
|
+
);
|
|
114
431
|
|
|
115
432
|
// Making GraphQL queries
|
|
116
|
-
const query =
|
|
433
|
+
const query = portalGraphql(`
|
|
117
434
|
query GetPendingTransactions {
|
|
118
435
|
getPendingTransactions {
|
|
119
436
|
count
|
|
@@ -121,16 +438,139 @@ const query = graphql(`
|
|
|
121
438
|
}
|
|
122
439
|
`);
|
|
123
440
|
|
|
124
|
-
const result = await
|
|
441
|
+
const result = await portalClient.request(query);
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
***
|
|
445
|
+
|
|
446
|
+
#### handleWalletVerificationChallenge()
|
|
447
|
+
|
|
448
|
+
> **handleWalletVerificationChallenge**\<`Setup`\>(`options`): `Promise`\<\{ `challengeResponse`: `string`; `verificationId?`: `string`; \}\>
|
|
449
|
+
|
|
450
|
+
Defined in: [sdk/portal/src/utils/wallet-verification-challenge.ts:106](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/utils/wallet-verification-challenge.ts#L106)
|
|
451
|
+
|
|
452
|
+
Handles a wallet verification challenge by generating an appropriate response
|
|
453
|
+
|
|
454
|
+
##### Type Parameters
|
|
455
|
+
|
|
456
|
+
| Type Parameter |
|
|
457
|
+
| ------ |
|
|
458
|
+
| `Setup` *extends* `AbstractSetupSchema` |
|
|
459
|
+
|
|
460
|
+
##### Parameters
|
|
461
|
+
|
|
462
|
+
| Parameter | Type | Description |
|
|
463
|
+
| ------ | ------ | ------ |
|
|
464
|
+
| `options` | [`HandleWalletVerificationChallengeOptions`](#handlewalletverificationchallengeoptions)\<`Setup`\> | The options for handling the wallet verification challenge |
|
|
465
|
+
|
|
466
|
+
##### Returns
|
|
467
|
+
|
|
468
|
+
`Promise`\<\{ `challengeResponse`: `string`; `verificationId?`: `string`; \}\>
|
|
469
|
+
|
|
470
|
+
Promise resolving to an object containing the challenge response and optionally the verification ID
|
|
471
|
+
|
|
472
|
+
##### Throws
|
|
473
|
+
|
|
474
|
+
If the challenge cannot be created or is invalid
|
|
475
|
+
|
|
476
|
+
##### Example
|
|
477
|
+
|
|
478
|
+
```ts
|
|
479
|
+
import { createPortalClient } from "@settlemint/sdk-portal";
|
|
480
|
+
import { handleWalletVerificationChallenge } from "@settlemint/sdk-portal";
|
|
481
|
+
|
|
482
|
+
const { client, graphql } = createPortalClient({
|
|
483
|
+
instance: "https://portal.example.com/graphql",
|
|
484
|
+
accessToken: "your-access-token"
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
const result = await handleWalletVerificationChallenge({
|
|
488
|
+
portalClient: client,
|
|
489
|
+
portalGraphql: graphql,
|
|
490
|
+
verificationId: "verification-123",
|
|
491
|
+
userWalletAddress: "0x123...",
|
|
492
|
+
code: "123456",
|
|
493
|
+
verificationType: "otp"
|
|
494
|
+
});
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
***
|
|
498
|
+
|
|
499
|
+
#### waitForTransactionReceipt()
|
|
500
|
+
|
|
501
|
+
> **waitForTransactionReceipt**(`transactionHash`, `options`): `Promise`\<[`Transaction`](#transaction)\>
|
|
502
|
+
|
|
503
|
+
Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:82](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L82)
|
|
504
|
+
|
|
505
|
+
Waits for a blockchain transaction receipt by subscribing to transaction updates via GraphQL.
|
|
506
|
+
This function polls until the transaction is confirmed or the timeout is reached.
|
|
507
|
+
|
|
508
|
+
##### Parameters
|
|
509
|
+
|
|
510
|
+
| Parameter | Type | Description |
|
|
511
|
+
| ------ | ------ | ------ |
|
|
512
|
+
| `transactionHash` | `string` | The hash of the transaction to wait for |
|
|
513
|
+
| `options` | [`WaitForTransactionReceiptOptions`](#waitfortransactionreceiptoptions) | Configuration options for the waiting process |
|
|
514
|
+
|
|
515
|
+
##### Returns
|
|
516
|
+
|
|
517
|
+
`Promise`\<[`Transaction`](#transaction)\>
|
|
518
|
+
|
|
519
|
+
The transaction details including receipt information when the transaction is confirmed
|
|
520
|
+
|
|
521
|
+
##### Throws
|
|
522
|
+
|
|
523
|
+
Error if the transaction receipt cannot be retrieved within the specified timeout
|
|
524
|
+
|
|
525
|
+
##### Example
|
|
526
|
+
|
|
527
|
+
```ts
|
|
528
|
+
import { waitForTransactionReceipt } from "@settlemint/sdk-portal";
|
|
529
|
+
|
|
530
|
+
const transaction = await waitForTransactionReceipt("0x123...", {
|
|
531
|
+
portalGraphqlEndpoint: "https://example.settlemint.com/graphql",
|
|
532
|
+
accessToken: "your-access-token",
|
|
533
|
+
timeout: 30000 // 30 seconds timeout
|
|
534
|
+
});
|
|
125
535
|
```
|
|
126
536
|
|
|
537
|
+
### Interfaces
|
|
538
|
+
|
|
539
|
+
#### HandleWalletVerificationChallengeOptions\<Setup\>
|
|
540
|
+
|
|
541
|
+
Defined in: [sdk/portal/src/utils/wallet-verification-challenge.ts:73](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/utils/wallet-verification-challenge.ts#L73)
|
|
542
|
+
|
|
543
|
+
Options for handling a wallet verification challenge
|
|
544
|
+
|
|
545
|
+
##### Type Parameters
|
|
546
|
+
|
|
547
|
+
| Type Parameter | Description |
|
|
548
|
+
| ------ | ------ |
|
|
549
|
+
| `Setup` *extends* `AbstractSetupSchema` | The GraphQL schema setup type |
|
|
550
|
+
|
|
551
|
+
***
|
|
552
|
+
|
|
553
|
+
#### Transaction
|
|
554
|
+
|
|
555
|
+
Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:25](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L25)
|
|
556
|
+
|
|
557
|
+
Represents the structure of a blockchain transaction with its receipt
|
|
558
|
+
|
|
559
|
+
***
|
|
560
|
+
|
|
561
|
+
#### WaitForTransactionReceiptOptions
|
|
562
|
+
|
|
563
|
+
Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:58](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L58)
|
|
564
|
+
|
|
565
|
+
Options for waiting for a transaction receipt
|
|
566
|
+
|
|
127
567
|
### Type Aliases
|
|
128
568
|
|
|
129
569
|
#### ClientOptions
|
|
130
570
|
|
|
131
571
|
> **ClientOptions** = `object`
|
|
132
572
|
|
|
133
|
-
Defined in: [sdk/portal/src/portal.ts:24](https://github.com/settlemint/sdk/blob/v2.2.
|
|
573
|
+
Defined in: [sdk/portal/src/portal.ts:24](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L24)
|
|
134
574
|
|
|
135
575
|
Type representing the validated client options.
|
|
136
576
|
|
|
@@ -138,9 +578,9 @@ Type representing the validated client options.
|
|
|
138
578
|
|
|
139
579
|
| Name | Type | Default value | Defined in |
|
|
140
580
|
| ------ | ------ | ------ | ------ |
|
|
141
|
-
| <a id="accesstoken"></a> `accessToken` | `string` | `ApplicationAccessTokenSchema` | [sdk/portal/src/portal.ts:17](https://github.com/settlemint/sdk/blob/v2.2.
|
|
142
|
-
| <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/portal/src/portal.ts:18](https://github.com/settlemint/sdk/blob/v2.2.
|
|
143
|
-
| <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/portal/src/portal.ts:16](https://github.com/settlemint/sdk/blob/v2.2.
|
|
581
|
+
| <a id="accesstoken"></a> `accessToken` | `string` | `ApplicationAccessTokenSchema` | [sdk/portal/src/portal.ts:17](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L17) |
|
|
582
|
+
| <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/portal/src/portal.ts:18](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L18) |
|
|
583
|
+
| <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/portal/src/portal.ts:16](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L16) |
|
|
144
584
|
|
|
145
585
|
***
|
|
146
586
|
|
|
@@ -148,7 +588,7 @@ Type representing the validated client options.
|
|
|
148
588
|
|
|
149
589
|
> **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
|
|
150
590
|
|
|
151
|
-
Defined in: [sdk/portal/src/portal.ts:10](https://github.com/settlemint/sdk/blob/v2.2.
|
|
591
|
+
Defined in: [sdk/portal/src/portal.ts:10](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L10)
|
|
152
592
|
|
|
153
593
|
Configuration options for the GraphQL client, excluding 'url' and 'exchanges'.
|
|
154
594
|
|
|
@@ -158,7 +598,7 @@ Configuration options for the GraphQL client, excluding 'url' and 'exchanges'.
|
|
|
158
598
|
|
|
159
599
|
> `const` **ClientOptionsSchema**: `ZodObject`\<[`ClientOptions`](#clientoptions)\>
|
|
160
600
|
|
|
161
|
-
Defined in: [sdk/portal/src/portal.ts:15](https://github.com/settlemint/sdk/blob/v2.2.
|
|
601
|
+
Defined in: [sdk/portal/src/portal.ts:15](https://github.com/settlemint/sdk/blob/v2.2.1/sdk/portal/src/portal.ts#L15)
|
|
162
602
|
|
|
163
603
|
Schema for validating Portal client configuration options.
|
|
164
604
|
|