@flarenetwork/multichain-wallet-connector 0.0.1 → 0.0.2-rc.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.
@@ -1,2 +1,2 @@
1
- import { A as LedgerConnectOptions, B as ErrorEvent, C as LedgerSession, D as ChainClient, E as EvmClient, F as ChainChangedEvent, G as ResolvedWalletConfig, H as MetaMaskWalletOptions, I as ChainOverride, J as WalletOptions, K as WalletConnectWalletOptions, L as ConnectEvent, M as LedgerPaginatedBip44, N as Bip44, O as LedgerCaip2, P as AccountChangedEvent, R as DcentWalletOptions, S as ConnectorTypeMap, T as XrpClient, U as MultiChainEvents, V as LedgerWalletOptions, W as MultiChainOptions, X as WalletAddressState, Y as XamanWalletOptions, Z as WalletState, _ as ConfigResolver, a as shortenAddress, at as EvmChain, c as WalletConnectError, ct as XrplChain, d as DcentError, et as WalletType, f as WalletError, g as MultiChain, h as ChainGuards, i as objectValues, it as Eip155Caip2, j as LedgerHDStandard, k as LedgerComputedAddress, l as MetaMaskError, m as ErrorCodeKey, n as objectFromEntries, nt as Caip2, o as WalletErrorHelper, ot as NonEvmChain, p as ErrorCode, q as WalletMetadata, r as objectKeys, rt as Chain, s as XamanError, st as XRPlCaip2, t as objectEntries, tt as BaseChain, u as LedgerError, w as DcentConnector, x as Connector, z as DisconnectEvent } from "../utils-C64Z4fWz.mjs";
1
+ import { A as LedgerConnectOptions, B as ErrorEvent, C as LedgerSession, D as ChainClient, E as EvmClient, F as ChainChangedEvent, G as ResolvedWalletConfig, H as MetaMaskWalletOptions, I as ChainOverride, J as WalletOptions, K as WalletConnectWalletOptions, L as ConnectEvent, M as LedgerPaginatedBip44, N as Bip44, O as LedgerCaip2, P as AccountChangedEvent, R as DcentWalletOptions, S as ConnectorTypeMap, T as XrpClient, U as MultiChainEvents, V as LedgerWalletOptions, W as MultiChainOptions, X as WalletAddressState, Y as XamanWalletOptions, Z as WalletState, _ as ConfigResolver, a as shortenAddress, at as EvmChain, c as WalletConnectError, ct as XrplChain, d as DcentError, et as WalletType, f as WalletError, g as MultiChain, h as ChainGuards, i as objectValues, it as Eip155Caip2, j as LedgerHDStandard, k as LedgerComputedAddress, l as MetaMaskError, m as ErrorCodeKey, n as objectFromEntries, nt as Caip2, o as WalletErrorHelper, ot as NonEvmChain, p as ErrorCode, q as WalletMetadata, r as objectKeys, rt as Chain, s as XamanError, st as XRPlCaip2, t as objectEntries, tt as BaseChain, u as LedgerError, w as DcentConnector, x as Connector, z as DisconnectEvent } from "../utils-BuE-T-_N.mjs";
2
2
  export { type AccountChangedEvent, type BaseChain, Bip44, type Caip2, type Chain, type ChainChangedEvent, type ChainClient, ChainGuards, type ChainOverride, ConfigResolver, type ConnectEvent, type Connector, type ConnectorTypeMap, DcentConnector, DcentError, type DcentWalletOptions, type DisconnectEvent, type Eip155Caip2, ErrorCode, type ErrorCodeKey, type ErrorEvent, type EvmChain, EvmClient, type LedgerCaip2, type LedgerComputedAddress, type LedgerConnectOptions, LedgerError, type LedgerHDStandard, type LedgerPaginatedBip44, type LedgerSession, type LedgerWalletOptions, MetaMaskError, type MetaMaskWalletOptions, MultiChain, type MultiChainEvents, type MultiChainOptions, type NonEvmChain, type ResolvedWalletConfig, type WalletAddressState, WalletConnectError, type WalletConnectWalletOptions, WalletError, WalletErrorHelper, type WalletMetadata, type WalletOptions, type WalletState, type WalletType, type XRPlCaip2, XamanError, type XamanWalletOptions, type XrpClient, type XrplChain, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress };
