2019-10-21 15:57:28 +03:00
|
|
|
function strip0x(input) {
|
|
|
|
return input.replace(/^0x/, '')
|
|
|
|
}
|
|
|
|
|
|
|
|
function addTxHashToData({ encodedData, transactionHash }) {
|
|
|
|
return encodedData.slice(0, 2) + strip0x(transactionHash) + encodedData.slice(2)
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseAMBMessage(message) {
|
|
|
|
message = strip0x(message)
|
|
|
|
|
2020-05-21 23:29:56 +03:00
|
|
|
const messageId = `0x${message.slice(0, 64)}`
|
2019-10-21 15:57:28 +03:00
|
|
|
const sender = `0x${message.slice(64, 104)}`
|
|
|
|
const executor = `0x${message.slice(104, 144)}`
|
|
|
|
|
|
|
|
return {
|
|
|
|
sender,
|
|
|
|
executor,
|
2020-05-21 23:29:56 +03:00
|
|
|
messageId
|
2019-10-21 15:57:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
addTxHashToData,
|
|
|
|
parseAMBMessage,
|
|
|
|
strip0x
|
|
|
|
}
|