@anywalletkit/wallet-near 0.1.4 → 0.1.6

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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { IWalletAccountReadOnly, TransferResult, IWalletAccount, Signer, WalletManager, FeeRates } from '@anywalletkit/core';
1
+ import { IWalletAccountReadOnly, TransferResult, IWalletAccount, Signer, WriteOptions, WalletManager, FeeRates } from '@anywalletkit/core';
2
2
  export { HistoryFetch, HistoryUnavailableError, NearChainTx, NearHistoryCursor, NearHistoryOptions, NearHistoryPage, NearHistoryRaw, NearHistorySource, NearblocksFtRow, NearblocksReceiptRow, NearblocksTxn, RpcTxStatus, createNearHistory, decodeFunctionCallArgs, decodeCursor as decodeHistoryCursor, encodeCursor as encodeHistoryCursor, mapNearblocksGroup, mapNearblocksTxn, mapRpcTxStatus, nearExplorerTxUrl, parseJsonPreservingBigInts } from './history.cjs';
3
3
 
4
4
  /** JSON-RPC transport: `method` + `params`, returns the `result` (throws on `error`). */
@@ -16,6 +16,8 @@ interface NearConfig {
16
16
  retries?: number;
17
17
  /** Optional headers for every request (e.g. an API key). */
18
18
  headers?: Record<string, string>;
19
+ /** Per-request timeout for url providers, in ms (default 15 000): a node that never answers fails over (reads) or ends as "maybe sent" (`send_tx`). */
20
+ timeoutMs?: number;
19
21
  /** "mainnet" (default) | "testnet" | any CAIP-2 suffix. */
20
22
  network?: 'mainnet' | 'testnet' | string;
21
23
  /** Max fee (yoctoNEAR) for `transfer`. */
@@ -291,6 +293,18 @@ declare class NearRpcError extends Error {
291
293
  code?: number;
292
294
  });
293
295
  }
296
+ /**
297
+ * The signed transaction was handed to the RPC but no definitive answer came back (no response, or
298
+ * a node timeout): it MAY be on chain. Do not sign it again (a new nonce would pay twice) — watch
299
+ * `hash`, computed locally.
300
+ */
301
+ declare class BroadcastUnknownError extends Error {
302
+ /** Always true: the transaction may be on its way. */
303
+ readonly maybeSent = true;
304
+ /** Base58 hash of the signed transaction. */
305
+ readonly hash: string;
306
+ constructor(hash: string, cause: unknown);
307
+ }
294
308
 
295
309
  /** True for a valid NEAR account id: 2–64 characters of the allowed alphabet, implicit or named. */
296
310
  declare function isValidAccountId(id: string): boolean;