@@ -1,3 +1,3 @@
1
- import { _ as objectFromEntries, a as WalletErrorHelper, b as shortenAddress, c as MetaMaskError, d as WalletError, f as ErrorCode, g as objectEntries, h as ChainGuards, i as DcentConnector, l as LedgerError, n as EvmClient, o as XamanError, p as ConfigResolver, r as Bip44, s as WalletConnectError, t as MultiChain, u as DcentError, v as objectKeys, y as objectValues } from "../multichain--W3uROp7.mjs";
1
+ import { _ as objectFromEntries, a as WalletErrorHelper, b as shortenAddress, c as MetaMaskError, d as WalletError, f as ErrorCode, g as objectEntries, h as ChainGuards, i as DcentConnector, l as LedgerError, n as EvmClient, o as XamanError, p as ConfigResolver, r as Bip44, s as WalletConnectError, t as MultiChain, u as DcentError, v as objectKeys, y as objectValues } from "../multichain-CzIWKOzm.mjs";
2
2
 
3
3
  export { Bip44, ChainGuards, ConfigResolver, DcentConnector, DcentError, ErrorCode, EvmClient, LedgerError, MetaMaskError, MultiChain, WalletConnectError, WalletError, WalletErrorHelper, XamanError, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as LedgerConnectOptions, B as ErrorEvent, C as LedgerSession, D as ChainClient, E as EvmClient, F as ChainChangedEvent, G as ResolvedWalletConfig, H as MetaMaskWalletOptions, I as ChainOverride, J as WalletOptions, K as WalletConnectWalletOptions, L as ConnectEvent, M as LedgerPaginatedBip44, N as Bip44, O as LedgerCaip2, P as AccountChangedEvent, R as DcentWalletOptions, S as ConnectorTypeMap, T as XrpClient, U as MultiChainEvents, V as LedgerWalletOptions, W as MultiChainOptions, X as WalletAddressState, Y as XamanWalletOptions, Z as WalletState, _ as ConfigResolver, a as shortenAddress, at as EvmChain, b as ConnectWalletArgs, c as WalletConnectError, ct as XrplChain, d as DcentError, et as WalletType, f as WalletError, g as MultiChain, h as ChainGuards, i as objectValues, it as Eip155Caip2, j as LedgerHDStandard, k as LedgerComputedAddress, l as MetaMaskError, m as ErrorCodeKey, n as objectFromEntries, nt as Caip2, o as WalletErrorHelper, ot as NonEvmChain, p as ErrorCode, q as WalletMetadata, r as objectKeys, rt as Chain, s as XamanError, st as XRPlCaip2, t as objectEntries, tt as BaseChain, u as LedgerError, w as DcentConnector, x as Connector, z as DisconnectEvent } from "./utils-C64Z4fWz.mjs";
