Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove client.actions/utils wrappers #21

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
63 changes: 30 additions & 33 deletions .github/ISSUE_TEMPLATE/bug-report-🐛.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
name: "Bug report \U0001F41B"
about: Thank you for reporting an issue with the Across Integrator SDK. To help us
about:
Thank you for reporting an issue with the Across Integrator SDK. To help us
address your problem efficiently, please fill out the following details.
title: ''
title: ""
labels: bug
assignees: ''

assignees: ""
---

## Summary
Expand All @@ -25,17 +25,16 @@ assignees: ''
## Integration Details

- **Functionality Affected**:
- [ ] Getting a quote
- [ ] Executing a quote
- [ ] Tracking bridge progress
- [ ] Lower-level utilities
- [ ] Other (please specify): <!-- Describe if other functionality is affected -->

- [ ] Getting a quote
- [ ] Executing a quote
- [ ] Tracking bridge progress
- [ ] Lower-level utilities
- [ ] Other (please specify): <!-- Describe if other functionality is affected -->

- **Network Environment**:

- [ ] Mainnet
- [ ] Testnet
- [ ] Mainnet
- [ ] Testnet

## Steps to Reproduce

Expand All @@ -53,34 +52,34 @@ assignees: ''

<!-- Describe what actually happened, including any error messages or stack traces -->

## Is This a Regression?
## Is This a Regression?

- [ ] Yes
- [ ] No
- [ ] Not Sure
- [ ] Yes
- [ ] No
- [ ] Not Sure

## Code Snippets (optional)

<!-- Provide relevant code snippets that can help us understand and reproduce the issue -->

```ts
const client = AcrossClient.create({
chains,
useTestnet: false,
integratorId: "TEST",
logLevel: "DEBUG",
walletClient,
tenderly: {
accessKey: process.env.TENDERLY_ACCESS_KEY!,
accountSlug: process.env.TENDERLY_ACCOUNT_SLUG!,
projectSlug: process.env.TENDERLY_PROJECT_SLUG!,
},
chains,
useTestnet: false,
integratorId: "TEST",
logLevel: "DEBUG",
walletClient,
tenderly: {
accessKey: process.env.TENDERLY_ACCESS_KEY!,
accountSlug: process.env.TENDERLY_ACCOUNT_SLUG!,
projectSlug: process.env.TENDERLY_PROJECT_SLUG!,
},
});

const routeInfo = await client.actions.getAvailableRoutes({
originChainId: 10,
destinationChainId: 1,
originToken: "0x123123",
const routeInfo = await client.getAvailableRoutes({
originChainId: 10,
destinationChainId: 1,
originToken: "0x123123",
});
```

