on master help sign in
Define transaction gas limit constants
5d25c4aFang
src/lib/constants.js+9
@@ -13,6 +13,14 @@ const GALAXY_ENTROPY_BITS = 384;
13
13
14const SEED_ENTROPY_BITS = 128;
14const SEED_ENTROPY_BITS = 128;
15
15
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+
16// TODO: this is walletgen-ui specific, move into a wallet router later
24// TODO: this is walletgen-ui specific, move into a wallet router later
17const GEN_STATES = {
25const GEN_STATES = {
18 ENY_NOSTART: Symbol('ENY_NOSTART'),
26 ENY_NOSTART: Symbol('ENY_NOSTART'),
@@ -45,6 +53,7 @@ const PROFILE_STATES = {
45};
53};
46
54
47export {
55export {
56+ GAS_LIMITS,
48 GEN_STATES,
57 GEN_STATES,
49 BUTTON_STATES,
58 BUTTON_STATES,
50 PROFILE_STATES,
59 PROFILE_STATES,
src/lib/invite.js+7−6
@@ -12,6 +12,7 @@ import saveAs from 'file-saver';
12import { sendSignedTransaction, hexify } from './txn';
12import { sendSignedTransaction, hexify } from './txn';
13import { attemptNetworkSeedDerivation } from './keys';
13import { attemptNetworkSeedDerivation } from './keys';
14import { addHexPrefix, WALLET_TYPES } from './wallet';
14import { addHexPrefix, WALLET_TYPES } from './wallet';
15+import { GAS_LIMITS } from './constants';
15
16
16const INVITE_STAGES = {
17const INVITE_STAGES = {
17 INVITE_LOGIN: 'invite login',
18 INVITE_LOGIN: 'invite login',
@@ -131,7 +132,7 @@ async function claimPointFromInvite({
131 inviteAddress,
132 inviteAddress,
132 false
133 false
133 );
134 );
134− transferTmpTx.gas = 500000; //TODO can maybe be lower?
135+ transferTmpTx.gas = GAS_LIMITS.TRANSFER;
135
136
136 // configure networking public keys
137 // configure networking public keys
137
138
@@ -160,7 +161,7 @@ async function claimPointFromInvite({
160 1,
161 1,
161 false
162 false
162 );
163 );
163− keysTx.gas = 150000;
164+ keysTx.gas = GAS_LIMITS.CONFIGURE_KEYS;
164
165
165 // configure management proxy
166 // configure management proxy
166
167
@@ -169,7 +170,7 @@ async function claimPointFromInvite({
169 point,
170 point,
170 wallet.management.keys.address
171 wallet.management.keys.address
171 );
172 );
172− managementTx.gas = 200000;
173+ managementTx.gas = GAS_LIMITS.SET_PROXY;
173
174
174 // set spawn & voting proxies situationally
175 // set spawn & voting proxies situationally
175
176
@@ -182,7 +183,7 @@ async function claimPointFromInvite({
182 point,
183 point,
183 wallet.spawn.keys.address
184 wallet.spawn.keys.address
184 );
185 );
185− spawnTx.gas = 200000;
186+ spawnTx.gas = GAS_LIMITS.SET_PROXY;
186 txs.push(spawnTx);
187 txs.push(spawnTx);
187
188
188 if (
189 if (
@@ -193,7 +194,7 @@ async function claimPointFromInvite({
193 point,
194 point,
194 wallet.voting.keys.address
195 wallet.voting.keys.address
195 );
196 );
196− votingTx.gas = 200000;
197+ votingTx.gas = GAS_LIMITS.SET_PROXY;
197 txs.push(votingTx);
198 txs.push(votingTx);
198 }
199 }
199 }
200 }
@@ -206,7 +207,7 @@ async function claimPointFromInvite({
206 wallet.ownership.keys.address,
207 wallet.ownership.keys.address,
207 false
208 false
208 );
209 );
209− transferFinalTx.gas = 500000; //TODO can maybe be lower?
210+ transferFinalTx.gas = GAS_LIMITS.TRANSFER;
210 txs.push(transferFinalTx);
211 txs.push(transferFinalTx);
211
212
212 //
213 //
src/views/Invite/InviteEmail.js+2−2
@@ -35,7 +35,7 @@ import LoadableButton from 'components/LoadableButton';
35import useArray from 'lib/useArray';
35import useArray from 'lib/useArray';
36import useForm from 'indigo-react/lib/useForm';
36import useForm from 'indigo-react/lib/useForm';
37import { buildEmailInputConfig } from 'components/Inputs';
37import { buildEmailInputConfig } from 'components/Inputs';
38−import { MIN_PLANET } from 'lib/constants';
38+import { MIN_PLANET, GAS_LIMITS } from 'lib/constants';
39import Highlighted from 'components/Highlighted';
39import Highlighted from 'components/Highlighted';
40import { useNetwork } from 'store/network';
40import { useNetwork } from 'store/network';
41import { usePointCache } from 'store/pointCache';
41import { usePointCache } from 'store/pointCache';
@@ -45,7 +45,7 @@ import pluralize from 'lib/pluralize';
45import useMailer from 'lib/useMailer';
45import useMailer from 'lib/useMailer';
46
46
47const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
47const GAS_PRICE_GWEI = 20; // we pay the premium for faster ux
48−const GAS_LIMIT = 400000;
48+const GAS_LIMIT = GAS_LIMITS.GIFT_PLANET;
49const INVITE_COST = toWei((GAS_PRICE_GWEI * GAS_LIMIT).toString(), 'gwei');
49const INVITE_COST = toWei((GAS_PRICE_GWEI * GAS_LIMIT).toString(), 'gwei');
50const HAS_RECEIVED_TEXT = 'This email has already received an invite.';
50const HAS_RECEIVED_TEXT = 'This email has already received an invite.';
51
51