Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
txwrapper
Commits
6203cdc4
Commit
6203cdc4
authored
Dec 02, 2019
by
Amaury Martiny
Browse files
Configurable era
parent
0744bf01
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/balanceTransfer.ts
View file @
6203cdc4
...
...
@@ -57,12 +57,16 @@ export interface TxInfo {
* The recipient address, ss-58 encoded
*/
to
:
string
;
/**
* The amount of time (in minutes) the transaction is valid for. Will be translated
* into a mortal era
*/
validityPeriod
:
number
;
}
//
Calculting Era. The d
ef
a
ul
t here allows for 240min mortal e
ra
s
.
//
Us
eful
constants for calculting an E
ra.
const
BLOCKTIME
=
6
;
const
ONE_MINUTE
=
60
/
BLOCKTIME
;
const
DEFAULT_MORTAL_LENGTH
=
240
*
ONE_MINUTE
;
const
ONE_SECOND
=
1
/
BLOCKTIME
;
/**
* Construct a balance transfer transaction offline. Transactions can be
...
...
@@ -83,7 +87,7 @@ export function balanceTransfer(info: TxInfo): UnsignedTransaction {
blockNumber
:
createType
(
registry
,
'
BlockNumber
'
,
info
.
blockNumber
).
toHex
(),
era
:
createType
(
registry
,
'
ExtrinsicEra
'
,
{
current
:
info
.
blockNumber
,
period
:
DEFAULT_MORTAL_LENGTH
period
:
ONE_SECOND
*
info
.
validityPeriod
}).
toHex
(),
genesisHash
:
info
.
genesisHash
,
metadataRpc
:
info
.
metadataRpc
,
...
...
src/util/testUtil.ts
View file @
6203cdc4
...
...
@@ -21,7 +21,8 @@ export const TEST_TX_INFO: TxInfo = {
nonce
:
2
,
specVersion
:
1019
,
tip
:
0
,
to
:
'
Fy2rsYCoowQBtuFXqLE65ehAY9T6KWcGiNCQAyPDCkfpm4s
'
to
:
'
Fy2rsYCoowQBtuFXqLE65ehAY9T6KWcGiNCQAyPDCkfpm4s
'
,
validityPeriod
:
240
*
60
};
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment