From 93dd99b489e28201a02daa4ef4e1bf738480fe22 Mon Sep 17 00:00:00 2001 From: Giovanni Sanchez <108043524+sisyphusSmiling@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:05:44 -0500 Subject: [PATCH] update ContractUpdate.code from [UInt8] to String --- contracts/ContractUpdater.cdc | 10 +++++----- scripts/get_updater_deployment.cdc | 2 +- scripts/get_updater_info.cdc | 2 +- .../setup_updater_single_account_and_contract.cdc | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/ContractUpdater.cdc b/contracts/ContractUpdater.cdc index 1526916..9318a76 100644 --- a/contracts/ContractUpdater.cdc +++ b/contracts/ContractUpdater.cdc @@ -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 @@ -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!") } } @@ -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) } @@ -360,7 +360,7 @@ pub contract ContractUpdater { ContractUpdater.ContractUpdate( address: address, name: nameAndCode.keys[0], - code: nameAndCode.values[0].decodeHex() + code: nameAndCode.values[0] ) ) } diff --git a/scripts/get_updater_deployment.cdc b/scripts/get_updater_deployment.cdc index 5cc36b7..34c159a 100644 --- a/scripts/get_updater_deployment.cdc +++ b/scripts/get_updater_deployment.cdc @@ -34,7 +34,7 @@ pub fun main(address: Address): [[ContractUpdateReadable]]? { ContractUpdateReadable( address: contractUpdate.address, name: contractUpdate.name, - code: contractUpdate.stringifyCode() + code: contractUpdate.codeAsCadence() ) ) } diff --git a/scripts/get_updater_info.cdc b/scripts/get_updater_info.cdc index 98c9c64..7613a0c 100644 --- a/scripts/get_updater_info.cdc +++ b/scripts/get_updater_info.cdc @@ -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() ) ) } diff --git a/transactions/setup_updater_single_account_and_contract.cdc b/transactions/setup_updater_single_account_and_contract.cdc index 37c4017..fed5aa1 100644 --- a/transactions/setup_updater_single_account_and_contract.cdc +++ b/transactions/setup_updater_single_account_and_contract.cdc @@ -23,7 +23,7 @@ transaction(blockUpdateBoundary: UInt64, contractName: String, code: String) { ContractUpdater.ContractUpdate( address: signer.address, name: contractName, - code: code.decodeHex() + code: code ) ]] ),