@hot-labs/kit 1.1.0-beta.5 → 1.1.0-beta.9
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/build/core/Intents.d.ts +20 -9
- package/build/core/Intents.js +110 -56
- package/build/core/Intents.js.map +1 -1
- package/build/core/utils.js +11 -1
- package/build/core/utils.js.map +1 -1
- package/build/exchange.js +1 -1
- package/build/exchange.js.map +1 -1
- package/build/ui/Popup.d.ts +1 -1
- package/build/ui/Popup.js +4 -0
- package/build/ui/Popup.js.map +1 -1
- package/build/ui/Toast.d.ts +4 -0
- package/build/ui/Toast.js +33 -0
- package/build/ui/Toast.js.map +1 -0
- package/build/ui/connect/ConnectWallet.d.ts +6 -2
- package/build/ui/connect/ConnectWallet.js +5 -5
- package/build/ui/connect/ConnectWallet.js.map +1 -1
- package/build/ui/connect/PrimaryWallet.d.ts +6 -0
- package/build/ui/connect/PrimaryWallet.js +18 -0
- package/build/ui/connect/PrimaryWallet.js.map +1 -0
- package/build/ui/payment/Bridge.js +1 -1
- package/build/ui/payment/Bridge.js.map +1 -1
- package/build/ui/payment/Payment.d.ts +9 -2
- package/build/ui/payment/Payment.js +42 -42
- package/build/ui/payment/Payment.js.map +1 -1
- package/build/ui/payment/TokenCard.d.ts +4 -2
- package/build/ui/payment/TokenCard.js +4 -4
- package/build/ui/payment/TokenCard.js.map +1 -1
- package/build/ui/router.d.ts +15 -5
- package/build/ui/router.js +15 -3
- package/build/ui/router.js.map +1 -1
- package/build/ui/styles.js +2 -0
- package/build/ui/styles.js.map +1 -1
- package/package.json +1 -1
- package/src/core/Intents.ts +113 -58
- package/src/core/utils.ts +6 -1
- package/src/exchange.ts +1 -1
- package/src/ui/Popup.tsx +5 -0
- package/src/ui/Toast.tsx +45 -0
- package/src/ui/connect/ConnectWallet.tsx +11 -6
- package/src/ui/connect/PrimaryWallet.tsx +65 -0
- package/src/ui/payment/Bridge.tsx +1 -1
- package/src/ui/payment/Payment.tsx +79 -90
- package/src/ui/payment/TokenCard.tsx +21 -17
- package/src/ui/router.tsx +43 -4
- package/src/ui/styles.ts +2 -0
package/build/ui/router.d.ts
CHANGED
|
@@ -7,13 +7,22 @@ import { Recipient } from "../core/recipient";
|
|
|
7
7
|
import { Intents } from "../core/Intents";
|
|
8
8
|
import { Token } from "../core/token";
|
|
9
9
|
import { BridgeProps } from "./payment/Bridge";
|
|
10
|
-
export declare const openPayment: (connector: HotConnector, intents
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
export declare const openPayment: (connector: HotConnector, { intents, title, allowedTokens, prepaidAmount, payableToken, needAmount, onConfirm, }: {
|
|
11
|
+
intents: Intents;
|
|
12
|
+
title?: string;
|
|
13
|
+
allowedTokens?: string[];
|
|
14
|
+
prepaidAmount: bigint;
|
|
15
|
+
payableToken: Token;
|
|
16
|
+
needAmount: bigint;
|
|
17
|
+
onConfirm: (args: {
|
|
18
|
+
depositQoute: BridgeReview | "direct";
|
|
19
|
+
processing?: () => Promise<BridgeReview>;
|
|
20
|
+
}) => Promise<void>;
|
|
21
|
+
}) => Promise<void>;
|
|
14
22
|
export declare const openLogoutPopup: (connector: OmniConnector) => Promise<void>;
|
|
15
23
|
export declare const openBridge: (hot: HotConnector, setup?: BridgeProps["setup"]) => Promise<BridgeReview>;
|
|
16
|
-
export declare const openConnector: (hot: HotConnector) => void
|
|
24
|
+
export declare const openConnector: (hot: HotConnector) => Promise<void>;
|
|
25
|
+
export declare const openConnectPrimaryWallet: (hot: HotConnector) => Promise<void>;
|
|
17
26
|
export declare const openProfile: (hot: HotConnector) => void;
|
|
18
27
|
export declare const openSelectTokenPopup: ({ hot, initialChain, onSelect }: {
|
|
19
28
|
hot: HotConnector;
|
|
@@ -39,3 +48,4 @@ export declare const openWCRequest: <T>(args: {
|
|
|
39
48
|
icon: string;
|
|
40
49
|
request: any;
|
|
41
50
|
}) => Promise<T>;
|
|
51
|
+
export declare const openToast: (message: string) => () => void;
|
package/build/ui/router.js
CHANGED
|
@@ -6,14 +6,16 @@ import { SelectSender } from "./payment/SelectSender";
|
|
|
6
6
|
import { Payment } from "./payment/Payment";
|
|
7
7
|
import { Profile } from "./payment/Profile";
|
|
8
8
|
import { Bridge } from "./payment/Bridge";
|
|
9
|
+
import ConnectPrimaryWallet from "./connect/PrimaryWallet";
|
|
9
10
|
import { LogoutPopup } from "./connect/LogoutPopup";
|
|
10
11
|
import { WalletPicker } from "./connect/WalletPicker";
|
|
11
12
|
import { Connector } from "./connect/ConnectWallet";
|
|
12
13
|
import { WCRequest } from "./connect/WCRequest";
|
|
13
|
-
|
|
14
|
+
import Toast from "./Toast";
|
|
15
|
+
export const openPayment = (connector, { intents, title, allowedTokens, prepaidAmount, payableToken, needAmount, onConfirm, }) => {
|
|
14
16
|
return new Promise((resolve, reject) => {
|
|
15
17
|
present((close) => (_jsx(Payment //
|
|
16
|
-
, { onReject: () => (close(), reject(new Error("User rejected"))),
|
|
18
|
+
, { onConfirm: onConfirm, close: () => (close(), resolve()), onReject: () => (close(), reject(new Error("User rejected"))), prepaidAmount: prepaidAmount, allowedTokens: allowedTokens, payableToken: payableToken, needAmount: needAmount, connector: connector, intents: intents, title: title })));
|
|
17
19
|
});
|
|
18
20
|
};
|
|
19
21
|
export const openLogoutPopup = (connector) => {
|
|
@@ -31,7 +33,14 @@ export const openBridge = (hot, setup) => {
|
|
|
31
33
|
});
|
|
32
34
|
};
|
|
33
35
|
export const openConnector = (hot) => {
|
|
34
|
-
|
|
36
|
+
return new Promise((resolve) => {
|
|
37
|
+
present((close) => _jsx(Connector, { hot: hot, onClose: () => (resolve(), close()) }));
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export const openConnectPrimaryWallet = (hot) => {
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
present((close) => _jsx(ConnectPrimaryWallet, { hot: hot, onClose: () => (close(), resolve()) }));
|
|
43
|
+
});
|
|
35
44
|
};
|
|
36
45
|
export const openProfile = (hot) => {
|
|
37
46
|
present((close) => _jsx(Profile, { hot: hot, onClose: close }));
|
|
@@ -53,4 +62,7 @@ export const openWCRequest = (args) => {
|
|
|
53
62
|
present((close) => _jsx(WCRequest, { deeplink: args.deeplink, name: args.name, icon: args.icon, onClose: close, task: taskPromise }));
|
|
54
63
|
return taskPromise;
|
|
55
64
|
};
|
|
65
|
+
export const openToast = (message) => {
|
|
66
|
+
return present(() => _jsx(Toast, { message: message }));
|
|
67
|
+
};
|
|
56
68
|
//# sourceMappingURL=router.js.map
|
package/build/ui/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/ui/router.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/ui/router.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,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OAAO,EAAE,KAAK,GAAI,CAAC,CAAC;AACxG,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAA8F,EAAE,EAAE;IACjI,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,YAAY,OAAK,KAAK,EAAE,OAAO,EAAE,KAAK,GAAI,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAA6G,EAAE,EAAE;IACnJ,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,eAAe,OAAK,KAAK,EAAE,OAAO,EAAE,KAAK,GAAI,CAAC,CAAC;AACrE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAK,IAA6F,EAAc,EAAE;IAC7I,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,SAAS,IAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,GAAI,CAAC,CAAC;IAChI,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IAC3C,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,KAAC,KAAK,IAAC,OAAO,EAAE,OAAO,GAAI,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
package/build/ui/styles.js
CHANGED
|
@@ -185,6 +185,7 @@ export const PopupOption = styled.button `
|
|
|
185
185
|
outline: none;
|
|
186
186
|
border: none;
|
|
187
187
|
background: transparent;
|
|
188
|
+
width: 100%;
|
|
188
189
|
gap: 12px;
|
|
189
190
|
|
|
190
191
|
img {
|
|
@@ -251,6 +252,7 @@ export const PopupButton = styled.button `
|
|
|
251
252
|
`;
|
|
252
253
|
export const PopupRoot = styled.div `
|
|
253
254
|
height: 100%;
|
|
255
|
+
width: 100%;
|
|
254
256
|
|
|
255
257
|
h1,
|
|
256
258
|
h2,
|
package/build/ui/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/ui/styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,IAAI,GAAG,+IAA+I,CAAC;AAE7J,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;CAiBvC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;CAUrC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAiC;;;;;;;;;;;;;;;;;;;;;;MAsBjE,CAAC,KAAsC,EAAE,EAAE,CAC3C,KAAK,CAAC,iBAAiB;IACvB,GAAG,CAAA;;;;;;;OAOF;;CAEN,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCpC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmClC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;CAqB/B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAA;;;;;;;;;;;;;;CAcpC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAA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,CAAA;;;;;;;;;;;;;;;;;;;;;;CAsBvC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;mBAWhB,IAAI;;;;;;;;;;;;;;;mBAeJ,IAAI;;;;;;;;;;CAUtB,CAAC"}
|
package/package.json
CHANGED
package/src/core/Intents.ts
CHANGED
|
@@ -7,10 +7,11 @@ import { rpc } from "../near/rpc";
|
|
|
7
7
|
import type { Intent, Commitment, TokenDiffIntent, MtWithdrawIntent, FtWithdrawIntent, NftWithdrawIntent, TransferIntent } from "./types";
|
|
8
8
|
import { OmniToken } from "./chains";
|
|
9
9
|
import { tokens } from "./tokens";
|
|
10
|
-
import { formatter } from "./utils";
|
|
11
10
|
import { api } from "./api";
|
|
12
11
|
|
|
13
|
-
import { openPayment } from "../ui/router";
|
|
12
|
+
import { openConnector, openConnectPrimaryWallet, openPayment, openToast } from "../ui/router";
|
|
13
|
+
import { formatter } from "./utils";
|
|
14
|
+
import { BridgeReview } from "../exchange";
|
|
14
15
|
|
|
15
16
|
export const TGAS = 1000000000000n;
|
|
16
17
|
|
|
@@ -26,16 +27,18 @@ export class Intents {
|
|
|
26
27
|
need = new Map<OmniToken, bigint>();
|
|
27
28
|
signer?: OmniWallet;
|
|
28
29
|
|
|
29
|
-
unsignedCommitment
|
|
30
|
+
unsignedCommitment?: {
|
|
30
31
|
intents: Intent[];
|
|
31
32
|
nonce?: Uint8Array;
|
|
32
33
|
deadline?: Date;
|
|
33
|
-
} = {
|
|
34
|
-
intents: [],
|
|
35
|
-
nonce: undefined,
|
|
36
|
-
deadline: undefined,
|
|
37
34
|
};
|
|
38
35
|
|
|
36
|
+
addIntent(intent: Intent) {
|
|
37
|
+
if (!this.unsignedCommitment) this.unsignedCommitment = { intents: [] };
|
|
38
|
+
this.unsignedCommitment.intents.push(intent);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
39
42
|
addNeed(token: OmniToken, amount: bigint) {
|
|
40
43
|
if (!this.need.has(token)) this.need.set(token, 0n);
|
|
41
44
|
this.need.set(token, this.need.get(token)! + amount);
|
|
@@ -44,7 +47,7 @@ export class Intents {
|
|
|
44
47
|
|
|
45
48
|
authCall(args: { contractId: string; msg: string; attachNear: bigint; tgas: number }) {
|
|
46
49
|
this.addNeed(OmniToken.NEAR, args.attachNear);
|
|
47
|
-
this.
|
|
50
|
+
this.addIntent({
|
|
48
51
|
min_gas: (BigInt(args.tgas) * TGAS).toString(),
|
|
49
52
|
attached_deposit: args.attachNear.toString(),
|
|
50
53
|
contract_id: args.contractId,
|
|
@@ -64,7 +67,11 @@ export class Intents {
|
|
|
64
67
|
recipient: "pay.fi.tg",
|
|
65
68
|
amount,
|
|
66
69
|
token,
|
|
67
|
-
}).
|
|
70
|
+
}).depositAndExecute({
|
|
71
|
+
title: `Pay ${this.wibe3?.omni(token).readable(amount)} ${this.wibe3?.omni(token).symbol}`,
|
|
72
|
+
serverSideProcessing: true,
|
|
73
|
+
payload: { email },
|
|
74
|
+
});
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
transfer(args: { recipient: string; token: OmniToken; amount: number | bigint; memo?: string; msg?: string; tgas?: number }) {
|
|
@@ -80,7 +87,7 @@ export class Intents {
|
|
|
80
87
|
};
|
|
81
88
|
|
|
82
89
|
this.addNeed(args.token, BigInt(amount));
|
|
83
|
-
this.
|
|
90
|
+
this.addIntent(intent);
|
|
84
91
|
return this;
|
|
85
92
|
}
|
|
86
93
|
|
|
@@ -102,7 +109,7 @@ export class Intents {
|
|
|
102
109
|
msg: args.msg,
|
|
103
110
|
};
|
|
104
111
|
|
|
105
|
-
this.
|
|
112
|
+
this.addIntent(intent);
|
|
106
113
|
return this;
|
|
107
114
|
}
|
|
108
115
|
|
|
@@ -125,7 +132,7 @@ export class Intents {
|
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
134
|
|
|
128
|
-
this.
|
|
135
|
+
this.addIntent(intent);
|
|
129
136
|
return this;
|
|
130
137
|
}
|
|
131
138
|
|
|
@@ -162,7 +169,7 @@ export class Intents {
|
|
|
162
169
|
this.addNeed(token, BigInt(rawIntent.amounts[i]));
|
|
163
170
|
}
|
|
164
171
|
|
|
165
|
-
this.
|
|
172
|
+
this.addIntent({
|
|
166
173
|
intent: "mt_withdraw",
|
|
167
174
|
amounts: rawIntent.amounts,
|
|
168
175
|
receiver_id: rawIntent.receiver_id,
|
|
@@ -217,12 +224,12 @@ export class Intents {
|
|
|
217
224
|
}
|
|
218
225
|
|
|
219
226
|
addPublicKey(publicKey: string) {
|
|
220
|
-
this.
|
|
227
|
+
this.addIntent({ intent: "add_public_key", public_key: publicKey });
|
|
221
228
|
return this;
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
removePublicKey(publicKey: string) {
|
|
225
|
-
this.
|
|
232
|
+
this.addIntent({ intent: "remove_public_key", public_key: publicKey });
|
|
226
233
|
return this;
|
|
227
234
|
}
|
|
228
235
|
|
|
@@ -235,7 +242,7 @@ export class Intents {
|
|
|
235
242
|
if (standart === "nep245") {
|
|
236
243
|
const mtContract = tokenParts[0];
|
|
237
244
|
const tokenId = tokenParts.slice(1).join(":");
|
|
238
|
-
this.
|
|
245
|
+
this.addIntent({
|
|
239
246
|
intent: "mt_withdraw",
|
|
240
247
|
amounts: [amount],
|
|
241
248
|
receiver_id: args.receiver,
|
|
@@ -249,7 +256,7 @@ export class Intents {
|
|
|
249
256
|
}
|
|
250
257
|
|
|
251
258
|
if (standart === "nep141") {
|
|
252
|
-
this.
|
|
259
|
+
this.addIntent({
|
|
253
260
|
intent: "ft_withdraw",
|
|
254
261
|
receiver_id: args.receiver,
|
|
255
262
|
token: tokenParts.join(":"),
|
|
@@ -261,7 +268,7 @@ export class Intents {
|
|
|
261
268
|
}
|
|
262
269
|
|
|
263
270
|
if (standart === "nep171") {
|
|
264
|
-
this.
|
|
271
|
+
this.addIntent({
|
|
265
272
|
intent: "nft_withdraw",
|
|
266
273
|
receiver_id: args.receiver,
|
|
267
274
|
token_id: tokenParts.join(":"),
|
|
@@ -286,21 +293,25 @@ export class Intents {
|
|
|
286
293
|
}
|
|
287
294
|
|
|
288
295
|
attachDeadline(deadline: Date) {
|
|
296
|
+
if (!this.unsignedCommitment) this.unsignedCommitment = { intents: [] };
|
|
289
297
|
this.unsignedCommitment.deadline = deadline;
|
|
290
298
|
return this;
|
|
291
299
|
}
|
|
292
300
|
|
|
293
301
|
attachNonce(nonce: Uint8Array) {
|
|
302
|
+
if (!this.unsignedCommitment) this.unsignedCommitment = { intents: [] };
|
|
294
303
|
this.unsignedCommitment.nonce = nonce;
|
|
295
304
|
return this;
|
|
296
305
|
}
|
|
297
306
|
|
|
298
307
|
attachTimeout(seconds: number) {
|
|
308
|
+
if (!this.unsignedCommitment) this.unsignedCommitment = { intents: [] };
|
|
299
309
|
this.unsignedCommitment.deadline = new Date(Date.now() + seconds * 1000);
|
|
300
310
|
return this;
|
|
301
311
|
}
|
|
302
312
|
|
|
303
313
|
attachSeed(seed: string) {
|
|
314
|
+
if (!this.unsignedCommitment) this.unsignedCommitment = { intents: [] };
|
|
304
315
|
this.unsignedCommitment.nonce = new Uint8Array(sha256(new TextEncoder().encode(seed))).slice(0, 32);
|
|
305
316
|
return this;
|
|
306
317
|
}
|
|
@@ -314,10 +325,10 @@ export class Intents {
|
|
|
314
325
|
const intAmount = typeof amount === "number" ? tokens.get(token).int(amount) : amount;
|
|
315
326
|
|
|
316
327
|
// this.addNeed(token, -intAmount); Do we need to add the need here?
|
|
317
|
-
const tokenDiff = this.unsignedCommitment
|
|
328
|
+
const tokenDiff = this.unsignedCommitment?.intents.find((intent) => intent.intent === "token_diff");
|
|
318
329
|
|
|
319
330
|
if (tokenDiff) tokenDiff.diff[token.toString()] = intAmount.toString();
|
|
320
|
-
else this.
|
|
331
|
+
else this.addIntent({ intent: "token_diff", diff: { [token.toString()]: intAmount.toString() } });
|
|
321
332
|
return this;
|
|
322
333
|
}
|
|
323
334
|
|
|
@@ -325,10 +336,10 @@ export class Intents {
|
|
|
325
336
|
const intAmount = typeof amount === "number" ? tokens.get(token).int(amount) : amount;
|
|
326
337
|
|
|
327
338
|
this.addNeed(token as OmniToken, intAmount);
|
|
328
|
-
const tokenDiff = this.unsignedCommitment
|
|
339
|
+
const tokenDiff = this.unsignedCommitment?.intents.find((intent) => intent.intent === "token_diff");
|
|
329
340
|
|
|
330
341
|
if (tokenDiff) tokenDiff.diff[token.toString()] = (-intAmount).toString();
|
|
331
|
-
else this.
|
|
342
|
+
else this.addIntent({ intent: "token_diff", diff: { [token.toString()]: (-intAmount).toString() } });
|
|
332
343
|
return this;
|
|
333
344
|
}
|
|
334
345
|
|
|
@@ -338,11 +349,11 @@ export class Intents {
|
|
|
338
349
|
if (!signer.omniAddress) throw new Error("No omni address");
|
|
339
350
|
|
|
340
351
|
const commitments: Commitment[] = [];
|
|
341
|
-
for (const intent of this.unsignedCommitment
|
|
352
|
+
for (const intent of this.unsignedCommitment?.intents || []) {
|
|
342
353
|
commitments.push(
|
|
343
354
|
await signer.signIntents([intent], {
|
|
344
|
-
deadline: this.unsignedCommitment
|
|
345
|
-
nonce: this.unsignedCommitment
|
|
355
|
+
deadline: this.unsignedCommitment?.deadline ? +this.unsignedCommitment.deadline : undefined,
|
|
356
|
+
nonce: this.unsignedCommitment?.nonce,
|
|
346
357
|
})
|
|
347
358
|
);
|
|
348
359
|
}
|
|
@@ -354,12 +365,12 @@ export class Intents {
|
|
|
354
365
|
const signer = this.signer;
|
|
355
366
|
if (!signer) throw new Error("No signer attached");
|
|
356
367
|
if (!signer.omniAddress) throw new Error("No omni address");
|
|
357
|
-
const commitment = await signer.signIntents(this.unsignedCommitment
|
|
358
|
-
deadline: this.unsignedCommitment
|
|
359
|
-
nonce: this.unsignedCommitment
|
|
368
|
+
const commitment = await signer.signIntents(this.unsignedCommitment?.intents || [], {
|
|
369
|
+
deadline: this.unsignedCommitment?.deadline ? +this.unsignedCommitment.deadline : undefined,
|
|
370
|
+
nonce: this.unsignedCommitment?.nonce,
|
|
360
371
|
});
|
|
361
372
|
|
|
362
|
-
this.unsignedCommitment =
|
|
373
|
+
this.unsignedCommitment = undefined;
|
|
363
374
|
this.commitments.push(commitment);
|
|
364
375
|
return this;
|
|
365
376
|
}
|
|
@@ -369,28 +380,88 @@ export class Intents {
|
|
|
369
380
|
return await Intents.simulateIntents(this.commitments);
|
|
370
381
|
}
|
|
371
382
|
|
|
372
|
-
async
|
|
383
|
+
async setupSigner() {
|
|
373
384
|
if (!this.wibe3) throw new Error("No wibe3 attached");
|
|
374
|
-
|
|
375
|
-
const depositAddress = depositQoute === "direct" ? undefined : typeof depositQoute?.qoute === "object" ? depositQoute?.qoute?.depositAddress : undefined;
|
|
385
|
+
if (this.signer) return this.signer;
|
|
376
386
|
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
return
|
|
387
|
+
if (this.wibe3.priorityWallet) {
|
|
388
|
+
this.signer = this.wibe3.priorityWallet;
|
|
389
|
+
return this.signer;
|
|
380
390
|
}
|
|
381
391
|
|
|
382
|
-
|
|
383
|
-
|
|
392
|
+
if (this.wibe3.wallets.length > 0) {
|
|
393
|
+
await openConnectPrimaryWallet(this.wibe3);
|
|
394
|
+
if (this.wibe3.priorityWallet == undefined) throw new Error("No signer attached");
|
|
395
|
+
this.signer = this.wibe3.priorityWallet;
|
|
396
|
+
return this.signer;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
await openConnector(this.wibe3);
|
|
400
|
+
if (this.wibe3.priorityWallet == undefined) await openConnectPrimaryWallet(this.wibe3);
|
|
401
|
+
if (this.wibe3.priorityWallet == undefined) throw new Error("No signer attached");
|
|
402
|
+
this.signer = this.wibe3.priorityWallet;
|
|
403
|
+
return this.signer;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async openSignFlow({
|
|
407
|
+
title,
|
|
408
|
+
allowedTokens,
|
|
409
|
+
onConfirm,
|
|
410
|
+
}: {
|
|
411
|
+
title?: string; //
|
|
412
|
+
allowedTokens?: string[];
|
|
413
|
+
onConfirm: (args: { depositQoute: BridgeReview | "direct"; processing?: () => Promise<BridgeReview> }) => Promise<void>;
|
|
414
|
+
}) {
|
|
415
|
+
if (!this.wibe3) throw "Attach wibe3";
|
|
416
|
+
if (!this.signer) throw "Attach signer";
|
|
417
|
+
|
|
418
|
+
// TODO: Handle multiple payables
|
|
419
|
+
const payableToken = tokens.get(Array.from(this.need.keys())[0]);
|
|
420
|
+
const payableAmount = this.need.get(payableToken.omniAddress as OmniToken) || 0n;
|
|
421
|
+
const balance = await this.wibe3.fetchToken(payableToken!, this.signer);
|
|
422
|
+
const prepaidAmount = formatter.bigIntMin(payableAmount, balance);
|
|
423
|
+
|
|
424
|
+
return await openPayment(this.wibe3, {
|
|
425
|
+
onConfirm,
|
|
426
|
+
needAmount: payableAmount - prepaidAmount,
|
|
427
|
+
allowedTokens,
|
|
428
|
+
prepaidAmount,
|
|
429
|
+
payableToken,
|
|
430
|
+
intents: this,
|
|
431
|
+
title,
|
|
432
|
+
});
|
|
384
433
|
}
|
|
385
434
|
|
|
386
|
-
async depositAndExecute() {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
await
|
|
390
|
-
|
|
435
|
+
async depositAndExecute({ title = "Payment", message, allowedTokens, serverSideProcessing, payload }: { title?: string; message?: string; allowedTokens?: string[]; serverSideProcessing?: boolean; payload?: Record<string, any> } = {}) {
|
|
436
|
+
await this.setupSigner();
|
|
437
|
+
if (this.need.size === 0) return this.execute();
|
|
438
|
+
await this.openSignFlow({
|
|
439
|
+
title,
|
|
440
|
+
allowedTokens,
|
|
441
|
+
onConfirm: async ({ depositQoute, processing }: { depositQoute: BridgeReview | "direct"; processing?: () => Promise<BridgeReview> }) => {
|
|
442
|
+
if (!serverSideProcessing) return;
|
|
443
|
+
|
|
444
|
+
if (depositQoute === "direct" || typeof depositQoute?.qoute !== "object" || !depositQoute.qoute?.depositAddress) {
|
|
445
|
+
await processing?.();
|
|
446
|
+
await this.execute();
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
await api.yieldIntentCall({
|
|
451
|
+
depositAddress: depositQoute.qoute.depositAddress,
|
|
452
|
+
commitment: this.commitments[0],
|
|
453
|
+
payload: payload || {},
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
if (serverSideProcessing) return;
|
|
459
|
+
const close = openToast(message || "Executing payment");
|
|
460
|
+
await this.execute().finally(() => close());
|
|
391
461
|
}
|
|
392
462
|
|
|
393
463
|
async execute() {
|
|
464
|
+
if (this.unsignedCommitment != null) await this.sign();
|
|
394
465
|
const task = Intents.publish(this.commitments, this.signedHashes);
|
|
395
466
|
this.commitments = [];
|
|
396
467
|
this.signedHashes = [];
|
|
@@ -400,22 +471,6 @@ export class Intents {
|
|
|
400
471
|
return hash;
|
|
401
472
|
}
|
|
402
473
|
|
|
403
|
-
async executeBatch(params = { checkTokens: true, chunkSize: this.unsignedCommitment.intents.length, onSuccess: (bucket: number, hash: string) => {} }) {
|
|
404
|
-
if (this.commitments.length === 0) throw new Error("No commitments attached");
|
|
405
|
-
const batches = formatter.chunk(this.unsignedCommitment.intents, params.chunkSize);
|
|
406
|
-
let index = 0;
|
|
407
|
-
|
|
408
|
-
const hashes: string[] = [];
|
|
409
|
-
for (const batch of batches) {
|
|
410
|
-
this.unsignedCommitment.intents = batch;
|
|
411
|
-
const hash = await this.sign().then(() => this.execute());
|
|
412
|
-
params.onSuccess(index++, hash);
|
|
413
|
-
hashes.push(hash);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return hashes;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
474
|
static async publish(signed: Commitment[], hashes: string[] = []): Promise<string> {
|
|
420
475
|
const result = await api.publishIntents(signed, hashes);
|
|
421
476
|
if (result.status === "FAILED") throw result.reason;
|
package/src/core/utils.ts
CHANGED
|
@@ -148,7 +148,12 @@ export const formatter = {
|
|
|
148
148
|
},
|
|
149
149
|
|
|
150
150
|
amount(value: Value, decimals = 24) {
|
|
151
|
-
|
|
151
|
+
if (+formatter.num(value) > 1_000_000_000_000_000_000) return `${formatter.round(+formatter.num(value) / 1_000_000_000_000_000, 2)}Q`;
|
|
152
|
+
if (+formatter.num(value) > 1_000_000_000_000_000) return `${formatter.round(+formatter.num(value) / 1_000_000_000_000, 2)}T`;
|
|
153
|
+
if (+formatter.num(value) > 1_000_000_000_000) return `${formatter.round(+formatter.num(value) / 1_000_000_000, 2)}B`;
|
|
154
|
+
if (+formatter.num(value) > 1_000_000_000) return `${formatter.round(+formatter.num(value) / 1_000_000, 2)}M`;
|
|
155
|
+
const num = formatter.num(value).toFixed(decimals);
|
|
156
|
+
if (+num === 0) return "0";
|
|
152
157
|
return formatter.formatNumberWithSubscriptZeros(num, 3, 0.0001);
|
|
153
158
|
},
|
|
154
159
|
|
package/src/exchange.ts
CHANGED
|
@@ -184,7 +184,7 @@ export class Exchange {
|
|
|
184
184
|
if (!intentFrom) throw new Error("Unsupported token");
|
|
185
185
|
if (!intentTo) throw new Error("Unsupported token");
|
|
186
186
|
|
|
187
|
-
const deadlineTime =
|
|
187
|
+
const deadlineTime = 5 * 60 * 1000;
|
|
188
188
|
const directChains = [Network.Near, Network.Juno, Network.Gonka, Network.ADI];
|
|
189
189
|
const deadline = new Date(Date.now() + deadlineTime).toISOString();
|
|
190
190
|
const noFee = from.symbol === to.symbol || (from.symbol.toLowerCase().includes("usd") && to.symbol.toLowerCase().includes("usd"));
|
package/src/ui/Popup.tsx
CHANGED
package/src/ui/Toast.tsx
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { Loader } from "./payment/Profile";
|
|
3
|
+
|
|
4
|
+
const Toast = ({ message }: { message: string }) => {
|
|
5
|
+
return (
|
|
6
|
+
<ToastRoot>
|
|
7
|
+
<div style={{ width: 44, height: 44, display: "flex", alignItems: "center", justifyContent: "center", borderRadius: 12, background: "rgba(255, 255, 255, 0.07)" }}>
|
|
8
|
+
<Loader />
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<p style={{ color: "#ADA5A4" }}>Executing transaction</p>
|
|
13
|
+
<p style={{ marginTop: 2 }}>{message}</p>
|
|
14
|
+
</div>
|
|
15
|
+
</ToastRoot>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default Toast;
|
|
20
|
+
|
|
21
|
+
const ToastRoot = styled.div`
|
|
22
|
+
position: fixed;
|
|
23
|
+
bottom: 48px;
|
|
24
|
+
left: 12px;
|
|
25
|
+
right: 12px;
|
|
26
|
+
background: var(--surface-common-container--low, #262729);
|
|
27
|
+
border: 1px solid var(--border-lowest, rgba(255, 255, 255, 0.07));
|
|
28
|
+
border-radius: 8px;
|
|
29
|
+
padding: 12px;
|
|
30
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
z-index: 1000000000;
|
|
35
|
+
width: fit-content;
|
|
36
|
+
padding-right: 24px;
|
|
37
|
+
gap: 12px;
|
|
38
|
+
|
|
39
|
+
p {
|
|
40
|
+
color: var(--text-primary, #fff);
|
|
41
|
+
font-size: 16px;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
margin: 0;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { observer } from "mobx-react-lite";
|
|
2
2
|
|
|
3
|
+
import { OmniWallet } from "../../OmniWallet";
|
|
3
4
|
import { HotConnector } from "../../HotConnector";
|
|
4
5
|
import { ConnectorType, OmniConnector } from "../../OmniConnector";
|
|
6
|
+
|
|
5
7
|
import { formatter } from "../../core/utils";
|
|
8
|
+
import { WalletType } from "../../core";
|
|
6
9
|
|
|
7
10
|
import { ImageView } from "../payment/TokenCard";
|
|
8
11
|
import { PopupOption, PopupOptionInfo } from "../styles";
|
|
@@ -12,22 +15,24 @@ import Popup from "../Popup";
|
|
|
12
15
|
|
|
13
16
|
interface MultichainPopupProps {
|
|
14
17
|
hot: HotConnector;
|
|
15
|
-
onClose: () => void;
|
|
18
|
+
onClose: (wallet?: OmniWallet) => void;
|
|
16
19
|
title?: string;
|
|
20
|
+
walletType?: WalletType;
|
|
21
|
+
widget?: boolean;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
export const Connector = observer(({ hot, onClose, title }: MultichainPopupProps) => {
|
|
20
|
-
const onechain = hot.connectors.filter((t) => t.type === ConnectorType.WALLET);
|
|
21
|
-
const social = hot.connectors.filter((t) => t.type === ConnectorType.SOCIAL);
|
|
24
|
+
export const Connector = observer(({ hot, onClose, title, walletType, widget }: MultichainPopupProps) => {
|
|
25
|
+
const onechain = hot.connectors.filter((t) => t.type === ConnectorType.WALLET && (walletType == null || t.walletTypes.includes(walletType as WalletType)));
|
|
26
|
+
const social = hot.connectors.filter((t) => t.type === ConnectorType.SOCIAL && (walletType == null || t.walletTypes.includes(walletType as WalletType)));
|
|
22
27
|
|
|
23
28
|
const selectConnector = async (t: OmniConnector) => {
|
|
24
29
|
if (t.wallets[0]) return t.disconnect();
|
|
25
|
-
if (t.options.length > 0) return
|
|
30
|
+
if (t.options.length > 0) return openWalletPicker(t, (w) => onClose(w));
|
|
26
31
|
await t.connect().finally(() => onClose());
|
|
27
32
|
};
|
|
28
33
|
|
|
29
34
|
return (
|
|
30
|
-
<Popup header={<p>{title || "Select network"}</p>} onClose={onClose}>
|
|
35
|
+
<Popup header={<p>{title || "Select network"}</p>} onClose={onClose} widget={widget}>
|
|
31
36
|
{onechain.map((t) => (
|
|
32
37
|
<PopupOption key={t.id} onClick={() => selectConnector(t)}>
|
|
33
38
|
<ImageView src={t.icon} alt={t.name} size={44} />
|