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

fix: add proper types #4401

Merged
merged 3 commits into from
Jun 5, 2023
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
64 changes: 64 additions & 0 deletions packages/agents/sdk/src/lib/helpers/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getHardcodedGasLimits as _getHardcodedGasLimits,
calculateRelayerFee as _calculateRelayerFee,
axiosGet,
XTransferStatus,
} from "@connext/nxtp-utils";
import { providers } from "ethers";

Expand Down Expand Up @@ -55,3 +56,66 @@ export const parseConnextLog = (log: providers.Log): any => {
throw new ParseConnextLogFailed({ log });
}
};

export type Transfer = {
transfer_id: string;
nonce: number;
to: string;
call_data: string;
origin_domain: string;
destination_domain: string;
receive_local: boolean;
origin_chain: string;
origin_transacting_asset: string;
origin_transacting_amount: string;
origin_bridged_asset: string;
origin_bridged_amount: string;
xcall_caller: string;
xcall_transaction_hash: string;
xcall_timestamp: string;
xcall_gas_price: string;
xcall_gas_limit: string;
xcall_block_number: string;
destination_chain: string;
status: XTransferStatus;
routers: string[];
destination_transacting_asset: string;
destination_transacting_amount: string;
destination_local_asset: string;
destination_local_amount: string;
execute_caller: string;
execute_transaction_hash: string;
execute_timestamp: number;
execute_gas_price: string;
execute_gas_limit: string;
execute_block_number: number;
execute_origin_sender: string;
reconcile_caller: string;
reconcile_transaction_hash: string;
reconcile_timestamp: string;
reconcile_gas_price: string;
reconcile_gas_limit: string;
reconcile_block_number: number;
update_time: string;
delegate: string;
message_hash: string;
canonical_domain: string;
slippage: number;
origin_sender: string;
bridged_amt: string;
normalized_in: string;
canonical_id: string;
router_fee?: string;
xcall_tx_origin: string;
execute_tx_origin: string;
reconcile_tx_origin: string;
relayer_fee: string;
error_status?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execute_simulation_input?: string,
execute_simulation_from?: string,
execute_simulation_to?: string,
execute_simulation_network?: string,
error_message?: string,
message_status?: string,
relayer_fees?: string[]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the ones i think was missing, @coinhippo review is required here as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrsirapop @pjenviri Can we check if all the types are present which we are using or need.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the missing ones.

execute_simulation_input?: string;
execute_simulation_from?: string;
execute_simulation_to?: string;
execute_simulation_network?: string;
error_message?: string;
message_status?: string;
relayer_fees?: string[];
};
2 changes: 1 addition & 1 deletion packages/agents/sdk/src/sdkBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export class SdkBase extends SdkShared {
throw new ParamsInvalid({
paramsError: "Must update slippage on destination domain",
domain: domainId,
destination: transfer.destionation_domain,
destination: transfer.destination_domain,
transferId,
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/agents/sdk/src/sdkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@connext/nxtp-utils";
import { contractDeployments } from "@connext/nxtp-txservice";

import { validateUri, axiosGetRequest } from "./lib/helpers";
import { validateUri, axiosGetRequest, Transfer } from "./lib/helpers";
import { SdkConfig, getConfig } from "./config";
import { SdkShared } from "./sdkShared";
import { RouterBalance } from "./interfaces";
Expand Down Expand Up @@ -216,7 +216,7 @@ export class SdkUtils extends SdkShared {
transactionHash?: string;
xcallCaller?: string;
range?: { limit?: number; offset?: number };
}): Promise<any> {
}): Promise<Transfer[]> {
const { userAddress, routerAddress, status, transferId, transactionHash, range, xcallCaller, errorStatus } =
params ?? {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const TransferButton = ({
} catch (error: unknown) {}
if (
[XTransferStatus.Executed, XTransferStatus.CompletedFast, XTransferStatus.CompletedSlow].includes(
transfer?.status,
transfer?.status as any,
)
) {
reset();
Expand All @@ -261,7 +261,7 @@ export const TransferButton = ({

if (
[XTransferStatus.Executed, XTransferStatus.CompletedFast, XTransferStatus.CompletedSlow].includes(
transfer?.status,
transfer?.status as any,
)
) {
reset();
Expand Down