Skip to content

Commit dd1dea6

Browse files
authored
fix: layerswap retrieve username from auth context (#2347)
1 parent e6bab90 commit dd1dea6

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

packages/keychain/src/hooks/starterpack/layerswap.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ export function useLayerswap({
541541
const input = depositToLayerswapInput(
542542
requestedAmount,
543543
0, // Fees will be fetched and added
544-
controller.username(),
545544
selectedPlatform,
546545
isMainnet,
547546
);

packages/keychain/src/utils/api/generated.ts

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ export type Activity = Node & {
361361
status: ActivityStatus;
362362
/** Transaction hash if this is a blockchain transaction */
363363
transactionHash?: Maybe<Scalars["String"]>;
364+
/** External transaction tracking ID for sponsored transactions */
365+
transactionID?: Maybe<Scalars["String"]>;
364366
/** Type of activity */
365367
type: ActivityType;
366368
updatedAt: Scalars["Time"];
@@ -645,6 +647,22 @@ export type ActivityWhereInput = {
645647
transactionHashNEQ?: InputMaybe<Scalars["String"]>;
646648
transactionHashNotIn?: InputMaybe<Array<Scalars["String"]>>;
647649
transactionHashNotNil?: InputMaybe<Scalars["Boolean"]>;
650+
/** transaction_id field predicates */
651+
transactionID?: InputMaybe<Scalars["String"]>;
652+
transactionIDContains?: InputMaybe<Scalars["String"]>;
653+
transactionIDContainsFold?: InputMaybe<Scalars["String"]>;
654+
transactionIDEqualFold?: InputMaybe<Scalars["String"]>;
655+
transactionIDGT?: InputMaybe<Scalars["String"]>;
656+
transactionIDGTE?: InputMaybe<Scalars["String"]>;
657+
transactionIDHasPrefix?: InputMaybe<Scalars["String"]>;
658+
transactionIDHasSuffix?: InputMaybe<Scalars["String"]>;
659+
transactionIDIn?: InputMaybe<Array<Scalars["String"]>>;
660+
transactionIDIsNil?: InputMaybe<Scalars["Boolean"]>;
661+
transactionIDLT?: InputMaybe<Scalars["String"]>;
662+
transactionIDLTE?: InputMaybe<Scalars["String"]>;
663+
transactionIDNEQ?: InputMaybe<Scalars["String"]>;
664+
transactionIDNotIn?: InputMaybe<Array<Scalars["String"]>>;
665+
transactionIDNotNil?: InputMaybe<Scalars["Boolean"]>;
648666
/** type field predicates */
649667
type?: InputMaybe<ActivityType>;
650668
typeIn?: InputMaybe<Array<ActivityType>>;
@@ -661,6 +679,14 @@ export type ActivityWhereInput = {
661679
updatedAtNotIn?: InputMaybe<Array<Scalars["Time"]>>;
662680
};
663681

682+
export enum AdminBudgetReason {
683+
Advance = "ADVANCE",
684+
Correction = "CORRECTION",
685+
Promotion = "PROMOTION",
686+
Refund = "REFUND",
687+
Settlement = "SETTLEMENT",
688+
}
689+
664690
export type AssetEdge = {
665691
__typename?: "AssetEdge";
666692
amount: Scalars["Float"];
@@ -772,6 +798,8 @@ export type CoinbaseOnrampQuote = {
772798
__typename?: "CoinbaseOnrampQuote";
773799
/** Fee charged by Coinbase. */
774800
coinbaseFee: CoinbaseAmount;
801+
/** Fees charged by Layerswap for bridging. */
802+
layerswapFees: CoinbaseAmount;
775803
/** Network fee for sending the crypto. */
776804
networkFee: CoinbaseAmount;
777805
/** Ready-to-use one-click-buy URL. Only returned when destinationAddress is provided. */
@@ -787,20 +815,10 @@ export type CoinbaseOnrampQuote = {
787815
};
788816

789817
export type CoinbaseOnrampQuoteInput = {
790-
/** The client's IP address. Required by Coinbase for compliance. */
791-
clientIP: Scalars["String"];
792-
/** ISO 3166-1 two-digit country code (e.g., "US"). */
793-
country: Scalars["String"];
794-
/** Optional destination wallet address. If provided, the response will include a one-click-buy URL. */
795-
destinationAddress?: InputMaybe<Scalars["String"]>;
796-
/** The destination network for the USDC purchase. */
797-
destinationNetwork: CoinbaseNetwork;
798-
/** The amount of fiat currency to pay (e.g., "100.00" for $100 USD). */
799-
paymentAmount: Scalars["String"];
800-
/** The fiat currency to pay with (e.g., "USD"). */
801-
paymentCurrency: Scalars["String"];
802-
/** ISO 3166-2 subdivision code (e.g., "NY"). Required for US users. */
803-
subdivision?: InputMaybe<Scalars["String"]>;
818+
/** The amount of USDC to purchase (e.g., "100.00" for 100 USDC). */
819+
purchaseUSDCAmount: Scalars["String"];
820+
/** If true, use sandbox mode to get a quote for testnet bridging. */
821+
sandbox?: InputMaybe<Scalars["Boolean"]>;
804822
};
805823

806824
export enum CoinbaseOnrampStatus {
@@ -1085,7 +1103,6 @@ export type CreateLayerswapDepositInput = {
10851103
layerswapFees?: InputMaybe<Scalars["BigInt"]>;
10861104
marginPercent?: InputMaybe<Scalars["Int"]>;
10871105
sourceNetwork: LayerswapSourceNetwork;
1088-
username: Scalars["String"];
10891106
};
10901107

10911108
export type CreateLayerswapPaymentInput = {
@@ -1096,7 +1113,6 @@ export type CreateLayerswapPaymentInput = {
10961113
sourceNetwork: LayerswapSourceNetwork;
10971114
starterpackId?: InputMaybe<Scalars["ID"]>;
10981115
teamId?: InputMaybe<Scalars["ID"]>;
1099-
username: Scalars["String"];
11001116
};
11011117

11021118
/**
@@ -2678,8 +2694,10 @@ export type MutationCreateTeamArgs = {
26782694
};
26792695

26802696
export type MutationDecreaseBudgetArgs = {
2697+
admin?: InputMaybe<Scalars["Boolean"]>;
26812698
amount: Scalars["Int"];
26822699
paymasterName: Scalars["ID"];
2700+
reason?: InputMaybe<AdminBudgetReason>;
26832701
unit: FeeUnit;
26842702
};
26852703

@@ -2719,8 +2737,10 @@ export type MutationFinalizeRegistrationArgs = {
27192737
};
27202738

27212739
export type MutationIncreaseBudgetArgs = {
2740+
admin?: InputMaybe<Scalars["Boolean"]>;
27222741
amount: Scalars["Int"];
27232742
paymasterName: Scalars["ID"];
2743+
reason?: InputMaybe<AdminBudgetReason>;
27242744
unit: FeeUnit;
27252745
};
27262746

packages/keychain/src/utils/payments.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import { mapPlatformToLayerswapSourceNetwork } from "@/hooks/starterpack/layersw
1212
*
1313
* @param amount The deposit amount.
1414
* @param layerswapFees The Layerswap fees.
15-
* @param username The user's username.
1615
* @param platform The source platform for the payment.
1716
* @param isMainnet Whether the transaction is for mainnet or testnet.
1817
* @returns A CreateLayerswapDepositInput object.
1918
*/
2019
export function depositToLayerswapInput(
2120
amount: number,
2221
layerswapFees: number,
23-
username: string,
2422
platform: ExternalPlatform,
2523
isMainnet: boolean,
2624
): CreateLayerswapDepositInput {
@@ -32,23 +30,21 @@ export function depositToLayerswapInput(
3230
return {
3331
amount: amount.toString(),
3432
layerswapFees: layerswapFees.toString(),
35-
username,
3633
sourceNetwork,
3734
};
3835
}
3936

4037
/**
4138
* Converts a credits purchase to a CreateLayerswapPaymentInput object.
4239
*
43-
* @param username The user's username.
40+
* @param starterpackId An optional starterpack ID.
4441
* @param platform The source platform for the payment.
4542
* @param isMainnet Whether the transaction is for mainnet or testnet.
4643
* @param wholeCredits The amount of credits to purchase.
4744
* @param teamId An optional team ID.
4845
* @returns A CreateLayerswapPaymentInput object.
4946
*/
5047
export function creditsPurchaseToLayerswapInput(
51-
username: string,
5248
starterpackId: string | undefined,
5349
platform: ExternalPlatform,
5450
isMainnet: boolean,
@@ -64,7 +60,6 @@ export function creditsPurchaseToLayerswapInput(
6460
: LayerswapDestinationNetwork.StarknetSepolia;
6561

6662
return {
67-
username,
6863
sourceNetwork,
6964
destinationNetwork,
7065
purchaseType: PurchaseType.Credits,

0 commit comments

Comments
 (0)