@getomnichain/omnichain 0.5.0 → 0.6.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/CHANGELOG.md +134 -0
- package/README.md +5 -3
- package/dist/cjs/address.factory.js +7 -4
- package/dist/cjs/address.factory.js.map +1 -1
- package/dist/cjs/asset_balance.js +7 -0
- package/dist/cjs/asset_balance.js.map +1 -0
- package/dist/cjs/asset_map.js +45 -0
- package/dist/cjs/asset_map.js.map +1 -0
- package/dist/cjs/asset_registry.js +21 -0
- package/dist/cjs/asset_registry.js.map +1 -0
- package/dist/cjs/bip39.js +88 -0
- package/dist/cjs/bip39.js.map +1 -0
- package/dist/cjs/bytes_from_hex.js +34 -0
- package/dist/cjs/bytes_from_hex.js.map +1 -0
- package/dist/cjs/chain_type.js +35 -0
- package/dist/cjs/chain_type.js.map +1 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/network_type.js +5 -2
- package/dist/cjs/network_type.js.map +1 -1
- package/dist/cjs/python_builtins.js +225 -0
- package/dist/cjs/python_builtins.js.map +1 -0
- package/dist/cjs/python_json.js +120 -0
- package/dist/cjs/python_json.js.map +1 -0
- package/dist/cjs/python_pydantic.js +50 -0
- package/dist/cjs/python_pydantic.js.map +1 -0
- package/dist/cjs/python_repr.js +172 -0
- package/dist/cjs/python_repr.js.map +1 -0
- package/dist/cjs/signed_transaction.js +24 -0
- package/dist/cjs/signed_transaction.js.map +1 -0
- package/dist/cjs/solana/solana_chain.js +89 -25
- package/dist/cjs/solana/solana_chain.js.map +1 -1
- package/dist/cjs/solana/solana_transaction_status.js +39 -3
- package/dist/cjs/solana/solana_transaction_status.js.map +1 -1
- package/dist/cjs/stellar/index.js +26 -0
- package/dist/cjs/stellar/index.js.map +1 -0
- package/dist/cjs/stellar/stellar_address.js +25 -0
- package/dist/cjs/stellar/stellar_address.js.map +1 -0
- package/dist/cjs/stellar/stellar_asset.js +155 -0
- package/dist/cjs/stellar/stellar_asset.js.map +1 -0
- package/dist/cjs/stellar/stellar_assets.js +26 -0
- package/dist/cjs/stellar/stellar_assets.js.map +1 -0
- package/dist/cjs/stellar/stellar_chain.js +1334 -0
- package/dist/cjs/stellar/stellar_chain.js.map +1 -0
- package/dist/cjs/stellar/stellar_chains.js +28 -0
- package/dist/cjs/stellar/stellar_chains.js.map +1 -0
- package/dist/cjs/stellar/stellar_gas_pricing.js +22 -0
- package/dist/cjs/stellar/stellar_gas_pricing.js.map +1 -0
- package/dist/cjs/stellar/stellar_strkey.js +71 -0
- package/dist/cjs/stellar/stellar_strkey.js.map +1 -0
- package/dist/cjs/stellar/stellar_transaction_status.js +72 -0
- package/dist/cjs/stellar/stellar_transaction_status.js.map +1 -0
- package/dist/cjs/stellar/stellar_transactions.js +475 -0
- package/dist/cjs/stellar/stellar_transactions.js.map +1 -0
- package/dist/cjs/stellar/stellar_wallet.js +195 -0
- package/dist/cjs/stellar/stellar_wallet.js.map +1 -0
- package/dist/cjs/token.js +3 -1
- package/dist/cjs/token.js.map +1 -1
- package/dist/cjs/transaction_json.js +85 -0
- package/dist/cjs/transaction_json.js.map +1 -0
- package/dist/cjs/transaction_prerequisite.js +19 -0
- package/dist/cjs/transaction_prerequisite.js.map +1 -0
- package/dist/cjs/transaction_simulation.js +21 -0
- package/dist/cjs/transaction_simulation.js.map +1 -0
- package/dist/cjs/tron/index.js +32 -0
- package/dist/cjs/tron/index.js.map +1 -0
- package/dist/cjs/tron/tron_abi.js +287 -0
- package/dist/cjs/tron/tron_abi.js.map +1 -0
- package/dist/cjs/tron/tron_address.js +38 -0
- package/dist/cjs/tron/tron_address.js.map +1 -0
- package/dist/cjs/tron/tron_asset.js +56 -0
- package/dist/cjs/tron/tron_asset.js.map +1 -0
- package/dist/cjs/tron/tron_assets.js +17 -0
- package/dist/cjs/tron/tron_assets.js.map +1 -0
- package/dist/cjs/tron/tron_base58.js +95 -0
- package/dist/cjs/tron/tron_base58.js.map +1 -0
- package/dist/cjs/tron/tron_canonical_transaction.js +268 -0
- package/dist/cjs/tron/tron_canonical_transaction.js.map +1 -0
- package/dist/cjs/tron/tron_chain.js +809 -0
- package/dist/cjs/tron/tron_chain.js.map +1 -0
- package/dist/cjs/tron/tron_chains.js +19 -0
- package/dist/cjs/tron/tron_chains.js.map +1 -0
- package/dist/cjs/tron/tron_client.js +327 -0
- package/dist/cjs/tron/tron_client.js.map +1 -0
- package/dist/cjs/tron/tron_contract.js +195 -0
- package/dist/cjs/tron/tron_contract.js.map +1 -0
- package/dist/cjs/tron/tron_gas_pricing.js +21 -0
- package/dist/cjs/tron/tron_gas_pricing.js.map +1 -0
- package/dist/cjs/tron/tron_keys.js +251 -0
- package/dist/cjs/tron/tron_keys.js.map +1 -0
- package/dist/cjs/tron/tron_transaction_builder.js +196 -0
- package/dist/cjs/tron/tron_transaction_builder.js.map +1 -0
- package/dist/cjs/tron/tron_transaction_status.js +118 -0
- package/dist/cjs/tron/tron_transaction_status.js.map +1 -0
- package/dist/cjs/tron/tron_transactions.js +192 -0
- package/dist/cjs/tron/tron_transactions.js.map +1 -0
- package/dist/cjs/tron/tron_wallet.js +152 -0
- package/dist/cjs/tron/tron_wallet.js.map +1 -0
- package/dist/cjs/unsigned_transaction.js +12 -0
- package/dist/cjs/unsigned_transaction.js.map +1 -1
- package/dist/cjs/wallet.base.js +29 -0
- package/dist/cjs/wallet.base.js.map +1 -0
- package/dist/esm/address.factory.d.ts.map +1 -1
- package/dist/esm/address.factory.js +7 -4
- package/dist/esm/address.factory.js.map +1 -1
- package/dist/esm/asset_balance.d.ts +5 -0
- package/dist/esm/asset_balance.d.ts.map +1 -0
- package/dist/esm/asset_balance.js +3 -0
- package/dist/esm/asset_balance.js.map +1 -0
- package/dist/esm/asset_map.d.ts +12 -0
- package/dist/esm/asset_map.d.ts.map +1 -0
- package/dist/esm/asset_map.js +40 -0
- package/dist/esm/asset_map.js.map +1 -0
- package/dist/esm/asset_registry.d.ts +6 -0
- package/dist/esm/asset_registry.d.ts.map +1 -0
- package/dist/esm/asset_registry.js +15 -0
- package/dist/esm/asset_registry.js.map +1 -0
- package/dist/esm/bip39.d.ts +4 -0
- package/dist/esm/bip39.d.ts.map +1 -0
- package/dist/esm/bip39.js +83 -0
- package/dist/esm/bip39.js.map +1 -0
- package/dist/esm/bytes_from_hex.d.ts +2 -0
- package/dist/esm/bytes_from_hex.d.ts.map +1 -0
- package/dist/esm/bytes_from_hex.js +31 -0
- package/dist/esm/bytes_from_hex.js.map +1 -0
- package/dist/esm/chain_type.d.ts +29 -0
- package/dist/esm/chain_type.d.ts.map +1 -0
- package/dist/esm/chain_type.js +32 -0
- package/dist/esm/chain_type.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/network_type.d.ts +3 -2
- package/dist/esm/network_type.d.ts.map +1 -1
- package/dist/esm/network_type.js +6 -3
- package/dist/esm/network_type.js.map +1 -1
- package/dist/esm/python_builtins.d.ts +13 -0
- package/dist/esm/python_builtins.d.ts.map +1 -0
- package/dist/esm/python_builtins.js +212 -0
- package/dist/esm/python_builtins.js.map +1 -0
- package/dist/esm/python_json.d.ts +9 -0
- package/dist/esm/python_json.d.ts.map +1 -0
- package/dist/esm/python_json.js +117 -0
- package/dist/esm/python_json.js.map +1 -0
- package/dist/esm/python_pydantic.d.ts +11 -0
- package/dist/esm/python_pydantic.d.ts.map +1 -0
- package/dist/esm/python_pydantic.js +39 -0
- package/dist/esm/python_pydantic.js.map +1 -0
- package/dist/esm/python_repr.d.ts +17 -0
- package/dist/esm/python_repr.d.ts.map +1 -0
- package/dist/esm/python_repr.js +160 -0
- package/dist/esm/python_repr.js.map +1 -0
- package/dist/esm/signed_transaction.d.ts +17 -0
- package/dist/esm/signed_transaction.d.ts.map +1 -0
- package/dist/esm/signed_transaction.js +19 -0
- package/dist/esm/signed_transaction.js.map +1 -0
- package/dist/esm/solana/solana_chain.d.ts.map +1 -1
- package/dist/esm/solana/solana_chain.js +90 -26
- package/dist/esm/solana/solana_chain.js.map +1 -1
- package/dist/esm/solana/solana_transaction_status.d.ts +40 -2
- package/dist/esm/solana/solana_transaction_status.d.ts.map +1 -1
- package/dist/esm/solana/solana_transaction_status.js +38 -2
- package/dist/esm/solana/solana_transaction_status.js.map +1 -1
- package/dist/esm/stellar/index.d.ts +10 -0
- package/dist/esm/stellar/index.d.ts.map +1 -0
- package/dist/esm/stellar/index.js +10 -0
- package/dist/esm/stellar/index.js.map +1 -0
- package/dist/esm/stellar/stellar_address.d.ts +8 -0
- package/dist/esm/stellar/stellar_address.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_address.js +21 -0
- package/dist/esm/stellar/stellar_address.js.map +1 -0
- package/dist/esm/stellar/stellar_asset.d.ts +52 -0
- package/dist/esm/stellar/stellar_asset.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_asset.js +147 -0
- package/dist/esm/stellar/stellar_asset.js.map +1 -0
- package/dist/esm/stellar/stellar_assets.d.ts +11 -0
- package/dist/esm/stellar/stellar_assets.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_assets.js +23 -0
- package/dist/esm/stellar/stellar_assets.js.map +1 -0
- package/dist/esm/stellar/stellar_chain.d.ts +173 -0
- package/dist/esm/stellar/stellar_chain.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_chain.js +1325 -0
- package/dist/esm/stellar/stellar_chain.js.map +1 -0
- package/dist/esm/stellar/stellar_chains.d.ts +5 -0
- package/dist/esm/stellar/stellar_chains.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_chains.js +25 -0
- package/dist/esm/stellar/stellar_chains.js.map +1 -0
- package/dist/esm/stellar/stellar_gas_pricing.d.ts +13 -0
- package/dist/esm/stellar/stellar_gas_pricing.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_gas_pricing.js +18 -0
- package/dist/esm/stellar/stellar_gas_pricing.js.map +1 -0
- package/dist/esm/stellar/stellar_strkey.d.ts +3 -0
- package/dist/esm/stellar/stellar_strkey.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_strkey.js +67 -0
- package/dist/esm/stellar/stellar_strkey.js.map +1 -0
- package/dist/esm/stellar/stellar_transaction_status.d.ts +39 -0
- package/dist/esm/stellar/stellar_transaction_status.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_transaction_status.js +68 -0
- package/dist/esm/stellar/stellar_transaction_status.js.map +1 -0
- package/dist/esm/stellar/stellar_transactions.d.ts +166 -0
- package/dist/esm/stellar/stellar_transactions.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_transactions.js +451 -0
- package/dist/esm/stellar/stellar_transactions.js.map +1 -0
- package/dist/esm/stellar/stellar_wallet.d.ts +43 -0
- package/dist/esm/stellar/stellar_wallet.d.ts.map +1 -0
- package/dist/esm/stellar/stellar_wallet.js +190 -0
- package/dist/esm/stellar/stellar_wallet.js.map +1 -0
- package/dist/esm/token.d.ts +1 -0
- package/dist/esm/token.d.ts.map +1 -1
- package/dist/esm/token.js +3 -1
- package/dist/esm/token.js.map +1 -1
- package/dist/esm/transaction_json.d.ts +21 -0
- package/dist/esm/transaction_json.d.ts.map +1 -0
- package/dist/esm/transaction_json.js +75 -0
- package/dist/esm/transaction_json.js.map +1 -0
- package/dist/esm/transaction_prerequisite.d.ts +17 -0
- package/dist/esm/transaction_prerequisite.d.ts.map +1 -0
- package/dist/esm/transaction_prerequisite.js +13 -0
- package/dist/esm/transaction_prerequisite.js.map +1 -0
- package/dist/esm/transaction_simulation.d.ts +20 -0
- package/dist/esm/transaction_simulation.d.ts.map +1 -0
- package/dist/esm/transaction_simulation.js +17 -0
- package/dist/esm/transaction_simulation.js.map +1 -0
- package/dist/esm/tron/index.d.ts +16 -0
- package/dist/esm/tron/index.d.ts.map +1 -0
- package/dist/esm/tron/index.js +16 -0
- package/dist/esm/tron/index.js.map +1 -0
- package/dist/esm/tron/tron_abi.d.ts +3 -0
- package/dist/esm/tron/tron_abi.d.ts.map +1 -0
- package/dist/esm/tron/tron_abi.js +283 -0
- package/dist/esm/tron/tron_abi.js.map +1 -0
- package/dist/esm/tron/tron_address.d.ts +10 -0
- package/dist/esm/tron/tron_address.d.ts.map +1 -0
- package/dist/esm/tron/tron_address.js +34 -0
- package/dist/esm/tron/tron_address.js.map +1 -0
- package/dist/esm/tron/tron_asset.d.ts +19 -0
- package/dist/esm/tron/tron_asset.d.ts.map +1 -0
- package/dist/esm/tron/tron_asset.js +51 -0
- package/dist/esm/tron/tron_asset.js.map +1 -0
- package/dist/esm/tron/tron_assets.d.ts +10 -0
- package/dist/esm/tron/tron_assets.d.ts.map +1 -0
- package/dist/esm/tron/tron_assets.js +14 -0
- package/dist/esm/tron/tron_assets.js.map +1 -0
- package/dist/esm/tron/tron_base58.d.ts +7 -0
- package/dist/esm/tron/tron_base58.d.ts.map +1 -0
- package/dist/esm/tron/tron_base58.js +84 -0
- package/dist/esm/tron/tron_base58.js.map +1 -0
- package/dist/esm/tron/tron_canonical_transaction.d.ts +164 -0
- package/dist/esm/tron/tron_canonical_transaction.d.ts.map +1 -0
- package/dist/esm/tron/tron_canonical_transaction.js +262 -0
- package/dist/esm/tron/tron_canonical_transaction.js.map +1 -0
- package/dist/esm/tron/tron_chain.d.ts +136 -0
- package/dist/esm/tron/tron_chain.d.ts.map +1 -0
- package/dist/esm/tron/tron_chain.js +801 -0
- package/dist/esm/tron/tron_chain.js.map +1 -0
- package/dist/esm/tron/tron_chains.d.ts +5 -0
- package/dist/esm/tron/tron_chains.d.ts.map +1 -0
- package/dist/esm/tron/tron_chains.js +16 -0
- package/dist/esm/tron/tron_chains.js.map +1 -0
- package/dist/esm/tron/tron_client.d.ts +56 -0
- package/dist/esm/tron/tron_client.d.ts.map +1 -0
- package/dist/esm/tron/tron_client.js +319 -0
- package/dist/esm/tron/tron_client.js.map +1 -0
- package/dist/esm/tron/tron_contract.d.ts +69 -0
- package/dist/esm/tron/tron_contract.d.ts.map +1 -0
- package/dist/esm/tron/tron_contract.js +190 -0
- package/dist/esm/tron/tron_contract.js.map +1 -0
- package/dist/esm/tron/tron_gas_pricing.d.ts +12 -0
- package/dist/esm/tron/tron_gas_pricing.d.ts.map +1 -0
- package/dist/esm/tron/tron_gas_pricing.js +17 -0
- package/dist/esm/tron/tron_gas_pricing.js.map +1 -0
- package/dist/esm/tron/tron_keys.d.ts +61 -0
- package/dist/esm/tron/tron_keys.d.ts.map +1 -0
- package/dist/esm/tron/tron_keys.js +228 -0
- package/dist/esm/tron/tron_keys.js.map +1 -0
- package/dist/esm/tron/tron_transaction_builder.d.ts +56 -0
- package/dist/esm/tron/tron_transaction_builder.d.ts.map +1 -0
- package/dist/esm/tron/tron_transaction_builder.js +188 -0
- package/dist/esm/tron/tron_transaction_builder.js.map +1 -0
- package/dist/esm/tron/tron_transaction_status.d.ts +54 -0
- package/dist/esm/tron/tron_transaction_status.d.ts.map +1 -0
- package/dist/esm/tron/tron_transaction_status.js +113 -0
- package/dist/esm/tron/tron_transaction_status.js.map +1 -0
- package/dist/esm/tron/tron_transactions.d.ts +96 -0
- package/dist/esm/tron/tron_transactions.d.ts.map +1 -0
- package/dist/esm/tron/tron_transactions.js +181 -0
- package/dist/esm/tron/tron_transactions.js.map +1 -0
- package/dist/esm/tron/tron_wallet.d.ts +43 -0
- package/dist/esm/tron/tron_wallet.d.ts.map +1 -0
- package/dist/esm/tron/tron_wallet.js +148 -0
- package/dist/esm/tron/tron_wallet.js.map +1 -0
- package/dist/esm/unsigned_transaction.d.ts +5 -0
- package/dist/esm/unsigned_transaction.d.ts.map +1 -1
- package/dist/esm/unsigned_transaction.js +12 -0
- package/dist/esm/unsigned_transaction.js.map +1 -1
- package/dist/esm/wallet.base.d.ts +32 -0
- package/dist/esm/wallet.base.d.ts.map +1 -0
- package/dist/esm/wallet.base.js +23 -0
- package/dist/esm/wallet.base.js.map +1 -0
- package/docs/README.md +16 -7
- package/docs/solana.md +23 -0
- package/docs/stellar.md +113 -0
- package/docs/tron.md +103 -0
- package/package.json +14 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,139 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.6.0] — 2026-10-04
|
|
12
|
+
|
|
13
|
+
Adds the Stellar and Tron chain families at parity with omnichain-py (RIN-315). Both are ports of `impl/stellar` and `impl/tron`: same methods (camelCased), same arguments and defaults, same RPC calls, same balance-change rules, same wallets and the same JSON wire format. They were verified against Python on mainnet and testnet:
|
|
14
|
+
- Every mainnet case from Python's integration tests produces identical output.
|
|
15
|
+
- Every key and signature vector from Python's unit tests is byte-identical.
|
|
16
|
+
- A transaction built by TS, signed by Python's `StellarWallet` and broadcast by TS lands on testnet.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Stellar and Tron are imported from their subpaths only. Like Python's `import omnichain`, the root entry does not load the families' chain modules, so at runtime `@stellar/stellar-sdk` is loaded only by consumers that use Stellar. Consumers that compile omnichain's source need it at compile time; see Migration.
|
|
21
|
+
- **`@getomnichain/omnichain/stellar`**:
|
|
22
|
+
- Chains: `StellarMainnet` / `StellarTestnet`.
|
|
23
|
+
- Assets: `StellarAsset` (native, SAC, non-SAC Soroban), `STELLAR_XLM` / `STELLAR_USDC` / `STELLAR_EURC` / `STELLAR_BNUSD` plus testnet assets, `STELLAR_MAINNET_STABLECOINS_PEG`.
|
|
24
|
+
- `StellarChain` methods:
|
|
25
|
+
- transfers: `createTransferTransaction` (classic `Payment` or Soroban `transfer`, with trustline prerequisites), `createExactInSwapTransaction`;
|
|
26
|
+
- status: `getTransactionStatus` (Horizon effects, Soroban diagnostic events, Stellar Expert fallback, memo, fees);
|
|
27
|
+
- simulation and broadcast: `simulateTransaction`, `broadcastSignedTransaction`;
|
|
28
|
+
- reads: `getAssetBalance` (reserve-aware), `getWalletBalance`, `getTrustLineLimit`, `resolveAsset`, `createSacToken`, `createNonSacToken`;
|
|
29
|
+
- utilities: `verifySignature` (SEP-53), `getAccountNextSequence`.
|
|
30
|
+
- Models: `StellarUnsignedTransaction` (intent → envelope at sign time), `StellarSignedTransaction`, `StellarWallet` (SEP-5 mnemonic, SEP-53 messages, trustline handling, Friendbot), `StellarAddress`, `StellarGasPricing`.
|
|
31
|
+
- **`@getomnichain/omnichain/tron`**:
|
|
32
|
+
- Chains: `TronMainnet` / `TronShastaTestnet`.
|
|
33
|
+
- Assets: `TronAsset` (TRX + TRC-20), `TRON_TRX` / `TRON_USDT` / `TRON_USDC` plus Shasta assets, `TRON_ASSETS_REQUIRING_ZERO_RESET_APPROVAL`, `TRON_MAINNET_STABLECOINS_PEG`.
|
|
34
|
+
- `TronChain` methods:
|
|
35
|
+
- transfers: `createTransferTransaction` (TransferContract / TRC-20 `TriggerSmartContract`, memo, fee limit);
|
|
36
|
+
- status: `getTransactionStatus` (TransferContract + internal transactions + TRC-20 logs + fee);
|
|
37
|
+
- simulation and broadcast: `simulateTransaction` (`wallet/triggerconstantcontract`, energy), `broadcastSignedTransaction` (duplicate-tolerant);
|
|
38
|
+
- reads: `getAssetBalance`, `resolveAsset`, `getChainParameters`;
|
|
39
|
+
- utilities: `verifySignature`.
|
|
40
|
+
- Models: `TronTransactionFees` (with Python's cross-field validator), `TronWallet` (BIP-44 secp256k1, tronpy-compatible message signatures, USDT zero-reset approve flow), `TronAddress`, `TronGasPricing`, `parseTronCanonicalTransaction` (the 12-contract schema from `helpers/transaction.py`).
|
|
41
|
+
- Ports of the tronpy pieces Python relies on: `TronClient`, `TronTransaction` / `TronTransactionBuilder`, `TronContract`, and the keys module (`TronPrivateKey` / `TronPublicKey` / `TronSignature`, base58check helpers).
|
|
42
|
+
- **Python base types** used by both families:
|
|
43
|
+
- enums `ChainType`, `WalletFamily`, `FiatCurrency`;
|
|
44
|
+
- `AbstractTransactionPrerequisite`, `AbstractHandledPrerequisiteResponse`, `UnsignedTransactionWithPrerequisites`;
|
|
45
|
+
- `AbstractSignedTransaction`, `AbstractBroadcastTransactionResponse`;
|
|
46
|
+
- `AbstractTransactionSimulationResult` with `TransactionSimulationStatusTypes`;
|
|
47
|
+
- `AbstractSignedMessage`, `AbstractWallet`, `AbstractBip32StyleSingleAccountWallet`, `AbstractAssetBalance`;
|
|
48
|
+
- the BIP-39 helpers `mnemonicToSeedSep5` / `mnemonicToSeedBip39`.
|
|
49
|
+
- **JSON wire format shared with Python** — `toJson()` / `toJsonStr()` / `fromJson()` on the Stellar and Tron unsigned/signed transactions, using Python's `{type, chain_id, …}` envelope. `UnsignedTransaction.fromJson` and `AbstractSignedTransaction.fromJson` dispatch on `type`, so payloads move between Python and TS processes unchanged. A family's types are registered when its subpath is imported: import `@getomnichain/omnichain/stellar` or `/tron` before decoding its payloads through the root `fromJson`.
|
|
50
|
+
- **`NetworkType.STELLAR`**, with the Stellar chain ids seeded in the registry. `addressFor` now parses addresses instead of throwing `ChainNotSupported`:
|
|
51
|
+
- Tron (`TronAddress`): what Python's `validate_wallet_address` + `format_wallet_address` accept, a `T…` base58check address of 21 bytes; `validateAddress` uses the same check.
|
|
52
|
+
- Stellar (`StellarAddress`): `G…` / `M…`, checked without loading `@stellar/stellar-sdk`.
|
|
53
|
+
- **Python-semantics helpers** the ports rely on:
|
|
54
|
+
- `AssetMap`, a `Map` keyed by asset value like a Python `dict`, and the shared asset registry (`searchRegisteredAsset` / `getRegisteredAsset`);
|
|
55
|
+
- `bytesFromHex`, equivalent to `bytes.fromhex`;
|
|
56
|
+
- `pyRepr` / `pyStr` / `pyTypeRepr` / `pyFloatRepr`, so error and `toString` texts match Python's;
|
|
57
|
+
- `pyJsonDumps`: `toJsonStr` output is byte-identical to omnichain-py's `to_json_str` and accepts its `json.dumps` options;
|
|
58
|
+
- `tronAbiEncodeSingle` / `tronAbiDecodeSingle`, a port of tronpy's `trx_abi` (strict eth_abi decoding with Tron addresses).
|
|
59
|
+
- **Tests** — 988 new tests:
|
|
60
|
+
- Python's wallet vectors;
|
|
61
|
+
- mainnet status cases replayed offline from recorded RPC responses;
|
|
62
|
+
- Python JSON payload fixtures;
|
|
63
|
+
- fixtures generated by CPython / pydantic / tronpy / eth_abi for hex parsing, UTF-8, `int`, `repr`, `json.dumps`, ABI coding, signing and node error texts;
|
|
64
|
+
- Horizon and TronGrid exercised over real local HTTP;
|
|
65
|
+
- builders, simulation, broadcast, prerequisites, canonical transactions.
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
|
|
69
|
+
- `UnsignedTransaction` gains `toJson()` / `toJsonStr()` (throwing `FeatureNotSupported` for models without a JSON form, as in Python) and a static `fromJson`.
|
|
70
|
+
- New runtime dependency `@stellar/stellar-sdk` `^15.1.0`, the newest line that still supports Node 20 (v17 requires Node ≥ 22.12). Tron adds no dependency.
|
|
71
|
+
|
|
72
|
+
### Migration
|
|
73
|
+
|
|
74
|
+
- **Consumers that compile omnichain's source** (a submodule whose `.ts` files are in the consumer's `tsconfig` `include`) must add `@stellar/stellar-sdk` `^15.1.0` and `decimal.js` to their own dependencies, or exclude `stellar/**` from compilation if they do not use Stellar. npm consumers of the built package get both as dependencies.
|
|
75
|
+
- **`NetworkType.STELLAR` is a new enum member.** Exhaustive `switch`es over `NetworkType` and local mirrors of the enum need a `STELLAR` case.
|
|
76
|
+
- **Registry and address behaviour on Tron and Stellar chain ids:**
|
|
77
|
+
- `networkTypeOf(-3500)` / `networkTypeOf(-3501)` threw before and now return `STELLAR`.
|
|
78
|
+
- `registerNonEvmChain(-3500 | -3501, <another type>)` now throws, because the ids are seeded as Stellar. Call `unregisterChain` first to reclassify one.
|
|
79
|
+
- `addressFor`, `canonicalizeAddressStrict` and `@IsAddress` on Tron and Stellar chain ids validate the address instead of throwing `ChainNotSupported`.
|
|
80
|
+
- **Advisories inherited from `@stellar/stellar-sdk` 15.1.** It pins `axios` 1.15.0 and depends on `toml` 3.0.0, both with high-severity advisories. The stellar-sdk line that fixes them (17.x) needs Node ≥ 22. Consumers can lift both with npm `overrides`; with this recipe `npm audit` reports no vulnerabilities for stellar-sdk, and the Stellar test suite passes on axios 1.20:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
"overrides": { "@stellar/stellar-sdk": { "axios": "^1.20.0", "toml": "^4.2.0" } }
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Note — differences from omnichain-py
|
|
87
|
+
|
|
88
|
+
- Transport and API failures of the transaction lookup during `getTransactionStatus` (Horizon 429/5xx, TronGrid rate limits) throw `ChainError(RpcError)`; Python reports them as `NotFound`. Real "not found" answers still return `NotFound`.
|
|
89
|
+
- Non-SAC Soroban balances are converted exactly; Python divides with a float.
|
|
90
|
+
- Tron debug `print()` calls and Python's log lines are not ported. tronpy's bundled shared TronGrid keys are not shipped.
|
|
91
|
+
- `StellarWallet` errors never include the secret seed.
|
|
92
|
+
- `AbstractWallet.signAndBroadcastTransaction` is Python's `sign_and_broad_cast_transaction` without the spelling slip.
|
|
93
|
+
- The TS `Chain` adapters wrap the Python-parity methods: `getBalance`, `createTransferUnsignedTransaction`, `broadcast`, `verifyMessageSignature`, `getChainTipHeight`, and batch `getTransactionStatus`.
|
|
94
|
+
- Stellar's adapter rejects `isFullBalance`, because Python ignores it and the TS request then has no amount;
|
|
95
|
+
- Stellar's adapter refuses a transfer whose trustline prerequisite is still pending (same check as Python's `ensure_minimum_trust_line`), because it can only return the transaction;
|
|
96
|
+
- Tron's `broadcast` adapter throws `BroadcastRejected` only for codes java-tron returns before accepting the transaction (`SIGERROR`, `CONTRACT_VALIDATE_ERROR`, `CONTRACT_EXE_ERROR`, `BANDWITH_ERROR`). Everything else that Python returns as `broadcast_error`, `DUP_TRANSACTION_ERROR` and a reply without `txid` included, is `RpcError`: check the transaction's status before re-signing. `TRANSACTION_EXPIRATION_ERROR` and `TAPOS_ERROR` are `RpcError` too, because java-tron checks expiry before its duplicate check, so re-broadcasting a transaction that already landed returns them after the 60 s expiry;
|
|
97
|
+
- Stellar's `broadcast` adapter throws `RpcError` for a Horizon `200` without `hash` (Python's `KeyError('hash')`);
|
|
98
|
+
- `wait` / `confirmations` options are rejected, as on UTXO.
|
|
99
|
+
- Soroban `prepare` assembles the transaction like stellar-sdk Python's `_assemble_transaction`: the signed fee is the classic fee plus the simulation's `minResourceFee`.
|
|
100
|
+
- Horizon submit reads `hash` without decoding `result_xdr`, as Python does, so a landed transaction is never reported as failed because of an unknown result type.
|
|
101
|
+
|
|
102
|
+
### Known issues shared with omnichain-py
|
|
103
|
+
|
|
104
|
+
These are bugs in omnichain-py itself. They are kept for parity and tracked to be fixed in both SDKs. Consumers that credit deposits from transaction status should account for them:
|
|
105
|
+
|
|
106
|
+
- RIN-316 (Stellar) — any contract can emit a `transfer` event carrying a SAC topic and pose as USDC / XLM in status, and `resolveAsset` returns XLM for any contract whose `name()` is `"native"`.
|
|
107
|
+
- RIN-317 (Tron) — status counts rejected internal transactions and TRC-10 `callValue` as TRX, and does not debit TRX sent as `call_value`.
|
|
108
|
+
- RIN-318 (Tron) — the wallet signs the txID returned by the node (or found in a JSON payload) without recomputing it from `raw_data`.
|
|
109
|
+
- RIN-319 (Stellar) — a decimals fallback of 7 is cached after an RPC error, and Horizon effects are read from the first page (200) only.
|
|
110
|
+
- Stellar — the ID of a muxed `M…` receiver is stripped to its `G…` account when a transfer is built.
|
|
111
|
+
|
|
112
|
+
### Note — upstream behaviour mirrored as-is
|
|
113
|
+
|
|
114
|
+
- Today's Soroban RPC returns diagnostic events at the top level, not under `events` where Python reads them. Historical Soroban statuses therefore resolve through the Stellar Expert API in both SDKs.
|
|
115
|
+
- `TronTransactionFees` validates against the *current* energy price. Transactions executed under an older price fail that check in both SDKs, which affects some historical Shasta transactions.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## [0.5.1] — 2026-09-22
|
|
120
|
+
|
|
121
|
+
Surfaces Solana finality on `SolanaTransactionStatus` (RIN-296, SDK half of RIN-285). Non-blocking pollers can now read one status snapshot and see how close to finality a tx is, matching the pattern EVM (`blockNumber` + tip derivation) and UTXO (RIN-195's carried `confirmations`) already use.
|
|
122
|
+
|
|
123
|
+
### Added
|
|
124
|
+
|
|
125
|
+
- **`SolanaTransactionStatus.slot: number | null`** — from `getTransaction`'s `slot` on the success path; from `getSignatureStatus`'s `slot` on the ledger-pruned fallback.
|
|
126
|
+
- **`SolanaTransactionStatus.confirmations: number | null`** — the raw RPC count for non-final states, normalised to the exported `SOLANA_FINALIZED_CONFIRMATIONS = 32` when the RPC returns `null` (rooted, per the Solana RPC contract). `null` when the sig-status read was unavailable.
|
|
127
|
+
- **`SolanaTransactionStatus.confirmationStatus: 'processed' | 'confirmed' | 'finalized' | null`** — the raw RPC string.
|
|
128
|
+
- **`SolanaTransactionStatus.signers: readonly string[]`** — base58 signer keys in message order (the first `header.numRequiredSignatures` `staticAccountKeys`). Mirrors omnichain-py `signer_keys = account_keys[: header.num_required_signatures]` at `impl/solana/base.py:1175`. Empty on the ledger-pruned fallback and on `notFound`.
|
|
129
|
+
- **`SOLANA_FINALIZED_CONFIRMATIONS = 32`** — exported constant.
|
|
130
|
+
- **`SolanaConfirmationStatus`** — union of the three RPC states.
|
|
131
|
+
|
|
132
|
+
### Changed
|
|
133
|
+
|
|
134
|
+
- **`SolanaChain.getTransactionStatus`** fires `getTransaction` and `getSignatureStatus` in parallel via `Promise.allSettled` (RIN-296 D1) — the common Success case pays one round-trip of latency instead of two. Sig-status failure on the Success path degrades the four new fields to `null`/`[]` rather than failing the whole read (D2). The ledger-pruned Pending branch carries whatever finality it has (D3).
|
|
135
|
+
|
|
136
|
+
### Note
|
|
137
|
+
|
|
138
|
+
- No `blockNumber` field. Solana slots are not block heights (skipped slots exist) and `getChainTipHeight` returns a block height (0.3.3 fix); consumers deriving finality from `blockNumber` on other families must gate Solana on `confirmations`.
|
|
139
|
+
- **Additive only.** All new fields optional in the init with safe defaults (`null` / `[]`); every pre-0.5.1 `SolanaTransactionStatus.successful/failed/pending/notFound` call site compiles unchanged.
|
|
140
|
+
- **Note on version bump.** RIN-285 R4 specifies a **minor** bump. This release ships as a **patch** (0.5.0 → 0.5.1) per requester decision. Under SemVer this is a documented divergence — the change is additive to the public surface (new optional fields, new exported constant/type) and a minor bump would be more strictly correct.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
11
144
|
## [0.5.0] — 2026-09-21
|
|
12
145
|
|
|
13
146
|
Adds a single canonical bidirectional map between omnichain chain ids and Rango's uppercase `blockchains[].name` identifiers. Removes the need for downstream consumers that talk to Rango to maintain their own partial copies of the mapping.
|
|
@@ -369,6 +502,7 @@ Initial npm release of `@getomnichain/omnichain`. Replaces prior vendored-submod
|
|
|
369
502
|
|
|
370
503
|
---
|
|
371
504
|
|
|
505
|
+
[0.5.1]: https://github.com/getomnichain/omnichain/releases/tag/v0.5.1
|
|
372
506
|
[0.5.0]: https://github.com/getomnichain/omnichain/releases/tag/v0.5.0
|
|
373
507
|
[0.4.0]: https://github.com/getomnichain/omnichain/releases/tag/v0.4.0
|
|
374
508
|
[0.3.6]: https://github.com/getomnichain/omnichain/releases/tag/v0.3.6
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @getomnichain/omnichain
|
|
2
2
|
|
|
3
|
-
Multi-chain TypeScript SDK. One `Chain` / `Token` / `Address` / `UnsignedTransaction` shape for EVM, UTXO (BTC/LTC/DOGE/DASH/ZEC/BCH), Solana,
|
|
3
|
+
Multi-chain TypeScript SDK. One `Chain` / `Token` / `Address` / `UnsignedTransaction` shape for EVM, UTXO (BTC/LTC/DOGE/DASH/ZEC/BCH), Solana, Stellar, Tron, and TON. Line-for-line parity port of Python's [`omnichain-py`](https://github.com/getomnichain/omnichain-py).
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install @getomnichain/omnichain decimal.js
|
|
@@ -39,8 +39,8 @@ Consumer TypeScript setup: `module: "NodeNext"` + `moduleResolution: "NodeNext"`
|
|
|
39
39
|
|
|
40
40
|
## What this SDK does NOT do
|
|
41
41
|
|
|
42
|
-
- **Hold keys** —
|
|
43
|
-
- **Read environment variables** — every constructor takes an explicit config object. The
|
|
42
|
+
- **Hold keys in chain classes** — chains only emit unsigned transactions and broadcast signed ones. The opt-in `StellarWallet` / `TronWallet` classes (ported from omnichain-py) are the only key-holding code, and only when a consumer constructs them.
|
|
43
|
+
- **Read environment variables** — every constructor takes an explicit config object. The exceptions are RPC URL fallback resolution (`<NAME>_RPC_URL` / `EVM_<chainId>_RPC_URL` / `SOLANA_<chainId>_RPC_URL` / `TRON_<chainId>_RPC_URL`, and Stellar's `*_HORIZON_URL` / `*_SOROBAN_RPC_URL`) and `TRONGRID_API_KEY`, all mirroring omnichain-py and documented per chain.
|
|
44
44
|
- **Decide chain IDs** — non-EVM chains have no universal numeric ID; consumers can seed a synthetic scheme via `registerNonEvmChain(id, family)`.
|
|
45
45
|
- **Ship infrastructure** — RPC URLs, indexer keys, Bitcoin Core / Esplora endpoints are consumer-owned.
|
|
46
46
|
|
|
@@ -59,6 +59,8 @@ Consumer TypeScript setup: `module: "NodeNext"` + `moduleResolution: "NodeNext"`
|
|
|
59
59
|
- [docs/evm.md](./docs/evm.md) — EVM chains and ERC-20
|
|
60
60
|
- [docs/utxo.md](./docs/utxo.md) — Bitcoin / Litecoin / Dogecoin, fee estimation, BTC asset filtering
|
|
61
61
|
- [docs/solana.md](./docs/solana.md) — Solana, SPL Token, Token-2022, priority-fee model
|
|
62
|
+
- [docs/stellar.md](./docs/stellar.md) — Stellar classic + Soroban, SAC / non-SAC assets, trustlines, SEP-5/SEP-53 wallet
|
|
63
|
+
- [docs/tron.md](./docs/tron.md) — Tron TRX + TRC-20, energy fees, approve prerequisites, canonical transaction schema
|
|
62
64
|
- [docs/PUBLISHING.md](./docs/PUBLISHING.md) — release + npm publish workflow
|
|
63
65
|
|
|
64
66
|
## License
|
|
@@ -8,7 +8,9 @@ const errors_ts_1 = require("./errors.js");
|
|
|
8
8
|
const network_type_ts_1 = require("./network_type.js");
|
|
9
9
|
const evm_address_ts_1 = require("./evm/evm_address.js");
|
|
10
10
|
const solana_address_ts_1 = require("./solana/solana_address.js");
|
|
11
|
+
const stellar_address_ts_1 = require("./stellar/stellar_address.js");
|
|
11
12
|
const ton_address_ts_1 = require("./ton/ton_address.js");
|
|
13
|
+
const tron_address_ts_1 = require("./tron/tron_address.js");
|
|
12
14
|
const btc_address_ts_1 = require("./utxo/btc/btc_address.js");
|
|
13
15
|
const network_params_ts_1 = require("./utxo/btc/network_params.js");
|
|
14
16
|
function addressFor(chainId, raw) {
|
|
@@ -22,11 +24,12 @@ function addressFor(chainId, raw) {
|
|
|
22
24
|
return new btc_address_ts_1.BtcAddress(raw, (0, network_params_ts_1.btcParamsForChainId)(BigInt(chainId)));
|
|
23
25
|
case network_type_ts_1.NetworkType.TON:
|
|
24
26
|
return new ton_address_ts_1.TonAddress(raw);
|
|
25
|
-
// TRON / COSMOS have no in-repo Address class yet. Rather than fall through
|
|
26
|
-
// to EvmAddress (which would silently accept a valid EVM address for a
|
|
27
|
-
// Tron chain and un-canonicalize base58 T… addresses), fail closed until
|
|
28
|
-
// the concrete implementations land.
|
|
29
27
|
case network_type_ts_1.NetworkType.TRON:
|
|
28
|
+
return new tron_address_ts_1.TronAddress(raw);
|
|
29
|
+
case network_type_ts_1.NetworkType.STELLAR:
|
|
30
|
+
return new stellar_address_ts_1.StellarAddress(raw);
|
|
31
|
+
// COSMOS has no in-repo Address class yet. Rather than fall through to
|
|
32
|
+
// EvmAddress, fail closed until the concrete implementation lands.
|
|
30
33
|
case network_type_ts_1.NetworkType.COSMOS:
|
|
31
34
|
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.ChainNotSupported, `${family} address parsing is not implemented for chainId ${chainId}`, { chainId });
|
|
32
35
|
default: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.factory.js","sourceRoot":"","sources":["../../address.factory.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"address.factory.js","sourceRoot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AAiB,EACjC,yBAAyB,MAAM,CAAC,UAAU,CAAC,gBAAgB,OAAO,EAAE,EACpE,EAAE,OAAO,EAAE,CACZ,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAAe,EAAE,GAAW;IAC9D,OAAO,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAe,EAAE,GAAW;IACjE,IAAI,CAAC;QACH,OAAO,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,yBAAyB,CAAC,OAAe,EAAE,GAAW;IACpE,IAAI,CAAC;QACH,OAAO,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,IAAA,wBAAY,EAAC,CAAC,EAAE,2BAAe,CAAC,iBAAiB,CAAC;YAAE,MAAM,CAAC,CAAC;QAChE,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset_balance.js","sourceRoot":"","sources":["../../asset_balance.ts"],"names":[],"mappings":";;;AAEA,MAAsB,oBAAoB;CAEzC;AAFD,oDAEC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssetMap = void 0;
|
|
4
|
+
exports.assetMapKey = assetMapKey;
|
|
5
|
+
function assetMapKey(asset) {
|
|
6
|
+
return JSON.stringify([asset.chainId, asset.symbol, asset.identifier ?? null, asset.decimals]);
|
|
7
|
+
}
|
|
8
|
+
class AssetMap extends Map {
|
|
9
|
+
#storedKeys = new Map();
|
|
10
|
+
constructor(entries) {
|
|
11
|
+
super();
|
|
12
|
+
for (const [key, value] of entries ?? [])
|
|
13
|
+
this.set(key, value);
|
|
14
|
+
}
|
|
15
|
+
get(key) {
|
|
16
|
+
const stored = this.#storedKeys.get(assetMapKey(key));
|
|
17
|
+
return stored === undefined ? undefined : super.get(stored);
|
|
18
|
+
}
|
|
19
|
+
has(key) {
|
|
20
|
+
return this.#storedKeys.has(assetMapKey(key));
|
|
21
|
+
}
|
|
22
|
+
set(key, value) {
|
|
23
|
+
const lookupKey = assetMapKey(key);
|
|
24
|
+
let stored = this.#storedKeys.get(lookupKey);
|
|
25
|
+
if (stored === undefined) {
|
|
26
|
+
stored = key;
|
|
27
|
+
this.#storedKeys.set(lookupKey, stored);
|
|
28
|
+
}
|
|
29
|
+
return super.set(stored, value);
|
|
30
|
+
}
|
|
31
|
+
delete(key) {
|
|
32
|
+
const lookupKey = assetMapKey(key);
|
|
33
|
+
const stored = this.#storedKeys.get(lookupKey);
|
|
34
|
+
if (stored === undefined)
|
|
35
|
+
return false;
|
|
36
|
+
this.#storedKeys.delete(lookupKey);
|
|
37
|
+
return super.delete(stored);
|
|
38
|
+
}
|
|
39
|
+
clear() {
|
|
40
|
+
this.#storedKeys.clear();
|
|
41
|
+
super.clear();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.AssetMap = AssetMap;
|
|
45
|
+
//# sourceMappingURL=asset_map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset_map.js","sourceRoot":"","sources":["../../asset_map.ts"],"names":[],"mappings":";;;AAEA,kCAEC;AAFD,SAAgB,WAAW,CAAC,KAAY;IACtC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AACjG,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;YAAE,OAAO,KAAK,CAAC;QACvC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAEQ,KAAK;QACZ,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;CACF;AAvCD,4BAuCC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assetRegistryKey = assetRegistryKey;
|
|
4
|
+
exports.registerAsset = registerAsset;
|
|
5
|
+
exports.searchRegisteredAsset = searchRegisteredAsset;
|
|
6
|
+
exports.getRegisteredAsset = getRegisteredAsset;
|
|
7
|
+
const assetRegistry = new Map();
|
|
8
|
+
function assetRegistryKey(chainId, symbol, identifier) {
|
|
9
|
+
return `${chainId}_${symbol}_${identifier || ''}`;
|
|
10
|
+
}
|
|
11
|
+
function registerAsset(asset) {
|
|
12
|
+
assetRegistry.set(assetRegistryKey(asset.chainId, asset.symbol, asset.identifier), asset);
|
|
13
|
+
}
|
|
14
|
+
function searchRegisteredAsset(chainId, identifier) {
|
|
15
|
+
const matches = [...assetRegistry.values()].filter((asset) => asset.chainId === chainId && (asset.identifier ?? null) === identifier);
|
|
16
|
+
return matches.length === 1 ? matches[0] : null;
|
|
17
|
+
}
|
|
18
|
+
function getRegisteredAsset(chainId, symbol, identifier) {
|
|
19
|
+
return assetRegistry.get(assetRegistryKey(chainId, symbol, identifier)) ?? null;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=asset_registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset_registry.js","sourceRoot":"","sources":["../../asset_registry.ts"],"names":[],"mappings":";;AAIA,4CAEC;AAED,sCAEC;AAED,sDAGC;AAED,gDAEC;AAjBD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAiB,CAAC;AAE/C,SAAgB,gBAAgB,CAAC,OAAe,EAAE,MAAc,EAAE,UAAqC;IACrG,OAAO,GAAG,OAAO,IAAI,MAAM,IAAI,UAAU,IAAI,EAAE,EAAE,CAAC;AACpD,CAAC;AAED,SAAgB,aAAa,CAAC,KAAY;IACxC,aAAa,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC;AAC5F,CAAC;AAED,SAAgB,qBAAqB,CAAC,OAAe,EAAE,UAAyB;IAC9E,MAAM,OAAO,GAAG,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,UAAU,CAAC,CAAC;IACtI,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED,SAAgB,kBAAkB,CAAC,OAAe,EAAE,MAAc,EAAE,UAAyB;IAC3F,OAAO,aAAa,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,IAAI,IAAI,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidEnglishMnemonic = isValidEnglishMnemonic;
|
|
4
|
+
exports.mnemonicToSeedSep5 = mnemonicToSeedSep5;
|
|
5
|
+
exports.mnemonicToSeedBip39 = mnemonicToSeedBip39;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const errors_ts_1 = require("./errors.js");
|
|
9
|
+
const python_builtins_ts_1 = require("./python_builtins.js");
|
|
10
|
+
const BIP39_PBKDF2_ROUNDS = 2048;
|
|
11
|
+
const BIP39_SEED_BYTES = 64;
|
|
12
|
+
const BIP39_VALID_WORD_COUNTS = new Set([12, 15, 18, 21, 24]);
|
|
13
|
+
const BIP_UTILS_LANGUAGE_ORDER = ['zh_cn', 'zh_tw', 'cz', 'en', 'fr', 'it', 'ko', 'pt', 'es'];
|
|
14
|
+
const normalizedWordIndexCache = new Map();
|
|
15
|
+
function nfkd(value) {
|
|
16
|
+
return value.normalize('NFKD');
|
|
17
|
+
}
|
|
18
|
+
function normalizedWordIndex(language, wordlist) {
|
|
19
|
+
let index = normalizedWordIndexCache.get(language);
|
|
20
|
+
if (index === undefined) {
|
|
21
|
+
index = new Map();
|
|
22
|
+
for (let i = 0; i < 2048; i++)
|
|
23
|
+
index.set(nfkd(wordlist.getWord(i)), i);
|
|
24
|
+
normalizedWordIndexCache.set(language, index);
|
|
25
|
+
}
|
|
26
|
+
return index;
|
|
27
|
+
}
|
|
28
|
+
function wordIndexes(words, language) {
|
|
29
|
+
const wordlist = ethers_1.wordlists[language];
|
|
30
|
+
const index = normalizedWordIndex(language, wordlist);
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const word of words) {
|
|
33
|
+
const i = index.get(word);
|
|
34
|
+
if (i === undefined)
|
|
35
|
+
return null;
|
|
36
|
+
out.push(i);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
function checksumMatches(indexes) {
|
|
41
|
+
const bits = indexes.map((i) => i.toString(2).padStart(11, '0')).join('');
|
|
42
|
+
const checksumLength = Math.floor(bits.length / 33);
|
|
43
|
+
const entropyBits = bits.slice(0, checksumLength * 32);
|
|
44
|
+
const checksumBits = bits.slice(bits.length - checksumLength);
|
|
45
|
+
const entropy = Buffer.from(BigInt(`0b${entropyBits}`).toString(16).padStart(checksumLength * 8, '0'), 'hex');
|
|
46
|
+
const hashBits = BigInt(`0x${(0, node_crypto_1.createHash)('sha256').update(entropy).digest('hex')}`).toString(2).padStart(256, '0');
|
|
47
|
+
return hashBits.slice(0, checksumLength) === checksumBits;
|
|
48
|
+
}
|
|
49
|
+
function pbkdf2Seed(mnemonic, salt) {
|
|
50
|
+
return new Uint8Array((0, node_crypto_1.pbkdf2Sync)((0, python_builtins_ts_1.pyEncodeUtf8)(mnemonic), (0, python_builtins_ts_1.pyEncodeUtf8)(salt), BIP39_PBKDF2_ROUNDS, BIP39_SEED_BYTES, 'sha512'));
|
|
51
|
+
}
|
|
52
|
+
function isValidEnglishMnemonic(mnemonic) {
|
|
53
|
+
const words = nfkd(mnemonic).split(' ');
|
|
54
|
+
if (!BIP39_VALID_WORD_COUNTS.has(words.length))
|
|
55
|
+
return false;
|
|
56
|
+
const indexes = wordIndexes(words, 'en');
|
|
57
|
+
return indexes !== null && checksumMatches(indexes);
|
|
58
|
+
}
|
|
59
|
+
function mnemonicToSeedSep5(mnemonic, passphrase = '') {
|
|
60
|
+
if (!isValidEnglishMnemonic(mnemonic)) {
|
|
61
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'Invalid mnemonic, please check if the mnemonic is correct, or if the language is set correctly.');
|
|
62
|
+
}
|
|
63
|
+
return pbkdf2Seed(nfkd(mnemonic), `mnemonic${nfkd(passphrase)}`);
|
|
64
|
+
}
|
|
65
|
+
function mnemonicToSeedBip39(mnemonic, passphrase = '') {
|
|
66
|
+
const words = mnemonic
|
|
67
|
+
.trim()
|
|
68
|
+
.split(/\s+/)
|
|
69
|
+
.filter((w) => w.length > 0)
|
|
70
|
+
.map((w) => nfkd(w.toLowerCase()));
|
|
71
|
+
if (!BIP39_VALID_WORD_COUNTS.has(words.length)) {
|
|
72
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `Mnemonic words count is not valid (${words.length})`);
|
|
73
|
+
}
|
|
74
|
+
let indexes = null;
|
|
75
|
+
for (const language of BIP_UTILS_LANGUAGE_ORDER) {
|
|
76
|
+
indexes = wordIndexes(words, language);
|
|
77
|
+
if (indexes !== null)
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (indexes === null) {
|
|
81
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'Invalid language for mnemonic');
|
|
82
|
+
}
|
|
83
|
+
if (!checksumMatches(indexes)) {
|
|
84
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'Invalid checksum');
|
|
85
|
+
}
|
|
86
|
+
return pbkdf2Seed(words.join(' '), nfkd(`mnemonic${passphrase}`));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=bip39.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bip39.js","sourceRoot":"","sources":["../../bip39.ts"],"names":[],"mappings":";;AAsDA,wDAKC;AAED,gDAQC;AAED,kDAqBC;AA5FD,6CAAqD;AAErD,mCAA6C;AAE7C,2CAA0D;AAC1D,6DAAoD;AAEpD,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACnF,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAEvG,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAA+B,CAAC;AAExE,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,mBAAmB,CAAC,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,+BAA+B,CAAC,CAAC;IACzF,CAAC;IACD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,sBAAU,CAAC,2BAAe,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,WAAW,UAAU,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bytesFromHex = bytesFromHex;
|
|
4
|
+
const errors_ts_1 = require("./errors.js");
|
|
5
|
+
const PY_ASCII_WHITESPACE = new Set([' ', '\t', '\n', '\v', '\f', '\r']);
|
|
6
|
+
function bytesFromHex(hex) {
|
|
7
|
+
const firstNonAscii = hex.search(/[^\x00-\x7f]/);
|
|
8
|
+
if (firstNonAscii !== -1)
|
|
9
|
+
throw nonHexadecimalAt(firstNonAscii);
|
|
10
|
+
const out = [];
|
|
11
|
+
let position = 0;
|
|
12
|
+
while (position < hex.length) {
|
|
13
|
+
if (PY_ASCII_WHITESPACE.has(hex[position])) {
|
|
14
|
+
position += 1;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const high = hexDigit(hex[position]);
|
|
18
|
+
if (high === null)
|
|
19
|
+
throw nonHexadecimalAt(position);
|
|
20
|
+
const low = position + 1 < hex.length ? hexDigit(hex[position + 1]) : null;
|
|
21
|
+
if (low === null)
|
|
22
|
+
throw nonHexadecimalAt(position + 1);
|
|
23
|
+
out.push(high * 16 + low);
|
|
24
|
+
position += 2;
|
|
25
|
+
}
|
|
26
|
+
return Uint8Array.from(out);
|
|
27
|
+
}
|
|
28
|
+
function hexDigit(char) {
|
|
29
|
+
return /^[0-9a-fA-F]$/.test(char) ? parseInt(char, 16) : null;
|
|
30
|
+
}
|
|
31
|
+
function nonHexadecimalAt(position) {
|
|
32
|
+
return new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `non-hexadecimal number found in fromhex() arg at position ${position}`);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=bytes_from_hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes_from_hex.js","sourceRoot":"","sources":["../../bytes_from_hex.ts"],"names":[],"mappings":";;AAIA,oCAkBC;AAtBD,2CAA0D;AAE1D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEzE,SAAgB,YAAY,CAAC,GAAW;IACtC,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACjD,IAAI,aAAa,KAAK,CAAC,CAAC;QAAE,MAAM,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAChE,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,OAAO,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QAC7B,IAAI,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YAC3C,QAAQ,IAAI,CAAC,CAAC;YACd,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACpD,MAAM,GAAG,GAAG,QAAQ,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3E,IAAI,GAAG,KAAK,IAAI;YAAE,MAAM,gBAAgB,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;QACvD,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;QAC1B,QAAQ,IAAI,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,IAAI,sBAAU,CACnB,2BAAe,CAAC,eAAe,EAC/B,6DAA6D,QAAQ,EAAE,CACxE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiatCurrency = exports.WalletFamily = exports.ChainType = void 0;
|
|
4
|
+
var ChainType;
|
|
5
|
+
(function (ChainType) {
|
|
6
|
+
ChainType["EVM"] = "EVM";
|
|
7
|
+
ChainType["SOLANA"] = "SOLANA";
|
|
8
|
+
ChainType["UTXO"] = "UTXO";
|
|
9
|
+
ChainType["SUI"] = "SUI";
|
|
10
|
+
ChainType["XRPL"] = "XRPL";
|
|
11
|
+
ChainType["STELLAR"] = "STELLAR";
|
|
12
|
+
ChainType["TRON"] = "TRON";
|
|
13
|
+
ChainType["TON"] = "TON";
|
|
14
|
+
})(ChainType || (exports.ChainType = ChainType = {}));
|
|
15
|
+
var WalletFamily;
|
|
16
|
+
(function (WalletFamily) {
|
|
17
|
+
WalletFamily["EVM"] = "EVM";
|
|
18
|
+
WalletFamily["SOLANA"] = "SOLANA";
|
|
19
|
+
WalletFamily["SUI"] = "SUI";
|
|
20
|
+
WalletFamily["XRPL"] = "XRPL";
|
|
21
|
+
WalletFamily["STELLAR"] = "STELLAR";
|
|
22
|
+
WalletFamily["TRON"] = "TRON";
|
|
23
|
+
WalletFamily["TON"] = "TON";
|
|
24
|
+
WalletFamily["BITCOIN"] = "BITCOIN";
|
|
25
|
+
WalletFamily["LITECOIN"] = "LITECOIN";
|
|
26
|
+
WalletFamily["DOGECOIN"] = "DOGECOIN";
|
|
27
|
+
WalletFamily["DASH"] = "DASH";
|
|
28
|
+
WalletFamily["BCH"] = "BCH";
|
|
29
|
+
})(WalletFamily || (exports.WalletFamily = WalletFamily = {}));
|
|
30
|
+
var FiatCurrency;
|
|
31
|
+
(function (FiatCurrency) {
|
|
32
|
+
FiatCurrency["USD"] = "USD";
|
|
33
|
+
FiatCurrency["EUR"] = "EUR";
|
|
34
|
+
})(FiatCurrency || (exports.FiatCurrency = FiatCurrency = {}));
|
|
35
|
+
//# sourceMappingURL=chain_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain_type.js","sourceRoot":"","sources":["../../chain_type.ts"],"names":[],"mappings":";;;AAAA,IAAY,SASX;AATD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,8BAAiB,CAAA;IACjB,0BAAa,CAAA;IACb,wBAAW,CAAA;IACX,0BAAa,CAAA;IACb,gCAAmB,CAAA;IACnB,0BAAa,CAAA;IACb,wBAAW,CAAA;AACb,CAAC,EATW,SAAS,yBAAT,SAAS,QASpB;AAED,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,iCAAiB,CAAA;IACjB,2BAAW,CAAA;IACX,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,6BAAa,CAAA;IACb,2BAAW,CAAA;IACX,mCAAmB,CAAA;IACnB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,2BAAW,CAAA;AACb,CAAC,EAbW,YAAY,4BAAZ,YAAY,QAavB;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,2BAAW,CAAA;AACb,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -18,16 +18,28 @@ __exportStar(require("./abstract_gas_pricing.js"), exports);
|
|
|
18
18
|
__exportStar(require("./address.js"), exports);
|
|
19
19
|
__exportStar(require("./address.factory.js"), exports);
|
|
20
20
|
__exportStar(require("./address_field.decorator.js"), exports);
|
|
21
|
+
__exportStar(require("./asset_balance.js"), exports);
|
|
22
|
+
__exportStar(require("./asset_map.js"), exports);
|
|
23
|
+
__exportStar(require("./asset_registry.js"), exports);
|
|
24
|
+
__exportStar(require("./bip39.js"), exports);
|
|
21
25
|
__exportStar(require("./chain.base.js"), exports);
|
|
22
26
|
__exportStar(require("./chain_ids.js"), exports);
|
|
27
|
+
__exportStar(require("./chain_type.js"), exports);
|
|
23
28
|
__exportStar(require("./errors.js"), exports);
|
|
24
29
|
__exportStar(require("./is_address.decorator.js"), exports);
|
|
25
30
|
__exportStar(require("./network_type.js"), exports);
|
|
26
31
|
__exportStar(require("./priority.js"), exports);
|
|
32
|
+
__exportStar(require("./python_json.js"), exports);
|
|
33
|
+
__exportStar(require("./python_repr.js"), exports);
|
|
27
34
|
__exportStar(require("./rango_chain_names.js"), exports);
|
|
35
|
+
__exportStar(require("./signed_transaction.js"), exports);
|
|
28
36
|
__exportStar(require("./token.js"), exports);
|
|
37
|
+
__exportStar(require("./transaction_json.js"), exports);
|
|
38
|
+
__exportStar(require("./transaction_prerequisite.js"), exports);
|
|
39
|
+
__exportStar(require("./transaction_simulation.js"), exports);
|
|
29
40
|
__exportStar(require("./transaction_status.js"), exports);
|
|
30
41
|
__exportStar(require("./unsigned_transaction.js"), exports);
|
|
42
|
+
__exportStar(require("./wallet.base.js"), exports);
|
|
31
43
|
__exportStar(require("./evm/index.js"), exports);
|
|
32
44
|
__exportStar(require("./solana/index.js"), exports);
|
|
33
45
|
__exportStar(require("./ton/index.js"), exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,+CAA6B;AAC7B,uDAAqC;AACrC,+DAA6C;AAC7C,kDAAgC;AAChC,iDAA+B;AAC/B,8CAA4B;AAC5B,4DAA0C;AAC1C,oDAAkC;AAClC,gDAA8B;AAC9B,yDAAuC;AACvC,6CAA2B;AAC3B,0DAAwC;AACxC,4DAA0C;AAC1C,iDAA+B;AAC/B,oDAAkC;AAClC,iDAA+B;AAC/B,kDAAgC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,+CAA6B;AAC7B,uDAAqC;AACrC,+DAA6C;AAC7C,qDAAmC;AACnC,iDAA+B;AAC/B,sDAAoC;AACpC,6CAA2B;AAC3B,kDAAgC;AAChC,iDAA+B;AAC/B,kDAAgC;AAChC,8CAA4B;AAC5B,4DAA0C;AAC1C,oDAAkC;AAClC,gDAA8B;AAC9B,mDAAiC;AACjC,mDAAiC;AACjC,yDAAuC;AACvC,0DAAwC;AACxC,6CAA2B;AAC3B,wDAAsC;AACtC,gEAA8C;AAC9C,8DAA4C;AAC5C,0DAAwC;AACxC,4DAA0C;AAC1C,mDAAiC;AACjC,iDAA+B;AAC/B,oDAAkC;AAClC,iDAA+B;AAC/B,kDAAgC"}
|
package/dist/cjs/network_type.js
CHANGED
|
@@ -24,10 +24,11 @@ var NetworkType;
|
|
|
24
24
|
NetworkType["SOLANA"] = "SOLANA";
|
|
25
25
|
NetworkType["BTC"] = "BTC";
|
|
26
26
|
NetworkType["TRON"] = "TRON";
|
|
27
|
+
NetworkType["STELLAR"] = "STELLAR";
|
|
27
28
|
})(NetworkType || (exports.NetworkType = NetworkType = {}));
|
|
28
29
|
const networkTypeRegistry = new Map();
|
|
29
30
|
// Seed the registry statically for families that have a working address
|
|
30
|
-
// parser
|
|
31
|
+
// parser. BTC (bech32 + base58 with BTC HRPs), Solana, TON, Tron, Stellar.
|
|
31
32
|
//
|
|
32
33
|
// LTC/DOGE/DASH/ZEC/BCH are NOT statically seeded: their address grammars
|
|
33
34
|
// differ from BTC's (different HRPs, different version bytes, CashAddr for
|
|
@@ -48,6 +49,8 @@ for (const id of chain_ids_ts_1.CHAIN_FAMILY_TON)
|
|
|
48
49
|
networkTypeRegistry.set(id, NetworkType.TON);
|
|
49
50
|
for (const id of chain_ids_ts_1.CHAIN_FAMILY_TRON)
|
|
50
51
|
networkTypeRegistry.set(id, NetworkType.TRON);
|
|
52
|
+
for (const id of chain_ids_ts_1.CHAIN_FAMILY_STELLAR)
|
|
53
|
+
networkTypeRegistry.set(id, NetworkType.STELLAR);
|
|
51
54
|
/**
|
|
52
55
|
* Register (or re-register) a chainId's NetworkType. Idempotent for the SAME
|
|
53
56
|
* NetworkType; throws `ChainError(InvalidArgument)` on a conflict — silently
|
|
@@ -106,7 +109,7 @@ function networkTypeRegistrations() {
|
|
|
106
109
|
/**
|
|
107
110
|
* Resolve the NetworkType for a chainId.
|
|
108
111
|
*
|
|
109
|
-
* - Static seeds (UTXO / Solana / TON / Tron families from `chain_ids.ts`)
|
|
112
|
+
* - Static seeds (UTXO / Solana / TON / Tron / Stellar families from `chain_ids.ts`)
|
|
110
113
|
* win first.
|
|
111
114
|
* - Instance constructors override via `registerNonEvmChain` (idempotent per
|
|
112
115
|
* the guard above).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network_type.js","sourceRoot":"","sources":["../../network_type.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"network_type.js","sourceRoot":"","sources":["../../network_type.ts"],"names":[],"mappings":";;;AAoEA,kDAmBC;AAkBD,0CAEC;AAOD,4DAEC;AAiBD,sCAmBC;AASD,4CAMC;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