Selaa lähdekoodia

[aptos] New address for aptos deployments and some small improvements (#996)

* Add abi diff command and small documentation fix

* Redeploy aptos package and update the address
Mohammad Amin Khashkhashi Moghaddam 2 vuotta sitten
vanhempi
sitoutus
1d5a96c35a

+ 1 - 1
contract_manager/store/contracts/AptosContract/aptos_mainnet_0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387.yaml → contract_manager/store/contracts/AptosContract/aptos_mainnet_0xbd6d205f2aa288baa71270e66716d3d1bafe173ab9f312de4e9dd761ddef5409.yaml

@@ -1,4 +1,4 @@
 chain: aptos_mainnet
-stateId: "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387"
+stateId: "0xbd6d205f2aa288baa71270e66716d3d1bafe173ab9f312de4e9dd761ddef5409"
 wormholeStateId: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625"
 type: AptosContract

+ 1 - 1
contract_manager/store/contracts/AptosContract/aptos_testnet_0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387.yaml → contract_manager/store/contracts/AptosContract/aptos_testnet_0xbd6d205f2aa288baa71270e66716d3d1bafe173ab9f312de4e9dd761ddef5409.yaml

@@ -1,4 +1,4 @@
 chain: aptos_testnet
-stateId: "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387"
+stateId: "0xbd6d205f2aa288baa71270e66716d3d1bafe173ab9f312de4e9dd761ddef5409"
 wormholeStateId: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625"
 type: AptosContract

+ 1 - 1
price_pusher/README.md

@@ -84,7 +84,7 @@ npm run start -- injective --grpc-endpoint https://grpc-endpoint.com \
 
 # For Aptos
 npm run start -- aptos --endpoint https://fullnode.testnet.aptoslabs.com/v1 \
-    --pyth-contract-address 0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387 --price-service-endpoint "https://xc-testnet.pyth.network" \
+    --pyth-contract-address 0xbd6d205f2aa288baa71270e66716d3d1bafe173ab9f312de4e9dd761ddef5409 --price-service-endpoint "https://xc-testnet.pyth.network" \
     --price-config-file "./price-config.testnet.sample.yaml" \
     --mnemonic-file "path/to/mnemonic.txt" \
     [--pushing-frequency 10] \

+ 1 - 1
price_pusher/config.aptos.testnet.sample.json

@@ -1,6 +1,6 @@
 {
   "endpoint": "https://fullnode.testnet.aptoslabs.com/v1",
-  "pyth-contract-address": "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387",
+  "pyth-contract-address": "0xbd6d205f2aa288baa71270e66716d3d1bafe173ab9f312de4e9dd761ddef5409",
   "price-service-endpoint": "https://xc-testnet.pyth.network",
   "mnemonic-file": "./mnemonic",
   "price-config-file": "./price-config.testnet.sample.yaml"

+ 4 - 4
target_chains/aptos/cli/README.md

@@ -13,7 +13,7 @@ capability. You can read more about it [here](https://github.com/wormhole-founda
 Assuming the wormhole and deployer contracts are already deployed, we can deploy the pyth oracle with the following command:
 
 ```bash
-npm run cli deploy-pyth ../contracts <seed> -n testnet
+npm run cli deploy-pyth -- ../contracts <seed> -n testnet
 ```
 
 `seed` can be any random string that is used for determining a specific contract address based on the seed value and the signer address.
@@ -33,7 +33,7 @@ wormhole = "_"
 You can run the following to initialize the pyth contract, the following is a sample (testnet) config:
 
 ```bash
-npm run cli init-pyth <seed> -n testnet \
+npm run cli init-pyth -- <seed> -n testnet \
 --stale-price-threshold 60 \
 --update-fee 1 \
 --governance-emitter-chain-id 1 \
@@ -62,7 +62,7 @@ The following steps are needed to upgrade our aptos contracts:
 Run the following command to generate the new hash, this will assume the default deployed addresses of deployer, wormhole, and pyth, but you can override them if necessary.
 
 ```bash
-npm run cli hash-contracts ../contracts
+npm run cli hash-contracts -- ../contracts
 ```
 
 ## Upgrading the contract
@@ -70,5 +70,5 @@ npm run cli hash-contracts ../contracts
 To upgrade the contract after the governance vaa was executed run:
 
 ```bash
-npm run cli upgrade ../contracts
+npm run cli upgrade -- ../contracts
 ```

+ 47 - 1
target_chains/aptos/cli/src/commands/aptos.ts

@@ -36,7 +36,7 @@ const WORMHOLE_OPTION = {
 const PYTH_OPTION = {
   describe: "pyth contract address deployed in the network",
   type: "string",
-  default: "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387",
+  default: "0xbd6d205f2aa288baa71270e66716d3d1bafe173ab9f312de4e9dd761ddef5409",
 } as const;
 
 interface Package {
@@ -367,6 +367,52 @@ export const builder: (args: Argv<any>) => Argv<any> = (yargs) =>
         await executeTransaction(argv.network, txPayload);
       }
     )
+    .command(
+      "diff-abi <addr-1> <addr-2>",
+      "Finds the differences between the ABIs of two published packages, can be used to make sure that the upgrade will be backward compatible",
+      (_yargs) => {
+        return yargs
+          .positional("addr-1", {
+            type: "string",
+            required: true,
+          })
+          .positional("addr-2", {
+            type: "string",
+            required: true,
+          })
+          .option("network", NETWORK_OPTION);
+      },
+      async (argv) => {
+        const endpoint = networks.get(argv.network)!.endpoint;
+        const addr1 = argv["addr-1"];
+        const addr2 = argv["addr-2"];
+        const url = `${endpoint}/accounts/${addr1}/resource/0x1::code::PackageRegistry`;
+        const response = await (await fetch(url)).json();
+        for (const module of response.data.packages[0].modules) {
+          const moduleName = module.name;
+          const addr1Module = `${endpoint}/accounts/${addr1}/module/${moduleName}`;
+          const addr2Module = `${endpoint}/accounts/${addr2}/module/${moduleName}`;
+          const module1Response = await (await fetch(addr1Module)).text();
+          const module2Response = await (await fetch(addr2Module)).text();
+          const module1Stripped = module1Response.replace(
+            new RegExp(addr1, "g"),
+            "0x0"
+          );
+          const module2Stripped = module2Response.replace(
+            new RegExp(addr2, "g"),
+            "0x0"
+          );
+          if (
+            JSON.stringify(JSON.parse(module1Stripped).abi) !==
+            JSON.stringify(JSON.parse(module2Stripped).abi)
+          ) {
+            console.log(`Module ${moduleName} ABI changed`);
+          } else {
+            console.log(`Module ${moduleName} ABI not changed`);
+          }
+        }
+      }
+    )
     .demandCommand();
 
 function getSender(network: string) {

+ 1 - 1
target_chains/aptos/examples/mint_nft/Move.toml

@@ -12,7 +12,7 @@ Pyth = { git = "https://github.com/pyth-network/pyth-crosschain.git", subdir = "
 # These are testnet addresses https://docs.pyth.network/documentation/pythnet-price-feeds/aptos#addresses
 aptos_framework = "0x1"
 mint_nft = "0x19f8503273cdb5aa93ffe4539277684615242127aa2e65ef91424136a316c9c7"
-pyth = "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387"
+pyth = "0xbd6d205f2aa288baa71270e66716d3d1bafe173ab9f312de4e9dd761ddef5409"
 deployer = "0xb31e712b26fd295357355f6845e77c888298636609e93bc9b05f0f604049f434"
 wormhole = "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625"