From 1904a913b84e01e902173e782ab45e0e3b4ccf8d Mon Sep 17 00:00:00 2001 From: kaotisk Date: Wed, 27 Dec 2023 16:29:28 +0200 Subject: Use only local libraries --- .../@shared/api/external.d.ts | 24 ++++ .../@shared/api/helpers/extensionMessaging.d.ts | 9 ++ .../stellar-freighter-api/@shared/api/types.d.ts | 158 +++++++++++++++++++++ .../@shared/constants/applicationState.d.ts | 8 ++ .../@shared/constants/hardwareWallet.d.ts | 4 + .../@shared/constants/services.d.ts | 62 ++++++++ .../@shared/constants/stellar.d.ts | 34 +++++ 7 files changed, 299 insertions(+) create mode 100644 src/external/stellar-freighter-api/@shared/api/external.d.ts create mode 100644 src/external/stellar-freighter-api/@shared/api/helpers/extensionMessaging.d.ts create mode 100644 src/external/stellar-freighter-api/@shared/api/types.d.ts create mode 100644 src/external/stellar-freighter-api/@shared/constants/applicationState.d.ts create mode 100644 src/external/stellar-freighter-api/@shared/constants/hardwareWallet.d.ts create mode 100644 src/external/stellar-freighter-api/@shared/constants/services.d.ts create mode 100644 src/external/stellar-freighter-api/@shared/constants/stellar.d.ts (limited to 'src/external/stellar-freighter-api/@shared') 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; +export declare const submitTransaction: (transactionXdr: string, opts?: string | { + network?: string | undefined; + accountToSign?: string | undefined; + networkPassphrase?: string | undefined; +} | undefined, accountToSign?: string | undefined) => Promise; +export declare const submitBlob: (blob: string, opts?: { + accountToSign?: string | undefined; +} | undefined) => Promise; +export declare const submitAuthEntry: (entryXdr: string, opts?: { + accountToSign?: string | undefined; +} | undefined) => Promise; +export declare const requestNetwork: () => Promise; +export declare const requestNetworkDetails: () => Promise<{ + network: string; + networkUrl: string; + networkPassphrase: string; + sorobanRpcUrl?: string | undefined; +}>; +export declare const requestConnectionStatus: () => Promise; +export declare const requestAllowedStatus: () => Promise; +export declare const setAllowedStatus: () => Promise; +export declare const requestUserInfo: () => Promise; 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; +export declare const sendMessageToBackground: (msg: Msg) => Promise; +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; + accountName: string; + assetCode: string; + assetCanonical: string; + iconUrl: string; + network: string; + networkIndex: number; + networkName: string; + recentAddresses: Array; + 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 | []; +} +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; -- cgit v1.2.3