Skip to content

Commit 8d48bd4

Browse files
authored
feat: minimize required getDeposit params (#43)
* feat: minimize required `getDeposit` params * chore: add changset
1 parent 31a0a8c commit 8d48bd4

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

.changeset/little-pans-explain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@across-protocol/app-sdk": patch
3+
---
4+
5+
decrease required `getDeposit` params

apps/example/scripts/sdk.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ async function main() {
194194
const depositFilter = {
195195
originChainId: 42161,
196196
destinationChainId: 10,
197-
originSpokePoolAddress: "0xe35e9842fceaCA96570B734083f4a58e8F7C5f2A",
198-
destinationSpokePoolAddress: "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
199197
} as const;
200198
const depositByTxHash = await client.getDeposit({
201199
findBy: {

packages/sdk/src/client.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export class AcrossClient {
145145
private walletClient?: ConfiguredWalletClient;
146146
private apiUrl: string;
147147
private indexerUrl: string;
148+
148149
logger: LoggerT;
149150

150151
// Tenderly related options
@@ -251,7 +252,7 @@ export class AcrossClient {
251252
acrossChains.map((acrossChain) => [acrossChain.chainId, acrossChain]),
252253
);
253254
}
254-
if (this.chainInfo.has(chainId)) {
255+
if (!this.chainInfo.has(chainId)) {
255256
throw new Error(`Could not find chainInfo for chain with id ${chainId}`);
256257
}
257258

@@ -566,11 +567,32 @@ export class AcrossClient {
566567
async getDeposit(
567568
params: Omit<
568569
GetDepositParams,
569-
"originChainClient" | "destinationChainClient" | "indexerUrl"
570-
>,
570+
"originChainClient" | "destinationChainClient" | "indexerUrl" | "findBy"
571+
> & {
572+
findBy: {
573+
originSpokePoolAddress?: Address;
574+
destinationSpokePoolAddress?: Address;
575+
originChainId: number;
576+
destinationChainId: number;
577+
depositId?: number;
578+
depositTxHash?: Hex;
579+
};
580+
},
571581
) {
582+
const originSpokePoolAddress =
583+
params.findBy.originSpokePoolAddress ??
584+
(await this.getSpokePoolAddress(params.findBy.originChainId));
585+
const destinationSpokePoolAddress =
586+
params.findBy.destinationSpokePoolAddress ??
587+
(await this.getSpokePoolAddress(params.findBy.destinationChainId));
588+
572589
return getDeposit({
573590
...params,
591+
findBy: {
592+
...params.findBy,
593+
originSpokePoolAddress,
594+
destinationSpokePoolAddress,
595+
},
574596
indexerUrl: this.indexerUrl,
575597
originChainClient: this.getPublicClient(params.findBy.originChainId),
576598
destinationChainClient: this.getPublicClient(

0 commit comments

Comments
 (0)