@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/docs/tron.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Tron
|
|
2
|
+
|
|
3
|
+
`@getomnichain/omnichain/tron` is a port of omnichain-py's `impl/tron` (`chains.py`, `assets.py`, `base.py`, `helpers/transaction.py`) together with the parts of `tronpy` it relies on (HTTP provider, transaction builder, TRC-20 contract calls, keys). There is no `tronweb` dependency: the same TronGrid HTTP endpoints tronpy calls are called directly, with `ethers` for secp256k1/keccak/ABI and `bs58` for addresses.
|
|
4
|
+
|
|
5
|
+
The family is imported from `@getomnichain/omnichain/tron` only. Like Python's `import omnichain`, the root entry does not load it.
|
|
6
|
+
|
|
7
|
+
## Chains and assets
|
|
8
|
+
|
|
9
|
+
| Export | Value |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `TronMainnet` | chain id `728126428`, RPC `https://api.trongrid.io`, explorer `https://tronscan.org` |
|
|
12
|
+
| `TronShastaTestnet` | chain id `2494104990`, RPC `https://api.shasta.trongrid.io`, explorer `https://shasta.tronscan.org` |
|
|
13
|
+
| `TRON_TRX`, `TRON_USDT`, `TRON_USDC` | mainnet native and TRC-20 (6 decimals) |
|
|
14
|
+
| `TRON_SHASTA_TRX`, `TRON_SHASTA_USDT` | Shasta counterparts |
|
|
15
|
+
| `TRON_ASSETS_REQUIRING_ZERO_RESET_APPROVAL` | `[TRON_USDT]` |
|
|
16
|
+
| `TRON_MAINNET_STABLECOINS_PEG` | `USDC → USD`, `USDT → USD` |
|
|
17
|
+
|
|
18
|
+
Block time is 3 s. The RPC URL resolves like Python: constructor `rpcUrl`, then `<NAME>_RPC_URL`, then `TRON_<chainId>_RPC_URL`, then the default. The TronGrid key comes from the constructor `trongridApiKey` or the `TRONGRID_API_KEY` environment variable, and is sent as `Tron-Pro-Api-Key` only to `trongrid` endpoints. tronpy's bundled shared keys are not copied; without a key TronGrid allows about 3 requests per second.
|
|
19
|
+
|
|
20
|
+
`TronAsset` covers native TRX (`symbol: 'TRX'`, 6 decimals, no contract) and TRC-20 tokens (base58check contract address). Every constructed `TronAsset` is registered so status decoding can reuse known token metadata without an RPC call, as Python's asset registry does.
|
|
21
|
+
|
|
22
|
+
## Moving funds
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { Decimal } from 'decimal.js';
|
|
26
|
+
import { TronMainnet, TRON_USDT, TronWallet } from '@getomnichain/omnichain/tron';
|
|
27
|
+
|
|
28
|
+
const { transaction } = await TronMainnet.createTransferTransaction({
|
|
29
|
+
asset: TRON_USDT,
|
|
30
|
+
amountHr: new Decimal('748'),
|
|
31
|
+
senderAddress: sender,
|
|
32
|
+
receiverAddress: receiver,
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- Native TRX builds a `TransferContract`. With `isFullBalance: true` the amount is reduced by 0.3 TRX (`DEFAULT_TRX_FEE_LIMIT_SUN`).
|
|
37
|
+
- TRC-20 builds a `TriggerSmartContract` calling `transfer(address,uint256)` with a 15 TRX `fee_limit` (`DEFAULT_TRC20_TRANSFER_FEE_LIMIT_SUN`), or the `feeLimitSun` of an explicit `TronGasPricing`. `FeePriority` has no effect on Tron.
|
|
38
|
+
- `memo` is stored hex-encoded in `raw_data.data`.
|
|
39
|
+
- `raw_data` is built exactly like tronpy: current timestamp, 60 s expiration, TAPoS reference from the latest solid block (`wallet/getnodeinfo`). The txID and the account permission come from `wallet/getsignweight`.
|
|
40
|
+
- `transaction.canonicalTransaction` parses the wire JSON into the 12-contract discriminated union from `helpers/transaction.py` (`parseTronCanonicalTransaction`).
|
|
41
|
+
|
|
42
|
+
## Signing and broadcasting
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const wallet = TronWallet.fromMnemonic(mnemonic); // m/44'/195'/0'/0/0 (BIP-44 secp256k1)
|
|
46
|
+
const signed = await wallet.signTransaction(transaction, TronMainnet);
|
|
47
|
+
const response = await TronMainnet.broadcastSignedTransaction(signed);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- Signatures are tronpy's: RFC 6979 recoverable `r || s || recid` over the txID, appended to the transaction's signature list (like tronpy, signing mutates the transaction). Messages use the TIP-191 `"\x19TRON Signed Message:\n"` keccak hash.
|
|
51
|
+
- `broadcastSignedTransaction` never throws: node rejections such as `DUP_TRANSACTION_ERROR`, `SERVER_BUSY` or `BLOCK_UNSOLIDIFIED` come back as `broadcastError` with the txID kept. A reply without `txid` is Python's `KeyError('txid')`. The TS `Chain.broadcast` adapter accepts the signed JSON and throws. It throws `BroadcastRejected` only for the codes java-tron returns before accepting the transaction (`SIGERROR`, `CONTRACT_VALIDATE_ERROR`, `CONTRACT_EXE_ERROR`, `BANDWITH_ERROR`) and `TransactionTooLarge` for `TOO_BIG_TRANSACTION_ERROR`. Everything else, including `DUP_TRANSACTION_ERROR`, `SERVER_BUSY`, `OTHER_ERROR`, unknown codes and a reply without `txid`, is `RpcError`: the transaction may be on-chain, so check its status and re-broadcast the same signed bytes rather than re-signing, as Python's warning says. `TRANSACTION_EXPIRATION_ERROR` and `TAPOS_ERROR` are `RpcError` too: java-tron checks expiry before its duplicate check, so re-broadcasting a transaction that already landed returns them after the 60 s expiry.
|
|
52
|
+
- `TronChain` constructs for any chain id (Nile, private networks) and never touches the network-type registry, as Python's constructor registers nothing.
|
|
53
|
+
- `broadcastSignedTransaction` takes the node's `txid` like Python (`result.get("txid") or signed.tx_hash`). The `broadcast` adapter returns the signed txID (lowercase) and throws `RpcError` if the node answers a different one, compared case-insensitively.
|
|
54
|
+
- Loading a TRC-20 contract checks the `getcontract` reply like tronpy's `AsyncContract`: a `bytecode` that is not hex and an `abi` that is not an object raise tronpy's texts before any other call.
|
|
55
|
+
- A TronGrid reply that is valid JSON but not an object fails like Python's `payload.get` (`'str' object has no attribute 'get'`) as `RpcError`, without echoing the reply.
|
|
56
|
+
- External signers sign `transaction.txId` and attach the signature with `transaction.transaction.setSignature([...])`.
|
|
57
|
+
- `TronWallet.handleTransactionPrerequisite` handles `TronApproveTransactionPrerequisite`. It reads the current allowance, skips if it is enough, and otherwise approves (25 TRX fee limit). For USDT-style tokens it first resets the allowance to 0 and waits three blocks; these are tokens in `ZERO_RESET_APPROVAL_TRC20_ADDRESSES` or prerequisites with `requiresZeroResetFirst`.
|
|
58
|
+
|
|
59
|
+
## Reading state
|
|
60
|
+
|
|
61
|
+
- `getAssetBalance(asset, owner)` — TRX from `wallet/getaccount` (0 for an unknown account), TRC-20 from `balanceOf`.
|
|
62
|
+
- `getTransactionStatus(hash, { filteredWallets, filteredAssets })` merges three sources, like Python:
|
|
63
|
+
- `TransferContract` entries;
|
|
64
|
+
- internal transactions (`callValueInfo`);
|
|
65
|
+
- TRC-20 `Transfer` logs;
|
|
66
|
+
- plus the fee debited from the first contract's owner.
|
|
67
|
+
|
|
68
|
+
Unknown TRC-20 tokens are resolved through `symbol()`/`decimals()`. `fees` is a `TronTransactionFees`, whose constructor enforces Python's rule `energyUsageTotal = energyUsage + originEnergyUsage + energyFee / getEnergyFee`.
|
|
69
|
+
- `simulateTransaction` dry-runs `TriggerSmartContract` through `wallet/triggerconstantcontract` and reports `energyUsed`; other contract types throw `FeatureNotSupported` (Python's `NotImplementedError`). `supportsFullTransactionSimulation` is `false`.
|
|
70
|
+
|
|
71
|
+
## Differences from omnichain-py
|
|
72
|
+
|
|
73
|
+
| Python | TS | Why |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| Any exception from `gettransactioninfobyid` (429, 5xx) is reported as `NotFound`; a failed `gettransactionbyid` is swallowed | Only "not found" maps to `NotFound`; transport and API errors throw `ChainError` | A rate limit must not look like a dropped transaction |
|
|
76
|
+
| `print()` debugging in `simulate_transaction` / `get_transaction_status` | Removed | Library code must not write to stdout |
|
|
77
|
+
| tronpy falls back to its own shared TronGrid keys | Anonymous access without a configured key | Those keys belong to the tronpy project |
|
|
78
|
+
| On TronGrid `403 "Exceed the user daily usage"`, tronpy raises `ApiError('rate limit! please add more API keys')` and drops the key for the rest of the process | Same text as `ChainError(RpcError)`; the key is kept for later requests | One rate-limit window must not disable the client permanently |
|
|
79
|
+
| `private_key_hex` / `_private_key` are plain attributes | `#private` fields; `wallet.privateKeyHex` still returns the key | `JSON.stringify` and the default `util.inspect` never print the key or the TronGrid API key, and a non-JSON TronGrid reply never reaches an error text |
|
|
80
|
+
| `is_base58check_address` raises `ValueError` on a bad checksum | Returns `false`; callers raise their own error | TS predicates do not throw |
|
|
81
|
+
| `logger.warning` for non-NORMAL `FeePriority` | No logging | The TS SDK has no logger |
|
|
82
|
+
|
|
83
|
+
`TronClient` behaves like tronpy's httpx provider: it never follows redirects, it raises httpx's `raise_for_status` text on non-2xx responses, and its timeout restarts on every received chunk. Contract calls go through `tronAbiEncodeSingle` / `tronAbiDecodeSingle`, a port of tronpy's `trx_abi` (strict eth_abi decoding, Tron addresses inside arrays and tuples). `TronTransaction.sign` refuses the payloads tronpy's `AsyncTransaction.sign` refuses, with the same texts.
|
|
84
|
+
|
|
85
|
+
Hex input (keys, signatures, txIDs, node messages) is parsed exactly like Python's `bytes.fromhex`: ASCII whitespace is skipped, `0x` is not hex, and errors report only a position. The TS `verifyMessageSignature` adapter additionally accepts TronWeb's `0x`-prefixed signatures.
|
|
86
|
+
|
|
87
|
+
`addressFor`, `@IsAddress` and `validateAddress` use one check: Python's `validate_wallet_address` followed by `format_wallet_address`, so a `T…` base58check address of 21 bytes passes (any prefix byte, as in Python) and hex / `0x` forms do not. Methods that take an address format it like Python, so they also take tronpy's hex / `0x` forms. `TRON_MAINNET_STABLECOINS_PEG` is an `AssetMap`, which looks assets up by value like a Python `dict`.
|
|
88
|
+
|
|
89
|
+
## Known upstream behaviour
|
|
90
|
+
|
|
91
|
+
- `TronTransactionFees` validates against the *current* `getEnergyFee`. A transaction executed under a different energy price fails that check. Shasta's price has changed since some historical transactions, so their status lookups fail in both SDKs.
|
|
92
|
+
- tronpy 0.6.2 with eth_abi 5 cannot encode or decode the `trcToken` ABI type. The selector keeps `trcToken`, and encoding raises the same `Cannot create UnsignedIntegerEncoder for type 'trcToken'` error in both SDKs.
|
|
93
|
+
|
|
94
|
+
## Known limitation
|
|
95
|
+
|
|
96
|
+
- TronGrid JSON integers above 2^53 lose precision in `JSON.parse` before they reach `BigInt`. Python's ints do not. Balances and amounts below 9,007,199,254 TRX (or 2^53 base units of a token) are exact.
|
|
97
|
+
|
|
98
|
+
## Known issues shared with omnichain-py
|
|
99
|
+
|
|
100
|
+
These are bugs in omnichain-py itself. They are kept for parity and tracked to be fixed in both SDKs:
|
|
101
|
+
|
|
102
|
+
- RIN-317 — status counts rejected internal transactions and TRC-10 `callValue` as TRX, and does not debit TRX sent as `call_value`.
|
|
103
|
+
- RIN-318 — the wallet signs the txID returned by the node (or found in a JSON payload) without recomputing it from `raw_data`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getomnichain/omnichain",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Multi-chain SDK for EVM, Solana, UTXO (BTC/LTC/DOGE/DASH/ZEC/BCH),
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Multi-chain SDK for EVM, Solana, UTXO (BTC/LTC/DOGE/DASH/ZEC/BCH), Stellar, Tron, and TON. TypeScript parity port of omnichain-py.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"omnichain",
|
|
7
7
|
"blockchain",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"solana",
|
|
11
11
|
"bitcoin",
|
|
12
12
|
"utxo",
|
|
13
|
+
"stellar",
|
|
13
14
|
"ton",
|
|
14
15
|
"tron",
|
|
15
16
|
"sdk",
|
|
@@ -54,6 +55,16 @@
|
|
|
54
55
|
"import": "./dist/esm/ton/index.js",
|
|
55
56
|
"require": "./dist/cjs/ton/index.js"
|
|
56
57
|
},
|
|
58
|
+
"./stellar": {
|
|
59
|
+
"types": "./dist/esm/stellar/index.d.ts",
|
|
60
|
+
"import": "./dist/esm/stellar/index.js",
|
|
61
|
+
"require": "./dist/cjs/stellar/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./tron": {
|
|
64
|
+
"types": "./dist/esm/tron/index.d.ts",
|
|
65
|
+
"import": "./dist/esm/tron/index.js",
|
|
66
|
+
"require": "./dist/cjs/tron/index.js"
|
|
67
|
+
},
|
|
57
68
|
"./package.json": "./package.json"
|
|
58
69
|
},
|
|
59
70
|
"files": [
|
|
@@ -76,6 +87,7 @@
|
|
|
76
87
|
"dependencies": {
|
|
77
88
|
"@solana/spl-token": "^0.4.14",
|
|
78
89
|
"@solana/web3.js": "^1.98.0",
|
|
90
|
+
"@stellar/stellar-sdk": "^15.1.0",
|
|
79
91
|
"axios": "^1.7.0",
|
|
80
92
|
"bitcoinjs-lib": "^7.0.1",
|
|
81
93
|
"bitcoinjs-message": "^2.2.0",
|