Skip to content

Commit

Permalink
add prettierrc
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Dec 6, 2024
1 parent 2a0f58a commit 8a33bdb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
6 changes: 6 additions & 0 deletions packages/react/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"useTabs": false,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 80
}
6 changes: 6 additions & 0 deletions packages/sdk/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"useTabs": false,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 80
}
10 changes: 5 additions & 5 deletions packages/sdk/src/internal/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const numberLike = refine(
(value) => {
if (typeof value === "string") return !isNaN(Number(value));
return true; // If it's a number or bigint, it's already valid
}
},
);

const BridgeCoreSchema = object({
Expand All @@ -43,7 +43,7 @@ const BridgeCoreWithRecipientSchema = assign(
BridgeCoreSchema,
object({
recipient: optional(hexString()),
})
}),
);

const ContractCallCoreSchema = object({
Expand All @@ -59,7 +59,7 @@ const TokenContractCallSchema = assign(
object({
outputTokenAddress: optional(hexString()),
approvalAddress: optional(hexString()),
})
}),
);

const ContractCallSchema = object({
Expand All @@ -72,10 +72,10 @@ export const MultiHopSchema = BridgeCoreSchema;

export const SingleHopWithContractSchema = assign(
BridgeCoreWithRecipientSchema,
ContractCallSchema
ContractCallSchema,
);

export const MultiHopWithContractSchema = assign(
BridgeCoreSchema,
ContractCallSchema
ContractCallSchema,
);
32 changes: 16 additions & 16 deletions packages/sdk/src/sprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export class Sprinter {
* ```
*/
public async getAvailableTokens(
options: FetchOptions = {}
options: FetchOptions = {},
): Promise<FungibleToken[]> {
if (!this.#tokens)
this.#tokens = await this.deferredRequest("tokens", () =>
getFungibleTokens(this.makeFetchOptions(options))
getFungibleTokens(this.makeFetchOptions(options)),
);
return this.#tokens;
}
Expand All @@ -85,11 +85,11 @@ export class Sprinter {
* ```
*/
public async getAvailableChains(
options: FetchOptions = {}
options: FetchOptions = {},
): Promise<Chain[]> {
if (!this.#chains)
this.#chains = await this.deferredRequest("chains", () =>
getSupportedChains(this.makeFetchOptions(options))
getSupportedChains(this.makeFetchOptions(options)),
);
return this.#chains;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ export class Sprinter {
public async getUserBalances(
account: Address,
tokens?: FungibleToken[],
options: FetchOptions = {}
options: FetchOptions = {},
): Promise<AggregateBalances> {
const tokenList = tokens || (await this.getAvailableTokens(options));

Expand All @@ -161,8 +161,8 @@ export class Sprinter {
getUserBalances(
account,
tokenList,
this.makeFetchOptions(options || {})
)
this.makeFetchOptions(options || {}),
),
);
return formatBalances([balances, nativeTokens]);
}
Expand Down Expand Up @@ -253,7 +253,7 @@ export class Sprinter {
*/
public async poolAssetOnDestination(
settings: Infer<typeof MultiHopSchema>,
options?: FetchOptions
options?: FetchOptions,
): Promise<SolutionResponse> {
assert(settings, MultiHopSchema);

Expand All @@ -264,7 +264,7 @@ export class Sprinter {
amount: BigInt(amount),
whitelistedSourceChains: sourceChains,
} as SolutionOptions,
this.makeFetchOptions(options)
this.makeFetchOptions(options),
);
}

Expand Down Expand Up @@ -327,7 +327,7 @@ export class Sprinter {
*/
public async poolAssetOnDestinationWithHook(
settings: Infer<typeof MultiHopWithContractSchema>,
options?: FetchOptions
options?: FetchOptions,
): Promise<SolutionResponse> {
assert(settings, MultiHopWithContractSchema);

Expand All @@ -338,7 +338,7 @@ export class Sprinter {
amount: BigInt(amount),
whitelistedSourceChains: sourceChains,
} as ContractSolutionOptions,
this.makeFetchOptions(options)
this.makeFetchOptions(options),
);
}

Expand Down Expand Up @@ -385,7 +385,7 @@ export class Sprinter {
*/
public async transfer(
settings: Infer<typeof SingleHopSchema>,
options?: FetchOptions
options?: FetchOptions,
): Promise<SolutionResponse> {
assert(settings, SingleHopSchema);

Expand All @@ -396,7 +396,7 @@ export class Sprinter {
amount: BigInt(amount),
whitelistedSourceChains: sourceChains,
} as SolutionOptions,
this.makeFetchOptions(options)
this.makeFetchOptions(options),
);
}

Expand Down Expand Up @@ -459,7 +459,7 @@ export class Sprinter {
*/
public async transferWithHook(
settings: Infer<typeof SingleHopWithContractSchema>,
options?: FetchOptions
options?: FetchOptions,
): Promise<SolutionResponse> {
assert(settings, SingleHopWithContractSchema);

Expand All @@ -470,13 +470,13 @@ export class Sprinter {
amount: BigInt(amount),
whitelistedSourceChains: sourceChains,
} as SolutionOptions,
this.makeFetchOptions(options)
this.makeFetchOptions(options),
);
}

private deferredRequest<T>(
name: string,
request: () => Promise<T>
request: () => Promise<T>,
): Promise<T> {
if (!(name in this.#requests)) {
this.#requests[name] = request();
Expand Down

0 comments on commit 8a33bdb

Please sign in to comment.