@0xsquid/react-hooks 6.4.4-sui-beta.0 → 6.4.4-xrpl-beta.0

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.
Files changed (87) hide show
  1. package/dist/core/connectors/xrp/CrossMark.d.ts +16 -0
  2. package/dist/core/connectors/xrp/CrossMark.js +30 -0
  3. package/dist/core/connectors/xrp/CrossMark.js.map +1 -0
  4. package/dist/core/connectors/xrp/XrpMetamaskSnap.d.ts +40 -0
  5. package/dist/core/connectors/xrp/XrpMetamaskSnap.js +204 -0
  6. package/dist/core/connectors/xrp/XrpMetamaskSnap.js.map +1 -0
  7. package/dist/core/constants.d.ts +4 -2
  8. package/dist/core/constants.js +13 -9
  9. package/dist/core/constants.js.map +1 -1
  10. package/dist/core/multicall3.js.map +1 -1
  11. package/dist/core/types/index.d.ts +1 -0
  12. package/dist/core/types/index.js +1 -0
  13. package/dist/core/types/index.js.map +1 -1
  14. package/dist/core/types/wallet.d.ts +15 -6
  15. package/dist/core/types/wallet.js +2 -0
  16. package/dist/core/types/wallet.js.map +1 -1
  17. package/dist/core/types/xrp.d.ts +23 -0
  18. package/dist/core/types/xrp.js +2 -0
  19. package/dist/core/types/xrp.js.map +1 -0
  20. package/dist/core/wallets.js +39 -3
  21. package/dist/core/wallets.js.map +1 -1
  22. package/dist/core/xrp/config.d.ts +21 -0
  23. package/dist/core/xrp/config.js +53 -0
  24. package/dist/core/xrp/config.js.map +1 -0
  25. package/dist/hooks/index.d.ts +1 -0
  26. package/dist/hooks/index.js +1 -0
  27. package/dist/hooks/index.js.map +1 -1
  28. package/dist/hooks/tokens/useAllConnectedWalletBalances.d.ts +1 -1
  29. package/dist/hooks/tokens/useAllConnectedWalletBalances.js +6 -6
  30. package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.d.ts +1 -1
  31. package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.js +10 -10
  32. package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.js.map +1 -1
  33. package/dist/hooks/tokens/useBalance.d.ts +1 -1
  34. package/dist/hooks/tokens/useBalance.js +8 -7
  35. package/dist/hooks/tokens/useBalance.js.map +1 -1
  36. package/dist/hooks/tokens/useMultiChainBalance.js +6 -6
  37. package/dist/hooks/tokens/useNativeBalance.d.ts +1 -1
  38. package/dist/hooks/tokens/useNativeBalance.js +12 -11
  39. package/dist/hooks/tokens/useNativeBalance.js.map +1 -1
  40. package/dist/hooks/tokens/useNativeTokenForChain.js +3 -3
  41. package/dist/hooks/tokens/useSquidTokens.d.ts +1 -1
  42. package/dist/hooks/tokens/useSquidTokens.js +5 -5
  43. package/dist/hooks/transaction/useExecuteTransaction.js +59 -14
  44. package/dist/hooks/transaction/useExecuteTransaction.js.map +1 -1
  45. package/dist/hooks/wallet/useMultiChainWallet.js +6 -6
  46. package/dist/hooks/wallet/useSigner.d.ts +1 -1
  47. package/dist/hooks/wallet/useSigner.js +7 -7
  48. package/dist/hooks/wallet/useSigner.js.map +1 -1
  49. package/dist/hooks/wallet/useWallet.js +3 -3
  50. package/dist/hooks/xrp/useXrp.d.ts +7 -0
  51. package/dist/hooks/xrp/useXrp.js +22 -0
  52. package/dist/hooks/xrp/useXrp.js.map +1 -0
  53. package/dist/services/external/rpcService.d.ts +3 -5
  54. package/dist/services/external/rpcService.js +80 -21
  55. package/dist/services/external/rpcService.js.map +1 -1
  56. package/dist/services/index.d.ts +1 -0
  57. package/dist/services/index.js +1 -0
  58. package/dist/services/index.js.map +1 -1
  59. package/dist/services/internal/assetsService.d.ts +2 -2
  60. package/dist/services/internal/assetsService.js +97 -77
  61. package/dist/services/internal/assetsService.js.map +1 -1
  62. package/dist/services/internal/errorService.js +1 -1
  63. package/dist/services/internal/errorService.js.map +1 -1
  64. package/dist/services/internal/transactionService.js +3 -2
  65. package/dist/services/internal/transactionService.js.map +1 -1
  66. package/dist/services/internal/walletService.d.ts +2 -2
  67. package/dist/services/internal/walletService.js +10 -10
  68. package/dist/services/internal/walletService.js.map +1 -1
  69. package/dist/services/internal/xrpService.d.ts +27 -0
  70. package/dist/services/internal/xrpService.js +86 -0
  71. package/dist/services/internal/xrpService.js.map +1 -0
  72. package/package.json +9 -10
  73. package/dist/core/types/rpc.d.ts +0 -10
  74. package/dist/core/types/rpc.js +0 -2
  75. package/dist/core/types/rpc.js.map +0 -1
  76. package/dist/core/types/sui.d.ts +0 -8
  77. package/dist/core/types/sui.js +0 -2
  78. package/dist/core/types/sui.js.map +0 -1
  79. package/dist/hooks/sui/useSui.d.ts +0 -7
  80. package/dist/hooks/sui/useSui.js +0 -16
  81. package/dist/hooks/sui/useSui.js.map +0 -1
  82. package/dist/services/external/suiRpcClient.d.ts +0 -14
  83. package/dist/services/external/suiRpcClient.js +0 -44
  84. package/dist/services/external/suiRpcClient.js.map +0 -1
  85. package/dist/services/internal/suiService.d.ts +0 -9
  86. package/dist/services/internal/suiService.js +0 -50
  87. package/dist/services/internal/suiService.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ import { ethers, parseUnits } from "ethers";