@@ -393,7 +407,11 @@ declare function decodeAnyTransaction(bytes: Uint8Array): {
393
407
  /** Base64 helpers that work in Node, browsers and Hermes (no Buffer). */
394
408
  declare function toBase64(bytes: Uint8Array): string;
395
409
  declare function fromBase64(s: string): Uint8Array;
396
- /** One transport, or a failover transport over the list. */
410
+ /**
411
+ * One transport, or a failover transport over the list. Reads fail over on anything but a
412
+ * definitive node answer; a broadcast is sent once — the account turns an unanswered one into
413
+ * `BroadcastUnknownError`.
414
+ */
397
415
  declare function createClient(config: NearConfig): NearFetch | undefined;
398
416
  interface RawAccountView {
399
417
  amount: string;
@@ -631,15 +649,15 @@ declare class WalletAccountNear extends WalletAccountReadOnlyNear implements IWa
631
649
  /** Build → hard checks → preflight → fee cap. Shared by sign / send / transfer. */
632
650
  private prepare;
633
651
  /** Build, check, preflight and sign; returns the signed transaction as base64 borsh (what `send_tx` takes). */
634
- signTransaction(tx: NearTransaction | string): Promise<string>;
652
+ signTransaction(tx: NearTransaction | string, options?: WriteOptions): Promise<string>;
635
653
  private broadcast;
636
654
  /**
637
655
  * Sign and broadcast. Accepts a transaction, or base64 borsh of an unsigned /
638
656
  * already-signed transaction (a signed one is checked, not re-signed).
639
657
  */
640
- sendTransaction(tx: NearTransaction | string): Promise<NearTransferResult>;
658
+ sendTransaction(tx: NearTransaction | string, options?: WriteOptions): Promise<NearTransferResult>;
641
659
  /** Native NEAR (no `token`) or NEP-141 `ft_transfer` (with `storage_deposit` when the recipient needs it). */
642
- transfer(o: NearTransferOptions): Promise<NearTransferResult>;
660
+ transfer(o: NearTransferOptions, writeOptions?: WriteOptions): Promise<NearTransferResult>;
643
661
  /** The same account as a {@link WalletAccountReadOnlyNear}. */
644
662
  toReadOnlyAccount(): IWalletAccountReadOnly;
645
663
  /** Dispose the signer (zeroizes a local key). Idempotent. */
@@ -674,4 +692,4 @@ declare class WalletManagerNear extends WalletManager<WalletAccountNear, NearCon
674
692
  getFeeRates(): Promise<FeeRates>;
675
693
  }
676
694
 
677
- export { ACTION_TAG, BorshReader, BorshWriter, CAIP2, DANGEROUS_ACTIONS, type DescribeContext, FT_TRANSFER_GAS, IMPLICIT_ACCOUNT_MIN_DEPOSIT, MAX_GAS, NEAR_BASE_PATH, NEP413_PREFIX, type NearAccessKey, type NearAccountView, type NearAction, type NearAddKeyAction, type NearBuiltTransaction, type NearConfig, type NearCreateAccountAction, type NearDelegateAction, type NearDeleteAccountAction, type NearDeleteKeyAction, type NearDeployContractAction, type NearDeployGlobalContractAction, type NearFeeEstimate, type NearFetch, type NearFunctionCallAction, type NearProvider, type NearPublicKey, type NearQuote, type NearReceipt, NearRpc, NearRpcError, type NearSignature, type NearSignedDelegateAction, type NearSignedTransaction, type NearSimulation, type NearStakeAction, type NearTransaction, type NearTransferAction, type NearTransferOptions, type NearTransferResult, type NearTxDescription, type NearTxKind, type NearTxWarning, type NearTxWarningCode, type NearUseGlobalContractAction, type Nep413Payload, type Nep413Signed, ONE_YOCTO, STORAGE_DEPOSIT_GAS, STORAGE_PRICE_PER_BYTE, SimulationError, TGAS, type UnsafeTransactionCode, UnsafeTransactionError, WalletAccountNear, WalletAccountReadOnlyNear, WalletManagerNear, YOCTO, actionKey, argsBytes, base58ToBytes, bytesToBase58, createClient, decodeAnyTransaction, decodeSignedTransaction, decodeTransaction, WalletManagerNear as default, describeTransaction, ed25519Key, encodeSignedTransaction, encodeTransaction, failureOf, fromBase64, implicitAccountId, isDangerous, isImplicitAccountId, isValidAccountId, nep413Bytes, nep413Hash, outcomeFailed, parsePublicKey, parseSignature, publicKeyOfImplicit, publicKeyToString, readAction, readPublicKey, readSignature, receiptOf, toBase64, writeAction, writePublicKey, writeSignature };
695
+ export { ACTION_TAG, BorshReader, BorshWriter, BroadcastUnknownError, CAIP2, DANGEROUS_ACTIONS, type DescribeContext, FT_TRANSFER_GAS, IMPLICIT_ACCOUNT_MIN_DEPOSIT, MAX_GAS, NEAR_BASE_PATH, NEP413_PREFIX, type NearAccessKey, type NearAccountView, type NearAction, type NearAddKeyAction, type NearBuiltTransaction, type NearConfig, type NearCreateAccountAction, type NearDelegateAction, type NearDeleteAccountAction, type NearDeleteKeyAction, type NearDeployContractAction, type NearDeployGlobalContractAction, type NearFeeEstimate, type NearFetch, type NearFunctionCallAction, type NearProvider, type NearPublicKey, type NearQuote, type NearReceipt, NearRpc, NearRpcError, type NearSignature, type NearSignedDelegateAction, type NearSignedTransaction, type NearSimulation, type NearStakeAction, type NearTransaction, type NearTransferAction, type NearTransferOptions, type NearTransferResult, type NearTxDescription, type NearTxKind, type NearTxWarning, type NearTxWarningCode, type NearUseGlobalContractAction, type Nep413Payload, type Nep413Signed, ONE_YOCTO, STORAGE_DEPOSIT_GAS, STORAGE_PRICE_PER_BYTE, SimulationError, TGAS, type UnsafeTransactionCode, UnsafeTransactionError, WalletAccountNear, WalletAccountReadOnlyNear, WalletManagerNear, YOCTO, actionKey, argsBytes, base58ToBytes, bytesToBase58, createClient, decodeAnyTransaction, decodeSignedTransaction, decodeTransaction, WalletManagerNear as default, describeTransaction, ed25519Key, encodeSignedTransaction, encodeTransaction, failureOf, fromBase64, implicitAccountId, isDangerous, isImplicitAccountId, isValidAccountId, nep413Bytes, nep413Hash, outcomeFailed, parsePublicKey, parseSignature, publicKeyOfImplicit, publicKeyToString, readAction, readPublicKey, readSignature, receiptOf, toBase64, writeAction, writePublicKey, writeSignature };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IWalletAccountReadOnly, TransferResult, IWalletAccount, Signer, WalletManager, FeeRates } from '@anywalletkit/core';
1
+ import { IWalletAccountReadOnly, TransferResult, IWalletAccount, Signer, WriteOptions, WalletManager, FeeRates } from '@anywalletkit/core';
2
2
  export { HistoryFetch, HistoryUnavailableError, NearChainTx, NearHistoryCursor, NearHistoryOptions, NearHistoryPage, NearHistoryRaw, NearHistorySource, NearblocksFtRow, NearblocksReceiptRow, NearblocksTxn, RpcTxStatus, createNearHistory, decodeFunctionCallArgs, decodeCursor as decodeHistoryCursor, encodeCursor as encodeHistoryCursor, mapNearblocksGroup, mapNearblocksTxn, mapRpcTxStatus, nearExplorerTxUrl, parseJsonPreservingBigInts } from './history.js';
