{"version":3,"file":"albedo.module.cjs","sources":["../../src/modules/albedo.module.ts"],"sourcesContent":["import albedo from '@albedo-link/intent';\n\nimport { ModuleInterface, ModuleType, WalletNetwork } from '../types';\nimport { parseError } from '../utils';\n\nexport const ALBEDO_ID = 'albedo';\n\nexport class AlbedoModule implements ModuleInterface {\n  moduleType: ModuleType = ModuleType.HOT_WALLET;\n\n  productId: string = ALBEDO_ID;\n  productName: string = 'Albedo';\n  productUrl: string = 'https://albedo.link/';\n  productIcon: string = 'https://stellar.creit.tech/wallet-icons/albedo.png';\n\n  async isAvailable(): Promise<boolean> {\n    return true;\n  }\n\n  async getAddress(): Promise<{ address: string }> {\n    return albedo\n      .publicKey({})\n      .then(result => ({ address: result.pubkey }))\n      .catch(e => {\n        throw parseError(e);\n      });\n  }\n\n  async signTransaction(\n    xdr: string,\n    opts?: {\n      networkPassphrase?: string;\n      address?: string;\n      path?: string;\n      submit?: boolean;\n      submitUrl?: string;\n    }\n  ): Promise<{ signedTxXdr: string; signerAddress?: string }> {\n    return albedo\n      .tx({\n        xdr,\n        pubkey: opts?.address,\n        network: opts?.networkPassphrase\n          ? opts.networkPassphrase === WalletNetwork.PUBLIC\n            ? AlbedoNetwork.PUBLIC\n            : AlbedoNetwork.TESTNET\n          : undefined,\n      })\n      .then(({ signed_envelope_xdr }) => ({\n        signedTxXdr: signed_envelope_xdr,\n        signerAddress: opts?.address,\n      }))\n      .catch(e => {\n        throw parseError(e);\n      });\n  }\n\n  async signAuthEntry(): Promise<{ signedAuthEntry: string; signerAddress?: string }> {\n    throw {\n      code: -3,\n      message: 'Albedo does not support the \"signAuthEntry\" function',\n    };\n  }\n\n  /**\n   * We understand that Albedo has a method to sign a message, but that method is not compatible with SEP-0043\n   */\n  async signMessage(): Promise<{ signedMessage: string; signerAddress?: string }> {\n    throw {\n      code: -3,\n      message: 'Albedo does not support the \"signMessage\" function',\n    };\n  }\n\n  async getNetwork(): Promise<{ network: string; networkPassphrase: string }> {\n    throw {\n      code: -3,\n      message: 'Albedo does not support the \"getNetwork\" function',\n    };\n  }\n}\n\nexport enum AlbedoNetwork {\n  PUBLIC = 'public',\n  TESTNET = 'testnet',\n}\n"],"names":["ModuleType","parseError","WalletNetwork","AlbedoNetwork"],"mappings":";;;;;;AAKO,MAAM,SAAS,GAAG;MAEZ,YAAY,CAAA;AAAzB,IAAA,WAAA,GAAA;AACE,QAAA,IAAA,CAAA,UAAU,GAAeA,gBAAU,CAAC,UAAU;QAE9C,IAAS,CAAA,SAAA,GAAW,SAAS;QAC7B,IAAW,CAAA,WAAA,GAAW,QAAQ;QAC9B,IAAU,CAAA,UAAA,GAAW,sBAAsB;QAC3C,IAAW,CAAA,WAAA,GAAW,oDAAoD;;AAE1E,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,OAAO,IAAI;;AAGb,IAAA,MAAM,UAAU,GAAA;AACd,QAAA,OAAO;aACJ,SAAS,CAAC,EAAE;AACZ,aAAA,IAAI,CAAC,MAAM,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;aAC3C,KAAK,CAAC,CAAC,IAAG;AACT,YAAA,MAAMC,gBAAU,CAAC,CAAC,CAAC;AACrB,SAAC,CAAC;;AAGN,IAAA,MAAM,eAAe,CACnB,GAAW,EACX,IAMC,EAAA;AAED,QAAA,OAAO;AACJ,aAAA,EAAE,CAAC;YACF,GAAG;YACH,MAAM,EAAE,IAAI,EAAE,OAAO;YACrB,OAAO,EAAE,IAAI,EAAE;AACb,kBAAE,IAAI,CAAC,iBAAiB,KAAKC,mBAAa,CAAC;sBACvCC,qBAAa,CAAC;sBACdA,qBAAa,CAAC;AAClB,kBAAE,SAAS;SACd;aACA,IAAI,CAAC,CAAC,EAAE,mBAAmB,EAAE,MAAM;AAClC,YAAA,WAAW,EAAE,mBAAmB;YAChC,aAAa,EAAE,IAAI,EAAE,OAAO;AAC7B,SAAA,CAAC;aACD,KAAK,CAAC,CAAC,IAAG;AACT,YAAA,MAAMF,gBAAU,CAAC,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