"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { BaseWallet: () => BaseWallet, DeflyWallet: () => DeflyWallet, ExodusWallet: () => ExodusWallet, KmdWallet: () => KmdWallet, MnemonicWallet: () => MnemonicWallet, NetworkId: () => NetworkId, PeraWallet: () => PeraWallet, StorageAdapter: () => StorageAdapter, WalletConnect: () => WalletConnect, WalletId: () => WalletId, WalletManager: () => WalletManager, defaultState: () => defaultState }); module.exports = __toCommonJS(src_exports); // src/manager.ts var import_store10 = require("@tanstack/store"); var import_algosdk10 = __toESM(require("algosdk"), 1); // src/network.ts var NetworkId = /* @__PURE__ */ ((NetworkId2) => { NetworkId2["MAINNET"] = "mainnet"; NetworkId2["TESTNET"] = "testnet"; NetworkId2["BETANET"] = "betanet"; NetworkId2["LOCALNET"] = "localnet"; return NetworkId2; })(NetworkId || {}); function isValidNetworkId(networkId) { return Object.values(NetworkId).includes(networkId); } function isNetworkConfigMap(config) { const networkKeys = Object.values(NetworkId); return Object.keys(config).some((key) => networkKeys.includes(key)); } var nodeServerMap = { ["mainnet" /* MAINNET */]: "https://mainnet-api.algonode.cloud", ["testnet" /* TESTNET */]: "https://testnet-api.algonode.cloud", ["betanet" /* BETANET */]: "https://betanet-api.algonode.cloud", ["localnet" /* LOCALNET */]: "http://localhost" }; function createDefaultNetworkConfig() { return Object.values(NetworkId).reduce((acc, value) => { acc[value] = { token: "", baseServer: nodeServerMap[value], port: "", headers: {} }; return acc; }, {}); } var caipChainId = { ["mainnet" /* MAINNET */]: "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k", ["testnet" /* TESTNET */]: "algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe", ["betanet" /* BETANET */]: "algorand:mFgazF-2uRS1tMiL9dsj01hJGySEmPN2" }; // src/storage.ts var StorageAdapter = class { static getItem(key) { if (typeof window === "undefined") { return null; } return localStorage.getItem(key); } static setItem(key, value) { if (typeof window === "undefined") { return; } localStorage.setItem(key, value); } }; // src/wallets/base.ts var BaseWallet = class { id; metadata; store; getAlgodClient; subscribe; constructor({ id, metadata, store, subscribe, getAlgodClient }) { this.id = id; this.store = store; this.subscribe = subscribe; this.getAlgodClient = getAlgodClient; const ctor = this.constructor; this.metadata = { ...ctor.defaultMetadata, ...metadata }; } static defaultMetadata = { name: "Base Wallet", icon: "" }; setActive() { console.info(`[Wallet] Set active wallet: ${this.id}`); setActiveWallet(this.store, { walletId: this.id }); } setActiveAccount(account) { console.info(`[Wallet] Set active account: ${account}`); setActiveAccount(this.store, { walletId: this.id, address: account }); } // ---------- Derived Properties ------------------------------------ // get name() { return this.id.toUpperCase(); } get accounts() { const state = this.store.state; const walletState = state.wallets[this.id]; return walletState ? walletState.accounts : []; } get addresses() { return this.accounts.map((account) => account.address); } get activeAccount() { const state = this.store.state; const walletState = state.wallets[this.id]; return walletState ? walletState.activeAccount : null; } get activeAddress() { return this.activeAccount?.address ?? null; } get activeNetwork() { const state = this.store.state; return state.activeNetwork; } get isConnected() { const state = this.store.state; const walletState = state.wallets[this.id]; return walletState ? walletState.accounts.length > 0 : false; } get isActive() { const state = this.store.state; return state.activeWallet === this.id; } // ---------- Protected Methods ------------------------------------- // onDisconnect() { removeWallet(this.store, { walletId: this.id }); } }; // src/wallets/defly.ts var import_algosdk9 = __toESM(require("algosdk"), 1); // src/utils.ts var import_algosdk8 = __toESM(require("algosdk"), 1); // src/wallets/types.ts var WalletId = /* @__PURE__ */ ((WalletId2) => { WalletId2["DEFLY"] = "defly"; WalletId2["EXODUS"] = "exodus"; WalletId2["KIBISIS"] = "kibisis"; WalletId2["KMD"] = "kmd"; WalletId2["LUTE"] = "lute"; WalletId2["MNEMONIC"] = "mnemonic"; WalletId2["PERA"] = "pera"; WalletId2["WALLETCONNECT"] = "walletconnect"; return WalletId2; })(WalletId || {}); // src/wallets/exodus.ts var import_algosdk = __toESM(require("algosdk"), 1); var icon = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjUuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMDAgMzAwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAzMDAgMzAwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Cgkuc3Qwe2ZpbGw6dXJsKCNTVkdJRF8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zUuMTAzOSIgZ3JhZGllbnRUcmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAtMSAwIDMwMikiPgoJCQk8c3RvcCAgb2Zmc2V0PSIwLjExOTgiIHN0eWxlPSJzdG9wLWNvbG9yOiM4OTUyRkY7c3RvcC1vcGFjaXR5OjAuODciLz4KCQkJPHN0b3AgIG9mZnNldD0iMSIgc3R5bGU9InN0b3AtY29sb3I6I0RBQkRGRjtzdG9wLW9wYWNpdHk6MCIvPgoJCTwvbGluZWFyR3JhZGllbnQ+CgkJCgkJCTxyZWN0IHg9IjI1LjQiIHk9IjIzIiBzdHlsZT0iZmlsbDp1cmwoI1NWR0lEXzAwMDAwMTA5MDE5OTE4NTU3NzczMDUzNDIwMDAwMDE3NjAyNDA1OTA4MDY3MTIwMzAwXyk7IiB3aWR0aD0iMjQ3LjYiIGhlaWdodD0iMjU0Ii8+Cgk8L2c+CjwvZz4KPC9zdmc+Cg=="; var ExodusWallet = class extends BaseWallet { client = null; options; store; constructor({ id, store, subscribe, getAlgodClient, options = {}, metadata = {} }) { super({ id, metadata, getAlgodClient, store, subscribe }); this.options = options; this.store = store; } static defaultMetadata = { name: "Exodus", icon }; async initializeClient() { console.info("[ExodusWallet] Initializing client..."); if (typeof window === "undefined" || window.algorand === void 0) { throw new Error("Exodus is not available."); } const client = window.algorand; this.client = client; return client; } async connect() { console.info("[ExodusWallet] Connecting..."); try { const client = this.client || await this.initializeClient(); const { accounts } = await client.enable(this.options); if (accounts.length === 0) { throw new Error("No accounts found!"); } const walletAccounts = accounts.map((address, idx) => ({ name: `Exodus Wallet ${idx + 1}`, address })); const activeAccount = walletAccounts[0]; addWallet(this.store, { walletId: this.id, wallet: { accounts: walletAccounts, activeAccount } }); return walletAccounts; } catch (error) { if (error.name === "UserRejectedRequestError") { console.info("[ExodusWallet] Connection cancelled."); } else { console.error(`[ExodusWallet] Error connecting: ${error.message}`); } return []; } } async disconnect() { console.info("[ExodusWallet] Disconnecting..."); this.onDisconnect(); } async resumeSession() { const state = this.store.state; const walletState = state.wallets[this.id]; if (!walletState) { return; } console.info("[ExodusWallet] Resuming session..."); if (window === void 0 || window.algorand === void 0 || window.algorand.isConnected !== true) { this.onDisconnect(); } } signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => { if (!this.client) { throw new Error("[ExodusWallet] Client not initialized!"); } const txnsToSign = []; const signedIndexes = []; const msgpackTxnGroup = normalizeTxnGroup(txnGroup); const decodedObjects = msgpackTxnGroup.map((txn) => { return import_algosdk.default.decodeObj(txn); }); decodedObjects.forEach((txnObject, idx) => { const isSigned = isSignedTxnObject(txnObject); const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx); const txnBuffer = msgpackTxnGroup[idx]; const txn = isSigned ? import_algosdk.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk.default.decodeUnsignedTransaction(txnBuffer); const txnBase64 = Buffer.from(txn.toByte()).toString("base64"); if (shouldSign) { txnsToSign.push({ txn: txnBase64 }); signedIndexes.push(idx); } else { txnsToSign.push({ txn: txnBase64, signers: [] }); } }); const signTxnsResult = await this.client.signTxns(txnsToSign); const signedTxnsBase64 = signTxnsResult.filter(Boolean); const signedTxns = signedTxnsBase64.map((txn) => new Uint8Array(Buffer.from(txn, "base64"))); const txnGroupSigned = mergeSignedTxnsWithGroup( signedTxns, msgpackTxnGroup, signedIndexes, returnGroup ); return txnGroupSigned; }; transactionSigner = async (txnGroup, indexesToSign) => { if (!this.client) { throw new Error("[ExodusWallet] Client not initialized!"); } const txnsToSign = txnGroup.reduce((acc, txn, idx) => { const txnBase64 = Buffer.from(txn.toByte()).toString("base64"); if (indexesToSign.includes(idx)) { acc.push({ txn: txnBase64 }); } else { acc.push({ txn: txnBase64, signers: [] }); } return acc; }, []); const signTxnsResult = await this.client.signTxns(txnsToSign); const signedTxnsBase64 = signTxnsResult.filter(Boolean); const signedTxns = signedTxnsBase64.map((txn) => new Uint8Array(Buffer.from(txn, "base64"))); return signedTxns; }; }; // src/wallets/kibisis.ts var import_algosdk2 = __toESM(require("algosdk"), 1); var ARC_0027_PREFIX = "arc0027"; var ARC_0027_CHANNEL_NAME = `${ARC_0027_PREFIX}:channel`; var ARC_0027_ENABLE_REQUEST = `${ARC_0027_PREFIX}:enable:request`; var ARC_0027_GET_PROVIDERS_REQUEST = `${ARC_0027_PREFIX}:get_providers:request`; var ARC_0027_PROVIDER_ID = "f6d1c86b-4493-42fb-b88d-a62407b4cdf6"; var ARC_0027_SIGN_TXNS_REQUEST = `${ARC_0027_PREFIX}:sign_txns:request`; var UNKNOWN_ERROR = 4e3; var METHOD_TIMED_OUT_ERROR = 4002; var METHOD_NOT_SUPPORTED_ERROR = 4003; var NETWORK_NOT_SUPPORTED_ERROR = 4004; var DEFAULT_REQUEST_TIMEOUT = 18e4; var LOWER_REQUEST_TIMEOUT = 750; var icon2 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnMiIKICAgdmlld0JveD0iMCAwIDEzNjUuMzMzMyAxMzY1LjMzMzMiCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGgKICAgIGQ9Im0gNjY3Ljk5OTk4LDEwNDguNjY2MiBjIDAsLTY0LjE2Njk4IC0wLjYyMDQ0LC0xMjguODE2OTggLTEuMzc4NzcsLTE0My42NjY3IC0yLjgxMTA3LC01NS4wNDczNyAtMTIuMDY3NDksLTkzLjA1MjU5IC0zMy4yNDA1OSwtMTM2LjQ3OTkyIC0yMS41MDczNCwtNDQuMTEyODkgLTUxLjA3MDU3LC04Mi42MzAyMiAtODQuNzM2ODYsLTExMC40MDE5OCAtMjMuNjQ4MjEsLTE5LjUwNzcxIC0yOS4zOTQ4NCwtMjMuNTc5NjMgLTUzLjU5NzA3LC0zNy45Nzc1NSAtMTAuMzU1NTMsLT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SAtMjMuNjI2NzMsMTAuOTYxMjcgLTQzLjMzMzMzLDIxLjUzNzYgLTUwLjMyMTQsMjcuMDA3MDIgLTExMi4xODU5NCw4Ny4zMjgyNCAtMTQxLjMzMzMzLDEzNy44MDc1MSAtMy4xODgxNyw1LjUyMTQ4IC00Ljg3MjYxLDguNDkzMjEgLTYuNjEyOTIsMTEuNjY2NjYgLTAuNzAzNzcsMS4yODMzNCAtMi42NTk1Niw0LjczMzM0IC00LjM0NjIxLDcuNjY2NjcgLTIuODAxNjUsNC44NzI1MyAtMTMuMzgzMjEsMjcuMzY0OTIgLTE2LjYwNzMxLDM1LjMwMDg1IC0xLjI0MDQ5LDMuMDUzNDQgLTEuNjQ5NDYsMi41MDM3NiAtNS40NTYsLTcuMzMzMzMgeiBtIC0xNzAuOTk3OTcsOTkuNjk5MTQgYyAtMC4wMTA3LC05MS40ODMzMyAtMC40NjEyMiwtMTY3LjAwNDkgLTEsLTE2Ny44MjU3IC0xLjI3NzQ4LC0xLjk0NjIgLTIwLjMzMzcyLC0xNy4wNDQ2OSAtMjMuOTY2MzIsLTE4Ljk4ODggLTEuNTQyOTMsLTAuODI1NzUgLTMuNjAyMTIsLTIuMjc5NDMgLTQuNTc1OTYsLTMuMjMwMzkgLTMuNDkwNDEsLTMuNDA4MzYgLTIxLjgzNjgzLC0xMy4yMTIyNiAtMjUuMTAzOTcsLTEzLjQxNDk2IGwgLTMuMzMzMzMsLTAuMjA2ODEgLTAuMzM4MDEsMTg1IC0wLjMzODAyLDE4NC45OTk5NSBoIDI5LjMzODAxIDI5LjMzODAyIHoiCiAgICBmaWxsPSIjOGMwMTlhIiAvPgo8L3N2Zz4K"; function isResponseError(error) { return typeof error === "object" && "code" in error && "message" in error; } var KibisisWallet = class _KibisisWallet extends BaseWallet { methods = []; store; constructor({ id, store, subscribe, getAlgodClient, metadata = {} }) { super({ id, metadata, getAlgodClient, store, subscribe }); this.store = store; } static defaultMetadata = { name: "Kibisis", icon: icon2 }; static async sendRequestWithTimeout({ method, params, timeout, reference }) { return new Promise((resolve, reject) => { const channel = new BroadcastChannel(ARC_0027_CHANNEL_NAME); const requestId = generateUuid(); let timer; channel.onmessage = (message) => { if (!message.data || message.data.requestId !== requestId) { return; } window.clearTimeout(timer); if (message.data.error) { reject(message.data.error); return channel.close(); } resolve(message.data.result); return channel.close(); }; timer = window.setTimeout(() => { channel.close(); reject({ code: METHOD_TIMED_OUT_ERROR, data: { method }, message: `No response from provider "${"kibisis" /* KIBISIS */.toUpperCase()}"`, providerId: ARC_0027_PROVIDER_ID }); }, timeout || DEFAULT_REQUEST_TIMEOUT); channel.postMessage({ id: requestId, params, reference }); }); } /** * Calls the enable method on the provider that returns the authorized accounts. * @returns {Arc0027Account[]} the authorized accounts. * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user. * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network. * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response. * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network. * @throws {UNKNOWN_ERROR} if the response result was empty. */ async enable() { const method = "enable"; this.validateMethod(method); const genesisHash = await this.getGenesisHash(); const result = await _KibisisWallet.sendRequestWithTimeout({ method, params: { genesisHash, providerId: ARC_0027_PROVIDER_ID }, reference: ARC_0027_ENABLE_REQUEST }); if (!result) { throw { code: UNKNOWN_ERROR, message: `Received response, but "${method}" request details were empty for provider "${this.name}"`, providerId: ARC_0027_PROVIDER_ID }; } return result.accounts; } /** * Gets the genesis hash of the algod client's configured network. * @returns {string} the genesis hash */ async getGenesisHash() { const algodClient = this.getAlgodClient(); const version = await algodClient.versionsCheck().do(); const genesisHash = version.genesis_hash_b64; return genesisHash; } /** * Gets the provider information and updates the supported methods. This should be called * before interacting with the provider to ensure methods are supported. * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response. * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network. * @throws {UNKNOWN_ERROR} if the response result was empty. */ async getSupportedMethods() { const genesisHash = await this.getGenesisHash(); const result = await _KibisisWallet.sendRequestWithTimeout({ method: "getProviders", params: { providerId: ARC_0027_PROVIDER_ID }, reference: ARC_0027_GET_PROVIDERS_REQUEST, timeout: LOWER_REQUEST_TIMEOUT }); if (!result) { throw { code: UNKNOWN_ERROR, message: `Received response, but provider details were empty for provider "${this.name}"`, providerId: ARC_0027_PROVIDER_ID }; } const networkConfiguration = result.networks.find((value) => value.genesisHash === genesisHash); if (!networkConfiguration) { throw { code: NETWORK_NOT_SUPPORTED_ERROR, data: { genesisHash }, message: `Network "${this.activeNetwork}" not supported on provider "${this.name}"`, providerId: ARC_0027_PROVIDER_ID }; } this.methods = networkConfiguration.methods; } /** * Calls the signTxns methods to sign the supplied transactions. * @param {Arc0001SignTxns[]} txns - the unsigned or signed transactions as defined in ARC-0001. * @returns {(string | null)[]} the authorized accounts. * @throws {INVALID_INPUT_ERROR} if computed group ID for the txns does not match the assigned group ID. * @throws {INVALID_GROUP_ID_ERROR} if the unsigned txns is malformed or not conforming to ARC-0001. * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user. * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network. * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response. * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network. * @throws {UNAUTHORIZED_SIGNER_ERROR} if a signer in the request is not authorized by the provider. * @throws {UNKNOWN_ERROR} if the response result was empty. */ async signTxns(txns) { const method = "signTxns"; this.validateMethod(method); const result = await _KibisisWallet.sendRequestWithTimeout({ method, params: { providerId: ARC_0027_PROVIDER_ID, txns }, reference: ARC_0027_SIGN_TXNS_REQUEST }); if (!result) { throw { code: UNKNOWN_ERROR, message: `Received response, but "${method}" request details were empty for provider "${this.name}"`, providerId: ARC_0027_PROVIDER_ID }; } return result.stxns; } /** * Validates whether a method is supported with the provider. * @param {ProviderMethod} method - the method to validate. * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network. */ validateMethod(method) { if (!this.methods.includes(method)) { throw { code: METHOD_NOT_SUPPORTED_ERROR, data: { method }, message: `"${method}" operation not supported on "${this.activeNetwork}" for provider "${this.name}"`, providerId: ARC_0027_PROVIDER_ID }; } } async connect() { console.info("[KibisisWallet] Connecting..."); try { await this.getSupportedMethods(); const accounts = await this.enable(); const walletAccounts = accounts.map(({ address, name }, idx) => ({ name: name || `Kibisis Wallet ${idx + 1}`, address })); const activeAccount = walletAccounts[0]; addWallet(this.store, { walletId: this.id, wallet: { accounts: walletAccounts, activeAccount } }); return walletAccounts; } catch (error) { console.error(`[KibisisWallet] Error connecting: ${error.message}`); return []; } } async disconnect() { console.info("[KibisisWallet] Disconnecting..."); this.onDisconnect(); } resumeSession() { return Promise.resolve(); } signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => { try { await this.getSupportedMethods(); const txnsToSign = []; const signedIndexes = []; const msgpackTxnGroup = normalizeTxnGroup(txnGroup); const decodedObjects = msgpackTxnGroup.map((txn) => { return import_algosdk2.default.decodeObj(txn); }); decodedObjects.forEach((txnObject, idx) => { const isSigned = isSignedTxnObject(txnObject); const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx); const txnBuffer = msgpackTxnGroup[idx]; const txn = isSigned ? import_algosdk2.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk2.default.decodeUnsignedTransaction(txnBuffer); const txnBase64 = Buffer.from(txn.toByte()).toString("base64"); if (shouldSign) { txnsToSign.push({ txn: txnBase64 }); signedIndexes.push(idx); } else { txnsToSign.push({ txn: txnBase64, signers: [] }); } }); const signTxnsResult = await this.signTxns(txnsToSign); const signedTxnsBase64 = signTxnsResult.filter(Boolean); const signedTxns = signedTxnsBase64.map((txn) => new Uint8Array(Buffer.from(txn, "base64"))); const txnGroupSigned = mergeSignedTxnsWithGroup( signedTxns, msgpackTxnGroup, signedIndexes, returnGroup ); return txnGroupSigned; } catch (error) { console.error( `[KibisisWallet] Error signing transactions: ` + (isResponseError(error) ? `${error.message} (code: ${error.code})` : error.message) ); throw error; } }; transactionSigner = async (txnGroup, indexesToSign) => { try { const txnsToSign = txnGroup.reduce((acc, txn, idx) => { const txnBase64 = Buffer.from(txn.toByte()).toString("base64"); if (indexesToSign.includes(idx)) { acc.push({ txn: txnBase64 }); } else { acc.push({ txn: txnBase64, signers: [] }); } return acc; }, []); const signTxnsResult = await this.signTxns(txnsToSign); const signedTxnsBase64 = signTxnsResult.filter(Boolean); const signedTxns = signedTxnsBase64.map((txn) => new Uint8Array(Buffer.from(txn, "base64"))); return signedTxns; } catch (error) { console.error( `[KibisisWallet] Error signing transactions: ` + (isResponseError(error) ? `${error.message} (code: ${error.code})` : error.message) ); throw error; } }; }; // src/wallets/kmd.ts var import_algosdk3 = __toESM(require("algosdk"), 1); var icon3 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MDkuODMgMjEwLjMzIj48dGV4dCB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIDE2MS4zMSkiIHN0eWxlPSJmb250LWZhbWlseTpJQk1QbGV4U2Fucy1NZWRtLCAmYXBvcztJQk0gUGxleCBTYW5zJmFwb3M7OyBmb250LXNpemU6MTkwcHg7Ij48dHNwYW4geD0iMCIgeT0iMCI+S01EPC90c3Bhbj48L3RleHQ+PC9zdmc+"; var KmdWallet = class extends BaseWallet { client = null; options; walletName; walletId = ""; password = ""; store; constructor({ id, store, subscribe, getAlgodClient, options, metadata = {} }) { super({ id, metadata, getAlgodClient, store, subscribe }); const { token = "a".repeat(64), baseServer = "http://127.0.0.1", port = 4002, wallet = "unencrypted-default-wallet" } = options || {}; this.options = { token, baseServer, port }; this.walletName = wallet; this.store = store; } static defaultMetadata = { name: "KMD", icon: icon3 }; async initializeClient() { console.info("[KmdWallet] Initializing client..."); const { token, baseServer, port } = this.options; const client = new import_algosdk3.default.Kmd(token, baseServer, port); this.client = client; return client; } async connect() { console.info("[KmdWallet] Connecting..."); try { if (!this.client) { await this.initializeClient(); } const walletId = this.walletId || await this.fetchWalletId(); const token = await this.fetchToken(walletId, this.getPassword()); const accounts = await this.fetchAccounts(token); if (accounts.length === 0) { throw new Error("No accounts found!"); } const walletAccounts = accounts.map((address, idx) => ({ name: `KMD Wallet ${idx + 1}`, address })); const activeAccount = walletAccounts[0]; addWallet(this.store, { walletId: this.id, wallet: { accounts: walletAccounts, activeAccount } }); await this.releaseToken(token); return walletAccounts; } catch (error) { console.error("[KmdWallet] Error connecting:", error); return []; } } async disconnect() { console.info("[KmdWallet] Disconnecting..."); this.onDisconnect(); } resumeSession() { return Promise.resolve(); } signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => { if (!this.client) { throw new Error("[KmdWallet] Client not initialized!"); } const walletId = this.walletId || await this.fetchWalletId(); const password = this.getPassword(); const token = await this.fetchToken(walletId, password); const signTxnPromises = []; const signedIndexes = []; const msgpackTxnGroup = normalizeTxnGroup(txnGroup); const decodedObjects = msgpackTxnGroup.map((txn) => { return import_algosdk3.default.decodeObj(txn); }); decodedObjects.forEach((txnObject, idx) => { const isSigned = isSignedTxnObject(txnObject); const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx); const txnBuffer = msgpackTxnGroup[idx]; const txn = isSigned ? import_algosdk3.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk3.default.decodeUnsignedTransaction(txnBuffer); if (shouldSign) { signTxnPromises.push(this.client.signTransaction(token, password, txn)); signedIndexes.push(idx); } }); const signedTxns = await Promise.all(signTxnPromises); await this.releaseToken(token); const txnGroupSigned = mergeSignedTxnsWithGroup( signedTxns, msgpackTxnGroup, signedIndexes, returnGroup ); return txnGroupSigned; }; transactionSigner = async (txnGroup, indexesToSign) => { if (!this.client) { throw new Error("[KmdWallet] Client not initialized!"); } const walletId = this.walletId || await this.fetchWalletId(); const password = this.getPassword(); const token = await this.fetchToken(walletId, password); const signTxnPromises = []; txnGroup.forEach((txn, idx) => { if (indexesToSign.includes(idx)) { signTxnPromises.push(this.client.signTransaction(token, password, txn)); } }); const signedTxns = await Promise.all(signTxnPromises); return signedTxns; }; async fetchWalletId() { console.info("[KmdWallet] Fetching wallet data..."); if (!this.client) { throw new Error("Client not initialized!"); } const { wallets } = await this.client.listWallets(); const wallet = wallets.find((wallet2) => wallet2.name === this.walletName); if (!wallet) { throw new Error(`Wallet ${this.walletName} not found!`); } this.walletId = wallet.id; return wallet.id; } async fetchToken(walletId, password) { console.info("[KmdWallet] Fetching token..."); if (!this.client) { throw new Error("Client not initialized!"); } const { wallet_handle_token } = await this.client.initWalletHandle( walletId, password ); return wallet_handle_token; } async fetchAccounts(token) { console.info("[KmdWallet] Fetching accounts..."); if (!this.client) { throw new Error("Client not initialized!"); } const { addresses } = await this.client.listKeys(token); return addresses; } async releaseToken(token) { console.info("[KmdWallet] Releasing token..."); if (!this.client) { throw new Error("Client not initialized!"); } await this.client.releaseWalletHandle(token); } getPassword() { if (this.password) { return this.password; } const password = prompt("KMD password") || ""; this.password = password; return password; } }; // src/wallets/lute.ts var import_algosdk4 = __toESM(require("algosdk"), 1); function isSignTxnsError(error) { return error instanceof Error && "code" in error; } var svgIcon = ` `; var LuteWallet = class extends BaseWallet { client = null; options; store; constructor({ id, store, subscribe, getAlgodClient, options, metadata = {} }) { super({ id, metadata, getAlgodClient, store, subscribe }); if (!options?.siteName) { throw new Error("[LuteWallet] Missing required option: siteName"); } this.options = options; this.store = store; } static defaultMetadata = { name: "Lute", icon: `data:image/svg+xml;base64,${btoa(svgIcon.trim())}` }; async initializeClient() { console.info("[LuteWallet] Initializing client..."); const module2 = await import("lute-connect"); const LuteConnect = module2.default; const client = new LuteConnect(this.options.siteName); this.client = client; return client; } async getGenesisId() { const algodClient = this.getAlgodClient(); const genesis = await algodClient.genesis().do(); const genesisId = `${genesis.network}-${genesis.id}`; return genesisId; } async connect() { console.info("[LuteWallet] Connecting..."); try { const client = this.client || await this.initializeClient(); const genesisId = await this.getGenesisId(); const accounts = await client.connect(genesisId); if (accounts.length === 0) { throw new Error("No accounts found!"); } const walletAccounts = accounts.map((address, idx) => ({ name: `Lute Wallet ${idx + 1}`, address })); const activeAccount = walletAccounts[0]; addWallet(this.store, { walletId: this.id, wallet: { accounts: walletAccounts, activeAccount } }); return walletAccounts; } catch (error) { console.error(`[LuteWallet] Error connecting: ${error.message}`); return []; } } async disconnect() { console.info("[LuteWallet] Disconnecting..."); this.onDisconnect(); } resumeSession() { return Promise.resolve(); } signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => { try { if (!this.client) { throw new Error("[LuteWallet] Client not initialized!"); } const txnsToSign = []; const signedIndexes = []; const msgpackTxnGroup = normalizeTxnGroup(txnGroup); const decodedObjects = msgpackTxnGroup.map((txn) => { return import_algosdk4.default.decodeObj(txn); }); decodedObjects.forEach((txnObject, idx) => { const isSigned = isSignedTxnObject(txnObject); const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx); const txnBuffer = msgpackTxnGroup[idx]; const txn = isSigned ? import_algosdk4.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk4.default.decodeUnsignedTransaction(txnBuffer); const txnBase64 = Buffer.from(txn.toByte()).toString("base64"); if (shouldSign) { txnsToSign.push({ txn: txnBase64 }); signedIndexes.push(idx); } else { txnsToSign.push({ txn: txnBase64, signers: [] }); } }); const signTxnsResult = await this.client.signTxns(txnsToSign); const signedTxns = signTxnsResult.filter(Boolean); const txnGroupSigned = mergeSignedTxnsWithGroup( signedTxns, msgpackTxnGroup, signedIndexes, returnGroup ); return txnGroupSigned; } catch (error) { console.error( `[LuteWallet] Error signing transactions: ` + (isSignTxnsError(error) ? `${error.message} (code: ${error.code})` : error.message) ); throw error; } }; transactionSigner = async (txnGroup, indexesToSign) => { try { if (!this.client) { throw new Error("[LuteWallet] Client not initialized!"); } const txnsToSign = txnGroup.reduce((acc, txn, idx) => { const txnBase64 = Buffer.from(txn.toByte()).toString("base64"); if (indexesToSign.includes(idx)) { acc.push({ txn: txnBase64 }); } else { acc.push({ txn: txnBase64, signers: [] }); } return acc; }, []); const signTxnsResult = await this.client.signTxns(txnsToSign); const signedTxns = signTxnsResult.filter(Boolean); return signedTxns; } catch (error) { console.error( `[LuteWallet] Error signing transactions: ` + (isSignTxnsError(error) ? `${error.message} (code: ${error.code})` : error.message) ); throw error; } }; }; // src/wallets/mnemonic.ts var import_algosdk5 = __toESM(require("algosdk"), 1); var icon4 = `data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8'%3f%3e %3c!-- Generated by Pixelmator Pro 3.2.2 --%3e %3csvg width='409' height='210' viewBox='0 0 409 210' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctext id='MNEMONIC' xml:space='preserve' x='0' y='129' font-family='Helvetica' font-size='72' fill='black'%3eMNEMONIC%3c/text%3e%3c/svg%3e`; var MnemonicWallet = class extends BaseWallet { account = null; options; store; constructor({ id, store, subscribe, getAlgodClient, options, metadata = {} }) { super({ id, metadata, getAlgodClient, store, subscribe }); const { persistToStorage = false } = options || {}; this.options = { persistToStorage }; this.store = store; } static defaultMetadata = { name: "Mnemonic", icon: icon4 }; // @todo: Show explicit security warning if persistToStorage is true // @todo: Save/load mnemonic from storage if persistToStorage is true // @todo: Throw error with link to docs if using mainnet initializeAccount() { const mnemonic = prompt("Enter 25-word mnemonic passphrase:"); if (!mnemonic) { this.account = null; throw new Error("No mnemonic provided"); } const account = import_algosdk5.default.mnemonicToSecretKey(mnemonic); this.account = account; return account; } async connect() { console.info("[MnemonicWallet] Connecting..."); try { const account = this.initializeAccount(); const walletAccount = { name: "Mnemonic Account", address: account.addr }; addWallet(this.store, { walletId: this.id, wallet: { accounts: [walletAccount], activeAccount: walletAccount } }); return [walletAccount]; } catch (error) { console.error("[MnemonicWallet] Error connecting:", error); throw error; } } async disconnect() { console.info("[MnemonicWallet] Disconnecting..."); try { this.account = null; this.onDisconnect(); } catch (error) { console.error(error); } } async resumeSession() { const state = this.store.state; const walletState = state.wallets[this.id]; if (walletState) { try { this.account = null; this.onDisconnect(); } catch (error) { console.error(error); } } } signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => { if (!this.account) { throw new Error("[MnemonicWallet] Client not initialized!"); } const txnGroupSigned = []; const msgpackTxnGroup = normalizeTxnGroup(txnGroup); const decodedObjects = msgpackTxnGroup.map((txn) => { return import_algosdk5.default.decodeObj(txn); }); decodedObjects.forEach((txnObject, idx) => { const isIndexMatch = !indexesToSign || indexesToSign.includes(idx); const isSigned = isSignedTxnObject(txnObject); const canSign = !isSigned && import_algosdk5.default.encodeAddress(txnObject.snd) === this.account.addr; const shouldSign = isIndexMatch && canSign; if (shouldSign) { const txn = import_algosdk5.default.Transaction.from_obj_for_encoding(txnObject); const signedTxn = txn.signTxn(this.account.sk); txnGroupSigned.push(signedTxn); } else if (returnGroup) { txnGroupSigned.push(msgpackTxnGroup[idx]); } }); return Promise.resolve(txnGroupSigned); }; transactionSigner = async (txnGroup, indexesToSign) => { if (!this.account) { throw new Error("[MnemonicWallet] Account not initialized!"); } const signedTxns = []; for (const index of indexesToSign) { const txnToSign = txnGroup[index]; if (txnToSign) { signedTxns.push(txnToSign.signTxn(this.account.sk)); } } return Promise.resolve(signedTxns); }; }; // src/wallets/pera.ts var import_algosdk6 = __toESM(require("algosdk"), 1); var icon5 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNzcgMTg3Ij48cmVjdCB4PSItMTEuMzgiIHk9Ii0yNS45NyIgd2lkdGg9IjIwMC4wMiIgaGVpZ2h0PSIyMzEuNTMiIHN0eWxlPSJmaWxsO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IHN0eWxlPSJmaWxsOiMxYzFjMWM7Ii8+PHBhdGggZD0iTTcxLjY0LDk3LjcxYy0yLjA4LTIuMTUtOC44OCwuOTgtMTUuMiw2Ljk5LTYuMzIsNi4wMS05Ljc2LDEyLjYzLTcuNjksMTQuNzgsMi4wOCwyLjE1LDguODgtLjk4LDE1LjItNi45OSw2LjMyLTYuMDEsOS43Ni0xMi42Myw3LjY5LTE0Ljc4WiIgc3R5bGU9ImZpbGw6IzFjMWMxYzsiLz48L3N2Zz4="; var PeraWallet = class extends BaseWallet { client = null; options; store; constructor({ id, store, subscribe, getAlgodClient, options = {}, metadata = {} }) { super({ id, metadata, getAlgodClient, store, subscribe }); this.options = options; this.store = store; } static defaultMetadata = { name: "Pera", icon: icon5 }; async initializeClient() { console.info("[PeraWallet] Initializing client..."); const module2 = await import("@perawallet/connect"); const PeraWalletConnect = module2.default ? module2.default.PeraWalletConnect : module2.PeraWalletConnect; const client = new PeraWalletConnect(this.options); client.connector?.on("disconnect", this.onDisconnect); this.client = client; return client; } async connect() { console.info("[PeraWallet] Connecting..."); try { const client = this.client || await this.initializeClient(); const accounts = await client.connect(); if (accounts.length === 0) { throw new Error("No accounts found!"); } const walletAccounts = accounts.map((address, idx) => ({ name: `Pera Wallet ${idx + 1}`, address })); const activeAccount = walletAccounts[0]; addWallet(this.store, { walletId: this.id, wallet: { accounts: walletAccounts, activeAccount } }); return walletAccounts; } catch (error) { if (error?.data?.type !== "CONNECT_MODAL_CLOSED") { console.error(`[PeraWallet] Error connecting: ${error.message}`); } else { console.info("[PeraWallet] Connection cancelled."); } return []; } } async disconnect() { console.info("[PeraWallet] Disconnecting..."); try { await this.client?.disconnect(); this.onDisconnect(); } catch (error) { console.error(error); } } async resumeSession() { try { const state = this.store.state; const walletState = state.wallets[this.id]; if (!walletState) { return; } console.info("[PeraWallet] Resuming session..."); const client = this.client || await this.initializeClient(); const accounts = await client.reconnectSession(); if (accounts.length === 0) { throw new Error("[PeraWallet] No accounts found!"); } const walletAccounts = accounts.map((address, idx) => ({ name: `Pera Wallet ${idx + 1}`, address })); const match = compareAccounts(walletAccounts, walletState.accounts); if (!match) { console.warn(`[PeraWallet] Session accounts mismatch, updating accounts`); setAccounts(this.store, { walletId: this.id, accounts: walletAccounts }); } } catch (error) { console.error(error); this.onDisconnect(); } } signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => { if (!this.client) { throw new Error("[PeraWallet] Client not initialized!"); } const txnsToSign = []; const signedIndexes = []; const msgpackTxnGroup = normalizeTxnGroup(txnGroup); const decodedObjects = msgpackTxnGroup.map((txn) => { return import_algosdk6.default.decodeObj(txn); }); decodedObjects.forEach((txnObject, idx) => { const isSigned = isSignedTxnObject(txnObject); const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx); const txnBuffer = msgpackTxnGroup[idx]; const txn = isSigned ? import_algosdk6.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk6.default.decodeUnsignedTransaction(txnBuffer); if (shouldSign) { txnsToSign.push({ txn }); signedIndexes.push(idx); } else { txnsToSign.push({ txn, signers: [] }); } }); const signedTxns = await this.client.signTransaction([txnsToSign]); const txnGroupSigned = mergeSignedTxnsWithGroup( signedTxns, msgpackTxnGroup, signedIndexes, returnGroup ); return txnGroupSigned; }; transactionSigner = async (txnGroup, indexesToSign) => { if (!this.client) { throw new Error("[PeraWallet] Client not initialized!"); } const txnsToSign = txnGroup.reduce((acc, txn, idx) => { if (indexesToSign.includes(idx)) { acc.push({ txn }); } else { acc.push({ txn, signers: [] }); } return acc; }, []); const signTxnsResult = await this.client.signTransaction([txnsToSign]); return signTxnsResult; }; }; // src/wallets/walletconnect.ts var import_utils7 = require("@walletconnect/utils"); var import_algosdk7 = __toESM(require("algosdk"), 1); var icon6 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDov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yMTcuMSw0MDMuNiwyMTcuMSw0MDYuNywyMjAuMkw0MDYuNywyMjAuMnoiLz4KPC9zdmc+Cg=="; var WalletConnect = class extends BaseWallet { client = null; options; modal = null; modalOptions; session = null; chains; store; constructor({ id, store, subscribe, getAlgodClient, options, metadata = {} }) { super({ id, metadata, getAlgodClient, store, subscribe }); if (!options?.projectId) { throw new Error("[WalletConnect] Missing required option: projectId"); } const { projectId, relayUrl = "wss://relay.walletconnect.com", metadata: _metadata = (0, import_utils7.getAppMetadata)(), ...modalOptions } = options; this.options = { projectId, relayUrl, ..._metadata }; this.modalOptions = modalOptions; this.chains = Object.values(caipChainId); this.store = store; } static defaultMetadata = { name: "WalletConnect", icon: icon6 }; async initializeClient() { console.info("[WalletConnect] Initializing client..."); const SignClient = (await import("@walletconnect/sign-client")).SignClient; const client = await SignClient.init(this.options); client.on("session_event", (args) => { console.log("[WalletConnect] EVENT", "session_event", args); }); client.on("session_update", ({ topic, params }) => { console.log("[WalletConnect] EVENT", "session_update", { topic, params }); const { namespaces } = params; const session = client.session.get(topic); const updatedSession = { ...session, namespaces }; this.onSessionConnected(updatedSession); }); client.on("session_delete", () => { console.log("[WalletConnect] EVENT", "session_delete"); this.session = null; }); this.client = client; return client; } async initializeModal() { console.info("[WalletConnect] Initializing modal..."); const WalletConnectModal = (await import("@walletconnect/modal")).WalletConnectModal; const modal = new WalletConnectModal({ projectId: this.options.projectId, chains: this.chains, ...this.modalOptions }); modal.subscribeModal( (state) => console.info(`[WalletConnect] Modal ${state.open ? "open" : "closed"}`) ); this.modal = modal; return modal; } onSessionConnected(session) { const caipAccounts = session.namespaces.algorand.accounts; if (!caipAccounts.length) { throw new Error("No accounts found!"); } const accounts = [...new Set(caipAccounts.map((account) => account.split(":").pop()))]; const walletAccounts = accounts.map((address, idx) => ({ name: `WalletConnect ${idx + 1}`, address })); const state = this.store.state; const walletState = state.wallets[this.id]; if (!walletState) { addWallet(this.store, { walletId: this.id, wallet: { accounts: walletAccounts, activeAccount: walletAccounts[0] } }); } else { const match = compareAccounts(walletAccounts, walletState.accounts); if (!match) { console.warn(`[WalletConnect] Session accounts mismatch, updating accounts`); setAccounts(this.store, { walletId: this.id, accounts: walletAccounts }); } } this.session = session; return walletAccounts; } async connect() { console.info("[WalletConnect] Connecting..."); try { const client = this.client || await this.initializeClient(); const modal = this.modal || await this.initializeModal(); const requiredNamespaces = { algorand: { chains: this.chains, methods: ["algo_signTxn"], events: [] } }; const { uri, approval } = await client.connect({ requiredNamespaces }); if (!uri) { throw new Error("No URI found"); } await modal.openModal({ uri }); const session = await approval(); const walletAccounts = this.onSessionConnected(session); return walletAccounts; } catch (error) { console.error(`[WalletConnect] Error connecting: ${error.message}`); return []; } finally { this.modal?.closeModal(); } } async disconnect() { console.info("[WalletConnect] Disconnecting..."); try { if (this.client && this.session) { await this.client.disconnect({ topic: this.session.topic, reason: (0, import_utils7.getSdkError)("USER_DISCONNECTED") }); } this.onDisconnect(); } catch (error) { console.error(error); } } async resumeSession() { try { const state = this.store.state; const walletState = state.wallets[this.id]; if (!walletState) { return; } console.info("[WalletConnect] Resuming session..."); const client = this.client || await this.initializeClient(); if (client.session.length) { const lastKeyIndex = client.session.keys.length - 1; const restoredSession = client.session.get(client.session.keys[lastKeyIndex]); this.onSessionConnected(restoredSession); } } catch (error) { console.error(error); this.onDisconnect(); } } signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => { if (!this.client) { throw new Error("[WalletConnect] Client not initialized!"); } if (!this.session) { throw new Error("[WalletConnect] Session is not connected"); } if (this.activeNetwork === "localnet" /* LOCALNET */) { throw new Error(`[WalletConnect] Invalid network: ${this.activeNetwork}`); } const txnsToSign = []; const signedIndexes = []; const msgpackTxnGroup = normalizeTxnGroup(txnGroup); const decodedObjects = msgpackTxnGroup.map((txn) => { return import_algosdk7.default.decodeObj(txn); }); decodedObjects.forEach((txnObject, idx) => { const isSigned = isSignedTxnObject(txnObject); const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx); const txnBuffer = msgpackTxnGroup[idx]; const txn = isSigned ? import_algosdk7.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk7.default.decodeUnsignedTransaction(txnBuffer); const txnBase64 = Buffer.from(txn.toByte()).toString("base64"); if (shouldSign) { txnsToSign.push({ txn: txnBase64 }); signedIndexes.push(idx); } else { txnsToSign.push({ txn: txnBase64, signers: [] }); } }); const request = formatJsonRpcRequest("algo_signTxn", [txnsToSign]); const signTxnsResult = await this.client.request({ chainId: caipChainId[this.activeNetwork], topic: this.session.topic, request }); const signedTxnsBase64 = signTxnsResult.filter(Boolean); const signedTxns = signedTxnsBase64.map((txn) => new Uint8Array(Buffer.from(txn, "base64"))); const txnGroupSigned = mergeSignedTxnsWithGroup( signedTxns, msgpackTxnGroup, signedIndexes, returnGroup ); return txnGroupSigned; }; transactionSigner = async (txnGroup, indexesToSign) => { if (!this.client) { throw new Error("[WalletConnect] Client not initialized!"); } if (!this.session) { throw new Error("[WalletConnect] Session is not connected"); } if (this.activeNetwork === "localnet" /* LOCALNET */) { throw new Error(`[WalletConnect] Invalid network: ${this.activeNetwork}`); } const txnsToSign = txnGroup.reduce((acc, txn, idx) => { const txnBase64 = Buffer.from(txn.toByte()).toString("base64"); if (indexesToSign.includes(idx)) { acc.push({ txn: txnBase64 }); } else { acc.push({ txn: txnBase64, signers: [] }); } return acc; }, []); const request = formatJsonRpcRequest("algo_signTxn", [txnsToSign]); const signTxnsResult = await this.client.request({ chainId: caipChainId[this.activeNetwork], topic: this.session.topic, request }); const signedTxnsBase64 = signTxnsResult.filter(Boolean); const signedTxns = signedTxnsBase64.map((txn) => new Uint8Array(Buffer.from(txn, "base64"))); return signedTxns; }; }; // src/utils.ts function createWalletMap() { return { ["defly" /* DEFLY */]: DeflyWallet, ["exodus" /* EXODUS */]: ExodusWallet, ["kibisis" /* KIBISIS */]: KibisisWallet, ["kmd" /* KMD */]: KmdWallet, ["lute" /* LUTE */]: LuteWallet, ["mnemonic" /* MNEMONIC */]: MnemonicWallet, ["pera" /* PERA */]: PeraWallet, ["walletconnect" /* WALLETCONNECT */]: WalletConnect }; } function compareAccounts(accounts, compareTo) { const addresses = new Set(accounts.map((account) => account.address)); const compareAddresses = new Set(compareTo.map((account) => account.address)); if (addresses.size !== compareAddresses.size) { return false; } for (const address of addresses) { if (!compareAddresses.has(address)) { return false; } } return true; } function isTransaction(item) { if (Array.isArray(item)) { return item.every( (elem) => typeof elem === "object" && elem !== null && "genesisID" in elem && typeof elem.genesisID === "string" ); } else { return typeof item === "object" && item !== null && "genesisID" in item && typeof item.genesisID === "string"; } } function isSignedTxnObject(item) { return item.txn !== void 0; } function normalizeTxnGroup(txnGroup) { if (!txnGroup[0]) { throw new Error("Empty transaction group!"); } const isTransactionType = isTransaction(txnGroup[0]); if (isTransactionType) { const transactionGroup = Array.isArray(txnGroup[0]) ? txnGroup.flatMap((txn) => txn) : txnGroup; return transactionGroup.map((txn) => { return import_algosdk8.default.encodeUnsignedTransaction(txn); }); } else { const transactionGroup = Array.isArray(txnGroup[0]) ? txnGroup.flatMap((txn) => txn) : txnGroup; return transactionGroup; } } function shouldSignTxnObject(txnObject, addresses, indexesToSign, idx) { const isIndexMatch = !indexesToSign || indexesToSign.includes(idx); const isSigned = isSignedTxnObject(txnObject); const canSign = !isSigned && addresses.includes(import_algosdk8.default.encodeAddress(txnObject.snd)); const shouldSign = isIndexMatch && canSign; return shouldSign; } function mergeSignedTxnsWithGroup(signedTxns, txnGroup, signedIndexes, returnGroup) { return txnGroup.reduce((acc, txn, i) => { if (signedIndexes.includes(i)) { const signedByUser = signedTxns.shift(); signedByUser && acc.push(signedByUser); } else if (returnGroup) { acc.push(txnGroup[i]); } return acc; }, []); } function getPayloadId() { const date = Date.now() * Math.pow(10, 3); const extra = Math.floor(Math.random() * Math.pow(10, 3)); return date + extra; } function formatJsonRpcRequest(method, params) { return { id: getPayloadId(), jsonrpc: "2.0", method, params }; } function deepMerge(target, source) { const isObject = (obj) => obj && typeof obj === "object"; if (!isObject(target) || !isObject(source)) { throw new Error("Target and source must be objects"); } Object.keys(source).forEach((key) => { const targetValue = target[key]; const sourceValue = source[key]; if (Array.isArray(targetValue) && Array.isArray(sourceValue)) { target[key] = targetValue.concat(sourceValue); } else if (isObject(targetValue) && isObject(sourceValue)) { target[key] = deepMerge(Object.assign({}, targetValue), sourceValue); } else { target[key] = sourceValue; } }); return target; } function generateUuid() { if (window.crypto.randomUUID) { return window.crypto.randomUUID(); } return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (value) => { const valueAsNumber = parseInt(value); return (valueAsNumber ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> valueAsNumber / 4).toString(16); }); } // src/wallets/defly.ts var icon7 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+Cjxzdmcgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxuczpzZXJpZj0iaHR0cDovL3d3dy5zZXJpZi5jb20vIiBzdHlsZT0iZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjI7Ij4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDI0IiBoZWlnaHQ9IjEwMjQiLz4KICAgIDxnIHRyYW5zZm9ybT0ibWF0cml4KDEuNjgyMDksMCwwLDEuNjgyMDksMjI2LjM2OCwyMTIuODE4KSI+CiAgICAgICAgPHBhdGggZD0iTTMyNy4wNDksMjgwLjE5MkwxNjkuNTI0LDEzTDEyLDI4MC4xOTJMMTY5LjUyNCwxODkuMDg0TDMyNy4wNDksMjgwLjE5MloiIHN0eWxlPSJmaWxsOndoaXRlO2ZpbGwtcnVsZTpub256ZXJvOyIvPgogICAgPC9nPgogICAgPGcgdHJhbnNmb3JtPSJtYXRyaXgoMS42ODIwOSwwLDAsMS42ODIwOSwyMjYuMzY4LDIxMi44MTgpIj4KICAgICAgICA8cGF0aCBkPSJNMjk5LjU0NiwzMDdMMTY5LjUyNSwyMzguNDczTDM5LjUwNCwzMDdMMTY5LjUyNSwyNjQuNjdMMjk5LjU0NiwzMDdaIiBzdHlsZT0iZmlsbDp3aGl0ZTtmaWxsLXJ1bGU6bm9uemVybzsiLz4KICAgIDwvZz4KPC9zdmc+Cg=="; var DeflyWallet = class extends BaseWallet { client = null; options; store; constructor({ id, store, subscribe, getAlgodClient, options = {}, metadata = {} }) { super({ id, metadata, getAlgodClient, store, subscribe }); this.options = options; this.store = store; } static defaultMetadata = { name: "Defly", icon: icon7 }; async initializeClient() { console.info("[DeflyWallet] Initializing client..."); const module2 = await import("@blockshake/defly-connect"); const DeflyWalletConnect = module2.default ? module2.default.DeflyWalletConnect : module2.DeflyWalletConnect; const client = new DeflyWalletConnect(this.options); client.connector?.on("disconnect", this.onDisconnect); this.client = client; return client; } async connect() { console.info("[DeflyWallet] Connecting..."); try { const client = this.client || await this.initializeClient(); const accounts = await client.connect(); if (accounts.length === 0) { throw new Error("No accounts found!"); } const walletAccounts = accounts.map((address, idx) => ({ name: `Defly Wallet ${idx + 1}`, address })); const activeAccount = walletAccounts[0]; addWallet(this.store, { walletId: this.id, wallet: { accounts: walletAccounts, activeAccount } }); return walletAccounts; } catch (error) { if (error?.data?.type !== "CONNECT_MODAL_CLOSED") { console.error(`[DeflyWallet] Error connecting: ${error.message}`); } else { console.info("[DeflyWallet] Connection cancelled."); } return []; } } async disconnect() { console.info("[DeflyWallet] Disconnecting..."); try { await this.client?.disconnect(); this.onDisconnect(); } catch (error) { console.error(error); } } async resumeSession() { try { const state = this.store.state; const walletState = state.wallets[this.id]; if (!walletState) { return; } console.info("[DeflyWallet] Resuming session..."); const client = this.client || await this.initializeClient(); const accounts = await client.reconnectSession(); if (accounts.length === 0) { throw new Error("[DeflyWallet] No accounts found!"); } const walletAccounts = accounts.map((address, idx) => ({ name: `Defly Wallet ${idx + 1}`, address })); const match = compareAccounts(walletAccounts, walletState.accounts); if (!match) { console.warn(`[DeflyWallet] Session accounts mismatch, updating accounts`); setAccounts(this.store, { walletId: this.id, accounts: walletAccounts }); } } catch (error) { console.error(error); this.onDisconnect(); } } signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => { if (!this.client) { throw new Error("[DeflyWallet] Client not initialized!"); } const txnsToSign = []; const signedIndexes = []; const msgpackTxnGroup = normalizeTxnGroup(txnGroup); const decodedObjects = msgpackTxnGroup.map((txn) => { return import_algosdk9.default.decodeObj(txn); }); decodedObjects.forEach((txnObject, idx) => { const isSigned = isSignedTxnObject(txnObject); const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx); const txnBuffer = msgpackTxnGroup[idx]; const txn = isSigned ? import_algosdk9.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk9.default.decodeUnsignedTransaction(txnBuffer); if (shouldSign) { txnsToSign.push({ txn }); signedIndexes.push(idx); } else { txnsToSign.push({ txn, signers: [] }); } }); const signedTxns = await this.client.signTransaction([txnsToSign]); const txnGroupSigned = mergeSignedTxnsWithGroup( signedTxns, msgpackTxnGroup, signedIndexes, returnGroup ); return txnGroupSigned; }; transactionSigner = async (txnGroup, indexesToSign) => { if (!this.client) { throw new Error("[DeflyWallet] Client not initialized!"); } const txnsToSign = txnGroup.reduce((acc, txn, idx) => { if (indexesToSign.includes(idx)) { acc.push({ txn }); } else { acc.push({ txn, signers: [] }); } return acc; }, []); const signTxnsResult = await this.client.signTransaction([txnsToSign]); return signTxnsResult; }; }; // src/store.ts var defaultState = { wallets: {}, activeWallet: null, activeNetwork: "testnet" /* TESTNET */ }; var LOCAL_STORAGE_KEY = "@txnlab/use-wallet-js"; function addWallet(store, { walletId, wallet }) { store.setState((state) => { const newWallets = { ...state.wallets, [walletId]: wallet }; return { ...state, wallets: newWallets, activeWallet: walletId }; }); } function removeWallet(store, { walletId }) { store.setState((state) => { const newWallets = { ...state.wallets }; delete newWallets[walletId]; return { ...state, wallets: newWallets, activeWallet: state.activeWallet === walletId ? null : state.activeWallet }; }); } function setActiveWallet(store, { walletId }) { store.setState((state) => { return { ...state, activeWallet: walletId }; }); } function setActiveAccount(store, { walletId, address }) { store.setState((state) => { const wallet = state.wallets[walletId]; if (!wallet) { return state; } const activeAccount = wallet.accounts.find((a) => a.address === address); if (!activeAccount) { return state; } const newWallets = { ...state.wallets, [walletId]: { ...wallet, activeAccount } }; return { ...state, wallets: newWallets }; }); } function setAccounts(store, { walletId, accounts }) { store.setState((state) => { const wallet = state.wallets[walletId]; if (!wallet) { return state; } const isActiveAccountConnected = accounts.some( (account) => account.address === wallet.activeAccount?.address ); const activeAccount = isActiveAccountConnected ? wallet.activeAccount : accounts[0] || null; const newWallet = { ...wallet, accounts, activeAccount }; const newWallets = { ...state.wallets, [walletId]: newWallet }; return { ...state, wallets: newWallets }; }); } function setActiveNetwork(store, { networkId }) { store.setState((state) => { return { ...state, activeNetwork: networkId }; }); } function isValidWalletId(walletId) { return Object.values(WalletId).includes(walletId); } function isValidWalletAccount(account) { return typeof account === "object" && account !== null && typeof account.name === "string" && typeof account.address === "string"; } function isValidWalletState(wallet) { return typeof wallet === "object" && wallet !== null && Array.isArray(wallet.accounts) && wallet.accounts.every(isValidWalletAccount) && (wallet.activeAccount === null || isValidWalletAccount(wallet.activeAccount)); } function isValidState(state) { if (!state || typeof state !== "object") return false; if (typeof state.wallets !== "object") return false; for (const [walletId, wallet] of Object.entries(state.wallets)) { if (!isValidWalletId(walletId) || !isValidWalletState(wallet)) return false; } if (state.activeWallet !== null && !isValidWalletId(state.activeWallet)) return false; if (!isValidNetworkId(state.activeNetwork)) return false; return true; } // src/manager.ts var WalletManager = class { _clients = /* @__PURE__ */ new Map(); networkConfig; algodClient; store; subscribe; constructor({ wallets = [], network = "testnet" /* TESTNET */, algod = {} } = {}) { const initialState = this.loadPersistedState() || { ...defaultState, activeNetwork: network }; this.store = new import_store10.Store(initialState, { onUpdate: () => this.savePersistedState() }); this.savePersistedState(); this.subscribe = (callback) => { const unsubscribe = this.store.subscribe(() => { callback(this.store.state); }); return unsubscribe; }; this.networkConfig = this.initNetworkConfig(network, algod); this.algodClient = this.createAlgodClient(this.networkConfig[network]); this.initializeWallets(wallets); } // ---------- Store ------------------------------------------------- // loadPersistedState() { try { const serializedState = StorageAdapter.getItem(LOCAL_STORAGE_KEY); if (serializedState === null) { return null; } const parsedState = JSON.parse(serializedState); if (!isValidState(parsedState)) { console.warn("[Store] Parsed state:", parsedState); throw new Error("Persisted state is invalid"); } return parsedState; } catch (error) { console.error(`[Store] Could not load state from local storage: ${error.message}`); return null; } } savePersistedState() { try { const state = this.store.state; const serializedState = JSON.stringify(state); StorageAdapter.setItem(LOCAL_STORAGE_KEY, serializedState); } catch (error) { console.error("[Store] Could not save state to local storage:", error); } } // ---------- Wallets ----------------------------------------------- // initializeWallets(walletsConfig) { console.info("[Manager] Initializing wallets..."); for (const walletConfig of walletsConfig) { let walletId; let walletOptions; let walletMetadata; if (typeof walletConfig === "string") { walletId = walletConfig; } else { const { id, options, metadata } = walletConfig; walletId = id; walletOptions = options; walletMetadata = metadata; } const walletMap = createWalletMap(); const WalletClass = walletMap[walletId]; if (!WalletClass) { console.error(`[Manager] Wallet not found: ${walletId}`); continue; } const walletInstance = new WalletClass({ id: walletId, metadata: walletMetadata, options: walletOptions, getAlgodClient: this.getAlgodClient, store: this.store, subscribe: this.subscribe }); this._clients.set(walletId, walletInstance); console.info(`[Manager] \u2705 Initialized ${walletId}`); } const state = this.store.state; const connectedWallets = Object.keys(state.wallets); for (const walletId of connectedWallets) { if (!this._clients.has(walletId)) { console.warn(`[Manager] Connected wallet not found: ${walletId}`); removeWallet(this.store, { walletId }); } } if (state.activeWallet && !this._clients.has(state.activeWallet)) { console.warn(`[Manager] Active wallet not found: ${state.activeWallet}`); setActiveWallet(this.store, { walletId: null }); } } get wallets() { return [...this._clients.values()]; } getWallet(walletId) { return this._clients.get(walletId); } async resumeSessions() { const promises = this.wallets.map((wallet) => wallet?.resumeSession()); await Promise.all(promises); } // ---------- Network ----------------------------------------------- // initNetworkConfig(network, config) { console.info("[Manager] Initializing network..."); let networkConfig = createDefaultNetworkConfig(); if (isNetworkConfigMap(config)) { networkConfig = deepMerge(networkConfig, config); } else { networkConfig[network] = deepMerge(networkConfig[network], config); } console.info("[Manager] Algodv2 config:", networkConfig); return networkConfig; } createAlgodClient(config) { console.info(`[Manager] Creating Algodv2 client for ${this.activeNetwork}...`); const { token = "", baseServer, port = "", headers = {} } = config; return new import_algosdk10.default.Algodv2(token, baseServer, port, headers); } getAlgodClient = () => { return this.algodClient; }; setActiveNetwork(networkId) { setActiveNetwork(this.store, { networkId }); this.algodClient = this.createAlgodClient(this.networkConfig[networkId]); } get activeNetwork() { return this.store.state.activeNetwork; } // ---------- Active Wallet ----------------------------------------- // get activeWallet() { const state = this.store.state; const activeWallet = this.wallets.find((wallet) => wallet.id === state.activeWallet); if (!activeWallet) { return null; } return activeWallet; } get activeWalletAccounts() { if (!this.activeWallet) { return null; } return this.activeWallet.accounts; } get activeWalletAddresses() { if (!this.activeWallet) { return null; } return this.activeWallet.accounts.map((account) => account.address); } get activeAccount() { if (!this.activeWallet) { return null; } return this.activeWallet.activeAccount; } get activeAddress() { if (!this.activeAccount) { return null; } return this.activeAccount.address; } // ---------- Sign Transactions ------------------------------------- // get signTransactions() { if (!this.activeWallet) { throw new Error("[Manager] No active wallet found!"); } return this.activeWallet.signTransactions; } /** * A function which can sign transactions from an atomic transaction group. The logic will be * specific to each wallet, but the function will always return a promise that resolves to an * array of encoded signed transactions matching the length of the indexesToSign array. * * @see https://github.com/algorand/js-algorand-sdk/blob/v2.6.0/src/signer.ts#L7-L18 * * @param txnGroup - The atomic group containing transactions to be signed * @param indexesToSign - An array of indexes in the atomic transaction group that should be signed * @returns A promise which resolves an array of encoded signed transactions. The length of the * array will be the same as the length of indexesToSign, and each index i in the array * corresponds to the signed transaction from txnGroup[indexesToSign[i]] */ get transactionSigner() { if (!this.activeWallet) { throw new Error("[Manager] No active wallet found!"); } return this.activeWallet.transactionSigner; } /** * A wrapper around `TransactionSigner` that also has the sender address (the current active * account). Can be used to produce a `TransactionWithSigner` object ready to be passed to an * AtomicTransactionComposer's `addTransaction` method. * * @see https://github.com/algorandfoundation/algokit-utils-ts/blob/v4.0.0/docs/code/modules/index.md#gettransactionwithsigner */ get transactionSignerAccount() { if (!this.activeAddress) { throw new Error("[Manager] No active account found!"); } return { addr: this.activeAddress, signer: this.transactionSigner }; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { BaseWallet, DeflyWallet, ExodusWallet, KmdWallet, MnemonicWallet, NetworkId, PeraWallet, StorageAdapter, WalletConnect, WalletId, WalletManager, defaultState }); //# sourceMappingURL=index.cjs.map