Expand All @@ -92,8 +91,6 @@ const routeInfo = await client.actions.getAvailableRoutes({

<!-- If applicable, add screenshots to help explain your problem -->



<!-- If yes, specify the last version where the issue did not occur -->

## Additional Context (optional)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a href="https://across.to">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./.github/across-logo-dark.png">
<img alt="viem logo" src="./.github/across-logo-light.png" width="auto" height="60">
<img alt="across logo" src="./.github/across-logo-light.png" width="auto" height="60">
</picture>
</a>
</p>
Expand Down Expand Up @@ -72,7 +72,7 @@ const route = {
inputToken: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
outputToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
};
const quote = await client.actions.getQuote({
const quote = await client.getQuote({
route,
inputAmount: parseUnit("1000", 6) // USDC decimals
})
Expand Down
8 changes: 4 additions & 4 deletions apps/example/app/ethers/components/Bridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const sdk = AcrossClient.create({
});

async function getQuote(account: Address) {
const routes = await sdk.actions.getAvailableRoutes({
const routes = await sdk.getAvailableRoutes({
originChainId: mainnet.id,
destinationChainId: arbitrum.id,
})!;

const route = routes.find((r) => r.inputTokenSymbol === "ETH")!;

// 1. get quote
const bridgeQuoteRes = await sdk.actions.getQuote({
const bridgeQuoteRes = await sdk.getQuote({
route,
inputAmount: parseEther("0.01"),
recipient: account,
Expand All @@ -52,7 +52,7 @@ async function bridge(
transport: custom(library.provider),
});

const { request } = await sdk.actions.simulateDepositTx({
const { request } = await sdk.simulateDepositTx({
walletClient,
deposit: quote.deposit,
});
Expand Down Expand Up @@ -115,7 +115,7 @@ export function Bridge() {
) => {
setLoadingFill(true);
// wait for tx to be filled
const data = await sdk.actions.waitForFillTx({
const data = await sdk.waitForFillTx({
depositId: deposit.depositId,
deposit: quote.deposit,
fromBlock: destinationBlock,
Expand Down
4 changes: 2 additions & 2 deletions apps/example/lib/hooks/useAvailableRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AcrossClient } from "@across-protocol/integrator-sdk";
import { buildQueryKey } from "../utils";

export type useAvailableRoutesParams = Parameters<
AcrossClient["actions"]["getAvailableRoutes"]
AcrossClient["getAvailableRoutes"]
>[0];

export function useAvailableRoutes(params: useAvailableRoutesParams) {
Expand All @@ -15,7 +15,7 @@ export function useAvailableRoutes(params: useAvailableRoutesParams) {
const { data: availableRoutes, ...rest } = useQuery({
queryKey,
queryFn: () => {
return sdk.actions.getAvailableRoutes(params);
return sdk.getAvailableRoutes(params);
},
enabled: Boolean(
params.originChainId && params.destinationChainId && params.originToken,
Expand Down
4 changes: 2 additions & 2 deletions apps/example/lib/hooks/useExecuteQuote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TransactionReceipt } from "viem";
import { getWalletClient } from "wagmi/actions";

export type useExecuteQuoteParams =
| Omit<Parameters<AcrossClient["actions"]["executeQuote"]>[0], "walletClient">
| Omit<Parameters<AcrossClient["executeQuote"]>[0], "walletClient">
| undefined;

export function useExecuteQuote(params: useExecuteQuoteParams) {
Expand Down Expand Up @@ -53,7 +53,7 @@ export function useExecuteQuote(params: useExecuteQuoteParams) {
return;
}

return sdk.actions.executeQuote({
return sdk.executeQuote({
...params,
walletClient,
infiniteApproval: true,
Expand Down
2 changes: 1 addition & 1 deletion apps/example/lib/hooks/useInputTokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function useInputTokens(originChainId: number | undefined) {
const { data: chains, ...rest } = useQuery({
queryKey,
queryFn: () => {
return sdk.utils.getSupportedChains({ chainId: originChainId });
return sdk.getSupportedChains({ chainId: originChainId });
},
enabled: Boolean(originChainId),
refetchInterval: Infinity,
Expand Down
2 changes: 1 addition & 1 deletion apps/example/lib/hooks/useOutputTokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function useOutputTokens(destinationChainId: number | undefined) {
const { data: chains, ...rest } = useQuery({
queryKey,
queryFn: () => {
return sdk.utils.getSupportedChains({ chainId: destinationChainId });
return sdk.getSupportedChains({ chainId: destinationChainId });
},
enabled: Boolean(destinationChainId),
refetchInterval: Infinity,
Expand Down
7 changes: 2 additions & 5 deletions apps/example/lib/hooks/useQuote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { AcrossClient } from "@across-protocol/integrator-sdk";
import { buildQueryKey } from "../utils";

export type useQuoteParams =
| Pick<
Parameters<AcrossClient["actions"]["getQuote"]>[0],
"inputAmount" | "route"
>
| Pick<Parameters<AcrossClient["getQuote"]>[0], "inputAmount" | "route">
| undefined;

export function useQuote(params: useQuoteParams) {
Expand All @@ -18,7 +15,7 @@ export function useQuote(params: useQuoteParams) {
queryKey,
queryFn: async () => {
if (!params) return;
return await sdk.actions.getQuote(params);
return await sdk.getQuote(params);
},
enabled: Boolean(params),
refetchInterval: 10_000,
Expand Down
2 changes: 1 addition & 1 deletion apps/example/lib/hooks/useSupportedAcrossChains.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function useSupportedAcrossChains(params: useAcrossChainsParams) {
const { data: supportedChains, ...rest } = useQuery({
queryKey,
queryFn: () => {
return sdk.utils.getSupportedChains(params);
return sdk.getSupportedChains(params);
},
enabled: true,
refetchInterval: Infinity,
Expand Down
22 changes: 11 additions & 11 deletions apps/example/scripts/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function main() {

// do call to find info for displaying input/output tokens and destination chains
// 1. populate UI
const chainDetails = await client.utils.getSupportedChains({});
const chainDetails = await client.getSupportedChains({});

// 2. choose origin chain, optimism in this example
const originChain = optimism.id;
Expand All @@ -81,7 +81,7 @@ async function main() {
const usdc = inputTokens.find((token) => token.symbol === "USDC")!;

// 5. get routes
const routeInfo = await client.actions.getAvailableRoutes({
const routeInfo = await client.getAvailableRoutes({
originChainId: originChain,
destinationChainId: destinationChainDetails?.chainId,
originToken: usdc?.address,
Expand All @@ -96,13 +96,13 @@ async function main() {
/* --------------------------- test normal bridge --------------------------- */

// 1. get quote
const bridgeQuoteRes = await client.actions.getQuote({
const bridgeQuoteRes = await client.getQuote({
route,
inputAmount: parseUnits("1", usdc.decimals),
});

// 2. simulate/prep deposit tx
const { request } = await client.actions.simulateDepositTx({
const { request } = await client.simulateDepositTx({
walletClient,
deposit: bridgeQuoteRes.deposit,
});
Expand Down Expand Up @@ -136,7 +136,7 @@ async function main() {

// 5. OPTION 1 - watch events on destination chain

const result = await client.actions.waitForFillTx({
const result = await client.waitForFillTx({
depositId,
deposit: bridgeQuoteRes.deposit,
fromBlock: destinationBlock,
Expand All @@ -153,7 +153,7 @@ async function main() {
let res = undefined;
while (!res) {
try {
const result = await client.actions.getFillByDepositTx({
const result = await client.getFillByDepositTx({
depositId,
depositTransactionHash: depositTxReceipt.transactionHash,
deposit: bridgeQuoteRes.deposit,
Expand All @@ -179,7 +179,7 @@ async function main() {
/* -------------------- test with `executeQuote` function ------------------- */
if (process.env.USE_EXECUTE_QUOTE === "true") {
console.log("\nExecuting quote via `executeQuote` function...");
const result = await client.actions.executeQuote({
const result = await client.executeQuote({
walletClient,
deposit: bridgeQuoteRes.deposit,
onProgress: (progress) => {
Expand All @@ -200,7 +200,7 @@ async function main() {
const inputTokenDetails = arbitrumInfo.inputTokens.find(
(token) => token.symbol === "DAI",
)!;
const routes = await client.actions.getAvailableRoutes({
const routes = await client.getAvailableRoutes({
originChainId: optimism.id,
destinationChainId: arbitrum.id,
});
Expand All @@ -218,7 +218,7 @@ async function main() {
const depositCurrency = inputTokenDetails.address;
const aaveReferralCode = 0;

const quoteRes = await client.actions.getQuote({
const quoteRes = await client.getQuote({
route: crossChainRoute,
inputAmount,
recipient: "0x924a9f036260DdD5808007E1AA95f08eD08aA569",
Expand Down Expand Up @@ -261,7 +261,7 @@ async function main() {
console.log(quoteRes);

try {
await client.actions.getLimits({
await client.getLimits({
inputToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
outputToken: "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",
originChainId: 1,
Expand All @@ -279,7 +279,7 @@ async function main() {
try {
// simulate deposit tx - should fail
const { request: simulateDepositTxRequest } =
await client.actions.simulateDepositTx({
await client.simulateDepositTx({
walletClient,
deposit: quoteRes.deposit,
});
Expand Down
Loading
Loading