3
3
 
4
4
  /** JSON-RPC transport: `method` + `params`, returns the `result` (throws on `error`). */
@@ -16,6 +16,8 @@ interface NearConfig {
16
16
  retries?: number;
17
17
  /** Optional headers for every request (e.g. an API key). */
18
18
  headers?: Record<string, string>;
19
+ /** Per-request timeout for url providers, in ms (default 15 000): a node that never answers fails over (reads) or ends as "maybe sent" (`send_tx`). */
20
+ timeoutMs?: number;
19
21
  /** "mainnet" (default) | "testnet" | any CAIP-2 suffix. */
20
22
  network?: 'mainnet' | 'testnet' | string;
21
23
  /** Max fee (yoctoNEAR) for `transfer`. */
@@ -291,6 +293,18 @@ declare class NearRpcError extends Error {
291
293
  code?: number;
292
294
  });
293
295
  }
296
+ /**
297
+ * The signed transaction was handed to the RPC but no definitive answer came back (no response, or
298
+ * a node timeout): it MAY be on chain. Do not sign it again (a new nonce would pay twice) — watch
299
+ * `hash`, computed locally.
300
+ */
301
+ declare class BroadcastUnknownError extends Error {
302
+ /** Always true: the transaction may be on its way. */
303
+ readonly maybeSent = true;
304
+ /** Base58 hash of the signed transaction. */
305
+ readonly hash: string;
306
+ constructor(hash: string, cause: unknown);
307
+ }
294
308
 
295
309
  /** True for a valid NEAR account id: 2–64 characters of the allowed alphabet, implicit or named. */
296
310
  declare function isValidAccountId(id: string): boolean;
