benduran 31c364cf41 feat: performed a minor bump all packages, since all were changed in the big dual package update 2 semanas atrás
..
src 76d65ed014 fix(@pythnetwork/aptos-cli): fixed build 3 semanas atrás
.gitignore ab0cf6f7d8 chore: updated gitignore to excluse the built dist/ folder 3 semanas atrás
.prettierignore 6efbe89542 chore: updated prettier ignores to prevent bikeshedding 2 semanas atrás
README.md 1b5195aa0a fix: run turbo fix 8 meses atrás
package.json 31c364cf41 feat: performed a minor bump all packages, since all were changed in the big dual package update 2 semanas atrás
tsconfig.build.json 87679545bb chore: removed npm-specific things and removed more packageManager fields 2 semanas atrás
tsconfig.json fe92275443 chore: migrated all package.json and tsconfig files to a single, modern standard 3 semanas atrás

README.md

Pre-requisites

Install aptos cli with the same version specified in the ci workflows.

All the commands which submit transactions require an environment variable APTOS_PRIVATE_KEY for the private key to be set.

Deploying from scratch

In addition to the wormhole dependency we depend on the deployer contract that facilitates the ownership of package upgrade capability. You can read more about it here.

Assuming the wormhole and deployer contracts are already deployed, we can deploy the pyth oracle with the following command:

npm run cli deploy-pyth -- ../contracts <seed> \
-n aptos_testnet \
--deployer <deployer-address> \
--wormhole <wormhole-address>

seed can be any random string that is used for determining a specific contract address based on the seed value and the signer address.

You can manually specify the address of wormhole and deployer contracts with --wormhole and --deployer flags. This requires the addresses to be empty in the Move.toml file for the pyth package:

[addresses]
pyth = "_"
deployer = "_"
wormhole = "_"

Initializing pyth

You can run the following to initialize the pyth contract:

npm run cli init-pyth -- <seed> -n <network> \
--stale-price-threshold 60 \
--update-fee 1 \
--channel <stable-or-beta>

Upgrade process:

The following steps are needed to upgrade our aptos contracts:

  • Generate the hash for the new contract build
  • Create a governance proposal, proposing the aptos package to be upgraded to this specific hash
  • Approve and execute the governance proposal
  • Submit the created wormhole VAA to the contract to allow an upgrade with the specified hash.
  • Run the upgrade transaction and publish the new package

Generating the new contract hash:

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.

npm run cli hash-contracts -- ../contracts

Creating a proposal

Here are sample steps you can take to create a proposal via the contract manager shell (npm run shell in contract manager package):

let wallet = await loadHotWallet("/path/to/solana/wallet.json");
let vault =
  DefaultStore.vaults.devnet_6baWtW1zTUVMSJHJQVxDUXWzqrQeYBr6mu31j3bTKwY3;
await vault.connect(wallet);
let payload =
  DefaultStore.chains.aptos_testnet.generateGovernanceUpgradePayload(
    "CONTRACT_HASH_TO_USE",
  );
await vault.proposeWormholeMessage([payload]);

VAA submission

After the approval process, you can fetch the VAA for the transaction and execute it by running:

import { SubmittedWormholeMessage } from "./src/governance";
let msg = await SubmittedWormholeMessage.fromTransactionSignature(
  "tx_signature",
  "devnet or mainnet-beta",
);
let vaa = await msg.fetchVaa();
let contract =
  DefaultStore.contracts
    .aptos_testnet_0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387;
await contract.executeGovernanceInstruction(
  "private-key-of-account-inaptos",
  vaa,
);

Upgrading the contract

To upgrade the contract after the governance vaa was executed run:

npm run cli upgrade -- ../contracts