-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
136 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const fs = require('node:fs'); | ||
const { execSync } = require('node:child_process'); | ||
|
||
// create dirs | ||
fs.mkdirSync('./temp', { recursive: true }); | ||
fs.mkdirSync('./src/lib/types', { recursive: true }); | ||
|
||
// generate bindgens | ||
execSync( | ||
`wasm-bindgen --target nodejs ./src-tauri/target/wasm32-unknown-unknown/release/tauri_app.wasm --out-dir ./temp --out-name tauriBindings`, | ||
); | ||
|
||
// prepare and move to src/lib/types | ||
let dts = fs.readFileSync(`./temp/tauriBindings.d.ts`, { | ||
encoding: 'utf-8', | ||
}); | ||
dts = dts.replace( | ||
`/* tslint:disable */ | ||
/* eslint-disable */`, | ||
'', | ||
); | ||
dts = '/* this file is auto-generated, do not modify */\n' + dts; | ||
fs.writeFileSync(`./src/lib/types/tauriBindings.ts`, dts); | ||
|
||
execSync('npm run rm-temp'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[cfg(target_family = "wasm")] | ||
pub mod types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod toast; | ||
mod transaction_status; | ||
|
||
pub use toast::*; | ||
pub use transaction_status::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use serde::{Deserialize, Serialize}; | ||
#[cfg(target_family = "wasm")] | ||
use wasm_bindgen_utils::{impl_wasm_traits, prelude::*}; | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
#[cfg_attr(target_family = "wasm", wasm_bindgen)] | ||
pub enum ToastMessageType { | ||
Success, | ||
Error, | ||
Warning, | ||
Info, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
#[cfg_attr(target_family = "wasm", derive(Tsify))] | ||
pub struct ToastPayload { | ||
pub message_type: ToastMessageType, | ||
pub text: String, | ||
} | ||
#[cfg(target_family = "wasm")] | ||
impl_wasm_traits!(ToastPayload); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use chrono::{DateTime, Utc}; | ||
use serde::{Deserialize, Serialize}; | ||
use uuid::Uuid; | ||
#[cfg(target_family = "wasm")] | ||
use wasm_bindgen_utils::{impl_wasm_traits, prelude::*}; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug)] | ||
#[serde(tag = "type", content = "payload")] | ||
#[cfg_attr(target_family = "wasm", derive(Tsify))] | ||
pub enum TransactionStatus { | ||
Initialized, | ||
PendingPrepare, | ||
PendingSign, | ||
PendingSend, | ||
Confirmed(String), | ||
Failed(String), | ||
} | ||
#[cfg(target_family = "wasm")] | ||
impl_wasm_traits!(TransactionStatus); | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug)] | ||
#[cfg_attr(target_family = "wasm", derive(Tsify))] | ||
pub struct TransactionStatusNotice { | ||
#[cfg_attr(target_family = "wasm", tsify(type = "string"))] | ||
pub id: Uuid, | ||
pub status: TransactionStatus, | ||
#[cfg_attr(target_family = "wasm", tsify(type = "string"))] | ||
pub created_at: DateTime<Utc>, | ||
/// Human-readable label to display in the UI, describing the transaction i.e. "Approving ERC20 Token Spend" | ||
pub label: String, | ||
} | ||
#[cfg(target_family = "wasm")] | ||
impl_wasm_traits!(TransactionStatusNotice); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.