@@ -393,7 +407,11 @@ declare function decodeAnyTransaction(bytes: Uint8Array): {
393
407
  /** Base64 helpers that work in Node, browsers and Hermes (no Buffer). */
394
408
  declare function toBase64(bytes: Uint8Array): string;
395
409
  declare function fromBase64(s: string): Uint8Array;
396
- /** One transport, or a failover transport over the list. */
410
+ /**
411
+ * One transport, or a failover transport over the list. Reads fail over on anything but a
412
+ * definitive node answer; a broadcast is sent once — the account turns an unanswered one into
413
+ * `BroadcastUnknownError`.
414
+ */
397
415
  declare function createClient(config: NearConfig): NearFetch | undefined;
398
416
  interface RawAccountView {
399
417
  amount: string;
@@ -631,15 +649,15 @@ declare class WalletAccountNear extends WalletAccountReadOnlyNear implements IWa
631
649
  /** Build → hard checks → preflight → fee cap. Shared by sign / send / transfer. */
632
650
  private prepare;
633
651
  /** Build, check, preflight and sign; returns the signed transaction as base64 borsh (what `send_tx` takes). */
634
- signTransaction(tx: NearTransaction | string): Promise<string>;
652
+ signTransaction(tx: NearTransaction | string, options?: WriteOptions): Promise<string>;
635
653
  private broadcast;
636
654
  /**
637
655
  * Sign and broadcast. Accepts a transaction, or base64 borsh of an unsigned /
638
656
  * already-signed transaction (a signed one is checked, not re-signed).
639
657
  */
640
- sendTransaction(tx: NearTransaction | string): Promise<NearTransferResult>;
658
+ sendTransaction(tx: NearTransaction | string, options?: WriteOptions): Promise<NearTransferResult>;
641
659
  /** Native NEAR (no `token`) or NEP-141 `ft_transfer` (with `storage_deposit` when the recipient needs it). */
642
- transfer(o: NearTransferOptions): Promise<NearTransferResult>;
660
+ transfer(o: NearTransferOptions, writeOptions?: WriteOptions): Promise<NearTransferResult>;
643
661
  /** The same account as a {@link WalletAccountReadOnlyNear}. */
644
662
  toReadOnlyAccount(): IWalletAccountReadOnly;
645
663
  /** Dispose the signer (zeroizes a local key). Idempotent. */
@@ -674,4 +692,4 @@ declare class WalletManagerNear extends WalletManager<WalletAccountNear, NearCon
674
692
  getFeeRates(): Promise<FeeRates>;
675
693
  }
676
694
 
677
- export { ACTION_TAG, BorshReader, BorshWriter, CAIP2, DANGEROUS_ACTIONS, type DescribeContext, FT_TRANSFER_GAS, IMPLICIT_ACCOUNT_MIN_DEPOSIT, MAX_GAS, NEAR_BASE_PATH, NEP413_PREFIX, type NearAccessKey, type NearAccountView, type NearAction, type NearAddKeyAction, type NearBuiltTransaction, type NearConfig, type NearCreateAccountAction, type NearDelegateAction, type NearDeleteAccountAction, type NearDeleteKeyAction, type NearDeployContractAction, type NearDeployGlobalContractAction, type NearFeeEstimate, type NearFetch, type NearFunctionCallAction, type NearProvider, type NearPublicKey, type NearQuote, type NearReceipt, NearRpc, NearRpcError, type NearSignature, type NearSignedDelegateAction, type NearSignedTransaction, type NearSimulation, type NearStakeAction, type NearTransaction, type NearTransferAction, type NearTransferOptions, type NearTransferResult, type NearTxDescription, type NearTxKind, type NearTxWarning, type NearTxWarningCode, type NearUseGlobalContractAction, type Nep413Payload, type Nep413Signed, ONE_YOCTO, STORAGE_DEPOSIT_GAS, STORAGE_PRICE_PER_BYTE, SimulationError, TGAS, type UnsafeTransactionCode, UnsafeTransactionError, WalletAccountNear, WalletAccountReadOnlyNear, WalletManagerNear, YOCTO, actionKey, argsBytes, base58ToBytes, bytesToBase58, createClient, decodeAnyTransaction, decodeSignedTransaction, decodeTransaction, WalletManagerNear as default, describeTransaction, ed25519Key, encodeSignedTransaction, encodeTransaction, failureOf, fromBase64, implicitAccountId, isDangerous, isImplicitAccountId, isValidAccountId, nep413Bytes, nep413Hash, outcomeFailed, parsePublicKey, parseSignature, publicKeyOfImplicit, publicKeyToString, readAction, readPublicKey, readSignature, receiptOf, toBase64, writeAction, writePublicKey, writeSignature };
695
+ export { ACTION_TAG, BorshReader, BorshWriter, BroadcastUnknownError, CAIP2, DANGEROUS_ACTIONS, type DescribeContext, FT_TRANSFER_GAS, IMPLICIT_ACCOUNT_MIN_DEPOSIT, MAX_GAS, NEAR_BASE_PATH, NEP413_PREFIX, type NearAccessKey, type NearAccountView, type NearAction, type NearAddKeyAction, type NearBuiltTransaction, type NearConfig, type NearCreateAccountAction, type NearDelegateAction, type NearDeleteAccountAction, type NearDeleteKeyAction, type NearDeployContractAction, type NearDeployGlobalContractAction, type NearFeeEstimate, type NearFetch, type NearFunctionCallAction, type NearProvider, type NearPublicKey, type NearQuote, type NearReceipt, NearRpc, NearRpcError, type NearSignature, type NearSignedDelegateAction, type NearSignedTransaction, type NearSimulation, type NearStakeAction, type NearTransaction, type NearTransferAction, type NearTransferOptions, type NearTransferResult, type NearTxDescription, type NearTxKind, type NearTxWarning, type NearTxWarningCode, type NearUseGlobalContractAction, type Nep413Payload, type Nep413Signed, ONE_YOCTO, STORAGE_DEPOSIT_GAS, STORAGE_PRICE_PER_BYTE, SimulationError, TGAS, type UnsafeTransactionCode, UnsafeTransactionError, WalletAccountNear, WalletAccountReadOnlyNear, WalletManagerNear, YOCTO, actionKey, argsBytes, base58ToBytes, bytesToBase58, createClient, decodeAnyTransaction, decodeSignedTransaction, decodeTransaction, WalletManagerNear as default, describeTransaction, ed25519Key, encodeSignedTransaction, encodeTransaction, failureOf, fromBase64, implicitAccountId, isDangerous, isImplicitAccountId, isValidAccountId, nep413Bytes, nep413Hash, outcomeFailed, parsePublicKey, parseSignature, publicKeyOfImplicit, publicKeyToString, readAction, readPublicKey, readSignature, receiptOf, toBase64, writeAction, writePublicKey, writeSignature };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ BroadcastUnknownError,
2
3
  CAIP2,
3
4
  FT_TRANSFER_GAS,
4
5
  HistoryUnavailableError,
@@ -20,6 +21,7 @@ import {
20
21
  encodeCursor,
21
22
  failureOf,
22
23
  fromBase64,
24
+ isDefinitive,
23
25
  mapNearblocksGroup,
24
26
  mapNearblocksTxn,
25
27
  mapRpcTxStatus,
@@ -27,7 +29,7 @@ import {
27
29
  outcomeFailed,
28
30
  parseJsonPreservingBigInts,
29
31
  toBase64
30
- } from "./chunk-2GH6U3LB.js";
32
+ } from "./chunk-6YJS2IMU.js";
31
33
 
32
34
  // src/address.ts
33
35
  import { base58 } from "@scure/base";
@@ -856,7 +858,7 @@ function equalBytes(a, b) {
856
858
  }
857
859
 
858
860
  // src/account.ts
859
- import { LocalSigner, SignerError, requireCurve } from "@anywalletkit/core";
861
+ import { LocalSigner, SignerError, feeLimit, requireCurve } from "@anywalletkit/core";
860
862
  var WalletAccountNear = class _WalletAccountNear extends WalletAccountReadOnlyNear {
861
863
  /** nonce / block hash come from the node, so building needs the network. */
862
864
  needsNetwork = true;
@@ -920,15 +922,22 @@ var WalletAccountNear = class _WalletAccountNear extends WalletAccountReadOnlyNe
920
922
  return { built, estimate };
921
923
  }
922
924
  /** Build, check, preflight and sign; returns the signed transaction as base64 borsh (what `send_tx` takes). */
923
- async signTransaction(tx) {
925
+ async signTransaction(tx, options = {}) {
924
926
  this.key();
925
927
  this.requireRpc("sign transactions");
926
- const { built } = await this.prepare(tx, this._config.transactionMaxFee, "transaction");
928
+ const { built } = await this.prepare(tx, feeLimit(this._config.transactionMaxFee, options), "transaction");
927
929
  return toBase64(encodeSignedTransaction(await this.signBuilt(built)));
928
930
  }
929
931
  async broadcast(signed) {
930
932
  const hash = WalletAccountReadOnlyNear.txHash(signed.transaction);
931
- const outcome = await this.requireRpc("broadcast").sendTx(toBase64(encodeSignedTransaction(signed)));
933
+ const rpc = this.requireRpc("broadcast");
934
+ let outcome;
935
+ try {
936
+ outcome = await rpc.sendTx(toBase64(encodeSignedTransaction(signed)));
937
+ } catch (e) {
938
+ if (isDefinitive(e)) throw e;
939
+ throw new BroadcastUnknownError(hash, e);
940
+ }
932
941
  const failure = outcomeFailed(outcome);
933
942
  if (failure) throw new Error(`Transaction ${hash} failed on chain: ${failure}`);
934
943
  return outcome.transaction?.hash ?? hash;
@@ -937,19 +946,19 @@ var WalletAccountNear = class _WalletAccountNear extends WalletAccountReadOnlyNe
937
946
  * Sign and broadcast. Accepts a transaction, or base64 borsh of an unsigned /
938
947
  * already-signed transaction (a signed one is checked, not re-signed).
939
948
  */
940
- async sendTransaction(tx) {
949
+ async sendTransaction(tx, options = {}) {
941
950
  this.key();
942
951
  this.requireRpc("send transactions");
943
952
  const presigned = typeof tx === "string" ? decodeSigned(tx) : void 0;
944
- const { built, estimate } = await this.prepare(tx, this._config.transactionMaxFee, "transaction");
953
+ const { built, estimate } = await this.prepare(tx, feeLimit(this._config.transactionMaxFee, options), "transaction");
945
954
  const signed = presigned ?? await this.signBuilt(built);
946
955
  return { hash: await this.broadcast(signed), fee: estimate.fee, estimate };
947
956
  }
948
957
  /** Native NEAR (no `token`) or NEP-141 `ft_transfer` (with `storage_deposit` when the recipient needs it). */
949
- async transfer(o) {
958
+ async transfer(o, writeOptions = {}) {
950
959
  this.key();
951
960
  this.requireRpc("transfer tokens");
952
- const { built, estimate } = await this.prepare(await this.transferActions(o), this._config.transferMaxFee, "transfer");
961
+ const { built, estimate } = await this.prepare(await this.transferActions(o), feeLimit(this._config.transferMaxFee, writeOptions), "transfer");
953
962
  return { hash: await this.broadcast(await this.signBuilt(built)), fee: estimate.fee, estimate };
954
963
  }
955
964
  /** The same account as a {@link WalletAccountReadOnlyNear}. */
@@ -985,10 +994,10 @@ var WalletManagerNear = class extends WalletManager {
985
994
  if (cached) return cached;
986
995
  const external = this.externalSigner();
987
996
  if (external) return this.fromSigner(external, full);
988
- const signer = LocalSigner2.leafFromSeed(this.seedBytes(), "ed25519", full);
989
- const account = new WalletAccountNear(signer, signer.publicKey, full, this._config);
990
- this._accounts.set(full, account);
991
- return account;
997
+ return this.cachedAccount(full, () => {
998
+ const signer = LocalSigner2.leafFromSeed(this.seedBytes(), "ed25519", full);
999
+ return new WalletAccountNear(signer, signer.publicKey, full, this._config);
1000
+ });
992
1001
  }
993
1002
  /** The key of account `index`, bound to a named account that lists it as a full-access key. */
994
1003
  async getNamedAccount(accountId, index = 0) {
@@ -997,22 +1006,18 @@ var WalletManagerNear = class extends WalletManager {
997
1006
  /** Resolve `path` against an injected signer: the signer itself, or a child when it can derive there. */
998
1007
  async fromSigner(signer, path) {
999
1008
  this.requireSigner("ed25519");
1000
- let leaf = signer;
1009
+ let rel;
1001
1010
  let key = "external";
1002
1011
  if (isSeedSigner(signer)) {
1003
1012
  if (path === signer.path) key = path;
1004
1013
  else if (path.startsWith(`${signer.path}/`)) {
1005
- leaf = await (signer.deriveLeaf ?? signer.derive).call(signer, path.slice(signer.path.length + 1));
1014
+ rel = path.slice(signer.path.length + 1);
1006
1015
  key = path;
1007
1016
  } else throw new SignerError2(`The injected signer sits at ${signer.path}; it cannot provide ${path}.`);
1008
1017
  } else if (path !== `${NEAR_BASE_PATH}/0'` && path !== "external") {
1009
1018
  throw new SignerError2(`An external signer has one account; ${path} is not derivable from it.`);
1010
1019
  }
1011
- const cached = this._accounts.get(key);
1012
- if (cached) return cached;
1013
- const account = new WalletAccountNear(leaf, await leaf.getPublicKey(), key, this._config);
1014
- this._accounts.set(key, account);
1015
- return account;
1020
+ return this.signerAccount(key, signer, rel, (leaf, publicKey) => new WalletAccountNear(leaf, publicKey, key, this._config));
1016
1021
  }
1017
1022
  /** A read-only account for any account id, with this manager's config. */
1018
1023
  getReadOnlyAccount(accountId, publicKey) {
@@ -1030,6 +1035,7 @@ export {
1030
1035
  ACTION_TAG,
1031
1036
  BorshReader,
1032
1037
  BorshWriter,
1038
+ BroadcastUnknownError,
1033
1039
  CAIP2,
1034
1040
  DANGEROUS_ACTIONS,
1035
1041
  FT_TRANSFER_GAS,