Skip to content

Commit

Permalink
mc fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
montera82 committed Aug 16, 2023
1 parent e0833e3 commit 93eff77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/celo-org/gas-snap.git"
},
"source": {
"shasum": "Aglj//sQdE+aaLIrYZNEA9WcyK0iWd3JH+JGANbCXRQ=",
"shasum": "4BXNaoFgU0KEg0USjhSjven6VJ2SGRbHJDAHbwM31CQ=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/src/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ export async function getOptimalFeeCurrency(
const gasLimit = (await wallet.estimateGas(tx)).mul(5);
const celoBalance = await wallet.getBalance();
const tokenAddresses = await feeCurrencyWhitelistContract.getWhitelist();

if (gasLimit.add(tx.value ?? 0) >= celoBalance) {
const gasLimitPlusValue = gasLimit.add(tx.value ?? 0);
if (gasLimitPlusValue.gt(celoBalance)) {
console.log('using stable token for gas');
const tokens: Contract[] = tokenAddresses.map(
(tokenAddress: string) =>
Expand Down
1 change: 1 addition & 0 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => {
const provider = new CeloProvider(network.url);
const keyPair = await getKeyPair(snap, tx.from);
const wallet = new CeloWallet(keyPair.privateKey).connect(provider);
tx.from = tx.from ? tx.from : wallet.address;
if (tx.value === constants.Zero) {
delete tx.value;
}
Expand Down

0 comments on commit 93eff77

Please sign in to comment.