Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add stellar upgrader contract to the deploy-contract.js script #487

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cgorenflo
Copy link

@cgorenflo cgorenflo commented Dec 24, 2024

AXE-6746

@cgorenflo cgorenflo requested a review from a team as a code owner December 24, 2024 00:19
const newWasmHash = await uploadWasm(wasmPath, wallet, chain);
printInfo('New Wasm hash', serializeValue(newWasmHash));

const operation = Operation.invokeContractFunction({
contract: contractAddress,
contract: chain.contracts.upgrader.address,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include this in the validation above as well in case it's not been deployed/present in the config

nativeToScVal(options.newVersion),
nativeToScVal(newWasmHash),
nativeToScVal([options.migrationData]),
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
],
].map(nativeToScVal),

Can use a map instead

await broadcast(operation, wallet, chain, 'Upgraded contract', options);
chain.contracts[contractName].wasmHash = serializeValue(newWasmHash);
printInfo('Contract upgraded successfully!', contractAddress);
}

async function createUpgradeAuths(contractAddress, newWasmHash, migrationData, chain, wallet) {
// 20 seems a reasonable number of ledgers to allow for the upgrade to take effect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a global constant for it. Could also create an option with a default of 20 though I don't see us configuring it

);
}

const createAuthorizedFunc = (contractAddress, functionName, args) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to the stellar utils.js

@@ -200,6 +245,8 @@ function main() {
.description('Upgrade a Stellar contract')
.argument('<contract-name>', 'contract name to deploy')
.addOption(new Option('--wasm-path <wasmPath>', 'path to the WASM file'))
.addOption(new Option('--new-version <newVersion>', 'new version of the contract'))
.addOption(new Option('--migration-data <migrationData>', 'migration data'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an upgrade usage example in the stellar/README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants