solana-labs / solana-program-library

A collection of Solana programs maintained by Solana Labs
https://solanalabs.com
Apache License 2.0
3.61k stars 2.1k forks source link

token-js: Expose `calculateFee` for mints with transfer fees #4513

Closed joncinque closed 1 year ago

joncinque commented 1 year ago

Problem

The rust side provides a nifty way to calculate a transfer fee using calculate_fee https://github.com/solana-labs/solana-program-library/blob/108e91e441e6633f046168536be571068e90169b/token/program-2022/src/extension/transfer_fee/mod.rs#L50, but wallets or JS clients can't use this.

Solution

Add an implementation for calculateFee in token-js.

dhruvdabhi101 commented 1 year ago

I would like to try this issue, As I have seen in this issue, we have to create a function for this interface. right ? https://github.com/solana-labs/solana-program-library/blob/108e91e441e6633f046168536be571068e90169b/token/js/src/extensions/transferFee/state.ts#L13

joncinque commented 1 year ago

Yep that's pretty much it. And it would also be good to add a helper like https://github.com/solana-labs/solana-program-library/blob/108e91e441e6633f046168536be571068e90169b/token/program-2022/src/extension/transfer_fee/mod.rs#L133 on TransferFeeConfig

dhruvdabhi101 commented 1 year ago

I will try solve this issue then, if there is something i don't understand then please help me, since I'm beginner in Rust.

pcellix commented 1 year ago

@dhruvdabhi101 have you worked on it? I would like to join as contributor as well :D

dhruvdabhi101 commented 1 year ago

@dhruvdabhi101 have you worked on it? I would like to join as contributor as well :D

Ohh. I already made pull request and got merged. I think they forgot to close this issue.

joncinque commented 1 year ago

Yep that's correct, https://github.com/solana-labs/solana-program-library/pull/4594 resolved it. Closing the issue