@argonprotocol/testing 1.4.6 → 1.4.7-dev.6c827619
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.cjs +39 -71
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +39 -71
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/lib/index.d.cts
CHANGED
|
@@ -234,7 +234,6 @@ type EthereumGatewayUpdateBatch = {
|
|
|
234
234
|
argonApprovalsNonce: bigint;
|
|
235
235
|
argonApprovalsHash: Hex;
|
|
236
236
|
paused: boolean;
|
|
237
|
-
pendingClearOutQueueNonces: bigint[];
|
|
238
237
|
firstQueueNonce?: bigint;
|
|
239
238
|
lastQueueNonce?: bigint;
|
|
240
239
|
updates: MintingGatewayGatewayUpdate[];
|
package/lib/index.d.ts
CHANGED
|
@@ -234,7 +234,6 @@ type EthereumGatewayUpdateBatch = {
|
|
|
234
234
|
argonApprovalsNonce: bigint;
|
|
235
235
|
argonApprovalsHash: Hex;
|
|
236
236
|
paused: boolean;
|
|
237
|
-
pendingClearOutQueueNonces: bigint[];
|
|
238
237
|
firstQueueNonce?: bigint;
|
|
239
238
|
lastQueueNonce?: bigint;
|
|
240
239
|
updates: MintingGatewayGatewayUpdate[];
|
package/lib/index.js
CHANGED
|
@@ -1342,7 +1342,6 @@ var {
|
|
|
1342
1342
|
encodeMintingGatewayMintingAuthorityDeactivateTarget,
|
|
1343
1343
|
hashMintingGatewayActivateMintingAuthority,
|
|
1344
1344
|
hashMintingGatewayGatewayUpdateApproval,
|
|
1345
|
-
hashMintingGatewayMintingAuthorityDeactivation,
|
|
1346
1345
|
mintingGatewayAbi,
|
|
1347
1346
|
MINTING_GATEWAY_UPDATE_KINDS
|
|
1348
1347
|
} = EvmContracts2;
|
|
@@ -1394,7 +1393,6 @@ async function getReadyEthereumGatewayUpdates(client, gatewayClient, options = {
|
|
|
1394
1393
|
const argonApprovalsNonce = rawArgonApprovalsNonce;
|
|
1395
1394
|
const argonApprovalsHash = rawArgonApprovalsHash;
|
|
1396
1395
|
const paused = rawPaused;
|
|
1397
|
-
const pendingClearOutQueueNonces = [];
|
|
1398
1396
|
const candidateUpdates = [];
|
|
1399
1397
|
let expectedPreviousApprovalHash = argonApprovalsHash;
|
|
1400
1398
|
let readyQueueEntriesScanned = 0;
|
|
@@ -1409,14 +1407,8 @@ async function getReadyEthereumGatewayUpdates(client, gatewayClient, options = {
|
|
|
1409
1407
|
}
|
|
1410
1408
|
const entry = entryOption.unwrap();
|
|
1411
1409
|
const approvingCouncilHash = toHexValue(entry.approvingCouncilHash);
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
entry,
|
|
1415
|
-
approvingCouncilHash,
|
|
1416
|
-
councilCache,
|
|
1417
|
-
hashContext,
|
|
1418
|
-
queueNonce
|
|
1419
|
-
)) {
|
|
1410
|
+
const approvingCouncil = await loadCouncilByHash(client, approvingCouncilHash, councilCache);
|
|
1411
|
+
if (!queueEntryHasQuorum(entry, approvingCouncil)) {
|
|
1420
1412
|
break;
|
|
1421
1413
|
}
|
|
1422
1414
|
readyQueueEntriesScanned += 1;
|
|
@@ -1433,10 +1425,15 @@ async function getReadyEthereumGatewayUpdates(client, gatewayClient, options = {
|
|
|
1433
1425
|
expectedPreviousApprovalHash = toHexValue(entry.approvalHash);
|
|
1434
1426
|
}
|
|
1435
1427
|
}
|
|
1436
|
-
while (candidateUpdates.length > 0 && candidateUpdates[candidateUpdates.length - 1]?.kind === MINTING_GATEWAY_UPDATE_KINDS.mintingAuthorityDeactivate) {
|
|
1437
|
-
pendingClearOutQueueNonces.unshift(candidateUpdates.pop().queueNonce);
|
|
1438
|
-
}
|
|
1439
1428
|
const updates = candidateUpdates;
|
|
1429
|
+
for (let index = 0; index < updates.length; index += 1) {
|
|
1430
|
+
const isBorder = updates[index].kind === MINTING_GATEWAY_UPDATE_KINDS.globalIssuanceCouncilRotate || index === updates.length - 1;
|
|
1431
|
+
if (isBorder || updates[index].signatures.length === 0) continue;
|
|
1432
|
+
updates[index] = {
|
|
1433
|
+
...updates[index],
|
|
1434
|
+
signatures: []
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1440
1437
|
const firstQueueNonce = updates[0]?.queueNonce;
|
|
1441
1438
|
const lastQueueNonce = updates[updates.length - 1]?.queueNonce;
|
|
1442
1439
|
return {
|
|
@@ -1448,7 +1445,6 @@ async function getReadyEthereumGatewayUpdates(client, gatewayClient, options = {
|
|
|
1448
1445
|
argonApprovalsNonce,
|
|
1449
1446
|
argonApprovalsHash,
|
|
1450
1447
|
paused,
|
|
1451
|
-
pendingClearOutQueueNonces,
|
|
1452
1448
|
...firstQueueNonce !== void 0 ? { firstQueueNonce, lastQueueNonce } : {},
|
|
1453
1449
|
updates
|
|
1454
1450
|
};
|
|
@@ -1476,7 +1472,7 @@ async function buildGatewayUpdate(client, destinationChain, hashContext, queueNo
|
|
|
1476
1472
|
signingKey
|
|
1477
1473
|
};
|
|
1478
1474
|
const payload = encodeMintingGatewayMintingAuthorityActivationTarget(target);
|
|
1479
|
-
const targetPayloadHash =
|
|
1475
|
+
const targetPayloadHash = hashMintingGatewayActivateMintingAuthority(hashContext, target);
|
|
1480
1476
|
const approvalHash = hashMintingGatewayGatewayUpdateApproval(hashContext, {
|
|
1481
1477
|
queueNonce,
|
|
1482
1478
|
approvingCouncilHash,
|
|
@@ -1501,17 +1497,30 @@ async function buildGatewayUpdate(client, destinationChain, hashContext, queueNo
|
|
|
1501
1497
|
};
|
|
1502
1498
|
}
|
|
1503
1499
|
if (entry.target.isMintingAuthorityDeactivation) {
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1500
|
+
const signingKey = getAddress2(toHexValue(entry.target.asMintingAuthorityDeactivation));
|
|
1501
|
+
const payload = encodeMintingGatewayMintingAuthorityDeactivateTarget({ signingKey });
|
|
1502
|
+
const targetPayloadHash = keccak256(payload);
|
|
1503
|
+
const approvalHash = hashMintingGatewayGatewayUpdateApproval(hashContext, {
|
|
1506
1504
|
queueNonce,
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1505
|
+
approvingCouncilHash,
|
|
1506
|
+
kind: MINTING_GATEWAY_UPDATE_KINDS.mintingAuthorityDeactivate,
|
|
1507
|
+
targetId: signingKeyTargetId(signingKey),
|
|
1508
|
+
targetPayloadHash,
|
|
1509
|
+
previousUpdateHash: toHexValue(entry.previousApprovalHash)
|
|
1510
|
+
});
|
|
1511
|
+
if (toHexValue(entry.targetPayloadHash) !== targetPayloadHash) {
|
|
1512
|
+
throw new Error(`Queue nonce ${queueNonce} target payload hash does not match deactivation`);
|
|
1513
|
+
}
|
|
1514
|
+
if (toHexValue(entry.approvalHash) !== approvalHash) {
|
|
1515
|
+
throw new Error(
|
|
1516
|
+
`Queue nonce ${queueNonce} approval hash does not match deactivation: actual=${toHexValue(entry.approvalHash)} expected=${approvalHash} previous=${toHexValue(entry.previousApprovalHash)} council=${approvingCouncilHash}`
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1510
1519
|
return {
|
|
1511
1520
|
queueNonce,
|
|
1512
1521
|
kind: MINTING_GATEWAY_UPDATE_KINDS.mintingAuthorityDeactivate,
|
|
1513
1522
|
payload,
|
|
1514
|
-
signatures
|
|
1523
|
+
signatures: getSortedSignatures(entry.signatures)
|
|
1515
1524
|
};
|
|
1516
1525
|
}
|
|
1517
1526
|
throw new Error(`Unsupported approval queue target ${entry.target.type}`);
|
|
@@ -1537,23 +1546,20 @@ async function loadCouncilByHash(client, councilHash, cache) {
|
|
|
1537
1546
|
return loaded;
|
|
1538
1547
|
}
|
|
1539
1548
|
function queueEntryHasQuorum(entry, council) {
|
|
1540
|
-
|
|
1549
|
+
let signedWeight = 0n;
|
|
1550
|
+
for (const [signer] of entry.signatures.entries()) {
|
|
1541
1551
|
const signerAddress = getAddress2(toHexValue(signer));
|
|
1542
1552
|
const member = council.members.find((x) => x.signer === signerAddress);
|
|
1543
1553
|
if (!member) {
|
|
1544
1554
|
throw new Error(`Signature submitted by ${signerAddress}, which is not in the council`);
|
|
1545
1555
|
}
|
|
1546
|
-
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
}
|
|
1550
|
-
async function queueEntryIsReady(client, entry, approvingCouncilHash, councilCache, hashContext, queueNonce) {
|
|
1551
|
-
if (entry.target.isMintingAuthorityDeactivation) {
|
|
1552
|
-
validateDeactivationEntry(hashContext, queueNonce, entry, approvingCouncilHash);
|
|
1556
|
+
signedWeight += member.weight;
|
|
1557
|
+
}
|
|
1558
|
+
if (signedWeight * 100n >= council.totalWeight * 90n) {
|
|
1553
1559
|
return true;
|
|
1554
1560
|
}
|
|
1555
|
-
const
|
|
1556
|
-
return
|
|
1561
|
+
const unsignedMemberCount = council.members.length - entry.signatures.size;
|
|
1562
|
+
return unsignedMemberCount <= 2 && signedWeight * 100n >= council.totalWeight * 80n;
|
|
1557
1563
|
}
|
|
1558
1564
|
function councilToSnapshot(council) {
|
|
1559
1565
|
return {
|
|
@@ -1561,46 +1567,8 @@ function councilToSnapshot(council) {
|
|
|
1561
1567
|
weights: council.members.map((member) => member.weight)
|
|
1562
1568
|
};
|
|
1563
1569
|
}
|
|
1564
|
-
function
|
|
1565
|
-
return
|
|
1566
|
-
}
|
|
1567
|
-
function payloadHashFromDeactivationPayload(target) {
|
|
1568
|
-
return keccak256(encodeMintingGatewayMintingAuthorityDeactivateTarget(target));
|
|
1569
|
-
}
|
|
1570
|
-
function validateDeactivationEntry(hashContext, queueNonce, entry, approvingCouncilHash) {
|
|
1571
|
-
const signingKey = getAddress2(toHexValue(entry.target.asMintingAuthorityDeactivation));
|
|
1572
|
-
const target = { signingKey };
|
|
1573
|
-
const payload = encodeMintingGatewayMintingAuthorityDeactivateTarget(target);
|
|
1574
|
-
const targetPayloadHash = payloadHashFromDeactivationPayload(target);
|
|
1575
|
-
const approvalHash = hashMintingGatewayMintingAuthorityDeactivation(hashContext, {
|
|
1576
|
-
queueNonce,
|
|
1577
|
-
target,
|
|
1578
|
-
previousUpdateHash: toHexValue(entry.previousApprovalHash)
|
|
1579
|
-
});
|
|
1580
|
-
if (toHexValue(entry.targetPayloadHash) !== targetPayloadHash) {
|
|
1581
|
-
throw new Error(`Queue nonce ${queueNonce} target payload hash does not match deactivation`);
|
|
1582
|
-
}
|
|
1583
|
-
if (toHexValue(entry.approvalHash) !== approvalHash) {
|
|
1584
|
-
throw new Error(
|
|
1585
|
-
`Queue nonce ${queueNonce} approval hash does not match deactivation: actual=${toHexValue(entry.approvalHash)} expected=${approvalHash} previous=${toHexValue(entry.previousApprovalHash)} council=${approvingCouncilHash}`
|
|
1586
|
-
);
|
|
1587
|
-
}
|
|
1588
|
-
const deactivationSignatures = [...entry.signatures.entries()];
|
|
1589
|
-
if (deactivationSignatures.length !== 1) {
|
|
1590
|
-
throw new Error(
|
|
1591
|
-
`Queue nonce ${queueNonce} expected exactly one deactivation signature, received ${deactivationSignatures.length}`
|
|
1592
|
-
);
|
|
1593
|
-
}
|
|
1594
|
-
const [signer] = deactivationSignatures[0];
|
|
1595
|
-
if (getAddress2(toHexValue(signer)) !== signingKey) {
|
|
1596
|
-
throw new Error(
|
|
1597
|
-
`Queue nonce ${queueNonce} deactivation signature was submitted by ${getAddress2(toHexValue(signer))}, expected ${signingKey}`
|
|
1598
|
-
);
|
|
1599
|
-
}
|
|
1600
|
-
return {
|
|
1601
|
-
payload,
|
|
1602
|
-
signatures: getSortedSignatures(entry.signatures)
|
|
1603
|
-
};
|
|
1570
|
+
function signingKeyTargetId(signingKey) {
|
|
1571
|
+
return `0x${signingKey.slice(2).padStart(64, "0").toLowerCase()}`;
|
|
1604
1572
|
}
|
|
1605
1573
|
function getSortedSignatures(signatures) {
|
|
1606
1574
|
return [...signatures.entries()].sort(
|