2
- import { C as UseChainOptions, D as useChainSupport, E as useChain, O as MultichainProvider, S as UseChainNotFound, T as UseXrpChainReturn, _ as LedgerSelectionState, a as useWalletSupport, b as useLedgerSelection, c as MultichainSelectionConfig, d as UseMultichainSelectionReturn, f as WalletsConfig, g as LedgerSelectionActions, h as useMultichainEvents, i as WalletInfo, l as MultichainSelectionMode, m as useMultichain, n as UseWalletReturn, o as MultichainSelectionProvider, p as UseMultichainReturn, r as useWallet, s as useMultichainSelection, t as useWallets, u as SelectionWallet, v as UseLedgerSelectionOptions, w as UseEvmChainReturn, x as UseChainFound, y as UseLedgerSelectionReturn } from "./use-wallets-B8SDOU0g.mjs";
1
+ import { A as LedgerConnectOptions, B as ErrorEvent, C as LedgerSession, D as ChainClient, E as EvmClient, F as ChainChangedEvent, G as ResolvedWalletConfig, H as MetaMaskWalletOptions, I as ChainOverride, J as WalletOptions, K as WalletConnectWalletOptions, L as ConnectEvent, M as LedgerPaginatedBip44, N as Bip44, O as LedgerCaip2, P as AccountChangedEvent, R as DcentWalletOptions, S as ConnectorTypeMap, T as XrpClient, U as MultiChainEvents, V as LedgerWalletOptions, W as MultiChainOptions, X as WalletAddressState, Y as XamanWalletOptions, Z as WalletState, _ as ConfigResolver, a as shortenAddress, at as EvmChain, b as ConnectWalletArgs, c as WalletConnectError, ct as XrplChain, d as DcentError, et as WalletType, f as WalletError, g as MultiChain, h as ChainGuards, i as objectValues, it as Eip155Caip2, j as LedgerHDStandard, k as LedgerComputedAddress, l as MetaMaskError, m as ErrorCodeKey, n as objectFromEntries, nt as Caip2, o as WalletErrorHelper, ot as NonEvmChain, p as ErrorCode, q as WalletMetadata, r as objectKeys, rt as Chain, s as XamanError, st as XRPlCaip2, t as objectEntries, tt as BaseChain, u as LedgerError, w as DcentConnector, x as Connector, z as DisconnectEvent } from "./utils-BuE-T-_N.mjs";
2
+ import { C as UseChainOptions, D as useChainSupport, E as useChain, O as MultichainProvider, S as UseChainNotFound, T as UseXrpChainReturn, _ as LedgerSelectionState, a as useWalletSupport, b as useLedgerSelection, c as MultichainSelectionConfig, d as UseMultichainSelectionReturn, f as WalletsConfig, g as LedgerSelectionActions, h as useMultichainEvents, i as WalletInfo, l as MultichainSelectionMode, m as useMultichain, n as UseWalletReturn, o as MultichainSelectionProvider, p as UseMultichainReturn, r as useWallet, s as useMultichainSelection, t as useWallets, u as SelectionWallet, v as UseLedgerSelectionOptions, w as UseEvmChainReturn, x as UseChainFound, y as UseLedgerSelectionReturn } from "./use-wallets-_d323M3D.mjs";
3
3
  export { AccountChangedEvent, BaseChain, Bip44, Caip2, Chain, ChainChangedEvent, ChainClient, ChainGuards, ChainOverride, ConfigResolver, ConnectEvent, ConnectWalletArgs, Connector, ConnectorTypeMap, DcentConnector, DcentError, DcentWalletOptions, DisconnectEvent, Eip155Caip2, ErrorCode, ErrorCodeKey, ErrorEvent, EvmChain, EvmClient, LedgerCaip2, LedgerComputedAddress, LedgerConnectOptions, LedgerError, LedgerHDStandard, LedgerPaginatedBip44, LedgerSelectionActions, LedgerSelectionState, LedgerSession, LedgerWalletOptions, MetaMaskError, MetaMaskWalletOptions, MultiChain, MultiChainEvents, MultiChainOptions, MultichainProvider, MultichainSelectionConfig, MultichainSelectionMode, MultichainSelectionProvider, NonEvmChain, ResolvedWalletConfig, SelectionWallet, UseChainFound, UseChainNotFound, UseChainOptions, UseEvmChainReturn, UseLedgerSelectionOptions, UseLedgerSelectionReturn, UseMultichainReturn, UseMultichainSelectionReturn, UseWalletReturn, UseXrpChainReturn, WalletAddressState, WalletConnectError, WalletConnectWalletOptions, WalletError, WalletErrorHelper, WalletInfo, WalletMetadata, WalletOptions, WalletState, WalletType, WalletsConfig, XRPlCaip2, XamanError, XamanWalletOptions, XrpClient, XrplChain, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress, useChain, useChainSupport, useLedgerSelection, useMultichain, useMultichainEvents, useMultichainSelection, useWallet, useWalletSupport, useWallets };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as objectFromEntries, a as WalletErrorHelper, b as shortenAddress, c as MetaMaskError, d as WalletError, f as ErrorCode, g as objectEntries, h as ChainGuards, i as DcentConnector, l as LedgerError, n as EvmClient, o as XamanError, p as ConfigResolver, r as Bip44, s as WalletConnectError, t as MultiChain, u as DcentError, v as objectKeys, y as objectValues } from "./multichain--W3uROp7.mjs";
