@t402/near 2.3.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 (38) hide show
  1. package/README.md +173 -0
  2. package/dist/cjs/exact-direct/client/index.d.ts +105 -0
  3. package/dist/cjs/exact-direct/client/index.js +156 -0
  4. package/dist/cjs/exact-direct/client/index.js.map +1 -0
  5. package/dist/cjs/exact-direct/facilitator/index.d.ts +114 -0
  6. package/dist/cjs/exact-direct/facilitator/index.js +304 -0
  7. package/dist/cjs/exact-direct/facilitator/index.js.map +1 -0
  8. package/dist/cjs/exact-direct/server/index.d.ts +129 -0
  9. package/dist/cjs/exact-direct/server/index.js +253 -0
  10. package/dist/cjs/exact-direct/server/index.js.map +1 -0
  11. package/dist/cjs/index.d.ts +226 -0
  12. package/dist/cjs/index.js +711 -0
  13. package/dist/cjs/index.js.map +1 -0
  14. package/dist/cjs/types-Ca7ztL_f.d.ts +169 -0
  15. package/dist/esm/chunk-B3RHERRA.mjs +162 -0
  16. package/dist/esm/chunk-B3RHERRA.mjs.map +1 -0
  17. package/dist/esm/chunk-BU2BQECZ.mjs +206 -0
  18. package/dist/esm/chunk-BU2BQECZ.mjs.map +1 -0
  19. package/dist/esm/chunk-G35SAYZI.mjs +67 -0
  20. package/dist/esm/chunk-G35SAYZI.mjs.map +1 -0
  21. package/dist/esm/chunk-WANNPL6S.mjs +155 -0
  22. package/dist/esm/chunk-WANNPL6S.mjs.map +1 -0
  23. package/dist/esm/chunk-YXBOH4MJ.mjs +103 -0
  24. package/dist/esm/chunk-YXBOH4MJ.mjs.map +1 -0
  25. package/dist/esm/exact-direct/client/index.d.mts +105 -0
  26. package/dist/esm/exact-direct/client/index.mjs +10 -0
  27. package/dist/esm/exact-direct/client/index.mjs.map +1 -0
  28. package/dist/esm/exact-direct/facilitator/index.d.mts +114 -0
  29. package/dist/esm/exact-direct/facilitator/index.mjs +11 -0
  30. package/dist/esm/exact-direct/facilitator/index.mjs.map +1 -0
  31. package/dist/esm/exact-direct/server/index.d.mts +129 -0
  32. package/dist/esm/exact-direct/server/index.mjs +11 -0
  33. package/dist/esm/exact-direct/server/index.mjs.map +1 -0
  34. package/dist/esm/index.d.mts +226 -0
  35. package/dist/esm/index.mjs +97 -0
  36. package/dist/esm/index.mjs.map +1 -0
  37. package/dist/esm/types-Ca7ztL_f.d.mts +169 -0
  38. package/package.json +97 -0
