@settlemint/sdk-portal 2.5.14 → 2.6.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/README.md CHANGED
@@ -38,6 +38,8 @@
38
38
  - [getWebsocketClient()](#getwebsocketclient)
39
39
  - [handleWalletVerificationChallenge()](#handlewalletverificationchallenge)
40
40
  - [waitForTransactionReceipt()](#waitfortransactionreceipt)
41
+ - [Classes](#classes)
42
+ - [WalletVerificationChallengeError](#walletverificationchallengeerror)
41
43
  - [Interfaces](#interfaces)
42
44
  - [HandleWalletVerificationChallengeOptions\<Setup\>](#handlewalletverificationchallengeoptionssetup)
43
45
  - [Transaction](#transaction)
@@ -48,6 +50,7 @@
48
50
  - [Type Aliases](#type-aliases)
49
51
  - [ClientOptions](#clientoptions)
50
52
  - [RequestConfig](#requestconfig)
53
+ - [WalletVerificationType](#walletverificationtype)
51
54
  - [Variables](#variables)
52
55
  - [ClientOptionsSchema](#clientoptionsschema)
53
56
  - [Contributing](#contributing)
@@ -112,7 +115,7 @@ const FROM = getAddress("0x4B03331cF2db1497ec58CAa4AFD8b93611906960");
112
115
  const deployForwarder = await portalClient.request(
113
116
  portalGraphql(`
114
117
  mutation DeployContractForwarder($from: String!) {
115
- DeployContractForwarder(from: $from, gasLimit: "0x3d0900") {
118
+ DeployContractATKForwarder(from: $from, gasLimit: "0x3d0900") {
116
119
  transactionHash
117
120
  }
118
121
  }
@@ -125,18 +128,18 @@ const deployForwarder = await portalClient.request(
125
128
  /**
126
129
  * Wait for the forwarder contract deployment to be finalized
127
130
  */
128
- const transaction = await waitForTransactionReceipt(deployForwarder.DeployContractForwarder?.transactionHash!, {
131
+ const transaction = await waitForTransactionReceipt(deployForwarder.DeployContractATKForwarder?.transactionHash!, {
129
132
  portalGraphqlEndpoint: env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
130
133
  accessToken: env.SETTLEMINT_ACCESS_TOKEN!,
131
134
  });
132
135
 
133
136
  /**
134
- * Deploy a stablecoin factory contract
137
+ * Deploy a stablecoin implementation contract
135
138
  */
136
- const deployStableCoinFactory = await portalClient.request(
139
+ const deployStableCoinImplementation = await portalClient.request(
137
140
  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") {
140
143
  transactionHash
141
144
  }
142
145
  }
@@ -144,12 +147,12 @@ const deployStableCoinFactory = await portalClient.request(
144
147
  {
145
148
  from: FROM,
146
149
  constructorArguments: {
147
- forwarder: getAddress(transaction?.receipt.contractAddress!),
150
+ forwarder_: getAddress(transaction?.receipt.contractAddress!),
148
151
  },
149
152
  },
150
153
  );
151
154
 
152
- console.log(deployStableCoinFactory?.DeployContractStableCoinFactory?.transactionHash);
155
+ console.log(deployStableCoinImplementation?.DeployContractATKStableCoinImplementation?.transactionHash);
153
156
 
154
157
  const contractAddresses = await portalClient.request(
155
158
  portalGraphql(`
@@ -471,7 +474,7 @@ runMonitoringExample();
471
474
  */
472
475
  import { loadEnv } from "@settlemint/sdk-utils/environment";
473
476
  import { createLogger, requestLogger } from "@settlemint/sdk-utils/logging";
474
- import type { Address } from "viem";
477
+ import { getAddress } from "viem";
475
478
  import { createPortalClient } from "../portal.js"; // Replace this path with "@settlemint/sdk-portal"
476
479
  import { handleWalletVerificationChallenge } from "../utils/wallet-verification-challenge.js"; // Replace this path with "@settlemint/sdk-portal"
477
480
  import type { introspection } from "./schemas/portal-env.js"; // Replace this path with the generated introspection type
@@ -543,9 +546,9 @@ const challengeResponse = await handleWalletVerificationChallenge({
543
546
  portalClient,
544
547
  portalGraphql,
545
548
  verificationId: pincodeVerification.createWalletVerification?.id!,
546
- userWalletAddress: wallet.createWallet?.address! as Address,
549
+ userWalletAddress: getAddress(wallet.createWallet?.address!),
547
550
  code: "123456",
548
- verificationType: "pincode",
551
+ verificationType: "PINCODE",
549
552
  });
550
553
 
551
554
  /**
@@ -556,40 +559,49 @@ const challengeResponse = await handleWalletVerificationChallenge({
556
559
  */
557
560
  const result = await portalClient.request(
558
561
  portalGraphql(`
559
- mutation StableCoinFactoryCreate(
560
- $challengeResponse: String!
561
- $verificationId: String
562
+ mutation CreateStableCoinMutation(
562
563
  $address: String!
563
564
  $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!
565
572
  ) {
566
- StableCoinFactoryCreate(
567
- challengeResponse: $challengeResponse
568
- verificationId: $verificationId
573
+ CreateStableCoin: ATKStableCoinFactoryImplementationCreateStableCoin(
569
574
  address: $address
570
575
  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
572
585
  ) {
573
586
  transactionHash
574
587
  }
575
588
  }
576
589
  `),
577
590
  {
578
- challengeResponse: challengeResponse.challengeResponse,
579
- verificationId: pincodeVerification.createWalletVerification?.id!,
580
591
  address: "0x5e771e1417100000000000000000000000000004",
581
592
  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
588
600
  },
589
601
  );
590
602
 
591
603
  // Log the transaction hash
592
- console.log("Transaction hash:", result.StableCoinFactoryCreate?.transactionHash);
604
+ console.log("Transaction hash:", result.CreateStableCoin?.transactionHash);
593
605
 
594
606
  ```
595
607
 
@@ -601,7 +613,7 @@ console.log("Transaction hash:", result.StableCoinFactoryCreate?.transactionHash
601
613
 
602
614
  > **createPortalClient**\<`Setup`\>(`options`, `clientOptions?`): `object`
603
615
 
604
- Defined in: [sdk/portal/src/portal.ts:72](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L72)
616
+ Defined in: [sdk/portal/src/portal.ts:72](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L72)
605
617
 
606
618
  Creates a Portal GraphQL client with the provided configuration.
607
619
 
@@ -629,8 +641,8 @@ An object containing the configured GraphQL client and graphql helper function
629
641
 
630
642
  | Name | Type | Defined in |
631
643
  | ------ | ------ | ------ |
632
- | `client` | `GraphQLClient` | [sdk/portal/src/portal.ts:76](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L76) |
633
- | `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/portal/src/portal.ts:77](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L77) |
644
+ | `client` | `GraphQLClient` | [sdk/portal/src/portal.ts:76](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L76) |
645
+ | `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/portal/src/portal.ts:77](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L77) |
634
646
 
635
647
  ##### Throws
636
648
 
@@ -682,7 +694,7 @@ const result = await portalClient.request(query);
682
694
 
683
695
  > **getWebsocketClient**(`options`): `Client`
684
696
 
685
- Defined in: [sdk/portal/src/utils/websocket-client.ts:30](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/websocket-client.ts#L30)
697
+ Defined in: [sdk/portal/src/utils/websocket-client.ts:30](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/websocket-client.ts#L30)
686
698
 
687
699
  Creates a GraphQL WebSocket client for the Portal API
688
700
 
@@ -713,9 +725,9 @@ const client = getWebsocketClient({
713
725
 
714
726
  #### handleWalletVerificationChallenge()
715
727
 
716
- > **handleWalletVerificationChallenge**\<`Setup`\>(`options`): `Promise`\<\{ `challengeResponse`: `string`; `verificationId?`: `string`; \}\>
728
+ > **handleWalletVerificationChallenge**\<`Setup`\>(`options`): `Promise`\<\{ `challengeId`: `string`; `challengeResponse`: `string`; \}\>
717
729
 
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.6.0/sdk/portal/src/utils/wallet-verification-challenge.ts#L111)
719
731
 
720
732
  Handles a wallet verification challenge by generating an appropriate response
721
733
 
@@ -733,7 +745,7 @@ Handles a wallet verification challenge by generating an appropriate response
733
745
 
734
746
  ##### Returns
735
747
 
736
- `Promise`\<\{ `challengeResponse`: `string`; `verificationId?`: `string`; \}\>
748
+ `Promise`\<\{ `challengeId`: `string`; `challengeResponse`: `string`; \}\>
737
749
 
738
750
  Promise resolving to an object containing the challenge response and optionally the verification ID
739
751
 
@@ -758,7 +770,7 @@ const result = await handleWalletVerificationChallenge({
758
770
  verificationId: "verification-123",
759
771
  userWalletAddress: "0x123...",
760
772
  code: "123456",
761
- verificationType: "otp"
773
+ verificationType: "OTP"
762
774
  });
763
775
  ```
764
776
 
@@ -768,7 +780,7 @@ const result = await handleWalletVerificationChallenge({
768
780
 
769
781
  > **waitForTransactionReceipt**(`transactionHash`, `options`): `Promise`\<[`Transaction`](#transaction)\>
770
782
 
771
- Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:80](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L80)
783
+ Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:80](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L80)
772
784
 
773
785
  Waits for a blockchain transaction receipt by subscribing to transaction updates via GraphQL.
774
786
  This function polls until the transaction is confirmed or the timeout is reached.
@@ -802,11 +814,23 @@ const transaction = await waitForTransactionReceipt("0x123...", {
802
814
  });
803
815
  ```
804
816
 
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.6.0/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
+
805
829
  ### Interfaces
806
830
 
807
831
  #### HandleWalletVerificationChallengeOptions\<Setup\>
808
832
 
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.6.0/sdk/portal/src/utils/wallet-verification-challenge.ts#L70)
810
834
 
811
835
  Options for handling a wallet verification challenge
812
836
 
@@ -820,18 +844,19 @@ Options for handling a wallet verification challenge
820
844
 
821
845
  | Property | Type | Description | Defined in |
822
846
  | ------ | ------ | ------ | ------ |
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.6.0/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.6.0/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.6.0/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.6.0/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.6.0/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.6.0/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.6.0/sdk/portal/src/utils/wallet-verification-challenge.ts#L82) |
829
854
 
830
855
  ***
831
856
 
832
857
  #### Transaction
833
858
 
834
- Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:34](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L34)
859
+ Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:34](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L34)
835
860
 
836
861
  Represents the structure of a blockchain transaction with its receipt
837
862
 
@@ -839,18 +864,18 @@ Represents the structure of a blockchain transaction with its receipt
839
864
 
840
865
  | Property | Type | Description | Defined in |
841
866
  | ------ | ------ | ------ | ------ |
842
- | <a id="address"></a> `address` | `string` | The contract address involved in the transaction | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:43](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L43) |
843
- | <a id="createdat"></a> `createdAt` | `string` | Timestamp when the transaction was created | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:41](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L41) |
844
- | <a id="from"></a> `from` | `string` | The sender address (duplicate of receipt.from) | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:39](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L39) |
845
- | <a id="functionname"></a> `functionName` | `string` | The name of the function called in the transaction | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:45](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L45) |
846
- | <a id="iscontract"></a> `isContract` | `boolean` | Whether the transaction is a contract deployment | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:47](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L47) |
847
- | <a id="transactionhash"></a> `transactionHash` | `string` | The hash of the transaction (duplicate of receipt.transactionHash) | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:37](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L37) |
867
+ | <a id="address"></a> `address` | `string` | The contract address involved in the transaction | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:43](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L43) |
868
+ | <a id="createdat"></a> `createdAt` | `string` | Timestamp when the transaction was created | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:41](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L41) |
869
+ | <a id="from"></a> `from` | `string` | The sender address (duplicate of receipt.from) | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:39](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L39) |
870
+ | <a id="functionname"></a> `functionName` | `string` | The name of the function called in the transaction | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:45](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L45) |
871
+ | <a id="iscontract"></a> `isContract` | `boolean` | Whether the transaction is a contract deployment | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:47](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L47) |
872
+ | <a id="transactionhash"></a> `transactionHash` | `string` | The hash of the transaction (duplicate of receipt.transactionHash) | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:37](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L37) |
848
873
 
849
874
  ***
850
875
 
851
876
  #### TransactionEvent
852
877
 
853
- Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:8](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L8)
878
+ Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:8](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L8)
854
879
 
855
880
  Represents an event emitted during a transaction execution
856
881
 
@@ -858,15 +883,15 @@ Represents an event emitted during a transaction execution
858
883
 
859
884
  | Property | Type | Description | Defined in |
860
885
  | ------ | ------ | ------ | ------ |
861
- | <a id="args"></a> `args` | `Record`\<`string`, `unknown`\> | The arguments emitted by the event | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:12](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L12) |
862
- | <a id="eventname"></a> `eventName` | `string` | The name of the event that was emitted | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:10](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L10) |
863
- | <a id="topics"></a> `topics` | `` `0x${string}` ``[] | Indexed event parameters used for filtering and searching | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:14](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L14) |
886
+ | <a id="args"></a> `args` | `Record`\<`string`, `unknown`\> | The arguments emitted by the event | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:12](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L12) |
887
+ | <a id="eventname"></a> `eventName` | `string` | The name of the event that was emitted | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:10](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L10) |
888
+ | <a id="topics"></a> `topics` | `` `0x${string}` ``[] | Indexed event parameters used for filtering and searching | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:14](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L14) |
864
889
 
865
890
  ***
866
891
 
867
892
  #### TransactionReceipt
868
893
 
869
- Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:20](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L20)
894
+ Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:20](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L20)
870
895
 
871
896
  Represents the structure of a blockchain transaction receipt
872
897
 
@@ -878,16 +903,16 @@ Represents the structure of a blockchain transaction receipt
878
903
 
879
904
  | Property | Type | Description | Overrides | Defined in |
880
905
  | ------ | ------ | ------ | ------ | ------ |
881
- | <a id="contractaddress"></a> `contractAddress` | `` `0x${string}` `` | The address of the contract deployed in the transaction | `TransactionReceiptViem.contractAddress` | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:28](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L28) |
882
- | <a id="events"></a> `events` | [`TransactionEvent`](#transactionevent)[] | Array of events emitted during the transaction | - | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:26](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L26) |
883
- | <a id="revertreason"></a> `revertReason` | `string` | The raw reason for transaction reversion, if applicable | - | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:22](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L22) |
884
- | <a id="revertreasondecoded"></a> `revertReasonDecoded` | `string` | Human-readable version of the revert reason | - | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:24](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L24) |
906
+ | <a id="contractaddress"></a> `contractAddress` | `` `0x${string}` `` | The address of the contract deployed in the transaction | `TransactionReceiptViem.contractAddress` | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:28](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L28) |
907
+ | <a id="events"></a> `events` | [`TransactionEvent`](#transactionevent)[] | Array of events emitted during the transaction | - | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:26](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L26) |
908
+ | <a id="revertreason"></a> `revertReason` | `string` | The raw reason for transaction reversion, if applicable | - | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:22](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L22) |
909
+ | <a id="revertreasondecoded"></a> `revertReasonDecoded` | `string` | Human-readable version of the revert reason | - | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:24](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L24) |
885
910
 
886
911
  ***
887
912
 
888
913
  #### WaitForTransactionReceiptOptions
889
914
 
890
- Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:57](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L57)
915
+ Defined in: [sdk/portal/src/utils/wait-for-transaction-receipt.ts:57](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L57)
891
916
 
892
917
  Options for waiting for a transaction receipt
893
918
 
@@ -899,15 +924,15 @@ Options for waiting for a transaction receipt
899
924
 
900
925
  | Property | Type | Description | Inherited from | Defined in |
901
926
  | ------ | ------ | ------ | ------ | ------ |
902
- | <a id="accesstoken"></a> `accessToken?` | `string` | The access token for authentication with the Portal API | [`WebsocketClientOptions`](#websocketclientoptions).[`accessToken`](#accesstoken-1) | [sdk/portal/src/utils/websocket-client.ts:14](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/websocket-client.ts#L14) |
903
- | <a id="portalgraphqlendpoint"></a> `portalGraphqlEndpoint` | `string` | The GraphQL endpoint URL for the Portal API | [`WebsocketClientOptions`](#websocketclientoptions).[`portalGraphqlEndpoint`](#portalgraphqlendpoint-1) | [sdk/portal/src/utils/websocket-client.ts:10](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/websocket-client.ts#L10) |
904
- | <a id="timeout"></a> `timeout?` | `number` | Optional timeout in milliseconds before the operation fails | - | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:59](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L59) |
927
+ | <a id="accesstoken"></a> `accessToken?` | `string` | The access token for authentication with the Portal API | [`WebsocketClientOptions`](#websocketclientoptions).[`accessToken`](#accesstoken-1) | [sdk/portal/src/utils/websocket-client.ts:14](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/websocket-client.ts#L14) |
928
+ | <a id="portalgraphqlendpoint"></a> `portalGraphqlEndpoint` | `string` | The GraphQL endpoint URL for the Portal API | [`WebsocketClientOptions`](#websocketclientoptions).[`portalGraphqlEndpoint`](#portalgraphqlendpoint-1) | [sdk/portal/src/utils/websocket-client.ts:10](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/websocket-client.ts#L10) |
929
+ | <a id="timeout"></a> `timeout?` | `number` | Optional timeout in milliseconds before the operation fails | - | [sdk/portal/src/utils/wait-for-transaction-receipt.ts:59](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/wait-for-transaction-receipt.ts#L59) |
905
930
 
906
931
  ***
907
932
 
908
933
  #### WebsocketClientOptions
909
934
 
910
- Defined in: [sdk/portal/src/utils/websocket-client.ts:6](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/websocket-client.ts#L6)
935
+ Defined in: [sdk/portal/src/utils/websocket-client.ts:6](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/websocket-client.ts#L6)
911
936
 
912
937
  Options for the GraphQL WebSocket client
913
938
 
@@ -919,8 +944,8 @@ Options for the GraphQL WebSocket client
919
944
 
920
945
  | Property | Type | Description | Defined in |
921
946
  | ------ | ------ | ------ | ------ |
922
- | <a id="accesstoken-1"></a> `accessToken?` | `string` | The access token for authentication with the Portal API | [sdk/portal/src/utils/websocket-client.ts:14](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/websocket-client.ts#L14) |
923
- | <a id="portalgraphqlendpoint-1"></a> `portalGraphqlEndpoint` | `string` | The GraphQL endpoint URL for the Portal API | [sdk/portal/src/utils/websocket-client.ts:10](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/utils/websocket-client.ts#L10) |
947
+ | <a id="accesstoken-1"></a> `accessToken?` | `string` | The access token for authentication with the Portal API | [sdk/portal/src/utils/websocket-client.ts:14](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/websocket-client.ts#L14) |
948
+ | <a id="portalgraphqlendpoint-1"></a> `portalGraphqlEndpoint` | `string` | The GraphQL endpoint URL for the Portal API | [sdk/portal/src/utils/websocket-client.ts:10](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/utils/websocket-client.ts#L10) |
924
949
 
925
950
  ### Type Aliases
926
951
 
@@ -928,7 +953,7 @@ Options for the GraphQL WebSocket client
928
953
 
929
954
  > **ClientOptions** = `object`
930
955
 
931
- Defined in: [sdk/portal/src/portal.ts:25](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L25)
956
+ Defined in: [sdk/portal/src/portal.ts:25](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L25)
932
957
 
933
958
  Type representing the validated client options.
934
959
 
@@ -936,9 +961,9 @@ Type representing the validated client options.
936
961
 
937
962
  | Name | Type | Default value | Defined in |
938
963
  | ------ | ------ | ------ | ------ |
939
- | <a id="accesstoken-2"></a> `accessToken?` | `string` | - | [sdk/portal/src/portal.ts:18](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L18) |
940
- | <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/portal/src/portal.ts:19](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L19) |
941
- | <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/portal/src/portal.ts:17](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L17) |
964
+ | <a id="accesstoken-2"></a> `accessToken?` | `string` | - | [sdk/portal/src/portal.ts:18](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L18) |
965
+ | <a id="cache"></a> `cache?` | `"default"` \| `"force-cache"` \| `"no-cache"` \| `"no-store"` \| `"only-if-cached"` \| `"reload"` | - | [sdk/portal/src/portal.ts:19](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L19) |
966
+ | <a id="instance"></a> `instance` | `string` | `UrlOrPathSchema` | [sdk/portal/src/portal.ts:17](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L17) |
942
967
 
943
968
  ***
944
969
 
@@ -946,17 +971,27 @@ Type representing the validated client options.
946
971
 
947
972
  > **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
948
973
 
949
- Defined in: [sdk/portal/src/portal.ts:11](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L11)
974
+ Defined in: [sdk/portal/src/portal.ts:11](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L11)
950
975
 
951
976
  Configuration options for the GraphQL client, excluding 'url' and 'exchanges'.
952
977
 
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.6.0/sdk/portal/src/utils/wallet-verification-challenge.ts#L9)
985
+
986
+ Type representing the different types of wallet verification methods
987
+
953
988
  ### Variables
954
989
 
955
990
  #### ClientOptionsSchema
956
991
 
957
992
  > `const` **ClientOptionsSchema**: `ZodObject`\<[`ClientOptions`](#clientoptions)\>
958
993
 
959
- Defined in: [sdk/portal/src/portal.ts:16](https://github.com/settlemint/sdk/blob/v2.5.14/sdk/portal/src/portal.ts#L16)
994
+ Defined in: [sdk/portal/src/portal.ts:16](https://github.com/settlemint/sdk/blob/v2.6.0/sdk/portal/src/portal.ts#L16)
960
995
 
961
996
  Schema for validating Portal client configuration options.
962
997
 
@@ -108,10 +108,14 @@ interface WaitForTransactionReceiptOptions extends WebsocketClientOptions {
108
108
  declare function waitForTransactionReceipt(transactionHash: string, options: WaitForTransactionReceiptOptions): Promise<Transaction>;
109
109
  //#endregion
110
110
  //#region src/utils/wallet-verification-challenge.d.ts
111
+ /**
112
+ * Type representing the different types of wallet verification methods
113
+ */
114
+ type WalletVerificationType = "PINCODE" | "OTP" | "SECRET_CODES";
111
115
  /**
112
116
  * Custom error class for challenge-related errors
113
117
  */
114
- declare class ChallengeError extends Error {
118
+ declare class WalletVerificationChallengeError extends Error {
115
119
  readonly code: string;
116
120
  constructor(message: string, code: string);
117
121
  }
@@ -130,14 +134,16 @@ interface HandleWalletVerificationChallengeOptions<Setup extends AbstractSetupSc
130
134
  /** The verification code provided by the user */
131
135
  code: string | number;
132
136
  /** The type of verification being performed */
133
- verificationType: "otp" | "secret-code" | "pincode";
137
+ verificationType: WalletVerificationType;
138
+ /** Request id which can be added for tracing purposes */
139
+ requestId?: string;
134
140
  }
135
141
  /**
136
142
  * Handles a wallet verification challenge by generating an appropriate response
137
143
  *
138
144
  * @param options - The options for handling the wallet verification challenge
139
145
  * @returns Promise resolving to an object containing the challenge response and optionally the verification ID
140
- * @throws {ChallengeError} If the challenge cannot be created or is invalid
146
+ * @throws {WalletVerificationChallengeError} If the challenge cannot be created or is invalid
141
147
  * @example
142
148
  * import { createPortalClient } from "@settlemint/sdk-portal";
143
149
  * import { handleWalletVerificationChallenge } from "@settlemint/sdk-portal";
@@ -153,7 +159,7 @@ interface HandleWalletVerificationChallengeOptions<Setup extends AbstractSetupSc
153
159
  * verificationId: "verification-123",
154
160
  * userWalletAddress: "0x123...",
155
161
  * code: "123456",
156
- * verificationType: "otp"
162
+ * verificationType: "OTP"
157
163
  * });
158
164
  */
159
165
  declare function handleWalletVerificationChallenge<const Setup extends AbstractSetupSchema>({
@@ -162,10 +168,11 @@ declare function handleWalletVerificationChallenge<const Setup extends AbstractS
162
168
  verificationId,
163
169
  userWalletAddress,
164
170
  code,
165
- verificationType
171
+ verificationType,
172
+ requestId
166
173
  }: HandleWalletVerificationChallengeOptions<Setup>): Promise<{
167
174
  challengeResponse: string;
168
- verificationId?: string;
175
+ challengeId: string;
169
176
  }>;
170
177
  //#endregion
171
178
  //#region src/portal.d.ts
@@ -242,5 +249,5 @@ declare function createPortalClient<const Setup extends AbstractSetupSchema>(opt
242
249
  graphql: initGraphQLTada<Setup>;
243
250
  };
244
251
  //#endregion
245
- export { ClientOptions, ClientOptionsSchema, type FragmentOf, type HandleWalletVerificationChallengeOptions, RequestConfig, type ResultOf, type Transaction, type TransactionEvent, type TransactionReceipt, type VariablesOf, type WaitForTransactionReceiptOptions, type WebsocketClientOptions, createPortalClient, getWebsocketClient, handleWalletVerificationChallenge, readFragment, waitForTransactionReceipt };
252
+ export { ClientOptions, ClientOptionsSchema, type FragmentOf, type HandleWalletVerificationChallengeOptions, RequestConfig, type ResultOf, type Transaction, type TransactionEvent, type TransactionReceipt, type VariablesOf, type WaitForTransactionReceiptOptions, WalletVerificationChallengeError, type WalletVerificationType, type WebsocketClientOptions, createPortalClient, getWebsocketClient, handleWalletVerificationChallenge, readFragment, waitForTransactionReceipt };
246
253
  //# sourceMappingURL=portal.d.ts.map
@@ -113,7 +113,7 @@ async function getTransactionFromSubscription(subscription) {
113
113
  /**
114
114
  * Custom error class for challenge-related errors
115
115
  */
116
- var ChallengeError = class extends Error {
116
+ var WalletVerificationChallengeError = class extends Error {
117
117
  code;
118
118
  constructor(message, code) {
119
119
  super(message);
@@ -146,7 +146,7 @@ function generateResponse(pincode, salt, challenge) {
146
146
  *
147
147
  * @param options - The options for handling the wallet verification challenge
148
148
  * @returns Promise resolving to an object containing the challenge response and optionally the verification ID
149
- * @throws {ChallengeError} If the challenge cannot be created or is invalid
149
+ * @throws {WalletVerificationChallengeError} If the challenge cannot be created or is invalid
150
150
  * @example
151
151
  * import { createPortalClient } from "@settlemint/sdk-portal";
152
152
  * import { handleWalletVerificationChallenge } from "@settlemint/sdk-portal";
@@ -162,55 +162,65 @@ function generateResponse(pincode, salt, challenge) {
162
162
  * verificationId: "verification-123",
163
163
  * userWalletAddress: "0x123...",
164
164
  * code: "123456",
165
- * verificationType: "otp"
165
+ * verificationType: "OTP"
166
166
  * });
167
167
  */
168
- async function handleWalletVerificationChallenge({ portalClient, portalGraphql, verificationId, userWalletAddress, code, verificationType }) {
168
+ async function handleWalletVerificationChallenge({ portalClient, portalGraphql, verificationId, userWalletAddress, code, verificationType, requestId }) {
169
169
  try {
170
- if (verificationType === "otp") {
171
- return {
172
- challengeResponse: code.toString(),
173
- verificationId
174
- };
170
+ const requestHeaders = new Headers();
171
+ if (requestId) {
172
+ requestHeaders.append("x-request-id", requestId);
175
173
  }
176
- if (verificationType === "secret-code") {
177
- const formattedCode = code.toString().replace(/(.{5})(?=.)/, "$1-");
178
- return {
179
- challengeResponse: formattedCode,
180
- verificationId
181
- };
182
- }
183
- const verificationChallenges = await portalClient.request(portalGraphql(`
184
- mutation CreateWalletVerificationChallenges($userWalletAddress: String!, $verificationId: String!) {
185
- createWalletVerificationChallenges(userWalletAddress: $userWalletAddress, verificationId: $verificationId) {
186
- challenge
174
+ const verificationChallenge = await portalClient.request(portalGraphql(`
175
+ mutation CreateWalletVerificationChallenge($userWalletAddress: String!, $verificationId: String!) {
176
+ createWalletVerificationChallenge(
177
+ userWalletAddress: $userWalletAddress
178
+ verificationId: $verificationId
179
+ ) {
187
180
  id
188
181
  name
182
+ verificationId
189
183
  verificationType
184
+ challenge {
185
+ salt
186
+ secret
187
+ }
190
188
  }
191
189
  }
192
190
  `), {
193
191
  userWalletAddress,
194
192
  verificationId
195
- });
196
- if (!verificationChallenges.createWalletVerificationChallenges?.length) {
197
- throw new ChallengeError("No verification challenges received", "NO_CHALLENGES");
193
+ }, requestHeaders);
194
+ if (!verificationChallenge.createWalletVerificationChallenge) {
195
+ throw new WalletVerificationChallengeError("No verification challenge received", "NO_CHALLENGES");
196
+ }
197
+ if (verificationType === "OTP") {
198
+ return {
199
+ challengeResponse: code.toString(),
200
+ challengeId: verificationChallenge.createWalletVerificationChallenge.id
201
+ };
198
202
  }
199
- const walletVerificationChallenge = verificationChallenges.createWalletVerificationChallenges.find((challenge) => challenge.id === verificationId);
200
- if (!walletVerificationChallenge?.challenge?.secret || !walletVerificationChallenge?.challenge?.salt) {
201
- throw new ChallengeError("Invalid challenge format", "INVALID_CHALLENGE");
203
+ if (verificationType === "SECRET_CODES") {
204
+ const formattedCode = code.toString().replace(/(.{5})(?=.)/, "$1-");
205
+ return {
206
+ challengeResponse: formattedCode,
207
+ challengeId: verificationChallenge.createWalletVerificationChallenge.id
208
+ };
209
+ }
210
+ const { secret, salt } = verificationChallenge.createWalletVerificationChallenge.challenge ?? {};
211
+ if (!secret || !salt) {
212
+ throw new WalletVerificationChallengeError("Invalid challenge format", "INVALID_CHALLENGE");
202
213
  }
203
- const { secret, salt } = walletVerificationChallenge.challenge;
204
214
  const challengeResponse = generateResponse(code.toString(), salt, secret);
205
215
  return {
206
216
  challengeResponse,
207
- verificationId
217
+ challengeId: verificationChallenge.createWalletVerificationChallenge.id
208
218
  };
209
219
  } catch (error) {
210
- if (error instanceof ChallengeError) {
220
+ if (error instanceof WalletVerificationChallengeError) {
211
221
  throw error;
212
222
  }
213
- throw new ChallengeError("Failed to process wallet verification challenge", "CHALLENGE_PROCESSING_ERROR");
223
+ throw new WalletVerificationChallengeError("Failed to process wallet verification challenge", "CHALLENGE_PROCESSING_ERROR");
214
224
  }
215
225
  }
216
226
 
@@ -291,5 +301,5 @@ function createPortalClient(options, clientOptions) {
291
301
  }
292
302
 
293
303
  //#endregion
294
- export { ClientOptionsSchema, createPortalClient, getWebsocketClient, handleWalletVerificationChallenge, readFragment, waitForTransactionReceipt };
304
+ export { ClientOptionsSchema, WalletVerificationChallengeError, createPortalClient, getWebsocketClient, handleWalletVerificationChallenge, readFragment, waitForTransactionReceipt };
295
305
  //# sourceMappingURL=portal.js.map