crypto-aio 0.1.0 → 1.0.0-rc.1
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 +220 -2
- package/README.md +42 -16
- package/dist/adapters/avalanche/driver.d.ts +4 -0
- package/dist/adapters/avalanche/driver.js.map +1 -1
- package/dist/adapters/avalanche/sdk.d.ts +15 -0
- package/dist/adapters/avalanche/sdk.js.map +1 -1
- package/dist/adapters/evm/builder.js +64 -4
- package/dist/adapters/evm/builder.js.map +1 -1
- package/dist/adapters/evm/decode.js +6 -1
- package/dist/adapters/evm/decode.js.map +1 -1
- package/dist/adapters/evm/ethers-client.js +4 -0
- package/dist/adapters/evm/ethers-client.js.map +1 -1
- package/dist/adapters/evm/fees.d.ts +24 -0
- package/dist/adapters/evm/fees.js +47 -4
- package/dist/adapters/evm/fees.js.map +1 -1
- package/dist/adapters/evm/index.d.ts +1 -1
- package/dist/adapters/evm/index.js +2 -1
- package/dist/adapters/evm/index.js.map +1 -1
- package/dist/adapters/evm/network.d.ts +5 -0
- package/dist/adapters/evm/network.js +21 -2
- package/dist/adapters/evm/network.js.map +1 -1
- package/dist/adapters/evm/plugin.d.ts +6 -6
- package/dist/adapters/evm/plugin.js +50 -2
- package/dist/adapters/evm/plugin.js.map +1 -1
- package/dist/adapters/evm/proofs.js +17 -5
- package/dist/adapters/evm/proofs.js.map +1 -1
- package/dist/adapters/evm/reader.d.ts +18 -0
- package/dist/adapters/evm/reader.js +34 -0
- package/dist/adapters/evm/reader.js.map +1 -1
- package/dist/adapters/evm/tokens.d.ts +3 -0
- package/dist/adapters/evm/tokens.js.map +1 -1
- package/dist/adapters/evm/types.d.ts +10 -0
- package/dist/adapters/evm/types.js.map +1 -1
- package/dist/adapters/evm/web3-client.d.ts +6 -3
- package/dist/adapters/evm/web3-client.js +19 -2
- package/dist/adapters/evm/web3-client.js.map +1 -1
- package/dist/adapters/solana/builder.js +29 -18
- package/dist/adapters/solana/builder.js.map +1 -1
- package/dist/adapters/solana/fees.d.ts +12 -3
- package/dist/adapters/solana/fees.js +13 -4
- package/dist/adapters/solana/fees.js.map +1 -1
- 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/plugin.js +4 -1
- package/dist/adapters/solana/plugin.js.map +1 -1
- package/dist/adapters/solana/types.d.ts +8 -5
- package/dist/adapters/solana/types.js.map +1 -1
- package/dist/adapters/solana/web3.js +10 -32
- package/dist/adapters/solana/web3.js.map +1 -1
- package/dist/adapters/ton/network.d.ts +1 -0
- package/dist/adapters/ton/network.js +1 -0
- package/dist/adapters/ton/network.js.map +1 -1
- package/dist/adapters/ton/proofs.js +18 -76
- package/dist/adapters/ton/proofs.js.map +1 -1
- package/dist/adapters/ton/reader.d.ts +45 -4
- package/dist/adapters/ton/reader.js +200 -5
- package/dist/adapters/ton/reader.js.map +1 -1
- package/dist/adapters/ton/trace.d.ts +26 -0
- package/dist/adapters/ton/trace.js +35 -9
- package/dist/adapters/ton/trace.js.map +1 -1
- package/dist/adapters/ton/types.d.ts +1 -0
- package/dist/adapters/ton/types.js.map +1 -1
- package/dist/adapters/tron/abi.d.ts +2 -0
- package/dist/adapters/tron/abi.js +2 -0
- package/dist/adapters/tron/abi.js.map +1 -1
- package/dist/adapters/tron/builder.js +20 -4
- package/dist/adapters/tron/builder.js.map +1 -1
- package/dist/adapters/tron/decode.d.ts +2 -0
- package/dist/adapters/tron/decode.js +4 -3
- package/dist/adapters/tron/decode.js.map +1 -1
- package/dist/adapters/tron/http.d.ts +6 -0
- package/dist/adapters/tron/http.js +9 -0
- package/dist/adapters/tron/http.js.map +1 -1
- package/dist/adapters/tron/network.d.ts +4 -0
- package/dist/adapters/tron/network.js +4 -0
- package/dist/adapters/tron/network.js.map +1 -1
- package/dist/adapters/tron/proofs.js +7 -2
- package/dist/adapters/tron/proofs.js.map +1 -1
- package/dist/adapters/tron/reader.d.ts +10 -0
- package/dist/adapters/tron/reader.js +18 -1
- package/dist/adapters/tron/reader.js.map +1 -1
- package/dist/adapters/tron/tokens.d.ts +2 -0
- package/dist/adapters/tron/tokens.js.map +1 -1
- package/dist/adapters/utxo/builder.js +1 -1
- package/dist/adapters/utxo/builder.js.map +1 -1
- package/dist/adapters/utxo/chains.js +2 -1
- package/dist/adapters/utxo/chains.js.map +1 -1
- package/dist/adapters/utxo/context.d.ts +6 -0
- package/dist/adapters/utxo/context.js +8 -1
- package/dist/adapters/utxo/context.js.map +1 -1
- package/dist/adapters/utxo/decode.d.ts +8 -0
- package/dist/adapters/utxo/decode.js +36 -0
- package/dist/adapters/utxo/decode.js.map +1 -1
- package/dist/adapters/utxo/driver.d.ts +4 -0
- package/dist/adapters/utxo/driver.js +5 -0
- package/dist/adapters/utxo/driver.js.map +1 -1
- package/dist/adapters/utxo/esplora.d.ts +29 -2
- package/dist/adapters/utxo/esplora.js +69 -5
- package/dist/adapters/utxo/esplora.js.map +1 -1
- package/dist/adapters/utxo/proofs.d.ts +15 -6
- package/dist/adapters/utxo/proofs.js +185 -47
- package/dist/adapters/utxo/proofs.js.map +1 -1
- 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 +14 -0
- package/dist/adapters/utxo/rawtx.js +44 -14
- package/dist/adapters/utxo/rawtx.js.map +1 -1
- package/dist/adapters/utxo/types.d.ts +1 -0
- package/dist/adapters/utxo/types.js.map +1 -1
- package/dist/core/blockchain/handle.d.ts +12 -28
- package/dist/core/blockchain/handle.js +113 -113
- package/dist/core/blockchain/handle.js.map +1 -1
- package/dist/core/config/types.d.ts +79 -0
- package/dist/core/config/types.js.map +1 -1
- package/dist/core/container/container.d.ts +4 -8
- package/dist/core/container/container.js +42 -8
- package/dist/core/container/container.js.map +1 -1
- package/dist/core/container/pool.js +12 -0
- package/dist/core/container/pool.js.map +1 -1
- package/dist/core/driver/types.d.ts +158 -8
- package/dist/core/driver/types.js.map +1 -1
- package/dist/core/errors/codes.d.ts +13 -0
- package/dist/core/errors/codes.js +4 -0
- package/dist/core/errors/codes.js.map +1 -1
- package/dist/core/errors/error.d.ts +26 -0
- package/dist/core/errors/error.js +20 -0
- package/dist/core/errors/error.js.map +1 -1
- package/dist/core/events/logger.d.ts +17 -1
- package/dist/core/events/logger.js +5 -1
- package/dist/core/events/logger.js.map +1 -1
- package/dist/core/events/types.d.ts +26 -1
- package/dist/core/events/types.js.map +1 -1
- package/dist/core/lifecycle/engine-rules.d.ts +3 -4
- package/dist/core/lifecycle/engine-rules.js +16 -6
- package/dist/core/lifecycle/engine-rules.js.map +1 -1
- package/dist/core/lifecycle/engine.d.ts +7 -0
- package/dist/core/lifecycle/engine.js +19 -1
- package/dist/core/lifecycle/engine.js.map +1 -1
- package/dist/core/lifecycle/evaluate.js +9 -4
- package/dist/core/lifecycle/evaluate.js.map +1 -1
- package/dist/core/lifecycle/monitor.d.ts +6 -0
- package/dist/core/lifecycle/monitor.js +16 -6
- package/dist/core/lifecycle/monitor.js.map +1 -1
- package/dist/core/lifecycle/reconcile.d.ts +1 -1
- package/dist/core/lifecycle/reconcile.js +1 -1
- package/dist/core/lifecycle/reconcile.js.map +1 -1
- package/dist/core/lifecycle/views.d.ts +5 -0
- package/dist/core/lifecycle/views.js.map +1 -1
- package/dist/core/lifecycle/workers.d.ts +10 -3
- package/dist/core/lifecycle/workers.js +32 -14
- package/dist/core/lifecycle/workers.js.map +1 -1
- package/dist/core/model/address.d.ts +4 -0
- package/dist/core/model/address.js.map +1 -1
- package/dist/core/model/amount.d.ts +5 -0
- package/dist/core/model/amount.js.map +1 -1
- package/dist/core/model/asset.d.ts +11 -0
- package/dist/core/model/asset.js +2 -0
- package/dist/core/model/asset.js.map +1 -1
- package/dist/core/model/capability.d.ts +6 -0
- package/dist/core/model/capability.js +4 -0
- package/dist/core/model/capability.js.map +1 -1
- package/dist/core/model/chain.d.ts +19 -0
- package/dist/core/model/chain.js +1 -0
- package/dist/core/model/chain.js.map +1 -1
- package/dist/core/model/fee.d.ts +24 -1
- package/dist/core/model/fee.js.map +1 -1
- package/dist/core/model/ids.d.ts +11 -7
- package/dist/core/model/ids.js +2 -0
- package/dist/core/model/ids.js.map +1 -1
- package/dist/core/model/intent.d.ts +13 -0
- package/dist/core/model/intent.js.map +1 -1
- package/dist/core/model/ordering.d.ts +13 -0
- package/dist/core/model/ordering.js.map +1 -1
- package/dist/core/model/transaction.d.ts +46 -0
- package/dist/core/model/transaction.js.map +1 -1
- package/dist/core/observe/scanner.d.ts +10 -1
- package/dist/core/observe/scanner.js +9 -0
- package/dist/core/observe/scanner.js.map +1 -1
- package/dist/core/registry/assets.d.ts +5 -0
- package/dist/core/registry/assets.js.map +1 -1
- package/dist/core/registry/plugin.d.ts +6 -1
- package/dist/core/registry/plugin.js.map +1 -1
- package/dist/core/registry/providers.d.ts +5 -0
- package/dist/core/registry/providers.js.map +1 -1
- package/dist/core/registry/schemes.d.ts +7 -0
- package/dist/core/registry/schemes.js.map +1 -1
- package/dist/core/secret/redact.d.ts +9 -0
- package/dist/core/secret/redact.js +9 -0
- package/dist/core/secret/redact.js.map +1 -1
- package/dist/core/secret/secret.d.ts +4 -0
- package/dist/core/secret/secret.js +4 -0
- package/dist/core/secret/secret.js.map +1 -1
- package/dist/core/signing/callback.d.ts +5 -0
- package/dist/core/signing/callback.js.map +1 -1
- package/dist/core/signing/hd.d.ts +4 -0
- package/dist/core/signing/hd.js.map +1 -1
- package/dist/core/signing/local.d.ts +17 -0
- package/dist/core/signing/local.js +5 -0
- package/dist/core/signing/local.js.map +1 -1
- package/dist/core/signing/types.d.ts +35 -1
- package/dist/core/signing/types.js.map +1 -1
- package/dist/core/signing/wallet.js +8 -0
- package/dist/core/signing/wallet.js.map +1 -1
- package/dist/core/store/format.d.ts +20 -0
- package/dist/core/store/format.js +96 -0
- package/dist/core/store/format.js.map +1 -0
- package/dist/core/store/memory.d.ts +11 -0
- package/dist/core/store/memory.js +13 -2
- package/dist/core/store/memory.js.map +1 -1
- package/dist/core/store/types.d.ts +179 -6
- package/dist/core/store/types.js +6 -0
- package/dist/core/store/types.js.map +1 -1
- package/dist/core/transport/http-transport.js +54 -26
- package/dist/core/transport/http-transport.js.map +1 -1
- package/dist/core/transport/types.d.ts +86 -1
- package/dist/core/transport/types.js.map +1 -1
- package/dist/core/util/clock.d.ts +6 -0
- package/dist/core/util/clock.js.map +1 -1
- package/dist/core/util/json.d.ts +13 -1
- package/dist/core/util/json.js +34 -12
- package/dist/core/util/json.js.map +1 -1
- package/dist/core/util/names.d.ts +6 -0
- package/dist/core/util/names.js +10 -0
- package/dist/core/util/names.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/testing/contracts/api.d.ts +1 -0
- package/dist/testing/contracts/api.js +1 -0
- package/dist/testing/contracts/api.js.map +1 -1
- package/dist/testing/contracts/cursors.d.ts +5 -0
- package/dist/testing/contracts/cursors.js +4 -0
- package/dist/testing/contracts/cursors.js.map +1 -1
- package/dist/testing/contracts/locks.d.ts +6 -0
- package/dist/testing/contracts/locks.js +5 -0
- package/dist/testing/contracts/locks.js.map +1 -1
- package/dist/testing/contracts/operations.d.ts +11 -0
- package/dist/testing/contracts/operations.js +30 -1
- package/dist/testing/contracts/operations.js.map +1 -1
- package/dist/testing/contracts/sequences.d.ts +5 -0
- package/dist/testing/contracts/sequences.js +4 -0
- package/dist/testing/contracts/sequences.js.map +1 -1
- package/dist/testing/env.d.ts +16 -0
- package/dist/testing/env.js +2 -1
- package/dist/testing/env.js.map +1 -1
- package/dist/testing/fake-chain.d.ts +32 -0
- package/dist/testing/fake-chain.js +11 -0
- package/dist/testing/fake-chain.js.map +1 -1
- package/dist/testing/fake-driver.d.ts +2 -0
- package/dist/testing/fake-driver.js.map +1 -1
- package/dist/testing/fake-fetch.d.ts +6 -0
- package/dist/testing/fake-fetch.js +2 -0
- package/dist/testing/fake-fetch.js.map +1 -1
- package/dist/testing/fake-plugin.d.ts +2 -0
- package/dist/testing/fake-plugin.js +2 -0
- package/dist/testing/fake-plugin.js.map +1 -1
- package/dist/testing/faulty-store.d.ts +4 -0
- package/dist/testing/faulty-store.js +6 -0
- package/dist/testing/faulty-store.js.map +1 -1
- package/package.json +21 -11
package/CHANGELOG.md
CHANGED
|
@@ -7,11 +7,229 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.0.0-rc.1] - 2026-11-12
|
|
11
|
+
|
|
12
|
+
The release candidate for 1.0.0. It keeps the API 0.2.0 settled and writes down the
|
|
13
|
+
contract 1.0 keeps: [Versioning and
|
|
14
|
+
stability](https://vhidvz.github.io/crypto-aio/reference/stability.html) lists what semver
|
|
15
|
+
covers surface by surface, [Errors](https://vhidvz.github.io/crypto-aio/reference/errors.html)
|
|
16
|
+
the safe action for every code and the error fields you may rely on, and the plugin and
|
|
17
|
+
store pages what a driver and a durable store must do. It closes the gaps a review of every
|
|
18
|
+
page found in the surfaces 1.0 freezes. Code written for 0.2.0 needs no change unless it
|
|
19
|
+
reads Tron block times (now Unix seconds, as on every family) or writes a plugin driver
|
|
20
|
+
that misdeclares its capabilities; [Upgrade to
|
|
21
|
+
1.0](https://vhidvz.github.io/crypto-aio/reference/upgrading.html) says what changed. It is
|
|
22
|
+
published under npm's `next` tag: `npm install crypto-aio@next`.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- `CallOptions.endpointLimit`: a transport read without a quorum can mark a definitive
|
|
27
|
+
refusal as the endpoint's own limit, so the read asks the endpoints it has not asked
|
|
28
|
+
instead of failing; the refusal stands only when every endpoint refuses.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- `stringifyTagged` refuses, with a `TypeError`, a plain object whose only key is `$bigint`
|
|
33
|
+
or `$bytes` (with a string value): `parseTagged` would read it back as a bigint or bytes,
|
|
34
|
+
so a durable store built on them refuses the write instead of storing data that reads
|
|
35
|
+
back changed. The format they write is unchanged, and the core never stores such an
|
|
36
|
+
object.
|
|
37
|
+
- A plugin driver that does not implement a capability its manifest and network declare
|
|
38
|
+
(`ChainDriver.capabilities`), or that orders Attempts otherwise than its chain
|
|
39
|
+
(`ordering`), is refused with `CONFIG_INVALID` when its handle first loads it, instead
|
|
40
|
+
of failing later at a port it lacks.
|
|
41
|
+
- During a rolling upgrade, `aio.operations.list()` and `recover()` leave out an
|
|
42
|
+
Operation a newer version stored, with a logged warning, instead of throwing
|
|
43
|
+
`RECORD_FORMAT_UNSUPPORTED` on the first one; a read by id, key or ref still throws.
|
|
44
|
+
- `Scanner`'s constructor is private, so its internal dependencies leave the declarations;
|
|
45
|
+
scanners come from `bc.scanner()`, as before (the package exports `Scanner` as a type
|
|
46
|
+
only).
|
|
47
|
+
- `OperationStore.findByRef` is specified for several Operations of a namespace holding
|
|
48
|
+
one ref, which the core never writes: a store may return any one of them.
|
|
49
|
+
- **Breaking (Tron):** block and transaction `timestamp`s are Unix seconds on every family.
|
|
50
|
+
Tron reported java-tron's milliseconds, so the same field meant another unit there;
|
|
51
|
+
multiply by 1,000 where you relied on milliseconds. Drivers report seconds too.
|
|
52
|
+
- The documentation states the 1.0 contract and corrects what 0.2.0 left stale: proofs
|
|
53
|
+
as 0.2.0 sizes them (a down endpoint still counts, so production wants three or more
|
|
54
|
+
providers), `TX_UNEVIDENCED` as a failure where value may have moved, what abandoning a
|
|
55
|
+
signed transfer leaves possible on each family, Avalanche change in deposit crediting,
|
|
56
|
+
TON's 512-transaction proof window, each family's covered fee and `ext` shapes, the
|
|
57
|
+
rules a driver and a durable store must keep, and a production checklist covering
|
|
58
|
+
stores, providers, keys, workers, monitoring and upgrades. 26 more snippets are
|
|
59
|
+
type-checked by the docs tests.
|
|
60
|
+
|
|
61
|
+
### Removed
|
|
62
|
+
|
|
63
|
+
- The repository's Dependabot configuration: the nightly run tests the newest release of
|
|
64
|
+
every chain SDK, and GitHub's security updates work without it. The runtime
|
|
65
|
+
dependencies `@noble/*` and `@scure/*` stay on their 1.x lines, since their 2.x lines
|
|
66
|
+
are ES modules only, which Jest's CommonJS loader cannot `require`; the pack check now
|
|
67
|
+
loads every entry point under Jest.
|
|
68
|
+
|
|
69
|
+
### Fixed
|
|
70
|
+
|
|
71
|
+
- Bitcoin: an indexer that refuses an address for its own limit (HTTP 400 "Scripthash
|
|
72
|
+
history too large to scan" or "Too many unspent transaction outputs") no longer fails the
|
|
73
|
+
balance, unspent-output or history read when another `indexer` endpoint is configured:
|
|
74
|
+
the read asks it. blockstream.info started refusing busy addresses this way, which failed
|
|
75
|
+
the nightly signet suite.
|
|
76
|
+
|
|
77
|
+
## [0.2.0] - 2026-10-21
|
|
78
|
+
|
|
79
|
+
crypto-aio 0.2.0 settles everything 1.0 will promise: the API is locked by reports in CI,
|
|
80
|
+
the driver port is final, stored Operations carry a record format, and the gaps that could
|
|
81
|
+
make a paid transfer look failed are closed. Entries marked **Breaking** need a change from
|
|
82
|
+
some users; [Upgrade to 1.0](https://vhidvz.github.io/crypto-aio/reference/upgrading.html)
|
|
83
|
+
says what to do for each.
|
|
84
|
+
|
|
85
|
+
### Added
|
|
86
|
+
|
|
87
|
+
- `SECURITY.md`: how to report a vulnerability privately, and what is in scope.
|
|
88
|
+
- Operation records carry `format` (`OPERATION_FORMAT`, 1), the record format they were
|
|
89
|
+
stored in; a record without one (0.1.0) reads as format 1. A process never reads a record
|
|
90
|
+
of a newer format: the read throws the new `RECORD_FORMAT_UNSUPPORTED`, and a worker
|
|
91
|
+
releases its claim for a newer process. The `OperationStore` contract suite checks that
|
|
92
|
+
a store keeps `format`, and tests pin the intent hash and the store keys as 0.1.0 wrote
|
|
93
|
+
them.
|
|
94
|
+
- API reports (`etc/api/*.api.md`, one per entry point), generated by API Extractor: CI fails
|
|
95
|
+
when the public API changes without its report (`pnpm api:update`).
|
|
96
|
+
- Release tooling: a tag such as `1.0.0-rc.1` publishes under npm's `next` dist-tag, a
|
|
97
|
+
release tag must match `package.json` and have a `CHANGELOG.md` section, which becomes the
|
|
98
|
+
GitHub Release's notes, and a release runs every CI check before it publishes.
|
|
99
|
+
- CI runs on Node.js 22.12.0, 22, 24 and 26, audits the runtime dependencies, and checks the
|
|
100
|
+
package's exports and types with `publint` and `@arethetypeswrong/cli`
|
|
101
|
+
(`pnpm lint:package`). CodeQL and Dependabot are configured.
|
|
102
|
+
|
|
103
|
+
### Changed
|
|
104
|
+
|
|
105
|
+
- **Breaking:** crypto-aio needs Node.js 22.12 or later (`engines.node` is `>=22.12`), the
|
|
106
|
+
version every family already needed for Solana. `engines` no longer names an npm version,
|
|
107
|
+
so npm 11 installs without an engine warning.
|
|
108
|
+
- `package.json` declares `"type": "commonjs"`.
|
|
109
|
+
- **Breaking:** a transfer whose transaction executed but shows no transfer to the
|
|
110
|
+
recipient fails with the new `TX_UNEVIDENCED`, not `TX_REVERTED`: an EVM or Tron token
|
|
111
|
+
that logged no `Transfer` to the recipient, or TON jettons sent to a wallet the master
|
|
112
|
+
does not name. Value may have moved, so check the chain before paying again; a
|
|
113
|
+
`TX_REVERTED` now always means the execution failed. Drivers say which with
|
|
114
|
+
`failure: 'reverted' | 'unevidenced'` (`TxFailure`) on `observe` and `includedFinal`, and
|
|
115
|
+
the core keeps it on the Attempt's observation (`failure`, a field stores must keep).
|
|
116
|
+
- **Breaking:** an endpoint reads `healthy` in `status()` and `getNetworkStatus()` only
|
|
117
|
+
once its height is known, when its family probes heights: before that it is `unknown`,
|
|
118
|
+
where a confirmed identity alone used to make it `healthy`.
|
|
119
|
+
- **Breaking:** a proof needs `proofQuorum` endpoints even after some drop out of its count
|
|
120
|
+
(down for three health intervals): the quorum is capped by the endpoints configured, not
|
|
121
|
+
by those still counted, so the one endpoint left never proves alone; proofs wait for the
|
|
122
|
+
others instead. The new `transport.degradedProofs: true` restores the old behavior, which
|
|
123
|
+
favours liveness.
|
|
124
|
+
- `lifecycle.leaseWaitMs` (default: `leaseMs`): how long a transfer waits for its wallet's
|
|
125
|
+
address lease before `SEQUENCE_BUSY`, so transfers can queue behind a slow signer.
|
|
126
|
+
- Fuzz tests feed every decoder of untrusted bytes (Solana messages and transactions, Tron
|
|
127
|
+
protobuf, Bitcoin and EVM raw transactions, Avalanche transactions, cb58, exact-integer
|
|
128
|
+
JSON) random and mutated input; they may refuse it, never throw an unclassified error.
|
|
129
|
+
A nightly workflow runs them deeper, runs the live read-only integration suites, and
|
|
130
|
+
runs the unit suites on the newest release of every SDK.
|
|
131
|
+
- The pack check compiles a project that imports every entry point with TypeScript 5.3 (the
|
|
132
|
+
oldest supported, with `skipLibCheck`), the tested 5.9 and 7, under `nodenext` and
|
|
133
|
+
`bundler` resolution.
|
|
134
|
+
- `@solana/web3.js` 3 is supported next to 1.99 (peer range `^1.99.0 || ^3.0.0`). The
|
|
135
|
+
Solana driver now compiles its messages and derives token account addresses itself
|
|
136
|
+
(checked byte for byte against the SDK), so signed bytes no longer depend on the SDK
|
|
137
|
+
version; the SDK only backs `native()`. The pack check loads the family with 3.x too.
|
|
138
|
+
- `BuildContext.decimals`: the decimals the core scaled a transfer's amounts with. The
|
|
139
|
+
Solana driver refuses a token transfer whose mint has other decimals
|
|
140
|
+
(`ASSET_RESOLUTION`), which a wrong registration would otherwise sign as a mis-scaled
|
|
141
|
+
`transferChecked`.
|
|
142
|
+
- `ReplacementPolicy.comparePrice` (optional): the EVM family ranks earlier cancels by
|
|
143
|
+
price, so a repeat cancel climbs from the highest one without an explicit `fee`.
|
|
144
|
+
- `assets` on the root container's options registers tokens (decimals, symbol, aliases)
|
|
145
|
+
without writing a plugin.
|
|
146
|
+
- `PROVIDER_MISCONFIGURED` for refused credentials carries `details.httpStatus` (401 or 403).
|
|
147
|
+
- Solana: the signature fee is computed (5,000 lamports per signature), and an endpoint's
|
|
148
|
+
`getFeeForMessage` quote must match the message's fee exactly; any other quote fails the
|
|
149
|
+
estimate with a retryable `PROVIDER_UNAVAILABLE`, so one endpoint can neither inflate an
|
|
150
|
+
estimate (refusing a payable transfer) nor deflate it. Whether an explicit fee fits in
|
|
151
|
+
u64 is decided locally.
|
|
152
|
+
- **Breaking:** Bitcoin: a wallet whose signer does not declare the scheme its address type
|
|
153
|
+
signs with (a `p2tr` wallet on an ECDSA-only signer, such as a KMS key) is refused with
|
|
154
|
+
`CONFIG_INVALID` when the wallet resolves (`ready()`, `walletAddress()`, `transfer()`,
|
|
155
|
+
`prepareTransfer()`), before anything is built or reserved, instead of failing at
|
|
156
|
+
signing. A Schnorr-only signer on a non-`p2tr` wallet gets the same error, where it got
|
|
157
|
+
`INVALID_ADDRESS`. Watch-only wallets are unaffected. Drivers declare this with the
|
|
158
|
+
optional `ChainDriver.signingSchemes(wallet)`.
|
|
159
|
+
- **Breaking:** EVM and Tron: a token whose contract answers `deprecated()` with `true`
|
|
160
|
+
(Tether's `TetherToken`, USDT on Ethereum and Tron) is refused before signing with
|
|
161
|
+
`ASSET_RESOLUTION`, rather than sent through a contract that forwards it and logs no
|
|
162
|
+
`Transfer`. Every token estimate makes one more read.
|
|
163
|
+
- **Breaking:** EVM: the `maxGasLimit` option (`chains.<id>.options`, a handle's `options`,
|
|
164
|
+
or a network's `params.maxGasLimit`) bounds the gas limit of every transfer, replacement
|
|
165
|
+
and cancel, by default 2^24 (`DEFAULT_MAX_GAS_LIMIT`, Ethereum's EIP-7825 cap). An
|
|
166
|
+
estimate (with its headroom) or an override above it fails with `INVALID_INTENT` before
|
|
167
|
+
signing (`details.required`, `details.maxGasLimit`).
|
|
168
|
+
- EVM: on OP Stack chains since Isthmus, the operator fee (`GasPriceOracle.getOperatorFee`
|
|
169
|
+
for the gas limit) is its own `operator` charge and `details.operatorFee`, counted in
|
|
170
|
+
`details.expected` and the funds check.
|
|
171
|
+
- **Breaking:** the Bitcoin scanner reads each block's own bytes (`/block/:hash/raw`) and
|
|
172
|
+
delivers only transactions its header commits to: the merkle root (refusing the
|
|
173
|
+
CVE-2012-2459 duplicate), a coinbase first, and the BIP141 witness commitment; the header
|
|
174
|
+
read at the height must match those bytes. A scanned transaction's `from`, input values and
|
|
175
|
+
fee come from the previous transactions' bytes, checked against the txids its inputs name.
|
|
176
|
+
A block that does not match is a retryable `PROVIDER_INCONSISTENT` and decides nothing. A
|
|
177
|
+
filtered scan uses the indexer's JSON pages only to find spends from watched addresses,
|
|
178
|
+
checked against the bytes; an unfiltered one reads one previous transaction per distinct
|
|
179
|
+
parent outside the block, so scan with `filter.addresses`. `details.vout[].type` is named
|
|
180
|
+
from the script, as Blockstream electrs names it.
|
|
181
|
+
- The transport's `http` reads a binary answer with `responseType: 'bytes'`, within
|
|
182
|
+
`maxResponseBytes`.
|
|
183
|
+
- A reference PostgreSQL implementation of the four store ports, in
|
|
184
|
+
`examples/postgres-store` (schema, source, README; not part of the package), passes every
|
|
185
|
+
store contract suite and an engine crash-and-recover run against PostgreSQL 16 in CI.
|
|
186
|
+
- `pnpm test:evm-local` proves the EVM write path on a local anvil node, with ethers and
|
|
187
|
+
web3: proven finality, idempotent repeats, concurrent nonces, an ERC-20, replace, cancel,
|
|
188
|
+
crash recovery, funds checks and a reorg. CI runs it on every change.
|
|
189
|
+
- **Breaking:** an idempotency key and a scanner's `cursorKey` must be well-formed text
|
|
190
|
+
without U+0000 (`INVALID_INTENT`, `CONFIG_INVALID`): a database may refuse U+0000, and a
|
|
191
|
+
driver may turn a lone surrogate into U+FFFD, so two keys would become one.
|
|
192
|
+
- The store ports say which clock stamps times (the container's, or a wall clock the
|
|
193
|
+
processes share), and that a store may refuse an attempt id another Operation holds; the
|
|
194
|
+
contract suite no longer reuses one. `createFakeEnv` takes a `clock`, so stores built
|
|
195
|
+
beforehand can share it, and `FaultyOperationStore` passes `purge` through. The memory
|
|
196
|
+
store lists and purges nothing for a negative `limit`, as for 0.
|
|
197
|
+
- `RecoveryReport.unresent`: a `signed` or ambiguous Operation whose wallet no longer
|
|
198
|
+
resolves is now checked on chain and counted `unresent`, where it was counted `failed`
|
|
199
|
+
without its check.
|
|
200
|
+
- **Breaking (types only):** `Blockchain`'s constructor is private (handles come from
|
|
201
|
+
`aio.blockchain()` or `Blockchain.create()`), and its internal `protected` methods are gone
|
|
202
|
+
from the type declarations. `CryptoAio`'s constructor has one signature, `(options?)`.
|
|
203
|
+
|
|
204
|
+
### Deprecated
|
|
205
|
+
|
|
206
|
+
- `library: 'web3'` (and `Library.WEB3`): web3.js is no longer maintained upstream (4.16.0 is
|
|
207
|
+
its last release). It keeps working through 1.x, warns once per process with a
|
|
208
|
+
`DeprecationWarning` (code `CRYPTO_AIO_WEB3`), and is removed in 2.0. Use `ethers`.
|
|
209
|
+
|
|
210
|
+
### Fixed
|
|
211
|
+
|
|
212
|
+
- `evmChainPlugin` registers each `assets` ERC-20 under its EIP-55 checksummed contract,
|
|
213
|
+
whatever case it is given in, so a token's alias, its ref, its transfers and its balances
|
|
214
|
+
share one asset id (a lower-case contract made two assets, and deposits missed the
|
|
215
|
+
alias's). A token of another standard, a malformed contract, or a mixed-case contract with
|
|
216
|
+
a wrong checksum is refused with `CONFIG_INVALID` at registration.
|
|
217
|
+
- `stringifyTagged` encodes a Node.js `Buffer` as bytes, as the memory store keeps it; it was
|
|
218
|
+
written as `{ type: 'Buffer', data }` and read back as a plain object by a durable store.
|
|
219
|
+
- TON: `transfer bounced` and `jetton transfer bounced` no longer rest on the indexer's
|
|
220
|
+
word. The provider's raw records of the wallet transaction and of each delivery, checked
|
|
221
|
+
against their hashes and linked by message hash, must show the bounce; until they do, or
|
|
222
|
+
while the provider's endpoints disagree, the transfer stays undecided (a warning with code
|
|
223
|
+
`BOUNCE_UNPROVEN` when they contradict the indexer). A lone lying indexer can delay a
|
|
224
|
+
verdict, never fail a transfer that landed.
|
|
225
|
+
|
|
10
226
|
## [0.1.0] - 2026-10-01
|
|
11
227
|
|
|
12
228
|
### Added
|
|
13
229
|
|
|
14
|
-
- initial release
|
|
230
|
+
- initial release 🎉🎊.
|
|
15
231
|
|
|
16
|
-
[Unreleased]: https://github.com/vhidvz/crypto-aio/compare/0.1
|
|
232
|
+
[Unreleased]: https://github.com/vhidvz/crypto-aio/compare/1.0.0-rc.1...HEAD
|
|
233
|
+
[1.0.0-rc.1]: https://github.com/vhidvz/crypto-aio/compare/0.2.0...1.0.0-rc.1
|
|
234
|
+
[0.2.0]: https://github.com/vhidvz/crypto-aio/compare/0.1.0...0.2.0
|
|
17
235
|
[0.1.0]: https://github.com/vhidvz/crypto-aio/releases/tag/0.1.0
|
package/README.md
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<a href="https://vhidvz.github.io/crypto-aio/">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/vhidvz/crypto-aio/main/docs/public/crypto-aio-logo-dark.svg">
|
|
5
|
+
<img alt="crypto-aio" src="https://raw.githubusercontent.com/vhidvz/crypto-aio/main/docs/public/crypto-aio-logo.svg" width="420">
|
|
6
|
+
</picture>
|
|
7
|
+
</a>
|
|
8
|
+
</h1>
|
|
9
|
+
|
|
10
|
+
<div align="center">
|
|
2
11
|
|
|
3
12
|
[](https://www.npmjs.com/package/crypto-aio)
|
|
4
13
|
[](https://github.com/vhidvz/crypto-aio/actions/workflows/ci.yml)
|
|
5
14
|

|
|
6
15
|
[](https://htmlpreview.github.io/?https://github.com/vhidvz/crypto-aio/blob/main/coverage/lcov-report/index.html)
|
|
7
16
|
[](LICENSE)
|
|
8
|
-
[](https://vhidvz.github.io/crypto-aio/)
|
|
9
18
|
|
|
10
19
|
**One TypeScript API for moving money on blockchains.** Balances, transfers, confirmations
|
|
11
20
|
and deposit scanning across EVM chains, Bitcoin, Tron, Solana, TON and the Avalanche X-Chain and
|
|
@@ -17,6 +26,8 @@ P-Chain, built for exchanges, wallets and payment systems.
|
|
|
17
26
|
[Examples](https://vhidvz.github.io/crypto-aio/build/examples.html) ·
|
|
18
27
|
[API](https://vhidvz.github.io/crypto-aio/reference/api.html)
|
|
19
28
|
|
|
29
|
+
</div>
|
|
30
|
+
|
|
20
31
|
## Why crypto-aio
|
|
21
32
|
|
|
22
33
|
Every chain has an SDK that can build, sign and send a transaction. None of them is a payment
|
|
@@ -26,11 +37,13 @@ node that says "final" about a block that is later replaced. crypto-aio is the l
|
|
|
26
37
|
those cases, written once, with the same API on every chain:
|
|
27
38
|
|
|
28
39
|
- **Pay exactly once.** Every transfer carries your own idempotency key. Repeat the call after a
|
|
29
|
-
timeout, a crash or a lost reply, and you get the same payment back, never a second one
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
timeout, a crash or a lost reply, and you get the same payment back, never a second one
|
|
41
|
+
(across restarts too, with durable stores).
|
|
42
|
+
- **Crash-safe.** With durable stores, a signed transaction is stored before it is sent. After
|
|
43
|
+
a restart, the library sends those exact bytes again; recovery never signs.
|
|
32
44
|
- **Final means proven.** A transfer is final only on finalized chain data that a quorum of
|
|
33
|
-
independent endpoints agree on, never on one node's word
|
|
45
|
+
independent endpoints agree on, never on one node's word, once you configure two or more
|
|
46
|
+
(three keep proofs going through an outage).
|
|
34
47
|
- **Deposits that survive reorgs.** Durable scanners deliver every block at least once, and roll
|
|
35
48
|
back when the chain reorganizes.
|
|
36
49
|
- **Keys stay with signers.** In memory, or behind your HSM, KMS or MPC custody, with a policy
|
|
@@ -46,10 +59,10 @@ principles, starting with [what a ledger is](https://vhidvz.github.io/crypto-aio
|
|
|
46
59
|
|
|
47
60
|
| Family | Chains | Through |
|
|
48
61
|
| --- | --- | --- |
|
|
49
|
-
| EVM | Ethereum, BNB Smart Chain, Polygon, Avalanche C-Chain, Arbitrum, Optimism, Base, and any EVM chain you add | `ethers` 6 (
|
|
62
|
+
| EVM | Ethereum, BNB Smart Chain, Polygon, Avalanche C-Chain, Arbitrum, Optimism, Base, and any EVM chain you add | `ethers` 6 (or the deprecated `web3` 4) |
|
|
50
63
|
| Bitcoin | mainnet, testnet, testnet4, signet, regtest | `bitcoinjs-lib` 7 and an Esplora indexer |
|
|
51
64
|
| Tron | mainnet, Shasta, Nile | `tronweb` 6 |
|
|
52
|
-
| Solana | mainnet, devnet, testnet | `@solana/web3.js` 1 |
|
|
65
|
+
| Solana | mainnet, devnet, testnet | `@solana/web3.js` 1 or 3 |
|
|
53
66
|
| TON | mainnet, testnet | `@ton/ton` 16 and toncenter |
|
|
54
67
|
| Avalanche X-Chain and P-Chain | mainnet, Fuji | `@avalabs/avalanchejs` 5 and the Avalanche Data API |
|
|
55
68
|
|
|
@@ -58,11 +71,11 @@ What each network supports, family by family, is in
|
|
|
58
71
|
|
|
59
72
|
## Install
|
|
60
73
|
|
|
61
|
-
crypto-aio needs Node.js 22
|
|
74
|
+
crypto-aio needs Node.js 22.12 or later. Install the package, and only the
|
|
62
75
|
SDK of each family you use:
|
|
63
76
|
|
|
64
77
|
```sh
|
|
65
|
-
npm install crypto-aio ethers # EVM chains
|
|
78
|
+
npm install crypto-aio ethers # EVM chains
|
|
66
79
|
npm install crypto-aio bitcoinjs-lib # Bitcoin
|
|
67
80
|
npm install crypto-aio tronweb # Tron
|
|
68
81
|
npm install crypto-aio @solana/web3.js # Solana
|
|
@@ -71,6 +84,9 @@ npm install crypto-aio @avalabs/avalanchejs # Avalanche X-Chain and P-Chain
|
|
|
71
84
|
```
|
|
72
85
|
|
|
73
86
|
A handle whose SDK is missing fails with `DEPENDENCY_MISSING` and names the install command.
|
|
87
|
+
The type declarations need TypeScript 5.3 or later, and each family's entry point
|
|
88
|
+
(`crypto-aio/evm`, …) the types of its SDK; some SDKs' own declarations need TypeScript 5.7
|
|
89
|
+
unless `skipLibCheck` is on. TypeScript 7 is supported.
|
|
74
90
|
|
|
75
91
|
## Your first transfer, with no network and no keys
|
|
76
92
|
|
|
@@ -104,6 +120,7 @@ configure({
|
|
|
104
120
|
},
|
|
105
121
|
signers: { hot: localSigner({ id: 'hot', secp256k1: secret(process.env.HOT_KEY ?? '') }) },
|
|
106
122
|
wallets: { treasury: { signer: 'hot' } },
|
|
123
|
+
// Two providers cross-check every proof; production wants three, so one outage never stalls it.
|
|
107
124
|
chains: { ethereum: { network: 'sepolia', provider: ['alchemy', 'infura'], wallet: 'treasury' } },
|
|
108
125
|
lifecycle: { requireIdempotencyKey: true },
|
|
109
126
|
});
|
|
@@ -115,6 +132,7 @@ console.log((await eth.getBalance(me.canonical)).amount.format()); // e.g. '0.5
|
|
|
115
132
|
const sub = await eth.transfer(
|
|
116
133
|
{ to: '0x3535353535353535353535353535353535353535', amount: '0.01' },
|
|
117
134
|
{ idempotencyKey: 'withdrawal-42' }, // your own id: repeating the call never pays twice
|
|
135
|
+
// (across restarts too, once `stores` are durable)
|
|
118
136
|
);
|
|
119
137
|
const { status } = await sub.wait({ finality: 'final' });
|
|
120
138
|
console.log(status.state, status.evidence); // 'final' 'proven'
|
|
@@ -137,16 +155,24 @@ family.
|
|
|
137
155
|
|
|
138
156
|
## Status
|
|
139
157
|
|
|
140
|
-
crypto-aio
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
158
|
+
crypto-aio 1.0 is in release candidate: **1.0.0-rc.1**, on npm's `next` tag
|
|
159
|
+
(`npm install crypto-aio@next`). From 1.0.0, [semantic
|
|
160
|
+
versioning](https://vhidvz.github.io/crypto-aio/reference/stability.html) covers what that
|
|
161
|
+
page lists: the API, the driver port and what a process stores, but not `crypto-aio/native`
|
|
162
|
+
or message texts. The 0.0.x releases on npm are an older, unrelated API. [Known
|
|
163
|
+
limitations](https://vhidvz.github.io/crypto-aio/reference/limitations.html) lists what it
|
|
164
|
+
does not do yet, and [Upgrade to 1.0](https://vhidvz.github.io/crypto-aio/reference/upgrading.html)
|
|
165
|
+
what changes from 0.2.0 and 0.1.0. Only in-memory stores ship: production needs durable stores of your
|
|
166
|
+
own, proven with the contract suites in `crypto-aio/testing`; [examples/postgres-store](examples/postgres-store)
|
|
167
|
+
is a reference implementation on PostgreSQL. Release notes are in the [changelog](CHANGELOG.md).
|
|
145
168
|
|
|
146
169
|
## Contributing
|
|
147
170
|
|
|
148
171
|
Issues and pull requests are welcome. `pnpm install` and `pnpm check` (lint, typecheck and tests)
|
|
149
|
-
are all a change needs locally
|
|
172
|
+
are all a change needs locally, plus `pnpm api:update` when it changes the public API (CI
|
|
173
|
+
compares the API with the reports in `etc/api/`). `pnpm test:evm-local` also signs, broadcasts
|
|
174
|
+
and proves real EVM transactions on a local anvil node, which it starts and stops; CI runs it
|
|
175
|
+
on every change. The [source map](https://vhidvz.github.io/crypto-aio/explore/source-map.html)
|
|
150
176
|
explains the repository, and [docs/README.md](docs/README.md) how the documentation is built and
|
|
151
177
|
tested.
|
|
152
178
|
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { DriverFactory } from '../../core/driver/types';
|
|
7
7
|
import { type AvalancheSdk, type SdkContext } from './sdk';
|
|
8
|
+
/**
|
|
9
|
+
* What `native(bc, '@avalabs/avalanchejs')` hands out. It mirrors the SDK, so it is outside
|
|
10
|
+
* semver: a new avalanchejs line may change it in a minor release.
|
|
11
|
+
*/
|
|
8
12
|
export interface AvalancheNativeClient {
|
|
9
13
|
/**
|
|
10
14
|
* The `@avalabs/avalanchejs` module. Its type names the members this library uses; cast
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../../src/adapters/avalanche/driver.ts"],"names":[],"mappings":";;;AAMA,mDAAsD;AAEtD,+BAAwE;AACxE,uCAAgF;AAChF,mCAAqC;AACrC,uCAAuE;AACvE,uCAAgF;AAChF,qCAAoD;AACpD,qCAAkF;AAClF,+BAAsE;
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../../src/adapters/avalanche/driver.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * The Avalanche driver factory: validated network config, endpoint probes on both\n * transports, and the ports. Loaded only by the manifest's `load()`, with\n * `@avalabs/avalanchejs`.\n */\nimport type { ChainDriver, DriverContext, DriverFactory } from '../../core/driver/types';\nimport { ConfigError } from '../../core/errors/error';\nimport type { EndpointCall, HealthProbes } from '../../core/transport/types';\nimport { AvalancheNode, DataApi, parseBlock, parseHeight } from './api';\nimport { avalancheBroadcaster, avalancheBuilder, MAX_OUTPUTS } from './builder';\nimport { sdkContext } from './codec';\nimport { LocationCache, READ, type AvalancheContext } from './context';\nimport { avalancheNetworkConfig, type AvalancheNetworkConfig } from './network';\nimport { blockSource, proofSource } from './proofs';\nimport { addressCodec, addressHistory, chainReader, listUnspent } from './reader';\nimport { avalanche, type AvalancheSdk, type SdkContext } from './sdk';\nimport type { AvalancheExt } from './types';\n\n/**\n * What `native(bc, '@avalabs/avalanchejs')` hands out. It mirrors the SDK, so it is outside\n * semver: a new avalanchejs line may change it in a minor release.\n */\nexport interface AvalancheNativeClient {\n /**\n * The `@avalabs/avalanchejs` module. Its type names the members this library uses; cast\n * it to reach the rest of the SDK.\n */\n readonly avalanche: AvalancheSdk;\n /**\n * avalanchejs's `Context` for this network and chain (network id, HRP, AVAX asset id,\n * this chain's id). Its fee fields are zero: read the fees from the chain.\n */\n readonly context: SdkContext;\n /** A JSON-RPC call (e.g. `avm.getTxFee`) to the handle's node endpoints, through the transport. */\n rpc<T = unknown>(method: string, params?: unknown): Promise<T>;\n}\n\nfunction nodeProbes(config: AvalancheNetworkConfig): HealthProbes {\n const prefix = config.vm === 'avm' ? 'avm' : 'platform';\n return {\n identity: async (call: EndpointCall) =>\n parseBlock(\n await call.rpc(`${prefix}.getBlockByHeight`, { height: '0', encoding: 'json' }),\n ).id,\n expectedIdentity: config.genesisBlockId,\n height: async (call: EndpointCall) =>\n parseHeight(\n ((await call.rpc(`${prefix}.getHeight`, {})) as { height?: unknown } | null)\n ?.height,\n ),\n };\n}\n\nfunction indexerProbes(config: AvalancheNetworkConfig): HealthProbes {\n return {\n identity: async (call: EndpointCall) =>\n DataApi.blockZero(\n await call.http({ method: 'GET', path: '/blocks/0', route: '/blocks/:id' }),\n ),\n expectedIdentity: config.genesisBlockId,\n height: async (call: EndpointCall) =>\n DataApi.latestHeight(\n await call.http({\n method: 'GET',\n path: '/blocks',\n query: { pageSize: '1' },\n route: '/blocks',\n }),\n ),\n };\n}\n\nexport const avalancheDriverFactory: DriverFactory = {\n async create(ctx: DriverContext): Promise<ChainDriver> {\n const config = avalancheNetworkConfig(ctx.chain, ctx.network, ctx.options);\n if (!ctx.indexer) {\n throw new ConfigError(\n 'CONFIG_INVALID',\n 'the Avalanche driver requires an indexer provider (the Avalanche Data API)',\n );\n }\n // Probes on both transports, once, before any traffic: without them an endpoint's\n // identity is never checked, and an endpoint of another network is never disabled.\n ctx.transport.setProbes(nodeProbes(config));\n ctx.indexer.setProbes(indexerProbes(config));\n const avax: AvalancheContext = {\n node: new AvalancheNode(ctx.transport, config.vm),\n dataApi: new DataApi(ctx.indexer),\n chain: ctx.chain,\n network: ctx.network,\n config,\n clock: ctx.clock,\n log: ctx.log,\n located: new LocationCache(),\n };\n return {\n ordering: 'inputs',\n capabilities: config.capabilities,\n address: addressCodec(avax),\n reader: chainReader(avax),\n builder: avalancheBuilder(avax),\n broadcaster: avalancheBroadcaster(avax),\n proofs: proofSource(avax),\n blocks: blockSource(avax),\n history: addressHistory(avax),\n ext: {\n avalanche: {\n listUnspent: (address: string) => listUnspent(avax, address),\n },\n } satisfies AvalancheExt,\n limits: () => ({ maxOutputs: MAX_OUTPUTS }),\n createNativeClient: () => {\n const client: AvalancheNativeClient = {\n avalanche,\n context: sdkContext(config),\n rpc: <T>(method: string, params?: unknown) =>\n ctx.transport.rpc<T>(method, params ?? {}, READ),\n };\n return { client };\n },\n };\n },\n};\n"]}
|
|
@@ -11,19 +11,24 @@
|
|
|
11
11
|
export interface SdkSerializable {
|
|
12
12
|
readonly _type: string;
|
|
13
13
|
}
|
|
14
|
+
/** The part of avalanchejs's `Id` this library uses; it mirrors the SDK, outside semver. */
|
|
14
15
|
export interface SdkId {
|
|
15
16
|
toString(): string;
|
|
16
17
|
toBytes(): Uint8Array;
|
|
17
18
|
}
|
|
19
|
+
/** The part of avalanchejs's `Int` this library uses; it mirrors the SDK, outside semver. */
|
|
18
20
|
export interface SdkInt {
|
|
19
21
|
value(): number;
|
|
20
22
|
}
|
|
23
|
+
/** The part of avalanchejs's `BigIntPr` this library uses; it mirrors the SDK, outside semver. */
|
|
21
24
|
export interface SdkBigInt {
|
|
22
25
|
value(): bigint;
|
|
23
26
|
}
|
|
27
|
+
/** The part of avalanchejs's `Address` this library uses; it mirrors the SDK, outside semver. */
|
|
24
28
|
export interface SdkAddress {
|
|
25
29
|
toBytes(): Uint8Array;
|
|
26
30
|
}
|
|
31
|
+
/** The part of avalanchejs's `OutputOwners` this library uses; it mirrors the SDK, outside semver. */
|
|
27
32
|
export interface SdkOutputOwners {
|
|
28
33
|
readonly locktime: SdkBigInt;
|
|
29
34
|
readonly threshold: SdkInt;
|
|
@@ -34,21 +39,25 @@ export interface SdkTransferOutput extends SdkSerializable {
|
|
|
34
39
|
readonly outputOwners: SdkOutputOwners;
|
|
35
40
|
amount(): bigint;
|
|
36
41
|
}
|
|
42
|
+
/** The part of avalanchejs's `TransferableOutput` this library uses; it mirrors the SDK, outside semver. */
|
|
37
43
|
export interface SdkTransferableOutput extends SdkSerializable {
|
|
38
44
|
readonly assetId: SdkId;
|
|
39
45
|
readonly output: SdkSerializable;
|
|
40
46
|
amount(): bigint;
|
|
41
47
|
}
|
|
48
|
+
/** The part of avalanchejs's `UTXOID` this library uses; it mirrors the SDK, outside semver. */
|
|
42
49
|
export interface SdkUtxoId {
|
|
43
50
|
readonly txID: SdkId;
|
|
44
51
|
readonly outputIdx: SdkInt;
|
|
45
52
|
}
|
|
53
|
+
/** The part of avalanchejs's `TransferableInput` this library uses; it mirrors the SDK, outside semver. */
|
|
46
54
|
export interface SdkTransferableInput extends SdkSerializable {
|
|
47
55
|
readonly utxoID: SdkUtxoId;
|
|
48
56
|
readonly assetId: SdkId;
|
|
49
57
|
amount(): bigint;
|
|
50
58
|
sigIndicies(): number[];
|
|
51
59
|
}
|
|
60
|
+
/** The part of avalanchejs's `Utxo` this library uses; it mirrors the SDK, outside semver. */
|
|
52
61
|
export interface SdkUtxo extends SdkSerializable {
|
|
53
62
|
readonly utxoId: SdkUtxoId;
|
|
54
63
|
readonly assetId: SdkId;
|
|
@@ -72,10 +81,12 @@ export interface SdkTransaction extends SdkSerializable {
|
|
|
72
81
|
readonly baseTx?: SdkBaseTx;
|
|
73
82
|
getSigIndices(): number[][];
|
|
74
83
|
}
|
|
84
|
+
/** The part of avalanchejs's `Credential` this library uses; it mirrors the SDK, outside semver. */
|
|
75
85
|
export interface SdkCredential extends SdkSerializable {
|
|
76
86
|
/** Each signature as hex (65 bytes: r, s, recovery id). */
|
|
77
87
|
getSignatures(): string[];
|
|
78
88
|
}
|
|
89
|
+
/** The part of avalanchejs's `SignedTx` this library uses; it mirrors the SDK, outside semver. */
|
|
79
90
|
export interface SdkSignedTx {
|
|
80
91
|
readonly unsignedTx: SdkTransaction;
|
|
81
92
|
getCredentials(): SdkCredential[];
|
|
@@ -86,6 +97,7 @@ export interface SdkUnsignedTx {
|
|
|
86
97
|
getTx(): SdkTransaction;
|
|
87
98
|
toBytes(): Uint8Array;
|
|
88
99
|
}
|
|
100
|
+
/** The part of avalanchejs's `codec Manager` this library uses; it mirrors the SDK, outside semver. */
|
|
89
101
|
export interface SdkManager {
|
|
90
102
|
getDefaultCodec(): unknown;
|
|
91
103
|
unpack<T>(bytes: Uint8Array, unpacker: SdkUnpacker<T>): T;
|
|
@@ -96,6 +108,7 @@ export interface SdkManager {
|
|
|
96
108
|
export interface SdkUnpacker<T> {
|
|
97
109
|
fromBytes(bytes: Uint8Array, codec: unknown): [T, Uint8Array];
|
|
98
110
|
}
|
|
111
|
+
/** The part of avalanchejs's `fee Dimensions` this library uses; it mirrors the SDK, outside semver. */
|
|
99
112
|
export interface SdkDimensions {
|
|
100
113
|
readonly 0: number;
|
|
101
114
|
readonly 1: number;
|
|
@@ -121,12 +134,14 @@ export interface SdkContext {
|
|
|
121
134
|
readonly excessConversionConstant: bigint;
|
|
122
135
|
};
|
|
123
136
|
}
|
|
137
|
+
/** The part of avalanchejs's `FeeState` this library uses; it mirrors the SDK, outside semver. */
|
|
124
138
|
export interface SdkFeeState {
|
|
125
139
|
readonly capacity: bigint;
|
|
126
140
|
readonly excess: bigint;
|
|
127
141
|
readonly price: bigint;
|
|
128
142
|
readonly timestamp: string;
|
|
129
143
|
}
|
|
144
|
+
/** The part of avalanchejs's `Signature` this library uses; it mirrors the SDK, outside semver. */
|
|
130
145
|
export interface SdkSignature extends SdkSerializable {
|
|
131
146
|
toString(): string;
|
|
132
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/adapters/avalanche/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/adapters/avalanche/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA4NH,iEAAiE;AACpD,QAAA,SAAS,GAAG,OAAO,CAAC,sBAAsB,CAAiB,CAAC;AAEzE,2DAA2D;AAC9C,QAAA,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IACjC,cAAc,EAAE,4BAA4B;IAC5C,gBAAgB,EAAE,sBAAsB;IACxC,UAAU,EAAE,wBAAwB;CACrC,CAAC,CAAC","sourcesContent":["/**\n * The one place that loads `@avalabs/avalanchejs`, at run time with `require()` (its 5.x\n * package is an ES module with a CommonJS build). Its type declarations re-export their own\n * modules without file extensions, which TypeScript cannot follow under `node16`\n * resolution, so the part of the SDK this library uses is declared here instead: the codec\n * managers, the transaction builders, the P-Chain fee calculator and the serializable\n * classes the driver reads. The tests run every declared member against the real package.\n * Loaded only through the manifest's `load()`.\n */\n\n/** A serializable avalanchejs object; `_type` names its class (e.g. `avm.BaseTx`). */\nexport interface SdkSerializable {\n readonly _type: string;\n}\n\n/** The part of avalanchejs's `Id` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkId {\n toString(): string;\n toBytes(): Uint8Array;\n}\n\n/** The part of avalanchejs's `Int` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkInt {\n value(): number;\n}\n\n/** The part of avalanchejs's `BigIntPr` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkBigInt {\n value(): bigint;\n}\n\n/** The part of avalanchejs's `Address` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkAddress {\n toBytes(): Uint8Array;\n}\n\n/** The part of avalanchejs's `OutputOwners` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkOutputOwners {\n readonly locktime: SdkBigInt;\n readonly threshold: SdkInt;\n readonly addrs: readonly SdkAddress[];\n}\n\n/** A `secp256k1fx.TransferOutput`. */\nexport interface SdkTransferOutput extends SdkSerializable {\n readonly outputOwners: SdkOutputOwners;\n amount(): bigint;\n}\n\n/** The part of avalanchejs's `TransferableOutput` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkTransferableOutput extends SdkSerializable {\n readonly assetId: SdkId;\n readonly output: SdkSerializable;\n amount(): bigint;\n}\n\n/** The part of avalanchejs's `UTXOID` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkUtxoId {\n readonly txID: SdkId;\n readonly outputIdx: SdkInt;\n}\n\n/** The part of avalanchejs's `TransferableInput` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkTransferableInput extends SdkSerializable {\n readonly utxoID: SdkUtxoId;\n readonly assetId: SdkId;\n amount(): bigint;\n sigIndicies(): number[];\n}\n\n/** The part of avalanchejs's `Utxo` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkUtxo extends SdkSerializable {\n readonly utxoId: SdkUtxoId;\n readonly assetId: SdkId;\n readonly output: SdkSerializable;\n /** Its bytes without the codec version, in `codec`. */\n toBytes(codec: unknown): Uint8Array;\n}\n\n/** The `avax.BaseTx` every X-Chain and most P-Chain transactions carry. */\nexport interface SdkBaseTx {\n readonly NetworkId: SdkInt;\n readonly BlockchainId: SdkId;\n readonly outputs: readonly SdkTransferableOutput[];\n readonly inputs: readonly SdkTransferableInput[];\n readonly memo: { readonly bytes: Uint8Array };\n}\n\n/** An unsigned transaction of any type (`avm.*`, `pvm.*`). */\nexport interface SdkTransaction extends SdkSerializable {\n readonly vm: string;\n readonly baseTx?: SdkBaseTx;\n getSigIndices(): number[][];\n}\n\n/** The part of avalanchejs's `Credential` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkCredential extends SdkSerializable {\n /** Each signature as hex (65 bytes: r, s, recovery id). */\n getSignatures(): string[];\n}\n\n/** The part of avalanchejs's `SignedTx` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkSignedTx {\n readonly unsignedTx: SdkTransaction;\n getCredentials(): SdkCredential[];\n toBytes(): Uint8Array;\n}\n\n/** A builder's result. */\nexport interface SdkUnsignedTx {\n getTx(): SdkTransaction;\n toBytes(): Uint8Array;\n}\n\n/** The part of avalanchejs's `codec Manager` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkManager {\n getDefaultCodec(): unknown;\n unpack<T>(bytes: Uint8Array, unpacker: SdkUnpacker<T>): T;\n unpackTransaction(bytes: Uint8Array): SdkTransaction;\n packCodec(serializable: SdkSerializable): Uint8Array;\n}\n\n/** A class `Manager.unpack` reads (`Utxo`, `avaxSerial.SignedTx`). */\nexport interface SdkUnpacker<T> {\n fromBytes(bytes: Uint8Array, codec: unknown): [T, Uint8Array];\n}\n\n/** The part of avalanchejs's `fee Dimensions` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkDimensions {\n readonly 0: number;\n readonly 1: number;\n readonly 2: number;\n readonly 3: number;\n}\n\n/** avalanchejs's `Context`: what its builders need to know about the network. */\nexport interface SdkContext {\n readonly networkID: number;\n readonly hrp: string;\n readonly xBlockchainID: string;\n readonly pBlockchainID: string;\n readonly cBlockchainID: string;\n readonly avaxAssetID: string;\n readonly baseTxFee: bigint;\n readonly createAssetTxFee: bigint;\n readonly platformFeeConfig: {\n readonly weights: SdkDimensions;\n readonly maxCapacity: bigint;\n readonly maxPerSecond: bigint;\n readonly targetPerSecond: bigint;\n readonly minPrice: bigint;\n readonly excessConversionConstant: bigint;\n };\n}\n\n/** The part of avalanchejs's `FeeState` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkFeeState {\n readonly capacity: bigint;\n readonly excess: bigint;\n readonly price: bigint;\n readonly timestamp: string;\n}\n\n/** The part of avalanchejs's `Signature` this library uses; it mirrors the SDK, outside semver. */\nexport interface SdkSignature extends SdkSerializable {\n toString(): string;\n}\n\n/** The members of `@avalabs/avalanchejs` this library calls. */\nexport interface AvalancheSdk {\n readonly Utxo: SdkUnpacker<SdkUtxo>;\n readonly avaxSerial: {\n readonly SignedTx: SdkUnpacker<SdkSignedTx> &\n (new (tx: SdkTransaction, credentials: SdkSerializable[]) => SdkSignedTx);\n };\n readonly Credential: new (signatures: SdkSignature[]) => SdkCredential;\n readonly Signature: new (bytes: Uint8Array) => SdkSignature;\n readonly TransferableOutput: {\n fromNative(\n assetId: string,\n amount: bigint,\n addresses: readonly Uint8Array[],\n locktime?: bigint,\n threshold?: number,\n ): SdkTransferableOutput;\n };\n readonly Common: {\n createDimensions(dimensions: {\n bandwidth: number;\n dbRead: number;\n dbWrite: number;\n compute: number;\n }): SdkDimensions;\n };\n readonly utils: {\n getManagerForVM(vm: 'AVM' | 'PVM'): SdkManager;\n getBurnedAmountByTx(tx: SdkTransaction, context: SdkContext): Map<string, bigint>;\n };\n readonly avm: {\n newBaseTx(\n context: SdkContext,\n fromAddressesBytes: readonly Uint8Array[],\n utxos: readonly SdkUtxo[],\n outputs: readonly SdkTransferableOutput[],\n options: {\n readonly changeAddresses: readonly Uint8Array[];\n readonly memo: Uint8Array;\n readonly minIssuanceTime: bigint;\n },\n ): SdkUnsignedTx;\n };\n readonly pvm: {\n newBaseTx(\n props: {\n readonly feeState: SdkFeeState;\n readonly fromAddressesBytes: readonly Uint8Array[];\n readonly changeAddressesBytes: readonly Uint8Array[];\n readonly outputs: readonly SdkTransferableOutput[];\n readonly utxos: readonly SdkUtxo[];\n readonly memo: Uint8Array;\n readonly minIssuanceTime: bigint;\n },\n context: SdkContext,\n ): SdkUnsignedTx;\n calculateFee(tx: SdkTransaction, weights: SdkDimensions, price: bigint): bigint;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nexport const avalanche = require('@avalabs/avalanchejs') as AvalancheSdk;\n\n/** The serializable class names the driver tells apart. */\nexport const TYPES = Object.freeze({\n transferOutput: 'secp256k1fx.TransferOutput',\n stakeableLockOut: 'pvm.StakeableLockOut',\n credential: 'secp256k1fx.Credential',\n});\n"]}
|