@@ -62,6 +62,19 @@ const EXTENDED_ENTROPY_ABI = [
62
62
stateMutability : "pure" ,
63
63
type : "function" ,
64
64
} ,
65
+ {
66
+ inputs : [
67
+ {
68
+ internalType : "address" ,
69
+ name : "newImplementation" ,
70
+ type : "address" ,
71
+ } ,
72
+ ] ,
73
+ name : "upgradeTo" ,
74
+ outputs : [ ] ,
75
+ stateMutability : "nonpayable" ,
76
+ type : "function" ,
77
+ } ,
65
78
...EntropyAbi ,
66
79
] as any ; // eslint-disable-line @typescript-eslint/no-explicit-any
67
80
const EXTENDED_PYTH_ABI = [
@@ -354,6 +367,29 @@ const EXECUTOR_ABI = [
354
367
type : "function" ,
355
368
} ,
356
369
] as any ; // eslint-disable-line @typescript-eslint/no-explicit-any
370
+
371
+ /**
372
+ * Returns the keccak256 digest of the contract bytecode at the given address after replacing
373
+ * any occurrences of the contract addr in the bytecode with 0.The bytecode stores the deployment
374
+ * address as an immutable variable. This behavior is inherited from OpenZeppelin's implementation
375
+ * of UUPSUpgradeable contract. You can read more about verification with immutable variables here:
376
+ * https://docs.sourcify.dev/docs/immutables/
377
+ * This function can be used to verify that the contract code is the same on all chains and matches
378
+ * with the deployedCode property generated by truffle builds
379
+ */
380
+ export async function getCodeDigestWithoutAddress (
381
+ rpcUrl : string ,
382
+ address : string
383
+ ) : Promise < string > {
384
+ const web3 = new Web3 ( rpcUrl ) ;
385
+ const code = await web3 . eth . getCode ( address ) ;
386
+ const strippedCode = code . replaceAll (
387
+ address . toLowerCase ( ) . replace ( "0x" , "" ) ,
388
+ "0000000000000000000000000000000000000000"
389
+ ) ;
390
+ return Web3 . utils . keccak256 ( strippedCode ) ;
391
+ }
392
+
357
393
export class WormholeEvmContract extends WormholeContract {
358
394
constructor ( public chain : EvmChain , public address : string ) {
359
395
super ( ) ;
@@ -480,6 +516,18 @@ export class EvmEntropyContract extends Storable {
480
516
return this . generateExecutorPayload ( newOwner , this . address , data ) ;
481
517
}
482
518
519
+ async generateUpgradeEntropyContractPayload (
520
+ newImplementation : string
521
+ ) : Promise < Buffer > {
522
+ const contract = this . getContract ( ) ;
523
+ const data = contract . methods . upgradeTo ( newImplementation ) . encodeABI ( ) ;
524
+ return this . generateExecutorPayload (
525
+ await this . getOwner ( ) ,
526
+ this . address ,
527
+ data
528
+ ) ;
529
+ }
530
+
483
531
// Generates a payload to upgrade the executor contract, the owner of entropy contracts
484
532
async generateUpgradeExecutorContractsPayload (
485
533
newImplementation : string
@@ -708,21 +756,10 @@ export class EvmPriceFeedContract extends PriceFeedContract {
708
756
}
709
757
710
758
/**
711
- * Returns the keccak256 digest of the contract bytecode after replacing any occurrences of the contract addr in
712
- * the bytecode with 0.The bytecode stores the deployment address as an immutable variable.
713
- * This behavior is inherited from OpenZeppelin's implementation of UUPSUpgradeable contract.
714
- * You can read more about verification with immutable variables here:
715
- * https://docs.sourcify.dev/docs/immutables/
716
- * This function can be used to verify that the contract code is the same on all chains and matches
717
- * with the deployedCode property generated by truffle builds
759
+ * Returns the keccak256 digest of the contract bytecode
718
760
*/
719
761
async getCodeDigestWithoutAddress ( ) : Promise < string > {
720
- const code = await this . getCode ( ) ;
721
- const strippedCode = code . replaceAll (
722
- this . address . toLowerCase ( ) . replace ( "0x" , "" ) ,
723
- "0000000000000000000000000000000000000000"
724
- ) ;
725
- return Web3 . utils . keccak256 ( strippedCode ) ;
762
+ return getCodeDigestWithoutAddress ( this . chain . getRpcUrl ( ) , this . address ) ;
726
763
}
727
764
728
765
async getTotalFee ( ) : Promise < TokenQty > {
0 commit comments