2
+ import { decodeAccountID, isValidClassicAddress, isValidXAddress, } from "ripple-address-codec";
3
+ import { CHAIN_IDS } from "../../core/constants";
4
+ import { AXELAR_XRPL_EVM_CHAIN_ID, XRPL_CONFIG } from "../../core/xrp/config";
5
+ import { parseToBigInt } from "./numberService";
6
+ /**
7
+ * Validates that a given address is a valid X-Address or a valid classic address.
8
+ *
9
+ * XRP has two types of addresses:
10
+ * - X-addresses (e.g XVfC9...pokKH)
11
+ * - Classic addresses (e.g r4bA...WHCG)
12
+ */
13
+ export function isXrpAddressValid(address) {
14
+ if (!address)
15
+ return false;
16
+ return isValidXAddress(address) || isValidClassicAddress(address);
17
+ }
18
+ /**
19
+ * Checks if the given chainId is an XRP chain (either XRPL or XRPL EVM)
20
+ */
21
+ export function isXrpChain(chainId) {
22
+ if (!chainId)
23
+ return false;
24
+ return [CHAIN_IDS.XRPL, CHAIN_IDS.XRPL_EVM].includes(chainId);
25
+ }
26
+ export async function sendInterchainTransfer({ destinationAddress, fromAmount, signer, }) {
27
+ if (!isXrpAddressValid(destinationAddress)) {
28
+ throw new Error("Destination address is not a valid XRP address");
29
+ }
30
+ const ITS_ABI = [
31
+ "function interchainTransfer(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata, uint256 gasValue) external",
32
+ ];
33
+ const itsContract = new ethers.Contract(XRPL_CONFIG.XRPL_EVM_ITS_ADDRESS, ITS_ABI, signer);
34
+ const destinationAddressAsHex = convertXrplAddressToHex(destinationAddress);
35
+ const tx = await itsContract.interchainTransfer(XRPL_CONFIG.XRP_ITS_TOKEN_ID, CHAIN_IDS.XRPL, destinationAddressAsHex, fromAmount, "0x", "100000000000000000", {
36
+ value: parseUnits("0.1", 18),
37
+ });
38
+ return tx;
39
+ }
40
+ /**
41
+ * Converts an XRPL address to a hex string
42
+ * to be able to send it through Axelar ITS
43
+ */
44
+ function convertXrplAddressToHex(address) {
45
+ return `0x${hex(decodeAccountID(address))}`;
46
+ }
47
+ export function hex(str) {
48
+ return Buffer.from(str).toString("hex");
49
+ }
50
+ export function isHexString(str) {
51
+ return /^[a-fA-F0-9]+$/.test(str);
52
+ }
53
+ export function asHexString(str) {
54
+ if (!isHexString(str)) {
55
+ throw new Error(`Invalid hex string: ${str}`);
56
+ }
57
+ return str;
58
+ }
59
+ export function buildXrplPayment({ fromAmount, sourceAddress, destinationAddress, }) {
60
+ const fromAmountBn = parseToBigInt(fromAmount, 6).toString();
61
+ const destinationAddressAsHex = asHexString(
62
+ // Remove the 0x prefix
63
+ destinationAddress.replace(/^0x/, ""));
64
+ return {
65
+ TransactionType: "Payment",
66
+ Account: sourceAddress,
67
+ Amount: fromAmountBn,
68
+ Destination: XRPL_CONFIG.XRPL_AXELAR_MULTISIG_ADDRESS,
69
+ Memos: [
70
+ {
71
+ Memo: {
72
+ MemoType: hex("destination_address"),
73
+ MemoData: destinationAddressAsHex,
74
+ },
75
+ },
76
+ {
77
+ Memo: {
78
+ MemoType: hex("destination_chain"),
79
+ MemoData: hex(AXELAR_XRPL_EVM_CHAIN_ID), // or "avalanche-fuji",
80
+ },
81
+ },
82
+ { Memo: { MemoType: hex("gas_fee_amount"), MemoData: "00" } }, // Always zero, for now
83
+ ],
84
+ };
85
+ }
86
+ //# sourceMappingURL=xrpService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrpService.js","sourceRoot":"","sources":["../../../src/services/internal/xrpService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAA4B,MAAM,QAAQ,CAAC;AACtE,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAE3B,OAAO,eAAe,CAAC,OAAO,CAAC,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAA2B;IACpD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAE3B,OAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAC3C,kBAAkB,EAClB,UAAU,EACV,MAAM,GAKP;IACC,IAAI,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,EAAE;QAC1C,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IAED,MAAM,OAAO,GAAG;QACd,4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B,kBAAkB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CACtC,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,SAAS;QAC1B,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,YAAY;QACpB,WAAW,EAAE,WAAW,CAAC,4BAA4B;QACrD,KAAK,EAAE;YACL;gBACE,IAAI,EAAE;oBACJ,QAAQ,EAAE,GAAG,CAAC,qBAAqB,CAAC;oBACpC,QAAQ,EAAE,uBAAuB;iBAClC;aACF;YACD;gBACE,IAAI,EAAE;oBACJ,QAAQ,EAAE,GAAG,CAAC,mBAAmB,CAAC;oBAClC,QAAQ,EAAE,GAAG,CAAC,wBAAwB,CAAC,EAAE,uBAAuB;iBACjE;aACF;YACD,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,uBAAuB;SACvF;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsquid/react-hooks",
3
- "version": "6.4.4-sui-beta.0",
3
+ "version": "6.4.4-xrpl-beta.0",
4
4
  "description": "Squid hooks monorepo",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,34 +28,33 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@0xsquid/sdk": "2.9.2",
