add compute fee
This commit is contained in:
@@ -66,7 +66,9 @@ function SharedData() {
|
|||||||
BigInt(store.accountInfo?.sequence?.nonce || 0),
|
BigInt(store.accountInfo?.sequence?.nonce || 0),
|
||||||
store.pubKey,
|
store.pubKey,
|
||||||
store.nodeInfo.networkIdentifier,
|
store.nodeInfo.networkIdentifier,
|
||||||
store.passPhrase
|
store.passPhrase,
|
||||||
|
store.nodeInfo?.genesisConfig?.minFeePerByte,
|
||||||
|
store.nodeInfo?.genesisConfig?.baseFees
|
||||||
);
|
);
|
||||||
|
|
||||||
const signedTx = builder.validate(
|
const signedTx = builder.validate(
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
onBecomeObserved,
|
onBecomeObserved,
|
||||||
onBecomeUnobserved,
|
onBecomeUnobserved,
|
||||||
} from 'mobx';
|
} from 'mobx';
|
||||||
import { cryptography } from '@liskhq/lisk-client';
|
import { cryptography, transactions } from '@liskhq/lisk-client';
|
||||||
import { passphrase } from '@liskhq/lisk-client';
|
import { passphrase } from '@liskhq/lisk-client';
|
||||||
import { getNodeInfo } from '../api/node';
|
import { getNodeInfo } from '../api/node';
|
||||||
import { fetchWrapper } from '../shared/fetchWrapper';
|
import { fetchWrapper } from '../shared/fetchWrapper';
|
||||||
@@ -210,7 +210,9 @@ class Store {
|
|||||||
BigInt(this.accountInfo?.sequence?.nonce || 0),
|
BigInt(this.accountInfo?.sequence?.nonce || 0),
|
||||||
this.addressAndPubKey.publicKey,
|
this.addressAndPubKey.publicKey,
|
||||||
this.nodeInfo.networkIdentifier,
|
this.nodeInfo.networkIdentifier,
|
||||||
this.passPhrase
|
this.passPhrase,
|
||||||
|
this.nodeInfo?.genesisConfig?.minFeePerByte,
|
||||||
|
this.nodeInfo?.genesisConfig?.baseFees
|
||||||
);
|
);
|
||||||
|
|
||||||
let signedTx = null;
|
let signedTx = null;
|
||||||
@@ -232,7 +234,9 @@ class Store {
|
|||||||
BigInt(this.accountInfo?.sequence?.nonce || 0),
|
BigInt(this.accountInfo?.sequence?.nonce || 0),
|
||||||
this.addressAndPubKey.publicKey,
|
this.addressAndPubKey.publicKey,
|
||||||
this.nodeInfo.networkIdentifier,
|
this.nodeInfo.networkIdentifier,
|
||||||
this.passPhrase
|
this.passPhrase,
|
||||||
|
this.nodeInfo?.genesisConfig?.minFeePerByte,
|
||||||
|
this.nodeInfo?.genesisConfig?.baseFees
|
||||||
);
|
);
|
||||||
|
|
||||||
const signedTx = builder.vote(delegateAddress, amount);
|
const signedTx = builder.vote(delegateAddress, amount);
|
||||||
@@ -251,7 +255,9 @@ class Store {
|
|||||||
BigInt(this.accountInfo?.sequence?.nonce || 0),
|
BigInt(this.accountInfo?.sequence?.nonce || 0),
|
||||||
this.addressAndPubKey.publicKey,
|
this.addressAndPubKey.publicKey,
|
||||||
this.nodeInfo.networkIdentifier,
|
this.nodeInfo.networkIdentifier,
|
||||||
this.passPhrase
|
this.passPhrase,
|
||||||
|
this.nodeInfo?.genesisConfig?.minFeePerByte,
|
||||||
|
this.nodeInfo?.genesisConfig?.baseFees
|
||||||
);
|
);
|
||||||
|
|
||||||
const unlockObjects = this.accountLockedVotesCanReturn[delegateAddress];
|
const unlockObjects = this.accountLockedVotesCanReturn[delegateAddress];
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ export const generateTransaction = (
|
|||||||
senderPublicKey = '',
|
senderPublicKey = '',
|
||||||
networkIdentifier = '',
|
networkIdentifier = '',
|
||||||
passPhrase = '',
|
passPhrase = '',
|
||||||
fee = BigInt(500000)
|
minFeePerByte = 0,
|
||||||
|
baseFees = []
|
||||||
) => {
|
) => {
|
||||||
return {
|
return {
|
||||||
update: (features) =>
|
update: (features) =>
|
||||||
@@ -166,7 +167,8 @@ export const generateTransaction = (
|
|||||||
senderPublicKey,
|
senderPublicKey,
|
||||||
networkIdentifier,
|
networkIdentifier,
|
||||||
passPhrase,
|
passPhrase,
|
||||||
fee
|
minFeePerByte,
|
||||||
|
baseFees
|
||||||
),
|
),
|
||||||
remove: (features) =>
|
remove: (features) =>
|
||||||
generateRemoveTransaction(
|
generateRemoveTransaction(
|
||||||
@@ -175,7 +177,8 @@ export const generateTransaction = (
|
|||||||
senderPublicKey,
|
senderPublicKey,
|
||||||
networkIdentifier,
|
networkIdentifier,
|
||||||
passPhrase,
|
passPhrase,
|
||||||
fee
|
minFeePerByte,
|
||||||
|
baseFees
|
||||||
),
|
),
|
||||||
validate: (features, recipientAddress) =>
|
validate: (features, recipientAddress) =>
|
||||||
generateValidateTransaction(
|
generateValidateTransaction(
|
||||||
@@ -184,7 +187,8 @@ export const generateTransaction = (
|
|||||||
senderPublicKey,
|
senderPublicKey,
|
||||||
networkIdentifier,
|
networkIdentifier,
|
||||||
passPhrase,
|
passPhrase,
|
||||||
fee,
|
minFeePerByte,
|
||||||
|
baseFees,
|
||||||
recipientAddress
|
recipientAddress
|
||||||
),
|
),
|
||||||
vote: (delegateAddress, amount) =>
|
vote: (delegateAddress, amount) =>
|
||||||
@@ -193,7 +197,8 @@ export const generateTransaction = (
|
|||||||
senderPublicKey,
|
senderPublicKey,
|
||||||
networkIdentifier,
|
networkIdentifier,
|
||||||
passPhrase,
|
passPhrase,
|
||||||
fee,
|
minFeePerByte,
|
||||||
|
baseFees,
|
||||||
delegateAddress,
|
delegateAddress,
|
||||||
amount
|
amount
|
||||||
),
|
),
|
||||||
@@ -203,7 +208,8 @@ export const generateTransaction = (
|
|||||||
senderPublicKey,
|
senderPublicKey,
|
||||||
networkIdentifier,
|
networkIdentifier,
|
||||||
passPhrase,
|
passPhrase,
|
||||||
fee,
|
minFeePerByte,
|
||||||
|
baseFees,
|
||||||
delegateAddress,
|
delegateAddress,
|
||||||
unlockObjects
|
unlockObjects
|
||||||
),
|
),
|
||||||
@@ -216,19 +222,25 @@ export const generateSetTransaction = (
|
|||||||
senderPublicKey = '',
|
senderPublicKey = '',
|
||||||
networkIdentifier = '',
|
networkIdentifier = '',
|
||||||
passPhrase = '',
|
passPhrase = '',
|
||||||
fee = BigInt(500000)
|
minFeePerByte = 0,
|
||||||
|
baseFees = []
|
||||||
) => {
|
) => {
|
||||||
const tx = {
|
const tx = {
|
||||||
moduleID: 1001,
|
moduleID: 1001,
|
||||||
assetID: 1,
|
assetID: 1,
|
||||||
nonce,
|
nonce,
|
||||||
senderPublicKey,
|
senderPublicKey,
|
||||||
fee,
|
|
||||||
asset: {
|
asset: {
|
||||||
features,
|
features,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tx.fee = transactions.computeMinFee(setFeatureAssetSchema, tx, {
|
||||||
|
minFeePerByte,
|
||||||
|
baseFees,
|
||||||
|
numberOfSignatures: 1,
|
||||||
|
});
|
||||||
|
|
||||||
if (features.length === 0) return;
|
if (features.length === 0) return;
|
||||||
|
|
||||||
const signedTx = transactions.signTransaction(
|
const signedTx = transactions.signTransaction(
|
||||||
@@ -256,18 +268,24 @@ export const generateRemoveTransaction = (
|
|||||||
senderPublicKey = '',
|
senderPublicKey = '',
|
||||||
networkIdentifier = '',
|
networkIdentifier = '',
|
||||||
passPhrase = '',
|
passPhrase = '',
|
||||||
fee = BigInt(500000)
|
minFeePerByte = 0,
|
||||||
|
baseFees = []
|
||||||
) => {
|
) => {
|
||||||
const tx = {
|
const tx = {
|
||||||
moduleID: 1001,
|
moduleID: 1001,
|
||||||
assetID: 2,
|
assetID: 2,
|
||||||
nonce,
|
nonce,
|
||||||
senderPublicKey,
|
senderPublicKey,
|
||||||
fee,
|
|
||||||
asset: {
|
asset: {
|
||||||
features,
|
features,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tx.fee = transactions.computeMinFee(removeFeatureAssetSchema, tx, {
|
||||||
|
minFeePerByte,
|
||||||
|
baseFees,
|
||||||
|
numberOfSignatures: 1,
|
||||||
|
});
|
||||||
const signedTx = transactions.signTransaction(
|
const signedTx = transactions.signTransaction(
|
||||||
removeFeatureAssetSchema,
|
removeFeatureAssetSchema,
|
||||||
tx,
|
tx,
|
||||||
@@ -289,7 +307,8 @@ const generateValidateTransaction = (
|
|||||||
senderPublicKey = '',
|
senderPublicKey = '',
|
||||||
networkIdentifier = '',
|
networkIdentifier = '',
|
||||||
passPhrase = '',
|
passPhrase = '',
|
||||||
fee = BigInt(500000),
|
minFeePerByte = 0,
|
||||||
|
baseFees = [],
|
||||||
recipientAddress = ''
|
recipientAddress = ''
|
||||||
) => {
|
) => {
|
||||||
const tx = {
|
const tx = {
|
||||||
@@ -297,13 +316,18 @@ const generateValidateTransaction = (
|
|||||||
assetID: 11,
|
assetID: 11,
|
||||||
nonce,
|
nonce,
|
||||||
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
||||||
fee,
|
|
||||||
asset: {
|
asset: {
|
||||||
features,
|
features,
|
||||||
recipientAddress: Buffer.from(recipientAddress, 'hex'),
|
recipientAddress: Buffer.from(recipientAddress, 'hex'),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tx.fee = transactions.computeMinFee(validateFeatureAssetSchema, tx, {
|
||||||
|
minFeePerByte,
|
||||||
|
baseFees,
|
||||||
|
numberOfSignatures: 1,
|
||||||
|
});
|
||||||
|
|
||||||
if (features.length === 0) return;
|
if (features.length === 0) return;
|
||||||
|
|
||||||
const signedTx = transactions.signTransaction(
|
const signedTx = transactions.signTransaction(
|
||||||
@@ -332,7 +356,8 @@ const generateVoteTransaction = (
|
|||||||
senderPublicKey = '',
|
senderPublicKey = '',
|
||||||
networkIdentifier = '',
|
networkIdentifier = '',
|
||||||
passPhrase = '',
|
passPhrase = '',
|
||||||
fee = BigInt(500000),
|
minFeePerByte = 0,
|
||||||
|
baseFees = [],
|
||||||
delegateAddress = '',
|
delegateAddress = '',
|
||||||
amount = 0n
|
amount = 0n
|
||||||
) => {
|
) => {
|
||||||
@@ -341,7 +366,6 @@ const generateVoteTransaction = (
|
|||||||
assetID: 1,
|
assetID: 1,
|
||||||
nonce,
|
nonce,
|
||||||
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
||||||
fee,
|
|
||||||
asset: {
|
asset: {
|
||||||
votes: [
|
votes: [
|
||||||
{
|
{
|
||||||
@@ -352,6 +376,12 @@ const generateVoteTransaction = (
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tx.fee = transactions.computeMinFee(voteDelegateAssetSchema, tx, {
|
||||||
|
minFeePerByte,
|
||||||
|
baseFees,
|
||||||
|
numberOfSignatures: 1,
|
||||||
|
});
|
||||||
|
|
||||||
const signedTx = transactions.signTransaction(
|
const signedTx = transactions.signTransaction(
|
||||||
voteDelegateAssetSchema,
|
voteDelegateAssetSchema,
|
||||||
tx,
|
tx,
|
||||||
@@ -376,7 +406,8 @@ const generateUnlockTransaction = (
|
|||||||
senderPublicKey = '',
|
senderPublicKey = '',
|
||||||
networkIdentifier = '',
|
networkIdentifier = '',
|
||||||
passPhrase = '',
|
passPhrase = '',
|
||||||
fee = BigInt(500000),
|
minFeePerByte = 0,
|
||||||
|
baseFees = [],
|
||||||
delegateAddress = '',
|
delegateAddress = '',
|
||||||
unlockObjects = []
|
unlockObjects = []
|
||||||
) => {
|
) => {
|
||||||
@@ -385,7 +416,6 @@ const generateUnlockTransaction = (
|
|||||||
assetID: 2,
|
assetID: 2,
|
||||||
nonce,
|
nonce,
|
||||||
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
||||||
fee,
|
|
||||||
asset: {
|
asset: {
|
||||||
unlockObjects: unlockObjects.map((e) => ({
|
unlockObjects: unlockObjects.map((e) => ({
|
||||||
delegateAddress: Buffer.from(delegateAddress, 'hex'),
|
delegateAddress: Buffer.from(delegateAddress, 'hex'),
|
||||||
@@ -395,6 +425,12 @@ const generateUnlockTransaction = (
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tx.fee = transactions.computeMinFee(unlockDelegateAssetSchema, tx, {
|
||||||
|
minFeePerByte,
|
||||||
|
baseFees,
|
||||||
|
numberOfSignatures: 1,
|
||||||
|
});
|
||||||
|
|
||||||
const signedTx = transactions.signTransaction(
|
const signedTx = transactions.signTransaction(
|
||||||
unlockDelegateAssetSchema,
|
unlockDelegateAssetSchema,
|
||||||
tx,
|
tx,
|
||||||
|
|||||||
Reference in New Issue
Block a user