@cardano-sdk/governance 0.2.0-nightly.13 → 0.2.0-nightly.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/cip36.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CML, coreToCml, util } from '@cardano-sdk/core';
|
|
2
2
|
import { util as keyManagementUtil } from '@cardano-sdk/key-management';
|
|
3
3
|
import { usingAutoFree } from '@cardano-sdk/util';
|
|
4
4
|
import blake2b from 'blake2b';
|
|
@@ -19,18 +19,18 @@ export var VotingPurpose;
|
|
|
19
19
|
})(VotingPurpose || (VotingPurpose = {}));
|
|
20
20
|
export const metadataBuilder = {
|
|
21
21
|
buildVotingRegistration({ delegations, stakeKey, purpose, rewardAccount, nonce = Date.now() }) {
|
|
22
|
-
const
|
|
22
|
+
const cmlRewardAddress = CML.Address.from_bech32(rewardAccount.toString());
|
|
23
23
|
const votingRegistration = new Map([
|
|
24
24
|
[1n, delegations.map(({ votingKey, weight }) => [Buffer.from(votingKey, 'hex'), BigInt(weight)])],
|
|
25
25
|
[2n, Buffer.from(stakeKey, 'hex')],
|
|
26
|
-
[3n, Buffer.from(
|
|
26
|
+
[3n, Buffer.from(cmlRewardAddress.to_bytes())],
|
|
27
27
|
[4n, BigInt(nonce)],
|
|
28
28
|
[5n, BigInt(purpose)]
|
|
29
29
|
]);
|
|
30
30
|
return new Map([[BigInt(MetadataLabel.DATA), votingRegistration]]);
|
|
31
31
|
},
|
|
32
32
|
async signVotingRegistration(votingRegistrationMetadata, stakeKeyBlobSigner) {
|
|
33
|
-
const votingRegistrationMetadataBytes = usingAutoFree((scope) =>
|
|
33
|
+
const votingRegistrationMetadataBytes = usingAutoFree((scope) => coreToCml.txMetadata(scope, votingRegistrationMetadata).to_bytes());
|
|
34
34
|
const hashedMetadata = blake2b(256 / 8)
|
|
35
35
|
.update(votingRegistrationMetadataBytes)
|
|
36
36
|
.digest('binary');
|