@hot-labs/kit 1.1.3 → 1.2.0-alpha.1
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 +9 -2
- package/package.json +4 -8
- package/src/HotConnector.ts +31 -24
- package/src/OmniConnector.ts +9 -10
- package/src/OmniWallet.ts +25 -24
- package/src/core/Intents.ts +151 -224
- package/src/core/api.ts +4 -44
- package/src/core/bridge.ts +2 -3
- package/src/core/index.ts +1 -1
- package/src/{near/rpc.ts → core/nearRpc.ts} +12 -7
- package/src/core/types.ts +0 -21
- package/src/core/utils.ts +1 -17
- package/src/cosmos/connector.ts +26 -22
- package/src/cosmos/wallet.ts +8 -3
- package/src/evm/connector.ts +0 -5
- package/src/evm/wallet.ts +6 -9
- package/src/exchange.ts +30 -24
- package/src/hot-wallet/google.ts +5 -12
- package/src/hot-wallet/proxy.ts +2 -2
- package/src/index.ts +0 -2
- package/src/near/connector.ts +2 -2
- package/src/near/wallet.ts +9 -4
- package/src/solana/connector.ts +8 -9
- package/src/solana/injected/solana-wallet.ts +6 -6
- package/src/solana/{WalletStandard.ts → protocol.ts} +4 -2
- package/src/solana/wallet.ts +20 -11
- package/src/stellar/connector.ts +6 -1
- package/src/stellar/wallet.ts +17 -17
- package/src/ton/connector.ts +5 -1
- package/src/ton/wallet.ts +3 -3
- package/src/ui/Popup.tsx +4 -12
- package/src/ui/connect/AuthPopup.tsx +1 -2
- package/src/ui/connect/ConnectWallet.tsx +6 -12
- 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 +4 -2
- package/src/ui/icons/qr.tsx +2 -1
- package/src/ui/icons/search.tsx +4 -4
- package/src/ui/icons/switch.tsx +4 -4
- package/src/ui/icons/wallet.tsx +4 -2
- package/src/ui/payment/Bridge.tsx +6 -25
- package/src/ui/payment/Payment.tsx +46 -244
- package/src/ui/payment/Profile.tsx +8 -10
- package/src/ui/payment/SelectToken.tsx +1 -1
- package/src/ui/payment/TokenCard.tsx +18 -22
- package/src/ui/router.tsx +16 -56
- package/src/ui/styles.ts +0 -2
- package/build/HotConnector.d.ts +0 -105
- package/build/HotConnector.js +0 -303
- package/build/HotConnector.js.map +0 -1
- package/build/OmniConnector.d.ts +0 -90
- package/build/OmniConnector.js +0 -121
- package/build/OmniConnector.js.map +0 -1
- package/build/OmniWallet.d.ts +0 -35
- package/build/OmniWallet.js +0 -56
- package/build/OmniWallet.js.map +0 -1
- package/build/activity.d.ts +0 -18
- package/build/activity.js +0 -87
- package/build/activity.js.map +0 -1
- package/build/core/Intents.d.ts +0 -100
- package/build/core/Intents.js +0 -474
- package/build/core/Intents.js.map +0 -1
- package/build/core/api.d.ts +0 -54
- package/build/core/api.js +0 -99
- package/build/core/api.js.map +0 -1
- package/build/core/bridge.d.ts +0 -3
- package/build/core/bridge.js +0 -36
- package/build/core/bridge.js.map +0 -1
- package/build/core/chains.d.ts +0 -115
- package/build/core/chains.js +0 -381
- package/build/core/chains.js.map +0 -1
- package/build/core/defaultTokens.d.ts +0 -17
- package/build/core/defaultTokens.js +0 -1079
- package/build/core/defaultTokens.js.map +0 -1
- package/build/core/events.d.ts +0 -42
- package/build/core/events.js +0 -64
- package/build/core/events.js.map +0 -1
- package/build/core/index.d.ts +0 -10
- package/build/core/index.js +0 -11
- package/build/core/index.js.map +0 -1
- package/build/core/recipient.d.ts +0 -10
- package/build/core/recipient.js +0 -40
- package/build/core/recipient.js.map +0 -1
- package/build/core/telemetry.d.ts +0 -13
- package/build/core/telemetry.js +0 -27
- package/build/core/telemetry.js.map +0 -1
- package/build/core/token.d.ts +0 -36
- package/build/core/token.js +0 -103
- package/build/core/token.js.map +0 -1
- package/build/core/tokens.d.ts +0 -14
- package/build/core/tokens.js +0 -59
- package/build/core/tokens.js.map +0 -1
- package/build/core/types.d.ts +0 -60
- package/build/core/types.js +0 -2
- package/build/core/types.js.map +0 -1
- package/build/core/utils.d.ts +0 -25
- package/build/core/utils.js +0 -170
- package/build/core/utils.js.map +0 -1
- package/build/cosmos/connector.d.ts +0 -36
- package/build/cosmos/connector.js +0 -211
- package/build/cosmos/connector.js.map +0 -1
- package/build/cosmos/helpers.d.ts +0 -2
- package/build/cosmos/helpers.js +0 -29
- package/build/cosmos/helpers.js.map +0 -1
- package/build/cosmos/index.d.ts +0 -6
- package/build/cosmos/index.js +0 -5
- package/build/cosmos/index.js.map +0 -1
- package/build/cosmos/wallet.d.ts +0 -26
- package/build/cosmos/wallet.js +0 -51
- package/build/cosmos/wallet.js.map +0 -1
- package/build/defaults.d.ts +0 -1
- package/build/defaults.js +0 -7
- package/build/defaults.js.map +0 -1
- package/build/evm/abi.d.ts +0 -17
- package/build/evm/abi.js +0 -38
- package/build/evm/abi.js.map +0 -1
- package/build/evm/connector.d.ts +0 -29
- package/build/evm/connector.js +0 -118
- package/build/evm/connector.js.map +0 -1
- package/build/evm/index.d.ts +0 -6
- package/build/evm/index.js +0 -5
- package/build/evm/index.js.map +0 -1
- package/build/evm/injected.d.ts +0 -1
- package/build/evm/injected.js +0 -33
- package/build/evm/injected.js.map +0 -1
- package/build/evm/wallet.d.ts +0 -42
- package/build/evm/wallet.js +0 -130
- package/build/evm/wallet.js.map +0 -1
- package/build/exchange.d.ts +0 -68
- package/build/exchange.js +0 -384
- package/build/exchange.js.map +0 -1
- package/build/hot-wallet/google.d.ts +0 -25
- package/build/hot-wallet/google.js +0 -117
- package/build/hot-wallet/google.js.map +0 -1
- package/build/hot-wallet/iframe.d.ts +0 -36
- package/build/hot-wallet/iframe.js +0 -140
- package/build/hot-wallet/iframe.js.map +0 -1
- package/build/hot-wallet/index.d.ts +0 -5
- package/build/hot-wallet/index.js +0 -4
- package/build/hot-wallet/index.js.map +0 -1
- package/build/hot-wallet/proxy.d.ts +0 -8
- package/build/hot-wallet/proxy.js +0 -45
- package/build/hot-wallet/proxy.js.map +0 -1
- package/build/index.d.ts +0 -6
- package/build/index.js +0 -7
- package/build/index.js.map +0 -1
- package/build/near/connector.d.ts +0 -18
- package/build/near/connector.js +0 -58
- package/build/near/connector.js.map +0 -1
- package/build/near/index.d.ts +0 -7
- package/build/near/index.js +0 -5
- package/build/near/index.js.map +0 -1
- package/build/near/rpc.d.ts +0 -23
- package/build/near/rpc.js +0 -162
- package/build/near/rpc.js.map +0 -1
- package/build/near/wallet.d.ts +0 -53
- package/build/near/wallet.js +0 -190
- package/build/near/wallet.js.map +0 -1
- package/build/solana/WalletStandard.d.ts +0 -25
- package/build/solana/WalletStandard.js +0 -56
- package/build/solana/WalletStandard.js.map +0 -1
- package/build/solana/connector.d.ts +0 -30
- package/build/solana/connector.js +0 -139
- package/build/solana/connector.js.map +0 -1
- package/build/solana/index.d.ts +0 -6
- package/build/solana/index.js +0 -5
- package/build/solana/index.js.map +0 -1
- package/build/solana/injected/account.d.ts +0 -11
- package/build/solana/injected/account.js +0 -41
- package/build/solana/injected/account.js.map +0 -1
- package/build/solana/injected/index.d.ts +0 -1
- package/build/solana/injected/index.js +0 -82
- package/build/solana/injected/index.js.map +0 -1
- package/build/solana/injected/register.d.ts +0 -2
- package/build/solana/injected/register.js +0 -41
- package/build/solana/injected/register.js.map +0 -1
- package/build/solana/injected/solana-wallet.d.ts +0 -34
- package/build/solana/injected/solana-wallet.js +0 -223
- package/build/solana/injected/solana-wallet.js.map +0 -1
- package/build/solana/injected/utils.d.ts +0 -32
- package/build/solana/injected/utils.js +0 -36
- package/build/solana/injected/utils.js.map +0 -1
- package/build/solana/wallet.d.ts +0 -40
- package/build/solana/wallet.js +0 -181
- package/build/solana/wallet.js.map +0 -1
- package/build/solana/walletStandartList.d.ts +0 -102
- package/build/solana/walletStandartList.js +0 -150
- package/build/solana/walletStandartList.js.map +0 -1
- package/build/stellar/connector.d.ts +0 -29
- package/build/stellar/connector.js +0 -64
- package/build/stellar/connector.js.map +0 -1
- package/build/stellar/freigher.d.ts +0 -46
- package/build/stellar/freigher.js +0 -110
- package/build/stellar/freigher.js.map +0 -1
- package/build/stellar/hotWallet.d.ts +0 -33
- package/build/stellar/hotWallet.js +0 -28
- package/build/stellar/hotWallet.js.map +0 -1
- package/build/stellar/index.d.ts +0 -6
- package/build/stellar/index.js +0 -5
- package/build/stellar/index.js.map +0 -1
- package/build/stellar/wallet.d.ts +0 -67
- package/build/stellar/wallet.js +0 -212
- package/build/stellar/wallet.js.map +0 -1
- package/build/storage.d.ts +0 -10
- package/build/storage.js +0 -12
- package/build/storage.js.map +0 -1
- package/build/ton/connector.d.ts +0 -24
- package/build/ton/connector.js +0 -111
- package/build/ton/connector.js.map +0 -1
- package/build/ton/index.d.ts +0 -7
- package/build/ton/index.js +0 -5
- package/build/ton/index.js.map +0 -1
- package/build/ton/injected.d.ts +0 -1
- package/build/ton/injected.js +0 -49
- package/build/ton/injected.js.map +0 -1
- package/build/ton/utils.d.ts +0 -45
- package/build/ton/utils.js +0 -63
- package/build/ton/utils.js.map +0 -1
- package/build/ton/wallet.d.ts +0 -54
- package/build/ton/wallet.js +0 -138
- package/build/ton/wallet.js.map +0 -1
- package/build/tron/connector.d.ts +0 -51
- package/build/tron/connector.js +0 -65
- package/build/tron/connector.js.map +0 -1
- package/build/tron/index.d.ts +0 -6
- package/build/tron/index.js +0 -5
- package/build/tron/index.js.map +0 -1
- package/build/tron/wallet.d.ts +0 -52
- package/build/tron/wallet.js +0 -122
- package/build/tron/wallet.js.map +0 -1
- package/build/ui/Popup.d.ts +0 -12
- package/build/ui/Popup.js +0 -43
- package/build/ui/Popup.js.map +0 -1
- package/build/ui/Toast.d.ts +0 -4
- package/build/ui/Toast.js +0 -33
- package/build/ui/Toast.js.map +0 -1
- package/build/ui/connect/AuthPopup.d.ts +0 -2
- package/build/ui/connect/AuthPopup.js +0 -48
- package/build/ui/connect/AuthPopup.js.map +0 -1
- package/build/ui/connect/ConnectWallet.d.ts +0 -14
- package/build/ui/connect/ConnectWallet.js +0 -22
- package/build/ui/connect/ConnectWallet.js.map +0 -1
- package/build/ui/connect/LogoutPopup.d.ts +0 -10
- package/build/ui/connect/LogoutPopup.js +0 -8
- package/build/ui/connect/LogoutPopup.js.map +0 -1
- package/build/ui/connect/PrimaryWallet.d.ts +0 -6
- package/build/ui/connect/PrimaryWallet.js +0 -18
- package/build/ui/connect/PrimaryWallet.js.map +0 -1
- package/build/ui/connect/WCPopup.d.ts +0 -13
- package/build/ui/connect/WCPopup.js +0 -81
- package/build/ui/connect/WCPopup.js.map +0 -1
- package/build/ui/connect/WCRequest.d.ts +0 -9
- package/build/ui/connect/WCRequest.js +0 -13
- package/build/ui/connect/WCRequest.js.map +0 -1
- package/build/ui/connect/WalletPicker.d.ts +0 -11
- package/build/ui/connect/WalletPicker.js +0 -48
- package/build/ui/connect/WalletPicker.js.map +0 -1
- package/build/ui/icons/arrow-right.d.ts +0 -1
- package/build/ui/icons/arrow-right.js +0 -5
- package/build/ui/icons/arrow-right.js.map +0 -1
- package/build/ui/icons/close.d.ts +0 -1
- package/build/ui/icons/close.js +0 -5
- package/build/ui/icons/close.js.map +0 -1
- package/build/ui/icons/exchange.d.ts +0 -6
- package/build/ui/icons/exchange.js +0 -6
- package/build/ui/icons/exchange.js.map +0 -1
- package/build/ui/icons/logout.d.ts +0 -1
- package/build/ui/icons/logout.js +0 -3
- package/build/ui/icons/logout.js.map +0 -1
- package/build/ui/icons/pending.d.ts +0 -1
- package/build/ui/icons/pending.js +0 -5
- package/build/ui/icons/pending.js.map +0 -1
- package/build/ui/icons/qr.d.ts +0 -1
- package/build/ui/icons/qr.js +0 -5
- package/build/ui/icons/qr.js.map +0 -1
- package/build/ui/icons/search.d.ts +0 -1
- package/build/ui/icons/search.js +0 -5
- package/build/ui/icons/search.js.map +0 -1
- package/build/ui/icons/switch.d.ts +0 -1
- package/build/ui/icons/switch.js +0 -5
- package/build/ui/icons/switch.js.map +0 -1
- package/build/ui/icons/wallet.d.ts +0 -1
- package/build/ui/icons/wallet.js +0 -5
- package/build/ui/icons/wallet.js.map +0 -1
- package/build/ui/payment/Bridge.d.ts +0 -29
- package/build/ui/payment/Bridge.js +0 -373
- package/build/ui/payment/Bridge.js.map +0 -1
- package/build/ui/payment/DepositQR.d.ts +0 -9
- package/build/ui/payment/DepositQR.js +0 -56
- package/build/ui/payment/DepositQR.js.map +0 -1
- package/build/ui/payment/Payment.d.ts +0 -23
- package/build/ui/payment/Payment.js +0 -139
- package/build/ui/payment/Payment.js.map +0 -1
- package/build/ui/payment/Profile.d.ts +0 -8
- package/build/ui/payment/Profile.js +0 -110
- package/build/ui/payment/Profile.js.map +0 -1
- package/build/ui/payment/SelectRecipient.d.ts +0 -14
- package/build/ui/payment/SelectRecipient.js +0 -68
- package/build/ui/payment/SelectRecipient.js.map +0 -1
- package/build/ui/payment/SelectSender.d.ts +0 -13
- package/build/ui/payment/SelectSender.js +0 -23
- package/build/ui/payment/SelectSender.js.map +0 -1
- package/build/ui/payment/SelectToken.d.ts +0 -13
- package/build/ui/payment/SelectToken.js +0 -92
- package/build/ui/payment/SelectToken.js.map +0 -1
- package/build/ui/payment/Stepper.d.ts +0 -13
- package/build/ui/payment/Stepper.js +0 -22
- package/build/ui/payment/Stepper.js.map +0 -1
- package/build/ui/payment/TokenCard.d.ts +0 -25
- package/build/ui/payment/TokenCard.js +0 -63
- package/build/ui/payment/TokenCard.js.map +0 -1
- package/build/ui/router.d.ts +0 -51
- package/build/ui/router.js +0 -68
- package/build/ui/router.js.map +0 -1
- package/build/ui/styles.d.ts +0 -13
- package/build/ui/styles.js +0 -290
- package/build/ui/styles.js.map +0 -1
- package/src/core/telemetry.ts +0 -28
- package/src/tron/connector.ts +0 -89
- package/src/tron/index.ts +0 -7
- package/src/tron/wallet.ts +0 -146
- package/src/ui/Toast.tsx +0 -45
- package/src/ui/connect/PrimaryWallet.tsx +0 -65
- package/src/ui/payment/Stepper.tsx +0 -50
- /package/src/solana/{walletStandartList.ts → wallets.ts} +0 -0
package/src/core/Intents.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
|
+
import { ed25519 } from "@noble/curves/ed25519";
|
|
3
|
+
import { base58, base64, hex } from "@scure/base";
|
|
2
4
|
|
|
3
5
|
import type { HotConnector } from "../HotConnector";
|
|
4
6
|
import type { OmniWallet } from "../OmniWallet";
|
|
5
|
-
import {
|
|
7
|
+
import type { TransferIntent, MtWithdrawIntent, FtWithdrawIntent, TokenDiffIntent, AuthCallIntent } from "./types";
|
|
6
8
|
|
|
7
|
-
import type { Intent, Commitment, TokenDiffIntent, MtWithdrawIntent, FtWithdrawIntent, NftWithdrawIntent, TransferIntent } from "./types";
|
|
8
9
|
import { OmniToken } from "./chains";
|
|
9
10
|
import { tokens } from "./tokens";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import { openConnector, openConnectPrimaryWallet, openPayment, openToast } from "../ui/router";
|
|
13
|
-
import { formatter } from "./utils";
|
|
14
|
-
import { BridgeReview } from "../exchange";
|
|
11
|
+
import { rpc } from "./nearRpc";
|
|
15
12
|
|
|
16
13
|
export const TGAS = 1000000000000n;
|
|
17
14
|
|
|
@@ -22,22 +19,14 @@ export class Intents {
|
|
|
22
19
|
return new Intents();
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
unsignedCommitment?: {
|
|
31
|
-
intents: Intent[];
|
|
32
|
-
nonce?: Uint8Array;
|
|
33
|
-
deadline?: Date;
|
|
34
|
-
};
|
|
22
|
+
hashes: string[] = [];
|
|
23
|
+
intents: (TransferIntent | MtWithdrawIntent | FtWithdrawIntent | TokenDiffIntent | AuthCallIntent)[] = [];
|
|
24
|
+
nonce?: Uint8Array;
|
|
25
|
+
deadline?: Date;
|
|
26
|
+
signer?: OmniWallet | { ed25519PrivateKey: Uint8Array; omniAddress?: string };
|
|
35
27
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.unsignedCommitment.intents.push(intent);
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
28
|
+
commitments: Record<string, any>[] = [];
|
|
29
|
+
need = new Map<OmniToken, bigint>();
|
|
41
30
|
|
|
42
31
|
addNeed(token: OmniToken, amount: bigint) {
|
|
43
32
|
if (!this.need.has(token)) this.need.set(token, 0n);
|
|
@@ -47,7 +36,7 @@ export class Intents {
|
|
|
47
36
|
|
|
48
37
|
authCall(args: { contractId: string; msg: string; attachNear: bigint; tgas: number }) {
|
|
49
38
|
this.addNeed(OmniToken.NEAR, args.attachNear);
|
|
50
|
-
this.
|
|
39
|
+
this.intents.push({
|
|
51
40
|
min_gas: (BigInt(args.tgas) * TGAS).toString(),
|
|
52
41
|
attached_deposit: args.attachNear.toString(),
|
|
53
42
|
contract_id: args.contractId,
|
|
@@ -58,22 +47,6 @@ export class Intents {
|
|
|
58
47
|
return this;
|
|
59
48
|
}
|
|
60
49
|
|
|
61
|
-
/**
|
|
62
|
-
* Use this method to pay for a merchant's item created in pay.hot-labs.org
|
|
63
|
-
*/
|
|
64
|
-
merchantPayment({ merchantId, token, itemId, email, amount, memo }: { token: OmniToken; merchantId: string; itemId: string; amount: number | bigint; memo: string; email: string }) {
|
|
65
|
-
return this.transfer({
|
|
66
|
-
msg: JSON.stringify({ merchant_id: merchantId, item_id: itemId, memo: memo }),
|
|
67
|
-
recipient: "pay.fi.tg",
|
|
68
|
-
amount,
|
|
69
|
-
token,
|
|
70
|
-
}).depositAndExecute({
|
|
71
|
-
title: `Pay ${this.wibe3?.omni(token).readable(amount)} ${this.wibe3?.omni(token).symbol}`,
|
|
72
|
-
serverSideProcessing: true,
|
|
73
|
-
payload: { email },
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
50
|
transfer(args: { recipient: string; token: OmniToken; amount: number | bigint; memo?: string; msg?: string; tgas?: number }) {
|
|
78
51
|
const omniToken = tokens.get(args.token);
|
|
79
52
|
const amount = (typeof args.amount === "number" ? omniToken.int(args.amount) : args.amount).toString();
|
|
@@ -87,7 +60,7 @@ export class Intents {
|
|
|
87
60
|
};
|
|
88
61
|
|
|
89
62
|
this.addNeed(args.token, BigInt(amount));
|
|
90
|
-
this.
|
|
63
|
+
this.intents.push(intent);
|
|
91
64
|
return this;
|
|
92
65
|
}
|
|
93
66
|
|
|
@@ -109,11 +82,11 @@ export class Intents {
|
|
|
109
82
|
msg: args.msg,
|
|
110
83
|
};
|
|
111
84
|
|
|
112
|
-
this.
|
|
85
|
+
this.intents.push(intent);
|
|
113
86
|
return this;
|
|
114
87
|
}
|
|
115
88
|
|
|
116
|
-
tokenDiff(args: Record<
|
|
89
|
+
tokenDiff(args: Record<OmniToken, bigint | number>) {
|
|
117
90
|
const parse = (token: OmniToken, amount: bigint | number): [string, string] => {
|
|
118
91
|
if (typeof amount === "number") return [token.toString(), tokens.get(token).int(amount).toString()];
|
|
119
92
|
return [token.toString(), amount.toString()];
|
|
@@ -132,44 +105,45 @@ export class Intents {
|
|
|
132
105
|
}
|
|
133
106
|
}
|
|
134
107
|
|
|
135
|
-
this.
|
|
108
|
+
this.intents.push(intent);
|
|
136
109
|
return this;
|
|
137
110
|
}
|
|
138
111
|
|
|
139
|
-
addRawIntent(rawIntent:
|
|
112
|
+
addRawIntent(rawIntent: Record<string, any>) {
|
|
140
113
|
if (!rawIntent.intent) throw new Error("Intent must have 'intent' field");
|
|
141
114
|
const intentType = rawIntent.intent;
|
|
142
115
|
|
|
143
116
|
if (intentType === "token_diff") {
|
|
117
|
+
const diff = rawIntent.diff || rawIntent.token_diff;
|
|
118
|
+
if (!diff) throw new Error("token_diff intent must have 'diff' or 'token_diff' field");
|
|
119
|
+
|
|
144
120
|
const tokenDiffArgs: Record<OmniToken, bigint> = {} as Record<OmniToken, bigint>;
|
|
145
|
-
for (const [token, amountStr] of Object.entries(
|
|
121
|
+
for (const [token, amountStr] of Object.entries(diff)) {
|
|
146
122
|
tokenDiffArgs[token as OmniToken] = BigInt(amountStr as string);
|
|
147
123
|
}
|
|
148
124
|
return this.tokenDiff(tokenDiffArgs);
|
|
149
125
|
}
|
|
150
126
|
|
|
151
127
|
if (intentType === "transfer") {
|
|
128
|
+
if (!rawIntent.tokens || !rawIntent.receiver_id) {
|
|
129
|
+
throw new Error("transfer intent must have 'tokens' and 'receiver_id' fields");
|
|
130
|
+
}
|
|
131
|
+
|
|
152
132
|
const tokens: Record<OmniToken, bigint> = {} as Record<OmniToken, bigint>;
|
|
153
133
|
for (const [token, amount] of Object.entries(rawIntent.tokens)) {
|
|
154
134
|
tokens[token as OmniToken] = BigInt(amount as string);
|
|
155
135
|
}
|
|
156
|
-
|
|
157
136
|
return this.batchTransfer({
|
|
158
|
-
tgas: rawIntent.min_gas ? Number(BigInt(rawIntent.min_gas) / TGAS) : undefined,
|
|
159
137
|
recipient: rawIntent.receiver_id,
|
|
138
|
+
tokens,
|
|
160
139
|
memo: rawIntent.memo,
|
|
161
140
|
msg: rawIntent.msg,
|
|
162
|
-
|
|
141
|
+
tgas: rawIntent.min_gas ? Number(BigInt(rawIntent.min_gas) / TGAS) : undefined,
|
|
163
142
|
});
|
|
164
143
|
}
|
|
165
144
|
|
|
166
145
|
if (intentType === "mt_withdraw") {
|
|
167
|
-
|
|
168
|
-
const token = `nep245:${rawIntent.token}:${rawIntent.token_ids[i]}` as OmniToken;
|
|
169
|
-
this.addNeed(token, BigInt(rawIntent.amounts[i]));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
this.addIntent({
|
|
146
|
+
const intent: MtWithdrawIntent = {
|
|
173
147
|
intent: "mt_withdraw",
|
|
174
148
|
amounts: rawIntent.amounts,
|
|
175
149
|
receiver_id: rawIntent.receiver_id,
|
|
@@ -178,71 +152,58 @@ export class Intents {
|
|
|
178
152
|
memo: rawIntent.memo,
|
|
179
153
|
msg: rawIntent.msg,
|
|
180
154
|
min_gas: rawIntent.min_gas,
|
|
181
|
-
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
for (let i = 0; i < rawIntent.amounts.length; i++) {
|
|
158
|
+
const token = `nep245:${rawIntent.token}:${rawIntent.token_ids[i]}` as OmniToken;
|
|
159
|
+
this.addNeed(token, BigInt(rawIntent.amounts[i]));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this.intents.push(intent);
|
|
182
163
|
return this;
|
|
183
164
|
}
|
|
184
165
|
|
|
185
166
|
if (intentType === "ft_withdraw") {
|
|
167
|
+
if (!rawIntent.token || !rawIntent.receiver_id || !rawIntent.amount) {
|
|
168
|
+
throw new Error("ft_withdraw intent must have 'token', 'receiver_id', and 'amount' fields");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const token = `nep141:${rawIntent.token}` as OmniToken;
|
|
186
172
|
return this.withdraw({
|
|
187
|
-
token: `nep141:${rawIntent.token}`,
|
|
188
173
|
amount: BigInt(rawIntent.amount),
|
|
189
174
|
receiver: rawIntent.receiver_id,
|
|
190
175
|
memo: rawIntent.memo,
|
|
191
176
|
msg: rawIntent.msg,
|
|
177
|
+
token,
|
|
192
178
|
});
|
|
193
179
|
}
|
|
194
180
|
|
|
195
181
|
if (intentType === "auth_call") {
|
|
182
|
+
if (!rawIntent.contract_id || !rawIntent.msg || !rawIntent.attached_deposit || !rawIntent.min_gas) {
|
|
183
|
+
throw new Error("auth_call intent must have 'contract_id', 'msg', 'attached_deposit', and 'min_gas' fields");
|
|
184
|
+
}
|
|
185
|
+
|
|
196
186
|
return this.authCall({
|
|
197
|
-
attachNear: BigInt(rawIntent.attached_deposit),
|
|
198
|
-
tgas: Number(BigInt(rawIntent.min_gas) / TGAS),
|
|
199
187
|
contractId: rawIntent.contract_id,
|
|
200
188
|
msg: rawIntent.msg,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (intentType === "add_public_key") {
|
|
205
|
-
return this.addPublicKey(rawIntent.public_key);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (intentType === "remove_public_key") {
|
|
209
|
-
return this.removePublicKey(rawIntent.public_key);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (intentType === "nft_withdraw") {
|
|
213
|
-
return this.withdraw({
|
|
214
|
-
token: rawIntent.token_id,
|
|
215
|
-
receiver: rawIntent.receiver_id,
|
|
216
|
-
memo: rawIntent.memo,
|
|
217
|
-
msg: rawIntent.msg,
|
|
218
|
-
tgas: rawIntent.min_gas ? Number(BigInt(rawIntent.min_gas) / TGAS) : undefined,
|
|
219
|
-
amount: 1n,
|
|
189
|
+
attachNear: BigInt(rawIntent.attached_deposit),
|
|
190
|
+
tgas: Number(BigInt(rawIntent.min_gas) / TGAS),
|
|
220
191
|
});
|
|
221
192
|
}
|
|
222
193
|
|
|
223
194
|
throw new Error(`Unsupported intent type: ${intentType}`);
|
|
224
195
|
}
|
|
225
196
|
|
|
226
|
-
|
|
227
|
-
this.addIntent({ intent: "add_public_key", public_key: publicKey });
|
|
228
|
-
return this;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
removePublicKey(publicKey: string) {
|
|
232
|
-
this.addIntent({ intent: "remove_public_key", public_key: publicKey });
|
|
233
|
-
return this;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
withdraw(args: { token: string; amount: number | bigint; receiver: string; memo?: string; msg?: string; tgas?: number }) {
|
|
197
|
+
withdraw(args: { token: OmniToken; amount: number | bigint; receiver: string; memo?: string; msg?: string; tgas?: number }) {
|
|
237
198
|
const omniToken = tokens.get(args.token);
|
|
238
199
|
const amount = (typeof args.amount === "number" ? omniToken.int(args.amount) : args.amount).toString();
|
|
239
200
|
const [standart, ...tokenParts] = args.token.split(":");
|
|
240
|
-
this.addNeed(args.token
|
|
201
|
+
this.addNeed(args.token, BigInt(amount));
|
|
241
202
|
|
|
242
203
|
if (standart === "nep245") {
|
|
243
204
|
const mtContract = tokenParts[0];
|
|
244
205
|
const tokenId = tokenParts.slice(1).join(":");
|
|
245
|
-
|
|
206
|
+
const intent: MtWithdrawIntent = {
|
|
246
207
|
intent: "mt_withdraw",
|
|
247
208
|
amounts: [amount],
|
|
248
209
|
receiver_id: args.receiver,
|
|
@@ -251,31 +212,23 @@ export class Intents {
|
|
|
251
212
|
memo: args.memo,
|
|
252
213
|
msg: args.msg,
|
|
253
214
|
min_gas: args.tgas ? (BigInt(args.tgas) * TGAS).toString() : undefined,
|
|
254
|
-
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
this.intents.push(intent);
|
|
255
218
|
return this;
|
|
256
219
|
}
|
|
257
220
|
|
|
258
221
|
if (standart === "nep141") {
|
|
259
|
-
|
|
222
|
+
const intent: FtWithdrawIntent = {
|
|
260
223
|
intent: "ft_withdraw",
|
|
261
224
|
receiver_id: args.receiver,
|
|
262
225
|
token: tokenParts.join(":"),
|
|
263
226
|
amount: amount,
|
|
264
227
|
memo: args.memo,
|
|
265
228
|
msg: args.msg,
|
|
266
|
-
}
|
|
267
|
-
return this;
|
|
268
|
-
}
|
|
229
|
+
};
|
|
269
230
|
|
|
270
|
-
|
|
271
|
-
this.addIntent({
|
|
272
|
-
intent: "nft_withdraw",
|
|
273
|
-
receiver_id: args.receiver,
|
|
274
|
-
token_id: tokenParts.join(":"),
|
|
275
|
-
min_gas: args.tgas ? (BigInt(args.tgas) * TGAS).toString() : undefined,
|
|
276
|
-
memo: args.memo,
|
|
277
|
-
msg: args.msg,
|
|
278
|
-
} as NftWithdrawIntent);
|
|
231
|
+
this.intents.push(intent);
|
|
279
232
|
return this;
|
|
280
233
|
}
|
|
281
234
|
|
|
@@ -283,190 +236,164 @@ export class Intents {
|
|
|
283
236
|
}
|
|
284
237
|
|
|
285
238
|
attachHashes(hashes: string[]) {
|
|
286
|
-
this.
|
|
239
|
+
this.hashes.push(...hashes);
|
|
287
240
|
return this;
|
|
288
241
|
}
|
|
289
242
|
|
|
290
|
-
attachWallet(wallet
|
|
243
|
+
attachWallet(wallet: OmniWallet) {
|
|
291
244
|
this.signer = wallet;
|
|
292
245
|
return this;
|
|
293
246
|
}
|
|
294
247
|
|
|
295
248
|
attachDeadline(deadline: Date) {
|
|
296
|
-
|
|
297
|
-
this.unsignedCommitment.deadline = deadline;
|
|
249
|
+
this.deadline = deadline;
|
|
298
250
|
return this;
|
|
299
251
|
}
|
|
300
252
|
|
|
301
253
|
attachNonce(nonce: Uint8Array) {
|
|
302
|
-
|
|
303
|
-
this.unsignedCommitment.nonce = nonce;
|
|
254
|
+
this.nonce = nonce;
|
|
304
255
|
return this;
|
|
305
256
|
}
|
|
306
257
|
|
|
307
258
|
attachTimeout(seconds: number) {
|
|
308
|
-
|
|
309
|
-
this.unsignedCommitment.deadline = new Date(Date.now() + seconds * 1000);
|
|
259
|
+
this.deadline = new Date(Date.now() + seconds * 1000);
|
|
310
260
|
return this;
|
|
311
261
|
}
|
|
312
262
|
|
|
313
263
|
attachSeed(seed: string) {
|
|
314
|
-
|
|
315
|
-
this.unsignedCommitment.nonce = new Uint8Array(sha256(new TextEncoder().encode(seed))).slice(0, 32);
|
|
316
|
-
return this;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
attachCommitment(commitment: Commitment) {
|
|
320
|
-
this.commitments.push(commitment);
|
|
264
|
+
this.nonce = new Uint8Array(sha256(new TextEncoder().encode(seed))).slice(0, 32);
|
|
321
265
|
return this;
|
|
322
266
|
}
|
|
323
267
|
|
|
324
|
-
take(token:
|
|
268
|
+
take(token: OmniToken, amount: number | bigint) {
|
|
325
269
|
const intAmount = typeof amount === "number" ? tokens.get(token).int(amount) : amount;
|
|
326
270
|
|
|
327
|
-
|
|
328
|
-
const tokenDiff = this.
|
|
271
|
+
this.addNeed(token, intAmount);
|
|
272
|
+
const tokenDiff = this.intents.find((intent) => intent.intent === "token_diff");
|
|
329
273
|
|
|
330
274
|
if (tokenDiff) tokenDiff.diff[token.toString()] = intAmount.toString();
|
|
331
|
-
else this.
|
|
275
|
+
else this.intents.push({ intent: "token_diff", diff: { [token.toString()]: intAmount.toString() } });
|
|
332
276
|
return this;
|
|
333
277
|
}
|
|
334
278
|
|
|
335
|
-
give(token:
|
|
279
|
+
give(token: OmniToken, amount: number | bigint) {
|
|
336
280
|
const intAmount = typeof amount === "number" ? tokens.get(token).int(amount) : amount;
|
|
337
281
|
|
|
338
|
-
this.addNeed(token
|
|
339
|
-
const tokenDiff = this.
|
|
282
|
+
this.addNeed(token, -intAmount);
|
|
283
|
+
const tokenDiff = this.intents.find((intent) => intent.intent === "token_diff");
|
|
340
284
|
|
|
341
285
|
if (tokenDiff) tokenDiff.diff[token.toString()] = (-intAmount).toString();
|
|
342
|
-
else this.
|
|
286
|
+
else this.intents.push({ intent: "token_diff", diff: { [token.toString()]: (-intAmount).toString() } });
|
|
343
287
|
return this;
|
|
344
288
|
}
|
|
345
289
|
|
|
346
|
-
async
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (!signer.omniAddress) throw new Error("No omni address");
|
|
350
|
-
|
|
351
|
-
const commitments: Commitment[] = [];
|
|
352
|
-
for (const intent of this.unsignedCommitment?.intents || []) {
|
|
353
|
-
commitments.push(
|
|
354
|
-
await signer.signIntents([intent], {
|
|
355
|
-
deadline: this.unsignedCommitment?.deadline ? +this.unsignedCommitment.deadline : undefined,
|
|
356
|
-
nonce: this.unsignedCommitment?.nonce,
|
|
357
|
-
})
|
|
358
|
-
);
|
|
290
|
+
async signRaw({ ed25519PrivateKey, intentsAddress, checkTokens }: { ed25519PrivateKey: Uint8Array; intentsAddress?: string; checkTokens?: boolean }) {
|
|
291
|
+
if (checkTokens) {
|
|
292
|
+
await this.checkRequiredTokens();
|
|
359
293
|
}
|
|
360
294
|
|
|
361
|
-
|
|
362
|
-
|
|
295
|
+
const publicKey = ed25519.getPublicKey(ed25519PrivateKey);
|
|
296
|
+
const nonce = new Uint8Array(this.nonce || window.crypto.getRandomValues(new Uint8Array(32)));
|
|
363
297
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
nonce: this.unsignedCommitment?.nonce,
|
|
298
|
+
const message = JSON.stringify({
|
|
299
|
+
deadline: this.deadline ? new Date(this.deadline).toISOString() : "2100-01-01T00:00:00.000Z",
|
|
300
|
+
nonce: base64.encode(nonce),
|
|
301
|
+
verifying_contract: "intents.near",
|
|
302
|
+
signer_id: intentsAddress || hex.encode(publicKey).toLowerCase(),
|
|
303
|
+
intents: this.intents,
|
|
371
304
|
});
|
|
372
305
|
|
|
373
|
-
|
|
306
|
+
return {
|
|
307
|
+
signature: `ed25519:${base58.encode(ed25519.sign(message, ed25519PrivateKey))}`,
|
|
308
|
+
public_key: `ed25519:${base58.encode(publicKey)}`,
|
|
309
|
+
standard: "raw_ed25519",
|
|
310
|
+
payload: message,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async attachCommitment(commitment: Record<string, any>) {
|
|
374
315
|
this.commitments.push(commitment);
|
|
375
316
|
return this;
|
|
376
317
|
}
|
|
377
318
|
|
|
378
|
-
async
|
|
379
|
-
|
|
380
|
-
return
|
|
319
|
+
async attachSigner(signer: OmniWallet | { ed25519PrivateKey: Uint8Array; omniAddress?: string }) {
|
|
320
|
+
this.signer = signer;
|
|
321
|
+
return this;
|
|
381
322
|
}
|
|
382
323
|
|
|
383
|
-
async
|
|
384
|
-
if (
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
this.signer = this.wibe3.priorityWallet;
|
|
389
|
-
return this.signer;
|
|
324
|
+
async checkRequiredTokens() {
|
|
325
|
+
if (this.wibe3 == null) return;
|
|
326
|
+
for (const [token, needAmount] of this.need.entries()) {
|
|
327
|
+
if (needAmount <= 0n) continue;
|
|
328
|
+
await this.wibe3.requestToken(token, needAmount);
|
|
390
329
|
}
|
|
330
|
+
}
|
|
391
331
|
|
|
392
|
-
|
|
393
|
-
|
|
332
|
+
async sign(params = { checkTokens: true }) {
|
|
333
|
+
const signer = this.signer;
|
|
334
|
+
if (!signer) throw new Error("No signer attached");
|
|
335
|
+
if (!signer.omniAddress) throw new Error("No omni address");
|
|
394
336
|
|
|
395
|
-
if (
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
337
|
+
if ("ed25519PrivateKey" in signer) {
|
|
338
|
+
return await this.signRaw({
|
|
339
|
+
ed25519PrivateKey: signer.ed25519PrivateKey,
|
|
340
|
+
intentsAddress: signer.omniAddress,
|
|
341
|
+
checkTokens: params.checkTokens,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
399
344
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
// TODO: Handle multiple payables
|
|
405
|
-
const payableToken = tokens.get(Array.from(this.need.keys())[0]);
|
|
406
|
-
const payableAmount = this.need.get(payableToken.omniAddress as OmniToken) || 0n;
|
|
407
|
-
const balance = await this.wibe3.fetchToken(payableToken!, this.signer);
|
|
408
|
-
const prepaidAmount = formatter.bigIntMin(payableAmount, balance);
|
|
409
|
-
|
|
410
|
-
return await openPayment(this.wibe3, {
|
|
411
|
-
onConfirm,
|
|
412
|
-
needAmount: payableAmount - prepaidAmount,
|
|
413
|
-
allowedTokens,
|
|
414
|
-
prepaidAmount,
|
|
415
|
-
payableToken,
|
|
416
|
-
intents: this,
|
|
417
|
-
title,
|
|
418
|
-
});
|
|
419
|
-
}
|
|
345
|
+
if (params.checkTokens) {
|
|
346
|
+
await this.checkRequiredTokens();
|
|
347
|
+
}
|
|
420
348
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
await this.openSignFlow({
|
|
426
|
-
title,
|
|
427
|
-
allowedTokens,
|
|
428
|
-
onConfirm: async ({ depositQoute, processing }: { depositQoute?: BridgeReview; processing?: () => Promise<BridgeReview> }) => {
|
|
429
|
-
if (!serverSideProcessing) return;
|
|
430
|
-
|
|
431
|
-
console.log("Processing 1");
|
|
432
|
-
let depositAddress: string | undefined;
|
|
433
|
-
if (depositQoute?.qoute === "deposit") await processing?.();
|
|
434
|
-
else if (depositQoute?.qoute === "withdraw") await processing?.();
|
|
435
|
-
else depositAddress = depositQoute?.qoute?.depositAddress;
|
|
436
|
-
|
|
437
|
-
console.log("yieldIntentCall", depositAddress, this.commitments[0], payload);
|
|
438
|
-
await api.yieldIntentCall({
|
|
439
|
-
depositAddress: depositAddress,
|
|
440
|
-
commitment: this.commitments[0],
|
|
441
|
-
payload: payload || {},
|
|
442
|
-
});
|
|
443
|
-
},
|
|
349
|
+
return await signer.signIntents(this.intents, {
|
|
350
|
+
deadline: this.deadline ? +this.deadline : undefined,
|
|
351
|
+
nonce: this.nonce,
|
|
444
352
|
});
|
|
445
|
-
|
|
446
|
-
if (serverSideProcessing) return;
|
|
447
|
-
const close = openToast(message || "Executing payment");
|
|
448
|
-
await this.execute().finally(() => close());
|
|
449
353
|
}
|
|
450
354
|
|
|
451
|
-
async
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
this.signedHashes = [];
|
|
355
|
+
async simulate(params = { checkTokens: true }) {
|
|
356
|
+
const signed = await this.sign(params);
|
|
357
|
+
return await Intents.simulateIntents([signed]);
|
|
358
|
+
}
|
|
456
359
|
|
|
457
|
-
|
|
360
|
+
async execute(params = { checkTokens: true }) {
|
|
361
|
+
const signed = await this.sign(params);
|
|
362
|
+
const hash = await Intents.publishSignedIntents([...this.commitments, signed], this.hashes);
|
|
458
363
|
await rpc.waitTransactionResult(hash, "intents.near");
|
|
459
364
|
return hash;
|
|
460
365
|
}
|
|
461
366
|
|
|
462
|
-
static async
|
|
463
|
-
const
|
|
367
|
+
static async publishSignedIntents(signed: Record<string, any>[], hashes: string[] = []): Promise<string> {
|
|
368
|
+
const res = await fetch("https://api0.herewallet.app/api/v1/evm/intent-solver", {
|
|
369
|
+
headers: { "Content-Type": "application/json" },
|
|
370
|
+
method: "POST",
|
|
371
|
+
body: JSON.stringify({
|
|
372
|
+
params: [{ signed_datas: signed, quote_hashes: hashes }],
|
|
373
|
+
method: "publish_intents",
|
|
374
|
+
id: "dontcare",
|
|
375
|
+
jsonrpc: "2.0",
|
|
376
|
+
}),
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
const { result } = await res.json();
|
|
464
380
|
if (result.status === "FAILED") throw result.reason;
|
|
465
381
|
const intentResult = result.intent_hashes[0];
|
|
466
382
|
|
|
467
383
|
const getStatus = async () => {
|
|
468
|
-
const
|
|
469
|
-
|
|
384
|
+
const statusRes = await fetch("https://api0.herewallet.app/api/v1/evm/intent-solver", {
|
|
385
|
+
headers: { "Content-Type": "application/json" },
|
|
386
|
+
method: "POST",
|
|
387
|
+
body: JSON.stringify({
|
|
388
|
+
params: [{ intent_hash: intentResult }],
|
|
389
|
+
method: "get_status",
|
|
390
|
+
id: "dontcare",
|
|
391
|
+
jsonrpc: "2.0",
|
|
392
|
+
}),
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
const { result } = await statusRes.json();
|
|
396
|
+
return result;
|
|
470
397
|
};
|
|
471
398
|
|
|
472
399
|
const fetchResult = async () => {
|
|
@@ -490,7 +417,7 @@ export class Intents {
|
|
|
490
417
|
});
|
|
491
418
|
}
|
|
492
419
|
|
|
493
|
-
static async simulateIntents(signed:
|
|
420
|
+
static async simulateIntents(signed: Record<string, any>[]) {
|
|
494
421
|
return await rpc.viewMethod({
|
|
495
422
|
args: { signed: signed },
|
|
496
423
|
methodName: "simulate_intents",
|
package/src/core/api.ts
CHANGED
|
@@ -8,16 +8,6 @@ export class ApiError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export interface PaymentStatus {
|
|
12
|
-
payment_id: string;
|
|
13
|
-
timestamp: number;
|
|
14
|
-
amount: string;
|
|
15
|
-
token_id: string;
|
|
16
|
-
sender_id: string;
|
|
17
|
-
near_trx: string;
|
|
18
|
-
status: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
11
|
export interface TokenType {
|
|
22
12
|
icon: string;
|
|
23
13
|
symbol: string;
|
|
@@ -79,29 +69,9 @@ export class Api {
|
|
|
79
69
|
return result.balances?.[chain] || [];
|
|
80
70
|
}
|
|
81
71
|
|
|
82
|
-
async yieldIntentCall(args: { commitment: Commitment; depositAddress?: string; payload?: Record<string, any> }) {
|
|
83
|
-
return await this.request(`/api/v1/wibe3/yield_intent_call`, {
|
|
84
|
-
method: "POST",
|
|
85
|
-
body: JSON.stringify({
|
|
86
|
-
commitment: args.commitment,
|
|
87
|
-
deposit_address: args.depositAddress,
|
|
88
|
-
...args.payload,
|
|
89
|
-
}),
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async paymentStatus(memo: string): Promise<PaymentStatus> {
|
|
94
|
-
const result = await this.request(`/partners/processed_payments?memo=${memo}`, { method: "GET" });
|
|
95
|
-
return result.payments[0];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async getPayments(merchantId: string): Promise<PaymentStatus[]> {
|
|
99
|
-
const result = await this.request(`/partners/processed_payments?merchant_id=${merchantId}`, { method: "GET" });
|
|
100
|
-
return result.payments;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
72
|
async publishIntents(signed: Record<string, any>[], hashes: string[]) {
|
|
104
|
-
|
|
73
|
+
return await this.request(`/api/v1/wibe3/solver-bus`, {
|
|
74
|
+
headers: { "Content-Type": "application/json" },
|
|
105
75
|
method: "POST",
|
|
106
76
|
body: JSON.stringify({
|
|
107
77
|
params: [{ signed_datas: signed, quote_hashes: hashes }],
|
|
@@ -110,19 +80,11 @@ export class Api {
|
|
|
110
80
|
jsonrpc: "2.0",
|
|
111
81
|
}),
|
|
112
82
|
});
|
|
113
|
-
|
|
114
|
-
return result.result;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async publishTelemetry(events: { event: string; value_str?: string; value_float?: number; ts: number }[], accountId: string) {
|
|
118
|
-
await this.request(`/api/v1/wibe3/telemetry/event`, {
|
|
119
|
-
body: JSON.stringify({ events, account_id: accountId }),
|
|
120
|
-
method: "POST",
|
|
121
|
-
});
|
|
122
83
|
}
|
|
123
84
|
|
|
124
85
|
async getIntentsStatus(intentHash: string) {
|
|
125
|
-
|
|
86
|
+
return await this.request(`/api/v1/wibe3/solver-bus`, {
|
|
87
|
+
headers: { "Content-Type": "application/json" },
|
|
126
88
|
method: "POST",
|
|
127
89
|
body: JSON.stringify({
|
|
128
90
|
params: [{ intent_hash: intentHash }],
|
|
@@ -131,8 +93,6 @@ export class Api {
|
|
|
131
93
|
jsonrpc: "2.0",
|
|
132
94
|
}),
|
|
133
95
|
});
|
|
134
|
-
|
|
135
|
-
return result.result;
|
|
136
96
|
}
|
|
137
97
|
}
|
|
138
98
|
|
package/src/core/bridge.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { CosmosConfig, HotBridge, ReviewFee } from "@hot-labs/omni-sdk";
|
|
2
2
|
import { chains, Network, WalletType } from "./chains";
|
|
3
3
|
import { Intents } from "./Intents";
|
|
4
|
-
import { Commitment } from "./types";
|
|
5
4
|
|
|
6
5
|
export { ReviewFee, HotBridge };
|
|
7
6
|
|
|
8
7
|
export const createHotBridge = () => {
|
|
9
8
|
return new HotBridge({
|
|
10
|
-
publishIntents: async (signed:
|
|
11
|
-
const hash = await Intents.
|
|
9
|
+
publishIntents: async (signed: Record<string, any>[], hashes: string[] = []) => {
|
|
10
|
+
const hash = await Intents.publishSignedIntents(signed, hashes);
|
|
12
11
|
return { sender: "intents.near", hash };
|
|
13
12
|
},
|
|
14
13
|
|