Skip to content

Commit

Permalink
update ContractUpdate.code from [UInt8] to String
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Sep 22, 2023
1 parent b265478 commit 93dd99b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions contracts/ContractUpdater.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ pub contract ContractUpdater {
pub struct ContractUpdate {
pub let address: Address
pub let name: String
pub let code: [UInt8]
pub let code: String

init(address: Address, name: String, code: [UInt8]) {
init(address: Address, name: String, code: String) {
self.address = address
self.name = name
self.code = code
Expand All @@ -65,7 +65,7 @@ pub contract ContractUpdater {
}

/// Returns code as a String
pub fun stringifyCode(): String {
pub fun codeAsCadence(): String {
return String.fromUTF8(self.code) ?? panic("Problem stringifying code!")
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ pub contract ContractUpdater {
// updatedContracts.append(contractUpdate.toString())
// }
// }
account.contracts.update__experimental(name: contractUpdate.name, code: contractUpdate.code)
account.contracts.update__experimental(name: contractUpdate.name, code: contractUpdate.code.decodeHex())
if !updatedAddresses.contains(account.address) {
updatedAddresses.append(account.address)
}
Expand Down Expand Up @@ -360,7 +360,7 @@ pub contract ContractUpdater {
ContractUpdater.ContractUpdate(
address: address,
name: nameAndCode.keys[0],
code: nameAndCode.values[0].decodeHex()
code: nameAndCode.values[0]
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/get_updater_deployment.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fun main(address: Address): [[ContractUpdateReadable]]? {
ContractUpdateReadable(
address: contractUpdate.address,
name: contractUpdate.name,
code: contractUpdate.stringifyCode()
code: contractUpdate.codeAsCadence()
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/get_updater_info.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fun main(address: Address): {Int: {Address: [ContractUpdateReadable]}}? {
data[contractUpdate.address]!.append(
ContractUpdateReadable(
name: contractUpdate.name,
code: contractUpdate.stringifyCode()
code: contractUpdate.codeAsCadence()
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion transactions/setup_updater_single_account_and_contract.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ transaction(blockUpdateBoundary: UInt64, contractName: String, code: String) {
ContractUpdater.ContractUpdate(
address: signer.address,
name: contractName,
code: code.decodeHex()
code: code
)
]]
),
Expand Down

0 comments on commit 93dd99b

Please sign in to comment.