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(sdk): expose transaction ref from ingress egress tracker in sdk swaps [WEB-1643] #1102

Merged
merged 10 commits into from
Dec 5, 2024

Conversation

sukhoviianastasia
Copy link
Contributor

@sukhoviianastasia sukhoviianastasia commented Dec 2, 2024

Added deposit_details field on depositSchema from the backend

enum DepositDetails {
	Bitcoin { tx_id: H256, vout: u32 },
	Ethereum { tx_hashes: Vec<H256> },
	Polkadot { extrinsic_index: PolkadotExtrinsicIndex },
	Arbitrum { tx_hashes: Vec<H256> },
}

@sukhoviianastasia sukhoviianastasia requested a review from a team as a code owner December 2, 2024 14:12
@sukhoviianastasia sukhoviianastasia marked this pull request as draft December 2, 2024 14:12
@sukhoviianastasia sukhoviianastasia self-assigned this Dec 2, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.18%. Comparing base (cff3a22) to head (f2e6025).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1102      +/-   ##
==========================================
- Coverage   87.21%   87.18%   -0.03%     
==========================================
  Files         100      100              
  Lines        1369     1366       -3     
  Branches      214      214              
==========================================
- Hits         1194     1191       -3     
  Misses        166      166              
  Partials        9        9              
Flag Coverage Δ
sdk 96.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 160 to 167
const parsedDeposit = depositSchema.parse(deposit);
const { deposit_details, deposit_chain_block_height } = parsedDeposit;

const baseDeposit = {
amount: parsedDeposit.amount,
asset: parsedDeposit.asset,
deposit_chain_block_height: parsedDeposit.deposit_chain_block_height,
};
Copy link
Collaborator

@acdibble acdibble Dec 3, 2024

Choose a reason for hiding this comment

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

a little shorter:

Suggested change
const parsedDeposit = depositSchema.parse(deposit);
const { deposit_details, deposit_chain_block_height } = parsedDeposit;
const baseDeposit = {
amount: parsedDeposit.amount,
asset: parsedDeposit.asset,
deposit_chain_block_height: parsedDeposit.deposit_chain_block_height,
};
const { deposit_details, ...baseDeposit } = depositSchema.parse(deposit);
const { deposit_chain_block_height } = baseDeposit;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if i need to somehow movebaseDeposit to the depositSchema (or i need to remove baseDeposit )

Copy link
Collaborator

Choose a reason for hiding this comment

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

oops, fixed it 🤦

},
]);
expect(mock).toHaveBeenCalledWith('deposit:Ethereum:0x1234', 0, -1);
});

it('returns the deposits if found - Polkadot', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚀

@@ -12,14 +13,38 @@ const jsonString = string.transform((value) => JSON.parse(value));

const chainAsset = uncheckedAssetAndChain.transform(({ asset }) => asset);

const BitcoinDeposit = z.object({
Copy link
Collaborator

Choose a reason for hiding this comment

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

these can be camelCase

Suggested change
const BitcoinDeposit = z.object({
const bitcoinDeposit = z.object({

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed ☺️

@sukhoviianastasia sukhoviianastasia changed the title fix(swap sdk): expose transaction ref from ingress egress tracker in sdk swaps [WEB-1643] fix(sdk): expose transaction ref from ingress egress tracker in sdk swaps [WEB-1643] Dec 3, 2024
@sukhoviianastasia sukhoviianastasia marked this pull request as ready for review December 3, 2024 15:58

if (!deposit_details) return { ...baseDeposit, tx_refs: [] };

switch (chain) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we maybe reuse the getDepositTxRef method here?

Copy link
Contributor Author

@sukhoviianastasia sukhoviianastasia Dec 5, 2024

Choose a reason for hiding this comment

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

I've been trying to reuse that function but it didn't really work because the shape of the ingress egress tracker does not match the depositDetails types (bitcoinSchema160, bitcoinSchema170...). I'm going to go back to my previous commits

@@ -127,12 +152,36 @@ export default class RedisClient {
return value ? broadcastParsers[chain].parse(JSON.parse(value)) : null;
}

async getDeposits(chain: Chain, asset: Asset, address: string) {
async getDeposits(chain: Chain, asset: Asset, address: string): Promise<PendingDeposit[]> {
Copy link
Contributor

Choose a reason for hiding this comment

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

now that this method returns the tx ref information, we should return it from the status endpoint. to do that, we need to adjust the getPendingDeposit method

Copy link
Contributor

Choose a reason for hiding this comment

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

but would be fine for me to do that in a separate pr if you prefer that!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do in separate pr 👾

@sukhoviianastasia
Copy link
Contributor Author

I'll try to refactor getDeposits soon

@sukhoviianastasia sukhoviianastasia force-pushed the expose-tx-ref-ingress-egress branch from 2f668b3 to f2e6025 Compare December 5, 2024 10:13
@sukhoviianastasia sukhoviianastasia merged commit d323cb4 into main Dec 5, 2024
42 checks passed
@sukhoviianastasia sukhoviianastasia deleted the expose-tx-ref-ingress-egress branch December 5, 2024 11:05
zoheb391 pushed a commit that referenced this pull request Dec 9, 2024
…waps [WEB-1643] (#1102)

* fix(swap sdk): expose transaction ref from ingress egress tracker in sdk status

* fix: clean

* fix: clean

* fix getDeposit func

* fix types

* add test and clean

* fix swap files

* fix imports

* fix pipeline

* camelcases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants