celo-org / viem

TypeScript Interface for Ethereum
https://viem.sh
Other
0 stars 0 forks source link

Add celo fee.estimateFeePerGas #10

Closed aaronmgdr closed 3 months ago

aaronmgdr commented 5 months ago

Overview

This PR introduces custom fee estimation for cases when feeCurrency is used to send a transaction.

Other changes

It also introduces a fallback behaviour of the custom estimation logic.

Tested

Test values from alfajores:

Symbol maxFeePerGas maxPriorityFeePerGas
CELO 8000000000n 2000000000n
cREAL 63940958968n 12788191793n
cEUR 11755155930n 2351031186n
cUSD 12672525950n 2534505190n
USDC 12672525950n 2534505190n

Fixes

Fixes #4

aaronmgdr commented 4 months ago

currently wrestling with types. since celo block formatter will format the block to include randomness that is considered required by this function. even though its not used.

my thought is its better to only included the properties that are used in the function as required but im not sure how to modify these types are they are quite complex.

Types of property 'block' are incompatible.
 Property 'randomness' is missing in type '{ number: bigint | null; hash: `0x${string}` | null; nonce: `0x${string}` | null; size: bigint; logsBloom: `0x${string}` | null; baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; ... 17 more ...; transactions: `0x${string}`[] | ({ ...; } | ... 2 more ... | { ...; })[]; }' but required in type '{ number: bigint | null; hash: `0x${string}` | null; nonce: never; size: bigint; logsBloom: `0x${string}` | null; baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: never; excessBlobGas: bigint; ... 17 more ...; transactions: `0x${string}`[] | ({ ...; } | ... 12 more ... | { ...; })[]; }'.
github-actions[bot] commented 3 months ago

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
viem (esm) 66.42 KB (+0.02% 🔺) 1.4 s (+0.02% 🔺) 4.7 s (+62.44% 🔺) 6 s
viem (cjs) 86.28 KB (+0.02% 🔺) 1.8 s (+0.02% 🔺) 9.7 s (+55.22% 🔺) 11.4 s
viem (minimal surface - tree-shaking) 3.73 KB (0%) 75 ms (0%) 61 ms (-4.89% 🔽) 136 ms
viem/accounts 91.47 KB (0%) 1.9 s (0%) 898 ms (-36.09% 🔽) 2.8 s
viem/accounts (tree-shaking) 21.09 KB (0%) 422 ms (0%) 815 ms (-23.26% 🔽) 1.3 s
viem/actions 46.67 KB (0%) 934 ms (0%) 1.2 s (-45.81% 🔽) 2.2 s
viem/actions (tree-shaking) 340 B (0%) 10 ms (0%) 32 ms (+23.95% 🔺) 42 ms
viem/chains 30.87 KB (+0.46% 🔺) 618 ms (+0.46% 🔺) 1.6 s (+2.94% 🔺) 2.2 s
viem/chains (tree-shaking) 367 B (0%) 10 ms (0%) 31 ms (+19.53% 🔺) 41 ms
viem/chains/utils 1.16 KB (0%) 24 ms (0%) 34 ms (-2.77% 🔽) 57 ms
viem/ens 46.67 KB (0%) 934 ms (0%) 1.6 s (+38.65% 🔺) 2.5 s
viem/ens (tree-shaking) 20.69 KB (0%) 414 ms (0%) 436 ms (-74.86% 🔽) 849 ms
aaronmgdr commented 3 months ago

I would say merge this into the celo/viem main branch and then open a pr from that to viem main