Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hive-js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
hive
hive-js
Commits
28b10397
Commit
28b10397
authored
Jun 11, 2020
by
Mahdi Yari
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hf24-chainid-swap' into 'master'
Hf24 chainid swap Closes
#7
See merge request
!5
parents
89a3d619
379a3d81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
15 deletions
+28
-15
config.json
config.json
+1
-1
package.json
package.json
+1
-1
src/broadcast/index.js
src/broadcast/index.js
+26
-13
No files found.
config.json
View file @
28b10397
...
...
@@ -6,7 +6,7 @@
"dev_uri"
:
""
,
"stage_uri"
:
""
,
"address_prefix"
:
"STM"
,
"chain_id"
:
"
00000000
00000000000000000000000000000000000000000000000000000000"
,
"chain_id"
:
"
beeab0de
00000000000000000000000000000000000000000000000000000000"
,
"alternative_api_endpoints"
:
[
"https://api.hive.blog"
,
"https://anyx.io"
],
"failover_threshold"
:
3
}
package.json
View file @
28b10397
{
"name"
:
"@hiveio/hive-js"
,
"version"
:
"0.
1
.0"
,
"version"
:
"0.
8
.0"
,
"description"
:
"Hive.js the JavaScript API for Hive blockchain"
,
"main"
:
"lib/index.js"
,
"scripts"
:
{
...
...
src/broadcast/index.js
View file @
28b10397
...
...
@@ -8,6 +8,11 @@ import steemApi from '../api';
import
steemAuth
from
'
../auth
'
;
import
{
camelCase
}
from
'
../utils
'
;
const
config
=
require
(
'
../config
'
)
const
HF23_CHAIN_ID
=
'
0000000000000000000000000000000000000000000000000000000000000000
'
const
HF24_CHAIN_ID
=
'
beeab0de00000000000000000000000000000000000000000000000000000000
'
const
debug
=
newDebug
(
'
steem:broadcast
'
);
const
noop
=
function
()
{}
const
formatter
=
formatterFactory
(
steemApi
);
...
...
@@ -51,19 +56,27 @@ steemBroadcast._prepareTransaction = function steemBroadcast$_prepareTransaction
const
propertiesP
=
steemApi
.
getDynamicGlobalPropertiesAsync
();
return
propertiesP
.
then
((
properties
)
=>
{
// Set defaults on the transaction
const
chainDate
=
new
Date
(
properties
.
time
+
'
Z
'
);
const
refBlockNum
=
(
properties
.
last_irreversible_block_num
-
1
)
&
0xFFFF
;
return
steemApi
.
getBlockHeaderAsync
(
properties
.
last_irreversible_block_num
).
then
((
block
)
=>
{
const
headBlockId
=
block
?
block
.
previous
:
'
0000000000000000000000000000000000000000
'
;
return
Object
.
assign
({
ref_block_num
:
refBlockNum
,
ref_block_prefix
:
new
Buffer
(
headBlockId
,
'
hex
'
).
readUInt32LE
(
4
),
expiration
:
new
Date
(
chainDate
.
getTime
()
+
600
*
1000
),
},
tx
);
const
hfVersion
=
steemApi
.
getHardforkVersionAsync
();
return
hfVersion
.
then
(
HFV
=>
{
if
(
HFV
==
'
0.23.0
'
)
{
config
.
set
(
'
chain_id
'
,
HF23_CHAIN_ID
)
}
else
{
config
.
set
(
'
chain_id
'
,
HF24_CHAIN_ID
)
}
// Set defaults on the transaction
const
chainDate
=
new
Date
(
properties
.
time
+
'
Z
'
);
const
refBlockNum
=
(
properties
.
last_irreversible_block_num
-
1
)
&
0xFFFF
;
return
steemApi
.
getBlockHeaderAsync
(
properties
.
last_irreversible_block_num
).
then
((
block
)
=>
{
const
headBlockId
=
block
?
block
.
previous
:
'
0000000000000000000000000000000000000000
'
;
return
Object
.
assign
({
ref_block_num
:
refBlockNum
,
ref_block_prefix
:
new
Buffer
(
headBlockId
,
'
hex
'
).
readUInt32LE
(
4
),
expiration
:
new
Date
(
chainDate
.
getTime
()
+
600
*
1000
),
},
tx
);
});
});
});
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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