@otoplo/wallet-common 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/index.d.ts +2278 -0
- package/dist/index.js +2005 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
- package/src/index.ts +5 -0
- package/src/persistence/datastore/db.ts +47 -0
- package/src/persistence/datastore/index.ts +2 -0
- package/src/persistence/datastore/kv.ts +129 -0
- package/src/persistence/index.ts +2 -0
- package/src/persistence/wallet-db.ts +251 -0
- package/src/services/asset.ts +220 -0
- package/src/services/cache.ts +54 -0
- package/src/services/discovery.ts +110 -0
- package/src/services/index.ts +8 -0
- package/src/services/key.ts +55 -0
- package/src/services/rostrum.ts +214 -0
- package/src/services/session.ts +225 -0
- package/src/services/transaction.ts +388 -0
- package/src/services/tx-transformer.ts +244 -0
- package/src/services/wallet.ts +650 -0
- package/src/state/hooks.ts +45 -0
- package/src/state/index.ts +3 -0
- package/src/state/slices/auth.ts +28 -0
- package/src/state/slices/dapp.ts +32 -0
- package/src/state/slices/index.ts +6 -0
- package/src/state/slices/loader.ts +31 -0
- package/src/state/slices/notifications.ts +44 -0
- package/src/state/slices/status.ts +70 -0
- package/src/state/slices/wallet.ts +112 -0
- package/src/state/store.ts +24 -0
- package/src/types/dapp.types.ts +21 -0
- package/src/types/db.types.ts +142 -0
- package/src/types/index.ts +5 -0
- package/src/types/notification.types.ts +13 -0
- package/src/types/rostrum.types.ts +161 -0
- package/src/types/wallet.types.ts +62 -0
- package/src/utils/asset.ts +103 -0
- package/src/utils/common.ts +159 -0
- package/src/utils/enums.ts +22 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/keypath.ts +15 -0
- package/src/utils/price.ts +40 -0
- package/src/utils/seed.ts +57 -0
- package/src/utils/vault.ts +39 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
|
|
4
|
+
export interface AuthState {
|
|
5
|
+
isWalletExist: boolean;
|
|
6
|
+
isAuthorized: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const initialState: AuthState = {
|
|
10
|
+
isWalletExist: false,
|
|
11
|
+
isAuthorized: false,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const authSlice = createSlice({
|
|
15
|
+
name: 'auth',
|
|
16
|
+
initialState,
|
|
17
|
+
reducers: {
|
|
18
|
+
setWalletExist: (state, action: PayloadAction<boolean>) => {
|
|
19
|
+
state.isWalletExist = action.payload;
|
|
20
|
+
},
|
|
21
|
+
setAuthorized: (state, action: PayloadAction<boolean>) => {
|
|
22
|
+
state.isAuthorized = action.payload;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const authActions = authSlice.actions;
|
|
28
|
+
export const authReducer = authSlice.reducer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
import type { SessionRequestType } from "../../utils";
|
|
4
|
+
import type { DappRpcRequest } from "../../types";
|
|
5
|
+
|
|
6
|
+
export interface DappModalState {
|
|
7
|
+
modalType: SessionRequestType | null;
|
|
8
|
+
currentRequest: DappRpcRequest | null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const initialState: DappModalState = {
|
|
12
|
+
modalType: null,
|
|
13
|
+
currentRequest: null,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const dappModalSlice = createSlice({
|
|
17
|
+
name: 'dappModal',
|
|
18
|
+
initialState,
|
|
19
|
+
reducers: {
|
|
20
|
+
showRequest(state, action: PayloadAction<DappRpcRequest>) {
|
|
21
|
+
state.modalType = action.payload.type;
|
|
22
|
+
state.currentRequest = action.payload;
|
|
23
|
+
},
|
|
24
|
+
clear(state) {
|
|
25
|
+
state.modalType = null;
|
|
26
|
+
state.currentRequest = null;
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const dappModalActions = dappModalSlice.actions;
|
|
32
|
+
export const dappModalReducer = dappModalSlice.reducer;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
|
|
4
|
+
export interface LoaderState {
|
|
5
|
+
counter: number
|
|
6
|
+
loading: boolean;
|
|
7
|
+
text?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const initState: LoaderState = {
|
|
11
|
+
counter: 0,
|
|
12
|
+
loading: false
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const loaderSlice = createSlice({
|
|
16
|
+
name: 'loader',
|
|
17
|
+
initialState: initState,
|
|
18
|
+
reducers: {
|
|
19
|
+
setLoader: (state, action: PayloadAction<Omit<LoaderState, 'counter'>>) => {
|
|
20
|
+
const counter = action.payload.loading
|
|
21
|
+
? state.counter + 1
|
|
22
|
+
: Math.max(0, state.counter - 1);
|
|
23
|
+
state.counter = counter;
|
|
24
|
+
state.loading = counter > 0;
|
|
25
|
+
state.text = action.payload.text;
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const loaderActions = loaderSlice.actions;
|
|
31
|
+
export const loaderReducer = loaderSlice.reducer;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
import type { AppNotification } from "../../types";
|
|
4
|
+
|
|
5
|
+
export interface NotificationsState {
|
|
6
|
+
wallet: Record<string, AppNotification>;
|
|
7
|
+
web3: Record<string, AppNotification>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const initialState: NotificationsState = {
|
|
11
|
+
wallet: {},
|
|
12
|
+
web3: {}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const notificationsSlice = createSlice({
|
|
16
|
+
name: 'notifications',
|
|
17
|
+
initialState,
|
|
18
|
+
reducers: {
|
|
19
|
+
addNotification: (state, action: PayloadAction<AppNotification>) => {
|
|
20
|
+
if (action.payload.type == 'wallet') {
|
|
21
|
+
state.wallet[action.payload.id] = action.payload;
|
|
22
|
+
} else if (action.payload.type == 'web3') {
|
|
23
|
+
state.web3[action.payload.id] = action.payload;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
removeNotification: (state, action: PayloadAction<string>) => {
|
|
27
|
+
delete state.wallet[action.payload];
|
|
28
|
+
delete state.web3[action.payload];
|
|
29
|
+
},
|
|
30
|
+
clearAll: (state, action: PayloadAction<'wallet' | 'web3' | 'all'>) => {
|
|
31
|
+
if (action.payload === 'wallet') {
|
|
32
|
+
state.wallet = {};
|
|
33
|
+
} else if (action.payload === 'web3') {
|
|
34
|
+
state.web3 = {};
|
|
35
|
+
} else if (action.payload === 'all') {
|
|
36
|
+
state.wallet = {};
|
|
37
|
+
state.web3 = {};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const notificationsActions = notificationsSlice.actions;
|
|
44
|
+
export const notificationsReducer = notificationsSlice.reducer;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
import type { Price } from "../../types";
|
|
4
|
+
import { getNexaPrices, initializePrices } from "../../utils";
|
|
5
|
+
|
|
6
|
+
export interface StatusState {
|
|
7
|
+
status: "Online" | "Offline";
|
|
8
|
+
height: number;
|
|
9
|
+
price: Record<string, Price>;
|
|
10
|
+
hasNetwork: boolean;
|
|
11
|
+
isSuspended: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const initialState: StatusState = {
|
|
15
|
+
status: "Offline",
|
|
16
|
+
height: 0,
|
|
17
|
+
price: initializePrices(),
|
|
18
|
+
hasNetwork: true,
|
|
19
|
+
isSuspended: false,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const fetchPrice = createAsyncThunk('status/fetchPrice', async () => {
|
|
23
|
+
const prices = initializePrices();
|
|
24
|
+
try {
|
|
25
|
+
const p = await getNexaPrices();
|
|
26
|
+
Object.keys(p).forEach(currency => {
|
|
27
|
+
prices[currency] = {
|
|
28
|
+
value: p[currency],
|
|
29
|
+
change: p[`${currency}_24h_change`]
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
} catch {
|
|
33
|
+
// prices remain at 0
|
|
34
|
+
}
|
|
35
|
+
return prices ;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const statusSlice = createSlice({
|
|
39
|
+
name: 'status',
|
|
40
|
+
initialState,
|
|
41
|
+
reducers: {
|
|
42
|
+
setHeight: (state, action: PayloadAction<number>) => {
|
|
43
|
+
if (action.payload > 0) {
|
|
44
|
+
state.status = "Online";
|
|
45
|
+
}
|
|
46
|
+
state.height = action.payload;
|
|
47
|
+
},
|
|
48
|
+
setOffline: (state) => {
|
|
49
|
+
state.status = "Offline";
|
|
50
|
+
},
|
|
51
|
+
setHasNetwork: (state, action: PayloadAction<boolean>) => {
|
|
52
|
+
state.hasNetwork = action.payload;
|
|
53
|
+
},
|
|
54
|
+
setIsSuspended: (state, action: PayloadAction<boolean>) => {
|
|
55
|
+
state.isSuspended = action.payload;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
extraReducers: (builder) => {
|
|
59
|
+
builder
|
|
60
|
+
.addCase(fetchPrice.fulfilled, (state, action) => {
|
|
61
|
+
state.price = action.payload;
|
|
62
|
+
})
|
|
63
|
+
.addCase(fetchPrice.rejected, (_, action) => {
|
|
64
|
+
console.error(action.error.message);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export const statusActions = statusSlice.actions;
|
|
70
|
+
export const statusReducer = statusSlice.reducer;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
import type { Account, AssetEntity, Balance, SessionInfo, VaultInfo } from "../../types";
|
|
4
|
+
import { MAIN_WALLET_ID } from "../../utils";
|
|
5
|
+
|
|
6
|
+
interface AddSessionPayload {
|
|
7
|
+
accountId: number;
|
|
8
|
+
sessionInfo: SessionInfo;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface RemoveSessionPayload {
|
|
12
|
+
accountId: number;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface WalletState {
|
|
17
|
+
isAuthorized: boolean;
|
|
18
|
+
selectedAccount: number;
|
|
19
|
+
accounts: Record<number, Account>;
|
|
20
|
+
vaults: Record<string, VaultInfo>;
|
|
21
|
+
sync: boolean;
|
|
22
|
+
initLoad: boolean;
|
|
23
|
+
txUpdateTrigger: number;
|
|
24
|
+
nftsUpdateTrigger: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const initialState: WalletState = {
|
|
28
|
+
isAuthorized: false,
|
|
29
|
+
selectedAccount: MAIN_WALLET_ID,
|
|
30
|
+
accounts: {
|
|
31
|
+
"-1": {
|
|
32
|
+
id: MAIN_WALLET_ID,
|
|
33
|
+
name: 'Main Wallet',
|
|
34
|
+
address: '',
|
|
35
|
+
balance: {confirmed: "0", unconfirmed: "0"},
|
|
36
|
+
tokensBalance: {},
|
|
37
|
+
tokens: [],
|
|
38
|
+
sessions: {}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
vaults: {},
|
|
42
|
+
sync: false,
|
|
43
|
+
initLoad: true,
|
|
44
|
+
txUpdateTrigger: 0,
|
|
45
|
+
nftsUpdateTrigger: 0
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const walletSlice = createSlice({
|
|
49
|
+
name: 'wallet',
|
|
50
|
+
initialState,
|
|
51
|
+
reducers: {
|
|
52
|
+
setInitLoad: (state, action: PayloadAction<boolean>) => {
|
|
53
|
+
state.initLoad = action.payload;
|
|
54
|
+
},
|
|
55
|
+
setSelectedAccount: (state, action: PayloadAction<number>) => {
|
|
56
|
+
state.selectedAccount = action.payload;
|
|
57
|
+
},
|
|
58
|
+
setSync: (state, action: PayloadAction<boolean>) => {
|
|
59
|
+
state.sync = action.payload;
|
|
60
|
+
},
|
|
61
|
+
setVault: (state, action: PayloadAction<VaultInfo>) => {
|
|
62
|
+
state.vaults[action.payload.address] = action.payload;
|
|
63
|
+
},
|
|
64
|
+
setVaultBalance: (state, action: PayloadAction<{ address: string, balance: Balance }>) => {
|
|
65
|
+
state.vaults[action.payload.address].balance = action.payload.balance;
|
|
66
|
+
},
|
|
67
|
+
setAccount: (state, action: PayloadAction<Account>) => {
|
|
68
|
+
state.accounts[action.payload.id] = action.payload;
|
|
69
|
+
},
|
|
70
|
+
setMainAddress: (state, action: PayloadAction<string>) => {
|
|
71
|
+
state.accounts[MAIN_WALLET_ID].address = action.payload;
|
|
72
|
+
},
|
|
73
|
+
setAccountBalance: (state, action: PayloadAction<{ id: number, balance: Balance, tokensBalance: Record<string, Balance> }>) => {
|
|
74
|
+
state.accounts[action.payload.id].balance = action.payload.balance;
|
|
75
|
+
state.accounts[action.payload.id].tokensBalance = action.payload.tokensBalance;
|
|
76
|
+
},
|
|
77
|
+
setAccountName: (state, action: PayloadAction<{ id: number, name: string }>) => {
|
|
78
|
+
state.accounts[action.payload.id].name = action.payload.name;
|
|
79
|
+
},
|
|
80
|
+
setTokens: (state, action: PayloadAction<{ id: number, assets: AssetEntity[] }>) => {
|
|
81
|
+
state.accounts[action.payload.id].tokens = action.payload.assets;
|
|
82
|
+
},
|
|
83
|
+
addToken: (state, action: PayloadAction<{ id: number, asset: AssetEntity }>) => {
|
|
84
|
+
state.accounts[action.payload.id].tokens.unshift(action.payload.asset);
|
|
85
|
+
},
|
|
86
|
+
removeToken: (state, action: PayloadAction<{ id: number, tokenId: string }>) => {
|
|
87
|
+
state.accounts[action.payload.id].tokens = state.accounts[action.payload.id].tokens.filter(n => n.tokenIdHex !== action.payload.tokenId);
|
|
88
|
+
},
|
|
89
|
+
refreshTxs: (state) => {
|
|
90
|
+
state.txUpdateTrigger++;
|
|
91
|
+
},
|
|
92
|
+
refreshNfts: (state) => {
|
|
93
|
+
state.nftsUpdateTrigger++;
|
|
94
|
+
},
|
|
95
|
+
addSession(state, action: PayloadAction<AddSessionPayload>) {
|
|
96
|
+
const { accountId, sessionInfo } = action.payload;
|
|
97
|
+
state.accounts[accountId].sessions[sessionInfo.details.sessionId] = sessionInfo;
|
|
98
|
+
},
|
|
99
|
+
removeSession(state, action: PayloadAction<RemoveSessionPayload>) {
|
|
100
|
+
const { accountId, sessionId } = action.payload;
|
|
101
|
+
if (state.accounts[accountId].sessions[sessionId]) {
|
|
102
|
+
delete state.accounts[accountId].sessions[sessionId];
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
clearSessions(state, action: PayloadAction<{ accountId: number }>) {
|
|
106
|
+
state.accounts[action.payload.accountId].sessions = {};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const walletActions = walletSlice.actions;
|
|
112
|
+
export const walletReducer = walletSlice.reducer;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { authReducer } from "./slices/auth";
|
|
2
|
+
import { dappModalReducer } from "./slices/dapp";
|
|
3
|
+
import { loaderReducer } from "./slices/loader";
|
|
4
|
+
import { notificationsReducer } from "./slices/notifications";
|
|
5
|
+
import { statusReducer } from "./slices/status";
|
|
6
|
+
import { walletReducer } from "./slices/wallet";
|
|
7
|
+
|
|
8
|
+
export const sharedReducers = {
|
|
9
|
+
loader: loaderReducer,
|
|
10
|
+
dapp: dappModalReducer,
|
|
11
|
+
status: statusReducer,
|
|
12
|
+
wallet: walletReducer,
|
|
13
|
+
auth: authReducer,
|
|
14
|
+
notifications: notificationsReducer,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type SharedState = {
|
|
18
|
+
loader: ReturnType<typeof loaderReducer>;
|
|
19
|
+
dapp: ReturnType<typeof dappModalReducer>;
|
|
20
|
+
status: ReturnType<typeof statusReducer>;
|
|
21
|
+
wallet: ReturnType<typeof walletReducer>;
|
|
22
|
+
auth: ReturnType<typeof authReducer>;
|
|
23
|
+
notifications: ReturnType<typeof notificationsReducer>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Transaction } from "libnexa-ts";
|
|
2
|
+
import type { AssetInfo } from "./wallet.types";
|
|
3
|
+
import type { SessionRequestType } from "../utils/enums";
|
|
4
|
+
|
|
5
|
+
export interface DappRpcRequest {
|
|
6
|
+
type: SessionRequestType;
|
|
7
|
+
accountId: number;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
request: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TransactionDetails {
|
|
13
|
+
tx: Transaction;
|
|
14
|
+
send: MovementDetails[];
|
|
15
|
+
receive: MovementDetails[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface MovementDetails {
|
|
19
|
+
asset?: AssetInfo;
|
|
20
|
+
amount: bigint;
|
|
21
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { AccountType, AssetType } from "../utils/enums";
|
|
2
|
+
import type { Balance } from "./wallet.types";
|
|
3
|
+
|
|
4
|
+
export interface AssetMovement {
|
|
5
|
+
address: string;
|
|
6
|
+
nexaAmount: string;
|
|
7
|
+
assetId: string;
|
|
8
|
+
assetAmount: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type TransactionType = 'receive' | 'send' | 'swap' | 'self';
|
|
12
|
+
|
|
13
|
+
export interface TransactionDTO {
|
|
14
|
+
accountId: number;
|
|
15
|
+
txIdem: string;
|
|
16
|
+
txId: string;
|
|
17
|
+
time: number;
|
|
18
|
+
height: number;
|
|
19
|
+
type: TransactionType;
|
|
20
|
+
fee: string;
|
|
21
|
+
othersOutputs: AssetMovement[];
|
|
22
|
+
myOutputs: AssetMovement[];
|
|
23
|
+
myInputs: AssetMovement[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface TransactionEntity {
|
|
27
|
+
accountId: number;
|
|
28
|
+
txIdem: string;
|
|
29
|
+
txId: string;
|
|
30
|
+
time: number;
|
|
31
|
+
height: number;
|
|
32
|
+
type: TransactionType;
|
|
33
|
+
fee: string;
|
|
34
|
+
othersOutputs: string;
|
|
35
|
+
myOutputs: string;
|
|
36
|
+
myInputs: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface AssetTransactionEntity {
|
|
40
|
+
accountId: number;
|
|
41
|
+
assetId: string;
|
|
42
|
+
txIdem: string;
|
|
43
|
+
time: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface TokenEntity {
|
|
47
|
+
token: string;
|
|
48
|
+
tokenIdHex: string;
|
|
49
|
+
name: string;
|
|
50
|
+
ticker: string;
|
|
51
|
+
iconUrl: string;
|
|
52
|
+
decimals: number;
|
|
53
|
+
parentGroup: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface NftEntity {
|
|
57
|
+
token: string;
|
|
58
|
+
tokenIdHex: string;
|
|
59
|
+
parentGroup: string;
|
|
60
|
+
source: string;
|
|
61
|
+
collection: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface SessionEntity {
|
|
65
|
+
sessionId: string;
|
|
66
|
+
accountId: number;
|
|
67
|
+
uri: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface AccountDTO {
|
|
71
|
+
id: number;
|
|
72
|
+
name: string;
|
|
73
|
+
address: string;
|
|
74
|
+
height: number;
|
|
75
|
+
hidden: number;
|
|
76
|
+
statusHash: string;
|
|
77
|
+
balance: Balance;
|
|
78
|
+
tokensBalance: Record<string, Balance>;
|
|
79
|
+
type: AccountType;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface AccountEntity {
|
|
83
|
+
id: number;
|
|
84
|
+
name: string;
|
|
85
|
+
address: string;
|
|
86
|
+
height: number;
|
|
87
|
+
hidden: number;
|
|
88
|
+
statusHash: string;
|
|
89
|
+
balance: string;
|
|
90
|
+
tokensBalance: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface AssetEntity {
|
|
94
|
+
accountId: number;
|
|
95
|
+
tokenIdHex: string;
|
|
96
|
+
type: AssetType;
|
|
97
|
+
addedTime: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface AddressDTO {
|
|
101
|
+
address: string;
|
|
102
|
+
space: number;
|
|
103
|
+
idx: number;
|
|
104
|
+
used: boolean;
|
|
105
|
+
height: number;
|
|
106
|
+
statusHash: string;
|
|
107
|
+
balance: Balance;
|
|
108
|
+
tokensBalance: Record<string, Balance>;
|
|
109
|
+
type: AccountType;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface AddressEntity {
|
|
113
|
+
address: string;
|
|
114
|
+
space: number;
|
|
115
|
+
idx: number;
|
|
116
|
+
used: boolean;
|
|
117
|
+
height: number;
|
|
118
|
+
statusHash: string;
|
|
119
|
+
balance: string;
|
|
120
|
+
tokensBalance: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface VaultDTO {
|
|
124
|
+
address: string;
|
|
125
|
+
idx: number;
|
|
126
|
+
block: number;
|
|
127
|
+
height: number;
|
|
128
|
+
statusHash: string;
|
|
129
|
+
balance: Balance;
|
|
130
|
+
tokensBalance: Record<string, Balance>;
|
|
131
|
+
type: AccountType;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface VaultEntity {
|
|
135
|
+
address: string;
|
|
136
|
+
idx: number;
|
|
137
|
+
block: number;
|
|
138
|
+
height: number;
|
|
139
|
+
statusHash: string;
|
|
140
|
+
balance: string;
|
|
141
|
+
tokensBalance: string;
|
|
142
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type NotificationAction =
|
|
2
|
+
| { type: 'DAPP_REQUEST'; account: number; sessionId: string; payload: string; }
|
|
3
|
+
| { type: 'DISPATCH'; actionType: string; payload?: any }
|
|
4
|
+
| { type: 'NONE' };
|
|
5
|
+
|
|
6
|
+
export interface AppNotification {
|
|
7
|
+
id: string;
|
|
8
|
+
type: 'wallet' | 'web3';
|
|
9
|
+
title: string;
|
|
10
|
+
message?: string;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
action?: NotificationAction;
|
|
13
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { TransportScheme } from "@otoplo/electrum-client";
|
|
2
|
+
|
|
3
|
+
export interface RostrumParams {
|
|
4
|
+
scheme: TransportScheme;
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ServerFeatures {
|
|
11
|
+
genesis_hash: string;
|
|
12
|
+
server_version: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BlockTip {
|
|
16
|
+
height: number;
|
|
17
|
+
hex: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IFirstUse {
|
|
21
|
+
block_hash: string;
|
|
22
|
+
block_height: number;
|
|
23
|
+
height: number;
|
|
24
|
+
tx_hash: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ITokenGenesis {
|
|
28
|
+
decimal_places?: number,
|
|
29
|
+
document_hash?: string;
|
|
30
|
+
document_url?: string;
|
|
31
|
+
group: string;
|
|
32
|
+
height: number;
|
|
33
|
+
name?: string;
|
|
34
|
+
op_return?: string;
|
|
35
|
+
ticker?: string;
|
|
36
|
+
token_id_hex: string;
|
|
37
|
+
txid: string;
|
|
38
|
+
txidem: string;
|
|
39
|
+
op_return_id: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ITokensBalance {
|
|
43
|
+
cursor?: any;
|
|
44
|
+
confirmed: Record<string, string | number>;
|
|
45
|
+
unconfirmed: Record<string, string | number>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ITokenListUnspent {
|
|
49
|
+
cursor?: any;
|
|
50
|
+
unspent: ITokenUtxo[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ITokenUtxo {
|
|
54
|
+
group: string;
|
|
55
|
+
height: number;
|
|
56
|
+
outpoint_hash: string;
|
|
57
|
+
token_amount: number | string;
|
|
58
|
+
token_id_hex: string;
|
|
59
|
+
tx_hash: string;
|
|
60
|
+
tx_pos: number;
|
|
61
|
+
value: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IListUnspentRecord {
|
|
65
|
+
has_token: boolean;
|
|
66
|
+
height: number;
|
|
67
|
+
outpoint_hash: string;
|
|
68
|
+
tx_hash: string;
|
|
69
|
+
tx_pos: number;
|
|
70
|
+
value: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface IUtxo {
|
|
74
|
+
addresses: string[];
|
|
75
|
+
amount: number;
|
|
76
|
+
group: string;
|
|
77
|
+
group_authority: string | number;
|
|
78
|
+
group_quantity: string | number;
|
|
79
|
+
height: number;
|
|
80
|
+
scripthash: string;
|
|
81
|
+
scriptpubkey: string;
|
|
82
|
+
spent: ISpent;
|
|
83
|
+
status: string;
|
|
84
|
+
template_argumenthash: string;
|
|
85
|
+
template_scripthash: string;
|
|
86
|
+
token_id_hex: string;
|
|
87
|
+
tx_hash: string;
|
|
88
|
+
tx_idem: string;
|
|
89
|
+
tx_pos: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ISpent {
|
|
93
|
+
height: number;
|
|
94
|
+
tx_hash: string;
|
|
95
|
+
tx_pos: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface ITransaction {
|
|
99
|
+
blockhash: string;
|
|
100
|
+
blocktime: number;
|
|
101
|
+
confirmations: number;
|
|
102
|
+
fee: number;
|
|
103
|
+
fee_satoshi: number;
|
|
104
|
+
hash: string;
|
|
105
|
+
height: number;
|
|
106
|
+
hex: string;
|
|
107
|
+
locktime: number;
|
|
108
|
+
size: number;
|
|
109
|
+
time: number;
|
|
110
|
+
txid: string;
|
|
111
|
+
txidem: string;
|
|
112
|
+
version: number;
|
|
113
|
+
vin: ITXInput[];
|
|
114
|
+
vout: ITXOutput[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface ITXInput {
|
|
118
|
+
outpoint: string;
|
|
119
|
+
scriptSig: IScriptSig;
|
|
120
|
+
sequence: number;
|
|
121
|
+
value: number;
|
|
122
|
+
value_satoshi: string | number;
|
|
123
|
+
addresses: string[];
|
|
124
|
+
group: string;
|
|
125
|
+
groupAuthority: string | number;
|
|
126
|
+
groupQuantity: string | number;
|
|
127
|
+
token_id_hex?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface ITXOutput {
|
|
131
|
+
n: number;
|
|
132
|
+
outpoint_hash: string;
|
|
133
|
+
scriptPubKey: IScriptPubKey;
|
|
134
|
+
type: number;
|
|
135
|
+
value: number;
|
|
136
|
+
value_satoshi: string | number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface IScriptSig {
|
|
140
|
+
asm: string;
|
|
141
|
+
hex: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface IScriptPubKey {
|
|
145
|
+
addresses: string[];
|
|
146
|
+
argHash: string;
|
|
147
|
+
asm: string;
|
|
148
|
+
group: string;
|
|
149
|
+
groupAuthority: string | number;
|
|
150
|
+
groupQuantity: string | number;
|
|
151
|
+
hex: string;
|
|
152
|
+
scriptHash: string;
|
|
153
|
+
token_id_hex?: string;
|
|
154
|
+
type: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface ITXHistory {
|
|
158
|
+
fee?: number;
|
|
159
|
+
height: number;
|
|
160
|
+
tx_hash: string;
|
|
161
|
+
}
|