2
- import { a as MultichainSelectionProvider, c as useLedgerSelection, d as MultichainProvider, i as useMultichainSelection, l as useChain, n as useWallet, o as useMultichain, r as useWalletSupport, s as useMultichainEvents, t as useWallets, u as useChainSupport } from "./use-wallets-DTvXJmfe.mjs";
1
+ import { _ as objectFromEntries, a as WalletErrorHelper, b as shortenAddress, c as MetaMaskError, d as WalletError, f as ErrorCode, g as objectEntries, h as ChainGuards, i as DcentConnector, l as LedgerError, n as EvmClient, o as XamanError, p as ConfigResolver, r as Bip44, s as WalletConnectError, t as MultiChain, u as DcentError, v as objectKeys, y as objectValues } from "./multichain-CzIWKOzm.mjs";
2
+ import { a as MultichainSelectionProvider, c as useLedgerSelection, d as MultichainProvider, i as useMultichainSelection, l as useChain, n as useWallet, o as useMultichain, r as useWalletSupport, s as useMultichainEvents, t as useWallets, u as useChainSupport } from "./use-wallets-Cj0_kjDe.mjs";
3
3
  import "./react/index.mjs";
4
4
 
5
5
  export { Bip44, ChainGuards, ConfigResolver, DcentConnector, DcentError, ErrorCode, EvmClient, LedgerError, MetaMaskError, MultiChain, MultichainProvider, MultichainSelectionProvider, WalletConnectError, WalletError, WalletErrorHelper, XamanError, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress, useChain, useChainSupport, useLedgerSelection, useMultichain, useMultichainEvents, useMultichainSelection, useWallet, useWalletSupport, useWallets };
@@ -1,7 +1,7 @@
1
1
  import { createPublicClient, createWalletClient, custom, defineChain, getAddress, getTypesForEIP712Domain, hashDomain, hashStruct, http, serializeSignature, serializeTransaction } from "viem";
2
2
  import { flare, flareTestnet, mainnet, sepolia, songbird } from "viem/chains";
3
3
  import { DisconnectedDevice, DisconnectedDeviceDuringOperation, LockedDeviceError, TransportInterfaceNotAvailable, TransportOpenUserCancelled, UserRefusedOnDevice } from "@ledgerhq/errors";
4
- import { Client, RippledError, encode } from "xrpl";
4
+ import { Client, RippledError, encode, parseAccountRootFlags } from "xrpl";
5
5
  import Eth from "@ledgerhq/hw-app-eth";
6
6
  import * as secp256k1 from "@noble/secp256k1";
7
7
  import { publicKeyToAddress, toAccount } from "viem/accounts";
