@hot-labs/kit 1.0.57 → 1.1.0-beta.2
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/README.md +2 -9
- package/build/HotConnector.d.ts +6 -6
- package/build/HotConnector.js +18 -23
- package/build/HotConnector.js.map +1 -1
- package/build/OmniConnector.d.ts +4 -0
- package/build/OmniConnector.js +5 -5
- package/build/OmniConnector.js.map +1 -1
- package/build/OmniWallet.d.ts +10 -17
- package/build/OmniWallet.js +14 -19
- package/build/OmniWallet.js.map +1 -1
- package/build/core/Intents.d.ts +23 -39
- package/build/core/Intents.js +104 -115
- package/build/core/Intents.js.map +1 -1
- package/build/core/api.d.ts +1 -0
- package/build/core/api.js +10 -2
- package/build/core/api.js.map +1 -1
- package/build/core/bridge.js +1 -1
- package/build/core/bridge.js.map +1 -1
- package/build/core/index.d.ts +1 -1
- package/build/core/index.js +1 -1
- package/build/core/index.js.map +1 -1
- package/build/core/types.d.ts +17 -0
- package/build/core/utils.d.ts +1 -0
- package/build/core/utils.js +10 -0
- package/build/core/utils.js.map +1 -1
- package/build/cosmos/connector.js +2 -2
- package/build/cosmos/connector.js.map +1 -1
- package/build/cosmos/wallet.d.ts +2 -4
- package/build/cosmos/wallet.js +3 -8
- package/build/cosmos/wallet.js.map +1 -1
- package/build/evm/connector.d.ts +1 -0
- package/build/evm/connector.js +4 -0
- package/build/evm/connector.js.map +1 -1
- package/build/evm/wallet.d.ts +2 -1
- package/build/evm/wallet.js +7 -5
- package/build/evm/wallet.js.map +1 -1
- package/build/exchange.d.ts +4 -1
- package/build/exchange.js +21 -20
- package/build/exchange.js.map +1 -1
- package/build/hot-wallet/google.js +10 -5
- package/build/hot-wallet/google.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/near/connector.js +2 -2
- package/build/near/connector.js.map +1 -1
- package/build/{core/nearRpc.d.ts → near/rpc.d.ts} +0 -1
- package/build/{core/nearRpc.js → near/rpc.js} +5 -11
- package/build/near/rpc.js.map +1 -0
- package/build/near/wallet.d.ts +2 -4
- package/build/near/wallet.js +4 -9
- package/build/near/wallet.js.map +1 -1
- package/build/solana/{protocol.d.ts → WalletStandard.d.ts} +1 -1
- package/build/solana/{protocol.js → WalletStandard.js} +1 -1
- package/build/solana/WalletStandard.js.map +1 -0
- package/build/solana/connector.d.ts +1 -1
- package/build/solana/connector.js +9 -8
- package/build/solana/connector.js.map +1 -1
- package/build/solana/injected/solana-wallet.js.map +1 -1
- package/build/solana/wallet.d.ts +3 -5
- package/build/solana/wallet.js +3 -8
- package/build/solana/wallet.js.map +1 -1
- package/build/solana/{wallets.js → walletStandartList.js} +1 -1
- package/build/solana/walletStandartList.js.map +1 -0
- package/build/stellar/connector.d.ts +0 -2
- package/build/stellar/connector.js +1 -4
- package/build/stellar/connector.js.map +1 -1
- package/build/stellar/wallet.d.ts +10 -8
- package/build/stellar/wallet.js +12 -16
- package/build/stellar/wallet.js.map +1 -1
- package/build/ton/connector.d.ts +0 -1
- package/build/ton/connector.js +1 -4
- package/build/ton/connector.js.map +1 -1
- package/build/ton/wallet.d.ts +2 -3
- package/build/ton/wallet.js +3 -4
- package/build/ton/wallet.js.map +1 -1
- package/build/tron/connector.d.ts +51 -0
- package/build/tron/connector.js +65 -0
- package/build/tron/connector.js.map +1 -0
- package/build/tron/index.d.ts +6 -0
- package/build/tron/index.js +5 -0
- package/build/tron/index.js.map +1 -0
- package/build/tron/wallet.d.ts +52 -0
- package/build/tron/wallet.js +122 -0
- package/build/tron/wallet.js.map +1 -0
- package/build/ui/connect/AuthPopup.js +1 -1
- package/build/ui/connect/AuthPopup.js.map +1 -1
- package/build/ui/connect/ConnectWallet.d.ts +2 -1
- package/build/ui/connect/ConnectWallet.js +2 -2
- package/build/ui/connect/ConnectWallet.js.map +1 -1
- package/build/ui/icons/arrow-right.js +1 -1
- package/build/ui/icons/arrow-right.js.map +1 -1
- package/build/ui/icons/close.js +1 -1
- package/build/ui/icons/close.js.map +1 -1
- package/build/ui/icons/exchange.js +1 -1
- package/build/ui/icons/exchange.js.map +1 -1
- package/build/ui/icons/logout.js +1 -1
- package/build/ui/icons/logout.js.map +1 -1
- package/build/ui/icons/pending.js +1 -1
- package/build/ui/icons/pending.js.map +1 -1
- package/build/ui/icons/qr.js +1 -1
- package/build/ui/icons/qr.js.map +1 -1
- package/build/ui/icons/search.js +1 -1
- package/build/ui/icons/search.js.map +1 -1
- package/build/ui/icons/switch.js +1 -1
- package/build/ui/icons/switch.js.map +1 -1
- package/build/ui/icons/wallet.js +1 -1
- package/build/ui/icons/wallet.js.map +1 -1
- package/build/ui/payment/Bridge.js +7 -2
- package/build/ui/payment/Bridge.js.map +1 -1
- package/build/ui/payment/Payment.d.ts +16 -8
- package/build/ui/payment/Payment.js +117 -21
- package/build/ui/payment/Payment.js.map +1 -1
- package/build/ui/payment/Profile.js +1 -1
- package/build/ui/payment/Profile.js.map +1 -1
- package/build/ui/payment/SelectToken.js +1 -1
- package/build/ui/payment/SelectToken.js.map +1 -1
- package/build/ui/payment/TokenCard.js +1 -1
- package/build/ui/payment/TokenCard.js.map +1 -1
- package/build/ui/router.d.ts +2 -1
- package/build/ui/router.js +2 -2
- package/build/ui/router.js.map +1 -1
- package/package.json +8 -4
- package/src/HotConnector.ts +21 -29
- package/src/OmniConnector.ts +9 -9
- package/src/OmniWallet.ts +24 -25
- package/src/core/Intents.ts +123 -139
- package/src/core/api.ts +13 -2
- package/src/core/bridge.ts +3 -2
- package/src/core/index.ts +1 -1
- package/src/core/types.ts +21 -0
- package/src/core/utils.ts +11 -0
- package/src/cosmos/connector.ts +2 -2
- package/src/cosmos/wallet.ts +3 -7
- package/src/evm/connector.ts +5 -0
- package/src/evm/wallet.ts +9 -6
- package/src/exchange.ts +20 -20
- package/src/hot-wallet/google.ts +12 -5
- package/src/index.ts +2 -0
- package/src/near/connector.ts +2 -2
- package/src/{core/nearRpc.ts → near/rpc.ts} +4 -11
- package/src/near/wallet.ts +4 -9
- package/src/solana/{protocol.ts → WalletStandard.ts} +2 -4
- package/src/solana/connector.ts +9 -8
- package/src/solana/injected/solana-wallet.ts +6 -6
- package/src/solana/wallet.ts +4 -8
- package/src/stellar/connector.ts +1 -6
- package/src/stellar/wallet.ts +17 -17
- package/src/ton/connector.ts +1 -5
- package/src/ton/wallet.ts +3 -3
- package/src/tron/connector.ts +89 -0
- package/src/tron/index.ts +7 -0
- package/src/tron/wallet.ts +146 -0
- package/src/ui/connect/AuthPopup.tsx +2 -1
- package/src/ui/connect/ConnectWallet.tsx +3 -2
- package/src/ui/icons/arrow-right.tsx +2 -2
- package/src/ui/icons/close.tsx +1 -1
- package/src/ui/icons/exchange.tsx +4 -4
- package/src/ui/icons/logout.tsx +6 -6
- package/src/ui/icons/pending.tsx +2 -4
- package/src/ui/icons/qr.tsx +1 -2
- package/src/ui/icons/search.tsx +4 -4
- package/src/ui/icons/switch.tsx +4 -4
- package/src/ui/icons/wallet.tsx +2 -4
- package/src/ui/payment/Bridge.tsx +9 -2
- package/src/ui/payment/Payment.tsx +258 -30
- package/src/ui/payment/Profile.tsx +10 -8
- package/src/ui/payment/SelectToken.tsx +1 -1
- package/src/ui/payment/TokenCard.tsx +1 -1
- package/src/ui/router.tsx +5 -6
- package/build/core/nearRpc.js.map +0 -1
- package/build/solana/protocol.js.map +0 -1
- package/build/solana/wallets.js.map +0 -1
- /package/build/solana/{wallets.d.ts → walletStandartList.d.ts} +0 -0
- /package/src/solana/{wallets.ts → walletStandartList.ts} +0 -0
package/build/ui/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/ui/router.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/ui/router.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAm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EAAE,IAAI,EAAE,WAAW,GAAI,CAAC,CAAC;IAChI,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-labs/kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-beta.2",
|
|
4
4
|
"description": "HOT Labs Kit is chain agnostic connector with omni payments",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"./solana": "./build/solana/index.js",
|
|
18
18
|
"./stellar": "./build/stellar/index.js",
|
|
19
19
|
"./ton": "./build/ton/index.js",
|
|
20
|
+
"./tron": "./build/tron/index.js",
|
|
20
21
|
"./core": "./build/core/index.js"
|
|
21
22
|
},
|
|
22
23
|
"directories": {
|
|
@@ -31,28 +32,31 @@
|
|
|
31
32
|
"@cosmjs/stargate": "^0.37.0",
|
|
32
33
|
"@defuse-protocol/one-click-sdk-typescript": "^0.1.13",
|
|
33
34
|
"@hot-labs/near-connect": "^0.8.1",
|
|
34
|
-
"@hot-labs/omni-sdk": "^2.24.
|
|
35
|
+
"@hot-labs/omni-sdk": "^2.24.6",
|
|
35
36
|
"@keplr-wallet/proto-types": "^0.12.291",
|
|
36
37
|
"@keplr-wallet/provider-extension": "^0.12.291",
|
|
37
|
-
"@
|
|
38
|
+
"@lottiefiles/dotlottie-wc": "^0.8.11",
|
|
38
39
|
"@near-js/crypto": "^2.3.3",
|
|
39
40
|
"@near-js/providers": "^2.5.1",
|
|
40
41
|
"@near-js/utils": "^2.2.4",
|
|
41
42
|
"@noble/hashes": "^2.0.1",
|
|
42
43
|
"@scure/base": "^2.0.0",
|
|
43
44
|
"@solana/spl-token": "^0.4.14",
|
|
45
|
+
"@solana/wallet-standard-features": "^1.3.0",
|
|
44
46
|
"@stellar/freighter-api": "^6.0.1",
|
|
45
47
|
"@ton-api/client": "^0.4.0",
|
|
46
48
|
"@ton/core": "^0.62.0",
|
|
47
49
|
"@ton/crypto": "^3.3.0",
|
|
48
50
|
"@tonconnect/ui": "^2.2.0",
|
|
49
51
|
"@wallet-standard/base": "^1.1.0",
|
|
52
|
+
"@wallet-standard/features": "^1.1.0",
|
|
50
53
|
"@walletconnect/universal-provider": "^2.23.0",
|
|
51
54
|
"ethers": "^6.15.0",
|
|
52
55
|
"mobx": "^6.15.0",
|
|
53
56
|
"mobx-react-lite": "^4.1.1",
|
|
54
57
|
"qr-code-styling": "^1.9.2",
|
|
55
|
-
"styled-components": "^6.1.19"
|
|
58
|
+
"styled-components": "^6.1.19",
|
|
59
|
+
"uuid4": "^2.0.3"
|
|
56
60
|
},
|
|
57
61
|
"scripts": {
|
|
58
62
|
"build": "rm -rf build && yarn tsc",
|
package/src/HotConnector.ts
CHANGED
|
@@ -8,10 +8,11 @@ import { OmniToken } from "./core/chains";
|
|
|
8
8
|
import { formatter } from "./core/utils";
|
|
9
9
|
import { Intents } from "./core/Intents";
|
|
10
10
|
import { tokens } from "./core/tokens";
|
|
11
|
-
import { rpc } from "./
|
|
11
|
+
import { rpc } from "./near/rpc";
|
|
12
12
|
import { Token } from "./core/token";
|
|
13
13
|
import { api } from "./core/api";
|
|
14
14
|
|
|
15
|
+
import { defaultConnectors } from "./defaults";
|
|
15
16
|
import type CosmosWallet from "./cosmos/wallet";
|
|
16
17
|
import type NearWallet from "./near/wallet";
|
|
17
18
|
import type EvmWallet from "./evm/wallet";
|
|
@@ -19,7 +20,7 @@ import type SolanaWallet from "./solana/wallet";
|
|
|
19
20
|
import type StellarWallet from "./stellar/wallet";
|
|
20
21
|
import type TonWallet from "./ton/wallet";
|
|
21
22
|
|
|
22
|
-
import { openBridge, openConnector,
|
|
23
|
+
import { openBridge, openConnector, openProfile, openWalletPicker } from "./ui/router";
|
|
23
24
|
import { ConnectorType, OmniConnector } from "./OmniConnector";
|
|
24
25
|
import { OmniWallet } from "./OmniWallet";
|
|
25
26
|
import { Exchange } from "./exchange";
|
|
@@ -49,8 +50,8 @@ export class HotConnector {
|
|
|
49
50
|
public exchange: Exchange;
|
|
50
51
|
|
|
51
52
|
private events = new EventEmitter<{
|
|
52
|
-
connect: { wallet: OmniWallet };
|
|
53
|
-
disconnect: { wallet: OmniWallet };
|
|
53
|
+
connect: { wallet: OmniWallet; connector: OmniConnector };
|
|
54
|
+
disconnect: { wallet: OmniWallet; connector: OmniConnector };
|
|
54
55
|
tokensUpdate: { tokens: Token[] };
|
|
55
56
|
}>();
|
|
56
57
|
|
|
@@ -87,7 +88,8 @@ export class HotConnector {
|
|
|
87
88
|
this.activity = new Activity(this);
|
|
88
89
|
|
|
89
90
|
const connectors: OmniConnector[] = [];
|
|
90
|
-
const
|
|
91
|
+
const configConnectors = options?.connectors || defaultConnectors;
|
|
92
|
+
const tasks = configConnectors.map(async (initConnector, index) => {
|
|
91
93
|
const connector = await initConnector(this);
|
|
92
94
|
connector.onConnect((payload) => this.events.emit("connect", payload));
|
|
93
95
|
connector.onDisconnect((payload) => this.events.emit("disconnect", payload));
|
|
@@ -294,36 +296,16 @@ export class HotConnector {
|
|
|
294
296
|
});
|
|
295
297
|
}
|
|
296
298
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const tokensList = await tokens.getTokens();
|
|
301
|
-
const ftToken = tokensList.find((t) => t.address === token)!;
|
|
302
|
-
const amountInt = typeof amount === "number" ? ftToken.int(amount) : amount;
|
|
303
|
-
const [existed] = this.walletsTokens.filter((t) => t.token.id === ftToken.id);
|
|
304
|
-
|
|
305
|
-
if (existed?.balance >= amountInt) return { token: ftToken, wallet: existed.wallet, amount: amountInt };
|
|
306
|
-
|
|
307
|
-
const needed = amountInt - (existed?.balance ?? 0n);
|
|
308
|
-
const result = await openPayment(this, ftToken, needed, Recipient.fromWallet(existed?.wallet));
|
|
309
|
-
|
|
310
|
-
const recipientWallet = this.wallets.find((w) => w.address === result.recipient.address);
|
|
311
|
-
if (!recipientWallet) throw new Error("Recipient not found");
|
|
312
|
-
const exist = await this.fetchToken(ftToken, recipientWallet);
|
|
313
|
-
|
|
314
|
-
return {
|
|
315
|
-
token: result.to,
|
|
316
|
-
wallet: recipientWallet,
|
|
317
|
-
amount: formatter.bigIntMin(exist, amountInt),
|
|
318
|
-
};
|
|
299
|
+
intentsBuilder(wallet?: OmniWallet) {
|
|
300
|
+
return new Intents(this).attachWallet(wallet);
|
|
319
301
|
}
|
|
320
302
|
|
|
321
|
-
onConnect(handler: (payload: { wallet: OmniWallet }) => void) {
|
|
303
|
+
onConnect(handler: (payload: { wallet: OmniWallet; connector: OmniConnector }) => void) {
|
|
322
304
|
this.events.on("connect", handler);
|
|
323
305
|
return () => this.events.off("connect", handler);
|
|
324
306
|
}
|
|
325
307
|
|
|
326
|
-
onDisconnect(handler: (payload: { wallet: OmniWallet }) => void) {
|
|
308
|
+
onDisconnect(handler: (payload: { wallet: OmniWallet; connector: OmniConnector }) => void) {
|
|
327
309
|
this.events.on("disconnect", handler);
|
|
328
310
|
return () => this.events.off("disconnect", handler);
|
|
329
311
|
}
|
|
@@ -384,4 +366,14 @@ export class HotConnector {
|
|
|
384
366
|
if (!connector) throw new Error("Connector not found");
|
|
385
367
|
return openWalletPicker(connector);
|
|
386
368
|
}
|
|
369
|
+
|
|
370
|
+
async disconnect(wallet: WalletType | OmniWallet) {
|
|
371
|
+
const connector = this.connectors.find((t) => {
|
|
372
|
+
if (wallet instanceof OmniWallet) return t.wallets.includes(wallet);
|
|
373
|
+
return t.walletTypes.includes(wallet);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
if (!connector) throw new Error("Connector not found");
|
|
377
|
+
await connector.disconnect();
|
|
378
|
+
}
|
|
387
379
|
}
|
package/src/OmniConnector.ts
CHANGED
|
@@ -30,8 +30,8 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
|
|
|
30
30
|
|
|
31
31
|
private storage = new LocalStorage();
|
|
32
32
|
protected events = new EventEmitter<{
|
|
33
|
-
connect: { wallet: T };
|
|
34
|
-
disconnect: { wallet: T };
|
|
33
|
+
connect: { wallet: T; connector: OmniConnector<T, O> };
|
|
34
|
+
disconnect: { wallet: T; connector: OmniConnector<T, O> };
|
|
35
35
|
}>();
|
|
36
36
|
|
|
37
37
|
protected wc: Promise<UniversalProvider> | null = null;
|
|
@@ -101,14 +101,14 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
|
|
|
101
101
|
|
|
102
102
|
protected setWallet(wallet: T) {
|
|
103
103
|
runInAction(() => this.wallets.push(wallet));
|
|
104
|
-
this.events.emit("connect", { wallet });
|
|
104
|
+
this.events.emit("connect", { wallet, connector: this });
|
|
105
105
|
return wallet;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
protected removeWallet() {
|
|
109
109
|
runInAction(() => {
|
|
110
110
|
const wallet = this.wallets.pop();
|
|
111
|
-
if (wallet) this.events.emit("disconnect", { wallet });
|
|
111
|
+
if (wallet) this.events.emit("disconnect", { wallet, connector: this });
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -116,7 +116,7 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
|
|
|
116
116
|
runInAction(() => {
|
|
117
117
|
const wallets = this.wallets;
|
|
118
118
|
this.wallets = [];
|
|
119
|
-
wallets.forEach((wallet) => this.events.emit("disconnect", { wallet }));
|
|
119
|
+
wallets.forEach((wallet) => this.events.emit("disconnect", { wallet, connector: this }));
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -130,7 +130,7 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
|
|
|
130
130
|
|
|
131
131
|
async getStorage(): Promise<{ type?: string; id?: string; address?: string; publicKey?: string }> {
|
|
132
132
|
const data = await this.storage.get(`wibe3:${this.id}`);
|
|
133
|
-
if (!data)
|
|
133
|
+
if (!data) return {};
|
|
134
134
|
return JSON.parse(data);
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -138,19 +138,19 @@ export abstract class OmniConnector<T extends OmniWallet = OmniWallet, O = {}> {
|
|
|
138
138
|
this.events.removeAllListeners();
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
onConnect(handler: (payload: { wallet: T }) => void) {
|
|
141
|
+
onConnect(handler: (payload: { wallet: T; connector: OmniConnector<T, O> }) => void) {
|
|
142
142
|
this.events.on("connect", handler);
|
|
143
143
|
return () => this.events.off("connect", handler);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
onDisconnect(handler: (payload: { wallet: T }) => void) {
|
|
146
|
+
onDisconnect(handler: (payload: { wallet: T; connector: OmniConnector<T, O> }) => void) {
|
|
147
147
|
this.events.on("disconnect", handler);
|
|
148
148
|
return () => this.events.off("disconnect", handler);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
async disconnect() {
|
|
152
152
|
this.disconnectWalletConnect();
|
|
153
|
+
this.removeAllWallets();
|
|
153
154
|
this.removeStorage();
|
|
154
|
-
this.removeWallet();
|
|
155
155
|
}
|
|
156
156
|
}
|
package/src/OmniWallet.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
1
|
import { hex } from "@scure/base";
|
|
3
2
|
|
|
4
3
|
import { openAuthPopup } from "./ui/connect/AuthPopup";
|
|
5
|
-
import {
|
|
6
|
-
import { OmniConnector } from "./OmniConnector";
|
|
4
|
+
import { WalletType } from "./core/chains";
|
|
7
5
|
import { Intents } from "./core/Intents";
|
|
8
6
|
import { ReviewFee } from "./core/bridge";
|
|
9
7
|
import { Token } from "./core/token";
|
|
@@ -11,38 +9,44 @@ import { Commitment } from "./core";
|
|
|
11
9
|
import { api } from "./core/api";
|
|
12
10
|
|
|
13
11
|
export abstract class OmniWallet {
|
|
14
|
-
constructor(readonly connector: OmniConnector) {}
|
|
15
|
-
|
|
16
12
|
abstract address: string;
|
|
17
13
|
abstract publicKey?: string;
|
|
18
14
|
abstract omniAddress: string;
|
|
19
15
|
abstract type: WalletType;
|
|
16
|
+
abstract icon: string;
|
|
20
17
|
|
|
21
|
-
async
|
|
22
|
-
|
|
23
|
-
await this.connector.disconnect();
|
|
18
|
+
async depositNfts(nftIds: string[], receiver: string) {
|
|
19
|
+
// TODO
|
|
24
20
|
}
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
async withdrawNfts(nftIds: string[], receiver: string) {
|
|
23
|
+
// TODO
|
|
24
|
+
}
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
async getDepositNftsFee(nfts: string[]) {
|
|
27
|
+
return new ReviewFee({ chain: -4 });
|
|
28
|
+
}
|
|
32
29
|
|
|
33
|
-
async
|
|
34
|
-
|
|
35
|
-
return await Intents.publishSignedIntents([signed], hashes);
|
|
30
|
+
async transferNft(nftId: string, receiver: string) {
|
|
31
|
+
// TODO
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
return
|
|
34
|
+
async getTranferNftFee(nftId: string, receiver: string) {
|
|
35
|
+
return new ReviewFee({ chain: -4 });
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
async getNfts(onLoad: (nfts: string[]) => void) {
|
|
39
|
+
// TODO
|
|
44
40
|
}
|
|
45
41
|
|
|
42
|
+
abstract transferFee(token: Token, receiver: string, amount: bigint): Promise<ReviewFee>;
|
|
43
|
+
abstract transfer(args: { token: Token; receiver: string; amount: bigint; comment?: string; gasFee?: ReviewFee }): Promise<string>;
|
|
44
|
+
|
|
45
|
+
abstract fetchBalance(chain: number, address: string): Promise<bigint>;
|
|
46
|
+
abstract fetchBalances(chain?: number, whitelist?: string[]): Promise<Record<string, bigint>>;
|
|
47
|
+
|
|
48
|
+
abstract signIntents(intents: Record<string, any>[], options?: { nonce?: Uint8Array; deadline?: number }): Promise<Commitment>;
|
|
49
|
+
|
|
46
50
|
async auth(intents?: Record<string, any>[]): Promise<string> {
|
|
47
51
|
return openAuthPopup(this, async () => {
|
|
48
52
|
const seed = hex.encode(new Uint8Array(window.crypto.getRandomValues(new Uint8Array(32))));
|
|
@@ -53,11 +57,6 @@ export abstract class OmniWallet {
|
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
async pay({ token, amount, recipient, paymentId }: { token: OmniToken; amount: number; recipient: string; paymentId: string }) {
|
|
57
|
-
const nonce = new Uint8Array(sha256(new TextEncoder().encode(paymentId))).slice(0, 32);
|
|
58
|
-
return this.intents.attachNonce(nonce).transfer({ recipient, token, amount }).execute();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
60
|
async waitUntilBalance(need: Record<string, bigint>, receiver: string, attempts = 0) {
|
|
62
61
|
if (attempts > 120) throw "Balance is not enough";
|
|
63
62
|
const assets = Object.keys(need) as string[];
|