|
|
@@ -62,6 +62,19 @@ const EXTENDED_ENTROPY_ABI = [
|
|
|
stateMutability: "pure",
|
|
|
type: "function",
|
|
|
},
|
|
|
+ {
|
|
|
+ inputs: [
|
|
|
+ {
|
|
|
+ internalType: "address",
|
|
|
+ name: "newImplementation",
|
|
|
+ type: "address",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ name: "upgradeTo",
|
|
|
+ outputs: [],
|
|
|
+ stateMutability: "nonpayable",
|
|
|
+ type: "function",
|
|
|
+ },
|
|
|
...EntropyAbi,
|
|
|
] as any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
const EXTENDED_PYTH_ABI = [
|
|
|
@@ -354,6 +367,29 @@ const EXECUTOR_ABI = [
|
|
|
type: "function",
|
|
|
},
|
|
|
] as any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
|
+
|
|
|
+/**
|
|
|
+ * Returns the keccak256 digest of the contract bytecode at the given address after replacing
|
|
|
+ * any occurrences of the contract addr in the bytecode with 0.The bytecode stores the deployment
|
|
|
+ * address as an immutable variable. This behavior is inherited from OpenZeppelin's implementation
|
|
|
+ * of UUPSUpgradeable contract. You can read more about verification with immutable variables here:
|
|
|
+ * https://docs.sourcify.dev/docs/immutables/
|
|
|
+ * This function can be used to verify that the contract code is the same on all chains and matches
|
|
|
+ * with the deployedCode property generated by truffle builds
|
|
|
+ */
|
|
|
+export async function getCodeDigestWithoutAddress(
|
|
|
+ rpcUrl: string,
|
|
|
+ address: string
|
|
|
+): Promise<string> {
|
|
|
+ const web3 = new Web3(rpcUrl);
|
|
|
+ const code = await web3.eth.getCode(address);
|
|
|
+ const strippedCode = code.replaceAll(
|
|
|
+ address.toLowerCase().replace("0x", ""),
|
|
|
+ "0000000000000000000000000000000000000000"
|
|
|
+ );
|
|
|
+ return Web3.utils.keccak256(strippedCode);
|
|
|
+}
|
|
|
+
|
|
|
export class WormholeEvmContract extends WormholeContract {
|
|
|
constructor(public chain: EvmChain, public address: string) {
|
|
|
super();
|
|
|
@@ -480,6 +516,18 @@ export class EvmEntropyContract extends Storable {
|
|
|
return this.generateExecutorPayload(newOwner, this.address, data);
|
|
|
}
|
|
|
|
|
|
+ async generateUpgradeEntropyContractPayload(
|
|
|
+ newImplementation: string
|
|
|
+ ): Promise<Buffer> {
|
|
|
+ const contract = this.getContract();
|
|
|
+ const data = contract.methods.upgradeTo(newImplementation).encodeABI();
|
|
|
+ return this.generateExecutorPayload(
|
|
|
+ await this.getOwner(),
|
|
|
+ this.address,
|
|
|
+ data
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
// Generates a payload to upgrade the executor contract, the owner of entropy contracts
|
|
|
async generateUpgradeExecutorContractsPayload(
|
|
|
newImplementation: string
|
|
|
@@ -708,21 +756,10 @@ export class EvmPriceFeedContract extends PriceFeedContract {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Returns the keccak256 digest of the contract bytecode after replacing any occurrences of the contract addr in
|
|
|
- * the bytecode with 0.The bytecode stores the deployment address as an immutable variable.
|
|
|
- * This behavior is inherited from OpenZeppelin's implementation of UUPSUpgradeable contract.
|
|
|
- * You can read more about verification with immutable variables here:
|
|
|
- * https://docs.sourcify.dev/docs/immutables/
|
|
|
- * This function can be used to verify that the contract code is the same on all chains and matches
|
|
|
- * with the deployedCode property generated by truffle builds
|
|
|
+ * Returns the keccak256 digest of the contract bytecode
|
|
|
*/
|
|
|
async getCodeDigestWithoutAddress(): Promise<string> {
|
|
|
- const code = await this.getCode();
|
|
|
- const strippedCode = code.replaceAll(
|
|
|
- this.address.toLowerCase().replace("0x", ""),
|
|
|
- "0000000000000000000000000000000000000000"
|
|
|
- );
|
|
|
- return Web3.utils.keccak256(strippedCode);
|
|
|
+ return getCodeDigestWithoutAddress(this.chain.getRpcUrl(), this.address);
|
|
|
}
|
|
|
|
|
|
async getTotalFee(): Promise<TokenQty> {
|