on master help sign in
Define transaction gas limit constants
commit5d25c4a40330e2e4bcff2ce8a6a21926ea15a955 authorFang <git@fang.io> dateWed 3 Jul 2019, 20:04 (7 years ago) parent2253aef
3 files changed+18−8
src/lib/constants.js+9 src/lib/invite.js+7−6 src/views/Invite/InviteEmail.js+2−2
src/lib/constants.js+9
@@ -13,6 +13,14 @@ const GALAXY_ENTROPY_BITS = 384;
1313
1414const SEED_ENTROPY_BITS = 128;
1515
16+//TODO properly research these, move into azimuth-js
17+const GAS_LIMITS = {
18+ TRANSFER: 500000,
19+ CONFIGURE_KEYS: 150000,
20+ SET_PROXY: 200000,
21+ GIFT_PLANET: 400000, //TODO can maybe do 370000, see also commit 8c0ecaaa
22+};
23+
1624// TODO: this is walletgen-ui specific, move into a wallet router later
1725const GEN_STATES = {
1826 ENY_NOSTART: Symbol('ENY_NOSTART'),
@@ -45,6 +53,7 @@ const PROFILE_STATES = {
4553};
4654
4755export {
56+ GAS_LIMITS,
4857 GEN_STATES,
4958 BUTTON_STATES,
5059 PROFILE_STATES,
src/lib/invite.js+7−6
@@ -12,6 +12,7 @@ import saveAs from 'file-saver';
1212import { sendSignedTransaction, hexify } from './txn';
1313import { attemptNetworkSeedDerivation } from './keys';
1414import { addHexPrefix, WALLET_TYPES } from './wallet';
15+import { GAS_LIMITS } from './constants';
1516
1617const INVITE_STAGES = {
1718 INVITE_LOGIN: 'invite login',
@@ -131,7 +132,7 @@ async function claimPointFromInvite({
131132 inviteAddress,
132133 false
133134 );
134− transferTmpTx.gas = 500000; //TODO can maybe be lower?
135+ transferTmpTx.gas = GAS_LIMITS.TRANSFER;
135136
136137 // configure networking public keys
137138
@@ -160,7 +161,7 @@ async function claimPointFromInvite({
160161 1,
161162 false
162163 );
163− keysTx.gas = 150000;
164+ keysTx.gas = GAS_LIMITS.CONFIGURE_KEYS;
164165
165166 // configure management proxy
166167
@@ -169,7 +170,7 @@ async function claimPointFromInvite({
169170 point,
170171 wallet.management.keys.address
171172 );
172− managementTx.gas = 200000;
173+ managementTx.gas = GAS_LIMITS.SET_PROXY;
173174
174175 // set spawn & voting proxies situationally
175176
@@ -182,7 +183,7 @@ async function claimPointFromInvite({
182183 point,
183184 wallet.spawn.keys.address
184185 );
185− spawnTx.gas = 200000;
186+ spawnTx.gas = GAS_LIMITS.SET_PROXY;
186187 txs.push(spawnTx);
187188
188189 if (
@@ -193,7 +194,7 @@ async function claimPointFromInvite({
193194 point,
194195 wallet.voting.keys.address
195196 );
196− votingTx.gas = 200000;
197+ votingTx.gas = GAS_LIMITS.SET_PROXY;
197198 txs.push(votingTx);
198199 }
199200 }
@@ -206,7 +207,7 @@ async function claimPointFromInvite({
206207 wallet.ownership.keys.address,
207208 false
208209 );
209− transferFinalTx.gas = 500000; //TODO can maybe be lower?
210+ transferFinalTx.gas = GAS_LIMITS.TRANSFER;
210211 txs.push(transferFinalTx);
211212
212213 //
src/views/Invite/InviteEmail.js+2−2
@@ -35,7 +35,7 @@ import LoadableButton from 'components/LoadableButton';
3535import useArray from 'lib/useArray';
3636import useForm from 'indigo-react/lib/useForm';
3737import { buildEmailInputConfig } from 'components/Inputs';
38−import { MIN_PLANET } from 'lib/constants';
38+import { MIN_PLANET, GAS_LIMITS } from 'lib/constants';
3939import Highlighted from 'components/Highlighted';
4040import { useNetwork } from 'store/network';
4141import { usePointCache } from 'store/pointCache';
@@ -45,7 +45,7 @@ import pluralize from 'lib/pluralize';
4545import useMailer from 'lib/useMailer';
4646
4747const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
48−const GAS_LIMIT = 400000;
48+const GAS_LIMIT = GAS_LIMITS.GIFT_PLANET;
4949const INVITE_COST = toWei((GAS_PRICE_GWEI * GAS_LIMIT).toString(), 'gwei');
5050const HAS_RECEIVED_TEXT = 'This email has already received an invite.';
5151