31
- "@0xsquid/squid-types": "0.1.144",
31
+ "@0xsquid/squid-types": "0.1.125-beta.0",
32
+ "@bitcoinerlab/secp256k1": "1.1.1",
32
33
  "@cosmjs/cosmwasm-stargate": "0.32.4",
33
34
  "@cosmjs/encoding": "0.32.4",
34
35
  "@cosmjs/proto-signing": "0.32.4",
35
36
  "@cosmjs/stargate": "0.32.4",
36
37
  "@injectivelabs/sdk-ts": "1.14.13",
37
38
  "@ledgerhq/iframe-provider": "0.4.3",
38
- "@mysten/sui": "1.20.0",
39
- "@mysten/wallet-standard": "0.13.23",
40
39
  "@safe-global/safe-apps-sdk": "9.1.0",
40
+ "@solana/spl-token": "0.4.9",
41
41
  "@solana/wallet-adapter-phantom": "0.9.24",
42
42
  "@solana/web3.js": "1.95.3",
43
- "@solana/spl-token": "0.4.9",
44
43
  "@tanstack/react-query": "4.36.1",
45
- "@wallet-standard/core": "1.1.0",
46
- "wagmi": "2.13.3",
47
44
  "axios": "1.7.4",
48
45
  "bignumber.js": "9.1.1",
46
+ "bitcoinjs-lib": "7.0.0-rc.0",
47
+ "bs58check": "4.0.0",
49
48
  "cosmjs-types": "0.9.0",
50
49
  "ethers": "6.8.1",
51
50
  "fuse.js": "6.6.2",
52
51
  "lodash": "4.17.21",
53
52
  "long": "5.2.3",
