Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
],
"private": true,
"dependencies": {
"@polkadot/api": "10.11.2",
"@polkadot/types": "10.11.2",
"@polkadot/types-codec": "10.11.2",
"@polkadot/api": "11.0.2",
"@polkadot/types": "11.0.2",
"@polkadot/types-codec": "11.0.2",
"@polkadot/util": "12.6.2",
"@substrate/txwrapper-core": "7.2.0",
"@substrate/txwrapper-polkadot": "7.2.0",
"@substrate/txwrapper-core": "7.4.0",
"@substrate/txwrapper-polkadot": "7.4.0",
"body-parser": "1.20.2",
"camelcase": "6.3.0",
"commander": "^11.0.0",
Expand Down
42 changes: 21 additions & 21 deletions server/src/helpers/construct-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface TxParams {
tip: number;
specVersion: number;
transactionVersion: number;
disableKeepAlive: boolean,
disableKeepAlive: boolean;
networkIdent: GearNetworkIdentifier;
}

Expand All @@ -36,28 +36,28 @@ export function constructTx({
}: TxParams) {
const args = { dest: { id: toAddress }, value };
const info = {
address: deriveAddress(fromAddress, ss58Format),
blockHash,
blockNumber,
eraPeriod,
nonce,
tip,
genesisHash: genesis,
metadataRpc: metadataRpc,
specVersion,
transactionVersion,
};
address: deriveAddress(fromAddress, ss58Format),
blockHash,
blockNumber,
eraPeriod,
nonce,
tip,
genesisHash: genesis,
metadataRpc: metadataRpc,
specVersion,
transactionVersion,
};
const options = {
metadataRpc: metadataRpc,
registry,
};
metadataRpc: metadataRpc,
registry,
};
const unsigned = disableKeepAlive
? methods.balances.transfer(args, info, options)
? methods.balances.transferAllowDeath(args, info, options)
: methods.balances.transferKeepAlive(args, info, options);

const loggedUnsignedTx = unsigned;
loggedUnsignedTx.metadataRpc = "0x...truncated...";
logger.info('[constructTx] Generated unsigned tx', { tx: loggedUnsignedTx })
loggedUnsignedTx.metadataRpc = '0x...truncated...';
logger.info('[constructTx] Generated unsigned tx', { tx: loggedUnsignedTx });

const { method, version, address } = unsigned;
const unsignedTx = stringToHex(JSON.stringify({ method, version, address, nonce, era: unsigned.era }));
Expand All @@ -78,7 +78,7 @@ export function constructSignedTx(unsigned: any, signature: string, { registry }
header[0] = 0;
const sigWithHeader = u8aConcat(header, sigU8a);
const tx = JSON.parse(hexToString(unsigned));

const extrinsic = registry.createType('Extrinsic', tx, { version: tx.version });
extrinsic.addSignature(tx.address, sigWithHeader, tx);
return extrinsic.toHex();
Expand All @@ -93,12 +93,12 @@ export function parseTransaction(
? decode(transaction, { registry, metadataRpc })
: decode(JSON.parse(hexToString(transaction)), { registry, metadataRpc });

tx.metadataRpc = "0x...truncated...";
tx.metadataRpc = '0x...truncated...';

logger.info(`[parseTransaction] Decoded transaction`, {
signed: signed,
encoded_tx: transaction,
decoded_tx: tx
decoded_tx: tx,
});

const source = tx.address;
Expand Down
9 changes: 7 additions & 2 deletions server/src/helpers/extrinsics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { AnyTuple } from '@polkadot/types-codec/types';

import { TxMethodLC, TxSectionLC } from '../types';

const TRANSFER_METHODS: string[] = [
TxMethodLC.TRANSFER,
TxMethodLC.TRANSFER_KEEP_ALIVE,
TxMethodLC.TRANSFER_ALLOW_DEATH,
];
Comment thread
osipov-mit marked this conversation as resolved.

export const isTransferTx = ({ method: { method, section } }: GenericExtrinsic<AnyTuple>) =>
section.toLowerCase() === TxSectionLC.BALANCES &&
(method.toLowerCase() === TxMethodLC.TRANSFER || method.toLowerCase() === TxMethodLC.TRANSFER_KEEP_ALIVE);
section.toLowerCase() === TxSectionLC.BALANCES && TRANSFER_METHODS.includes(method.toLocaleLowerCase());
6 changes: 4 additions & 2 deletions server/src/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum EventMethodsLC {
TRANSFER = 'transfer',
BALANCE_SET = 'balanceset',
TRANSACTION_FEE_PAID = 'transactionfeepaid',
DUST_LOST = 'dustlost'
DUST_LOST = 'dustlost',
}

export enum EventSectionLC {
Expand All @@ -38,7 +38,7 @@ export enum OpType {
RESERVE_REPATRIATED = 'ReserveRepatriated',
BALANCE_SET = 'BalanceSet',
TRANSACTION_FEE_PAID = 'TransactionFeePaid',
DUST_LOST = 'DustLost'
DUST_LOST = 'DustLost',
}

export const opTypes = Object.values(OpType);
Expand All @@ -50,4 +50,6 @@ export enum TxSectionLC {
export enum TxMethodLC {
TRANSFER = 'transfer',
TRANSFER_KEEP_ALIVE = 'transferkeepalive',
TRANSFER_ALLOW_DEATH = 'transferallowdeath',
TRANSFER_ALL = 'transferall',
}
Loading