Skip to content

Commit b12ddf6

Browse files
committed
fix: docs generation
1 parent d32d3ea commit b12ddf6

File tree

3 files changed

+94
-55
lines changed

3 files changed

+94
-55
lines changed

scripts/generate-readme.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ async function generateReadme() {
2727
const sdkDir = join(__dirname, "..", "sdk");
2828
console.log(`Scanning SDK directory: ${sdkDir}`);
2929
const sdkDirEntries = await readdir(sdkDir, { withFileTypes: true });
30-
const packages = sdkDirEntries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
30+
const packages = sdkDirEntries
31+
.filter((entry) => entry.isDirectory())
32+
.map((entry) => entry.name)
33+
.filter((entry) => entry !== "test")
34+
.sort();
3135
console.log(`Found ${packages.length} packages`);
3236

3337
// Generate README for each package

sdk/portal/README.md

Lines changed: 74 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
- [getWebsocketClient()](#getwebsocketclient)
3939
- [handleWalletVerificationChallenge()](#handlewalletverificationchallenge)
4040
- [waitForTransactionReceipt()](#waitfortransactionreceipt)
41+
- [Classes](#classes)
42+
- [WalletVerificationChallengeError](#walletverificationchallengeerror)
4143
- [Interfaces](#interfaces)
4244
- [HandleWalletVerificationChallengeOptions\<Setup\>](#handlewalletverificationchallengeoptionssetup)
4345
- [Transaction](#transaction)
@@ -48,6 +50,7 @@
4850
- [Type Aliases](#type-aliases)
4951
- [ClientOptions](#clientoptions)
5052
- [RequestConfig](#requestconfig)
53+
- [WalletVerificationType](#walletverificationtype)
5154
- [Variables](#variables)
5255
- [ClientOptionsSchema](#clientoptionsschema)
5356
- [Contributing](#contributing)
@@ -112,7 +115,7 @@ const FROM = getAddress("0x4B03331cF2db1497ec58CAa4AFD8b93611906960");
112115
const deployForwarder = await portalClient.request(
113116
portalGraphql(`
114117
mutation DeployContractForwarder($from: String!) {
115-
DeployContractForwarder(from: $from, gasLimit: "0x3d0900") {
118+
DeployContractATKForwarder(from: $from, gasLimit: "0x3d0900") {
116119
transactionHash
117120
}
118121
}
@@ -125,31 +128,31 @@ const deployForwarder = await portalClient.request(
125128
/**
126129
* Wait for the forwarder contract deployment to be finalized
127130
*/
128-
const transaction = await waitForTransactionReceipt(deployForwarder.DeployContractForwarder?.transactionHash!, {
131+
const transaction = await waitForTransactionReceipt(deployForwarder.DeployContractATKForwarder?.transactionHash!, {
129132
portalGraphqlEndpoint: env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
130133
accessToken: env.SETTLEMINT_ACCESS_TOKEN!,
131134
});
132135

133136
/**
134-
* Deploy a stablecoin factory contract
137+
* Deploy a stablecoin implementation contract
135138
*/
136-
const deployStableCoinFactory = await portalClient.request(
139+
const deployStableCoinImplementation = await portalClient.request(
137140
portalGraphql(`
138-
mutation DeployContractStableCoinFactory($from: String!, $constructorArguments: DeployContractStableCoinFactoryInput!) {
139-
DeployContractStableCoinFactory(from: $from, constructorArguments: $constructorArguments, gasLimit: "0x3d0900") {
141+
mutation DeployContractStableCoinFactory($from: String!, $constructorArguments: DeployContractATKStableCoinImplementationInput!) {
142+
DeployContractATKStableCoinImplementation(from: $from, constructorArguments: $constructorArguments, gasLimit: "0x3d0900") {
140143
transactionHash
141144
}
142145
}
143146
`),
144147
{
145148
from: FROM,
146149
constructorArguments: {
147-
forwarder: getAddress(transaction?.receipt.contractAddress!),
150+
forwarder_: getAddress(transaction?.receipt.contractAddress!),
148151
},
149152
},
150153
);
151154

152-
console.log(deployStableCoinFactory?.DeployContractStableCoinFactory?.transactionHash);
155+
console.log(deployStableCoinImplementation?.DeployContractATKStableCoinImplementation?.transactionHash);
153156

154157
const contractAddresses = await portalClient.request(
155158
portalGraphql(`
@@ -471,7 +474,7 @@ runMonitoringExample();
471474
*/
472475
import { loadEnv } from "@settlemint/sdk-utils/environment";
473476
import { createLogger, requestLogger } from "@settlemint/sdk-utils/logging";
474-
import type { Address } from "viem";
477+
import { getAddress } from "viem";
475478
import { createPortalClient } from "../portal.js"; // Replace this path with "@settlemint/sdk-portal"
476479
import { handleWalletVerificationChallenge } from "../utils/wallet-verification-challenge.js"; // Replace this path with "@settlemint/sdk-portal"
477480
import type { introspection } from "./schemas/portal-env.js"; // Replace this path with the generated introspection type
@@ -543,9 +546,9 @@ const challengeResponse = await handleWalletVerificationChallenge({
543546
portalClient,
544547
portalGraphql,
545548
verificationId: pincodeVerification.createWalletVerification?.id!,
546-
userWalletAddress: wallet.createWallet?.address! as Address,
549+
userWalletAddress: getAddress(wallet.createWallet?.address!),
547550
code: "123456",
548-
verificationType: "pincode",
551+
verificationType: "PINCODE",
549552
});
550553

551554
/**
@@ -556,40 +559,49 @@ const challengeResponse = await handleWalletVerificationChallenge({
556559
*/
557560
const result = await portalClient.request(
558561
portalGraphql(`
559-
mutation StableCoinFactoryCreate(
560-
$challengeResponse: String!
561-
$verificationId: String
562+
mutation CreateStableCoinMutation(
562563
$address: String!
563564
$from: String!
564-
$input: StableCoinFactoryCreateInput!
565+
$symbol: String!
566+
$name: String!
567+
$decimals: Int!
568+
$initialModulePairs: [ATKStableCoinFactoryImplementationATKStableCoinFactoryImplementationCreateStableCoinInitialModulePairsInput!]!
569+
$challengeId: String
570+
$challengeResponse: String
571+
$countryCode: Int!
565572
) {
566-
StableCoinFactoryCreate(
567-
challengeResponse: $challengeResponse
568-
verificationId: $verificationId
573+
CreateStableCoin: ATKStableCoinFactoryImplementationCreateStableCoin(
569574
address: $address
570575
from: $from
571-
input: $input
576+
input: {
577+
symbol_: $symbol
578+
name_: $name
579+
decimals_: $decimals
580+
initialModulePairs_: $initialModulePairs
581+
countryCode_: $countryCode
582+
}
583+
challengeId: $challengeId
584+
challengeResponse: $challengeResponse
572585
) {
573586
transactionHash
574587
}
575588
}
576589
`),
577590
{
578-
challengeResponse: challengeResponse.challengeResponse,
579-
verificationId: pincodeVerification.createWalletVerification?.id!,
580591
address: "0x5e771e1417100000000000000000000000000004",
581592
from: wallet.createWallet?.address!,
582-
input: {
583-
name: "Test Coin",
584-
symbol: "TEST",
585-
decimals: 18,
586-
collateralLivenessSeconds: 3_600,
587-
},
593+
symbol: "TEST",
594+
name: "Test Coin",
595+
decimals: 18,
596+
initialModulePairs: [],
597+
challengeResponse: challengeResponse.challengeResponse,
598+
challengeId: challengeResponse.challengeId,
599+
countryCode: 56, // Example country code for BE
588600
},
589601
);
590602

591603
// Log the transaction hash
592-
console.log("Transaction hash:", result.StableCoinFactoryCreate?.transactionHash);
604+
console.log("Transaction hash:", result.CreateStableCoin?.transactionHash);
593605

594606
```
595607

@@ -713,9 +725,9 @@ const client = getWebsocketClient({
713725

714726
#### handleWalletVerificationChallenge()
715727

716-
> **handleWalletVerificationChallenge**\<`Setup`\>(`options`): `Promise`\<\{ `challengeResponse`: `string`; `verificationId?`: `string`; \}\>
728+
> **handleWalletVerificationChallenge**\<`Setup`\>(`options`): `Promise`\<\{ `challengeId`: `string`; `challengeResponse`: `string`; \}\>
717729
718-
Defined in: [sdk/portal/src/utils/wallet-verification-challenge.ts:103](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L103)
730+
Defined in: [sdk/portal/src/utils/wallet-verification-challenge.ts:111](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L111)
719731

720732
Handles a wallet verification challenge by generating an appropriate response
721733

@@ -733,7 +745,7 @@ Handles a wallet verification challenge by generating an appropriate response
733745

734746
##### Returns
735747

736-
`Promise`\<\{ `challengeResponse`: `string`; `verificationId?`: `string`; \}\>
748+
`Promise`\<\{ `challengeId`: `string`; `challengeResponse`: `string`; \}\>
737749

738750
Promise resolving to an object containing the challenge response and optionally the verification ID
739751

@@ -758,7 +770,7 @@ const result = await handleWalletVerificationChallenge({
758770
verificationId: "verification-123",
759771
userWalletAddress: "0x123...",
760772
code: "123456",
761-
verificationType: "otp"
773+
verificationType: "OTP"
762774
});
763775
```
764776

@@ -802,11 +814,23 @@ const transaction = await waitForTransactionReceipt("0x123...", {
802814
});
803815
```
804816

817+
### Classes
818+
819+
#### WalletVerificationChallengeError
820+
821+
Defined in: [sdk/portal/src/utils/wallet-verification-challenge.ts:14](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L14)
822+
823+
Custom error class for challenge-related errors
824+
825+
##### Extends
826+
827+
- `Error`
828+
805829
### Interfaces
806830

807831
#### HandleWalletVerificationChallengeOptions\<Setup\>
808832

809-
Defined in: [sdk/portal/src/utils/wallet-verification-challenge.ts:64](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L64)
833+
Defined in: [sdk/portal/src/utils/wallet-verification-challenge.ts:70](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L70)
810834

811835
Options for handling a wallet verification challenge
812836

@@ -820,12 +844,13 @@ Options for handling a wallet verification challenge
820844

821845
| Property | Type | Description | Defined in |
822846
| ------ | ------ | ------ | ------ |
823-
| <a id="code"></a> `code` | `string` \| `number` | The verification code provided by the user | [sdk/portal/src/utils/wallet-verification-challenge.ts:74](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L74) |
824-
| <a id="portalclient"></a> `portalClient` | `GraphQLClient` | The portal client instance | [sdk/portal/src/utils/wallet-verification-challenge.ts:66](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L66) |
825-
| <a id="portalgraphql"></a> `portalGraphql` | `initGraphQLTada`\<`Setup`\> | The GraphQL query builder | [sdk/portal/src/utils/wallet-verification-challenge.ts:68](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L68) |
826-
| <a id="userwalletaddress"></a> `userWalletAddress` | `` `0x${string}` `` | The wallet address to verify | [sdk/portal/src/utils/wallet-verification-challenge.ts:72](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L72) |
827-
| <a id="verificationid"></a> `verificationId` | `string` | The ID of the verification challenge | [sdk/portal/src/utils/wallet-verification-challenge.ts:70](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L70) |
828-
| <a id="verificationtype"></a> `verificationType` | `"otp"` \| `"secret-code"` \| `"pincode"` | The type of verification being performed | [sdk/portal/src/utils/wallet-verification-challenge.ts:76](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L76) |
847+
| <a id="code"></a> `code` | `string` \| `number` | The verification code provided by the user | [sdk/portal/src/utils/wallet-verification-challenge.ts:80](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L80) |
848+
| <a id="portalclient"></a> `portalClient` | `GraphQLClient` | The portal client instance | [sdk/portal/src/utils/wallet-verification-challenge.ts:72](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L72) |
849+
| <a id="portalgraphql"></a> `portalGraphql` | `initGraphQLTada`\<`Setup`\> | The GraphQL query builder | [sdk/portal/src/utils/wallet-verification-challenge.ts:74](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L74) |
850+
| <a id="requestid"></a> `requestId?` | `string` | Request id which can be added for tracing purposes | [sdk/portal/src/utils/wallet-verification-challenge.ts:84](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L84) |
851+
| <a id="userwalletaddress"></a> `userWalletAddress` | `` `0x${string}` `` | The wallet address to verify | [sdk/portal/src/utils/wallet-verification-challenge.ts:78](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L78) |
852+
| <a id="verificationid"></a> `verificationId` | `string` | The ID of the verification challenge | [sdk/portal/src/utils/wallet-verification-challenge.ts:76](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L76) |
853+
| <a id="verificationtype"></a> `verificationType` | [`WalletVerificationType`](#walletverificationtype) | The type of verification being performed | [sdk/portal/src/utils/wallet-verification-challenge.ts:82](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L82) |
829854

830855
***
831856

@@ -950,6 +975,16 @@ Defined in: [sdk/portal/src/portal.ts:11](https://github.com/settlemint/sdk/blob
950975

951976
Configuration options for the GraphQL client, excluding 'url' and 'exchanges'.
952977

978+
***
979+
980+
#### WalletVerificationType
981+
982+
> **WalletVerificationType** = `"PINCODE"` \| `"OTP"` \| `"SECRET_CODES"`
983+
984+
Defined in: [sdk/portal/src/utils/wallet-verification-challenge.ts:9](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wallet-verification-challenge.ts#L9)
985+
986+
Type representing the different types of wallet verification methods
987+
953988
### Variables
954989

955990
#### ClientOptionsSchema

0 commit comments

Comments
 (0)