Skip to content

Commit

Permalink
default to false and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Dec 9, 2024
1 parent 8a33bdb commit 035ed1d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,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 @@ -37,6 +37,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
4 changes: 4 additions & 0 deletions packages/sdk/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export async function getContractSolution(
contractCall,
threshold,
whitelistedSourceChains,
enableSwaps,
}: ContractSolutionOptions,
{ baseUrl, signal }: FetchOptions = {},
): Promise<SolutionResponse> {
Expand All @@ -165,6 +166,7 @@ export async function getContractSolution(
type: "fungible",
threshold,
whitelistedSourceChains,
enableSwaps
}),
}).then(
(response) =>
Expand All @@ -185,6 +187,7 @@ export async function getContractCallSolution(
recipient,
threshold,
whitelistedSourceChains,
enableSwaps,
}: SingleHopContractSolutionOptions,
{ baseUrl, signal }: FetchOptions = {},
): Promise<SolutionResponse> {
Expand All @@ -203,6 +206,7 @@ export async function getContractCallSolution(
recipient,
threshold,
whitelistedSourceChains,
enableSwaps,
}),
}).then(
(response) =>
Expand Down
10 changes: 6 additions & 4 deletions packages/sdk/src/sprinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +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): Whether to enable token swaps on the source chain.
* - `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 Down Expand Up @@ -389,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 @@ -424,7 +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): Whether to enable token swaps on the source chain.
* - `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 Down Expand Up @@ -463,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 @@ -45,6 +45,7 @@ export interface SolutionOptions {
amount: NumberLike;
threshold?: number;
whitelistedSourceChains?: ChainID[];
enableSwaps?: boolean;
}

export interface ContractCallSolutionOptions {
Expand Down

0 comments on commit 035ed1d

Please sign in to comment.