@@ -0,0 +1,105 @@
1
+ import { SchemeNetworkClient, PaymentRequirements, PaymentPayload, Network } from '@t402/core/types';
2
+ import { C as ClientNearSigner } from '../../types-Ca7ztL_f.mjs';
3
+ import { t402Client, PaymentPolicy } from '@t402/core/client';
4
+
5
+ /**
6
+ * NEAR Client Scheme Implementation - Exact Direct
7
+ *
8
+ * Creates payment payloads for NEAR NEP-141 transfers using the exact-direct scheme.
9
+ * In this scheme, the client executes the ft_transfer directly and provides
10
+ * the transaction hash as proof of payment.
11
+ */
12
+
13
+ /**
14
+ * Configuration for ExactDirectNearClient
15
+ */
16
+ interface ExactDirectNearClientConfig {
17
+ /** Override the gas amount for ft_transfer */
18
+ gasAmount?: string;
19
+ /** Optional memo to include in the transfer */
20
+ memo?: string;
21
+ }
22
+ /**
23
+ * NEAR client implementation for the Exact-Direct payment scheme.
24
+ *
25
+ * Executes NEP-141 ft_transfer and returns the transaction hash as proof.
26
+ */
27
+ declare class ExactDirectNearClient implements SchemeNetworkClient {
28
+ private readonly signer;
29
+ private readonly config;
30
+ readonly scheme = "exact-direct";
31
+ /**
32
+ * Creates a new ExactDirectNearScheme instance.
33
+ *
34
+ * @param signer - The NEAR signer for client operations
35
+ * @param config - Optional configuration overrides
36
+ */
37
+ constructor(signer: ClientNearSigner, config?: ExactDirectNearClientConfig);
38
+ /**
39
+ * Creates a payment payload by executing the transfer.
40
+ *
41
+ * Unlike other schemes where the client creates a signed message for
42
+ * the facilitator to execute, the exact-direct scheme has the client
43
+ * execute the transfer directly. The transaction hash is then used
44
+ * as proof of payment.
45
+ *
46
+ * @param t402Version - The t402 protocol version
47
+ * @param paymentRequirements - The payment requirements
48
+ * @returns Promise resolving to a payment payload with transaction hash
49
+ */
50
+ createPaymentPayload(t402Version: number, paymentRequirements: PaymentRequirements): Promise<Pick<PaymentPayload, "t402Version" | "payload">>;
51
+ }
52
+
53
+ /**
54
+ * Registration function for NEAR Exact-Direct client
55
+ */
56
+
57
+ /**
58
+ * Configuration options for registering NEAR schemes to a t402Client
59
+ */
60
+ interface NearClientConfig {
61
+ /**
62
+ * The NEAR signer to use for creating payment payloads
63
+ */
64
+ signer: ClientNearSigner;
65
+ /**
66
+ * Optional policies to apply to the client
67
+ */
68
+ policies?: PaymentPolicy[];
69
+ /**
70
+ * Optional specific networks to register
71
+ * If not provided, registers wildcard support (near:*)
72
+ */
73
+ networks?: Network[];
74
+ /**
75
+ * Optional scheme configuration (gas amounts, memo)
76
+ */
77
+ schemeConfig?: ExactDirectNearClientConfig;
78
+ }
79
+ /**
80
+ * Registers NEAR exact-direct payment schemes to a t402Client instance.
81
+ *
82
+ * @param client - The t402Client instance to register schemes to
83
+ * @param config - Configuration for NEAR client registration
84
+ * @returns The client instance for chaining
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * import { registerExactDirectNearClient } from "@t402/near/exact-direct/client";
89
+ * import { t402Client } from "@t402/core/client";
90
+ *
91
+ * const client = new t402Client();
92
+ * registerExactDirectNearClient(client, {
93
+ * signer: {
94
+ * accountId: "alice.near",
95
+ * signAndSendTransaction: async (receiverId, methodName, args, gas, deposit) => {
96
+ * // Sign and send using wallet
97
+ * return txHash;
98
+ * }
99
+ * }
100
+ * });
101
+ * ```
102
+ */
103
+ declare function registerExactDirectNearClient(client: t402Client, config: NearClientConfig): t402Client;
104
+
105
+ export { ExactDirectNearClient, type ExactDirectNearClientConfig, type NearClientConfig, registerExactDirectNearClient };
@@ -0,0 +1,10 @@
1
+ import {
2
+ ExactDirectNearClient,
3
+ registerExactDirectNearClient
4
+ } from "../../chunk-YXBOH4MJ.mjs";
5
+ import "../../chunk-WANNPL6S.mjs";
6
+ export {
7
+ ExactDirectNearClient,
8
+ registerExactDirectNearClient
9
+ };
10
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,114 @@
1
+ import { SchemeNetworkFacilitator, Network, PaymentPayload, PaymentRequirements, VerifyResponse, SettleResponse } from '@t402/core/types';
2
+ import { f as FacilitatorNearSigner } from '../../types-Ca7ztL_f.mjs';
3
+ import { t402Facilitator } from '@t402/core/facilitator';
4
+
5
+ /**
6
+ * NEAR Facilitator Scheme Implementation - Exact Direct
7
+ *
8
+ * Verifies and settles NEAR NEP-141 payments using the exact-direct scheme.
9
+ * The facilitator verifies that the client's transaction was successful
10
+ * and matches the payment requirements.
11
+ */
12
+
13
+ /**
14
+ * Configuration for ExactDirectNearFacilitator
15
+ */
16
+ interface ExactDirectNearFacilitatorConfig {
17
+ /** Maximum age of a transaction to accept (in milliseconds) */
18
+ maxTransactionAge?: number;
19
+ /** Duration to cache used transaction hashes (in milliseconds) */
20
+ usedTxCacheDuration?: number;
21
+ }
22
+ /**
23
+ * NEAR facilitator implementation for the Exact-Direct payment scheme.
24
+ * Verifies transaction proofs and confirms payments.
25
+ */
26
+ declare class ExactDirectNearFacilitator implements SchemeNetworkFacilitator {
27
+ private readonly signer;
28
+ readonly scheme = "exact-direct";
29
+ readonly caipFamily = "near:*";
30
+ private readonly config;
31
+ private usedTxs;
32
+ constructor(signer: FacilitatorNearSigner, config?: ExactDirectNearFacilitatorConfig);
33
+ /**
34
+ * Get extra data for a supported kind
35
+ */
36
+ getExtra(network: Network): Record<string, unknown> | undefined;
37
+ /**
38
+ * Get signer addresses for a network
39
+ */
40
+ getSigners(network: Network): string[];
41
+ /**
42
+ * Verify a payment payload
43
+ */
44
+ verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
45
+ /**
46
+ * Settle a payment - for exact-direct, the transfer is already complete
47
+ */
48
+ settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
49
+ /**
50
+ * Check if a transaction has been used
51
+ */
52
+ private isTxUsed;
53
+ /**
54
+ * Mark a transaction as used
55
+ */
56
+ private markTxUsed;
57
+ /**
58
+ * Start the cleanup interval for used transactions
59
+ */
60
+ private startCleanupInterval;
61
+ }
62
+
63
+ /**
64
+ * Registration function for NEAR Exact-Direct facilitator
65
+ */
66
+
67
+ /**
68
+ * Configuration options for registering NEAR schemes to a t402Facilitator
69
+ */
70
+ interface NearFacilitatorConfig {
71
+ /**
72
+ * The NEAR signer for facilitator operations (verify and settle)
73
+ */
74
+ signer: FacilitatorNearSigner;
75
+ /**
76
+ * Networks to register (single network or array of networks)
77
+ * Examples: "near:mainnet", ["near:mainnet", "near:testnet"]
78
+ */
79
+ networks: Network | Network[];
80
+ /**
81
+ * Optional scheme configuration
82
+ */
83
+ schemeConfig?: ExactDirectNearFacilitatorConfig;
84
+ }
85
+ /**
86
+ * Registers NEAR exact-direct payment schemes to a t402Facilitator instance.
87
+ *
88
+ * @param facilitator - The t402Facilitator instance to register schemes to
89
+ * @param config - Configuration for NEAR facilitator registration
90
+ * @returns The facilitator instance for chaining
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * import { registerExactDirectNearFacilitator } from "@t402/near/exact-direct/facilitator";
95
+ * import { t402Facilitator } from "@t402/core/facilitator";
96
+ *
97
+ * const facilitator = new t402Facilitator();
98
+ *
99
+ * // Single network
100
+ * registerExactDirectNearFacilitator(facilitator, {
101
+ * signer: myNearSigner,
102
+ * networks: "near:mainnet"
103
+ * });
104
+ *
105
+ * // Multiple networks
106
+ * registerExactDirectNearFacilitator(facilitator, {
107
+ * signer: myNearSigner,
108
+ * networks: ["near:mainnet", "near:testnet"]
109
+ * });
110
+ * ```
111
+ */
112
+ declare function registerExactDirectNearFacilitator(facilitator: t402Facilitator, config: NearFacilitatorConfig): t402Facilitator;
113
+
114
+ export { ExactDirectNearFacilitator, type ExactDirectNearFacilitatorConfig, type NearFacilitatorConfig, registerExactDirectNearFacilitator };
@@ -0,0 +1,11 @@
1
+ import {
2
+ ExactDirectNearFacilitator,
3
+ registerExactDirectNearFacilitator
4
+ } from "../../chunk-BU2BQECZ.mjs";
5
+ import "../../chunk-G35SAYZI.mjs";
6
+ import "../../chunk-WANNPL6S.mjs";
7
+ export {
8
+ ExactDirectNearFacilitator,
9
+ registerExactDirectNearFacilitator
10
+ };
11
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,129 @@
1
+ import { SchemeNetworkServer, MoneyParser, Price, Network, AssetAmount, PaymentRequirements } from '@t402/core/types';
2
+ import { t402ResourceServer } from '@t402/core/server';
3
+
4
+ /**
5
+ * NEAR Server Scheme Implementation - Exact Direct
6
+ *
7
+ * Handles price parsing and payment requirement enhancement for
8
+ * NEAR NEP-141 payments using the exact-direct scheme.
9
+ */
10
+
11
+ /**
12
+ * Configuration options for ExactDirectNearServer
13
+ */
14
+ interface ExactDirectNearServerConfig {
15
+ /** Preferred token symbol (e.g., "USDC"). Defaults to network's highest priority token. */
16
+ preferredToken?: string;
17
+ }
18
+ /**
19
+ * NEAR server implementation for the Exact-Direct payment scheme.
20
+ * Handles price parsing and converts user-friendly amounts to token amounts.
21
+ */
22
+ declare class ExactDirectNearServer implements SchemeNetworkServer {
23
+ readonly scheme = "exact-direct";
24
+ private moneyParsers;
25
+ private config;
26
+ constructor(config?: ExactDirectNearServerConfig);
27
+ /**
28
+ * Register a custom money parser in the parser chain.
29
+ * Multiple parsers can be registered - they will be tried in registration order.
30
+ * Each parser receives a decimal amount (e.g., 1.50 for $1.50).
31
+ * If a parser returns null, the next parser in the chain will be tried.
32
+ * The default parser is always the final fallback.
33
+ *
34
+ * @param parser - Custom function to convert amount to AssetAmount (or null to skip)
35
+ * @returns The server instance for chaining
36
+ */
37
+ registerMoneyParser(parser: MoneyParser): ExactDirectNearServer;
38
+ /**
39
+ * Parses a price into an asset amount.
40
+ * If price is already an AssetAmount, returns it directly.
41
+ * If price is Money (string | number), parses to decimal and tries custom parsers.
42
+ * Falls back to default conversion if all custom parsers return null.
43
+ *
44
+ * @param price - The price to parse
45
+ * @param network - The network to use
46
+ * @returns Promise that resolves to the parsed asset amount
47
+ */
48
+ parsePrice(price: Price, network: Network): Promise<AssetAmount>;
49
+ /**
50
+ * Build payment requirements for this scheme/network combination.
51
+ *
52
+ * @param paymentRequirements - Base payment requirements with amount/asset already set
53
+ * @param supportedKind - The supported kind from facilitator's /supported endpoint
54
+ * @param extensionKeys - Extensions supported by the facilitator
55
+ * @returns Enhanced payment requirements ready to be sent to clients
56
+ */
57
+ enhancePaymentRequirements(paymentRequirements: PaymentRequirements, supportedKind: {
58
+ t402Version: number;
59
+ scheme: string;
60
+ network: Network;
61
+ extra?: Record<string, unknown>;
62
+ }, extensionKeys: string[]): Promise<PaymentRequirements>;
63
+ /**
64
+ * Parse Money (string | number) to a decimal number.
65
+ * Handles formats like "$1.50", "1.50", 1.50, etc.
66
+ */
67
+ private parseMoneyToDecimal;
68
+ /**
69
+ * Default money conversion implementation.
70
+ * Converts decimal amount to the preferred token on the specified network.
71
+ */
72
+ private defaultMoneyConversion;
73
+ /**
74
+ * Get the default asset info for a network.
75
+ * Priority: configured preferredToken > network default
76
+ */
77
+ private getDefaultAsset;
78
+ /**
79
+ * Get all supported networks
80
+ */
81
+ static getSupportedNetworks(): string[];
82
+ /**
83
+ * Check if a network is supported
84
+ */
85
+ static isNetworkSupported(network: string): boolean;
86
+ }
87
+
88
+ /**
89
+ * Registration function for NEAR Exact-Direct server
90
+ */
91
+
92
+ /**
93
+ * Configuration options for registering NEAR schemes to a t402ResourceServer
94
+ */
95
+ interface NearResourceServerConfig {
96
+ /**
97
+ * Optional specific networks to register
98
+ * If not provided, registers wildcard support (near:*)
99
+ */
100
+ networks?: Network[];
101
+ /**
102
+ * Optional scheme configuration (preferred token, etc.)
103
+ */
104
+ schemeConfig?: ExactDirectNearServerConfig;
105
+ }
106
+ /**
107
+ * Registers NEAR exact-direct payment schemes to a t402ResourceServer instance.
108
+ *
109
+ * @param server - The t402ResourceServer instance to register schemes to
110
+ * @param config - Configuration for NEAR resource server registration
111
+ * @returns The server instance for chaining
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * import { registerExactDirectNearServer } from "@t402/near/exact-direct/server";
116
+ * import { t402ResourceServer } from "@t402/core/server";
117
+ *
118
+ * const server = new t402ResourceServer(facilitatorClient);
119
+ * registerExactDirectNearServer(server, {});
120
+ *
121
+ * // Or with specific token preference
122
+ * registerExactDirectNearServer(server, {
123
+ * schemeConfig: { preferredToken: "USDT" }
124
+ * });
125
+ * ```
126
+ */
127
+ declare function registerExactDirectNearServer(server: t402ResourceServer, config?: NearResourceServerConfig): t402ResourceServer;
128
+
129
+ export { ExactDirectNearServer, type ExactDirectNearServerConfig, type NearResourceServerConfig, registerExactDirectNearServer };
@@ -0,0 +1,11 @@
1
+ import {
2
+ ExactDirectNearServer,
3
+ registerExactDirectNearServer
4
+ } from "../../chunk-B3RHERRA.mjs";
5
+ import "../../chunk-G35SAYZI.mjs";
6
+ import "../../chunk-WANNPL6S.mjs";
7
+ export {
8
+ ExactDirectNearServer,
9
+ registerExactDirectNearServer
10
+ };
11
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,226 @@
1
+ import { N as NearRpcRequest, T as TransactionResult, F as FtTransferArgs } from './types-Ca7ztL_f.mjs';
2
+ export { C as ClientNearSigner, E as ExactDirectNearPayload, f as FacilitatorNearSigner, c as FunctionCallAction, e as NearRpcResponse, d as NearTransaction, b as TransactionOutcome, a as TransactionStatus, V as VerifyTransactionResult } from './types-Ca7ztL_f.mjs';
3
+ export { ExactDirectNearClient, ExactDirectNearClientConfig, NearClientConfig, registerExactDirectNearClient } from './exact-direct/client/index.mjs';
4
+ export { ExactDirectNearServer, ExactDirectNearServerConfig, NearResourceServerConfig, registerExactDirectNearServer } from './exact-direct/server/index.mjs';
5
+ export { ExactDirectNearFacilitator, ExactDirectNearFacilitatorConfig, NearFacilitatorConfig, registerExactDirectNearFacilitator } from './exact-direct/facilitator/index.mjs';
6
+ import '@t402/core/types';
7
+ import '@t402/core/client';
8
+ import '@t402/core/server';
9
+ import '@t402/core/facilitator';
10
+
11
+ /**
12
+ * NEAR Network Constants
13
+ *
14
+ * This module provides constants for NEAR blockchain integration including:
15
+ * - CAIP-2 network identifiers
16
+ * - RPC endpoints
17
+ * - NEP-141 function names
18
+ * - Default gas amounts
19
+ */
20
+ /**
21
+ * CAIP-2 Network Identifiers for NEAR
22
+ */
23
+ declare const NEAR_MAINNET_CAIP2 = "near:mainnet";
24
+ declare const NEAR_TESTNET_CAIP2 = "near:testnet";
25
+ /**
26
+ * Supported NEAR networks
27
+ */
28
+ declare const NEAR_NETWORKS: readonly ["near:mainnet", "near:testnet"];
29
+ type NearNetwork = (typeof NEAR_NETWORKS)[number];
30
+ /**
31
+ * NEAR network IDs (for wallet connection)
32
+ */
33
+ declare const NEAR_NETWORK_IDS: Record<string, string>;
34
+ /**
35
+ * Default RPC endpoints
36
+ */
37
+ declare const NEAR_MAINNET_RPC = "https://rpc.mainnet.near.org";
38
+ declare const NEAR_TESTNET_RPC = "https://rpc.testnet.near.org";
39
+ /**
40
+ * Network RPC endpoint mapping
41
+ */
42
+ declare const NETWORK_RPC_ENDPOINTS: Record<string, string>;
43
+ /**
44
+ * NEP-141 Fungible Token Standard function names
45
+ * @see https://nomicon.io/Standards/Tokens/FungibleToken/Core
46
+ */
47
+ declare const NEP141_FT_TRANSFER = "ft_transfer";
48
+ declare const NEP141_FT_BALANCE_OF = "ft_balance_of";
49
+ declare const NEP141_STORAGE_DEPOSIT = "storage_deposit";
50
+ declare const NEP141_STORAGE_BALANCE_OF = "storage_balance_of";
51
+ /**
52
+ * Default gas amounts for NEP-141 transfers
53
+ * NEAR gas is measured in TGas (1 TGas = 10^12 gas)
54
+ */
55
+ declare const DEFAULT_FT_TRANSFER_GAS = "30000000000000";
56
+ declare const DEFAULT_STORAGE_DEPOSIT_GAS = "10000000000000";
57
+ /**
58
+ * Required deposits for NEP-141 operations
59
+ * ft_transfer requires 1 yoctoNEAR attached deposit
60
+ */
61
+ declare const FT_TRANSFER_DEPOSIT = "1";
62
+ declare const DEFAULT_STORAGE_DEPOSIT = "1250000000000000000000";
63
+ /**
64
+ * Scheme identifier for exact-direct payments
65
+ */
66
+ declare const SCHEME_EXACT_DIRECT = "exact-direct";
67
+ /**
68
+ * Default timeout for payment validity (in seconds)
69
+ */
70
+ declare const DEFAULT_VALIDITY_DURATION = 3600;
71
+ /**
72
+ * Maximum transaction age to accept (in milliseconds)
73
+ */
74
+ declare const MAX_TRANSACTION_AGE: number;
75
+ /**
76
+ * CAIP-2 namespace for NEAR
77
+ */
78
+ declare const NEAR_CAIP2_NAMESPACE = "near";
79
+
80
+ /**
81
+ * NEAR Token Registry
82
+ *
83
+ * Defines supported tokens (NEP-141 fungible tokens) for each NEAR network.
84
+ */
85
+ /**
86
+ * Token configuration
87
+ */
88
+ interface TokenConfig {
89
+ /** Contract address/account ID */
90
+ contractId: string;
91
+ /** Token symbol */
92
+ symbol: string;
93
+ /** Token name */
94
+ name: string;
95
+ /** Decimal places */
96
+ decimals: number;
97
+ /** Priority for selection (lower = higher priority) */
98
+ priority: number;
99
+ }
100
+ /**
101
+ * Token registry by network
102
+ */
103
+ declare const TOKEN_REGISTRY: Record<string, TokenConfig[]>;
104
+ /**
105
+ * Get token configuration by symbol
106
+ * @param network - CAIP-2 network identifier
107
+ * @param symbol - Token symbol (e.g., "USDC")
108
+ * @returns Token configuration or undefined
109
+ */
110
+ declare function getTokenConfig(network: string, symbol: string): TokenConfig | undefined;
111
+ /**
112
+ * Get token configuration by contract ID
113
+ * @param network - CAIP-2 network identifier
114
+ * @param contractId - Token contract account ID
115
+ * @returns Token configuration or undefined
116
+ */
117
+ declare function getTokenByContract(network: string, contractId: string): TokenConfig | undefined;
118
+ /**
119
+ * Get the default token for a network
120
+ * Returns the token with highest priority (lowest priority number)
121
+ * @param network - CAIP-2 network identifier
122
+ * @returns Default token configuration or undefined
123
+ */
124
+ declare function getDefaultToken(network: string): TokenConfig | undefined;
125
+ /**
126
+ * Get all tokens for a network
127
+ * @param network - CAIP-2 network identifier
128
+ * @returns Array of token configurations
129
+ */
130
+ declare function getNetworkTokens(network: string): TokenConfig[];
131
+ /**
132
+ * Check if a network is supported
133
+ * @param network - CAIP-2 network identifier
134
+ */
135
+ declare function isNetworkSupported(network: string): boolean;
136
+
137
+ /**
138
+ * NEAR Utility Functions
139
+ *
140
+ * Helper functions for NEAR address validation, network normalization,
141
+ * and RPC interactions.
142
+ */
143
+
144
+ /**
145
+ * Normalize a network identifier to CAIP-2 format
146
+ * @param network - Network identifier (e.g., "mainnet", "near:mainnet")
147
+ * @returns CAIP-2 formatted network identifier
148
+ */
149
+ declare function normalizeNetwork(network: string): NearNetwork;
150
+ /**
151
+ * Extract network ID from CAIP-2 identifier
152
+ * @param network - CAIP-2 network identifier
153
+ * @returns Network ID (e.g., "mainnet")
154
+ */
155
+ declare function extractNetworkId(network: string): string;
156
+ /**
157
+ * Validate a NEAR account ID
158
+ * NEAR account IDs must:
159
+ * - Be 2-64 characters
160
+ * - Contain only lowercase alphanumeric, underscores, hyphens
161
+ * - Not start with a hyphen or underscore
162
+ * @param accountId - Account ID to validate
163
+ * @returns Whether the account ID is valid
164
+ */
165
+ declare function isValidAccountId(accountId: string): boolean;
166
+ /**
167
+ * Get RPC endpoint for a network
168
+ * @param network - CAIP-2 network identifier
169
+ * @returns RPC endpoint URL
170
+ */
171
+ declare function getRpcEndpoint(network: string): string;
172
+ /**
173
+ * Make a JSON-RPC call to NEAR
174
+ * @param network - CAIP-2 network identifier
175
+ * @param method - RPC method name
176
+ * @param params - Method parameters
177
+ * @returns RPC response result
178
+ */
179
+ declare function rpcCall<T>(network: string, method: string, params: NearRpcRequest["params"]): Promise<T>;
180
+ /**
181
+ * Query a transaction by hash
182
+ * @param network - CAIP-2 network identifier
183
+ * @param txHash - Transaction hash
184
+ * @param senderAccountId - Sender account ID
185
+ * @returns Transaction result
186
+ */
187
+ declare function queryTransaction(network: string, txHash: string, senderAccountId: string): Promise<TransactionResult>;
188
+ /**
189
+ * Query token balance
190
+ * @param network - CAIP-2 network identifier
191
+ * @param accountId - Account to query
192
+ * @param tokenContract - Token contract address
193
+ * @returns Balance as bigint
194
+ */
195
+ declare function queryTokenBalance(network: string, accountId: string, tokenContract: string): Promise<bigint>;
196
+ /**
197
+ * Parse ft_transfer args from base64 encoded string
198
+ * @param argsBase64 - Base64 encoded JSON arguments
199
+ * @returns Parsed ft_transfer arguments
200
+ */
201
+ declare function parseFtTransferArgs(argsBase64: string): FtTransferArgs | null;
202
+ /**
203
+ * Check if a transaction succeeded
204
+ * @param status - Transaction status
205
+ * @returns Whether the transaction succeeded
206
+ */
207
+ declare function isTransactionSuccessful(status: {
208
+ SuccessValue?: string;
209
+ Failure?: unknown;
210
+ }): boolean;
211
+ /**
212
+ * Format amount for display (with decimals)
213
+ * @param amount - Amount in smallest units
214
+ * @param decimals - Number of decimal places
215
+ * @returns Formatted amount string
216
+ */
217
+ declare function formatAmount(amount: bigint, decimals: number): string;
218
+ /**
219
+ * Convert decimal amount to token units
220
+ * @param decimalAmount - Amount with decimals (e.g., "1.50")
221
+ * @param decimals - Token decimals
222
+ * @returns Amount in smallest units
223
+ */
224
+ declare function toTokenUnits(decimalAmount: string | number, decimals: number): bigint;
225
+
226
+ export { DEFAULT_FT_TRANSFER_GAS, DEFAULT_STORAGE_DEPOSIT, DEFAULT_STORAGE_DEPOSIT_GAS, DEFAULT_VALIDITY_DURATION, FT_TRANSFER_DEPOSIT, FtTransferArgs, MAX_TRANSACTION_AGE, NEAR_CAIP2_NAMESPACE, NEAR_MAINNET_CAIP2, NEAR_MAINNET_RPC, NEAR_NETWORKS, NEAR_NETWORK_IDS, NEAR_TESTNET_CAIP2, NEAR_TESTNET_RPC, NEP141_FT_BALANCE_OF, NEP141_FT_TRANSFER, NEP141_STORAGE_BALANCE_OF, NEP141_STORAGE_DEPOSIT, NETWORK_RPC_ENDPOINTS, type NearNetwork, NearRpcRequest, SCHEME_EXACT_DIRECT, TOKEN_REGISTRY, type TokenConfig, TransactionResult, extractNetworkId, formatAmount, getDefaultToken, getNetworkTokens, getRpcEndpoint, getTokenByContract, getTokenConfig, isNetworkSupported, isTransactionSuccessful, isValidAccountId, normalizeNetwork, parseFtTransferArgs, queryTokenBalance, queryTransaction, rpcCall, toTokenUnits };