Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import ethUtil from 'ethereumjs-util'; | ||
import {Buffer} from 'safe-buffer'; | ||
|
||
class MinterTxDataDeclareCandidacy { | ||
constructor(data) { | ||
data = data || {}; | ||
// Define Properties | ||
const fields = [ | ||
{ | ||
name: 'pubKey', | ||
allowZero: true, | ||
default: new Buffer([]), | ||
}, | ||
{ | ||
name: 'rewardAddress', | ||
allowZero: true, | ||
length: 20, | ||
default: new Buffer([]), | ||
}, | ||
{ | ||
name: 'ownerAddress', | ||
allowZero: true, | ||
length: 20, | ||
default: new Buffer([]), | ||
}]; | ||
|
||
/** | ||
* Returns the rlp encoding of the transaction | ||
* @method serialize | ||
* @return {Buffer} | ||
* @memberof Transaction | ||
* @name serialize | ||
*/ | ||
// attached serialize | ||
ethUtil.defineProperties(this, fields, data); | ||
} | ||
} | ||
|
||
export default MinterTxDataDeclareCandidacy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {toBuffer} from 'minterjs-util'; | ||
import {MinterTxDataEditCandidate} from '~/src'; | ||
import decodeToArray from '../decode-to-array'; | ||
|
||
describe('MinterTxDataDeclareCandidacy', () => { | ||
test('rlp encoded fields', () => { | ||
const serializedTxData = (new MinterTxDataEditCandidate({ | ||
pubKey: toBuffer('Mpf9e036839a29f7fba2d5394bd489eda927ccb95acc99e506e688e4888082b3a3'), | ||
rewardAddress: toBuffer('Mx7633980c000139dd3bd24a3f54e06474fa941e16'), | ||
ownerAddress: toBuffer('Mx7633980c000139dd3bd24a3f54e06474fa941e16'), | ||
})).serialize(); | ||
|
||
expect(decodeToArray(serializedTxData)) | ||
.toEqual([ | ||
[249, 224, 54, 131, 154, 41, 247, 251, 162, 213, 57, 75, 212, 137, 237, 169, 39, 204, 185, 90, 204, 153, 229, 6, 230, 136, 228, 136, 128, 130, 179, 163], | ||
[118, 51, 152, 12, 0, 1, 57, 221, 59, 210, 74, 63, 84, 224, 100, 116, 250, 148, 30, 22], | ||
[118, 51, 152, 12, 0, 1, 57, 221, 59, 210, 74, 63, 84, 224, 100, 116, 250, 148, 30, 22], | ||
]); | ||
}); | ||
}); |