diff --git a/crates/sage/src/sage.rs b/crates/sage/src/sage.rs index 29894b380..a7e16121e 100644 --- a/crates/sage/src/sage.rs +++ b/crates/sage/src/sage.rs @@ -409,23 +409,14 @@ impl Sage { ) .await?; - let version = Self::database_version(&pool).await?; - - if version < 2 { + if let Err(_error) = sqlx::migrate!("../../migrations").run(&pool).await { + // TODO: Handle migration error return Err(Error::DatabaseVersionTooOld); } - sqlx::migrate!("../../migrations").run(&pool).await?; Ok(pool) } - async fn database_version(pool: &SqlitePool) -> Result { - let row: (i32,) = sqlx::query_as("PRAGMA user_version") - .fetch_one(pool) - .await?; - Ok(row.0) - } - pub fn wallet_db_path(&self, fingerprint: u32) -> Result { let path = self.path.join("wallets").join(fingerprint.to_string()); fs::create_dir_all(&path)?; diff --git a/migrations/0000_pragmas.sql b/migrations/0000_pragmas.sql index 2ed243e1e..a5243959d 100644 --- a/migrations/0000_pragmas.sql +++ b/migrations/0000_pragmas.sql @@ -1,3 +1,2 @@ PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON; -PRAGMA user_version = 2; \ No newline at end of file diff --git a/src/bindings.ts b/src/bindings.ts index 37cc0a9ec..5e3f0520f 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -5,303 +5,303 @@ export const commands = { - async initialize(): Promise { - return await TAURI_INVOKE("initialize"); - }, - async login(req: Login): Promise { - return await TAURI_INVOKE("login", { req }); - }, - async logout(req: Logout): Promise { - return await TAURI_INVOKE("logout", { req }); - }, - async resync(req: Resync): Promise { - return await TAURI_INVOKE("resync", { req }); - }, - async generateMnemonic(req: GenerateMnemonic): Promise { - return await TAURI_INVOKE("generate_mnemonic", { req }); - }, - async importKey(req: ImportKey): Promise { - return await TAURI_INVOKE("import_key", { req }); - }, - async deleteKey(req: DeleteKey): Promise { - return await TAURI_INVOKE("delete_key", { req }); - }, - async renameKey(req: RenameKey): Promise { - return await TAURI_INVOKE("rename_key", { req }); - }, - async getKeys(req: GetKeys): Promise { - return await TAURI_INVOKE("get_keys", { req }); - }, - async getKey(req: GetKey): Promise { - return await TAURI_INVOKE("get_key", { req }); - }, - async getSecretKey(req: GetSecretKey): Promise { - return await TAURI_INVOKE("get_secret_key", { req }); - }, - async sendXch(req: SendXch): Promise { - return await TAURI_INVOKE("send_xch", { req }); - }, - async bulkSendXch(req: BulkSendXch): Promise { - return await TAURI_INVOKE("bulk_send_xch", { req }); - }, - async combineXch(req: CombineXch): Promise { - return await TAURI_INVOKE("combine_xch", { req }); - }, - async autoCombineXch(req: AutoCombineXch): Promise { - return await TAURI_INVOKE("auto_combine_xch", { req }); - }, - async splitXch(req: SplitXch): Promise { - return await TAURI_INVOKE("split_xch", { req }); - }, - async sendCat(req: SendCat): Promise { - return await TAURI_INVOKE("send_cat", { req }); - }, - async bulkSendCat(req: BulkSendCat): Promise { - return await TAURI_INVOKE("bulk_send_cat", { req }); - }, - async combineCat(req: CombineCat): Promise { - return await TAURI_INVOKE("combine_cat", { req }); - }, - async autoCombineCat(req: AutoCombineCat): Promise { - return await TAURI_INVOKE("auto_combine_cat", { req }); - }, - async splitCat(req: SplitCat): Promise { - return await TAURI_INVOKE("split_cat", { req }); - }, - async issueCat(req: IssueCat): Promise { - return await TAURI_INVOKE("issue_cat", { req }); - }, - async createDid(req: CreateDid): Promise { - return await TAURI_INVOKE("create_did", { req }); - }, - async bulkMintNfts(req: BulkMintNfts): Promise { - return await TAURI_INVOKE("bulk_mint_nfts", { req }); - }, - async transferNfts(req: TransferNfts): Promise { - return await TAURI_INVOKE("transfer_nfts", { req }); - }, - async transferDids(req: TransferDids): Promise { - return await TAURI_INVOKE("transfer_dids", { req }); - }, - async normalizeDids(req: NormalizeDids): Promise { - return await TAURI_INVOKE("normalize_dids", { req }); - }, - async addNftUri(req: AddNftUri): Promise { - return await TAURI_INVOKE("add_nft_uri", { req }); - }, - async assignNftsToDid(req: AssignNftsToDid): Promise { - return await TAURI_INVOKE("assign_nfts_to_did", { req }); - }, - async signCoinSpends(req: SignCoinSpends): Promise { - return await TAURI_INVOKE("sign_coin_spends", { req }); - }, - async viewCoinSpends(req: ViewCoinSpends): Promise { - return await TAURI_INVOKE("view_coin_spends", { req }); - }, - async submitTransaction(req: SubmitTransaction): Promise { - return await TAURI_INVOKE("submit_transaction", { req }); - }, - async getSyncStatus(req: GetSyncStatus): Promise { - return await TAURI_INVOKE("get_sync_status", { req }); - }, - async getVersion(req: GetVersion): Promise { - return await TAURI_INVOKE("get_version", { req }); - }, - async checkAddress(req: CheckAddress): Promise { - return await TAURI_INVOKE("check_address", { req }); - }, - async getDerivations(req: GetDerivations): Promise { - return await TAURI_INVOKE("get_derivations", { req }); - }, - async getAreCoinsSpendable(req: GetAreCoinsSpendable): Promise { - return await TAURI_INVOKE("get_are_coins_spendable", { req }); - }, - async getSpendableCoinCount(req: GetSpendableCoinCount): Promise { - return await TAURI_INVOKE("get_spendable_coin_count", { req }); - }, - async getCoinsByIds(req: GetCoinsByIds): Promise { - return await TAURI_INVOKE("get_coins_by_ids", { req }); - }, - async getXchCoins(req: GetXchCoins): Promise { - return await TAURI_INVOKE("get_xch_coins", { req }); - }, - async getCatCoins(req: GetCatCoins): Promise { - return await TAURI_INVOKE("get_cat_coins", { req }); - }, - async getCats(req: GetCats): Promise { - return await TAURI_INVOKE("get_cats", { req }); - }, - async getCat(req: GetCat): Promise { - return await TAURI_INVOKE("get_cat", { req }); - }, - async getDids(req: GetDids): Promise { - return await TAURI_INVOKE("get_dids", { req }); - }, - async getMinterDidIds(req: GetMinterDidIds): Promise { - return await TAURI_INVOKE("get_minter_did_ids", { req }); - }, - async getNftCollections(req: GetNftCollections): Promise { - return await TAURI_INVOKE("get_nft_collections", { req }); - }, - async getNftCollection(req: GetNftCollection): Promise { - return await TAURI_INVOKE("get_nft_collection", { req }); - }, - async getNfts(req: GetNfts): Promise { - return await TAURI_INVOKE("get_nfts", { req }); - }, - async getNft(req: GetNft): Promise { - return await TAURI_INVOKE("get_nft", { req }); - }, - async getNftData(req: GetNftData): Promise { - return await TAURI_INVOKE("get_nft_data", { req }); - }, - async getNftIcon(req: GetNftIcon): Promise { - return await TAURI_INVOKE("get_nft_icon", { req }); - }, - async getNftThumbnail(req: GetNftThumbnail): Promise { - return await TAURI_INVOKE("get_nft_thumbnail", { req }); - }, - async getPendingTransactions(req: GetPendingTransactions): Promise { - return await TAURI_INVOKE("get_pending_transactions", { req }); - }, - async getTransactions(req: GetTransactions): Promise { - return await TAURI_INVOKE("get_transactions", { req }); - }, - async validateAddress(address: string): Promise { - return await TAURI_INVOKE("validate_address", { address }); - }, - async makeOffer(req: MakeOffer): Promise { - return await TAURI_INVOKE("make_offer", { req }); - }, - async takeOffer(req: TakeOffer): Promise { - return await TAURI_INVOKE("take_offer", { req }); - }, - async combineOffers(req: CombineOffers): Promise { - return await TAURI_INVOKE("combine_offers", { req }); - }, - async viewOffer(req: ViewOffer): Promise { - return await TAURI_INVOKE("view_offer", { req }); - }, - async importOffer(req: ImportOffer): Promise { - return await TAURI_INVOKE("import_offer", { req }); - }, - async getOffers(req: GetOffers): Promise { - return await TAURI_INVOKE("get_offers", { req }); - }, - async getOffer(req: GetOffer): Promise { - return await TAURI_INVOKE("get_offer", { req }); - }, - async deleteOffer(req: DeleteOffer): Promise { - return await TAURI_INVOKE("delete_offer", { req }); - }, - async cancelOffer(req: CancelOffer): Promise { - return await TAURI_INVOKE("cancel_offer", { req }); - }, - async cancelOffers(req: CancelOffers): Promise { - return await TAURI_INVOKE("cancel_offers", { req }); - }, - async networkConfig(): Promise { - return await TAURI_INVOKE("network_config"); - }, - async setDiscoverPeers(req: SetDiscoverPeers): Promise { - return await TAURI_INVOKE("set_discover_peers", { req }); - }, - async setTargetPeers(req: SetTargetPeers): Promise { - return await TAURI_INVOKE("set_target_peers", { req }); - }, - async setNetwork(req: SetNetwork): Promise { - return await TAURI_INVOKE("set_network", { req }); - }, - async setNetworkOverride(req: SetNetworkOverride): Promise { - return await TAURI_INVOKE("set_network_override", { req }); - }, - async walletConfig(fingerprint: number): Promise { - return await TAURI_INVOKE("wallet_config", { fingerprint }); - }, - async getNetworks(req: GetNetworks): Promise { - return await TAURI_INVOKE("get_networks", { req }); - }, - async getNetwork(req: GetNetwork): Promise { - return await TAURI_INVOKE("get_network", { req }); - }, - async updateCat(req: UpdateCat): Promise { - return await TAURI_INVOKE("update_cat", { req }); - }, - async resyncCat(req: ResyncCat): Promise { - return await TAURI_INVOKE("resync_cat", { req }); - }, - async updateDid(req: UpdateDid): Promise { - return await TAURI_INVOKE("update_did", { req }); - }, - async updateNft(req: UpdateNft): Promise { - return await TAURI_INVOKE("update_nft", { req }); - }, - async updateNftCollection(req: UpdateNftCollection): Promise { - return await TAURI_INVOKE("update_nft_collection", { req }); - }, - async redownloadNft(req: RedownloadNft): Promise { - return await TAURI_INVOKE("redownload_nft", { req }); - }, - async increaseDerivationIndex(req: IncreaseDerivationIndex): Promise { - return await TAURI_INVOKE("increase_derivation_index", { req }); - }, - async getPeers(req: GetPeers): Promise { - return await TAURI_INVOKE("get_peers", { req }); - }, - async addPeer(req: AddPeer): Promise { - return await TAURI_INVOKE("add_peer", { req }); - }, - async removePeer(req: RemovePeer): Promise { - return await TAURI_INVOKE("remove_peer", { req }); - }, - async filterUnlockedCoins(req: FilterUnlockedCoins): Promise { - return await TAURI_INVOKE("filter_unlocked_coins", { req }); - }, - async getAssetCoins(req: GetAssetCoins): Promise { - return await TAURI_INVOKE("get_asset_coins", { req }); - }, - async signMessageWithPublicKey(req: SignMessageWithPublicKey): Promise { - return await TAURI_INVOKE("sign_message_with_public_key", { req }); - }, - async signMessageByAddress(req: SignMessageByAddress): Promise { - return await TAURI_INVOKE("sign_message_by_address", { req }); - }, - async sendTransactionImmediately(req: SendTransactionImmediately): Promise { - return await TAURI_INVOKE("send_transaction_immediately", { req }); - }, - async isRpcRunning(): Promise { - return await TAURI_INVOKE("is_rpc_running"); - }, - async startRpcServer(): Promise { - return await TAURI_INVOKE("start_rpc_server"); - }, - async stopRpcServer(): Promise { - return await TAURI_INVOKE("stop_rpc_server"); - }, - async getRpcRunOnStartup(): Promise { - return await TAURI_INVOKE("get_rpc_run_on_startup"); - }, - async setRpcRunOnStartup(runOnStartup: boolean): Promise { - return await TAURI_INVOKE("set_rpc_run_on_startup", { runOnStartup }); - }, - async switchWallet(): Promise { - return await TAURI_INVOKE("switch_wallet"); - }, - async moveKey(fingerprint: number, index: number): Promise { - return await TAURI_INVOKE("move_key", { fingerprint, index }); - }, - async downloadCniOffercode(code: string): Promise { - return await TAURI_INVOKE("download_cni_offercode", { code }); - } +async initialize() : Promise { + return await TAURI_INVOKE("initialize"); +}, +async login(req: Login) : Promise { + return await TAURI_INVOKE("login", { req }); +}, +async logout(req: Logout) : Promise { + return await TAURI_INVOKE("logout", { req }); +}, +async resync(req: Resync) : Promise { + return await TAURI_INVOKE("resync", { req }); +}, +async generateMnemonic(req: GenerateMnemonic) : Promise { + return await TAURI_INVOKE("generate_mnemonic", { req }); +}, +async importKey(req: ImportKey) : Promise { + return await TAURI_INVOKE("import_key", { req }); +}, +async deleteKey(req: DeleteKey) : Promise { + return await TAURI_INVOKE("delete_key", { req }); +}, +async renameKey(req: RenameKey) : Promise { + return await TAURI_INVOKE("rename_key", { req }); +}, +async getKeys(req: GetKeys) : Promise { + return await TAURI_INVOKE("get_keys", { req }); +}, +async getKey(req: GetKey) : Promise { + return await TAURI_INVOKE("get_key", { req }); +}, +async getSecretKey(req: GetSecretKey) : Promise { + return await TAURI_INVOKE("get_secret_key", { req }); +}, +async sendXch(req: SendXch) : Promise { + return await TAURI_INVOKE("send_xch", { req }); +}, +async bulkSendXch(req: BulkSendXch) : Promise { + return await TAURI_INVOKE("bulk_send_xch", { req }); +}, +async combineXch(req: CombineXch) : Promise { + return await TAURI_INVOKE("combine_xch", { req }); +}, +async autoCombineXch(req: AutoCombineXch) : Promise { + return await TAURI_INVOKE("auto_combine_xch", { req }); +}, +async splitXch(req: SplitXch) : Promise { + return await TAURI_INVOKE("split_xch", { req }); +}, +async sendCat(req: SendCat) : Promise { + return await TAURI_INVOKE("send_cat", { req }); +}, +async bulkSendCat(req: BulkSendCat) : Promise { + return await TAURI_INVOKE("bulk_send_cat", { req }); +}, +async combineCat(req: CombineCat) : Promise { + return await TAURI_INVOKE("combine_cat", { req }); +}, +async autoCombineCat(req: AutoCombineCat) : Promise { + return await TAURI_INVOKE("auto_combine_cat", { req }); +}, +async splitCat(req: SplitCat) : Promise { + return await TAURI_INVOKE("split_cat", { req }); +}, +async issueCat(req: IssueCat) : Promise { + return await TAURI_INVOKE("issue_cat", { req }); +}, +async createDid(req: CreateDid) : Promise { + return await TAURI_INVOKE("create_did", { req }); +}, +async bulkMintNfts(req: BulkMintNfts) : Promise { + return await TAURI_INVOKE("bulk_mint_nfts", { req }); +}, +async transferNfts(req: TransferNfts) : Promise { + return await TAURI_INVOKE("transfer_nfts", { req }); +}, +async transferDids(req: TransferDids) : Promise { + return await TAURI_INVOKE("transfer_dids", { req }); +}, +async normalizeDids(req: NormalizeDids) : Promise { + return await TAURI_INVOKE("normalize_dids", { req }); +}, +async addNftUri(req: AddNftUri) : Promise { + return await TAURI_INVOKE("add_nft_uri", { req }); +}, +async assignNftsToDid(req: AssignNftsToDid) : Promise { + return await TAURI_INVOKE("assign_nfts_to_did", { req }); +}, +async signCoinSpends(req: SignCoinSpends) : Promise { + return await TAURI_INVOKE("sign_coin_spends", { req }); +}, +async viewCoinSpends(req: ViewCoinSpends) : Promise { + return await TAURI_INVOKE("view_coin_spends", { req }); +}, +async submitTransaction(req: SubmitTransaction) : Promise { + return await TAURI_INVOKE("submit_transaction", { req }); +}, +async getSyncStatus(req: GetSyncStatus) : Promise { + return await TAURI_INVOKE("get_sync_status", { req }); +}, +async getVersion(req: GetVersion) : Promise { + return await TAURI_INVOKE("get_version", { req }); +}, +async checkAddress(req: CheckAddress) : Promise { + return await TAURI_INVOKE("check_address", { req }); +}, +async getDerivations(req: GetDerivations) : Promise { + return await TAURI_INVOKE("get_derivations", { req }); +}, +async getAreCoinsSpendable(req: GetAreCoinsSpendable) : Promise { + return await TAURI_INVOKE("get_are_coins_spendable", { req }); +}, +async getSpendableCoinCount(req: GetSpendableCoinCount) : Promise { + return await TAURI_INVOKE("get_spendable_coin_count", { req }); +}, +async getCoinsByIds(req: GetCoinsByIds) : Promise { + return await TAURI_INVOKE("get_coins_by_ids", { req }); +}, +async getXchCoins(req: GetXchCoins) : Promise { + return await TAURI_INVOKE("get_xch_coins", { req }); +}, +async getCatCoins(req: GetCatCoins) : Promise { + return await TAURI_INVOKE("get_cat_coins", { req }); +}, +async getCats(req: GetCats) : Promise { + return await TAURI_INVOKE("get_cats", { req }); +}, +async getCat(req: GetCat) : Promise { + return await TAURI_INVOKE("get_cat", { req }); +}, +async getDids(req: GetDids) : Promise { + return await TAURI_INVOKE("get_dids", { req }); +}, +async getMinterDidIds(req: GetMinterDidIds) : Promise { + return await TAURI_INVOKE("get_minter_did_ids", { req }); +}, +async getNftCollections(req: GetNftCollections) : Promise { + return await TAURI_INVOKE("get_nft_collections", { req }); +}, +async getNftCollection(req: GetNftCollection) : Promise { + return await TAURI_INVOKE("get_nft_collection", { req }); +}, +async getNfts(req: GetNfts) : Promise { + return await TAURI_INVOKE("get_nfts", { req }); +}, +async getNft(req: GetNft) : Promise { + return await TAURI_INVOKE("get_nft", { req }); +}, +async getNftData(req: GetNftData) : Promise { + return await TAURI_INVOKE("get_nft_data", { req }); +}, +async getNftIcon(req: GetNftIcon) : Promise { + return await TAURI_INVOKE("get_nft_icon", { req }); +}, +async getNftThumbnail(req: GetNftThumbnail) : Promise { + return await TAURI_INVOKE("get_nft_thumbnail", { req }); +}, +async getPendingTransactions(req: GetPendingTransactions) : Promise { + return await TAURI_INVOKE("get_pending_transactions", { req }); +}, +async getTransactions(req: GetTransactions) : Promise { + return await TAURI_INVOKE("get_transactions", { req }); +}, +async validateAddress(address: string) : Promise { + return await TAURI_INVOKE("validate_address", { address }); +}, +async makeOffer(req: MakeOffer) : Promise { + return await TAURI_INVOKE("make_offer", { req }); +}, +async takeOffer(req: TakeOffer) : Promise { + return await TAURI_INVOKE("take_offer", { req }); +}, +async combineOffers(req: CombineOffers) : Promise { + return await TAURI_INVOKE("combine_offers", { req }); +}, +async viewOffer(req: ViewOffer) : Promise { + return await TAURI_INVOKE("view_offer", { req }); +}, +async importOffer(req: ImportOffer) : Promise { + return await TAURI_INVOKE("import_offer", { req }); +}, +async getOffers(req: GetOffers) : Promise { + return await TAURI_INVOKE("get_offers", { req }); +}, +async getOffer(req: GetOffer) : Promise { + return await TAURI_INVOKE("get_offer", { req }); +}, +async deleteOffer(req: DeleteOffer) : Promise { + return await TAURI_INVOKE("delete_offer", { req }); +}, +async cancelOffer(req: CancelOffer) : Promise { + return await TAURI_INVOKE("cancel_offer", { req }); +}, +async cancelOffers(req: CancelOffers) : Promise { + return await TAURI_INVOKE("cancel_offers", { req }); +}, +async networkConfig() : Promise { + return await TAURI_INVOKE("network_config"); +}, +async setDiscoverPeers(req: SetDiscoverPeers) : Promise { + return await TAURI_INVOKE("set_discover_peers", { req }); +}, +async setTargetPeers(req: SetTargetPeers) : Promise { + return await TAURI_INVOKE("set_target_peers", { req }); +}, +async setNetwork(req: SetNetwork) : Promise { + return await TAURI_INVOKE("set_network", { req }); +}, +async setNetworkOverride(req: SetNetworkOverride) : Promise { + return await TAURI_INVOKE("set_network_override", { req }); +}, +async walletConfig(fingerprint: number) : Promise { + return await TAURI_INVOKE("wallet_config", { fingerprint }); +}, +async getNetworks(req: GetNetworks) : Promise { + return await TAURI_INVOKE("get_networks", { req }); +}, +async getNetwork(req: GetNetwork) : Promise { + return await TAURI_INVOKE("get_network", { req }); +}, +async updateCat(req: UpdateCat) : Promise { + return await TAURI_INVOKE("update_cat", { req }); +}, +async resyncCat(req: ResyncCat) : Promise { + return await TAURI_INVOKE("resync_cat", { req }); +}, +async updateDid(req: UpdateDid) : Promise { + return await TAURI_INVOKE("update_did", { req }); +}, +async updateNft(req: UpdateNft) : Promise { + return await TAURI_INVOKE("update_nft", { req }); +}, +async updateNftCollection(req: UpdateNftCollection) : Promise { + return await TAURI_INVOKE("update_nft_collection", { req }); +}, +async redownloadNft(req: RedownloadNft) : Promise { + return await TAURI_INVOKE("redownload_nft", { req }); +}, +async increaseDerivationIndex(req: IncreaseDerivationIndex) : Promise { + return await TAURI_INVOKE("increase_derivation_index", { req }); +}, +async getPeers(req: GetPeers) : Promise { + return await TAURI_INVOKE("get_peers", { req }); +}, +async addPeer(req: AddPeer) : Promise { + return await TAURI_INVOKE("add_peer", { req }); +}, +async removePeer(req: RemovePeer) : Promise { + return await TAURI_INVOKE("remove_peer", { req }); +}, +async filterUnlockedCoins(req: FilterUnlockedCoins) : Promise { + return await TAURI_INVOKE("filter_unlocked_coins", { req }); +}, +async getAssetCoins(req: GetAssetCoins) : Promise { + return await TAURI_INVOKE("get_asset_coins", { req }); +}, +async signMessageWithPublicKey(req: SignMessageWithPublicKey) : Promise { + return await TAURI_INVOKE("sign_message_with_public_key", { req }); +}, +async signMessageByAddress(req: SignMessageByAddress) : Promise { + return await TAURI_INVOKE("sign_message_by_address", { req }); +}, +async sendTransactionImmediately(req: SendTransactionImmediately) : Promise { + return await TAURI_INVOKE("send_transaction_immediately", { req }); +}, +async isRpcRunning() : Promise { + return await TAURI_INVOKE("is_rpc_running"); +}, +async startRpcServer() : Promise { + return await TAURI_INVOKE("start_rpc_server"); +}, +async stopRpcServer() : Promise { + return await TAURI_INVOKE("stop_rpc_server"); +}, +async getRpcRunOnStartup() : Promise { + return await TAURI_INVOKE("get_rpc_run_on_startup"); +}, +async setRpcRunOnStartup(runOnStartup: boolean) : Promise { + return await TAURI_INVOKE("set_rpc_run_on_startup", { runOnStartup }); +}, +async switchWallet() : Promise { + return await TAURI_INVOKE("switch_wallet"); +}, +async moveKey(fingerprint: number, index: number) : Promise { + return await TAURI_INVOKE("move_key", { fingerprint, index }); +}, +async downloadCniOffercode(code: string) : Promise { + return await TAURI_INVOKE("download_cni_offercode", { code }); +} } /** user-defined events **/ export const events = __makeEvents__<{ - syncEvent: SyncEvent +syncEvent: SyncEvent }>({ - syncEvent: "sync-event" +syncEvent: "sync-event" }) /** user-defined constants **/ @@ -324,19 +324,19 @@ export type AutoCombineXch = { max_coins: number; max_coin_amount: Amount | null export type AutoCombineXchResponse = { coin_ids: string[]; summary: TransactionSummary; coin_spends: CoinSpendJson[] } export type BulkMintNfts = { mints: NftMint[]; did_id: string; fee: Amount; auto_submit?: boolean } export type BulkMintNftsResponse = { nft_ids: string[]; summary: TransactionSummary; coin_spends: CoinSpendJson[] } -export type BulkSendCat = { asset_id: string; addresses: string[]; amount: Amount; fee: Amount; include_hint?: boolean; memos?: string[] | null; auto_submit?: boolean } -export type BulkSendXch = { addresses: string[]; amount: Amount; fee: Amount; memos?: string[] | null; auto_submit?: boolean } +export type BulkSendCat = { asset_id: string; addresses: string[]; amount: Amount; fee: Amount; include_hint?: boolean; memos?: string[]; auto_submit?: boolean } +export type BulkSendXch = { addresses: string[]; amount: Amount; fee: Amount; memos?: string[]; auto_submit?: boolean } export type CancelOffer = { offer_id: string; fee: Amount; auto_submit?: boolean } export type CancelOffers = { offer_ids: string[]; fee: Amount; auto_submit?: boolean } export type CatAmount = { asset_id: string; amount: Amount } export type CatRecord = { asset_id: string; name: string | null; ticker: string | null; description: string | null; icon_url: string | null; visible: boolean; balance: Amount } -export type ChangeMode = { mode: "default" } | +export type ChangeMode = { mode: "default" } | /** * Reuse the first address of coins involved in the transaction * as the change address for the output. This improves compatibility * with wallets which do not support multiple addresses. */ -{ mode: "same" } | +{ mode: "same" } | /** * Use an address that has not been used before as the change address * for the output. This is beneficial for privacy, but results in more @@ -347,7 +347,7 @@ export type CheckAddress = { address: string } export type CheckAddressResponse = { valid: boolean } export type Coin = { parent_coin_info: string; puzzle_hash: string; amount: number } export type CoinJson = { parent_coin_info: string; puzzle_hash: string; amount: Amount } -export type CoinRecord = { coin_id: string; address: string; amount: Amount; created_height: number | null; spent_height: number | null; create_transaction_id: string | null; spend_transaction_id: string | null; offer_id: string | null; spent_timestamp: number | null; created_timestamp: number | null } +export type CoinRecord = { coin_id: string; address: string; amount: Amount; created_height: number | null; spent_height: number | null; transaction_id: string | null; offer_id: string | null; spent_timestamp: number | null; created_timestamp: number | null } export type CoinSortMode = "coin_id" | "amount" | "created_height" | "spent_height" export type CoinSpend = { coin: Coin; puzzle_reveal: string; solution: string } export type CoinSpendJson = { coin: CoinJson; puzzle_reveal: string; solution: string } @@ -360,12 +360,12 @@ export type DeleteKey = { fingerprint: number } export type DeleteKeyResponse = Record export type DeleteOffer = { offer_id: string } export type DeleteOfferResponse = Record -export type DerivationMode = { mode: "default" } | +export type DerivationMode = { mode: "default" } | /** * Automatically generate new addresses if there aren't enough that * haven't been used yet. */ -{ mode: "auto"; derivation_batch_size: number } | +{ mode: "auto"; derivation_batch_size: number } | /** * Don't generate any new addresses, only use existing ones. */ @@ -468,26 +468,26 @@ export type OfferAssets = { xch: OfferXch; cats: { [key in string]: OfferCat }; export type OfferCat = { amount: Amount; royalty: Amount; name: string | null; ticker: string | null; icon_url: string | null } export type OfferNft = { icon: string | null; name: string | null; royalty_ten_thousandths: number; royalty_address: string } export type OfferRecord = { offer_id: string; offer: string; status: OfferRecordStatus; creation_date: string; summary: OfferSummary } -export type OfferRecordStatus = "active" | "completed" | "cancelled" | "expired" +export type OfferRecordStatus = "pending" | "active" | "completed" | "cancelled" | "expired" export type OfferSummary = { fee: Amount; maker: OfferAssets; taker: OfferAssets; expiration_height: number | null; expiration_timestamp: number | null } export type OfferXch = { amount: Amount; royalty: Amount } export type PeerRecord = { ip_addr: string; port: number; peak_height: number; user_managed: boolean } export type PendingTransactionRecord = { transaction_id: string; fee: Amount; submitted_at: string | null } export type RedownloadNft = { nft_id: string } export type RedownloadNftResponse = Record -export type ResyncCat = { asset_id: string } -export type ResyncCatResponse = Record export type RemovePeer = { ip: string; ban: boolean } export type RemovePeerResponse = Record export type RenameKey = { fingerprint: number; name: string } export type RenameKeyResponse = Record export type Resync = { fingerprint: number; delete_offer_files?: boolean; delete_addresses?: boolean; delete_blockinfo?: boolean } +export type ResyncCat = { asset_id: string } +export type ResyncCatResponse = Record export type ResyncResponse = Record export type SecretKeyInfo = { mnemonic: string | null; secret_key: string } -export type SendCat = { asset_id: string; address: string; amount: Amount; fee: Amount; include_hint?: boolean; memos?: string[] | null; auto_submit?: boolean } +export type SendCat = { asset_id: string; address: string; amount: Amount; fee: Amount; include_hint?: boolean; memos?: string[]; auto_submit?: boolean } export type SendTransactionImmediately = { spend_bundle: SpendBundle } export type SendTransactionImmediatelyResponse = { status: number; error: string | null } -export type SendXch = { address: string; amount: Amount; fee: Amount; memos?: string[] | null; auto_submit?: boolean } +export type SendXch = { address: string; amount: Amount; fee: Amount; memos?: string[]; auto_submit?: boolean } export type SetDiscoverPeers = { discover_peers: boolean } export type SetDiscoverPeersResponse = Record export type SetNetwork = { name: string } @@ -512,10 +512,10 @@ export type SubmitTransactionResponse = Record export type SyncEvent = { type: "start"; ip: string } | { type: "stop" } | { type: "subscribed" } | { type: "derivation" } | { type: "coin_state" } | { type: "transaction_failed"; transaction_id: string; error: string | null } | { type: "puzzle_batch_synced" } | { type: "cat_info" } | { type: "did_info" } | { type: "nft_data" } export type TakeOffer = { offer: string; fee: Amount; auto_submit?: boolean; auto_import?: boolean } export type TakeOfferResponse = { summary: TransactionSummary; spend_bundle: SpendBundleJson; transaction_id: string } -export type TransactionCoin = ({ type: "unknown" } | { type: "xch" } | { type: "launcher" } | { type: "cat"; asset_id: string; name: string | null; ticker: string | null; icon_url: string | null } | { type: "did"; launcher_id: string; name: string | null } | { type: "nft"; launcher_id: string; icon: string | null; name: string | null }) & { coin_id: string; amount: Amount; address: string | null; address_kind: AddressKind } -export type TransactionInput = ({ type: "unknown" } | { type: "xch" } | { type: "launcher" } | { type: "cat"; asset_id: string; name: string | null; ticker: string | null; icon_url: string | null } | { type: "did"; launcher_id: string; name: string | null } | { type: "nft"; launcher_id: string; icon: string | null; name: string | null }) & { coin_id: string; amount: Amount; address: string; outputs: TransactionOutput[] } +export type TransactionInput = ({ type: "unknown" } | { type: "xch" } | { type: "launcher" } | { type: "cat"; asset_id: string; name: string | null; ticker: string | null; icon_url: string | null } | { type: "did"; launcher_id: string; name: string | null } | { type: "nft"; launcher_id: string; icon: string | null; name: string | null } | { type: "option" }) & { coin_id: string; amount: Amount; address: string; outputs: TransactionOutput[] } export type TransactionOutput = { coin_id: string; amount: Amount; address: string; receiving: boolean; burning: boolean } -export type TransactionRecord = { height: number; timestamp: number | null; spent: TransactionCoin[]; created: TransactionCoin[] } +export type TransactionRecord = { height: number; timestamp: number | null; spent: TransactionRecordCoin[]; created: TransactionRecordCoin[] } +export type TransactionRecordCoin = ({ type: "unknown" } | { type: "xch" } | { type: "launcher" } | { type: "cat"; asset_id: string; name: string | null; ticker: string | null; icon_url: string | null } | { type: "did"; launcher_id: string; name: string | null } | { type: "nft"; launcher_id: string; icon: string | null; name: string | null } | { type: "option" }) & { coin_id: string; amount: Amount; address: string | null; address_kind: AddressKind } export type TransactionResponse = { summary: TransactionSummary; coin_spends: CoinSpendJson[] } export type TransactionSummary = { fee: Amount; inputs: TransactionInput[] } export type TransferDids = { did_ids: string[]; address: string; fee: Amount; auto_submit?: boolean } @@ -538,59 +538,59 @@ export type Wallet = { name?: string; fingerprint: number; change: ChangeMode; d /** tauri-specta globals **/ import { - invoke as TAURI_INVOKE, - Channel as TAURI_CHANNEL, + invoke as TAURI_INVOKE, + Channel as TAURI_CHANNEL, } from "@tauri-apps/api/core"; import * as TAURI_API_EVENT from "@tauri-apps/api/event"; import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; type __EventObj__ = { - listen: ( - cb: TAURI_API_EVENT.EventCallback, - ) => ReturnType>; - once: ( - cb: TAURI_API_EVENT.EventCallback, - ) => ReturnType>; - emit: null extends T - ? (payload?: T) => ReturnType - : (payload: T) => ReturnType; + listen: ( + cb: TAURI_API_EVENT.EventCallback, + ) => ReturnType>; + once: ( + cb: TAURI_API_EVENT.EventCallback, + ) => ReturnType>; + emit: null extends T + ? (payload?: T) => ReturnType + : (payload: T) => ReturnType; }; export type Result = - | { status: "ok"; data: T } - | { status: "error"; error: E }; + | { status: "ok"; data: T } + | { status: "error"; error: E }; function __makeEvents__>( - mappings: Record, + mappings: Record, ) { - return new Proxy( - {} as unknown as { - [K in keyof T]: __EventObj__ & { - (handle: __WebviewWindow__): __EventObj__; - }; - }, - { - get: (_, event) => { - const name = mappings[event as keyof T]; + return new Proxy( + {} as unknown as { + [K in keyof T]: __EventObj__ & { + (handle: __WebviewWindow__): __EventObj__; + }; + }, + { + get: (_, event) => { + const name = mappings[event as keyof T]; - return new Proxy((() => { }) as any, { - apply: (_, __, [window]: [__WebviewWindow__]) => ({ - listen: (arg: any) => window.listen(name, arg), - once: (arg: any) => window.once(name, arg), - emit: (arg: any) => window.emit(name, arg), - }), - get: (_, command: keyof __EventObj__) => { - switch (command) { - case "listen": - return (arg: any) => TAURI_API_EVENT.listen(name, arg); - case "once": - return (arg: any) => TAURI_API_EVENT.once(name, arg); - case "emit": - return (arg: any) => TAURI_API_EVENT.emit(name, arg); - } - }, - }); - }, - }, - ); + return new Proxy((() => {}) as any, { + apply: (_, __, [window]: [__WebviewWindow__]) => ({ + listen: (arg: any) => window.listen(name, arg), + once: (arg: any) => window.once(name, arg), + emit: (arg: any) => window.emit(name, arg), + }), + get: (_, command: keyof __EventObj__) => { + switch (command) { + case "listen": + return (arg: any) => TAURI_API_EVENT.listen(name, arg); + case "once": + return (arg: any) => TAURI_API_EVENT.once(name, arg); + case "emit": + return (arg: any) => TAURI_API_EVENT.emit(name, arg); + } + }, + }); + }, + }, + ); }