-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallet.js
44 lines (44 loc) · 6.83 KB
/
wallet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { WalletStatus, } from './types';
export function createConnectedWallet({ connection, post, sign, signBytes, supportFeatures, wallets, status, network, }) {
try {
if (status === WalletStatus.WALLET_CONNECTED &&
wallets.length > 0 &&
// TODO: validate addresses
//AccAddress.validate(wallets[0].terraAddress) &&
!!connection) {
const { addresses, connectType, design } = wallets[0];
return {
network,
addresses,
design,
post: (tx) => {
return post(tx, addresses[tx.chainID]);
},
sign: (tx) => {
return sign(tx, addresses[tx.chainID]);
},
signBytes: (bytes) => {
return signBytes(bytes);
},
availablePost: supportFeatures.has('post'),
availableSign: supportFeatures.has('sign'),
availableSignBytes: supportFeatures.has('sign-bytes'),
connectType,
connection,
};
}
else {
return undefined;
}
}
catch (_a) {
return undefined;
}
}
export function createInstallableWallets({ status, installations, }) {
if (status === WalletStatus.WALLET_NOT_CONNECTED) {
return installations;
}
return undefined;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL0B0ZXJyYS1tb25leS93YWxsZXQtdHlwZXMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFTTCxZQUFZLEdBQ2IsTUFBTSxTQUFTLENBQUM7QUFnQ2pCLE1BQU0sVUFBVSxxQkFBcUIsQ0FBQyxFQUNwQyxVQUFVLEVBQ1YsSUFBSSxFQUNKLElBQUksRUFDSixTQUFTLEVBQ1QsZUFBZSxFQUNmLE9BQU8sRUFDUCxNQUFNLEVBQ04sT0FBTyxHQUNxQjtJQUM1QixJQUFJO1FBQ0YsSUFDRSxNQUFNLEtBQ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