UNPKG

@creit.tech/stellar-wallets-kit

Version:
1 lines 4.2 kB
{"version":3,"file":"lobstr.module.cjs","sources":["../../src/modules/lobstr.module.ts"],"sourcesContent":["import { isConnected, getPublicKey, signTransaction } from '@lobstrco/signer-extension-api';\nimport { ModuleInterface, ModuleType } from '../types';\nimport { parseError } from '../utils';\n\nexport const LOBSTR_ID = 'lobstr';\n\nexport class LobstrModule implements ModuleInterface {\n moduleType: ModuleType = ModuleType.HOT_WALLET;\n\n productId: string = LOBSTR_ID;\n productName: string = 'LOBSTR';\n productUrl: string = 'https://lobstr.co';\n productIcon: string = 'https://stellar.creit.tech/wallet-icons/lobstr.png';\n\n async isAvailable(): Promise<boolean> {\n return isConnected();\n }\n\n async getAddress(): Promise<{ address: string }> {\n const runChecks = async () => {\n if (!(await isConnected())) {\n throw new Error(`Lobstr is not connected`);\n }\n };\n\n return runChecks()\n .then(() => getPublicKey())\n .then(address => ({ address }))\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 const runChecks = async () => {\n if (!(await isConnected())) {\n throw new Error(`Lobstr is not connected`);\n }\n\n if (opts?.address) {\n console.warn(`Lobstr doesn't allow specifying what public key should sign the transaction, we skip the value`);\n }\n\n if (opts?.networkPassphrase) {\n console.warn(`Lobstr doesn't allow specifying the network that should be used, we skip the value`);\n }\n };\n\n return runChecks()\n .then(() => signTransaction(xdr))\n .then(signedTxXdr => ({ signedTxXdr }))\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: 'Lobstr does not support the \"signAuthEntry\" function',\n };\n }\n\n async signMessage(): Promise<{ signedMessage: string; signerAddress?: string }> {\n throw {\n code: -3,\n message: 'Lobstr does not support the \"signMessage\" function',\n };\n }\n\n async getNetwork(): Promise<{ network: string; networkPassphrase: string }> {\n throw {\n code: -3,\n message: 'Lobstr does not support the \"getNetwork\" function',\n };\n }\n}\n"],"names":["ModuleType","isConnected","getPublicKey","parseError","signTransaction"],"mappings":";;;;;;AAIO,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,mBAAmB;QACxC,IAAW,CAAA,WAAA,GAAW,oDAAoD;;AAE1E,IAAA,MAAM,WAAW,GAAA;QACf,OAAOC,8BAAW,EAAE;;AAGtB,IAAA,MAAM,UAAU,GAAA;AACd,QAAA,MAAM,SAAS,GAAG,YAAW;AAC3B,YAAA,IAAI,EAAE,MAAMA,8BAAW,EAAE,CAAC,EAAE;AAC1B,gBAAA,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,CAAyB,CAAC;;AAE9C,SAAC;AAED,QAAA,OAAO,SAAS;AACb,aAAA,IAAI,CAAC,MAAMC,+BAAY,EAAE;aACzB,IAAI,CAAC,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC;aAC7B,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,MAAM,SAAS,GAAG,YAAW;AAC3B,YAAA,IAAI,EAAE,MAAMF,8BAAW,EAAE,CAAC,EAAE;AAC1B,gBAAA,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,CAAyB,CAAC;;AAG5C,YAAA,IAAI,IAAI,EAAE,OAAO,EAAE;AACjB,gBAAA,OAAO,CAAC,IAAI,CAAC,CAAA,8FAAA,CAAgG,CAAC;;AAGh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