Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ sprinter.transferWithHook(settings, { baseUrl: "https://custom.api.url" }).then(
## Parameters

- `settings`: _(Required)_ An object containing the following fields:

- `account`: The user’s address.
- `destinationChain`: The ID of the destination chain.
- `token`: The symbol of the token to be transferred (e.g., `USDC`, `ETH`).
Expand All @@ -112,6 +113,8 @@ sprinter.transferWithHook(settings, { baseUrl: "https://custom.api.url" }).then(
- `recipient?`: _(Optional)_ The address of the recipient of any leftover tokens.
- `sourceChains?`: _(Optional)_ An array of source chain IDs to be considered for the transfer. If omitted, Sprinter will use all available chains for the solution.
- `threshold?`: _(Optional)_ The minimum amount of tokens required to trigger the transfer solution. If not met, the transfer solution will not proceed.
- `enableSwaps`: _(Optional)_ Defaults to `false`. Whether to enable token swaps on the source chain.

- `fetchOptions?`: _(Optional)_ An object containing `baseUrl` to override the default API endpoint for this request.

import HowToCallData from "../\_how-to-calldata.md"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sprinter.transfer(settings).then((solution) => {
- `recipient?`: _(Optional)_ The address of the recipient of any leftover tokens.
- `sourceChains?`: _(Optional)_ An array of source chain IDs to be considered for the transfer. If omitted, Sprinter will use all available chains for the solution. To limit the solution to a specific chain, provide an array containing only that chain's ID.
- `threshold?`: _(Optional)_ The minimum amount of tokens required to trigger the transfer solution. If not met, the transfer solution will not proceed.
- `enableSwaps`: _(Optional)_ Defaults to `false`. Whether to enable token swaps on the source chain.

- `fetchOptions?`: _(Optional)_ An object containing `baseUrl` to override the default API endpoint for this request.

Expand Down
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
}
2 changes: 2 additions & 0 deletions packages/sdk/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export async function getContractCallSolution(
recipient,
threshold,
whitelistedSourceChains,
enableSwaps,
}: SingleHopContractSolutionOptions,
{ baseUrl, signal }: FetchOptions = {},
): Promise<SolutionResponse> {
Expand All @@ -203,6 +204,7 @@ export async function getContractCallSolution(
recipient,
threshold,
whitelistedSourceChains,
enableSwaps,
}),
}).then(
(response) =>
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/src/internal/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
array,
assign,
bigint,
boolean,
define,
number,
object,
Expand Down Expand Up @@ -40,6 +41,7 @@ const BridgeCoreSchema = object({
const BridgeCoreWithRecipientSchema = assign(
BridgeCoreSchema,
object({
enableSwaps: optional(boolean()),
recipient: optional(hexString()),
}),
);
Expand Down
10 changes: 8 additions & 2 deletions packages/sdk/src/sprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export class Sprinter {
* - `recipient` (optional): The address of the recipient of any leftover tokens.
* - `threshold` (optional): The minimum amount threshold required for the transfer.
* - `sourceChains` (optional): An array of whitelisted source chain IDs for the transfer.
* - `enableSwaps` {boolean} (optional): Defaults to `false`. Whether to enable token swaps on the source chain.
*
* @param {FetchOptions} [options] - Optional configuration for the fetch request, such as custom headers or query parameters.
*
Expand All @@ -372,6 +373,7 @@ export class Sprinter {
* token: "USDC",
* amount: "100000000",
* recipient: "0xRecipientAddress", // Optional recipient of leftover tokens
* enableSwaps: true, // Enabling swaps on the source chain
* };
*
* sprinter.transfer(settings).then(solution => {
Expand All @@ -387,10 +389,11 @@ export class Sprinter {
): Promise<SolutionResponse> {
assert(settings, SingleHopSchema);

const { sourceChains, amount, ...data } = settings;
const { sourceChains, amount, enableSwaps = false, ...data } = settings;
return await getContractCallSolution(
{
...data,
enableSwaps,
amount: BigInt(amount),
whitelistedSourceChains: sourceChains,
} as SolutionOptions,
Expand Down Expand Up @@ -422,6 +425,7 @@ export class Sprinter {
* - `recipient` {string} (optional): The address of the recipient of any leftover tokens.
* - `sourceChains` {Array<number>} (optional): An array of source chain IDs to be considered for the transfer.
* - `threshold` {number} (optional): The minimum amount threshold required for the transfer.
* - `enableSwaps` {boolean} (optional): Defaults to `false`. Whether to enable token swaps on the source chain.
*
* @param {FetchOptions} [options] - Optional configuration for the fetch request, such as custom headers or query parameters.
*
Expand All @@ -444,6 +448,7 @@ export class Sprinter {
* gasLimit: 21000,
* },
* recipient: "0xRecipientAddress", // for sending leftover tokens
* enableSwaps: true, // Enabling swaps on the source chain
* };
*
* sprinter.transferWithHook(settings).then(solution => {
Expand All @@ -459,10 +464,11 @@ export class Sprinter {
): Promise<SolutionResponse> {
assert(settings, SingleHopWithContractSchema);

const { sourceChains, amount, ...data } = settings;
const { sourceChains, amount, enableSwaps = false, ...data } = settings;
return await getContractCallSolution(
{
...data,
enableSwaps,
amount: BigInt(amount),
whitelistedSourceChains: sourceChains,
} as SolutionOptions,
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface ContractCallSolutionOptions {
export interface SingleHopContractSolutionOptions extends SolutionOptions {
recipient?: Address;
contractCall?: ContractCallSolutionOptions;
enableSwaps?: boolean;
}

export interface ContractSolutionOptions extends SolutionOptions {
Expand Down
Loading