@ar.io/sdk 3.24.0 → 4.0.0-alpha.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/README.md +682 -600
- package/lib/esm/cli/cli.js +188 -152
- package/lib/esm/cli/commands/antCommands.js +23 -58
- package/lib/esm/cli/commands/arnsPurchaseCommands.js +48 -30
- package/lib/esm/cli/commands/escrowCommands.js +221 -0
- package/lib/esm/cli/commands/gatewayWriteCommands.js +142 -23
- package/lib/esm/cli/commands/pruneCommands.js +150 -0
- package/lib/esm/cli/commands/readCommands.js +22 -3
- package/lib/esm/cli/commands/transfer.js +6 -6
- package/lib/esm/cli/options.js +124 -58
- package/lib/esm/cli/utils.js +280 -174
- package/lib/esm/common/ant-registry.js +17 -143
- package/lib/esm/common/ant.js +44 -1167
- package/lib/esm/common/faucet.js +11 -6
- package/lib/esm/common/index.js +0 -4
- package/lib/esm/common/io.js +25 -1412
- package/lib/esm/constants.js +13 -19
- package/lib/esm/solana/ant-readable.js +724 -0
- package/lib/esm/solana/ant-registry-readable.js +133 -0
- package/lib/esm/solana/ant-registry-writeable.js +472 -0
- package/lib/esm/solana/ant-writeable.js +384 -0
- package/lib/esm/solana/ata.js +70 -0
- package/lib/esm/solana/canonical-message.js +128 -0
- package/lib/esm/solana/clusters.js +111 -0
- package/lib/esm/solana/constants.js +146 -0
- package/lib/esm/solana/delegation-math.js +112 -0
- package/lib/esm/solana/deserialize.js +711 -0
- package/lib/esm/solana/escrow.js +839 -0
- package/lib/{cjs/utils/json.js → esm/solana/events.js} +15 -10
- package/lib/esm/solana/funding-plan.js +699 -0
- package/lib/esm/solana/index.js +126 -0
- package/lib/esm/solana/instruction.js +39 -0
- package/lib/esm/solana/io-readable.js +2182 -0
- package/lib/esm/solana/io-writeable.js +3196 -0
- package/lib/esm/solana/json-rpc.js +90 -0
- package/lib/esm/solana/metadata.js +81 -0
- package/lib/esm/solana/mpl-core.js +192 -0
- package/lib/esm/solana/pda.js +332 -0
- package/lib/esm/solana/predict-prescribed-observers.js +110 -0
- package/lib/esm/solana/retry.js +117 -0
- package/lib/esm/solana/rpc-circuit-breaker.js +258 -0
- package/lib/esm/solana/send.js +372 -0
- package/lib/esm/solana/spawn-ant.js +224 -0
- package/lib/esm/solana/types.js +1 -0
- package/lib/esm/types/ant.js +27 -15
- package/lib/esm/types/io.js +8 -11
- package/lib/esm/utils/ant.js +0 -63
- package/lib/esm/utils/index.js +0 -3
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +5 -13
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +33 -7
- package/lib/types/cli/commands/escrowCommands.d.ts +68 -0
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +12 -11
- package/lib/types/cli/commands/pruneCommands.d.ts +31 -0
- package/lib/types/cli/commands/readCommands.d.ts +27 -22
- package/lib/types/cli/commands/transfer.d.ts +9 -9
- package/lib/types/cli/options.d.ts +76 -21
- package/lib/types/cli/types.d.ts +11 -13
- package/lib/types/cli/utils.d.ts +71 -31
- package/lib/types/common/ant-registry.d.ts +49 -47
- package/lib/types/common/ant.d.ts +54 -539
- package/lib/types/common/faucet.d.ts +20 -8
- package/lib/types/common/index.d.ts +0 -3
- package/lib/types/common/io.d.ts +51 -263
- package/lib/types/constants.d.ts +11 -18
- package/lib/types/solana/ant-readable.d.ts +180 -0
- package/lib/types/solana/ant-registry-readable.d.ts +105 -0
- package/lib/types/solana/ant-registry-writeable.d.ts +249 -0
- package/lib/types/solana/ant-writeable.d.ts +177 -0
- package/lib/types/solana/ata.d.ts +44 -0
- package/lib/types/solana/canonical-message.d.ts +121 -0
- package/lib/types/solana/clusters.d.ts +109 -0
- package/lib/types/solana/constants.d.ts +119 -0
- package/lib/types/solana/delegation-math.d.ts +45 -0
- package/lib/types/solana/deserialize.d.ts +262 -0
- package/lib/types/solana/escrow.d.ts +480 -0
- package/lib/types/solana/events.d.ts +38 -0
- package/lib/types/solana/funding-plan.d.ts +225 -0
- package/lib/types/solana/index.d.ts +87 -0
- package/lib/types/solana/instruction.d.ts +39 -0
- package/lib/types/solana/io-readable.d.ts +499 -0
- package/lib/types/solana/io-writeable.d.ts +893 -0
- package/lib/types/solana/json-rpc.d.ts +47 -0
- package/lib/types/solana/metadata.d.ts +84 -0
- package/lib/types/solana/mpl-core.d.ts +120 -0
- package/lib/types/solana/pda.d.ts +95 -0
- package/lib/types/solana/predict-prescribed-observers.d.ts +28 -0
- package/lib/types/solana/retry.d.ts +62 -0
- package/lib/types/solana/rpc-circuit-breaker.d.ts +78 -0
- package/lib/types/solana/send.d.ts +94 -0
- package/lib/types/solana/spawn-ant.d.ts +145 -0
- package/lib/types/solana/types.d.ts +82 -0
- package/lib/types/types/ant-registry.d.ts +43 -4
- package/lib/types/types/ant.d.ts +114 -96
- package/lib/types/types/common.d.ts +18 -74
- package/lib/types/types/faucet.d.ts +2 -2
- package/lib/types/types/io.d.ts +244 -158
- package/lib/types/types/token.d.ts +0 -12
- package/lib/types/utils/ant.d.ts +1 -12
- package/lib/types/utils/index.d.ts +0 -3
- package/lib/types/version.d.ts +1 -1
- package/package.json +36 -33
- package/lib/cjs/cli/cli.js +0 -822
- package/lib/cjs/cli/commands/antCommands.js +0 -113
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +0 -212
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +0 -210
- package/lib/cjs/cli/commands/readCommands.js +0 -215
- package/lib/cjs/cli/commands/transfer.js +0 -159
- package/lib/cjs/cli/options.js +0 -470
- package/lib/cjs/cli/types.js +0 -2
- package/lib/cjs/cli/utils.js +0 -639
- package/lib/cjs/common/ant-registry.js +0 -155
- package/lib/cjs/common/ant-versions.js +0 -93
- package/lib/cjs/common/ant.js +0 -1182
- package/lib/cjs/common/arweave.js +0 -27
- package/lib/cjs/common/contracts/ao-process.js +0 -224
- package/lib/cjs/common/error.js +0 -64
- package/lib/cjs/common/faucet.js +0 -150
- package/lib/cjs/common/hyperbeam/hb.js +0 -173
- package/lib/cjs/common/index.js +0 -42
- package/lib/cjs/common/io.js +0 -1423
- package/lib/cjs/common/logger.js +0 -83
- package/lib/cjs/common/loggers/winston.js +0 -68
- package/lib/cjs/common/marketplace.js +0 -731
- package/lib/cjs/common/turbo.js +0 -223
- package/lib/cjs/constants.js +0 -41
- package/lib/cjs/node/index.js +0 -39
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/types/ant-registry.js +0 -2
- package/lib/cjs/types/ant.js +0 -168
- package/lib/cjs/types/common.js +0 -2
- package/lib/cjs/types/faucet.js +0 -2
- package/lib/cjs/types/index.js +0 -37
- package/lib/cjs/types/io.js +0 -51
- package/lib/cjs/types/token.js +0 -116
- package/lib/cjs/utils/ant.js +0 -108
- package/lib/cjs/utils/ao.js +0 -432
- package/lib/cjs/utils/arweave.js +0 -285
- package/lib/cjs/utils/base64.js +0 -62
- package/lib/cjs/utils/hash.js +0 -56
- package/lib/cjs/utils/index.js +0 -38
- package/lib/cjs/utils/processes.js +0 -173
- package/lib/cjs/utils/random.js +0 -30
- package/lib/cjs/utils/schema.js +0 -15
- package/lib/cjs/utils/url.js +0 -37
- package/lib/cjs/version.js +0 -20
- package/lib/cjs/web/index.js +0 -41
- package/lib/esm/common/ant-versions.js +0 -87
- package/lib/esm/common/arweave.js +0 -21
- package/lib/esm/common/contracts/ao-process.js +0 -220
- package/lib/esm/common/hyperbeam/hb.js +0 -169
- package/lib/esm/common/marketplace.js +0 -724
- package/lib/esm/common/turbo.js +0 -215
- package/lib/esm/node/index.js +0 -20
- package/lib/esm/utils/ao.js +0 -420
- package/lib/esm/utils/arweave.js +0 -271
- package/lib/esm/utils/processes.js +0 -167
- package/lib/esm/web/index.js +0 -20
- package/lib/types/common/ant-versions.d.ts +0 -39
- package/lib/types/common/arweave.d.ts +0 -17
- package/lib/types/common/contracts/ao-process.d.ts +0 -47
- package/lib/types/common/hyperbeam/hb.d.ts +0 -88
- package/lib/types/common/marketplace.d.ts +0 -568
- package/lib/types/common/turbo.d.ts +0 -61
- package/lib/types/node/index.d.ts +0 -20
- package/lib/types/utils/ao.d.ts +0 -80
- package/lib/types/utils/arweave.d.ts +0 -79
- package/lib/types/utils/processes.d.ts +0 -39
- package/lib/types/web/index.d.ts +0 -20
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Solana backend for the AR.IO SDK.
|
|
18
|
+
*
|
|
19
|
+
* This module provides Solana-native implementations of the AR.IO read/write
|
|
20
|
+
* interfaces, allowing consumers to interact with AR.IO protocol state
|
|
21
|
+
* stored on Solana instead of AO. All primitives come from `@solana/kit` —
|
|
22
|
+
* `@solana/web3.js` is not used.
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* ```ts
|
|
26
|
+
* import {
|
|
27
|
+
* createSolanaRpc,
|
|
28
|
+
* createSolanaRpcSubscriptions,
|
|
29
|
+
* generateKeyPairSigner,
|
|
30
|
+
* } from '@solana/kit';
|
|
31
|
+
* import {
|
|
32
|
+
* SolanaARIOReadable,
|
|
33
|
+
* SolanaARIOWriteable,
|
|
34
|
+
* SolanaANTReadable,
|
|
35
|
+
* } from '@ar.io/sdk/solana';
|
|
36
|
+
*
|
|
37
|
+
* const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
38
|
+
*
|
|
39
|
+
* // Read-only (RPC only)
|
|
40
|
+
* const ario = new SolanaARIOReadable({ rpc });
|
|
41
|
+
*
|
|
42
|
+
* // Read-write (signer + subscriptions client needed for confirmation)
|
|
43
|
+
* const rpcSubscriptions = createSolanaRpcSubscriptions(
|
|
44
|
+
* 'wss://api.mainnet-beta.solana.com',
|
|
45
|
+
* );
|
|
46
|
+
* const signer = await generateKeyPairSigner();
|
|
47
|
+
* const arioWrite = new SolanaARIOWriteable({ rpc, rpcSubscriptions, signer });
|
|
48
|
+
*
|
|
49
|
+
* // ANT (Arweave Name Token)
|
|
50
|
+
* const ant = new SolanaANTReadable({
|
|
51
|
+
* rpc,
|
|
52
|
+
* processId: 'MetaplexCoreAssetAddress...',
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
// Public factory classes — `ARIO.init({ rpc })` / `ANT.init({ ... })` /
|
|
57
|
+
// `ANTRegistry.init({ ... })` are the primary entry points for consumers.
|
|
58
|
+
// `createFaucet` wraps an ARIO instance with the HTTP faucet client.
|
|
59
|
+
export * from '../common/index.js';
|
|
60
|
+
// Public types (interfaces, params, pagination, etc.) shared by the SDK
|
|
61
|
+
// surface and the Solana implementation.
|
|
62
|
+
export * from '../types/index.js';
|
|
63
|
+
// Public utility helpers (base64, json, schema validators, ANT helpers).
|
|
64
|
+
export * from '../utils/index.js';
|
|
65
|
+
// Top-level protocol constants. Explicit named exports to avoid colliding
|
|
66
|
+
// with `./spawn-ant.js`'s `ARIO_LOGO_TX_ID` (different value used by the
|
|
67
|
+
// Solana metadata builder — kept distinct on purpose).
|
|
68
|
+
export { ARWEAVE_TX_REGEX, AR_IO_PROTOCOL, arweaveUri, FQDN_REGEX, MARIO_PER_ARIO, } from '../constants.js';
|
|
69
|
+
// Solana implementation classes (still exported for advanced/direct usage —
|
|
70
|
+
// the `ARIO` / `ANT` factories above wrap these).
|
|
71
|
+
export { SolanaARIOReadable } from './io-readable.js';
|
|
72
|
+
export { isInvalidGatewayAccountError, SolanaARIOWriteable, } from './io-writeable.js';
|
|
73
|
+
// ANT classes
|
|
74
|
+
export { SolanaANTReadable } from './ant-readable.js';
|
|
75
|
+
export { SolanaANTWriteable } from './ant-writeable.js';
|
|
76
|
+
// ANT Registry (on-chain paginated ACL — ADR-012). Read-only fetch of
|
|
77
|
+
// `AclConfig` + `AclPage`s for `accessControlList`; the writeable variant
|
|
78
|
+
// also owns the per-instruction builders, the preflight resolvers used
|
|
79
|
+
// by the contract-required ACL accounts on `add_controller` /
|
|
80
|
+
// `remove_controller` / `transfer`, and the spawn / ex-controller
|
|
81
|
+
// workflow helpers (`bootstrapOwnerOnSpawn`,
|
|
82
|
+
// `bulkRemoveControllerEntries`).
|
|
83
|
+
export { SolanaANTRegistryReadable } from './ant-registry-readable.js';
|
|
84
|
+
export { SolanaANTRegistryWriteable } from './ant-registry-writeable.js';
|
|
85
|
+
// ANT-escrow client (trustless multi-protocol custody — Arweave RSA-PSS / Ethereum ECDSA)
|
|
86
|
+
export { ANTEscrow, TokenEscrow,
|
|
87
|
+
// Vault-claim pre-flight helpers (ADR-022 / VaultStillLocked).
|
|
88
|
+
// Exported so downstream UIs can gate their Submit buttons using the
|
|
89
|
+
// SAME forward CLOCK_SKEW_TOLERANCE_SECONDS buffer the SDK's
|
|
90
|
+
// assertVaultClaimable throws use — keeping pre-flight and UI gates
|
|
91
|
+
// in lock-step so users never see a raw on-chain error.
|
|
92
|
+
assertVaultClaimable, isVaultClaimable, CLOCK_SKEW_TOLERANCE_SECONDS, } from './escrow.js';
|
|
93
|
+
// Canonical claim-message helper (byte-equivalent to Rust impl)
|
|
94
|
+
export { canonicalMessage, canonicalMessageV2, deriveRecipientId, bytesToHexLower, } from './canonical-message.js';
|
|
95
|
+
// ANT spawn (mint MPL Core asset + initialize ario-ant state in one tx)
|
|
96
|
+
export { spawnSolanaANT, ARIO_LOGO_TX_ID, DEFAULT_ANT_TRANSACTION_ID, } from './spawn-ant.js';
|
|
97
|
+
// PDA derivation
|
|
98
|
+
export { hashName, getArioConfigPDA, getBalancePDA, getVaultPDA, getVaultCounterPDA, getPrimaryNamePDA, getPrimaryNameRequestPDA, getGatewayRegistryPDA, getGarSettingsPDA, getGatewayPDA, getDelegationPDA, getWithdrawalPDA, getWithdrawalCounterPDA, getAllowlistPDA, getEpochPDA, getEpochSettingsPDA, getObservationPDA, getArnsRegistryPDA, getArnsSettingsPDA, getArnsRecordPDA, getArnsRecordPDAFromHash, getReservedNamePDA, getReturnedNamePDA, getDemandFactorPDA, getPrimaryNameReversePDA, getRedelegationRecordPDA, getAntConfigPDA, getAntControllersPDA, getAntRecordPDA, getAclConfigPDA, getAclPagePDA, getEscrowAntPDA, getEscrowTokenPDA, getEscrowVaultPDA, } from './pda.js';
|
|
99
|
+
// Deserialization adapters
|
|
100
|
+
//
|
|
101
|
+
// Thin wrappers over Codama-generated decoders from `@ar.io/solana-contracts`.
|
|
102
|
+
// They accept raw `Buffer` data and return plain-object types (string/number)
|
|
103
|
+
// instead of Codama's `Address`/`bigint` types, so SDK consumers don't need
|
|
104
|
+
// to import the contracts package directly.
|
|
105
|
+
// Account discriminators come from `@ar.io/solana-contracts/<program>`.
|
|
106
|
+
export { BorshReader, BorshWriter, deserializeGateway, deserializeArnsRecord, deserializeVault, deserializeDelegation, deserializeBalance, deserializeEpochSettings, deserializeArioConfig, deserializeDemandFactor, deserializeReservedName, deserializeReturnedName, deserializeWithdrawal, deserializeRedelegationRecord, deserializePrimaryNameRequest, deserializePrimaryName, deserializeAllowlist, deserializeGarSettings, deserializeEpochSettingsFull, deserializeEpoch, deserializeObservation, deserializeAntConfig, deserializeAntControllers, deserializeAntRecord, deserializeAclConfig, deserializeAclPage, } from './deserialize.js';
|
|
107
|
+
// Off-chain prediction of prescribe_epoch's observer selection (cranker helper)
|
|
108
|
+
export { predictPrescribedObservers, } from './predict-prescribed-observers.js';
|
|
109
|
+
// Constants
|
|
110
|
+
export * from './constants.js';
|
|
111
|
+
// Cluster-specific deployment constants (devnet program IDs, RPC URL,
|
|
112
|
+
// mint). PDAs derive from these via the codama `find*Pda` helpers; token
|
|
113
|
+
// accounts are read on-chain — neither is stored here.
|
|
114
|
+
export * from './clusters.js';
|
|
115
|
+
// RPC circuit breaker (opossum-backed transparent fallback)
|
|
116
|
+
export { createCircuitBreakerRpc, defaultFallbackUrl, } from './rpc-circuit-breaker.js';
|
|
117
|
+
// Retry utility (exponential back-off for transient RPC errors)
|
|
118
|
+
export { withRetry, isRetryableError } from './retry.js';
|
|
119
|
+
// Event decoders
|
|
120
|
+
//
|
|
121
|
+
// `parseTransactionEvents(rpc, signature)` and `parseEventsFromLogs(logs)`
|
|
122
|
+
// give consumers strongly-typed access to every Anchor `#[event]` emit
|
|
123
|
+
// the AR.IO programs produce. Each event variant in `AnyEvent` is
|
|
124
|
+
// tagged by `name` for narrowing; per-program union types
|
|
125
|
+
// (`AnyArio*Event`) are available for filtering.
|
|
126
|
+
export { parseTransactionEvents, parseEventsFromLogs, isEvent, } from './events.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Common Solana program/sysvar addresses used by the SDK.
|
|
18
|
+
*
|
|
19
|
+
* All AR.IO and Metaplex Core instructions are now built via Codama-generated
|
|
20
|
+
* builders under `./generated/<program>/instructions/*`. This module only
|
|
21
|
+
* re-exports the AR.IO program IDs and a few sysvar/system constants that
|
|
22
|
+
* the rest of the SDK still references by name.
|
|
23
|
+
*/
|
|
24
|
+
import { address } from '@solana/kit';
|
|
25
|
+
import { ARIO_ANT_PROGRAM_ID, ARIO_ARNS_PROGRAM_ID, ARIO_CORE_PROGRAM_ID, ARIO_GAR_PROGRAM_ID, } from './constants.js';
|
|
26
|
+
/**
|
|
27
|
+
* System program (11111111111111111111111111111111).
|
|
28
|
+
* Kit-native equivalent of web3.js's `SystemProgram.programId`.
|
|
29
|
+
*/
|
|
30
|
+
export const SYSTEM_PROGRAM_ADDRESS = address('11111111111111111111111111111111');
|
|
31
|
+
/**
|
|
32
|
+
* SPL Token program address.
|
|
33
|
+
*/
|
|
34
|
+
export const TOKEN_PROGRAM_ADDRESS = address('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
|
|
35
|
+
/**
|
|
36
|
+
* Rent sysvar address.
|
|
37
|
+
*/
|
|
38
|
+
export const SYSVAR_RENT_ADDRESS = address('SysvarRent111111111111111111111111111111111');
|
|
39
|
+
export { ARIO_CORE_PROGRAM_ID, ARIO_GAR_PROGRAM_ID, ARIO_ARNS_PROGRAM_ID, ARIO_ANT_PROGRAM_ID, };
|