diff --git a/custom_account_setup_qa.cdc b/custom_account_setup_qa.cdc index c6c96d44..549225bc 100644 --- a/custom_account_setup_qa.cdc +++ b/custom_account_setup_qa.cdc @@ -1,29 +1,32 @@ import NonFungibleToken from 0x631e88ae7f1d7c20 import Electables from 0x4c05c3d3499ca274 +import Crypto -transaction(publicKeys: [String], contracts: {String: String}) { +transaction(publicKeys: [Crypto.KeyListEntry], contracts: {String: String}) { prepare(signer: AuthAccount) { - let acct = AuthAccount(payer: signer) + let account = AuthAccount(payer: signer) + // add all the keys to the account for key in publicKeys { - acct.addPublicKey(key.decodeHex()) + account.keys.add(publicKey: key.publicKey, hashAlgorithm: key.hashAlgorithm, weight: key.weight) } + // add contracts if provided for contract in contracts.keys { - acct.contracts.add(name: contract, code: contracts[contract]!.decodeHex()) + account.contracts.add(name: contract, code: contracts[contract]!.decodeHex()) } - if acct.borrow<&Electables.Collection>(from: Electables.CollectionStoragePath) == nil { + if account.borrow<&Electables.Collection>(from: Electables.CollectionStoragePath) == nil { // create a new empty collection let collection <- Electables.createEmptyCollection() // save it to the account - acct.save(<- collection, to: Electables.CollectionStoragePath) + account.save(<- collection, to: Electables.CollectionStoragePath) // Creates a public capability for the collection so that other users can publicly access electable attributes. // The pieces inside of the brackets specify the type of the linked object, and only expose the fields and // functions on those types. - acct.link<&Electables.Collection{NonFungibleToken.CollectionPublic, Electables.ElectablesPublicCollection}>( + account.link<&Electables.Collection{NonFungibleToken.CollectionPublic, Electables.ElectablesPublicCollection}>( Electables.CollectionPublicPath, target: Electables.CollectionStoragePath ) }