Skip to content

Commit

Permalink
chore: update policy values
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Jul 29, 2024
1 parent 7d7f4ae commit 1cf6f5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions sui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ node sui/deploy-contract.js upgrade axelar_gateway <policy>

policy should be one of the following:

- `0`: Allow any upgrade.
- `128`: Upgrade policy to just add code. https://docs.sui.io/references/framework/sui-framework/package#function-only_additive_upgrades
- `192`: Upgrade policy to just change dependencies. https://docs.sui.io/references/framework/sui-framework/package#function-only_dep_upgrades
- `any_upgrade`: Allow any upgrade.
- `code_upgrade`: Upgrade policy to just add code. https://docs.sui.io/references/framework/sui-framework/package#function-only_additive_upgrades
- `dep_upgrade`: Upgrade policy to just change dependencies. https://docs.sui.io/references/framework/sui-framework/package#function-only_dep_upgrades

Provide `--txFilePath` with `--offline` to generate tx data file for offline signing.

Expand Down
10 changes: 5 additions & 5 deletions sui/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ async function deploy(contractName, config, chain, options) {
],
});

if (policy !== '0') {
const upgradeType = policy === '128' ? 'only_additive_upgrades' : 'only_dep_upgrades';
if (policy !== 'any_upgrade') {
const upgradeType = policy === 'code_upgrade' ? 'only_additive_upgrades' : 'only_dep_upgrades';

tx.moveCall({
target: `${suiPackageAddress}::package::${upgradeType}`,
Expand Down Expand Up @@ -206,9 +206,9 @@ if (require.main === module) {
.addOption(new Option('--nonce <nonce>', 'nonce for the signer (defaults to HashZero)'))
.addOption(new Option('--previousSigners <previousSigners>', 'number of previous signers to retain').default('15'))
.addOption(
new Option('--policy <policy>', 'upgrade policy for upgrade cap: For example, use "0" to allow all types of upgrades')
.choices(['0', '128', '192'])
.default('0'),
new Option('--policy <policy>', 'upgrade policy for upgrade cap: For example, use "any_upgrade" to allow all types of upgrades')
.choices(['any_upgrade', 'code_upgrade', 'dep_upgrade'])
.default('any_upgrade'),
)
.action((contractName, options) => {
mainProcessor([contractName], options, deploy);
Expand Down
4 changes: 2 additions & 2 deletions sui/deploy-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ async function upgradePackage(client, keypair, packageName, packageConfig, build
const { policy, offline } = options;
const sender = options.sender || keypair.toSuiAddress();

if (!['0', '128', '192'].includes(policy)) {
throw new Error(`Unknown upgrade policy: ${policy}`);
if (!['any_upgrade', 'code_upgrade', 'dep_upgrade'].includes(policy)) {
throw new Error(`Unknown upgrade policy: ${policy}. Supported policies: any_upgrade, code_upgrade, dep_upgrade`);
}

const upgradeCap = packageConfig.objects?.upgradeCap;
Expand Down

0 comments on commit 1cf6f5f

Please sign in to comment.