@argonprotocol/testing 1.4.10-dev.479c016c → 1.4.10-dev.a229760e

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/lib/index.js CHANGED
@@ -1317,10 +1317,14 @@ import {
1317
1317
  } from "@argonprotocol/mainchain";
1318
1318
  import { getAddress as getAddress2, keccak256 } from "viem";
1319
1319
  var {
1320
+ encodeMintingGatewayGlobalIssuanceCouncilRotateTarget,
1320
1321
  encodeMintingGatewayMintingAuthorityActivationTarget,
1321
1322
  encodeMintingGatewayMintingAuthorityDeactivateTarget,
1322
1323
  hashMintingGatewayActivateMintingAuthority,
1323
1324
  hashMintingGatewayGatewayUpdateApproval,
1325
+ hashMintingGatewayGlobalIssuanceCouncil: hashMintingGatewayGlobalIssuanceCouncil2,
1326
+ hashMintingGatewayRotateGlobalIssuanceCouncil,
1327
+ hashMintingGatewayRotateGlobalIssuanceCouncilApproval,
1324
1328
  mintingGatewayAbi,
1325
1329
  MINTING_GATEWAY_UPDATE_KINDS
1326
1330
  } = EvmContracts2;
@@ -1398,7 +1402,8 @@ async function getReadyEthereumGatewayUpdates(client, gatewayClient, options = {
1398
1402
  }
1399
1403
  const update = await buildGatewayUpdate(client, destinationChain, hashContext, queueNonce, {
1400
1404
  entry,
1401
- approvingCouncilHash
1405
+ approvingCouncilHash,
1406
+ councilCache
1402
1407
  });
1403
1408
  candidateUpdates.push(update);
1404
1409
  expectedPreviousApprovalHash = toHexValue(entry.approvalHash);
@@ -1429,7 +1434,42 @@ async function getReadyEthereumGatewayUpdates(client, gatewayClient, options = {
1429
1434
  };
1430
1435
  }
1431
1436
  async function buildGatewayUpdate(client, destinationChain, hashContext, queueNonce, queueItem) {
1432
- const { entry, approvingCouncilHash } = queueItem;
1437
+ const { entry, approvingCouncilHash, councilCache } = queueItem;
1438
+ if (entry.target.isGlobalIssuanceCouncilRotation) {
1439
+ const signatures = getSortedSignatures(entry.signatures);
1440
+ const nextCouncilHash = toHexValue(entry.target.asGlobalIssuanceCouncilRotation);
1441
+ const nextCouncil = await loadCouncilByHash(client, nextCouncilHash, councilCache);
1442
+ const target = {
1443
+ council: councilToSnapshot(nextCouncil),
1444
+ epochMicrogonsPerArgonot: nextCouncil.epochMicrogonsPerArgonot
1445
+ };
1446
+ const calculatedCouncilHash = hashMintingGatewayGlobalIssuanceCouncil2({
1447
+ ...target.council,
1448
+ epochMicrogonsPerArgonot: target.epochMicrogonsPerArgonot
1449
+ });
1450
+ const targetPayloadHash = hashMintingGatewayRotateGlobalIssuanceCouncil(hashContext, target);
1451
+ const approvalHash = hashMintingGatewayRotateGlobalIssuanceCouncilApproval(hashContext, {
1452
+ queueNonce,
1453
+ approvingCouncilHash,
1454
+ previousUpdateHash: toHexValue(entry.previousApprovalHash),
1455
+ target
1456
+ });
1457
+ if (calculatedCouncilHash !== nextCouncilHash) {
1458
+ throw new Error(`Queue nonce ${queueNonce} target council hash does not match council`);
1459
+ }
1460
+ if (toHexValue(entry.targetPayloadHash) !== targetPayloadHash) {
1461
+ throw new Error(`Queue nonce ${queueNonce} target payload hash does not match council`);
1462
+ }
1463
+ if (toHexValue(entry.approvalHash) !== approvalHash) {
1464
+ throw new Error(`Queue nonce ${queueNonce} approval hash does not match council rotation`);
1465
+ }
1466
+ return {
1467
+ queueNonce,
1468
+ kind: MINTING_GATEWAY_UPDATE_KINDS.globalIssuanceCouncilRotate,
1469
+ payload: encodeMintingGatewayGlobalIssuanceCouncilRotateTarget(target),
1470
+ signatures
1471
+ };
1472
+ }
1433
1473
  if (entry.target.isMintingAuthorityActivation) {
1434
1474
  const signatures = getSortedSignatures(entry.signatures);
1435
1475
  const signingKey = getAddress2(toHexValue(entry.target.asMintingAuthorityActivation));
@@ -1515,6 +1555,7 @@ async function loadCouncilByHash(client, councilHash, cache) {
1515
1555
  }
1516
1556
  const council = councilOption.unwrap();
1517
1557
  const loaded = {
1558
+ epochMicrogonsPerArgonot: council.epochMicrogonsPerArgonot.toBigInt(),
1518
1559
  totalWeight: council.totalWeight.toBigInt(),
1519
1560
  members: [...council.members.entries()].map(([signer, member]) => ({
1520
1561
  signer: getAddress2(toHexValue(signer)),