diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2023-12-27 16:29:28 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2023-12-27 16:29:28 +0200 |
commit | 1904a913b84e01e902173e782ab45e0e3b4ccf8d (patch) | |
tree | 016cd489ec4b3c6b905a9d0d837bcafe8daeb8a6 /src/external/stellar-freighter-api | |
parent | 34b89f42c737955e510ba058a126b33cba6d2bb6 (diff) | |
download | arching-kaos-web-ui-1904a913b84e01e902173e782ab45e0e3b4ccf8d.tar.gz arching-kaos-web-ui-1904a913b84e01e902173e782ab45e0e3b4ccf8d.tar.bz2 arching-kaos-web-ui-1904a913b84e01e902173e782ab45e0e3b4ccf8d.zip |
Use only local libraries
Diffstat (limited to 'src/external/stellar-freighter-api')
20 files changed, 373 insertions, 0 deletions
diff --git a/src/external/stellar-freighter-api/@shared/api/external.d.ts b/src/external/stellar-freighter-api/@shared/api/external.d.ts new file mode 100644 index 0000000..9755ca4 --- /dev/null +++ b/src/external/stellar-freighter-api/@shared/api/external.d.ts @@ -0,0 +1,24 @@ +import { UserInfo } from "./types"; +export declare const requestPublicKey: () => Promise<string>; +export declare const submitTransaction: (transactionXdr: string, opts?: string | { + network?: string | undefined; + accountToSign?: string | undefined; + networkPassphrase?: string | undefined; +} | undefined, accountToSign?: string | undefined) => Promise<string>; +export declare const submitBlob: (blob: string, opts?: { + accountToSign?: string | undefined; +} | undefined) => Promise<string>; +export declare const submitAuthEntry: (entryXdr: string, opts?: { + accountToSign?: string | undefined; +} | undefined) => Promise<string>; +export declare const requestNetwork: () => Promise<string>; +export declare const requestNetworkDetails: () => Promise<{ + network: string; + networkUrl: string; + networkPassphrase: string; + sorobanRpcUrl?: string | undefined; +}>; +export declare const requestConnectionStatus: () => Promise<boolean>; +export declare const requestAllowedStatus: () => Promise<boolean>; +export declare const setAllowedStatus: () => Promise<boolean>; +export declare const requestUserInfo: () => Promise<UserInfo>; diff --git a/src/external/stellar-freighter-api/@shared/api/helpers/extensionMessaging.d.ts b/src/external/stellar-freighter-api/@shared/api/helpers/extensionMessaging.d.ts new file mode 100644 index 0000000..1aed2d8 --- /dev/null +++ b/src/external/stellar-freighter-api/@shared/api/helpers/extensionMessaging.d.ts @@ -0,0 +1,9 @@ +import { EXTERNAL_SERVICE_TYPES, SERVICE_TYPES } from "../../constants/services"; +import { Response } from "../types"; +interface Msg { + [key: string]: any; + type: EXTERNAL_SERVICE_TYPES | SERVICE_TYPES; +} +export declare const sendMessageToContentScript: (msg: Msg) => Promise<Response>; +export declare const sendMessageToBackground: (msg: Msg) => Promise<Response>; +export {}; diff --git a/src/external/stellar-freighter-api/@shared/api/types.d.ts b/src/external/stellar-freighter-api/@shared/api/types.d.ts new file mode 100644 index 0000000..be44b6a --- /dev/null +++ b/src/external/stellar-freighter-api/@shared/api/types.d.ts @@ -0,0 +1,158 @@ +import BigNumber from "bignumber.js"; +import { Horizon } from "stellar-sdk"; +import { Types } from "@stellar/wallet-sdk"; +import { SERVICE_TYPES, EXTERNAL_SERVICE_TYPES } from "../constants/services"; +import { APPLICATION_STATE } from "../constants/applicationState"; +import { WalletType } from "../constants/hardwareWallet"; +import { NetworkDetails } from "../constants/stellar"; +export declare enum ActionStatus { + IDLE = "IDLE", + PENDING = "PENDING", + SUCCESS = "SUCCESS", + ERROR = "ERROR" +} +export interface UserInfo { + publicKey: string; +} +export interface Response { + error: string; + messagedId: number; + applicationState: APPLICATION_STATE; + publicKey: string; + privateKey: string; + hasPrivateKey: boolean; + mnemonicPhrase: string; + isCorrectPhrase: boolean; + confirmedPassword: boolean; + password: string; + mnemonicPhraseToConfirm: string; + recoverMnemonic: string; + transaction: { + sign: (sourceKeys: {}) => void; + }; + transactionXDR: string; + signedTransaction: string; + signedBlob: string; + signedAuthEntry: string; + source: string; + type: SERVICE_TYPES; + url: string; + isDataSharingAllowed: boolean; + isTestnet: boolean; + isMemoValidationEnabled: boolean; + isSafetyValidationEnabled: boolean; + isValidatingSafeAssetsEnabled: boolean; + isExperimentalModeEnabled: boolean; + networkDetails: NetworkDetails; + sorobanRpcUrl: string; + networksList: NetworkDetails[]; + allAccounts: Array<Account>; + accountName: string; + assetCode: string; + assetCanonical: string; + iconUrl: string; + network: string; + networkIndex: number; + networkName: string; + recentAddresses: Array<string>; + hardwareWalletType: WalletType; + bipPath: string; + blockedDomains: BlockedDomains; + blockedAccounts: BlockedAccount[]; + assetDomain: string; + contractId: string; + tokenId: string; + tokenIdList: string[]; + isConnected: boolean; + isAllowed: boolean; + userInfo: UserInfo; + allowList: string[]; +} +export interface BlockedDomains { + [key: string]: boolean; +} +export interface BlockedAccount { + address: string; + name: string; + domain: string | null; + tags: string[]; +} +export interface ExternalRequestBase { + network: string; + networkPassphrase: string; + accountToSign: string; + type: EXTERNAL_SERVICE_TYPES; +} +export interface ExternalRequestTx extends ExternalRequestBase { + transactionXdr: string; +} +export interface ExternalRequestBlob extends ExternalRequestBase { + blob: string; +} +export interface ExternalRequestAuthEntry extends ExternalRequestBase { + entryXdr: string; +} +export declare type ExternalRequest = ExternalRequestTx | ExternalRequestBlob | ExternalRequestAuthEntry; +export interface Account { + publicKey: string; + name: string; + imported: boolean; + hardwareWalletType?: WalletType; +} +export declare enum AccountType { + HW = "HW", + IMPORTED = "IMPORTED", + FREIGHTER = "FREIGHTER" +} +export interface Preferences { + isDataSharingAllowed: boolean; + isMemoValidationEnabled: boolean; + isSafetyValidationEnabled: boolean; + isValidatingSafeAssetsEnabled: boolean; + networksList: NetworkDetails[]; + error: string; + isExperimentalModeEnabled: boolean; +} +export declare type Settings = { + allowList: string[]; + networkDetails: NetworkDetails; + networksList: NetworkDetails[]; + error: string; +} & Preferences; +export interface AssetIcons { + [code: string]: string; +} +export interface AssetDomains { + [code: string]: string; +} +export declare type Balances = Types.BalanceMap | null; +export interface SorobanBalance { + contractId: string; + total: BigNumber; + name: string; + symbol: string; + decimals: number; +} +export declare type AssetType = Types.AssetBalance | Types.NativeBalance | SorobanBalance; +export declare type TokenBalances = SorobanBalance[]; +export declare type HorizonOperation = any; +export interface AccountBalancesInterface { + balances: Balances; + isFunded: boolean | null; + subentryCount: number; +} +export interface AccountHistoryInterface { + operations: Array<HorizonOperation> | []; +} +export interface ErrorMessage { + errorMessage: string; + response?: Horizon.ErrorResponseData.TransactionFailed; +} +declare global { + interface Window { + freighter: boolean; + freighterApi: { + [key: string]: any; + }; + } +} diff --git a/src/external/stellar-freighter-api/@shared/constants/applicationState.d.ts b/src/external/stellar-freighter-api/@shared/constants/applicationState.d.ts new file mode 100644 index 0000000..44f8f14 --- /dev/null +++ b/src/external/stellar-freighter-api/@shared/constants/applicationState.d.ts @@ -0,0 +1,8 @@ +export declare enum APPLICATION_STATE { + APPLICATION_LOADING = "APPLICATION_LOADING", + APPLICATION_ERROR = "APPLICATION_ERROR", + APPLICATION_STARTED = "APPLICATION_STARTED", + PASSWORD_CREATED = "PASSWORD_CREATED", + MNEMONIC_PHRASE_CONFIRMED = "MNEMONIC_PHRASE_CONFIRMED", + MNEMONIC_PHRASE_FAILED = "MNEMONIC_PHRASE_FAILED" +} diff --git a/src/external/stellar-freighter-api/@shared/constants/hardwareWallet.d.ts b/src/external/stellar-freighter-api/@shared/constants/hardwareWallet.d.ts new file mode 100644 index 0000000..54b6088 --- /dev/null +++ b/src/external/stellar-freighter-api/@shared/constants/hardwareWallet.d.ts @@ -0,0 +1,4 @@ +export declare enum WalletType { + LEDGER = "Ledger", + NONE = "" +} diff --git a/src/external/stellar-freighter-api/@shared/constants/services.d.ts b/src/external/stellar-freighter-api/@shared/constants/services.d.ts new file mode 100644 index 0000000..7c4738b --- /dev/null +++ b/src/external/stellar-freighter-api/@shared/constants/services.d.ts @@ -0,0 +1,62 @@ +export declare enum SERVICE_TYPES { + CREATE_ACCOUNT = "CREATE_ACCOUNT", + FUND_ACCOUNT = "FUND_ACCOUNT", + ADD_ACCOUNT = "ADD_ACCOUNT", + IMPORT_ACCOUNT = "IMPORT_ACCOUNT", + IMPORT_HARDWARE_WALLET = "IMPORT_HARDWARE_WALLET", + LOAD_ACCOUNT = "LOAD_ACCOUNT", + MAKE_ACCOUNT_ACTIVE = "MAKE_ACCOUNT_ACTIVE", + UPDATE_ACCOUNT_NAME = "UPDATE_ACCOUNT_NAME", + GET_MNEMONIC_PHRASE = "GET_MNEMONIC_PHRASE", + CONFIRM_MNEMONIC_PHRASE = "CONFIRM_MNEMONIC_PHRASE", + RECOVER_ACCOUNT = "RECOVER_ACCOUNT", + CONFIRM_PASSWORD = "CONFIRM_PASSWORD", + REJECT_ACCESS = "REJECT_ACCESS", + GRANT_ACCESS = "GRANT_ACCESS", + SIGN_TRANSACTION = "SIGN_TRANSACTION", + SIGN_BLOB = "SIGN_BLOB", + SIGN_AUTH_ENTRY = "SIGN_AUTH_ENTRY", + HANDLE_SIGNED_HW_TRANSACTION = "HANDLE_SIGNED_HW_TRANSACTION", + REJECT_TRANSACTION = "REJECT_TRANSACTION", + SIGN_FREIGHTER_TRANSACTION = "SIGN_FREIGHTER_TRANSACTION", + SIGN_FREIGHTER_SOROBAN_TRANSACTION = "SIGN_FREIGHTER_SOROBAN_TRANSACTION", + ADD_RECENT_ADDRESS = "ADD_RECENT_ADDRESS", + LOAD_RECENT_ADDRESSES = "LOAD_RECENT_ADDRESSES", + SIGN_OUT = "SIGN_OUT", + SHOW_BACKUP_PHRASE = "SHOW_BACKUP_PHRASE", + SAVE_ALLOWLIST = "SAVE_ALLOWLIST", + SAVE_SETTINGS = "SAVE_SETTINGS", + LOAD_SETTINGS = "LOAD_SETTINGS", + GET_CACHED_ASSET_ICON = "GET_CACHED_ASSET_ICON", + CACHE_ASSET_ICON = "CACHE_ASSET_ICON", + GET_CACHED_ASSET_DOMAIN = "GET_CACHED_ASSET_DOMAIN", + CACHE_ASSET_DOMAIN = "CACHE_ASSET_DOMAIN", + GET_BLOCKED_ACCOUNTS = "GET_BLOCKED_ACCOUNTS", + GET_BLOCKED_DOMAINS = "GET_BLOCKED_DOMAINS", + ADD_CUSTOM_NETWORK = "ADD_CUSTOM_NETWORK", + CHANGE_NETWORK = "CHANGE_NETWORK", + REMOVE_CUSTOM_NETWORK = "REMOVE_CUSTOM_NETWORK", + EDIT_CUSTOM_NETWORK = "EDIT_CUSTOM_NETWORK", + RESET_EXP_DATA = "RESET_EXP_DATA", + ADD_TOKEN_ID = "ADD_TOKEN_ID", + GET_TOKEN_IDS = "GET_TOKEN_IDS", + REMOVE_TOKEN_ID = "REMOVE_TOKEN_ID" +} +export declare enum EXTERNAL_SERVICE_TYPES { + REQUEST_ACCESS = "REQUEST_ACCESS", + SUBMIT_TRANSACTION = "SUBMIT_TRANSACTION", + SUBMIT_BLOB = "SUBMIT_BLOB", + SUBMIT_AUTH_ENTRY = "SUBMIT_AUTH_ENTRY", + REQUEST_NETWORK = "REQUEST_NETWORK", + REQUEST_NETWORK_DETAILS = "REQUEST_NETWORK_DETAILS", + REQUEST_CONNECTION_STATUS = "REQUEST_CONNECTION_STATUS", + REQUEST_ALLOWED_STATUS = "REQUEST_ALLOWED_STATUS", + SET_ALLOWED_STATUS = "SET_ALLOWED_STATUS", + REQUEST_USER_INFO = "REQUEST_USER_INFO" +} +export declare const EXTERNAL_MSG_REQUEST = "FREIGHTER_EXTERNAL_MSG_REQUEST"; +export declare const EXTERNAL_MSG_RESPONSE = "FREIGHTER_EXTERNAL_MSG_RESPONSE"; +declare const _DEV_SERVER: string; +export { _DEV_SERVER as DEV_SERVER }; +declare const _DEV_EXTENSION: string; +export { _DEV_EXTENSION as DEV_EXTENSION }; diff --git a/src/external/stellar-freighter-api/@shared/constants/stellar.d.ts b/src/external/stellar-freighter-api/@shared/constants/stellar.d.ts new file mode 100644 index 0000000..7f54032 --- /dev/null +++ b/src/external/stellar-freighter-api/@shared/constants/stellar.d.ts @@ -0,0 +1,34 @@ +export declare enum NETWORK_NAMES { + TESTNET = "Test Net", + PUBNET = "Main Net", + FUTURENET = "Future Net" +} +export declare enum NETWORKS { + PUBLIC = "PUBLIC", + TESTNET = "TESTNET", + FUTURENET = "FUTURENET" +} +export declare enum NETWORK_URLS { + PUBLIC = "https://horizon.stellar.org", + TESTNET = "https://horizon-testnet.stellar.org", + FUTURENET = "https://horizon-futurenet.stellar.org" +} +export declare enum FRIENDBOT_URLS { + TESTNET = "https://friendbot.stellar.org", + FUTURENET = "https://friendbot-futurenet.stellar.org" +} +export declare const SOROBAN_RPC_URLS: { + [key in NETWORKS]?: string; +}; +export interface NetworkDetails { + network: string; + networkName: string; + networkUrl: string; + networkPassphrase: string; + friendbotUrl?: string; + sorobanRpcUrl?: string; +} +export declare const MAINNET_NETWORK_DETAILS: NetworkDetails; +export declare const TESTNET_NETWORK_DETAILS: NetworkDetails; +export declare const FUTURENET_NETWORK_DETAILS: NetworkDetails; +export declare const DEFAULT_NETWORKS: Array<NetworkDetails>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/getNetwork.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/getNetwork.d.ts new file mode 100644 index 0000000..6352aa0 --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/getNetwork.d.ts @@ -0,0 +1 @@ +export declare const getNetwork: () => Promise<string>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/getNetworkDetails.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/getNetworkDetails.d.ts new file mode 100644 index 0000000..b161629 --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/getNetworkDetails.d.ts @@ -0,0 +1,6 @@ +export declare const getNetworkDetails: () => Promise<{ + network: string; + networkUrl: string; + networkPassphrase: string; + sorobanRpcUrl?: string; +}>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/getPublicKey.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/getPublicKey.d.ts new file mode 100644 index 0000000..80cf670 --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/getPublicKey.d.ts @@ -0,0 +1 @@ +export declare const getPublicKey: () => Promise<string>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/getUserInfo.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/getUserInfo.d.ts new file mode 100644 index 0000000..0a464a2 --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/getUserInfo.d.ts @@ -0,0 +1,3 @@ +export declare const getUserInfo: () => Promise<{ + publicKey: string; +}>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/index.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/index.d.ts new file mode 100644 index 0000000..8c3e29a --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/index.d.ts @@ -0,0 +1,40 @@ +import { getPublicKey } from "./getPublicKey"; +import { signTransaction } from "./signTransaction"; +import { signBlob } from "./signBlob"; +import { signAuthEntry } from "./signAuthEntry"; +import { isConnected } from "./isConnected"; +import { getNetwork } from "./getNetwork"; +import { getNetworkDetails } from "./getNetworkDetails"; +import { isAllowed } from "./isAllowed"; +import { setAllowed } from "./setAllowed"; +import { getUserInfo } from "./getUserInfo"; +export declare const isBrowser: boolean; +export { getPublicKey, signTransaction, signBlob, signAuthEntry, isConnected, getNetwork, getNetworkDetails, isAllowed, setAllowed, getUserInfo, }; +declare const _default: { + getPublicKey: () => Promise<string>; + signTransaction: (transactionXdr: string, opts?: { + network?: string | undefined; + networkPassphrase?: string | undefined; + accountToSign?: string | undefined; + } | undefined) => Promise<string>; + signBlob: (blob: string, opts?: { + accountToSign?: string | undefined; + } | undefined) => Promise<string>; + signAuthEntry: (entryXdr: string, opts?: { + accountToSign?: string | undefined; + } | undefined) => Promise<string>; + isConnected: () => Promise<boolean>; + getNetwork: () => Promise<string>; + getNetworkDetails: () => Promise<{ + network: string; + networkUrl: string; + networkPassphrase: string; + sorobanRpcUrl?: string | undefined; + }>; + isAllowed: () => Promise<boolean>; + setAllowed: () => Promise<boolean>; + getUserInfo: () => Promise<{ + publicKey: string; + }>; +}; +export default _default; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/isAllowed.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/isAllowed.d.ts new file mode 100644 index 0000000..39eed0a --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/isAllowed.d.ts @@ -0,0 +1 @@ +export declare const isAllowed: () => Promise<boolean>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/isConnected.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/isConnected.d.ts new file mode 100644 index 0000000..8e4b262 --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/isConnected.d.ts @@ -0,0 +1 @@ +export declare const isConnected: () => Promise<boolean>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/setAllowed.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/setAllowed.d.ts new file mode 100644 index 0000000..989cab6 --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/setAllowed.d.ts @@ -0,0 +1 @@ +export declare const setAllowed: () => Promise<boolean>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/signAuthEntry.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/signAuthEntry.d.ts new file mode 100644 index 0000000..ca8cc91 --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/signAuthEntry.d.ts @@ -0,0 +1,3 @@ +export declare const signAuthEntry: (entryXdr: string, opts?: { + accountToSign?: string | undefined; +} | undefined) => Promise<string>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/signBlob.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/signBlob.d.ts new file mode 100644 index 0000000..eab6a5a --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/signBlob.d.ts @@ -0,0 +1,3 @@ +export declare const signBlob: (blob: string, opts?: { + accountToSign?: string | undefined; +} | undefined) => Promise<string>; diff --git a/src/external/stellar-freighter-api/@stellar/freighter-api/src/signTransaction.d.ts b/src/external/stellar-freighter-api/@stellar/freighter-api/src/signTransaction.d.ts new file mode 100644 index 0000000..2605f0f --- /dev/null +++ b/src/external/stellar-freighter-api/@stellar/freighter-api/src/signTransaction.d.ts @@ -0,0 +1,5 @@ +export declare const signTransaction: (transactionXdr: string, opts?: { + network?: string | undefined; + networkPassphrase?: string | undefined; + accountToSign?: string | undefined; +} | undefined) => Promise<string>; diff --git a/src/external/stellar-freighter-api/config/shims/webextension-polyfill.d.ts b/src/external/stellar-freighter-api/config/shims/webextension-polyfill.d.ts new file mode 100644 index 0000000..c1f1e2b --- /dev/null +++ b/src/external/stellar-freighter-api/config/shims/webextension-polyfill.d.ts @@ -0,0 +1,8 @@ +declare const _default: { + tabs: { + create: ({ url }: { + url: string; + }) => Window | null; + }; +}; +export default _default; diff --git a/src/external/stellar-freighter-api/index.min.js b/src/external/stellar-freighter-api/index.min.js new file mode 100644 index 0000000..bcd8fc3 --- /dev/null +++ b/src/external/stellar-freighter-api/index.min.js @@ -0,0 +1 @@ +!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.freighterApi=r():e.freighterApi=r()}(this,()=>(()=>{"use strict";var e,r,o={d:(e,r)=>{for(var E in r)o.o(r,E)&&!o.o(e,E)&&Object.defineProperty(e,E,{enumerable:!0,get:r[E]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},E={};o.r(E),o.d(E,{default:()=>a,getNetwork:()=>N,getNetworkDetails:()=>s,getPublicKey:()=>t,getUserInfo:()=>i,isAllowed:()=>O,isBrowser:()=>R,isConnected:()=>n,setAllowed:()=>C,signAuthEntry:()=>A,signBlob:()=>S,signTransaction:()=>_}),function(e){e.CREATE_ACCOUNT="CREATE_ACCOUNT",e.FUND_ACCOUNT="FUND_ACCOUNT",e.ADD_ACCOUNT="ADD_ACCOUNT",e.IMPORT_ACCOUNT="IMPORT_ACCOUNT",e.IMPORT_HARDWARE_WALLET="IMPORT_HARDWARE_WALLET",e.LOAD_ACCOUNT="LOAD_ACCOUNT",e.MAKE_ACCOUNT_ACTIVE="MAKE_ACCOUNT_ACTIVE",e.UPDATE_ACCOUNT_NAME="UPDATE_ACCOUNT_NAME",e.GET_MNEMONIC_PHRASE="GET_MNEMONIC_PHRASE",e.CONFIRM_MNEMONIC_PHRASE="CONFIRM_MNEMONIC_PHRASE",e.RECOVER_ACCOUNT="RECOVER_ACCOUNT",e.CONFIRM_PASSWORD="CONFIRM_PASSWORD",e.REJECT_ACCESS="REJECT_ACCESS",e.GRANT_ACCESS="GRANT_ACCESS",e.SIGN_TRANSACTION="SIGN_TRANSACTION",e.SIGN_BLOB="SIGN_BLOB",e.SIGN_AUTH_ENTRY="SIGN_AUTH_ENTRY",e.HANDLE_SIGNED_HW_TRANSACTION="HANDLE_SIGNED_HW_TRANSACTION",e.REJECT_TRANSACTION="REJECT_TRANSACTION",e.SIGN_FREIGHTER_TRANSACTION="SIGN_FREIGHTER_TRANSACTION",e.SIGN_FREIGHTER_SOROBAN_TRANSACTION="SIGN_FREIGHTER_SOROBAN_TRANSACTION",e.ADD_RECENT_ADDRESS="ADD_RECENT_ADDRESS",e.LOAD_RECENT_ADDRESSES="LOAD_RECENT_ADDRESSES",e.SIGN_OUT="SIGN_OUT",e.SHOW_BACKUP_PHRASE="SHOW_BACKUP_PHRASE",e.SAVE_ALLOWLIST="SAVE_ALLOWLIST",e.SAVE_SETTINGS="SAVE_SETTINGS",e.LOAD_SETTINGS="LOAD_SETTINGS",e.GET_CACHED_ASSET_ICON="GET_CACHED_ASSET_ICON",e.CACHE_ASSET_ICON="CACHE_ASSET_ICON",e.GET_CACHED_ASSET_DOMAIN="GET_CACHED_ASSET_DOMAIN",e.CACHE_ASSET_DOMAIN="CACHE_ASSET_DOMAIN",e.GET_BLOCKED_ACCOUNTS="GET_BLOCKED_ACCOUNTS",e.GET_BLOCKED_DOMAINS="GET_BLOCKED_DOMAINS",e.ADD_CUSTOM_NETWORK="ADD_CUSTOM_NETWORK",e.CHANGE_NETWORK="CHANGE_NETWORK",e.REMOVE_CUSTOM_NETWORK="REMOVE_CUSTOM_NETWORK",e.EDIT_CUSTOM_NETWORK="EDIT_CUSTOM_NETWORK",e.RESET_EXP_DATA="RESET_EXP_DATA",e.ADD_TOKEN_ID="ADD_TOKEN_ID",e.GET_TOKEN_IDS="GET_TOKEN_IDS",e.REMOVE_TOKEN_ID="REMOVE_TOKEN_ID"}(e||(e={})),function(e){e.REQUEST_ACCESS="REQUEST_ACCESS",e.SUBMIT_TRANSACTION="SUBMIT_TRANSACTION",e.SUBMIT_BLOB="SUBMIT_BLOB",e.SUBMIT_AUTH_ENTRY="SUBMIT_AUTH_ENTRY",e.REQUEST_NETWORK="REQUEST_NETWORK",e.REQUEST_NETWORK_DETAILS="REQUEST_NETWORK_DETAILS",e.REQUEST_CONNECTION_STATUS="REQUEST_CONNECTION_STATUS",e.REQUEST_ALLOWED_STATUS="REQUEST_ALLOWED_STATUS",e.SET_ALLOWED_STATUS="SET_ALLOWED_STATUS",e.REQUEST_USER_INFO="REQUEST_USER_INFO"}(r||(r={}));const T=e=>{const o=Date.now()+Math.random();return window.postMessage({source:"FREIGHTER_EXTERNAL_MSG_REQUEST",messageId:o,...e},window.location.origin),new Promise(E=>{let T=0;e.type===r.REQUEST_CONNECTION_STATUS&&(T=setTimeout(()=>{E({isConnected:!1}),window.removeEventListener("message",t)},2e3));const t=e=>{var r,_;e.source===window&&"FREIGHTER_EXTERNAL_MSG_RESPONSE"===(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.source)&&(null===(_=null==e?void 0:e.data)||void 0===_?void 0:_.messagedId)===o&&(E(e.data),window.removeEventListener("message",t),clearTimeout(T))};window.addEventListener("message",t,!1)})},t=()=>R?(async()=>{let e={publicKey:"",error:""};try{e=await T({type:r.REQUEST_ACCESS})}catch(e){console.error(e)}const{publicKey:o,error:E}=e;if(E)throw E;return o})():Promise.resolve(""),_=(e,o)=>R?(async(e,o,E)=>{let t="",_="",S="";"object"==typeof o?(t=o.network||"",_=o.accountToSign||"",S=o.networkPassphrase||""):(t=o||"",_="");let A={signedTransaction:"",error:""};try{A=await T({transactionXdr:e,network:t,networkPassphrase:S,accountToSign:_,type:r.SUBMIT_TRANSACTION})}catch(e){throw console.error(e),e}const{signedTransaction:n,error:N}=A;if(N)throw N;return n})(e,o):Promise.resolve(""),S=(e,o)=>R?(async(e,o)=>{let E={signedBlob:"",error:""};const t=(o||{}).accountToSign||"";try{E=await T({blob:e,accountToSign:t,type:r.SUBMIT_BLOB})}catch(e){throw console.error(e),e}const{signedBlob:_,error:S}=E;if(S)throw S;return _})(e,o):Promise.resolve(""),A=(e,o)=>R?(async(e,o)=>{let E={signedAuthEntry:"",error:""};const t=(o||{}).accountToSign||"";try{E=await T({entryXdr:e,accountToSign:t,type:r.SUBMIT_AUTH_ENTRY})}catch(e){console.error(e)}const{signedAuthEntry:_,error:S}=E;if(S)throw S;return _})(e,o):Promise.resolve(""),n=()=>R?window.freighter?Promise.resolve(window.freighter):(async()=>{let e={isConnected:!1};try{e=await T({type:r.REQUEST_CONNECTION_STATUS})}catch(e){console.error(e)}return e.isConnected})():Promise.resolve(!1),N=()=>R?(async()=>{let e={network:"",error:""};try{e=await T({type:r.REQUEST_NETWORK})}catch(e){console.error(e)}const{network:o,error:E}=e;if(E)throw E;return o})():Promise.resolve(""),s=()=>R?(async()=>{let e={networkDetails:{network:"",networkName:"",networkUrl:"",networkPassphrase:"",sorobanRpcUrl:void 0},error:""};try{e=await T({type:r.REQUEST_NETWORK_DETAILS})}catch(e){console.error(e)}const{networkDetails:o,error:E}=e,{network:t,networkUrl:_,networkPassphrase:S,sorobanRpcUrl:A}=o;if(E)throw E;return{network:t,networkUrl:_,networkPassphrase:S,sorobanRpcUrl:A}})():Promise.resolve({network:"",networkUrl:"",networkPassphrase:"",sorobanRpcUrl:""}),O=()=>R?(async()=>{let e={isAllowed:!1};try{e=await T({type:r.REQUEST_ALLOWED_STATUS})}catch(e){console.error(e)}return e.isAllowed})():Promise.resolve(!1),C=()=>R?(async()=>{let e={isAllowed:!1,error:""};try{e=await T({type:r.SET_ALLOWED_STATUS})}catch(e){console.error(e)}const{isAllowed:o,error:E}=e;if(E)throw E;return o})():Promise.resolve(!1),i=()=>R?(async()=>{let e={userInfo:{publicKey:""},error:""};try{e=await T({type:r.REQUEST_USER_INFO})}catch(e){console.error(e)}const{userInfo:o,error:E}=e;if(E)throw E;return o})():Promise.resolve({publicKey:""}),R="undefined"!=typeof window,a={getPublicKey:t,signTransaction:_,signBlob:S,signAuthEntry:A,isConnected:n,getNetwork:N,getNetworkDetails:s,isAllowed:O,setAllowed:C,getUserInfo:i};return E})());
\ No newline at end of file |