@hot-labs/kit 1.0.33
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/.eslintrc.cjs +11 -0
- package/.github/workflows/deploy-example.yml +55 -0
- package/.github/workflows/release.yml +74 -0
- package/.prettierrc +4 -0
- package/.prototools +2 -0
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +1 -0
- package/README.md +67 -0
- package/build/GoogleConnector.d.ts +20 -0
- package/build/GoogleConnector.js +76 -0
- package/build/GoogleConnector.js.map +1 -0
- package/build/HotConnector.d.ts +91 -0
- package/build/HotConnector.js +285 -0
- package/build/HotConnector.js.map +1 -0
- package/build/OmniConnector.d.ts +95 -0
- package/build/OmniConnector.js +123 -0
- package/build/OmniConnector.js.map +1 -0
- package/build/OmniWallet.d.ts +57 -0
- package/build/OmniWallet.js +56 -0
- package/build/OmniWallet.js.map +1 -0
- package/build/cosmos/connector.d.ts +53 -0
- package/build/cosmos/connector.js +207 -0
- package/build/cosmos/connector.js.map +1 -0
- package/build/cosmos/wallet.d.ts +28 -0
- package/build/cosmos/wallet.js +59 -0
- package/build/cosmos/wallet.js.map +1 -0
- package/build/events.d.ts +42 -0
- package/build/events.js +64 -0
- package/build/events.js.map +1 -0
- package/build/evm/abi.d.ts +17 -0
- package/build/evm/abi.js +38 -0
- package/build/evm/abi.js.map +1 -0
- package/build/evm/connector.d.ts +35 -0
- package/build/evm/connector.js +124 -0
- package/build/evm/connector.js.map +1 -0
- package/build/evm/wallet.d.ts +47 -0
- package/build/evm/wallet.js +136 -0
- package/build/evm/wallet.js.map +1 -0
- package/build/exchange.d.ts +63 -0
- package/build/exchange.js +384 -0
- package/build/exchange.js.map +1 -0
- package/build/hot-wallet/evm.d.ts +1 -0
- package/build/hot-wallet/evm.js +33 -0
- package/build/hot-wallet/evm.js.map +1 -0
- package/build/hot-wallet/hot.d.ts +3 -0
- package/build/hot-wallet/hot.js +40 -0
- package/build/hot-wallet/hot.js.map +1 -0
- package/build/hot-wallet/index.d.ts +4 -0
- package/build/hot-wallet/index.js +5 -0
- package/build/hot-wallet/index.js.map +1 -0
- package/build/hot-wallet/solana/account.d.ts +11 -0
- package/build/hot-wallet/solana/account.js +42 -0
- package/build/hot-wallet/solana/account.js.map +1 -0
- package/build/hot-wallet/solana/index.d.ts +1 -0
- package/build/hot-wallet/solana/index.js +85 -0
- package/build/hot-wallet/solana/index.js.map +1 -0
- package/build/hot-wallet/solana/register.d.ts +2 -0
- package/build/hot-wallet/solana/register.js +41 -0
- package/build/hot-wallet/solana/register.js.map +1 -0
- package/build/hot-wallet/solana/solana-wallet.d.ts +34 -0
- package/build/hot-wallet/solana/solana-wallet.js +223 -0
- package/build/hot-wallet/solana/solana-wallet.js.map +1 -0
- package/build/hot-wallet/solana/utils.d.ts +32 -0
- package/build/hot-wallet/solana/utils.js +36 -0
- package/build/hot-wallet/solana/utils.js.map +1 -0
- package/build/hot-wallet/stellar.d.ts +38 -0
- package/build/hot-wallet/stellar.js +32 -0
- package/build/hot-wallet/stellar.js.map +1 -0
- package/build/hot-wallet/ton.d.ts +1 -0
- package/build/hot-wallet/ton.js +49 -0
- package/build/hot-wallet/ton.js.map +1 -0
- package/build/hot-wallet/wallet.d.ts +1 -0
- package/build/hot-wallet/wallet.js +40 -0
- package/build/hot-wallet/wallet.js.map +1 -0
- package/build/index.d.ts +24 -0
- package/build/index.js +25 -0
- package/build/index.js.map +1 -0
- package/build/near/connector.d.ts +28 -0
- package/build/near/connector.js +56 -0
- package/build/near/connector.js.map +1 -0
- package/build/near/wallet.d.ts +62 -0
- package/build/near/wallet.js +233 -0
- package/build/near/wallet.js.map +1 -0
- package/build/omni/Intents.d.ts +93 -0
- package/build/omni/Intents.js +395 -0
- package/build/omni/Intents.js.map +1 -0
- package/build/omni/bridge.d.ts +3 -0
- package/build/omni/bridge.js +34 -0
- package/build/omni/bridge.js.map +1 -0
- package/build/omni/config.d.ts +99 -0
- package/build/omni/config.js +126 -0
- package/build/omni/config.js.map +1 -0
- package/build/omni/defaultTokens.d.ts +17 -0
- package/build/omni/defaultTokens.js +1079 -0
- package/build/omni/defaultTokens.js.map +1 -0
- package/build/omni/index.d.ts +8 -0
- package/build/omni/index.js +9 -0
- package/build/omni/index.js.map +1 -0
- package/build/omni/nearRpc.d.ts +24 -0
- package/build/omni/nearRpc.js +167 -0
- package/build/omni/nearRpc.js.map +1 -0
- package/build/omni/recipient.d.ts +10 -0
- package/build/omni/recipient.js +40 -0
- package/build/omni/recipient.js.map +1 -0
- package/build/omni/token.d.ts +36 -0
- package/build/omni/token.js +136 -0
- package/build/omni/token.js.map +1 -0
- package/build/omni/tokens.d.ts +14 -0
- package/build/omni/tokens.js +57 -0
- package/build/omni/tokens.js.map +1 -0
- package/build/omni/types.d.ts +41 -0
- package/build/omni/types.js +2 -0
- package/build/omni/types.js.map +1 -0
- package/build/omni/utils.d.ts +24 -0
- package/build/omni/utils.js +150 -0
- package/build/omni/utils.js.map +1 -0
- package/build/settings.d.ts +5 -0
- package/build/settings.js +6 -0
- package/build/settings.js.map +1 -0
- package/build/solana/connector.d.ts +31 -0
- package/build/solana/connector.js +138 -0
- package/build/solana/connector.js.map +1 -0
- package/build/solana/protocol.d.ts +25 -0
- package/build/solana/protocol.js +56 -0
- package/build/solana/protocol.js.map +1 -0
- package/build/solana/wallet.d.ts +47 -0
- package/build/solana/wallet.js +188 -0
- package/build/solana/wallet.js.map +1 -0
- package/build/solana/wallets.d.ts +102 -0
- package/build/solana/wallets.js +150 -0
- package/build/solana/wallets.js.map +1 -0
- package/build/stellar/connector.d.ts +25 -0
- package/build/stellar/connector.js +56 -0
- package/build/stellar/connector.js.map +1 -0
- package/build/stellar/wallet.d.ts +70 -0
- package/build/stellar/wallet.js +225 -0
- package/build/stellar/wallet.js.map +1 -0
- package/build/storage.d.ts +10 -0
- package/build/storage.js +12 -0
- package/build/storage.js.map +1 -0
- package/build/ton/connector.d.ts +25 -0
- package/build/ton/connector.js +119 -0
- package/build/ton/connector.js.map +1 -0
- package/build/ton/utils.d.ts +45 -0
- package/build/ton/utils.js +64 -0
- package/build/ton/utils.js.map +1 -0
- package/build/ton/wallet.d.ts +70 -0
- package/build/ton/wallet.js +154 -0
- package/build/ton/wallet.js.map +1 -0
- package/build/ui/Popup.d.ts +10 -0
- package/build/ui/Popup.js +38 -0
- package/build/ui/Popup.js.map +1 -0
- package/build/ui/connect/AuthPopup.d.ts +2 -0
- package/build/ui/connect/AuthPopup.js +48 -0
- package/build/ui/connect/AuthPopup.js.map +1 -0
- package/build/ui/connect/ConnectWallet.d.ts +9 -0
- package/build/ui/connect/ConnectWallet.js +22 -0
- package/build/ui/connect/ConnectWallet.js.map +1 -0
- package/build/ui/connect/LogoutPopup.d.ts +10 -0
- package/build/ui/connect/LogoutPopup.js +8 -0
- package/build/ui/connect/LogoutPopup.js.map +1 -0
- package/build/ui/connect/WCPopup.d.ts +13 -0
- package/build/ui/connect/WCPopup.js +81 -0
- package/build/ui/connect/WCPopup.js.map +1 -0
- package/build/ui/connect/WCRequest.d.ts +9 -0
- package/build/ui/connect/WCRequest.js +13 -0
- package/build/ui/connect/WCRequest.js.map +1 -0
- package/build/ui/connect/WalletPicker.d.ts +11 -0
- package/build/ui/connect/WalletPicker.js +48 -0
- package/build/ui/connect/WalletPicker.js.map +1 -0
- package/build/ui/icons/arrow-right.d.ts +1 -0
- package/build/ui/icons/arrow-right.js +5 -0
- package/build/ui/icons/arrow-right.js.map +1 -0
- package/build/ui/icons/exchange.d.ts +6 -0
- package/build/ui/icons/exchange.js +6 -0
- package/build/ui/icons/exchange.js.map +1 -0
- package/build/ui/icons/logout.d.ts +1 -0
- package/build/ui/icons/logout.js +3 -0
- package/build/ui/icons/logout.js.map +1 -0
- package/build/ui/icons/pending.d.ts +1 -0
- package/build/ui/icons/pending.js +5 -0
- package/build/ui/icons/pending.js.map +1 -0
- package/build/ui/icons/qr.d.ts +1 -0
- package/build/ui/icons/qr.js +5 -0
- package/build/ui/icons/qr.js.map +1 -0
- package/build/ui/icons/search.d.ts +1 -0
- package/build/ui/icons/search.js +5 -0
- package/build/ui/icons/search.js.map +1 -0
- package/build/ui/icons/switch.d.ts +1 -0
- package/build/ui/icons/switch.js +5 -0
- package/build/ui/icons/switch.js.map +1 -0
- package/build/ui/icons/wallet.d.ts +1 -0
- package/build/ui/icons/wallet.js +5 -0
- package/build/ui/icons/wallet.js.map +1 -0
- package/build/ui/payment/Bridge.d.ts +27 -0
- package/build/ui/payment/Bridge.js +340 -0
- package/build/ui/payment/Bridge.js.map +1 -0
- package/build/ui/payment/DepositQR.d.ts +9 -0
- package/build/ui/payment/DepositQR.js +56 -0
- package/build/ui/payment/DepositQR.js.map +1 -0
- package/build/ui/payment/Payment.d.ts +16 -0
- package/build/ui/payment/Payment.js +50 -0
- package/build/ui/payment/Payment.js.map +1 -0
- package/build/ui/payment/Profile.d.ts +7 -0
- package/build/ui/payment/Profile.js +88 -0
- package/build/ui/payment/Profile.js.map +1 -0
- package/build/ui/payment/SelectRecipient.d.ts +14 -0
- package/build/ui/payment/SelectRecipient.js +68 -0
- package/build/ui/payment/SelectRecipient.js.map +1 -0
- package/build/ui/payment/SelectSender.d.ts +13 -0
- package/build/ui/payment/SelectSender.js +23 -0
- package/build/ui/payment/SelectSender.js.map +1 -0
- package/build/ui/payment/SelectToken.d.ts +13 -0
- package/build/ui/payment/SelectToken.js +92 -0
- package/build/ui/payment/SelectToken.js.map +1 -0
- package/build/ui/payment/TokenCard.d.ts +23 -0
- package/build/ui/payment/TokenCard.js +50 -0
- package/build/ui/payment/TokenCard.js.map +1 -0
- package/build/ui/router.d.ts +37 -0
- package/build/ui/router.js +56 -0
- package/build/ui/router.js.map +1 -0
- package/build/ui/styles.d.ts +11 -0
- package/build/ui/styles.js +273 -0
- package/build/ui/styles.js.map +1 -0
- package/package.json +60 -0
- package/skill.md +989 -0
- package/src/GoogleConnector.ts +102 -0
- package/src/HotConnector.ts +344 -0
- package/src/OmniConnector.ts +161 -0
- package/src/OmniWallet.ts +94 -0
- package/src/cosmos/connector.ts +242 -0
- package/src/cosmos/wallet.ts +77 -0
- package/src/events.ts +66 -0
- package/src/evm/abi.ts +39 -0
- package/src/evm/connector.ts +139 -0
- package/src/evm/wallet.ts +156 -0
- package/src/exchange.ts +426 -0
- package/src/hot-wallet/evm.ts +38 -0
- package/src/hot-wallet/hot.ts +39 -0
- package/src/hot-wallet/index.ts +4 -0
- package/src/hot-wallet/solana/account.ts +52 -0
- package/src/hot-wallet/solana/index.ts +98 -0
- package/src/hot-wallet/solana/register.ts +48 -0
- package/src/hot-wallet/solana/solana-wallet.ts +280 -0
- package/src/hot-wallet/solana/utils.ts +56 -0
- package/src/hot-wallet/stellar.ts +39 -0
- package/src/hot-wallet/ton.ts +56 -0
- package/src/hot-wallet/wallet.ts +44 -0
- package/src/index.ts +30 -0
- package/src/near/connector.ts +71 -0
- package/src/near/wallet.ts +255 -0
- package/src/omni/Intents.ts +454 -0
- package/src/omni/bridge.ts +38 -0
- package/src/omni/config.ts +130 -0
- package/src/omni/defaultTokens.ts +1078 -0
- package/src/omni/index.ts +8 -0
- package/src/omni/nearRpc.ts +187 -0
- package/src/omni/recipient.ts +41 -0
- package/src/omni/token.ts +125 -0
- package/src/omni/tokens.ts +68 -0
- package/src/omni/types.ts +46 -0
- package/src/omni/utils.ts +163 -0
- package/src/settings.ts +5 -0
- package/src/solana/connector.ts +151 -0
- package/src/solana/protocol.ts +66 -0
- package/src/solana/wallet.ts +230 -0
- package/src/solana/wallets.ts +243 -0
- package/src/stellar/connector.ts +69 -0
- package/src/stellar/wallet.ts +267 -0
- package/src/storage.ts +19 -0
- package/src/ton/connector.ts +138 -0
- package/src/ton/utils.ts +73 -0
- package/src/ton/wallet.ts +178 -0
- package/src/ui/Popup.tsx +62 -0
- package/src/ui/connect/AuthPopup.tsx +78 -0
- package/src/ui/connect/ConnectWallet.tsx +63 -0
- package/src/ui/connect/LogoutPopup.tsx +20 -0
- package/src/ui/connect/WCPopup.tsx +122 -0
- package/src/ui/connect/WCRequest.tsx +28 -0
- package/src/ui/connect/WalletPicker.tsx +92 -0
- package/src/ui/icons/arrow-right.tsx +8 -0
- package/src/ui/icons/exchange.tsx +17 -0
- package/src/ui/icons/logout.tsx +18 -0
- package/src/ui/icons/pending.tsx +18 -0
- package/src/ui/icons/qr.tsx +12 -0
- package/src/ui/icons/search.tsx +18 -0
- package/src/ui/icons/switch.tsx +10 -0
- package/src/ui/icons/wallet.tsx +18 -0
- package/src/ui/payment/Bridge.tsx +582 -0
- package/src/ui/payment/DepositQR.tsx +88 -0
- package/src/ui/payment/Payment.tsx +78 -0
- package/src/ui/payment/Profile.tsx +140 -0
- package/src/ui/payment/SelectRecipient.tsx +111 -0
- package/src/ui/payment/SelectSender.tsx +60 -0
- package/src/ui/payment/SelectToken.tsx +134 -0
- package/src/ui/payment/TokenCard.tsx +83 -0
- package/src/ui/router.tsx +92 -0
- package/src/ui/styles.ts +284 -0
- package/tsconfig.json +22 -0
- package/vite.config.ts +17 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GlobalSettings } from "../settings";
|
|
2
|
+
import { uuid4 } from "./hot";
|
|
3
|
+
export const requestWebWallet = (chain, address) => (method, request) => {
|
|
4
|
+
const width = 480;
|
|
5
|
+
const height = 640;
|
|
6
|
+
const wallet = GlobalSettings.webWallet;
|
|
7
|
+
const x = (window.screen.width - width) / 2;
|
|
8
|
+
const y = (window.screen.height - height) / 2;
|
|
9
|
+
const popup = window.open(`${wallet}`, "_blank", `popup=1,width=${width},height=${height},top=${y},left=${x}`);
|
|
10
|
+
return new Promise(async (resolve, reject) => {
|
|
11
|
+
const interval = setInterval(() => {
|
|
12
|
+
if (!popup?.closed)
|
|
13
|
+
return;
|
|
14
|
+
clearInterval(interval);
|
|
15
|
+
reject(new Error("User rejected"));
|
|
16
|
+
}, 100);
|
|
17
|
+
const id = uuid4();
|
|
18
|
+
const handler = (event) => {
|
|
19
|
+
if (event.origin !== wallet)
|
|
20
|
+
return;
|
|
21
|
+
if (event.data === "hot:ready") {
|
|
22
|
+
popup?.postMessage({ chain, address, method, request, id }, "*");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (event.data.id !== id)
|
|
26
|
+
return;
|
|
27
|
+
if (event.data.success === false) {
|
|
28
|
+
clearInterval(interval);
|
|
29
|
+
reject(new Error(event.data.payload));
|
|
30
|
+
window.removeEventListener("message", handler);
|
|
31
|
+
}
|
|
32
|
+
window.removeEventListener("message", handler);
|
|
33
|
+
resolve(event.data.payload);
|
|
34
|
+
clearInterval(interval);
|
|
35
|
+
popup?.close();
|
|
36
|
+
};
|
|
37
|
+
window.addEventListener("message", handler);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/hot-wallet/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAE,OAAgB,EAAE,EAAE,CAAC,CAAC,MAAc,EAAE,OAAY,EAAE,EAAE;IACrG,MAAM,KAAK,GAAG,GAAG,CAAC;IAClB,MAAM,MAAM,GAAG,GAAG,CAAC;IACnB,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC;IACxC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAE9C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,iBAAiB,KAAK,WAAW,MAAM,QAAQ,CAA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C;QAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { Network, OmniToken, WalletType } from "./omni/config";
|
|
2
|
+
export { formatter } from "./omni/utils";
|
|
3
|
+
export { EventEmitter } from "./events";
|
|
4
|
+
export { OmniWallet } from "./OmniWallet";
|
|
5
|
+
export { OmniConnector } from "./OmniConnector";
|
|
6
|
+
export { Intents } from "./omni/Intents";
|
|
7
|
+
export { Token } from "./omni/token";
|
|
8
|
+
export { TGAS } from "./omni/nearRpc";
|
|
9
|
+
export { default as EvmConnector } from "./evm/connector";
|
|
10
|
+
export { default as SolanaConnector } from "./solana/connector";
|
|
11
|
+
export { default as StellarConnector } from "./stellar/connector";
|
|
12
|
+
export { default as TonConnector } from "./ton/connector";
|
|
13
|
+
export { default as NearConnector } from "./near/connector";
|
|
14
|
+
export { default as CosmosConnector } from "./cosmos/connector";
|
|
15
|
+
export { default as EvmWallet } from "./evm/wallet";
|
|
16
|
+
export { default as SolanaWallet } from "./solana/wallet";
|
|
17
|
+
export { default as StellarWallet } from "./stellar/wallet";
|
|
18
|
+
export { default as TonWallet } from "./ton/wallet";
|
|
19
|
+
export { default as NearWallet } from "./near/wallet";
|
|
20
|
+
export { default as CosmosWallet } from "./cosmos/wallet";
|
|
21
|
+
export { near, evm, solana, stellar, ton, google } from "./HotConnector";
|
|
22
|
+
export { HotConnector } from "./HotConnector";
|
|
23
|
+
import "./hot-wallet";
|
|
24
|
+
export { Bridge as BridgeWidget } from "./ui/payment/Bridge";
|
package/build/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { Network, OmniToken, WalletType } from "./omni/config";
|
|
2
|
+
export { formatter } from "./omni/utils";
|
|
3
|
+
export { EventEmitter } from "./events";
|
|
4
|
+
export { OmniWallet } from "./OmniWallet";
|
|
5
|
+
export { OmniConnector } from "./OmniConnector";
|
|
6
|
+
export { Intents } from "./omni/Intents";
|
|
7
|
+
export { Token } from "./omni/token";
|
|
8
|
+
export { TGAS } from "./omni/nearRpc";
|
|
9
|
+
export { default as EvmConnector } from "./evm/connector";
|
|
10
|
+
export { default as SolanaConnector } from "./solana/connector";
|
|
11
|
+
export { default as StellarConnector } from "./stellar/connector";
|
|
12
|
+
export { default as TonConnector } from "./ton/connector";
|
|
13
|
+
export { default as NearConnector } from "./near/connector";
|
|
14
|
+
export { default as CosmosConnector } from "./cosmos/connector";
|
|
15
|
+
export { default as EvmWallet } from "./evm/wallet";
|
|
16
|
+
export { default as SolanaWallet } from "./solana/wallet";
|
|
17
|
+
export { default as StellarWallet } from "./stellar/wallet";
|
|
18
|
+
export { default as TonWallet } from "./ton/wallet";
|
|
19
|
+
export { default as NearWallet } from "./near/wallet";
|
|
20
|
+
export { default as CosmosWallet } from "./cosmos/wallet";
|
|
21
|
+
export { near, evm, solana, stellar, ton, google } from "./HotConnector";
|
|
22
|
+
export { HotConnector } from "./HotConnector";
|
|
23
|
+
import "./hot-wallet";
|
|
24
|
+
export { Bridge as BridgeWidget } from "./ui/payment/Bridge";
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NearConnector } from "@hot-labs/near-connect";
|
|
2
|
+
import { WalletType } from "../omni/config";
|
|
3
|
+
import { ConnectorType, OmniConnector } from "../OmniConnector";
|
|
4
|
+
import { HotConnector } from "../HotConnector";
|
|
5
|
+
import NearWallet from "./wallet";
|
|
6
|
+
export interface NearConnectorOptions {
|
|
7
|
+
connector?: NearConnector;
|
|
8
|
+
projectId?: string;
|
|
9
|
+
metadata?: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
url: string;
|
|
13
|
+
icons: string[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
declare class Connector extends OmniConnector<NearWallet> {
|
|
17
|
+
readonly wibe3: HotConnector;
|
|
18
|
+
connector: NearConnector;
|
|
19
|
+
type: ConnectorType;
|
|
20
|
+
walletTypes: WalletType[];
|
|
21
|
+
icon: string;
|
|
22
|
+
name: string;
|
|
23
|
+
id: string;
|
|
24
|
+
constructor(wibe3: HotConnector, options?: NearConnectorOptions);
|
|
25
|
+
connect(id: string): Promise<NearWallet>;
|
|
26
|
+
disconnect(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export default Connector;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NearConnector } from "@hot-labs/near-connect";
|
|
2
|
+
import { runInAction } from "mobx";
|
|
3
|
+
import { WalletType } from "../omni/config";
|
|
4
|
+
import { ConnectorType, OmniConnector } from "../OmniConnector";
|
|
5
|
+
import NearWallet from "./wallet";
|
|
6
|
+
class Connector extends OmniConnector {
|
|
7
|
+
wibe3;
|
|
8
|
+
connector;
|
|
9
|
+
type = ConnectorType.WALLET;
|
|
10
|
+
walletTypes = [WalletType.NEAR, WalletType.OMNI];
|
|
11
|
+
icon = "https://storage.herewallet.app/upload/73a44e583769f11112b0eff1f2dd2a560c05eed5f6d92f0c03484fa047c31668.png";
|
|
12
|
+
name = "NEAR Wallet";
|
|
13
|
+
id = "near";
|
|
14
|
+
constructor(wibe3, options) {
|
|
15
|
+
super(wibe3);
|
|
16
|
+
this.wibe3 = wibe3;
|
|
17
|
+
this.connector =
|
|
18
|
+
options?.connector ||
|
|
19
|
+
new NearConnector({
|
|
20
|
+
network: "mainnet",
|
|
21
|
+
walletConnect: options?.projectId ? { projectId: options.projectId, metadata: options.metadata } : undefined,
|
|
22
|
+
});
|
|
23
|
+
this.connector.on("wallet:signOut", () => this.removeWallet());
|
|
24
|
+
this.connector.getConnectedWallet().then(async ({ wallet }) => {
|
|
25
|
+
const [account] = await wallet.getAccounts();
|
|
26
|
+
if (account)
|
|
27
|
+
this.setWallet(new NearWallet(this, account.accountId, account.publicKey, wallet));
|
|
28
|
+
});
|
|
29
|
+
this.connector.whenManifestLoaded.then(() => {
|
|
30
|
+
runInAction(() => {
|
|
31
|
+
this.options = this.connector.wallets.map((w) => ({
|
|
32
|
+
download: w.manifest.website,
|
|
33
|
+
name: w.manifest.name,
|
|
34
|
+
icon: w.manifest.icon,
|
|
35
|
+
id: w.manifest.id,
|
|
36
|
+
type: "external",
|
|
37
|
+
}));
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async connect(id) {
|
|
42
|
+
const wallet = await this.connector.connect(id);
|
|
43
|
+
if (!wallet)
|
|
44
|
+
throw new Error("Wallet not found");
|
|
45
|
+
const [account] = await wallet.getAccounts();
|
|
46
|
+
if (!account)
|
|
47
|
+
throw new Error("No account found");
|
|
48
|
+
return this.setWallet(new NearWallet(this, account.accountId, account.publicKey, wallet));
|
|
49
|
+
}
|
|
50
|
+
async disconnect() {
|
|
51
|
+
super.disconnect();
|
|
52
|
+
this.connector.disconnect();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export default Connector;
|
|
56
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/near/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,aA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
|
2
|
+
import { OmniConnector } from "../OmniConnector";
|
|
3
|
+
import { OmniWallet } from "../OmniWallet";
|
|
4
|
+
import { WalletType } from "../omni/config";
|
|
5
|
+
import { ReviewFee } from "../omni/bridge";
|
|
6
|
+
import { Token } from "../omni/token";
|
|
7
|
+
export default class NearWallet extends OmniWallet {
|
|
8
|
+
readonly connector: OmniConnector;
|
|
9
|
+
readonly address: string;
|
|
10
|
+
readonly publicKey?: string | undefined;
|
|
11
|
+
readonly wallet?: NearWalletBase | undefined;
|
|
12
|
+
readonly type = WalletType.NEAR;
|
|
13
|
+
constructor(connector: OmniConnector, address: string, publicKey?: string | undefined, wallet?: NearWalletBase | undefined);
|
|
14
|
+
get omniAddress(): string;
|
|
15
|
+
disconnect(): Promise<void>;
|
|
16
|
+
fetchBalances(_: number, whitelist: string[]): Promise<Record<string, bigint>>;
|
|
17
|
+
sendTransaction(params: SignAndSendTransactionParams): Promise<string>;
|
|
18
|
+
signMessage(params: SignMessageParams): Promise<SignedMessage>;
|
|
19
|
+
getWrapNearDepositAction(amount: bigint, address: string): Promise<({
|
|
20
|
+
type: string;
|
|
21
|
+
params: {
|
|
22
|
+
methodName: string;
|
|
23
|
+
deposit: string;
|
|
24
|
+
gas: string;
|
|
25
|
+
args: {};
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
type: string;
|
|
29
|
+
params: {
|
|
30
|
+
gas: bigint;
|
|
31
|
+
methodName: string;
|
|
32
|
+
deposit: string;
|
|
33
|
+
args: {
|
|
34
|
+
account_id: string;
|
|
35
|
+
registration_only: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
})[]>;
|
|
39
|
+
needRegisterToken(token: string, address: string): Promise<boolean>;
|
|
40
|
+
registerToken(token: string): Promise<void>;
|
|
41
|
+
transferFee(): Promise<ReviewFee>;
|
|
42
|
+
fetchBalance(chain: number, address: string): Promise<bigint>;
|
|
43
|
+
transfer(args: {
|
|
44
|
+
token: Token;
|
|
45
|
+
receiver: string;
|
|
46
|
+
amount: bigint;
|
|
47
|
+
comment?: string;
|
|
48
|
+
gasFee?: ReviewFee;
|
|
49
|
+
}): Promise<string>;
|
|
50
|
+
signIntentsWithAuth(domain: string, intents?: Record<string, any>[]): Promise<{
|
|
51
|
+
signed: Record<string, any>;
|
|
52
|
+
chainId: WalletType;
|
|
53
|
+
publicKey: string;
|
|
54
|
+
address: string;
|
|
55
|
+
domain: string;
|
|
56
|
+
seed: string;
|
|
57
|
+
}>;
|
|
58
|
+
signIntents(intents: Record<string, any>[], options?: {
|
|
59
|
+
nonce?: Uint8Array;
|
|
60
|
+
deadline?: number;
|
|
61
|
+
}): Promise<Record<string, any>>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { base64, base58, hex } from "@scure/base";
|
|
2
|
+
import { OmniWallet } from "../OmniWallet";
|
|
3
|
+
import { WalletType } from "../omni/config";
|
|
4
|
+
import { ReviewFee } from "../omni/bridge";
|
|
5
|
+
import { rpc, TGAS } from "../omni/nearRpc";
|
|
6
|
+
export default class NearWallet extends OmniWallet {
|
|
7
|
+
connector;
|
|
8
|
+
address;
|
|
9
|
+
publicKey;
|
|
10
|
+
wallet;
|
|
11
|
+
type = WalletType.NEAR;
|
|
12
|
+
constructor(connector, address, publicKey, wallet) {
|
|
13
|
+
super(connector);
|
|
14
|
+
this.connector = connector;
|
|
15
|
+
this.address = address;
|
|
16
|
+
this.publicKey = publicKey;
|
|
17
|
+
this.wallet = wallet;
|
|
18
|
+
}
|
|
19
|
+
get omniAddress() {
|
|
20
|
+
return this.address;
|
|
21
|
+
}
|
|
22
|
+
async disconnect() {
|
|
23
|
+
await this.wallet?.signOut();
|
|
24
|
+
super.disconnect();
|
|
25
|
+
}
|
|
26
|
+
async fetchBalances(_, whitelist) {
|
|
27
|
+
const balances = await Promise.all(whitelist.map(async (token) => {
|
|
28
|
+
const balance = await this.fetchBalance(1010, token);
|
|
29
|
+
return [token, balance];
|
|
30
|
+
}));
|
|
31
|
+
return Object.fromEntries(balances);
|
|
32
|
+
}
|
|
33
|
+
async sendTransaction(params) {
|
|
34
|
+
if (!this.wallet)
|
|
35
|
+
throw "not impl";
|
|
36
|
+
const actions = params.actions.map((action) => {
|
|
37
|
+
if (action["type"])
|
|
38
|
+
return action;
|
|
39
|
+
if (action.functionCall) {
|
|
40
|
+
return {
|
|
41
|
+
type: "FunctionCall",
|
|
42
|
+
params: {
|
|
43
|
+
methodName: action.functionCall.methodName,
|
|
44
|
+
args: JSON.parse(Buffer.from(action.functionCall.args).toString("utf8")),
|
|
45
|
+
gas: String(action.functionCall.gas),
|
|
46
|
+
deposit: String(action.functionCall.deposit),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (action.transfer) {
|
|
51
|
+
return {
|
|
52
|
+
type: "Transfer",
|
|
53
|
+
params: { deposit: String(action.transfer.deposit) },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const result = await this.wallet.signAndSendTransaction({ receiverId: params.receiverId, actions });
|
|
58
|
+
return result.transaction.hash;
|
|
59
|
+
}
|
|
60
|
+
async signMessage(params) {
|
|
61
|
+
if (!this.wallet)
|
|
62
|
+
throw "not impl";
|
|
63
|
+
return this.wallet.signMessage(params);
|
|
64
|
+
}
|
|
65
|
+
async getWrapNearDepositAction(amount, address) {
|
|
66
|
+
const storage = await rpc.viewMethod({
|
|
67
|
+
contractId: "wrap.near",
|
|
68
|
+
methodName: "storage_balance_of",
|
|
69
|
+
args: { account_id: address },
|
|
70
|
+
});
|
|
71
|
+
const depositAction = {
|
|
72
|
+
type: "FunctionCall",
|
|
73
|
+
params: {
|
|
74
|
+
methodName: "near_deposit",
|
|
75
|
+
deposit: String(amount),
|
|
76
|
+
gas: String(50n * TGAS),
|
|
77
|
+
args: {},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
if (storage != null)
|
|
81
|
+
return [depositAction];
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
type: "FunctionCall",
|
|
85
|
+
params: {
|
|
86
|
+
gas: 30n * TGAS,
|
|
87
|
+
methodName: "storage_deposit",
|
|
88
|
+
deposit: `12500000000000000000000`,
|
|
89
|
+
args: { account_id: address, registration_only: true },
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
depositAction,
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
async needRegisterToken(token, address) {
|
|
96
|
+
const storage = await rpc.viewMethod({ contractId: token, methodName: "storage_balance_of", args: { account_id: address } }).catch(() => null);
|
|
97
|
+
return storage == null;
|
|
98
|
+
}
|
|
99
|
+
async registerToken(token) {
|
|
100
|
+
const isNeedRegister = await this.needRegisterToken(token, this.address);
|
|
101
|
+
if (!isNeedRegister)
|
|
102
|
+
return;
|
|
103
|
+
await this.sendTransaction({
|
|
104
|
+
receiverId: token,
|
|
105
|
+
actions: [
|
|
106
|
+
{
|
|
107
|
+
type: "FunctionCall",
|
|
108
|
+
params: {
|
|
109
|
+
methodName: "storage_deposit",
|
|
110
|
+
args: { account_id: this.address, registration_only: true },
|
|
111
|
+
deposit: String(1n),
|
|
112
|
+
gas: String(30n * TGAS),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async transferFee() {
|
|
119
|
+
return new ReviewFee({ baseFee: 0n, gasLimit: 300n * TGAS, chain: 1010 });
|
|
120
|
+
}
|
|
121
|
+
async fetchBalance(chain, address) {
|
|
122
|
+
if (chain !== 1010)
|
|
123
|
+
throw "Invalid chain";
|
|
124
|
+
if (address === "native") {
|
|
125
|
+
const protocolConfig = await rpc.experimental_protocolConfig({ finality: "near-final" });
|
|
126
|
+
const state = await rpc.viewAccount(this.address, { finality: "near-final" });
|
|
127
|
+
const costPerByte = BigInt(protocolConfig.runtime_config.storage_amount_per_byte);
|
|
128
|
+
const usedOnStorage = BigInt(state.storage_usage) * costPerByte;
|
|
129
|
+
const locked = BigInt(state.locked);
|
|
130
|
+
const total = BigInt(state.amount) + locked;
|
|
131
|
+
const available = total - (locked > usedOnStorage ? locked : usedOnStorage);
|
|
132
|
+
return available < 0n ? 0n : available;
|
|
133
|
+
}
|
|
134
|
+
const balance = await rpc.viewMethod({
|
|
135
|
+
args: { account_id: this.address },
|
|
136
|
+
contractId: address,
|
|
137
|
+
methodName: "ft_balance_of",
|
|
138
|
+
});
|
|
139
|
+
return BigInt(balance);
|
|
140
|
+
}
|
|
141
|
+
async transfer(args) {
|
|
142
|
+
if (args.token.address === "native") {
|
|
143
|
+
return await this.sendTransaction({
|
|
144
|
+
actions: [{ type: "Transfer", params: { deposit: String(args.amount) } }],
|
|
145
|
+
receiverId: args.receiver,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const actions = [
|
|
149
|
+
{
|
|
150
|
+
type: "FunctionCall",
|
|
151
|
+
params: {
|
|
152
|
+
methodName: "ft_transfer",
|
|
153
|
+
args: { receiver_id: args.receiver, amount: String(args.amount) },
|
|
154
|
+
gas: String(30n * TGAS),
|
|
155
|
+
deposit: String(1n),
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
const needRegister = await this.needRegisterToken(args.token.address, args.receiver);
|
|
160
|
+
if (needRegister)
|
|
161
|
+
actions.unshift({
|
|
162
|
+
type: "FunctionCall",
|
|
163
|
+
params: {
|
|
164
|
+
gas: String(30n * TGAS),
|
|
165
|
+
methodName: "storage_deposit",
|
|
166
|
+
deposit: `12500000000000000000000`,
|
|
167
|
+
args: { account_id: args.receiver, registration_only: true },
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
return await this.sendTransaction({ receiverId: args.token.address, actions });
|
|
171
|
+
}
|
|
172
|
+
async signIntentsWithAuth(domain, intents) {
|
|
173
|
+
if (!this.wallet)
|
|
174
|
+
throw "not impl";
|
|
175
|
+
const accounts = await this.wallet.getAccounts();
|
|
176
|
+
if (accounts.length === 0)
|
|
177
|
+
throw new Error("No account found");
|
|
178
|
+
const { accountId, publicKey } = accounts[0];
|
|
179
|
+
const seed = hex.encode(window.crypto.getRandomValues(new Uint8Array(32)));
|
|
180
|
+
const msgBuffer = new TextEncoder().encode(`${domain}_${seed}`);
|
|
181
|
+
const nonce = await window.crypto.subtle.digest("SHA-256", new Uint8Array(msgBuffer));
|
|
182
|
+
return {
|
|
183
|
+
signed: await this.signIntents(intents || [], { nonce: new Uint8Array(nonce) }),
|
|
184
|
+
chainId: WalletType.NEAR,
|
|
185
|
+
publicKey: publicKey,
|
|
186
|
+
address: accountId,
|
|
187
|
+
domain,
|
|
188
|
+
seed,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async signIntents(intents, options) {
|
|
192
|
+
if (!this.wallet)
|
|
193
|
+
throw "not impl";
|
|
194
|
+
const nonce = new Uint8Array(options?.nonce || window.crypto.getRandomValues(new Uint8Array(32)));
|
|
195
|
+
const message = JSON.stringify({
|
|
196
|
+
deadline: options?.deadline ? new Date(options.deadline).toISOString() : "2100-01-01T00:00:00.000Z",
|
|
197
|
+
signer_id: this.omniAddress,
|
|
198
|
+
intents: intents,
|
|
199
|
+
});
|
|
200
|
+
const result = await this.wallet.signMessage({ message, recipient: "intents.near", nonce });
|
|
201
|
+
if (!result)
|
|
202
|
+
throw new Error("Failed to sign message");
|
|
203
|
+
const { signature, publicKey } = result;
|
|
204
|
+
const keys = await rpc.viewMethod({
|
|
205
|
+
contractId: "intents.near",
|
|
206
|
+
methodName: "public_keys_of",
|
|
207
|
+
args: { account_id: this.address },
|
|
208
|
+
});
|
|
209
|
+
if (!keys.includes(publicKey)) {
|
|
210
|
+
await this.sendTransaction({
|
|
211
|
+
receiverId: "intents.near",
|
|
212
|
+
actions: [
|
|
213
|
+
{
|
|
214
|
+
type: "FunctionCall",
|
|
215
|
+
params: {
|
|
216
|
+
methodName: "add_public_key",
|
|
217
|
+
args: { public_key: publicKey },
|
|
218
|
+
gas: String(80n * TGAS),
|
|
219
|
+
deposit: String(1n),
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
standard: "nep413",
|
|
227
|
+
payload: { nonce: base64.encode(nonce), recipient: "intents.near", message },
|
|
228
|
+
signature: signature.includes("ed25519:") ? signature : `ed25519:${base58.encode(base64.decode(signature))}`,
|
|
229
|
+
public_key: publicKey,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/near/wallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIlD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,UAAU;IAG3B;IAAmC;IAA0B;IAA6B;IAFtG,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAEhC,YAAqB,SAAwB,EAAW,OAAe,EAAW,SAAkB,EAAW,MAAuB;QACpI,KAAK,CAAC,SAAS,CAAC,CAAC;QADE,cAAS,GAAT,SAAS,CAAe;QAAW,YAAO,GAAP,OAAO,CAAQ;QAAW,cAAS,GAAT,SAAS,CAAS;QAAW,WAAM,GAAN,MAAM,CAAiB;IAEtI,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;QAC7B,KAAK,C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MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;YAC5G,UAAU,EAAE,SAAS;SACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { HotConnector } from "../HotConnector";
|
|
2
|
+
import type { OmniWallet } from "../OmniWallet";
|
|
3
|
+
import type { TransferIntent, MtWithdrawIntent, FtWithdrawIntent, TokenDiffIntent, AuthCallIntent } from "./types";
|
|
4
|
+
import { OmniToken } from "./config";
|
|
5
|
+
export declare const TGAS = 1000000000000n;
|
|
6
|
+
export declare class Intents {
|
|
7
|
+
readonly wibe3?: HotConnector | undefined;
|
|
8
|
+
constructor(wibe3?: HotConnector | undefined);
|
|
9
|
+
static get builder(): Intents;
|
|
10
|
+
hashes: string[];
|
|
11
|
+
intents: (TransferIntent | MtWithdrawIntent | FtWithdrawIntent | TokenDiffIntent | AuthCallIntent)[];
|
|
12
|
+
nonce?: Uint8Array;
|
|
13
|
+
deadline?: Date;
|
|
14
|
+
signer?: OmniWallet | {
|
|
15
|
+
ed25519PrivateKey: Uint8Array;
|
|
16
|
+
omniAddress?: string;
|
|
17
|
+
};
|
|
18
|
+
commitments: Record<string, any>[];
|
|
19
|
+
need: Map<OmniToken, bigint>;
|
|
20
|
+
addNeed(token: OmniToken, amount: bigint): this;
|
|
21
|
+
authCall(args: {
|
|
22
|
+
contractId: string;
|
|
23
|
+
msg: string;
|
|
24
|
+
attachNear: bigint;
|
|
25
|
+
tgas: number;
|
|
26
|
+
}): this;
|
|
27
|
+
transfer(args: {
|
|
28
|
+
recipient: string;
|
|
29
|
+
token: OmniToken;
|
|
30
|
+
amount: number | bigint;
|
|
31
|
+
msg?: string;
|
|
32
|
+
tgas?: number;
|
|
33
|
+
}): this;
|
|
34
|
+
batchTransfer(args: {
|
|
35
|
+
recipient: string;
|
|
36
|
+
tokens: Record<OmniToken, number | bigint>;
|
|
37
|
+
msg?: string;
|
|
38
|
+
tgas?: number;
|
|
39
|
+
}): this;
|
|
40
|
+
tokenDiff(args: Record<OmniToken, bigint | number>): this;
|
|
41
|
+
addRawIntent(rawIntent: Record<string, any>): this;
|
|
42
|
+
withdraw(args: {
|
|
43
|
+
token: OmniToken;
|
|
44
|
+
amount: number | bigint;
|
|
45
|
+
receiver: string;
|
|
46
|
+
memo?: string;
|
|
47
|
+
msg?: string;
|
|
48
|
+
tgas?: number;
|
|
49
|
+
}): this;
|
|
50
|
+
attachHashes(hashes: string[]): this;
|
|
51
|
+
attachWallet(wallet: OmniWallet): this;
|
|
52
|
+
attachDeadline(deadline: Date): this;
|
|
53
|
+
attachNonce(nonce: Uint8Array): this;
|
|
54
|
+
attachTimeout(seconds: number): this;
|
|
55
|
+
attachSeed(seed: string): this;
|
|
56
|
+
take(token: OmniToken, amount: number | bigint): this;
|
|
57
|
+
give(token: OmniToken, amount: number | bigint): this;
|
|
58
|
+
signRaw({ ed25519PrivateKey, intentsAddress, checkTokens }: {
|
|
59
|
+
ed25519PrivateKey: Uint8Array;
|
|
60
|
+
intentsAddress?: string;
|
|
61
|
+
checkTokens?: boolean;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
signature: string;
|
|
64
|
+
public_key: string;
|
|
65
|
+
standard: string;
|
|
66
|
+
payload: string;
|
|
67
|
+
}>;
|
|
68
|
+
attachCommitment(commitment: Record<string, any>): Promise<this>;
|
|
69
|
+
attachSigner(signer: OmniWallet | {
|
|
70
|
+
ed25519PrivateKey: Uint8Array;
|
|
71
|
+
omniAddress?: string;
|
|
72
|
+
}): Promise<this>;
|
|
73
|
+
checkRequiredTokens(): Promise<void>;
|
|
74
|
+
sign(params?: {
|
|
75
|
+
checkTokens: boolean;
|
|
76
|
+
}): Promise<Record<string, any> | {
|
|
77
|
+
signature: string;
|
|
78
|
+
public_key: string;
|
|
79
|
+
standard: string;
|
|
80
|
+
payload: string;
|
|
81
|
+
}>;
|
|
82
|
+
simulate(params?: {
|
|
83
|
+
checkTokens: boolean;
|
|
84
|
+
}): Promise<any>;
|
|
85
|
+
execute(params?: {
|
|
86
|
+
checkTokens: boolean;
|
|
87
|
+
}): Promise<string>;
|
|
88
|
+
static publishSignedIntents(signed: Record<string, any>[], hashes?: string[]): Promise<string>;
|
|
89
|
+
static hasPublicKey(accountId: string, publicKey: string): Promise<boolean>;
|
|
90
|
+
static simulateIntents(signed: Record<string, any>[]): Promise<any>;
|
|
91
|
+
static getIntentsBalances(assets: string[], accountId: string): Promise<Record<string, bigint>>;
|
|
92
|
+
static getIntentsAssets(accountId: string): Promise<string[]>;
|
|
93
|
+
}
|