Skip to content

Commit 20c0f5a

Browse files
committed
Added script for governance
1 parent 1fda5ee commit 20c0f5a

File tree

2 files changed

+247
-15
lines changed

2 files changed

+247
-15
lines changed

contract_manager/src/core/contracts/evm.ts

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
EXTENDED_PYTH_ABI,
1212
WORMHOLE_ABI,
1313
PULSE_UPGRADEABLE_ABI,
14+
LAZER_ABI,
1415
} from "./evm_abis";
1516

1617
/**
@@ -962,6 +963,45 @@ export class EvmLazerContract extends Storable {
962963
return new EvmLazerContract(chain as EvmChain, parsed.address);
963964
}
964965

966+
getContract() {
967+
const web3 = this.chain.getWeb3();
968+
return new web3.eth.Contract(LAZER_ABI, this.address);
969+
}
970+
971+
async getVersion(): Promise<string> {
972+
const contract = this.getContract();
973+
return await contract.methods.version().call();
974+
}
975+
976+
async getOwner(): Promise<string> {
977+
const contract = this.getContract();
978+
return contract.methods.owner().call();
979+
}
980+
981+
982+
983+
async generateUpdateTrustedSignerPayload(
984+
trustedSigner: string,
985+
expiresAt: number,
986+
): Promise<Buffer> {
987+
// Executor contract is the owner of the PythLazer contract
988+
const executorAddress = await this.getOwner();
989+
const web3 = this.chain.getWeb3();
990+
const executorContract = new web3.eth.Contract(
991+
EXECUTOR_ABI,
992+
executorAddress,
993+
);
994+
const data = executorContract.methods.updateTrustedSigner(
995+
trustedSigner,
996+
expiresAt,
997+
).encodeABI();
998+
return this.chain.generateExecutorPayload(
999+
executorAddress,
1000+
this.address,
1001+
data,
1002+
);
1003+
}
1004+
9651005
/**
9661006
* Updates the trusted signer for the PythLazer contract
9671007
* @param trustedSigner The address of the trusted signer
@@ -974,21 +1014,7 @@ export class EvmLazerContract extends Storable {
9741014
privateKey: PrivateKey,
9751015
): Promise<void> {
9761016
const web3 = this.chain.getWeb3();
977-
const contract = new web3.eth.Contract(
978-
[
979-
{
980-
inputs: [
981-
{ name: "trustedSigner", type: "address" },
982-
{ name: "expiresAt", type: "uint256" },
983-
],
984-
name: "updateTrustedSigner",
985-
outputs: [],
986-
stateMutability: "nonpayable",
987-
type: "function",
988-
},
989-
],
990-
this.address,
991-
);
1017+
const contract = this.getContract();
9921018

9931019
const account = web3.eth.accounts.privateKeyToAccount(privateKey);
9941020
const gasEstimate = await contract.methods

contract_manager/src/core/contracts/evm_abis.ts

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,3 +1366,209 @@ export const PULSE_UPGRADEABLE_ABI = [
13661366
],
13671367
},
13681368
] as any; // eslint-disable-line @typescript-eslint/no-explicit-any
1369+
1370+
export const LAZER_ABI = [
1371+
{ "type": "constructor", "inputs": [], "stateMutability": "nonpayable" },
1372+
{
1373+
"type": "function",
1374+
"name": "UPGRADE_INTERFACE_VERSION",
1375+
"inputs": [],
1376+
"outputs": [{ "name": "", "type": "string", "internalType": "string" }],
1377+
"stateMutability": "view"
1378+
},
1379+
{
1380+
"type": "function",
1381+
"name": "initialize",
1382+
"inputs": [
1383+
{
1384+
"name": "_topAuthority",
1385+
"type": "address",
1386+
"internalType": "address"
1387+
}
1388+
],
1389+
"outputs": [],
1390+
"stateMutability": "nonpayable"
1391+
},
1392+
{
1393+
"type": "function",
1394+
"name": "isValidSigner",
1395+
"inputs": [
1396+
{ "name": "signer", "type": "address", "internalType": "address" }
1397+
],
1398+
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
1399+
"stateMutability": "view"
1400+
},
1401+
{
1402+
"type": "function",
1403+
"name": "owner",
1404+
"inputs": [],
1405+
"outputs": [{ "name": "", "type": "address", "internalType": "address" }],
1406+
"stateMutability": "view"
1407+
},
1408+
{
1409+
"type": "function",
1410+
"name": "proxiableUUID",
1411+
"inputs": [],
1412+
"outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }],
1413+
"stateMutability": "view"
1414+
},
1415+
{
1416+
"type": "function",
1417+
"name": "renounceOwnership",
1418+
"inputs": [],
1419+
"outputs": [],
1420+
"stateMutability": "nonpayable"
1421+
},
1422+
{
1423+
"type": "function",
1424+
"name": "transferOwnership",
1425+
"inputs": [
1426+
{ "name": "newOwner", "type": "address", "internalType": "address" }
1427+
],
1428+
"outputs": [],
1429+
"stateMutability": "nonpayable"
1430+
},
1431+
{
1432+
"type": "function",
1433+
"name": "updateTrustedSigner",
1434+
"inputs": [
1435+
{
1436+
"name": "trustedSigner",
1437+
"type": "address",
1438+
"internalType": "address"
1439+
},
1440+
{ "name": "expiresAt", "type": "uint256", "internalType": "uint256" }
1441+
],
1442+
"outputs": [],
1443+
"stateMutability": "nonpayable"
1444+
},
1445+
{
1446+
"type": "function",
1447+
"name": "upgradeToAndCall",
1448+
"inputs": [
1449+
{
1450+
"name": "newImplementation",
1451+
"type": "address",
1452+
"internalType": "address"
1453+
},
1454+
{ "name": "data", "type": "bytes", "internalType": "bytes" }
1455+
],
1456+
"outputs": [],
1457+
"stateMutability": "payable"
1458+
},
1459+
{
1460+
"type": "function",
1461+
"name": "verification_fee",
1462+
"inputs": [],
1463+
"outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }],
1464+
"stateMutability": "view"
1465+
},
1466+
{
1467+
"type": "function",
1468+
"name": "verifyUpdate",
1469+
"inputs": [
1470+
{ "name": "update", "type": "bytes", "internalType": "bytes" }
1471+
],
1472+
"outputs": [
1473+
{ "name": "payload", "type": "bytes", "internalType": "bytes" },
1474+
{ "name": "signer", "type": "address", "internalType": "address" }
1475+
],
1476+
"stateMutability": "payable"
1477+
},
1478+
{
1479+
"type": "function",
1480+
"name": "version",
1481+
"inputs": [],
1482+
"outputs": [{ "name": "", "type": "string", "internalType": "string" }],
1483+
"stateMutability": "pure"
1484+
},
1485+
{
1486+
"type": "event",
1487+
"name": "Initialized",
1488+
"inputs": [
1489+
{
1490+
"name": "version",
1491+
"type": "uint64",
1492+
"indexed": false,
1493+
"internalType": "uint64"
1494+
}
1495+
],
1496+
"anonymous": false
1497+
},
1498+
{
1499+
"type": "event",
1500+
"name": "OwnershipTransferred",
1501+
"inputs": [
1502+
{
1503+
"name": "previousOwner",
1504+
"type": "address",
1505+
"indexed": true,
1506+
"internalType": "address"
1507+
},
1508+
{
1509+
"name": "newOwner",
1510+
"type": "address",
1511+
"indexed": true,
1512+
"internalType": "address"
1513+
}
1514+
],
1515+
"anonymous": false
1516+
},
1517+
{
1518+
"type": "event",
1519+
"name": "Upgraded",
1520+
"inputs": [
1521+
{
1522+
"name": "implementation",
1523+
"type": "address",
1524+
"indexed": true,
1525+
"internalType": "address"
1526+
}
1527+
],
1528+
"anonymous": false
1529+
},
1530+
{
1531+
"type": "error",
1532+
"name": "AddressEmptyCode",
1533+
"inputs": [
1534+
{ "name": "target", "type": "address", "internalType": "address" }
1535+
]
1536+
},
1537+
{
1538+
"type": "error",
1539+
"name": "ERC1967InvalidImplementation",
1540+
"inputs": [
1541+
{
1542+
"name": "implementation",
1543+
"type": "address",
1544+
"internalType": "address"
1545+
}
1546+
]
1547+
},
1548+
{ "type": "error", "name": "ERC1967NonPayable", "inputs": [] },
1549+
{ "type": "error", "name": "FailedCall", "inputs": [] },
1550+
{ "type": "error", "name": "InvalidInitialization", "inputs": [] },
1551+
{ "type": "error", "name": "NotInitializing", "inputs": [] },
1552+
{
1553+
"type": "error",
1554+
"name": "OwnableInvalidOwner",
1555+
"inputs": [
1556+
{ "name": "owner", "type": "address", "internalType": "address" }
1557+
]
1558+
},
1559+
{
1560+
"type": "error",
1561+
"name": "OwnableUnauthorizedAccount",
1562+
"inputs": [
1563+
{ "name": "account", "type": "address", "internalType": "address" }
1564+
]
1565+
},
1566+
{ "type": "error", "name": "UUPSUnauthorizedCallContext", "inputs": [] },
1567+
{
1568+
"type": "error",
1569+
"name": "UUPSUnsupportedProxiableUUID",
1570+
"inputs": [
1571+
{ "name": "slot", "type": "bytes32", "internalType": "bytes32" }
1572+
]
1573+
}
1574+
] as any; // eslint-disable-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)