F
Flow7mo ago
Bohao

Bohao | Flow (2024-05-16)

[C0.42] Is it a bug or a feature? Does it work in C1.0?
log("Deploying the contract to the account: ".concat(childAddr.toString()))

// add the contract
childAcctRef.contracts.add(name: contractName, code: ftContract.code)

// check if the contract is deployed
let names = childAcctRef.contracts.names
if names.length > 0 {
log("The contracts in the account: ".concat(StringUtils.join(names, ",")))
} else {
log("No contract is deployed in the account")
}
log("Deploying the contract to the account: ".concat(childAddr.toString()))

// add the contract
childAcctRef.contracts.add(name: contractName, code: ftContract.code)

// check if the contract is deployed
let names = childAcctRef.contracts.names
if names.length > 0 {
log("The contracts in the account: ".concat(StringUtils.join(names, ",")))
} else {
log("No contract is deployed in the account")
}
Log result is No contract is deployed in the account
No description
4 Replies
Needle
Needle7mo ago
I've created a thread for your message. Please continue any relevant discussion in this thread. You can rename this thread using /title <new title> If this is a technical question that others may benefit from, considering also asking it on Stackoverflow: https://stackoverflow.com/questions/ask?tags=onflow-cadence
turbolent
turbolent7mo ago
This behaviour is correct, and the same in the current version of Cadence (v0.42) nd the upcoming version (v1.0). Contract deployments are only effective after the transaction completed (i.e. in the next transaction). We might improve that in the future, feel free to open a feature request
Bohao
BohaoOP7mo ago
Got it. so it is not possible to register a new deployed ft contract to my token list in same transaction for now. (Borrow ViewResolver will be failed in the same transaction) Will open a feature request
Bohao
BohaoOP7mo ago
GitHub
Let new added contract be accessable in the same transaction after ...
Issue to be solved log("Deploying the contract to the account: ".concat(childAddr.toString())) // add the contract childAcctRef.contracts.add(name: contractName, code: ftContract.code) //...
Want results from more Discord servers?
Add your server