@@ -34,7 +34,8 @@ import {
35} from 'lib/txn';
35} from 'lib/txn';
36import * as tank from 'lib/tank';
36import * as tank from 'lib/tank';
37−import { MIN_PLANET, GAS_LIMITS, DEFAULT_GAS_PRICE_GWEI } from 'lib/constants';
37+import { MIN_PLANET, GAS_LIMITS } from 'lib/constants';
38+import { useSuggestedGasPrice } from 'lib/useSuggestedGasPrice';
38import * as need from 'lib/need';
39import * as need from 'lib/need';
39import * as wg from 'lib/walletgen';
40import * as wg from 'lib/walletgen';
40import useSetState from 'lib/useSetState';
41import useSetState from 'lib/useSetState';
@@ -59,10 +60,6 @@ import FormError from 'form/FormError';
59const INITIAL_VALUES = { emails: [''] };
60const INITIAL_VALUES = { emails: [''] };
61const GAS_LIMIT = GAS_LIMITS.GIFT_PLANET;
62const GAS_LIMIT = GAS_LIMITS.GIFT_PLANET;
62−const INVITE_COST = toWei(
63− (DEFAULT_GAS_PRICE_GWEI * GAS_LIMIT).toString(),
66const HAS_RECEIVED_TEXT = 'This email has already received an invite.';
63const HAS_RECEIVED_TEXT = 'This email has already received an invite.';
68const STATUS = {
65const STATUS = {
@@ -106,6 +103,7 @@ export default function InviteEmail() {
106 const { pointCursor } = usePointCursor();
103 const { pointCursor } = usePointCursor();
107 const point = need.point(pointCursor);
104 const point = need.point(pointCursor);
108 const { getHasReceived, sendMail } = useMailer();
105 const { getHasReceived, sendMail } = useMailer();
106+ const { gasPrice } = useSuggestedGasPrice(networkType);
110 const cachedEmails = useRef([]);
108 const cachedEmails = useRef([]);
@@ -245,7 +243,7 @@ export default function InviteEmail() {
245 nonce: nonce + i,
243 nonce: nonce + i,
246 // TODO: ^ make a useTransactionSigner to encapsulate this logic
244 // TODO: ^ make a useTransactionSigner to encapsulate this logic
247 txn: inviteTx,
245 txn: inviteTx,
248− gasPrice: DEFAULT_GAS_PRICE_GWEI.toString(),
246+ gasPrice: gasPrice.toString(),
249 gasLimit: GAS_LIMIT.toString(),
247 gasLimit: GAS_LIMIT.toString(),
@@ -278,6 +276,7 @@ export default function InviteEmail() {
278 walletType,
276 walletType,
279 walletHdPath,
277 walletHdPath,
280 networkType,
278 networkType,
281 addInvite,
280 addInvite,
@@ -295,7 +294,7 @@ export default function InviteEmail() {
297 _wallet.address,
296 _wallet.address,
298− INVITE_COST * emails.length,
297+ toWei((gasPrice * GAS_LIMIT * emails.length).toString(), 'gwei'),
299 emails.map(email => invites[email].rawTx),
298 emails.map(email => invites[email].rawTx),
300 (address, minBalance, balance) =>
299 (address, minBalance, balance) =>
301 setNeedFunds({ address, minBalance, balance }),
300 setNeedFunds({ address, minBalance, balance }),
@@ -361,7 +360,16 @@ export default function InviteEmail() {
361 if (errorString !== '') {
360 if (errorString !== '') {
362 throw new Error(errorString);
361 throw new Error(errorString);
364− }, [web3, addReceipt, clearReceipts, invites, point, wallet, sendMail]);
363+ }, [
366 const onSubmit = useCallback(
374 const onSubmit = useCallback(
367 async values => {
375 async values => {