-
Notifications
You must be signed in to change notification settings - Fork 9
/
unstage_contract.cdc
33 lines (28 loc) · 1.22 KB
/
unstage_contract.cdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import "MigrationContractStaging"
#interaction (
version: "1.1.0",
title: "Unstage Contract Update",
description: "Removes the staged contract code from the staging contract. Only the contract host can perform this action.",
language: "en-US",
)
/// Unstages the given contract from the staging contract. Only the contract host can perform this action.
/// After the transaction, the contract will no longer be staged for Cadence 1.0 migration.
///
/// For more context, see the repo - https://github.com/onflow/contract-updater
///
transaction(contractName: String) {
let host: &MigrationContractStaging.Host
prepare(signer: AuthAccount) {
// Assign Host reference
self.host = signer.borrow<&MigrationContractStaging.Host>(from: MigrationContractStaging.HostStoragePath)
?? panic("Host was not found in storage")
}
execute {
// Call staging contract, storing the contract code that will update during Cadence 1.0 migration
MigrationContractStaging.unstageContract(host: self.host, name: contractName)
}
post {
!MigrationContractStaging.isStaged(address: self.host.address(), name: contractName):
"Problem while unstaging update"
}
}