crypto-aio 0.0.3 → 0.2.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 +167 -0
- package/README.md +163 -13
- package/dist/adapters/avalanche/address.d.ts +15 -0
- package/dist/adapters/avalanche/address.js +74 -0
- package/dist/adapters/avalanche/address.js.map +1 -0
- package/dist/adapters/avalanche/api.d.ts +100 -0
- package/dist/adapters/avalanche/api.js +381 -0
- package/dist/adapters/avalanche/api.js.map +1 -0
- package/dist/adapters/avalanche/builder.d.ts +13 -0
- package/dist/adapters/avalanche/builder.js +336 -0
- package/dist/adapters/avalanche/builder.js.map +1 -0
- package/dist/adapters/avalanche/cb58.d.ts +7 -0
- package/dist/adapters/avalanche/cb58.js +49 -0
- package/dist/adapters/avalanche/cb58.js.map +1 -0
- package/dist/adapters/avalanche/chains.d.ts +21 -0
- package/dist/adapters/avalanche/chains.js +79 -0
- package/dist/adapters/avalanche/chains.js.map +1 -0
- package/dist/adapters/avalanche/codec.d.ts +94 -0
- package/dist/adapters/avalanche/codec.js +371 -0
- package/dist/adapters/avalanche/codec.js.map +1 -0
- package/dist/adapters/avalanche/context.d.ts +59 -0
- package/dist/adapters/avalanche/context.js +114 -0
- package/dist/adapters/avalanche/context.js.map +1 -0
- package/dist/adapters/avalanche/decode.d.ts +16 -0
- package/dist/adapters/avalanche/decode.js +101 -0
- package/dist/adapters/avalanche/decode.js.map +1 -0
- package/dist/adapters/avalanche/driver.d.ts +22 -0
- package/dist/adapters/avalanche/driver.js +81 -0
- package/dist/adapters/avalanche/driver.js.map +1 -0
- package/dist/adapters/avalanche/errors.d.ts +18 -0
- package/dist/adapters/avalanche/errors.js +61 -0
- package/dist/adapters/avalanche/errors.js.map +1 -0
- package/dist/adapters/avalanche/fees.d.ts +23 -0
- package/dist/adapters/avalanche/fees.js +105 -0
- package/dist/adapters/avalanche/fees.js.map +1 -0
- package/dist/adapters/avalanche/index.d.ts +19 -0
- package/dist/adapters/avalanche/index.js +8 -0
- package/dist/adapters/avalanche/index.js.map +1 -0
- package/dist/adapters/avalanche/network.d.ts +37 -0
- package/dist/adapters/avalanche/network.js +135 -0
- package/dist/adapters/avalanche/network.js.map +1 -0
- package/dist/adapters/avalanche/plugin.d.ts +21 -0
- package/dist/adapters/avalanche/plugin.js +46 -0
- package/dist/adapters/avalanche/plugin.js.map +1 -0
- package/dist/adapters/avalanche/presets.d.ts +6 -0
- package/dist/adapters/avalanche/presets.js +86 -0
- package/dist/adapters/avalanche/presets.js.map +1 -0
- package/dist/adapters/avalanche/proofs.d.ts +41 -0
- package/dist/adapters/avalanche/proofs.js +270 -0
- package/dist/adapters/avalanche/proofs.js.map +1 -0
- package/dist/adapters/avalanche/reader.d.ts +40 -0
- package/dist/adapters/avalanche/reader.js +231 -0
- package/dist/adapters/avalanche/reader.js.map +1 -0
- package/dist/adapters/avalanche/sdk.d.ts +182 -0
- package/dist/adapters/avalanche/sdk.js +21 -0
- package/dist/adapters/avalanche/sdk.js.map +1 -0
- package/dist/adapters/avalanche/types.d.ts +86 -0
- package/dist/{type/common.js → adapters/avalanche/types.js} +1 -1
- package/dist/adapters/avalanche/types.js.map +1 -0
- package/dist/adapters/evm/builder.d.ts +11 -0
- package/dist/adapters/evm/builder.js +386 -0
- package/dist/adapters/evm/builder.js.map +1 -0
- package/dist/adapters/evm/chains.d.ts +6 -0
- package/dist/adapters/evm/chains.js +203 -0
- package/dist/adapters/evm/chains.js.map +1 -0
- package/dist/adapters/evm/client.d.ts +84 -0
- package/dist/adapters/evm/client.js +335 -0
- package/dist/adapters/evm/client.js.map +1 -0
- package/dist/adapters/evm/decode.d.ts +35 -0
- package/dist/adapters/evm/decode.js +175 -0
- package/dist/adapters/evm/decode.js.map +1 -0
- package/dist/adapters/evm/driver.d.ts +8 -0
- package/dist/adapters/evm/driver.js +61 -0
- package/dist/adapters/evm/driver.js.map +1 -0
- package/dist/adapters/evm/errors.d.ts +20 -0
- package/dist/adapters/evm/errors.js +110 -0
- package/dist/adapters/evm/errors.js.map +1 -0
- package/dist/adapters/evm/ethers-client.d.ts +43 -0
- package/dist/adapters/evm/ethers-client.js +139 -0
- package/dist/adapters/evm/ethers-client.js.map +1 -0
- package/dist/adapters/evm/fees.d.ts +103 -0
- package/dist/adapters/evm/fees.js +277 -0
- package/dist/adapters/evm/fees.js.map +1 -0
- package/dist/adapters/evm/index.d.ts +20 -0
- package/dist/adapters/evm/index.js +12 -0
- package/dist/adapters/evm/index.js.map +1 -0
- package/dist/adapters/evm/network.d.ts +65 -0
- package/dist/adapters/evm/network.js +150 -0
- package/dist/adapters/evm/network.js.map +1 -0
- package/dist/adapters/evm/plugin.d.ts +35 -0
- package/dist/adapters/evm/plugin.js +150 -0
- package/dist/adapters/evm/plugin.js.map +1 -0
- package/dist/adapters/evm/presets.d.ts +2 -0
- package/dist/adapters/evm/presets.js +105 -0
- package/dist/adapters/evm/presets.js.map +1 -0
- package/dist/adapters/evm/proofs.d.ts +19 -0
- package/dist/adapters/evm/proofs.js +370 -0
- package/dist/adapters/evm/proofs.js.map +1 -0
- package/dist/adapters/evm/rawtx.d.ts +25 -0
- package/dist/adapters/evm/rawtx.js +176 -0
- package/dist/adapters/evm/rawtx.js.map +1 -0
- package/dist/adapters/evm/reader.d.ts +83 -0
- package/dist/adapters/evm/reader.js +326 -0
- package/dist/adapters/evm/reader.js.map +1 -0
- package/dist/adapters/evm/rpc.d.ts +39 -0
- package/dist/adapters/evm/rpc.js +152 -0
- package/dist/adapters/evm/rpc.js.map +1 -0
- package/dist/adapters/evm/tokens.d.ts +10 -0
- package/dist/adapters/evm/tokens.js +23 -0
- package/dist/adapters/evm/tokens.js.map +1 -0
- package/dist/adapters/evm/types.d.ts +265 -0
- package/dist/{type/account.js → adapters/evm/types.js} +1 -1
- package/dist/adapters/evm/types.js.map +1 -0
- package/dist/adapters/evm/web3-client.d.ts +26 -0
- package/dist/adapters/evm/web3-client.js +176 -0
- package/dist/adapters/evm/web3-client.js.map +1 -0
- package/dist/adapters/solana/builder.d.ts +18 -0
- package/dist/adapters/solana/builder.js +556 -0
- package/dist/adapters/solana/builder.js.map +1 -0
- package/dist/adapters/solana/chains.d.ts +13 -0
- package/dist/adapters/solana/chains.js +37 -0
- package/dist/adapters/solana/chains.js.map +1 -0
- package/dist/adapters/solana/decode.d.ts +111 -0
- package/dist/adapters/solana/decode.js +595 -0
- package/dist/adapters/solana/decode.js.map +1 -0
- package/dist/adapters/solana/driver.d.ts +15 -0
- package/dist/adapters/solana/driver.js +72 -0
- package/dist/adapters/solana/driver.js.map +1 -0
- package/dist/adapters/solana/errors.d.ts +36 -0
- package/dist/adapters/solana/errors.js +154 -0
- package/dist/adapters/solana/errors.js.map +1 -0
- package/dist/adapters/solana/fees.d.ts +77 -0
- package/dist/adapters/solana/fees.js +214 -0
- package/dist/adapters/solana/fees.js.map +1 -0
- package/dist/adapters/solana/heights.d.ts +47 -0
- package/dist/adapters/solana/heights.js +185 -0
- package/dist/adapters/solana/heights.js.map +1 -0
- package/dist/adapters/solana/history.d.ts +10 -0
- package/dist/adapters/solana/history.js +71 -0
- package/dist/adapters/solana/history.js.map +1 -0
- package/dist/adapters/solana/index.d.ts +16 -0
- package/dist/adapters/solana/index.js +9 -0
- package/dist/adapters/solana/index.js.map +1 -0
- package/dist/adapters/solana/keys.d.ts +13 -0
- package/dist/adapters/solana/keys.js +69 -0
- package/dist/adapters/solana/keys.js.map +1 -0
- package/dist/adapters/solana/message.d.ts +15 -0
- package/dist/adapters/solana/message.js +120 -0
- package/dist/adapters/solana/message.js.map +1 -0
- package/dist/adapters/solana/network.d.ts +24 -0
- package/dist/adapters/solana/network.js +95 -0
- package/dist/adapters/solana/network.js.map +1 -0
- package/dist/adapters/solana/plugin.d.ts +18 -0
- package/dist/adapters/solana/plugin.js +44 -0
- package/dist/adapters/solana/plugin.js.map +1 -0
- package/dist/adapters/solana/presets.d.ts +2 -0
- package/dist/adapters/solana/presets.js +77 -0
- package/dist/adapters/solana/presets.js.map +1 -0
- package/dist/adapters/solana/programs.d.ts +44 -0
- package/dist/adapters/solana/programs.js +159 -0
- package/dist/adapters/solana/programs.js.map +1 -0
- package/dist/adapters/solana/proofs.d.ts +56 -0
- package/dist/adapters/solana/proofs.js +540 -0
- package/dist/adapters/solana/proofs.js.map +1 -0
- package/dist/adapters/solana/reader.d.ts +82 -0
- package/dist/adapters/solana/reader.js +326 -0
- package/dist/adapters/solana/reader.js.map +1 -0
- package/dist/adapters/solana/rpc.d.ts +102 -0
- package/dist/adapters/solana/rpc.js +301 -0
- package/dist/adapters/solana/rpc.js.map +1 -0
- package/dist/adapters/solana/tokens.d.ts +7 -0
- package/dist/adapters/solana/tokens.js +19 -0
- package/dist/adapters/solana/tokens.js.map +1 -0
- package/dist/adapters/solana/types.d.ts +124 -0
- package/dist/{type/contract.js → adapters/solana/types.js} +1 -1
- package/dist/adapters/solana/types.js.map +1 -0
- package/dist/adapters/solana/web3.d.ts +5 -0
- package/dist/adapters/solana/web3.js +61 -0
- package/dist/adapters/solana/web3.js.map +1 -0
- package/dist/adapters/solana/wire.d.ts +62 -0
- package/dist/adapters/solana/wire.js +168 -0
- package/dist/adapters/solana/wire.js.map +1 -0
- package/dist/adapters/ton/address.d.ts +43 -0
- package/dist/adapters/ton/address.js +168 -0
- package/dist/adapters/ton/address.js.map +1 -0
- package/dist/adapters/ton/api.d.ts +344 -0
- package/dist/adapters/ton/api.js +942 -0
- package/dist/adapters/ton/api.js.map +1 -0
- package/dist/adapters/ton/builder.d.ts +18 -0
- package/dist/adapters/ton/builder.js +701 -0
- package/dist/adapters/ton/builder.js.map +1 -0
- package/dist/adapters/ton/chains.d.ts +16 -0
- package/dist/adapters/ton/chains.js +39 -0
- package/dist/adapters/ton/chains.js.map +1 -0
- package/dist/adapters/ton/decode.d.ts +43 -0
- package/dist/adapters/ton/decode.js +219 -0
- package/dist/adapters/ton/decode.js.map +1 -0
- package/dist/adapters/ton/driver.d.ts +10 -0
- package/dist/adapters/ton/driver.js +117 -0
- package/dist/adapters/ton/driver.js.map +1 -0
- package/dist/adapters/ton/errors.d.ts +36 -0
- package/dist/adapters/ton/errors.js +89 -0
- package/dist/adapters/ton/errors.js.map +1 -0
- package/dist/adapters/ton/fees.d.ts +28 -0
- package/dist/adapters/ton/fees.js +121 -0
- package/dist/adapters/ton/fees.js.map +1 -0
- package/dist/adapters/ton/index.d.ts +16 -0
- package/dist/adapters/ton/index.js +9 -0
- package/dist/adapters/ton/index.js.map +1 -0
- package/dist/adapters/ton/messages.d.ts +157 -0
- package/dist/adapters/ton/messages.js +397 -0
- package/dist/adapters/ton/messages.js.map +1 -0
- package/dist/adapters/ton/native-client.d.ts +10 -0
- package/dist/adapters/ton/native-client.js +47 -0
- package/dist/adapters/ton/native-client.js.map +1 -0
- package/dist/adapters/ton/network.d.ts +58 -0
- package/dist/adapters/ton/network.js +207 -0
- package/dist/adapters/ton/network.js.map +1 -0
- package/dist/adapters/ton/plugin.d.ts +24 -0
- package/dist/adapters/ton/plugin.js +57 -0
- package/dist/adapters/ton/plugin.js.map +1 -0
- package/dist/adapters/ton/presets.d.ts +6 -0
- package/dist/adapters/ton/presets.js +94 -0
- package/dist/adapters/ton/presets.js.map +1 -0
- package/dist/adapters/ton/proofs.d.ts +66 -0
- package/dist/adapters/ton/proofs.js +755 -0
- package/dist/adapters/ton/proofs.js.map +1 -0
- package/dist/adapters/ton/reader.d.ts +235 -0
- package/dist/adapters/ton/reader.js +976 -0
- package/dist/adapters/ton/reader.js.map +1 -0
- package/dist/adapters/ton/tokens.d.ts +10 -0
- package/dist/adapters/ton/tokens.js +27 -0
- package/dist/adapters/ton/tokens.js.map +1 -0
- package/dist/adapters/ton/trace.d.ts +74 -0
- package/dist/adapters/ton/trace.js +303 -0
- package/dist/adapters/ton/trace.js.map +1 -0
- package/dist/adapters/ton/types.d.ts +105 -0
- package/dist/{type/transact.js → adapters/ton/types.js} +1 -1
- package/dist/adapters/ton/types.js.map +1 -0
- package/dist/adapters/ton/wallets.d.ts +86 -0
- package/dist/adapters/ton/wallets.js +373 -0
- package/dist/adapters/ton/wallets.js.map +1 -0
- package/dist/adapters/tron/abi.d.ts +41 -0
- package/dist/adapters/tron/abi.js +112 -0
- package/dist/adapters/tron/abi.js.map +1 -0
- package/dist/adapters/tron/address.d.ts +20 -0
- package/dist/adapters/tron/address.js +110 -0
- package/dist/adapters/tron/address.js.map +1 -0
- package/dist/adapters/tron/builder.d.ts +12 -0
- package/dist/adapters/tron/builder.js +569 -0
- package/dist/adapters/tron/builder.js.map +1 -0
- package/dist/adapters/tron/chains.d.ts +12 -0
- package/dist/adapters/tron/chains.js +35 -0
- package/dist/adapters/tron/chains.js.map +1 -0
- package/dist/adapters/tron/codec.d.ts +10 -0
- package/dist/adapters/tron/codec.js +322 -0
- package/dist/adapters/tron/codec.js.map +1 -0
- package/dist/adapters/tron/decode.d.ts +52 -0
- package/dist/adapters/tron/decode.js +280 -0
- package/dist/adapters/tron/decode.js.map +1 -0
- package/dist/adapters/tron/driver.d.ts +12 -0
- package/dist/adapters/tron/driver.js +106 -0
- package/dist/adapters/tron/driver.js.map +1 -0
- package/dist/adapters/tron/errors.d.ts +74 -0
- package/dist/adapters/tron/errors.js +261 -0
- package/dist/adapters/tron/errors.js.map +1 -0
- package/dist/adapters/tron/fees.d.ts +49 -0
- package/dist/adapters/tron/fees.js +166 -0
- package/dist/adapters/tron/fees.js.map +1 -0
- package/dist/adapters/tron/http.d.ts +173 -0
- package/dist/adapters/tron/http.js +729 -0
- package/dist/adapters/tron/http.js.map +1 -0
- package/dist/adapters/tron/index.d.ts +16 -0
- package/dist/adapters/tron/index.js +15 -0
- package/dist/adapters/tron/index.js.map +1 -0
- package/dist/adapters/tron/network.d.ts +44 -0
- package/dist/adapters/tron/network.js +163 -0
- package/dist/adapters/tron/network.js.map +1 -0
- package/dist/adapters/tron/plugin.d.ts +17 -0
- package/dist/adapters/tron/plugin.js +39 -0
- package/dist/adapters/tron/plugin.js.map +1 -0
- package/dist/adapters/tron/presets.d.ts +5 -0
- package/dist/adapters/tron/presets.js +68 -0
- package/dist/adapters/tron/presets.js.map +1 -0
- package/dist/adapters/tron/proofs.d.ts +80 -0
- package/dist/adapters/tron/proofs.js +371 -0
- package/dist/adapters/tron/proofs.js.map +1 -0
- package/dist/adapters/tron/protobuf.d.ts +36 -0
- package/dist/adapters/tron/protobuf.js +90 -0
- package/dist/adapters/tron/protobuf.js.map +1 -0
- package/dist/adapters/tron/reader.d.ts +57 -0
- package/dist/adapters/tron/reader.js +220 -0
- package/dist/adapters/tron/reader.js.map +1 -0
- package/dist/adapters/tron/tokens.d.ts +9 -0
- package/dist/adapters/tron/tokens.js +14 -0
- package/dist/adapters/tron/tokens.js.map +1 -0
- package/dist/adapters/tron/types.d.ts +166 -0
- package/dist/adapters/tron/types.js +3 -0
- package/dist/adapters/tron/types.js.map +1 -0
- package/dist/adapters/utxo/address.d.ts +51 -0
- package/dist/adapters/utxo/address.js +341 -0
- package/dist/adapters/utxo/address.js.map +1 -0
- package/dist/adapters/utxo/builder.d.ts +35 -0
- package/dist/adapters/utxo/builder.js +380 -0
- package/dist/adapters/utxo/builder.js.map +1 -0
- package/dist/adapters/utxo/chains.d.ts +17 -0
- package/dist/adapters/utxo/chains.js +100 -0
- package/dist/adapters/utxo/chains.js.map +1 -0
- package/dist/adapters/utxo/codec.d.ts +120 -0
- package/dist/adapters/utxo/codec.js +408 -0
- package/dist/adapters/utxo/codec.js.map +1 -0
- package/dist/adapters/utxo/coinselect.d.ts +48 -0
- package/dist/adapters/utxo/coinselect.js +131 -0
- package/dist/adapters/utxo/coinselect.js.map +1 -0
- package/dist/adapters/utxo/context.d.ts +63 -0
- package/dist/adapters/utxo/context.js +125 -0
- package/dist/adapters/utxo/context.js.map +1 -0
- package/dist/adapters/utxo/decode.d.ts +22 -0
- package/dist/adapters/utxo/decode.js +121 -0
- package/dist/adapters/utxo/decode.js.map +1 -0
- package/dist/adapters/utxo/driver.d.ts +16 -0
- package/dist/adapters/utxo/driver.js +79 -0
- package/dist/adapters/utxo/driver.js.map +1 -0
- package/dist/adapters/utxo/ecc.d.ts +9 -0
- package/dist/adapters/utxo/ecc.js +26 -0
- package/dist/adapters/utxo/ecc.js.map +1 -0
- package/dist/adapters/utxo/errors.d.ts +52 -0
- package/dist/adapters/utxo/errors.js +191 -0
- package/dist/adapters/utxo/errors.js.map +1 -0
- package/dist/adapters/utxo/esplora.d.ts +100 -0
- package/dist/adapters/utxo/esplora.js +498 -0
- package/dist/adapters/utxo/esplora.js.map +1 -0
- package/dist/adapters/utxo/fees.d.ts +41 -0
- package/dist/adapters/utxo/fees.js +125 -0
- package/dist/adapters/utxo/fees.js.map +1 -0
- package/dist/adapters/utxo/index.d.ts +17 -0
- package/dist/adapters/utxo/index.js +8 -0
- package/dist/adapters/utxo/index.js.map +1 -0
- package/dist/adapters/utxo/network.d.ts +50 -0
- package/dist/adapters/utxo/network.js +165 -0
- package/dist/adapters/utxo/network.js.map +1 -0
- package/dist/adapters/utxo/plugin.d.ts +17 -0
- package/dist/adapters/utxo/plugin.js +41 -0
- package/dist/adapters/utxo/plugin.js.map +1 -0
- package/dist/adapters/utxo/presets.d.ts +12 -0
- package/dist/adapters/utxo/presets.js +47 -0
- package/dist/adapters/utxo/presets.js.map +1 -0
- package/dist/adapters/utxo/preview.d.ts +3 -0
- package/dist/adapters/utxo/preview.js +65 -0
- package/dist/adapters/utxo/preview.js.map +1 -0
- package/dist/adapters/utxo/proofs.d.ts +66 -0
- package/dist/adapters/utxo/proofs.js +469 -0
- package/dist/adapters/utxo/proofs.js.map +1 -0
- package/dist/adapters/utxo/rawblock.d.ts +46 -0
- package/dist/adapters/utxo/rawblock.js +159 -0
- package/dist/adapters/utxo/rawblock.js.map +1 -0
- package/dist/adapters/utxo/rawtx.d.ts +73 -0
- package/dist/adapters/utxo/rawtx.js +264 -0
- package/dist/adapters/utxo/rawtx.js.map +1 -0
- package/dist/adapters/utxo/reader.d.ts +36 -0
- package/dist/adapters/utxo/reader.js +265 -0
- package/dist/adapters/utxo/reader.js.map +1 -0
- package/dist/adapters/utxo/sdk.d.ts +18 -0
- package/dist/adapters/utxo/sdk.js +17 -0
- package/dist/adapters/utxo/sdk.js.map +1 -0
- package/dist/adapters/utxo/signed-psbt.d.ts +36 -0
- package/dist/adapters/utxo/signed-psbt.js +428 -0
- package/dist/adapters/utxo/signed-psbt.js.map +1 -0
- package/dist/adapters/utxo/spend.d.ts +59 -0
- package/dist/adapters/utxo/spend.js +230 -0
- package/dist/adapters/utxo/spend.js.map +1 -0
- package/dist/adapters/utxo/types.d.ts +167 -0
- package/dist/adapters/utxo/types.js +3 -0
- package/dist/adapters/utxo/types.js.map +1 -0
- package/dist/core/assets/service.d.ts +18 -0
- package/dist/core/assets/service.js +69 -0
- package/dist/core/assets/service.js.map +1 -0
- package/dist/core/blockchain/default-ref.d.ts +4 -0
- package/dist/core/blockchain/default-ref.js +16 -0
- package/dist/core/blockchain/default-ref.js.map +1 -0
- package/dist/core/blockchain/handle.d.ts +179 -0
- package/dist/core/blockchain/handle.js +579 -0
- package/dist/core/blockchain/handle.js.map +1 -0
- package/dist/core/blockchain/internal.d.ts +19 -0
- package/dist/core/blockchain/internal.js +16 -0
- package/dist/core/blockchain/internal.js.map +1 -0
- package/dist/core/blockchain/mapping.d.ts +22 -0
- package/dist/core/blockchain/mapping.js +136 -0
- package/dist/core/blockchain/mapping.js.map +1 -0
- package/dist/core/config/env.d.ts +8 -0
- package/dist/core/config/env.js +60 -0
- package/dist/core/config/env.js.map +1 -0
- package/dist/core/config/merge.d.ts +26 -0
- package/dist/core/config/merge.js +144 -0
- package/dist/core/config/merge.js.map +1 -0
- package/dist/core/config/resolve.d.ts +12 -0
- package/dist/core/config/resolve.js +251 -0
- package/dist/core/config/resolve.js.map +1 -0
- package/dist/core/config/types.d.ts +180 -0
- package/dist/core/config/types.js +3 -0
- package/dist/core/config/types.js.map +1 -0
- package/dist/core/container/builtins.d.ts +4 -0
- package/dist/core/container/builtins.js +13 -0
- package/dist/core/container/builtins.js.map +1 -0
- package/dist/core/container/container.d.ts +62 -0
- package/dist/core/container/container.js +500 -0
- package/dist/core/container/container.js.map +1 -0
- package/dist/core/container/default.d.ts +15 -0
- package/dist/core/container/default.js +70 -0
- package/dist/core/container/default.js.map +1 -0
- package/dist/core/container/internals.d.ts +54 -0
- package/dist/core/container/internals.js +21 -0
- package/dist/core/container/internals.js.map +1 -0
- package/dist/core/container/pool.d.ts +27 -0
- package/dist/core/container/pool.js +77 -0
- package/dist/core/container/pool.js.map +1 -0
- package/dist/core/driver/types.d.ts +379 -0
- package/dist/core/driver/types.js +3 -0
- package/dist/core/driver/types.js.map +1 -0
- package/dist/core/errors/codes.d.ts +163 -0
- package/dist/core/errors/codes.js +53 -0
- package/dist/core/errors/codes.js.map +1 -0
- package/dist/core/errors/error.d.ts +66 -0
- package/dist/core/errors/error.js +129 -0
- package/dist/core/errors/error.js.map +1 -0
- package/dist/core/events/bus.d.ts +12 -0
- package/dist/core/events/bus.js +46 -0
- package/dist/core/events/bus.js.map +1 -0
- package/dist/core/events/logger.d.ts +13 -0
- package/dist/core/events/logger.js +42 -0
- package/dist/core/events/logger.js.map +1 -0
- package/dist/core/events/types.d.ts +131 -0
- package/dist/core/events/types.js +3 -0
- package/dist/core/events/types.js.map +1 -0
- package/dist/core/lifecycle/engine-rules.d.ts +106 -0
- package/dist/core/lifecycle/engine-rules.js +267 -0
- package/dist/core/lifecycle/engine-rules.js.map +1 -0
- package/dist/core/lifecycle/engine.d.ts +502 -0
- package/dist/core/lifecycle/engine.js +1750 -0
- package/dist/core/lifecycle/engine.js.map +1 -0
- package/dist/core/lifecycle/evaluate.d.ts +19 -0
- package/dist/core/lifecycle/evaluate.js +77 -0
- package/dist/core/lifecycle/evaluate.js.map +1 -0
- package/dist/core/lifecycle/intent.d.ts +11 -0
- package/dist/core/lifecycle/intent.js +88 -0
- package/dist/core/lifecycle/intent.js.map +1 -0
- package/dist/core/lifecycle/monitor.d.ts +138 -0
- package/dist/core/lifecycle/monitor.js +616 -0
- package/dist/core/lifecycle/monitor.js.map +1 -0
- package/dist/core/lifecycle/observations.d.ts +17 -0
- package/dist/core/lifecycle/observations.js +59 -0
- package/dist/core/lifecycle/observations.js.map +1 -0
- package/dist/core/lifecycle/reconcile.d.ts +58 -0
- package/dist/core/lifecycle/reconcile.js +112 -0
- package/dist/core/lifecycle/reconcile.js.map +1 -0
- package/dist/core/lifecycle/views.d.ts +49 -0
- package/dist/core/lifecycle/views.js +57 -0
- package/dist/core/lifecycle/views.js.map +1 -0
- package/dist/core/lifecycle/workers.d.ts +88 -0
- package/dist/core/lifecycle/workers.js +347 -0
- package/dist/core/lifecycle/workers.js.map +1 -0
- package/dist/core/model/address.d.ts +32 -0
- package/dist/core/model/address.js +43 -0
- package/dist/core/model/address.js.map +1 -0
- package/dist/core/model/amount.d.ts +25 -0
- package/dist/core/model/amount.js +102 -0
- package/dist/core/model/amount.js.map +1 -0
- package/dist/core/model/asset.d.ts +28 -0
- package/dist/core/model/asset.js +47 -0
- package/dist/core/model/asset.js.map +1 -0
- package/dist/core/model/capability.d.ts +3 -0
- package/dist/core/model/capability.js +18 -0
- package/dist/core/model/capability.js.map +1 -0
- package/dist/core/model/chain.d.ts +63 -0
- package/dist/core/model/chain.js +8 -0
- package/dist/core/model/chain.js.map +1 -0
- package/dist/core/model/fee.d.ts +36 -0
- package/dist/core/model/fee.js +17 -0
- package/dist/core/model/fee.js.map +1 -0
- package/dist/core/model/ids.d.ts +38 -0
- package/dist/core/model/ids.js +14 -0
- package/dist/core/model/ids.js.map +1 -0
- package/dist/core/model/intent.d.ts +63 -0
- package/dist/core/model/intent.js +81 -0
- package/dist/core/model/intent.js.map +1 -0
- package/dist/core/model/ordering.d.ts +28 -0
- package/dist/core/model/ordering.js +29 -0
- package/dist/core/model/ordering.js.map +1 -0
- package/dist/core/model/transaction.d.ts +123 -0
- package/dist/{type/lib-types.js → core/model/transaction.js} +1 -1
- package/dist/core/model/transaction.js.map +1 -0
- package/dist/core/observe/scanner.d.ts +135 -0
- package/dist/core/observe/scanner.js +358 -0
- package/dist/core/observe/scanner.js.map +1 -0
- package/dist/core/ordering/reservations.d.ts +16 -0
- package/dist/core/ordering/reservations.js +53 -0
- package/dist/core/ordering/reservations.js.map +1 -0
- package/dist/core/ordering/sequence.d.ts +61 -0
- package/dist/core/ordering/sequence.js +155 -0
- package/dist/core/ordering/sequence.js.map +1 -0
- package/dist/core/registry/adapters.d.ts +10 -0
- package/dist/core/registry/adapters.js +56 -0
- package/dist/core/registry/adapters.js.map +1 -0
- package/dist/core/registry/assets.d.ts +18 -0
- package/dist/core/registry/assets.js +90 -0
- package/dist/core/registry/assets.js.map +1 -0
- package/dist/core/registry/chains.d.ts +10 -0
- package/dist/core/registry/chains.js +80 -0
- package/dist/core/registry/chains.js.map +1 -0
- package/dist/core/registry/plugin.d.ts +41 -0
- package/dist/core/registry/plugin.js +109 -0
- package/dist/core/registry/plugin.js.map +1 -0
- package/dist/core/registry/providers.d.ts +31 -0
- package/dist/core/registry/providers.js +43 -0
- package/dist/core/registry/providers.js.map +1 -0
- package/dist/core/registry/schemes.d.ts +30 -0
- package/dist/core/registry/schemes.js +84 -0
- package/dist/core/registry/schemes.js.map +1 -0
- package/dist/core/secret/fragments.d.ts +33 -0
- package/dist/core/secret/fragments.js +110 -0
- package/dist/core/secret/fragments.js.map +1 -0
- package/dist/core/secret/redact.d.ts +10 -0
- package/dist/core/secret/redact.js +110 -0
- package/dist/core/secret/redact.js.map +1 -0
- package/dist/core/secret/secret.d.ts +14 -0
- package/dist/core/secret/secret.js +42 -0
- package/dist/core/secret/secret.js.map +1 -0
- package/dist/core/signing/callback.d.ts +10 -0
- package/dist/core/signing/callback.js +22 -0
- package/dist/core/signing/callback.js.map +1 -0
- package/dist/core/signing/guard.d.ts +18 -0
- package/dist/core/signing/guard.js +72 -0
- package/dist/core/signing/guard.js.map +1 -0
- package/dist/core/signing/hd.d.ts +36 -0
- package/dist/core/signing/hd.js +167 -0
- package/dist/core/signing/hd.js.map +1 -0
- package/dist/core/signing/local.d.ts +48 -0
- package/dist/core/signing/local.js +190 -0
- package/dist/core/signing/local.js.map +1 -0
- package/dist/core/signing/orchestrator.d.ts +40 -0
- package/dist/core/signing/orchestrator.js +300 -0
- package/dist/core/signing/orchestrator.js.map +1 -0
- package/dist/core/signing/types.d.ts +64 -0
- package/dist/core/signing/types.js +3 -0
- package/dist/core/signing/types.js.map +1 -0
- package/dist/core/signing/wallet.d.ts +48 -0
- package/dist/core/signing/wallet.js +161 -0
- package/dist/core/signing/wallet.js.map +1 -0
- package/dist/core/store/clone.d.ts +25 -0
- package/dist/core/store/clone.js +71 -0
- package/dist/core/store/clone.js.map +1 -0
- package/dist/core/store/format.d.ts +20 -0
- package/dist/core/store/format.js +86 -0
- package/dist/core/store/format.js.map +1 -0
- package/dist/core/store/memory.d.ts +38 -0
- package/dist/core/store/memory.js +325 -0
- package/dist/core/store/memory.js.map +1 -0
- package/dist/core/store/types.d.ts +258 -0
- package/dist/core/store/types.js +119 -0
- package/dist/core/store/types.js.map +1 -0
- package/dist/core/transport/backoff.d.ts +8 -0
- package/dist/core/transport/backoff.js +27 -0
- package/dist/core/transport/backoff.js.map +1 -0
- package/dist/core/transport/circuit.d.ts +25 -0
- package/dist/core/transport/circuit.js +61 -0
- package/dist/core/transport/circuit.js.map +1 -0
- package/dist/core/transport/http-transport.d.ts +30 -0
- package/dist/core/transport/http-transport.js +1703 -0
- package/dist/core/transport/http-transport.js.map +1 -0
- package/dist/core/transport/rate-limit.d.ts +27 -0
- package/dist/core/transport/rate-limit.js +78 -0
- package/dist/core/transport/rate-limit.js.map +1 -0
- package/dist/core/transport/stale-view.d.ts +11 -0
- package/dist/core/transport/stale-view.js +17 -0
- package/dist/core/transport/stale-view.js.map +1 -0
- package/dist/core/transport/types.d.ts +159 -0
- package/dist/core/transport/types.js +6 -0
- package/dist/core/transport/types.js.map +1 -0
- package/dist/core/util/bytes.d.ts +9 -0
- package/dist/core/util/bytes.js +40 -0
- package/dist/core/util/bytes.js.map +1 -0
- package/dist/core/util/clock.d.ts +6 -0
- package/dist/core/util/clock.js +26 -0
- package/dist/core/util/clock.js.map +1 -0
- package/dist/core/util/freeze.d.ts +8 -0
- package/dist/core/util/freeze.js +31 -0
- package/dist/core/util/freeze.js.map +1 -0
- package/dist/core/util/json.d.ts +35 -0
- package/dist/core/util/json.js +174 -0
- package/dist/core/util/json.js.map +1 -0
- package/dist/core/util/names.d.ts +27 -0
- package/dist/core/util/names.js +56 -0
- package/dist/core/util/names.js.map +1 -0
- package/dist/index.d.ts +65 -14
- package/dist/index.js +107 -49
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +21 -0
- package/dist/native.js +44 -0
- package/dist/native.js.map +1 -0
- package/dist/testing/contracts/api.d.ts +12 -0
- package/dist/testing/contracts/api.js +58 -0
- package/dist/testing/contracts/api.js.map +1 -0
- package/dist/testing/contracts/cursors.d.ts +6 -0
- package/dist/testing/contracts/cursors.js +43 -0
- package/dist/testing/contracts/cursors.js.map +1 -0
- package/dist/testing/contracts/locks.d.ts +10 -0
- package/dist/testing/contracts/locks.js +63 -0
- package/dist/testing/contracts/locks.js.map +1 -0
- package/dist/testing/contracts/operations.d.ts +21 -0
- package/dist/testing/contracts/operations.js +737 -0
- package/dist/testing/contracts/operations.js.map +1 -0
- package/dist/testing/contracts/sequences.d.ts +6 -0
- package/dist/testing/contracts/sequences.js +68 -0
- package/dist/testing/contracts/sequences.js.map +1 -0
- package/dist/testing/env.d.ts +68 -0
- package/dist/testing/env.js +105 -0
- package/dist/testing/env.js.map +1 -0
- package/dist/testing/fake-chain.d.ts +118 -0
- package/dist/testing/fake-chain.js +536 -0
- package/dist/testing/fake-chain.js.map +1 -0
- package/dist/testing/fake-clock.d.ts +15 -0
- package/dist/testing/fake-clock.js +86 -0
- package/dist/testing/fake-clock.js.map +1 -0
- package/dist/testing/fake-driver.d.ts +15 -0
- package/dist/testing/fake-driver.js +458 -0
- package/dist/testing/fake-driver.js.map +1 -0
- package/dist/testing/fake-fetch.d.ts +32 -0
- package/dist/testing/fake-fetch.js +81 -0
- package/dist/testing/fake-fetch.js.map +1 -0
- package/dist/testing/fake-plugin.d.ts +30 -0
- package/dist/testing/fake-plugin.js +66 -0
- package/dist/testing/fake-plugin.js.map +1 -0
- package/dist/testing/faulty-store.d.ts +38 -0
- package/dist/testing/faulty-store.js +71 -0
- package/dist/testing/faulty-store.js.map +1 -0
- package/dist/testing/generation.d.ts +60 -0
- package/dist/testing/generation.js +252 -0
- package/dist/testing/generation.js.map +1 -0
- package/dist/testing/index.d.ts +28 -0
- package/dist/testing/index.js +51 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +198 -45
- package/dist/libs/eth/account.d.ts +0 -9
- package/dist/libs/eth/account.js +0 -58
- package/dist/libs/eth/account.js.map +0 -1
- package/dist/libs/eth/contract.d.ts +0 -7
- package/dist/libs/eth/contract.js +0 -42
- package/dist/libs/eth/contract.js.map +0 -1
- package/dist/libs/eth/index.d.ts +0 -24
- package/dist/libs/eth/index.js +0 -72
- package/dist/libs/eth/index.js.map +0 -1
- package/dist/libs/eth/transact.d.ts +0 -7
- package/dist/libs/eth/transact.js +0 -26
- package/dist/libs/eth/transact.js.map +0 -1
- package/dist/libs/index.d.ts +0 -2
- package/dist/libs/index.js +0 -19
- package/dist/libs/index.js.map +0 -1
- package/dist/libs/trx/account.d.ts +0 -9
- package/dist/libs/trx/account.js +0 -55
- package/dist/libs/trx/account.js.map +0 -1
- package/dist/libs/trx/contract.d.ts +0 -7
- package/dist/libs/trx/contract.js +0 -27
- package/dist/libs/trx/contract.js.map +0 -1
- package/dist/libs/trx/index.d.ts +0 -22
- package/dist/libs/trx/index.js +0 -64
- package/dist/libs/trx/index.js.map +0 -1
- package/dist/libs/trx/transact.d.ts +0 -7
- package/dist/libs/trx/transact.js +0 -26
- package/dist/libs/trx/transact.js.map +0 -1
- package/dist/tool/common.d.ts +0 -28
- package/dist/tool/common.js +0 -33
- package/dist/tool/common.js.map +0 -1
- package/dist/tool/eth-tools.d.ts +0 -3
- package/dist/tool/eth-tools.js +0 -33
- package/dist/tool/eth-tools.js.map +0 -1
- package/dist/tool/index.d.ts +0 -5
- package/dist/tool/index.js +0 -22
- package/dist/tool/index.js.map +0 -1
- package/dist/tool/logging.d.ts +0 -3
- package/dist/tool/logging.js +0 -11
- package/dist/tool/logging.js.map +0 -1
- package/dist/tool/options.d.ts +0 -6
- package/dist/tool/options.js +0 -41
- package/dist/tool/options.js.map +0 -1
- package/dist/tool/trx-tools.d.ts +0 -3
- package/dist/tool/trx-tools.js +0 -20
- package/dist/tool/trx-tools.js.map +0 -1
- package/dist/type/account.d.ts +0 -9
- package/dist/type/account.js.map +0 -1
- package/dist/type/common.d.ts +0 -18
- package/dist/type/common.js.map +0 -1
- package/dist/type/contract.d.ts +0 -10
- package/dist/type/contract.js.map +0 -1
- package/dist/type/index.d.ts +0 -5
- package/dist/type/index.js +0 -22
- package/dist/type/index.js.map +0 -1
- package/dist/type/lib-types.d.ts +0 -9
- package/dist/type/lib-types.js.map +0 -1
- package/dist/type/transact.d.ts +0 -7
- package/dist/type/transact.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solana addresses, reads and the `ext.solana` API. Every call carries the tags of the
|
|
3
|
+
* `ChainDriver` contract table: `read` for point queries, `monitor` for heights and
|
|
4
|
+
* observations. Heads are read at `confirmed`, finality at `finalized`.
|
|
5
|
+
*/
|
|
6
|
+
import type { AddressCodec, ChainReader, DriverBlock } from '../../core/driver/types';
|
|
7
|
+
import type { Logger } from '../../core/events/logger';
|
|
8
|
+
import type { AssetRef } from '../../core/model/asset';
|
|
9
|
+
import type { ChainInfo, NetworkInfo } from '../../core/model/chain';
|
|
10
|
+
import type { Transport } from '../../core/transport/types';
|
|
11
|
+
import { type ParsedTransaction } from './decode';
|
|
12
|
+
import type { HeightIndex } from './heights';
|
|
13
|
+
import type { SolanaNetworkConfig } from './network';
|
|
14
|
+
import { type BlockHeader } from './rpc';
|
|
15
|
+
import type { SolanaCallTags, SolanaCodec, SolanaExt, SolanaTokenAccount } from './types';
|
|
16
|
+
/** What every Solana port is built from. */
|
|
17
|
+
export interface SolanaContext {
|
|
18
|
+
readonly transport: Transport;
|
|
19
|
+
readonly codec: SolanaCodec;
|
|
20
|
+
readonly chain: ChainInfo;
|
|
21
|
+
readonly network: NetworkInfo;
|
|
22
|
+
readonly config: SolanaNetworkConfig;
|
|
23
|
+
readonly heights: HeightIndex;
|
|
24
|
+
readonly log: Logger;
|
|
25
|
+
/** The next build variant (`fees.ts`, `variantCounter`). */
|
|
26
|
+
readonly nextVariant: () => number;
|
|
27
|
+
}
|
|
28
|
+
export interface AccountInfo {
|
|
29
|
+
readonly owner: string;
|
|
30
|
+
readonly executable: boolean;
|
|
31
|
+
readonly data: Uint8Array;
|
|
32
|
+
}
|
|
33
|
+
/** `getAccountInfo` (base64) at `confirmed`; `null` when the account does not exist. */
|
|
34
|
+
export declare function accountInfo(ctx: SolanaContext, address: string, tags: SolanaCallTags): Promise<AccountInfo | null>;
|
|
35
|
+
/** The mint of an `spl` asset ref; any other standard is not a Solana token. */
|
|
36
|
+
export declare function mintOf(asset: AssetRef): string;
|
|
37
|
+
/**
|
|
38
|
+
* A classic Token mint's decimals: a missing mint, an account of another
|
|
39
|
+
* program or data that does not parse is the token's own `ASSET_RESOLUTION`; a Token-2022
|
|
40
|
+
* mint is `UNSUPPORTED_CAPABILITY`. A definitive node error is made retryable;
|
|
41
|
+
* `PROVIDER_MISCONFIGURED` and retryable errors propagate unchanged. Under a quorum (the
|
|
42
|
+
* token metadata the core caches), endpoints must agree on the verdict: a lagging one that
|
|
43
|
+
* has no mint yet, or one with other decimals, decides nothing (`PROVIDER_INCONSISTENT`).
|
|
44
|
+
*/
|
|
45
|
+
export declare function mintDecimals(ctx: SolanaContext, mint: string, tags: SolanaCallTags): Promise<number>;
|
|
46
|
+
export declare function createSolanaAddressCodec(): AddressCodec;
|
|
47
|
+
/**
|
|
48
|
+
* The block at dense `height` (`confirmed`), checked against the height it claims; `null`
|
|
49
|
+
* while the endpoint has no block there. A contradicting answer is a retryable
|
|
50
|
+
* `PROVIDER_INCONSISTENT`, and the cached slot it came from is dropped.
|
|
51
|
+
*/
|
|
52
|
+
export declare function blockAtHeight(ctx: SolanaContext, height: bigint, tags: SolanaCallTags): Promise<{
|
|
53
|
+
readonly slot: bigint;
|
|
54
|
+
readonly block: DriverBlock;
|
|
55
|
+
} | null>;
|
|
56
|
+
/**
|
|
57
|
+
* Reads a transaction at `confirmed`, with its block's height and hash. The answer must be
|
|
58
|
+
* the transaction asked for: another one decides nothing (a retryable "not yet"), never
|
|
59
|
+
* reads as ours.
|
|
60
|
+
*/
|
|
61
|
+
export declare function readTransaction(ctx: SolanaContext, signature: string, tags: SolanaCallTags): Promise<{
|
|
62
|
+
readonly parsed: ParsedTransaction;
|
|
63
|
+
readonly header: BlockHeader;
|
|
64
|
+
} | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Token metadata is read under the proof quorum, stricter than
|
|
67
|
+
* the contract table's minimum: the core caches a token's decimals and "no such token" for
|
|
68
|
+
* the container's life, so one lagging or wrong endpoint must not mis-scale every amount
|
|
69
|
+
* until a restart. `mintDecimals` compares the mint's verdict only. The builder reads the
|
|
70
|
+
* decimals it signs into `transferChecked` the same way, so a lagging
|
|
71
|
+
* endpoint without the mint decides nothing instead of refusing the transfer.
|
|
72
|
+
*/
|
|
73
|
+
export declare const METADATA: SolanaCallTags;
|
|
74
|
+
export declare function createSolanaReader(ctx: SolanaContext): ChainReader;
|
|
75
|
+
/**
|
|
76
|
+
* The classic token accounts of `owner`, optionally for one mint. The answer is filtered to
|
|
77
|
+
* what was asked (lookups by id): an account of another owner or mint, as a node that
|
|
78
|
+
* drops a filter would list it, is none of the owner's. Token-2022 accounts are skipped
|
|
79
|
+
* (unsupported). An account listed twice is malformed, never a doubled balance.
|
|
80
|
+
*/
|
|
81
|
+
export declare function tokenAccountsOf(ctx: SolanaContext, owner: string, mint: string | undefined, tags: SolanaCallTags): Promise<SolanaTokenAccount[]>;
|
|
82
|
+
export declare function createSolanaExt(ctx: SolanaContext): SolanaExt;
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.METADATA = void 0;
|
|
4
|
+
exports.accountInfo = accountInfo;
|
|
5
|
+
exports.mintOf = mintOf;
|
|
6
|
+
exports.mintDecimals = mintDecimals;
|
|
7
|
+
exports.createSolanaAddressCodec = createSolanaAddressCodec;
|
|
8
|
+
exports.blockAtHeight = blockAtHeight;
|
|
9
|
+
exports.readTransaction = readTransaction;
|
|
10
|
+
exports.createSolanaReader = createSolanaReader;
|
|
11
|
+
exports.tokenAccountsOf = tokenAccountsOf;
|
|
12
|
+
exports.createSolanaExt = createSolanaExt;
|
|
13
|
+
const error_1 = require("../../core/errors/error");
|
|
14
|
+
const decode_1 = require("./decode");
|
|
15
|
+
const keys_1 = require("./keys");
|
|
16
|
+
const programs_1 = require("./programs");
|
|
17
|
+
const rpc_1 = require("./rpc");
|
|
18
|
+
/**
|
|
19
|
+
* Account data in agave's `base64` encoding, refused unless it is canonical: Node decodes
|
|
20
|
+
* leniently (a stray character is skipped, `AB==` reads as `AA==`), so the bytes must
|
|
21
|
+
* encode back to the same text. The check is linear, which matters: accounts hold up to
|
|
22
|
+
* 10 MiB, and a repeated-group regex overflows the stack on a few MiB.
|
|
23
|
+
*/
|
|
24
|
+
function base64Data(value, what) {
|
|
25
|
+
if (!Array.isArray(value) ||
|
|
26
|
+
value.length !== 2 ||
|
|
27
|
+
value[1] !== 'base64' ||
|
|
28
|
+
typeof value[0] !== 'string' ||
|
|
29
|
+
value[0].length % 4 !== 0) {
|
|
30
|
+
throw (0, rpc_1.malformed)(what);
|
|
31
|
+
}
|
|
32
|
+
const bytes = Buffer.from(value[0], 'base64');
|
|
33
|
+
if (bytes.toString('base64') !== value[0])
|
|
34
|
+
throw (0, rpc_1.malformed)(what);
|
|
35
|
+
return new Uint8Array(bytes);
|
|
36
|
+
}
|
|
37
|
+
/** A `getAccountInfo` answer (base64): the account, or `null` when it does not exist. */
|
|
38
|
+
function parseAccount(result) {
|
|
39
|
+
const value = (0, rpc_1.contextValue)(result, 'getAccountInfo');
|
|
40
|
+
if (value === null)
|
|
41
|
+
return null;
|
|
42
|
+
const account = (0, rpc_1.record)(value);
|
|
43
|
+
if (!account || !(0, keys_1.isAddress)(account.owner) || typeof account.executable !== 'boolean') {
|
|
44
|
+
throw (0, rpc_1.malformed)('getAccountInfo');
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
owner: account.owner,
|
|
48
|
+
executable: account.executable,
|
|
49
|
+
data: base64Data(account.data, 'getAccountInfo'),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** `getAccountInfo` (base64) at `confirmed`; `null` when the account does not exist. */
|
|
53
|
+
async function accountInfo(ctx, address, tags) {
|
|
54
|
+
return parseAccount(await (0, rpc_1.call)(ctx.transport, 'getAccountInfo', [address, { encoding: 'base64', commitment: 'confirmed' }], tags));
|
|
55
|
+
}
|
|
56
|
+
const assetError = (reason) => new error_1.ValidationError('ASSET_RESOLUTION', reason);
|
|
57
|
+
/** The mint of an `spl` asset ref; any other standard is not a Solana token. */
|
|
58
|
+
function mintOf(asset) {
|
|
59
|
+
if (asset === 'native' || asset.standard !== 'spl') {
|
|
60
|
+
throw assetError(`Solana tokens use the 'spl' standard`);
|
|
61
|
+
}
|
|
62
|
+
if (!(0, keys_1.isAddress)(asset.contract))
|
|
63
|
+
throw assetError('not a Solana mint address');
|
|
64
|
+
return asset.contract;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The verdict of a mint account, by its owning program first: a classic mint and a
|
|
68
|
+
* Token-2022 one cannot be told apart by their size.
|
|
69
|
+
*/
|
|
70
|
+
function mintVerdict(info) {
|
|
71
|
+
if (!info)
|
|
72
|
+
return { refused: 'missing' };
|
|
73
|
+
if (info.owner === programs_1.TOKEN_2022_PROGRAM)
|
|
74
|
+
return { refused: 'token-2022' };
|
|
75
|
+
if (info.owner !== programs_1.TOKEN_PROGRAM)
|
|
76
|
+
return { refused: 'other-program' };
|
|
77
|
+
const decoded = (0, programs_1.decodeMint)(info.data);
|
|
78
|
+
return decoded ? { decimals: decoded.decimals } : { refused: 'unparsable' };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A mint read's quorum key, verdict fields only: the verdict itself, never the
|
|
82
|
+
* context slot, the lamports or the supply, on which honest endpoints differ. A malformed
|
|
83
|
+
* answer keys as such, so it never agrees with a verdict.
|
|
84
|
+
*/
|
|
85
|
+
function mintKey(result) {
|
|
86
|
+
try {
|
|
87
|
+
return mintVerdict(parseAccount(result));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return 'malformed';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A classic Token mint's decimals: a missing mint, an account of another
|
|
95
|
+
* program or data that does not parse is the token's own `ASSET_RESOLUTION`; a Token-2022
|
|
96
|
+
* mint is `UNSUPPORTED_CAPABILITY`. A definitive node error is made retryable;
|
|
97
|
+
* `PROVIDER_MISCONFIGURED` and retryable errors propagate unchanged. Under a quorum (the
|
|
98
|
+
* token metadata the core caches), endpoints must agree on the verdict: a lagging one that
|
|
99
|
+
* has no mint yet, or one with other decimals, decides nothing (`PROVIDER_INCONSISTENT`).
|
|
100
|
+
*/
|
|
101
|
+
async function mintDecimals(ctx, mint, tags) {
|
|
102
|
+
let info;
|
|
103
|
+
try {
|
|
104
|
+
info = await accountInfo(ctx, mint, { ...tags, quorumKey: mintKey });
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if ((0, error_1.isCryptoAioError)(error, 'RPC_ERROR') && !error.retryable) {
|
|
108
|
+
throw (0, error_1.withContext)(error, {}, { retryable: true });
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
const verdict = mintVerdict(info);
|
|
113
|
+
if ('decimals' in verdict)
|
|
114
|
+
return verdict.decimals;
|
|
115
|
+
switch (verdict.refused) {
|
|
116
|
+
case 'missing':
|
|
117
|
+
throw assetError('no mint at this address');
|
|
118
|
+
case 'token-2022':
|
|
119
|
+
throw new error_1.UnsupportedCapabilityError('UNSUPPORTED_CAPABILITY', 'Token-2022 mints are not supported');
|
|
120
|
+
case 'other-program':
|
|
121
|
+
throw assetError('not an SPL token mint');
|
|
122
|
+
case 'unparsable':
|
|
123
|
+
throw assetError('the mint does not parse');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function createSolanaAddressCodec() {
|
|
127
|
+
return {
|
|
128
|
+
validate: (value) => (0, keys_1.isAddress)(value),
|
|
129
|
+
normalize: (value) => {
|
|
130
|
+
if (!(0, keys_1.isAddress)(value)) {
|
|
131
|
+
throw new error_1.ValidationError('INVALID_ADDRESS', 'not a Solana address');
|
|
132
|
+
}
|
|
133
|
+
return { canonical: value, display: value };
|
|
134
|
+
},
|
|
135
|
+
fromPublicKey: (publicKey) => {
|
|
136
|
+
const canonical = (0, keys_1.addressFromPublicKey)(publicKey);
|
|
137
|
+
return { canonical, display: canonical };
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function driverBlock(height, header) {
|
|
142
|
+
return {
|
|
143
|
+
height,
|
|
144
|
+
hash: header.blockhash,
|
|
145
|
+
parentHash: header.previousBlockhash,
|
|
146
|
+
...(header.blockTime !== undefined ? { timestamp: header.blockTime } : {}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The block at dense `height` (`confirmed`), checked against the height it claims; `null`
|
|
151
|
+
* while the endpoint has no block there. A contradicting answer is a retryable
|
|
152
|
+
* `PROVIDER_INCONSISTENT`, and the cached slot it came from is dropped.
|
|
153
|
+
*/
|
|
154
|
+
async function blockAtHeight(ctx, height, tags) {
|
|
155
|
+
const slot = await ctx.heights.slotAt(height, 'confirmed', tags);
|
|
156
|
+
if (slot === null)
|
|
157
|
+
return null;
|
|
158
|
+
const header = await ctx.heights.header(slot, 'confirmed', tags);
|
|
159
|
+
if (!header)
|
|
160
|
+
return null;
|
|
161
|
+
if (header.blockHeight !== height) {
|
|
162
|
+
ctx.heights.forget();
|
|
163
|
+
throw (0, rpc_1.inconsistent)(`the block at slot ${slot} is not at height ${height}`);
|
|
164
|
+
}
|
|
165
|
+
return { slot, block: driverBlock(height, header) };
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Reads a transaction at `confirmed`, with its block's height and hash. The answer must be
|
|
169
|
+
* the transaction asked for: another one decides nothing (a retryable "not yet"), never
|
|
170
|
+
* reads as ours.
|
|
171
|
+
*/
|
|
172
|
+
async function readTransaction(ctx, signature, tags) {
|
|
173
|
+
const result = await (0, rpc_1.call)(ctx.transport, 'getTransaction', [signature, (0, rpc_1.parsedOptions)('confirmed')], tags);
|
|
174
|
+
if (result === null)
|
|
175
|
+
return null;
|
|
176
|
+
const parsed = (0, decode_1.parseTransaction)(result, signature);
|
|
177
|
+
if (parsed.slot === undefined)
|
|
178
|
+
throw (0, rpc_1.malformed)('getTransaction');
|
|
179
|
+
const header = await ctx.heights.header(parsed.slot, 'confirmed', tags);
|
|
180
|
+
if (!header)
|
|
181
|
+
throw (0, rpc_1.notYet)('the block of the transaction');
|
|
182
|
+
return { parsed, header };
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Token metadata is read under the proof quorum, stricter than
|
|
186
|
+
* the contract table's minimum: the core caches a token's decimals and "no such token" for
|
|
187
|
+
* the container's life, so one lagging or wrong endpoint must not mis-scale every amount
|
|
188
|
+
* until a restart. `mintDecimals` compares the mint's verdict only. The builder reads the
|
|
189
|
+
* decimals it signs into `transferChecked` the same way, so a lagging
|
|
190
|
+
* endpoint without the mint decides nothing instead of refusing the transfer.
|
|
191
|
+
*/
|
|
192
|
+
exports.METADATA = Object.freeze({ ...rpc_1.READ, quorum: 'proof' });
|
|
193
|
+
function createSolanaReader(ctx) {
|
|
194
|
+
const height = async (commitment) => (0, rpc_1.u64)(await (0, rpc_1.call)(ctx.transport, 'getBlockHeight', [{ commitment }], rpc_1.MONITOR), 'getBlockHeight');
|
|
195
|
+
return {
|
|
196
|
+
getBalance: async (address, asset) => {
|
|
197
|
+
if (asset === 'native') {
|
|
198
|
+
return (0, rpc_1.u64)((0, rpc_1.contextValue)(await (0, rpc_1.call)(ctx.transport, 'getBalance', [address, { commitment: 'confirmed' }], rpc_1.READ), 'getBalance'), 'balance');
|
|
199
|
+
}
|
|
200
|
+
const mint = mintOf(asset);
|
|
201
|
+
const accounts = await tokenAccountsOf(ctx, address, mint, rpc_1.READ);
|
|
202
|
+
return accounts.reduce((sum, account) => sum + account.amount, 0n);
|
|
203
|
+
},
|
|
204
|
+
getBlockHeight: () => height('confirmed'),
|
|
205
|
+
getFinalizedHeight: () => height('finalized'),
|
|
206
|
+
getBlock: async (ref) => {
|
|
207
|
+
if (typeof ref !== 'bigint') {
|
|
208
|
+
throw new error_1.UnsupportedCapabilityError('UNSUPPORTED_CAPABILITY', 'Solana has no block lookup by hash; pass a block height');
|
|
209
|
+
}
|
|
210
|
+
return (await blockAtHeight(ctx, ref, rpc_1.READ))?.block ?? null;
|
|
211
|
+
},
|
|
212
|
+
getTransaction: async (id) => {
|
|
213
|
+
if (!(0, keys_1.isSignature)(id))
|
|
214
|
+
return null;
|
|
215
|
+
const found = await readTransaction(ctx, id, rpc_1.READ);
|
|
216
|
+
if (!found)
|
|
217
|
+
return null;
|
|
218
|
+
return (0, decode_1.decodeTransaction)(found.parsed, {
|
|
219
|
+
height: found.header.blockHeight,
|
|
220
|
+
hash: found.header.blockhash,
|
|
221
|
+
...(found.parsed.blockTime !== undefined
|
|
222
|
+
? { blockTime: found.parsed.blockTime }
|
|
223
|
+
: {}),
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
observe: async (ref, ordering, from) => {
|
|
227
|
+
if (!(0, keys_1.isSignature)(ref.id))
|
|
228
|
+
return { seen: 'none' };
|
|
229
|
+
const found = await readTransaction(ctx, ref.id, rpc_1.MONITOR);
|
|
230
|
+
if (!found)
|
|
231
|
+
return { seen: 'none' };
|
|
232
|
+
const { parsed, header } = found;
|
|
233
|
+
let success = parsed.err === null;
|
|
234
|
+
let reason = success ? undefined : 'transaction failed';
|
|
235
|
+
// The phantom-success guard applies to our own Attempts only. This is
|
|
236
|
+
// one endpoint's `confirmed` view, so the core records it as observed evidence,
|
|
237
|
+
// never terminal: a verdict reads the finalized transaction under the proof quorum's
|
|
238
|
+
// key (`proofs.ts`). A node that drops the token instruction makes the transfer look
|
|
239
|
+
// native here, which that verdict catches.
|
|
240
|
+
if (success && ordering !== undefined && from !== undefined) {
|
|
241
|
+
if (!(0, decode_1.tokenTransfersLanded)(parsed, from)) {
|
|
242
|
+
success = false;
|
|
243
|
+
reason = 'token transfer failed';
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
seen: 'block',
|
|
248
|
+
txHash: parsed.signature,
|
|
249
|
+
blockHeight: header.blockHeight,
|
|
250
|
+
blockHash: header.blockhash,
|
|
251
|
+
success,
|
|
252
|
+
...(reason !== undefined ? { reason } : {}),
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
getTokenMetadata: async (ref) => {
|
|
256
|
+
const mint = mintOf(ref);
|
|
257
|
+
const decimals = await mintDecimals(ctx, mint, exports.METADATA);
|
|
258
|
+
// SPL mints carry no symbol on chain: a registered token has its own; any other
|
|
259
|
+
// shows the first characters of its mint (display only).
|
|
260
|
+
return { symbol: mint.slice(0, 8), decimals };
|
|
261
|
+
},
|
|
262
|
+
normalizeTokenRef: (ref) => ({ standard: 'spl', contract: mintOf(ref) }),
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The classic token accounts of `owner`, optionally for one mint. The answer is filtered to
|
|
267
|
+
* what was asked (lookups by id): an account of another owner or mint, as a node that
|
|
268
|
+
* drops a filter would list it, is none of the owner's. Token-2022 accounts are skipped
|
|
269
|
+
* (unsupported). An account listed twice is malformed, never a doubled balance.
|
|
270
|
+
*/
|
|
271
|
+
async function tokenAccountsOf(ctx, owner, mint, tags) {
|
|
272
|
+
const value = (0, rpc_1.contextValue)(await (0, rpc_1.call)(ctx.transport, 'getTokenAccountsByOwner', [
|
|
273
|
+
owner,
|
|
274
|
+
mint !== undefined ? { mint } : { programId: programs_1.TOKEN_PROGRAM },
|
|
275
|
+
{ encoding: 'base64', commitment: 'confirmed' },
|
|
276
|
+
], tags), 'getTokenAccountsByOwner');
|
|
277
|
+
if (!Array.isArray(value))
|
|
278
|
+
throw (0, rpc_1.malformed)('getTokenAccountsByOwner');
|
|
279
|
+
const accounts = [];
|
|
280
|
+
const listed = new Set();
|
|
281
|
+
for (const entry of value) {
|
|
282
|
+
const item = (0, rpc_1.record)(entry);
|
|
283
|
+
const account = (0, rpc_1.record)(item?.account);
|
|
284
|
+
if (!item ||
|
|
285
|
+
!account ||
|
|
286
|
+
!(0, keys_1.isAddress)(item.pubkey) ||
|
|
287
|
+
listed.has(item.pubkey) ||
|
|
288
|
+
!(0, keys_1.isAddress)(account.owner)) {
|
|
289
|
+
throw (0, rpc_1.malformed)('getTokenAccountsByOwner');
|
|
290
|
+
}
|
|
291
|
+
listed.add(item.pubkey);
|
|
292
|
+
if (account.owner !== programs_1.TOKEN_PROGRAM)
|
|
293
|
+
continue; // Token-2022 is unsupported.
|
|
294
|
+
const decoded = (0, programs_1.decodeTokenAccount)(base64Data(account.data, 'getTokenAccountsByOwner'));
|
|
295
|
+
if (!decoded)
|
|
296
|
+
throw (0, rpc_1.malformed)('getTokenAccountsByOwner');
|
|
297
|
+
const accountMint = (0, keys_1.encodeBase58)(decoded.mint);
|
|
298
|
+
if ((0, keys_1.encodeBase58)(decoded.owner) !== owner)
|
|
299
|
+
continue;
|
|
300
|
+
if (mint !== undefined && accountMint !== mint)
|
|
301
|
+
continue;
|
|
302
|
+
accounts.push({
|
|
303
|
+
address: item.pubkey,
|
|
304
|
+
mint: accountMint,
|
|
305
|
+
amount: decoded.amount,
|
|
306
|
+
frozen: decoded.frozen,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
return accounts;
|
|
310
|
+
}
|
|
311
|
+
function createSolanaExt(ctx) {
|
|
312
|
+
return {
|
|
313
|
+
solana: {
|
|
314
|
+
getTokenAccounts: async (owner, mint) => {
|
|
315
|
+
if (!(0, keys_1.isAddress)(owner)) {
|
|
316
|
+
throw new error_1.ValidationError('INVALID_ADDRESS', 'not a Solana address');
|
|
317
|
+
}
|
|
318
|
+
if (mint !== undefined && (0, keys_1.decodeBase58)(mint, 32) === null) {
|
|
319
|
+
throw new error_1.ValidationError('INVALID_ADDRESS', 'not a Solana mint address');
|
|
320
|
+
}
|
|
321
|
+
return tokenAccountsOf(ctx, owner, mint, rpc_1.READ);
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../src/adapters/solana/reader.ts"],"names":[],"mappings":";;;AAiHA,kCAaC;AAKD,wBAMC;AAwCD,oCA6BC;AAED,4DAcC;AAgBD,sCAcC;AAOD,0CAiBC;AAYD,gDAqFC;AAQD,0CAmDC;AAED,0CAcC;AArbD,mDAKiC;AAKjC,qCAKkB;AAElB,iCAMgB;AAEhB,yCAKoB;AACpB,+BAYe;AAsBf;;;;;GAKG;AACH,SAAS,UAAU,CAAC,KAAc,EAAE,IAAY;IAC9C,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ;QACrB,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ;QAC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QAAQ,CAAC,IAAI,CAAC;YACZ,OAAO,EAAE,IAAI,CAAC,MAAM;YACpB,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,eAAe,CAAC,GAAkB;IAChD,OAAO;QACL,MAAM,EAAE;YACN,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACtC,IAAI,CAAC,IAAA,gBAAS,EAAC,KAAK,CAAC,EAAE,CAAC;oBACtB,MAAM,IAAI,uBAAe,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,CAAC;gBACvE,CAAC;gBACD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAA,mBAAY,EAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;oBAC1D,MAAM,IAAI,uBAAe,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,CAAC;gBAC5E,CAAC;gBACD,OAAO,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,UAAI,CAAC,CAAC;YACjD,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Solana addresses, reads and the `ext.solana` API. Every call carries the tags of the\n * `ChainDriver` contract table: `read` for point queries, `monitor` for heights and\n * observations. Heads are read at `confirmed`, finality at `finalized`.\n */\nimport type {\n AddressCodec,\n ChainReader,\n DriverBlock,\n DriverTxObservation,\n} from '../../core/driver/types';\nimport {\n UnsupportedCapabilityError,\n ValidationError,\n isCryptoAioError,\n withContext,\n} from '../../core/errors/error';\nimport type { Logger } from '../../core/events/logger';\nimport type { AssetMetadata, AssetRef, TokenRef } from '../../core/model/asset';\nimport type { ChainInfo, NetworkInfo } from '../../core/model/chain';\nimport type { Transport } from '../../core/transport/types';\nimport {\n decodeTransaction,\n parseTransaction,\n tokenTransfersLanded,\n type ParsedTransaction,\n} from './decode';\nimport type { HeightIndex } from './heights';\nimport {\n addressFromPublicKey,\n decodeBase58,\n encodeBase58,\n isAddress,\n isSignature,\n} from './keys';\nimport type { SolanaNetworkConfig } from './network';\nimport {\n TOKEN_2022_PROGRAM,\n TOKEN_PROGRAM,\n decodeMint,\n decodeTokenAccount,\n} from './programs';\nimport {\n MONITOR,\n READ,\n call,\n contextValue,\n inconsistent,\n malformed,\n notYet,\n parsedOptions,\n record,\n u64,\n type BlockHeader,\n} from './rpc';\nimport type { SolanaCallTags, SolanaCodec, SolanaExt, SolanaTokenAccount } from './types';\n\n/** What every Solana port is built from. */\nexport interface SolanaContext {\n readonly transport: Transport;\n readonly codec: SolanaCodec;\n readonly chain: ChainInfo;\n readonly network: NetworkInfo;\n readonly config: SolanaNetworkConfig;\n readonly heights: HeightIndex;\n readonly log: Logger;\n /** The next build variant (`fees.ts`, `variantCounter`). */\n readonly nextVariant: () => number;\n}\n\nexport interface AccountInfo {\n readonly owner: string;\n readonly executable: boolean;\n readonly data: Uint8Array;\n}\n\n/**\n * Account data in agave's `base64` encoding, refused unless it is canonical: Node decodes\n * leniently (a stray character is skipped, `AB==` reads as `AA==`), so the bytes must\n * encode back to the same text. The check is linear, which matters: accounts hold up to\n * 10 MiB, and a repeated-group regex overflows the stack on a few MiB.\n */\nfunction base64Data(value: unknown, what: string): Uint8Array {\n if (\n !Array.isArray(value) ||\n value.length !== 2 ||\n value[1] !== 'base64' ||\n typeof value[0] !== 'string' ||\n value[0].length % 4 !== 0\n ) {\n throw malformed(what);\n }\n const bytes = Buffer.from(value[0], 'base64');\n if (bytes.toString('base64') !== value[0]) throw malformed(what);\n return new Uint8Array(bytes);\n}\n\n/** A `getAccountInfo` answer (base64): the account, or `null` when it does not exist. */\nfunction parseAccount(result: unknown): AccountInfo | null {\n const value = contextValue(result, 'getAccountInfo');\n if (value === null) return null;\n const account = record(value);\n if (!account || !isAddress(account.owner) || typeof account.executable !== 'boolean') {\n throw malformed('getAccountInfo');\n }\n return {\n owner: account.owner,\n executable: account.executable,\n data: base64Data(account.data, 'getAccountInfo'),\n };\n}\n\n/** `getAccountInfo` (base64) at `confirmed`; `null` when the account does not exist. */\nexport async function accountInfo(\n ctx: SolanaContext,\n address: string,\n tags: SolanaCallTags,\n): Promise<AccountInfo | null> {\n return parseAccount(\n await call(\n ctx.transport,\n 'getAccountInfo',\n [address, { encoding: 'base64', commitment: 'confirmed' }],\n tags,\n ),\n );\n}\n\nconst assetError = (reason: string) => new ValidationError('ASSET_RESOLUTION', reason);\n\n/** The mint of an `spl` asset ref; any other standard is not a Solana token. */\nexport function mintOf(asset: AssetRef): string {\n if (asset === 'native' || asset.standard !== 'spl') {\n throw assetError(`Solana tokens use the 'spl' standard`);\n }\n if (!isAddress(asset.contract)) throw assetError('not a Solana mint address');\n return asset.contract;\n}\n\n/** What a mint account says about its token: the only fields a mint read decides on. */\ntype MintVerdict =\n | { readonly decimals: number }\n | { readonly refused: 'missing' | 'token-2022' | 'other-program' | 'unparsable' };\n\n/**\n * The verdict of a mint account, by its owning program first: a classic mint and a\n * Token-2022 one cannot be told apart by their size.\n */\nfunction mintVerdict(info: AccountInfo | null): MintVerdict {\n if (!info) return { refused: 'missing' };\n if (info.owner === TOKEN_2022_PROGRAM) return { refused: 'token-2022' };\n if (info.owner !== TOKEN_PROGRAM) return { refused: 'other-program' };\n const decoded = decodeMint(info.data);\n return decoded ? { decimals: decoded.decimals } : { refused: 'unparsable' };\n}\n\n/**\n * A mint read's quorum key, verdict fields only: the verdict itself, never the\n * context slot, the lamports or the supply, on which honest endpoints differ. A malformed\n * answer keys as such, so it never agrees with a verdict.\n */\nfunction mintKey(result: unknown): unknown {\n try {\n return mintVerdict(parseAccount(result));\n } catch {\n return 'malformed';\n }\n}\n\n/**\n * A classic Token mint's decimals: a missing mint, an account of another\n * program or data that does not parse is the token's own `ASSET_RESOLUTION`; a Token-2022\n * mint is `UNSUPPORTED_CAPABILITY`. A definitive node error is made retryable;\n * `PROVIDER_MISCONFIGURED` and retryable errors propagate unchanged. Under a quorum (the\n * token metadata the core caches), endpoints must agree on the verdict: a lagging one that\n * has no mint yet, or one with other decimals, decides nothing (`PROVIDER_INCONSISTENT`).\n */\nexport async function mintDecimals(\n ctx: SolanaContext,\n mint: string,\n tags: SolanaCallTags,\n): Promise<number> {\n let info: AccountInfo | null;\n try {\n info = await accountInfo(ctx, mint, { ...tags, quorumKey: mintKey });\n } catch (error) {\n if (isCryptoAioError(error, 'RPC_ERROR') && !error.retryable) {\n throw withContext(error, {}, { retryable: true });\n }\n throw error;\n }\n const verdict = mintVerdict(info);\n if ('decimals' in verdict) return verdict.decimals;\n switch (verdict.refused) {\n case 'missing':\n throw assetError('no mint at this address');\n case 'token-2022':\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n 'Token-2022 mints are not supported',\n );\n case 'other-program':\n throw assetError('not an SPL token mint');\n case 'unparsable':\n throw assetError('the mint does not parse');\n }\n}\n\nexport function createSolanaAddressCodec(): AddressCodec {\n return {\n validate: (value) => isAddress(value),\n normalize: (value) => {\n if (!isAddress(value)) {\n throw new ValidationError('INVALID_ADDRESS', 'not a Solana address');\n }\n return { canonical: value, display: value };\n },\n fromPublicKey: (publicKey) => {\n const canonical = addressFromPublicKey(publicKey);\n return { canonical, display: canonical };\n },\n };\n}\n\nfunction driverBlock(height: bigint, header: BlockHeader): DriverBlock {\n return {\n height,\n hash: header.blockhash,\n parentHash: header.previousBlockhash,\n ...(header.blockTime !== undefined ? { timestamp: header.blockTime } : {}),\n };\n}\n\n/**\n * The block at dense `height` (`confirmed`), checked against the height it claims; `null`\n * while the endpoint has no block there. A contradicting answer is a retryable\n * `PROVIDER_INCONSISTENT`, and the cached slot it came from is dropped.\n */\nexport async function blockAtHeight(\n ctx: SolanaContext,\n height: bigint,\n tags: SolanaCallTags,\n): Promise<{ readonly slot: bigint; readonly block: DriverBlock } | null> {\n const slot = await ctx.heights.slotAt(height, 'confirmed', tags);\n if (slot === null) return null;\n const header = await ctx.heights.header(slot, 'confirmed', tags);\n if (!header) return null;\n if (header.blockHeight !== height) {\n ctx.heights.forget();\n throw inconsistent(`the block at slot ${slot} is not at height ${height}`);\n }\n return { slot, block: driverBlock(height, header) };\n}\n\n/**\n * Reads a transaction at `confirmed`, with its block's height and hash. The answer must be\n * the transaction asked for: another one decides nothing (a retryable \"not yet\"), never\n * reads as ours.\n */\nexport async function readTransaction(\n ctx: SolanaContext,\n signature: string,\n tags: SolanaCallTags,\n): Promise<{ readonly parsed: ParsedTransaction; readonly header: BlockHeader } | null> {\n const result = await call(\n ctx.transport,\n 'getTransaction',\n [signature, parsedOptions('confirmed')],\n tags,\n );\n if (result === null) return null;\n const parsed = parseTransaction(result, signature);\n if (parsed.slot === undefined) throw malformed('getTransaction');\n const header = await ctx.heights.header(parsed.slot, 'confirmed', tags);\n if (!header) throw notYet('the block of the transaction');\n return { parsed, header };\n}\n\n/**\n * Token metadata is read under the proof quorum, stricter than\n * the contract table's minimum: the core caches a token's decimals and \"no such token\" for\n * the container's life, so one lagging or wrong endpoint must not mis-scale every amount\n * until a restart. `mintDecimals` compares the mint's verdict only. The builder reads the\n * decimals it signs into `transferChecked` the same way, so a lagging\n * endpoint without the mint decides nothing instead of refusing the transfer.\n */\nexport const METADATA: SolanaCallTags = Object.freeze({ ...READ, quorum: 'proof' });\n\nexport function createSolanaReader(ctx: SolanaContext): ChainReader {\n const height = async (commitment: 'confirmed' | 'finalized') =>\n u64(\n await call(ctx.transport, 'getBlockHeight', [{ commitment }], MONITOR),\n 'getBlockHeight',\n );\n return {\n getBalance: async (address, asset) => {\n if (asset === 'native') {\n return u64(\n contextValue(\n await call(\n ctx.transport,\n 'getBalance',\n [address, { commitment: 'confirmed' }],\n READ,\n ),\n 'getBalance',\n ),\n 'balance',\n );\n }\n const mint = mintOf(asset);\n const accounts = await tokenAccountsOf(ctx, address, mint, READ);\n return accounts.reduce((sum, account) => sum + account.amount, 0n);\n },\n getBlockHeight: () => height('confirmed'),\n getFinalizedHeight: () => height('finalized'),\n getBlock: async (ref) => {\n if (typeof ref !== 'bigint') {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n 'Solana has no block lookup by hash; pass a block height',\n );\n }\n return (await blockAtHeight(ctx, ref, READ))?.block ?? null;\n },\n getTransaction: async (id) => {\n if (!isSignature(id)) return null;\n const found = await readTransaction(ctx, id, READ);\n if (!found) return null;\n return decodeTransaction(found.parsed, {\n height: found.header.blockHeight,\n hash: found.header.blockhash,\n ...(found.parsed.blockTime !== undefined\n ? { blockTime: found.parsed.blockTime }\n : {}),\n });\n },\n observe: async (ref, ordering, from): Promise<DriverTxObservation> => {\n if (!isSignature(ref.id)) return { seen: 'none' };\n const found = await readTransaction(ctx, ref.id, MONITOR);\n if (!found) return { seen: 'none' };\n const { parsed, header } = found;\n let success = parsed.err === null;\n let reason = success ? undefined : 'transaction failed';\n // The phantom-success guard applies to our own Attempts only. This is\n // one endpoint's `confirmed` view, so the core records it as observed evidence,\n // never terminal: a verdict reads the finalized transaction under the proof quorum's\n // key (`proofs.ts`). A node that drops the token instruction makes the transfer look\n // native here, which that verdict catches.\n if (success && ordering !== undefined && from !== undefined) {\n if (!tokenTransfersLanded(parsed, from)) {\n success = false;\n reason = 'token transfer failed';\n }\n }\n return {\n seen: 'block',\n txHash: parsed.signature,\n blockHeight: header.blockHeight,\n blockHash: header.blockhash,\n success,\n ...(reason !== undefined ? { reason } : {}),\n };\n },\n getTokenMetadata: async (ref: TokenRef): Promise<AssetMetadata> => {\n const mint = mintOf(ref);\n const decimals = await mintDecimals(ctx, mint, METADATA);\n // SPL mints carry no symbol on chain: a registered token has its own; any other\n // shows the first characters of its mint (display only).\n return { symbol: mint.slice(0, 8), decimals };\n },\n normalizeTokenRef: (ref) => ({ standard: 'spl', contract: mintOf(ref) }),\n };\n}\n\n/**\n * The classic token accounts of `owner`, optionally for one mint. The answer is filtered to\n * what was asked (lookups by id): an account of another owner or mint, as a node that\n * drops a filter would list it, is none of the owner's. Token-2022 accounts are skipped\n * (unsupported). An account listed twice is malformed, never a doubled balance.\n */\nexport async function tokenAccountsOf(\n ctx: SolanaContext,\n owner: string,\n mint: string | undefined,\n tags: SolanaCallTags,\n): Promise<SolanaTokenAccount[]> {\n const value = contextValue(\n await call(\n ctx.transport,\n 'getTokenAccountsByOwner',\n [\n owner,\n mint !== undefined ? { mint } : { programId: TOKEN_PROGRAM },\n { encoding: 'base64', commitment: 'confirmed' },\n ],\n tags,\n ),\n 'getTokenAccountsByOwner',\n );\n if (!Array.isArray(value)) throw malformed('getTokenAccountsByOwner');\n const accounts: SolanaTokenAccount[] = [];\n const listed = new Set<string>();\n for (const entry of value) {\n const item = record(entry);\n const account = record(item?.account);\n if (\n !item ||\n !account ||\n !isAddress(item.pubkey) ||\n listed.has(item.pubkey) ||\n !isAddress(account.owner)\n ) {\n throw malformed('getTokenAccountsByOwner');\n }\n listed.add(item.pubkey);\n if (account.owner !== TOKEN_PROGRAM) continue; // Token-2022 is unsupported.\n const decoded = decodeTokenAccount(\n base64Data(account.data, 'getTokenAccountsByOwner'),\n );\n if (!decoded) throw malformed('getTokenAccountsByOwner');\n const accountMint = encodeBase58(decoded.mint);\n if (encodeBase58(decoded.owner) !== owner) continue;\n if (mint !== undefined && accountMint !== mint) continue;\n accounts.push({\n address: item.pubkey,\n mint: accountMint,\n amount: decoded.amount,\n frozen: decoded.frozen,\n });\n }\n return accounts;\n}\n\nexport function createSolanaExt(ctx: SolanaContext): SolanaExt {\n return {\n solana: {\n getTokenAccounts: async (owner, mint) => {\n if (!isAddress(owner)) {\n throw new ValidationError('INVALID_ADDRESS', 'not a Solana address');\n }\n if (mint !== undefined && decodeBase58(mint, 32) === null) {\n throw new ValidationError('INVALID_ADDRESS', 'not a Solana mint address');\n }\n return tokenAccountsOf(ctx, owner, mint, READ);\n },\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Solana driver's path to the core transport. Every JSON-RPC call
|
|
3
|
+
* is one direct `transport.rpc` call carrying the tags of the `ChainDriver` method that made
|
|
4
|
+
* it; `@solana/web3.js` is never on a request path. Answers are validated here: a malformed
|
|
5
|
+
* answer is a retryable `PROVIDER_UNAVAILABLE`, never a foreign error.
|
|
6
|
+
*/
|
|
7
|
+
import { ProviderError, type CryptoAioError } from '../../core/errors/error';
|
|
8
|
+
import type { Transport } from '../../core/transport/types';
|
|
9
|
+
import type { Commitment, SolanaCallTags } from './types';
|
|
10
|
+
export declare const READ: SolanaCallTags;
|
|
11
|
+
export declare const MONITOR: SolanaCallTags;
|
|
12
|
+
export declare const PROOF: SolanaCallTags;
|
|
13
|
+
export declare const BROADCAST: SolanaCallTags;
|
|
14
|
+
export declare const withSignal: (tags: SolanaCallTags, signal?: AbortSignal) => SolanaCallTags;
|
|
15
|
+
/** Solana's JSON-RPC server errors (agave `rpc-client-api/src/custom_error.rs`). */
|
|
16
|
+
export declare const RPC_CODES: Readonly<{
|
|
17
|
+
BLOCK_CLEANED_UP: -32001;
|
|
18
|
+
SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002;
|
|
19
|
+
TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003;
|
|
20
|
+
BLOCK_NOT_AVAILABLE: -32004;
|
|
21
|
+
SLOT_SKIPPED: -32007;
|
|
22
|
+
LONG_TERM_STORAGE_SLOT_SKIPPED: -32009;
|
|
23
|
+
TRANSACTION_HISTORY_NOT_AVAILABLE: -32011;
|
|
24
|
+
BLOCK_STATUS_NOT_AVAILABLE_YET: -32014;
|
|
25
|
+
MIN_CONTEXT_SLOT_NOT_REACHED: -32016;
|
|
26
|
+
LONG_TERM_STORAGE_UNREACHABLE: -32019;
|
|
27
|
+
FILTER_TRANSACTION_NOT_FOUND: -32020;
|
|
28
|
+
}>;
|
|
29
|
+
/** The JSON-RPC code of a definitive, non-ambiguous `RPC_ERROR`; otherwise `undefined`. */
|
|
30
|
+
export declare function rpcCode(error: unknown): number | undefined;
|
|
31
|
+
/** The node's message of a definitive, non-ambiguous `RPC_ERROR`. */
|
|
32
|
+
export declare function rpcMessage(error: CryptoAioError): string;
|
|
33
|
+
/** The endpoint has not reached that block or state yet (`null`, decides nothing). */
|
|
34
|
+
export declare const isNotYet: (error: unknown) => boolean;
|
|
35
|
+
/** The endpoint no longer holds that block or history, or never did (decides nothing). */
|
|
36
|
+
export declare const isGone: (error: unknown) => boolean;
|
|
37
|
+
/** The endpoint says the slot was skipped, or is missing on this endpoint (`-32007`). */
|
|
38
|
+
export declare const isSkipped: (error: unknown) => boolean;
|
|
39
|
+
/** Any answer meaning "this endpoint cannot show that": it never decides anything. */
|
|
40
|
+
export declare const isNotAvailable: (error: unknown) => boolean;
|
|
41
|
+
/** A retryable error that decides nothing: the endpoint no longer holds what was asked. */
|
|
42
|
+
export declare const gone: (what: string) => ProviderError;
|
|
43
|
+
/** A retryable error that decides nothing: the endpoints cannot show this yet. */
|
|
44
|
+
export declare const notYet: (what: string) => ProviderError;
|
|
45
|
+
/**
|
|
46
|
+
* On a proof path only a definitive negative proof answers "no". Any
|
|
47
|
+
* other definitive RPC error (agave 4.3.0's `getBlocks` answers `-32602 "BigTable query
|
|
48
|
+
* failed"` for a range below its local ledger, `-32603` on a blockstore error) decides
|
|
49
|
+
* nothing: it becomes a retryable `PROVIDER_UNAVAILABLE`. Every other error (retryable
|
|
50
|
+
* ones, `PROVIDER_MISCONFIGURED`) is returned unchanged.
|
|
51
|
+
*/
|
|
52
|
+
export declare function undecided(error: unknown, what: string): unknown;
|
|
53
|
+
export declare const malformed: (what: string) => ProviderError;
|
|
54
|
+
export declare const inconsistent: (what: string) => ProviderError;
|
|
55
|
+
/** A JSON object's fields, or `null` for anything else (arrays and `null` included). */
|
|
56
|
+
export declare const record: (value: unknown) => Record<string, unknown> | null;
|
|
57
|
+
/**
|
|
58
|
+
* An unsigned 64-bit JSON integer (lamports, slots, heights) as a `bigint`. Every call
|
|
59
|
+
* parses with `exactIntegers`, so a value above 2^53 − 1 arrives as a `bigint`; a
|
|
60
|
+
* number outside the safe range was rounded somewhere and is refused as malformed.
|
|
61
|
+
*/
|
|
62
|
+
export declare function u64(value: unknown, what: string): bigint;
|
|
63
|
+
/** A decimal string of base units (token amounts), as a `bigint`. */
|
|
64
|
+
export declare function amountString(value: unknown, what: string): bigint;
|
|
65
|
+
/** The `value` of an RPC response with context (`{ context: { slot }, value }`). */
|
|
66
|
+
export declare function contextValue(result: unknown, what: string): unknown;
|
|
67
|
+
/** A block header as `getBlock` returns it with `transactionDetails: 'none'`. */
|
|
68
|
+
export interface BlockHeader {
|
|
69
|
+
readonly blockhash: string;
|
|
70
|
+
readonly previousBlockhash: string;
|
|
71
|
+
readonly parentSlot: bigint;
|
|
72
|
+
readonly blockHeight: bigint;
|
|
73
|
+
/** Unix seconds, when the node estimates one. */
|
|
74
|
+
readonly blockTime?: number;
|
|
75
|
+
}
|
|
76
|
+
export declare function blockHeader(result: unknown): BlockHeader;
|
|
77
|
+
export declare const pick: (value: unknown, keys: readonly string[]) => unknown;
|
|
78
|
+
/** The consensus fields of a block header, compared under a quorum. */
|
|
79
|
+
export declare const BLOCK_FIELDS: readonly ["blockhash", "previousBlockhash", "parentSlot", "blockHeight"];
|
|
80
|
+
/**
|
|
81
|
+
* The consensus facts compared under a quorum, per method. A key that throws
|
|
82
|
+
* counts as a disagreement (a retryable `PROVIDER_INCONSISTENT`).
|
|
83
|
+
*/
|
|
84
|
+
export declare function quorumKeyFor(method: string): ((result: unknown) => unknown) | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* One JSON-RPC call through the transport, under the calling driver method's tags. Solana
|
|
87
|
+
* sends u64 values (lamports) as JSON numbers, so every answer is parsed with
|
|
88
|
+
* `exactIntegers`: nothing above 2^53 − 1 is ever rounded.
|
|
89
|
+
*/
|
|
90
|
+
export declare function call(transport: Transport, method: string, params: readonly unknown[], tags: SolanaCallTags): Promise<unknown>;
|
|
91
|
+
/** `getBlock` options for a header (no transactions, no rewards). */
|
|
92
|
+
export declare const headerOptions: (commitment: Commitment) => {
|
|
93
|
+
commitment: Commitment;
|
|
94
|
+
transactionDetails: string;
|
|
95
|
+
rewards: boolean;
|
|
96
|
+
};
|
|
97
|
+
/** `getBlock`/`getTransaction` options for decoding (every transaction version we parse). */
|
|
98
|
+
export declare const parsedOptions: (commitment: Commitment) => {
|
|
99
|
+
commitment: Commitment;
|
|
100
|
+
encoding: string;
|
|
101
|
+
maxSupportedTransactionVersion: number;
|
|
102
|
+
};
|