Skip to content

Commit

Permalink
update StagedContractUpdated.code to .codeHash: [UInt8]
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Jul 26, 2024
1 parent d912641 commit 525c207
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
14 changes: 7 additions & 7 deletions contracts/MigrationContractStaging.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ access(all) contract MigrationContractStaging {
access(all) event StagingStatusUpdated(
capsuleUUID: UInt64,
address: Address,
code: String,
codeHash: [UInt8],
contract: String,
action: String
)
Expand Down Expand Up @@ -112,7 +112,7 @@ access(all) contract MigrationContractStaging {
emit StagingStatusUpdated(
capsuleUUID: capsuleUUID,
address: address,
code: "",
codeHash: [],
contract: name,
action: "unstage"
)
Expand Down Expand Up @@ -158,7 +158,7 @@ access(all) contract MigrationContractStaging {

/// Returns the staged contract code hash for the given address and name or nil if it's not staged
///
access(all) view fun getStagedContractCodeHash(address: Address, name: String): String? {
access(all) view fun getStagedContractCodeHash(address: Address, name: String): [UInt8]? {
if let update = self.getStagedContractUpdate(address: address, name: name) {
return self.getCodeHash(update.code)
}
Expand Down Expand Up @@ -220,8 +220,8 @@ access(all) contract MigrationContractStaging {

/// Returns the hash of the given code, hashing with SHA3-256
///
access(all) fun getCodeHash(_ code: String): String {
return String.encodeHex(HashAlgorithm.SHA3_256.hash(code.utf8))
access(all) fun getCodeHash(_ code: String): [UInt8] {
return HashAlgorithm.SHA3_256.hash(code.utf8)
}

/* ------------------------------------------------------------------------------------------------------------ */
Expand Down Expand Up @@ -369,7 +369,7 @@ access(all) contract MigrationContractStaging {
emit StagingStatusUpdated(
capsuleUUID: self.uuid,
address: self.update.address,
code: MigrationContractStaging.getCodeHash(code),
codeHash: MigrationContractStaging.getCodeHash(code),
contract: self.update.name,
action: "replace"
)
Expand Down Expand Up @@ -423,7 +423,7 @@ access(all) contract MigrationContractStaging {
emit StagingStatusUpdated(
capsuleUUID: capsule.uuid,
address: host.address(),
code: MigrationContractStaging.getCodeHash(code),
codeHash: MigrationContractStaging.getCodeHash(code),
contract: name,
action: "stage"
)
Expand Down
Loading

0 comments on commit 525c207

Please sign in to comment.