decane-connect-kit 2.4.0 → 2.5.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.
package/dist/index.cjs CHANGED
@@ -2064,6 +2064,21 @@ var ApiClient = class {
2064
2064
  })
2065
2065
  });
2066
2066
  }
2067
+ // ── Transaction history ───────────────────────────────────────────────────
2068
+ async recordTransaction(jwt, tx) {
2069
+ const body = await this._request("/transactions", {
2070
+ method: "POST",
2071
+ headers: { Authorization: `Bearer ${jwt}` },
2072
+ body: JSON.stringify(tx)
2073
+ });
2074
+ return body.transaction;
2075
+ }
2076
+ async getTransactions(jwt, limit = 50) {
2077
+ const body = await this._request(`/transactions?limit=${encodeURIComponent(String(limit))}`, {
2078
+ headers: { Authorization: `Bearer ${jwt}` }
2079
+ });
2080
+ return body.transactions;
2081
+ }
2067
2082
  // ── WebAuthn registration (additive to the PRF-only passkey flow) ─────────
2068
2083
  async getWebAuthnRegisterOptions(jwt, rpId, rpName) {
2069
2084
  return this._request(`/webauthn/register-options?rpId=${encodeURIComponent(rpId)}&rpName=${encodeURIComponent(rpName)}`, {
@@ -3806,6 +3821,16 @@ async function createDecaneConnect(config) {
3806
3821
  };
3807
3822
  const signedTx = await signEvmTransaction(tee, req.chain, tx, auth?.jwt);
3808
3823
  const txResponse = await provider.broadcastTransaction(signedTx);
3824
+ if (auth?.jwt) {
3825
+ void api.recordTransaction(auth.jwt, {
3826
+ chain: req.chain,
3827
+ txHash: txResponse.hash,
3828
+ to: req.to,
3829
+ value: (req.value ?? 0n).toString(),
3830
+ kind: "send"
3831
+ }).catch(() => {
3832
+ });
3833
+ }
3809
3834
  return txResponse.hash;
3810
3835
  },
3811
3836
  async signTypedData(req) {
@@ -3838,6 +3863,14 @@ async function createDecaneConnect(config) {
3838
3863
  getAccessToken() {
3839
3864
  return auth?.jwt ?? null;
3840
3865
  },
3866
+ async recordTransaction(tx) {
3867
+ if (!auth?.jwt) throw new CallSequenceError("Not connected \u2014 call connect() first");
3868
+ return api.recordTransaction(auth.jwt, tx);
3869
+ },
3870
+ async getTransactionHistory(limit = 50) {
3871
+ if (!auth?.jwt) throw new CallSequenceError("Not connected \u2014 call connect() first");
3872
+ return api.getTransactions(auth.jwt, limit);
3873
+ },
3841
3874
  getEthereumProvider(opts) {
3842
3875
  if (!ethProvider) {
3843
3876
  const firstEvm = config.chains.find((c) => c.startsWith("evm:"));
@@ -6055,6 +6088,16 @@ function DecaneKit({ config, children }) {
6055
6088
  if (!sdk) throw new Error("Social wallet not connected");
6056
6089
  return sdk.signTronTransaction(rawDataHex);
6057
6090
  }, []);
6091
+ const socialRecordTransaction = (0, import_react5.useCallback)(async (tx) => {
6092
+ const sdk = socialRef.current;
6093
+ if (!sdk) throw new Error("Social wallet not connected");
6094
+ return sdk.recordTransaction(tx);
6095
+ }, []);
6096
+ const socialGetTransactionHistory = (0, import_react5.useCallback)(async (limit) => {
6097
+ const sdk = socialRef.current;
6098
+ if (!sdk) throw new Error("Social wallet not connected");
6099
+ return sdk.getTransactionHistory(limit);
6100
+ }, []);
6058
6101
  const socialSignTypedData = (0, import_react5.useCallback)(async (req) => {
6059
6102
  const sdk = socialRef.current;
6060
6103
  if (!sdk) throw new Error("Social wallet not connected");
@@ -6146,6 +6189,8 @@ function DecaneKit({ config, children }) {
6146
6189
  socialGetEthereumProvider,
6147
6190
  socialSignAuthorization,
6148
6191
  socialSignTronTransaction,
6192
+ socialRecordTransaction,
6193
+ socialGetTransactionHistory,
6149
6194
  socialGetAccessToken,
6150
6195
  socialSignSolanaTransaction,
6151
6196
  socialSignTypedData,
@@ -6367,6 +6412,8 @@ function useSocialWallet() {
6367
6412
  socialSendTransaction,
6368
6413
  socialSignSolanaTransaction,
6369
6414
  socialSignTronTransaction,
6415
+ socialRecordTransaction,
6416
+ socialGetTransactionHistory,
6370
6417
  socialSignTypedData,
6371
6418
  socialGetBalance,
6372
6419
  socialGetBalances,
@@ -6413,6 +6460,14 @@ function useSocialWallet() {
6413
6460
  (rawDataHex) => run(() => socialSignTronTransaction(rawDataHex)),
6414
6461
  [socialSignTronTransaction]
6415
6462
  );
6463
+ const recordTransaction = (0, import_react6.useCallback)(
6464
+ (tx) => run(() => socialRecordTransaction(tx)),
6465
+ [socialRecordTransaction]
6466
+ );
6467
+ const getTransactionHistory = (0, import_react6.useCallback)(
6468
+ (limit) => socialGetTransactionHistory(limit),
6469
+ [socialGetTransactionHistory]
6470
+ );
6416
6471
  const signTypedData = (0, import_react6.useCallback)(
6417
6472
  (req) => run(() => socialSignTypedData(req)),
6418
6473
  [socialSignTypedData]
@@ -6495,6 +6550,8 @@ function useSocialWallet() {
6495
6550
  sendTransaction,
6496
6551
  signSolanaTransaction: signSolanaTransaction2,
6497
6552
  signTronTransaction,
6553
+ recordTransaction,
6554
+ getTransactionHistory,
6498
6555
  signTypedData,
6499
6556
  // Balances (native token; read-only, works while locked)
6500
6557
  getBalance,