Right now the create account TX template definition looks like this:
def create_account_template(
*,
keys: list[AccountKey],
reference_block_id: bytes = None,
payer: cadence.Address = None,
proposal_key: ProposalKey = None,
contracts: dict[Annotated[str, "name"], Annotated[str, "source"]] = None
) -> Tx:
if keys:
cadence_public_keys = cadence.Array([cadence.String(k.hex()) for k in keys])
else:
cadence_public_keys = cadence.Array([])
if contracts:
cadence_contracts = cadence.Dictionary(
[
cadence.KeyValuePair(
cadence.String(k), cadence.String(v.encode("utf-8").hex())
)
for (k, v) in contracts.items()
]
)
else:
cadence_contracts = cadence.Dictionary([])
tx = (
Tx(
code="""
transaction(publicKeys: [String], contracts:{String: String}) {
prepare(signer: AuthAccount) {
let acct = AuthAccount(payer: signer)
for key in publicKeys {
acct.addPublicKey(key.decodeHex())
}
for contract in contracts.keys {
acct.contracts.add(name: contract, code: contracts[contract]!.decodeHex())
}
}
}
""",
reference_block_id=reference_block_id,
payer=payer,
proposal_key=proposal_key,
)
.add_arguments(cadence_public_keys)
.add_arguments(cadence_contracts)
)
The reference_block_id, payer, proposal_key parameters should be included in any transaction template.
The templates need a base class (or some common way) to be defined, so these parameters (and the logic of including them in the TX) don't need to be copied many times
Right now the create account TX template definition looks like this:
The reference_block_id, payer, proposal_key parameters should be included in any transaction template.
The templates need a base class (or some common way) to be defined, so these parameters (and the logic of including them in the TX) don't need to be copied many times