@@ -57,6 +57,13 @@ function objectEntries(obj) {
57
57
  function objectFromEntries(entries) {
58
58
  return Object.fromEntries(entries);
59
59
  }
60
+ function isEmptyObject(value) {
61
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
62
+ }
63
+ /** Strips fields with empty object values ({}) from an object. */
64
+ function stripEmptyObjects(obj) {
65
+ return objectFromEntries(objectEntries(obj).filter(([, v]) => !isEmptyObject(v)));
66
+ }
60
67
 
61
68
  //#endregion
62
69
  //#region src/core/chains/chain.constants.ts
@@ -795,6 +802,13 @@ var BaseXrplClient = class extends Client {
795
802
  async ensureConnected() {
796
803
  if (!this.isConnected()) await this.connect();
797
804
  }
805
+ async requiresDestinationTag(address) {
806
+ await this.ensureConnected();
807
+ return parseAccountRootFlags((await this.request({
808
+ command: "account_info",
809
+ account: address
810
+ })).result.account_data.Flags).lsfRequireDestTag ?? false;
811
+ }
798
812
  async getBalance(address) {
799
813
  try {
800
814
  await this.ensureConnected();
@@ -843,8 +857,14 @@ var DcentXrpClient = class {
843
857
  return result.tx_hash;
844
858
  }
845
859
  async getBalance(address) {
860
+ return (await this.getSimpleClient()).getBalance(address);
861
+ }
862
+ async requiresDestinationTag(address) {
863
+ return (await this.getSimpleClient()).requiresDestinationTag(address);
864
+ }
865
+ async getSimpleClient() {
846
866
  const caip2 = await this.getCaip2();
847
- return new XrplClient(this.resolvedConfig.getXrplChain(caip2)).getBalance(address);
867
+ return new XrplClient(this.resolvedConfig.getXrplChain(caip2));
848
868
  }
849
869
  async getCaip2() {
850
870
  return (await this.provider.getWalletInfo()).chainId;
@@ -2115,11 +2135,33 @@ var WalletConnectXrpClient = class extends XrplClient {
2115
2135
  submit: false
2116
2136
  }
2117
2137
  }, xrpCaip2);
2118
- return (await this.submitAndWait(result.tx_json)).result.hash;
2138
+ const signedTx = this.sanitizeTx(result.tx_json);
2139
+ return (await this.submitAndWait(signedTx)).result.hash;
2119
2140
  } finally {
2120
2141
  await this.disconnect();
2121
2142
  }
2122
2143
  }
2144
+ sanitizeTx(walletResult) {
2145
+ if (this.isGirin(walletResult)) return stripEmptyObjects({
2146
+ TransactionType: walletResult.TransactionType,
2147
+ Account: walletResult.Account,
2148
+ Fee: walletResult.Fee,
2149
+ Sequence: walletResult.Sequence,
2150
+ SigningPubKey: walletResult.SigningPubKey,
2151
+ TxnSignature: walletResult.TxnSignature,
2152
+ Flags: walletResult.Flags,
2153
+ LastLedgerSequence: walletResult.LastLedgerSequence,
2154
+ Destination: walletResult.Destination,
2155
+ Amount: walletResult.Amount,
2156
+ DestinationTag: walletResult.DestinationTag,
2157
+ Memos: walletResult.Memos,
2158
+ SourceTag: walletResult.SourceTag
2159
+ });
2160
+ return walletResult;
2161
+ }
2162
+ isGirin(walletResult) {
2163
+ return (this.provider.session?.peer.metadata.name ?? "unknown").toLowerCase().includes("girin");
2164
+ }
2123
2165
  };
2124
2166
 
2125
2167
  //#endregion
@@ -2472,6 +2514,9 @@ var XamanClient = class XamanClient extends Xumm {
2472
2514
  async getBalance(address) {
2473
2515
  return (await this.getSimpleClient()).getBalance(address);
2474
2516
  }
2517
+ async requiresDestinationTag(address) {
2518
+ return (await this.getSimpleClient()).requiresDestinationTag(address);
2519
+ }
2475
2520
  async getSimpleClient() {
2476
2521
  const caip2 = await this.getCaip2();
2477
2522
  return new XrplClient(this.resolvedConfig.getXrplChain(caip2));
@@ -2859,4 +2904,4 @@ var MultiChain = class {
2859
2904
 
2860
2905
  //#endregion
2861
2906
  export { objectFromEntries as _, WalletErrorHelper as a, shortenAddress as b, MetaMaskError as c, WalletError as d, ErrorCode as f, objectEntries as g, ChainGuards as h, DcentConnector as i, LedgerError as l, evmCaip2s as m, EvmClient as n, XamanError as o, ConfigResolver as p, Bip44 as r, WalletConnectError as s, MultiChain as t, DcentError as u, objectKeys as v, objectValues as y };
2862
- //# sourceMappingURL=multichain--W3uROp7.mjs.map
2907
+ //# sourceMappingURL=multichain-CzIWKOzm.mjs.map