@t402/aptos 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.
- package/README.md +171 -0
- package/dist/exact-direct/client/index.d.cts +91 -0
- package/dist/exact-direct/client/index.d.ts +91 -0
- package/dist/exact-direct/client/index.js +203 -0
- package/dist/exact-direct/client/index.js.map +1 -0
- package/dist/exact-direct/client/index.mjs +175 -0
- package/dist/exact-direct/client/index.mjs.map +1 -0
- package/dist/exact-direct/facilitator/index.d.cts +110 -0
- package/dist/exact-direct/facilitator/index.d.ts +110 -0
- package/dist/exact-direct/facilitator/index.js +352 -0
- package/dist/exact-direct/facilitator/index.js.map +1 -0
- package/dist/exact-direct/facilitator/index.mjs +324 -0
- package/dist/exact-direct/facilitator/index.mjs.map +1 -0
- package/dist/exact-direct/server/index.d.cts +106 -0
- package/dist/exact-direct/server/index.d.ts +106 -0
- package/dist/exact-direct/server/index.js +220 -0
- package/dist/exact-direct/server/index.js.map +1 -0
- package/dist/exact-direct/server/index.mjs +192 -0
- package/dist/exact-direct/server/index.mjs.map +1 -0
- package/dist/index.d.cts +145 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.js +759 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +687 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types-kOweBf4U.d.cts +149 -0
- package/dist/types-kOweBf4U.d.ts +149 -0
- package/package.json +100 -0
- package/src/constants.ts +48 -0
- package/src/exact-direct/client/index.ts +12 -0
- package/src/exact-direct/client/register.ts +83 -0
- package/src/exact-direct/client/scheme.ts +148 -0
- package/src/exact-direct/facilitator/index.ts +12 -0
- package/src/exact-direct/facilitator/register.ts +74 -0
- package/src/exact-direct/facilitator/scheme.ts +300 -0
- package/src/exact-direct/server/index.ts +12 -0
- package/src/exact-direct/server/register.ts +65 -0
- package/src/exact-direct/server/scheme.ts +196 -0
- package/src/index.ts +58 -0
- package/src/tokens.ts +114 -0
- package/src/types.ts +174 -0
- package/src/utils.ts +240 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { A as AptosTransactionEvent, P as ParsedFATransfer, a as AptosTransactionResult } from './types-kOweBf4U.js';
|
|
2
|
+
export { c as AptosStateChange, b as AptosTransactionPayload, C as ClientAptosSigner, E as ExactDirectAptosPayload, F as FacilitatorAptosSigner, e as extractChainId } from './types-kOweBf4U.js';
|
|
3
|
+
import { Network } from '@t402/core/types';
|
|
4
|
+
export { AptosClientConfig, ExactDirectAptosClient, ExactDirectAptosClientConfig, registerExactDirectAptosClient } from './exact-direct/client/index.js';
|
|
5
|
+
export { AptosServerConfig, ExactDirectAptosServer, ExactDirectAptosServerConfig, registerExactDirectAptosServer } from './exact-direct/server/index.js';
|
|
6
|
+
export { AptosFacilitatorConfig, ExactDirectAptosFacilitator, ExactDirectAptosFacilitatorConfig, registerExactDirectAptosFacilitator } from './exact-direct/facilitator/index.js';
|
|
7
|
+
import '@t402/core/client';
|
|
8
|
+
import '@t402/core/server';
|
|
9
|
+
import '@t402/core/facilitator';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Aptos Network Constants
|
|
13
|
+
*/
|
|
14
|
+
declare const APTOS_CAIP2_NAMESPACE = "aptos";
|
|
15
|
+
declare const APTOS_MAINNET_CAIP2 = "aptos:1";
|
|
16
|
+
declare const APTOS_TESTNET_CAIP2 = "aptos:2";
|
|
17
|
+
declare const APTOS_DEVNET_CAIP2 = "aptos:149";
|
|
18
|
+
declare const APTOS_NETWORKS: readonly ["aptos:1", "aptos:2", "aptos:149"];
|
|
19
|
+
type AptosNetwork = (typeof APTOS_NETWORKS)[number];
|
|
20
|
+
declare const APTOS_MAINNET_CHAIN_ID = 1;
|
|
21
|
+
declare const APTOS_TESTNET_CHAIN_ID = 2;
|
|
22
|
+
declare const APTOS_DEVNET_CHAIN_ID = 149;
|
|
23
|
+
declare const DEFAULT_MAINNET_RPC = "https://fullnode.mainnet.aptoslabs.com/v1";
|
|
24
|
+
declare const DEFAULT_TESTNET_RPC = "https://fullnode.testnet.aptoslabs.com/v1";
|
|
25
|
+
declare const DEFAULT_DEVNET_RPC = "https://fullnode.devnet.aptoslabs.com/v1";
|
|
26
|
+
declare const SCHEME_EXACT_DIRECT = "exact-direct";
|
|
27
|
+
declare const PRIMARY_FUNGIBLE_STORE_MODULE = "0x1::primary_fungible_store";
|
|
28
|
+
declare const FUNGIBLE_ASSET_MODULE = "0x1::fungible_asset";
|
|
29
|
+
declare const APTOS_ACCOUNT_MODULE = "0x1::aptos_account";
|
|
30
|
+
declare const FA_TRANSFER_FUNCTION = "0x1::primary_fungible_store::transfer";
|
|
31
|
+
declare const DEFAULT_MAX_GAS_AMOUNT = 100000n;
|
|
32
|
+
declare const DEFAULT_GAS_UNIT_PRICE = 100n;
|
|
33
|
+
declare const DEFAULT_TX_EXPIRATION_SECONDS = 600;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Aptos Token Registry
|
|
37
|
+
*
|
|
38
|
+
* Token addresses for supported stablecoins on Aptos networks.
|
|
39
|
+
* All tokens use the Fungible Asset (FA) standard.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Token configuration for Aptos fungible assets
|
|
43
|
+
*/
|
|
44
|
+
interface TokenConfig {
|
|
45
|
+
/** Fungible Asset metadata address */
|
|
46
|
+
metadataAddress: string;
|
|
47
|
+
/** Token symbol (e.g., "USDT", "USDC") */
|
|
48
|
+
symbol: string;
|
|
49
|
+
/** Token name */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Decimal places */
|
|
52
|
+
decimals: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Token registry mapping network -> tokens
|
|
56
|
+
*/
|
|
57
|
+
declare const TOKEN_REGISTRY: Record<string, TokenConfig[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Get token configuration for a specific network and symbol
|
|
60
|
+
*/
|
|
61
|
+
declare function getTokenConfig(network: string, symbol: string): TokenConfig | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Get all supported tokens for a network
|
|
64
|
+
*/
|
|
65
|
+
declare function getSupportedTokens(network: string): TokenConfig[];
|
|
66
|
+
/**
|
|
67
|
+
* Check if a token is supported on a network
|
|
68
|
+
*/
|
|
69
|
+
declare function isTokenSupported(network: string, symbol: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Get token by metadata address
|
|
72
|
+
*/
|
|
73
|
+
declare function getTokenByAddress(network: string, metadataAddress: string): TokenConfig | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Default token symbol for payments (USDT)
|
|
76
|
+
*/
|
|
77
|
+
declare const DEFAULT_TOKEN_SYMBOL = "USDT";
|
|
78
|
+
/**
|
|
79
|
+
* Get the default token for a network
|
|
80
|
+
*/
|
|
81
|
+
declare function getDefaultToken(network: string): TokenConfig | undefined;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Aptos Utility Functions
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Validate Aptos address format
|
|
89
|
+
* Aptos addresses are 64 hex characters (32 bytes) with 0x prefix
|
|
90
|
+
*/
|
|
91
|
+
declare function isValidAptosAddress(address: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Normalize Aptos address to full 64-character format
|
|
94
|
+
*/
|
|
95
|
+
declare function normalizeAptosAddress(address: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Compare two Aptos addresses (case-insensitive, handles short addresses)
|
|
98
|
+
*/
|
|
99
|
+
declare function compareAddresses(addr1: string, addr2: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Validate transaction hash format
|
|
102
|
+
*/
|
|
103
|
+
declare function isValidTxHash(txHash: string): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Get default RPC URL for a network
|
|
106
|
+
*/
|
|
107
|
+
declare function getDefaultRpcUrl(network: Network): string;
|
|
108
|
+
/**
|
|
109
|
+
* Check if a network identifier is for Aptos
|
|
110
|
+
*/
|
|
111
|
+
declare function isAptosNetwork(network: Network): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Parse CAIP-19 asset identifier for Aptos
|
|
114
|
+
* Format: aptos:1/fa:0x...
|
|
115
|
+
*/
|
|
116
|
+
declare function parseAssetIdentifier(asset: string): {
|
|
117
|
+
network: Network;
|
|
118
|
+
metadataAddress: string;
|
|
119
|
+
} | null;
|
|
120
|
+
/**
|
|
121
|
+
* Create CAIP-19 asset identifier for Aptos FA
|
|
122
|
+
*/
|
|
123
|
+
declare function createAssetIdentifier(network: Network, metadataAddress: string): string;
|
|
124
|
+
/**
|
|
125
|
+
* Parse fungible asset transfer from transaction events
|
|
126
|
+
*/
|
|
127
|
+
declare function parseFATransferFromEvents(events: AptosTransactionEvent[]): ParsedFATransfer | null;
|
|
128
|
+
/**
|
|
129
|
+
* Check if transaction is a FA transfer
|
|
130
|
+
*/
|
|
131
|
+
declare function isFATransferTransaction(tx: AptosTransactionResult): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Extract transfer details from transaction
|
|
134
|
+
*/
|
|
135
|
+
declare function extractTransferDetails(tx: AptosTransactionResult): ParsedFATransfer | null;
|
|
136
|
+
/**
|
|
137
|
+
* Format amount with decimals for display
|
|
138
|
+
*/
|
|
139
|
+
declare function formatAmount(amount: bigint, decimals: number): string;
|
|
140
|
+
/**
|
|
141
|
+
* Parse amount string to bigint
|
|
142
|
+
*/
|
|
143
|
+
declare function parseAmount(amount: string, decimals: number): bigint;
|
|
144
|
+
|
|
145
|
+
export { APTOS_ACCOUNT_MODULE, APTOS_CAIP2_NAMESPACE, APTOS_DEVNET_CAIP2, APTOS_DEVNET_CHAIN_ID, APTOS_MAINNET_CAIP2, APTOS_MAINNET_CHAIN_ID, APTOS_NETWORKS, APTOS_TESTNET_CAIP2, APTOS_TESTNET_CHAIN_ID, type AptosNetwork, AptosTransactionEvent, AptosTransactionResult, DEFAULT_DEVNET_RPC, DEFAULT_GAS_UNIT_PRICE, DEFAULT_MAINNET_RPC, DEFAULT_MAX_GAS_AMOUNT, DEFAULT_TESTNET_RPC, DEFAULT_TOKEN_SYMBOL, DEFAULT_TX_EXPIRATION_SECONDS, FA_TRANSFER_FUNCTION, FUNGIBLE_ASSET_MODULE, PRIMARY_FUNGIBLE_STORE_MODULE, ParsedFATransfer, SCHEME_EXACT_DIRECT, TOKEN_REGISTRY, type TokenConfig, compareAddresses, createAssetIdentifier, extractTransferDetails, formatAmount, getDefaultRpcUrl, getDefaultToken, getSupportedTokens, getTokenByAddress, getTokenConfig, isAptosNetwork, isFATransferTransaction, isTokenSupported, isValidAptosAddress, isValidTxHash, normalizeAptosAddress, parseAmount, parseAssetIdentifier, parseFATransferFromEvents };
|