{"version":3,"file":"get-or-create-kmd-wallet-account.mjs","sources":["../../src/localnet/get-or-create-kmd-wallet-account.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { AlgoAmount } from '../types/amount'\nimport { ClientManager } from '../types/client-manager'\nimport { KmdAccountManager } from '../types/kmd-account-manager'\nimport Account = algosdk.Account\nimport Algodv2 = algosdk.Algodv2\nimport Kmd = algosdk.Kmd\n\n/**\n * @deprecated use `algorand.account.kmd.getOrCreateWalletAccount(name, fundWith)` or `new KMDAccountManager(clientManager).getOrCreateWalletAccount(name, fundWith)` instead.\n *\n * Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name.\n *\n * This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet).\n *\n * This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh LocalNet.\n *\n * If this is used via `mnemonicAccountFromEnvironment`, then you can even use the same code that runs on production without changes for local development!\n *\n * @param walletAccount The wallet details with:\n *   * `name`: The name of the wallet to retrieve / create\n *   * `fundWith`: The number of Algo to fund the account with when it gets created, if not specified then 1000 ALGO will be funded from the dispenser account\n * @param algod An algod client\n * @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables\n *\n * @returns An Algorand account with private key loaded - either one that already existed in the given KMD wallet, or a new one that is funded for you\n */\nexport async function getOrCreateKmdWalletAccount(\n  walletAccount: { name: string; fundWith?: AlgoAmount },\n  algod: Algodv2,\n  kmdClient?: Kmd,\n): Promise<Account> {\n  return (\n    await new KmdAccountManager(new ClientManager({ algod, kmd: kmdClient })).getOrCreateWalletAccount(\n      walletAccount.name,\n      walletAccount.fundWith,\n    )\n  ).account\n}\n"],"names":[],"mappings":";;;AAQA;;;;;;;;;;;;;;;;;;AAkBG;AACI,eAAe,2BAA2B,CAC/C,aAAsD,EACtD,KAAc,EACd,SAAe,EAAA;AAEf,IAAA,OAAO,CACL,MAAM,IAAI,iBAAiB,CAAC,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAChG,aAAa,CAAC,IAAI,EAClB,aAAa,CAAC,QAAQ,CACvB,EACD,OAAO;AACX;;;;"}