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

feat(earn): add function for preparing supply transaction #5405

Merged
merged 5 commits into from May 14, 2024

Conversation

satish-ravi
Copy link
Contributor

Description

Mostly based off of swap transaction preparation

Test plan

Unit tests, manually preparing a tx

Related issues

Backwards compatibility

Yes

Network scalability

If a new NetworkId and/or Network are added in the future, the changes in this PR will:

  • Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 97.61905% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 86.15%. Comparing base (d6f9a38) to head (794001f).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5405   +/-   ##
=======================================
  Coverage   86.14%   86.15%           
=======================================
  Files         744      745    +1     
  Lines       30291    30333   +42     
  Branches     5181     5186    +5     
=======================================
+ Hits        26094    26133   +39     
- Misses       3969     3972    +3     
  Partials      228      228           
Files Coverage Δ
src/web3/networkConfig.ts 100.00% <100.00%> (ø)
src/earn/prepareTransactions.ts 97.50% <97.50%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6f9a38...794001f. Read the comment docs.

// amount in smallest unit
const amountToSupply = parseUnits(amount, token.decimals)

if (!token.address) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i've been nagging people to use the viem type guard in places like this:

if (!token.address || !isAddress(token.address) {

const approvedAllowanceForSpender = await publicClient[
networkIdToNetwork[token.networkId]
].readContract({
address: token.address as Address,
Copy link
Collaborator

Choose a reason for hiding this comment

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

...then you can drop the type assertions and maybe feel good about that.

@satish-ravi satish-ravi added this pull request to the merge queue May 13, 2024
Merged via the queue into main with commit 258f77a May 14, 2024
16 checks passed
@satish-ravi satish-ravi deleted the satish/act-1178-prepare-tx branch May 14, 2024 00:02
shottah pushed a commit to zed-io/kolektivo that referenced this pull request May 15, 2024
…#5405)

### Description

Mostly based off of swap transaction preparation

### Test plan

Unit tests, manually preparing a tx

### Related issues

- Part of ACT-1178

### Backwards compatibility

Yes

### Network scalability

If a new NetworkId and/or Network are added in the future, the changes
in this PR will:

- [x] Continue to work without code changes, OR trigger a compilation
error (guaranteeing we find it when a new network is added)
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.

None yet

4 participants