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

feature request: ability to estimate fees from NetworkFacade class #757

Open
comountainclimber opened this issue Jul 2, 2021 · 2 comments

Comments

@comountainclimber
Copy link
Member

As a wallet developer using the slick NetworkFacade class it would be very helpful to add a method for calculating estimated fees for a transaction it would be amazing if API was similar to that of the transferToken method!

@lock9
Copy link

lock9 commented Aug 26, 2022

Hi @ixje , is this related to the smartCalculateFee?

@ixje
Copy link
Member

ixje commented Aug 30, 2022

it can be done with just smartCalculateNetworkFee but that would require manually building the tx. I believe @comountainclimber is basically asking for combining this

const client = this.getRpcNode();
const txBuilder = new TransactionBuilder();
for (const intent of intents) {
if (intent.decimalAmt) {
const [tokenInfo] = await getTokenInfos([intent.contractHash], client);
const amt = u.BigInteger.fromDecimal(
intent.decimalAmt,
tokenInfo.decimals
);
txBuilder.addNep17Transfer(
intent.from,
intent.to,
intent.contractHash,
amt
);
} else if (intent.integerAmt) {
txBuilder.addNep17Transfer(
intent.from,
intent.to,
intent.contractHash,
intent.integerAmt
);
} else {
throw new Error("no amount specified!");
}
}
const txn = txBuilder.build();
const validateResult = await this.validate(txn);
if (!validateResult.valid) {
throw new Error("Unable to validate transaction");
}

with this
export async function smartCalculateNetworkFee(

into a single function

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

No branches or pull requests

3 participants