53
+ "ripple-address-codec": "5.0.0",
54
54
  "secretjs": "1.12.4",
55
55
  "viem": "2.21.32",
56
- "zustand": "4.5.4",
57
- "bitcoinjs-lib": "7.0.0-rc.0",
58
- "@bitcoinerlab/secp256k1": "1.1.1"
56
+ "wagmi": "2.13.3",
57
+ "zustand": "4.5.4"
59
58
  },
60
59
  "peerDependencies": {
61
60
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0",
@@ -1,10 +0,0 @@
1
- export interface JsonRpcResponse<T> {
2
- jsonrpc: string;
3
- id: number;
4
- result?: T;
5
- error?: {
6
- code: number;
7
- data: string;
8
- message: string;
9
- };
10
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=rpc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../../src/core/types/rpc.ts"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- export interface SuiConnector {
2
- connect: () => Promise<string>;
3
- }
4
- export interface SuiCoinBalance {
5
- coinType: string;
6
- coinObjectCount: number;
7
- totalBalance: string;
8
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=sui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sui.js","sourceRoot":"","sources":["../../../src/core/types/sui.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { ConnectWalletResult, SuiWallet } from "../../core/types/wallet";
2
- export declare const useSui: () => {
3
- connectSui: import("@tanstack/react-query").UseMutationResult<ConnectWalletResult, unknown, {
4
- wallet: SuiWallet;
5
- }, unknown>;
6
- signer: undefined;
7
- };
@@ -1,16 +0,0 @@
1
- import { useMutation } from "@tanstack/react-query";
2
- export const useSui = () => {
3
- const connectSui = useMutation(async ({ wallet }) => {
4
- const suiConnectedAddress = await wallet.connector.connect();
5
- return {
6
- wallet,
7
- address: suiConnectedAddress,
8
- };
9
- });
10
- return {
11
- connectSui,
12
- // TODO: implement sui signer
13
- signer: undefined,
14
- };
15
- };
16
- //# sourceMappingURL=useSui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSui.js","sourceRoot":"","sources":["../../../src/hooks/sui/useSui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE;IACzB,MAAM,UAAU,GAAG,WAAW,CAC5B,KAAK,EAAE,EAAE,MAAM,EAAyB,EAAgC,EAAE;QACxE,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAE7D,OAAO;YACL,MAAM;YACN,OAAO,EAAE,mBAAmB;SAC7B,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,OAAO;QACL,UAAU;QACV,6BAA6B;QAC7B,MAAM,EAAE,SAAS;KAClB,CAAC;AACJ,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import { SuiCoinBalance } from "../../core/types/sui";
2
- export declare class SuiRpcClient {
3
- private rpcUrl;
4
- constructor(rpcUrl: string);
5
- /**
6
- * Fetches the balance of a single Sui token for a given address.
7
- */
8
- getBalance(userAddress: string, tokenAddress: string): Promise<SuiCoinBalance>;
9
- /**
10
- * Fetches all Sui coin balances for a given address.
11
- */
12
- getAllBalances(userAddress: string): Promise<SuiCoinBalance[]>;
13
- private call;
14
- }
@@ -1,44 +0,0 @@
1
- export class SuiRpcClient {
2
- rpcUrl;
3
- constructor(rpcUrl) {
4
- this.rpcUrl = rpcUrl;
5
- }
6
- /**
7
- * Fetches the balance of a single Sui token for a given address.
8
- */
9
- async getBalance(userAddress, tokenAddress) {
10
- return this.call("suix_getBalance", [
11
- userAddress,
12
- tokenAddress,
13
- ]);
14
- }
15
- /**
16
- * Fetches all Sui coin balances for a given address.
17
- */
18
- async getAllBalances(userAddress) {
19
- return this.call("suix_getAllBalances", [userAddress]);
20
- }
21
- async call(method, params) {
22
- const response = await fetch(this.rpcUrl, {
23
- method: "POST",
24
- headers: {
25
- "Content-Type": "application/json",
26
- },
27
- body: JSON.stringify({
28
- jsonrpc: "2.0",
29
- id: 1,
30
- method,
31
- params,
32
- }),
33
- });
34
- const data = await response.json();
35
- if (data.error) {
36
- throw new Error(`RPC Error (${method}): ${data.error.message}`);
37
- }
38
- if (!data.result) {
39
- throw new Error(`Invalid response from RPC (${method})`);
40
- }
41
- return data.result;
42
- }
43
- }
44
- //# sourceMappingURL=suiRpcClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"suiRpcClient.js","sourceRoot":"","sources":["../../../src/services/external/suiRpcClient.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,YAAY;IACf,MAAM,CAAS;IAEvB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CACd,WAAmB,EACnB,YAAoB;QAEpB,OAAO,IAAI,CAAC,IAAI,CAAiB,iBAAiB,EAAE;YAClD,WAAW;YACX,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,WAAmB;QACtC,OAAO,IAAI,CAAC,IAAI,CAAmB,qBAAqB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3E,CAAC;IAEO,KAAK,CAAC,IAAI,CAAI,MAAc,EAAE,MAAa;QACjD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;YACxC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,OAAO,EAAE,KAAK;gBACd,EAAE,EAAE,CAAC;gBACL,MAAM;gBACN,MAAM;aACP,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,IAAI,GAAuB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEvD,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,cAAc,MAAM,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;SACjE;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,GAAG,CAAC,CAAC;SAC1D;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
@@ -1,9 +0,0 @@
1
- import type { WalletWithRequiredFeatures as SuiStandardWallet, Wallet, WalletWithFeatures } from "@mysten/wallet-standard";
2
- import { SuiWallet } from "../../core/types/wallet";
3
- export declare function getRegisteredWallets<AdditionalFeatures extends Wallet["features"]>(): WalletWithFeatures<import("@mysten/wallet-standard").StandardConnectFeature & import("@mysten/wallet-standard").StandardEventsFeature & AdditionalFeatures>[];
4
- export declare const SUI_ADDRESS_LENGTH = 32;
5
- export declare function isSuiAddressValid(address: string): boolean;
6
- /**
7
- * Format a Sui standard wallet into a Squid Wallet
8
- */
9
- export declare function formatSuiWallet({ icon, name, features, }: SuiStandardWallet): SuiWallet;
@@ -1,50 +0,0 @@
1
- import { ChainType } from "@0xsquid/squid-types";
2
- import { getWallets, isWalletWithRequiredFeatureSet, } from "@mysten/wallet-standard";
3
- const SIGN_FEATURES = [
4
- "sui:signTransaction",
5
- "sui:signTransactionBlock",
6
- ];
7
- const suiWalletFilter = (wallet) => SIGN_FEATURES.some((feature) => wallet.features[feature]);
8
- export function getRegisteredWallets() {
9
- const allStandardWallets = getWallets().get();
10
- // Filter out all non-Sui standard wallets
11
- const suiWallets = allStandardWallets.filter((wallet) => isWalletWithRequiredFeatureSet(wallet) &&
12
- (!suiWalletFilter || suiWalletFilter(wallet)));
13
- return suiWallets;
14
- }
15
- function isHex(value) {
16
- return /^(0x|0X)?[a-fA-F0-9]+$/.test(value) && value.length % 2 === 0;
17
- }
18
- function getHexByteLength(value) {
19
- return /^(0x|0X)/.test(value) ? (value.length - 2) / 2 : value.length / 2;
20
- }
21
- export const SUI_ADDRESS_LENGTH = 32;
22
- // Taken from https://github.com/MystenLabs/ts-sdks/blob/31dd6c73d7aab9819bd545323273f733cfcc5a01/packages/typescript/src/utils/sui-types.ts#L24-L27
23
- export function isSuiAddressValid(address) {
24
- return isHex(address) && getHexByteLength(address) === SUI_ADDRESS_LENGTH;
25
- }
26
- /**
27
- * Format a Sui standard wallet into a Squid Wallet
28
- */
29
- export function formatSuiWallet({ icon, name, features, }) {
30
- return {
31
- // TODO: remove connectorId as it's not needed for Sui wallets
32
- connectorId: name,
33
- name,
34
- connectorName: name,
35
- type: ChainType.SUI,
36
- icon,
37
- windowFlag: name,
38
- // TODO: check this
39
- isMobile: false,
40
- // TODO: implement install detection
41
- isInstalled: () => true,
42
- connector: {
43
- async connect() {
44
- const { accounts } = await features["standard:connect"].connect();
45
- return accounts[0].address;
46
- },
47
- },
48
- };
49
- }
50
- //# sourceMappingURL=suiService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"suiService.js","sourceRoot":"","sources":["../../../src/services/internal/suiService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AASjD,OAAO,EACL,UAAU,EACV,8BAA8B,GAC/B,MAAM,yBAAyB,CAAC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