import { AbstractTransactionSigner } from '../../../../core/AbstractTransactionSigner.cjs'; import { JWK } from '../../../../core/interfaces/JWK.cjs'; import { Transaction } from '../../../../core/interfaces/Transaction.cjs'; import '../../../../core/interfaces/TransactionSigner.cjs'; interface IArweaveJS { /** * Create a transaction using the given attributes. * @param attributes The attributes to use to create the transaction. */ createTransaction(attributes: MinimumTxFields): Promise; /** Object containing transaction-related members. */ transactions: { /** * Create a transaction using the given attributes. * @param attributes The attributes to use to create the transaction. */ fromRaw(attributes: MinimumTxFields): ArweaveJSTransaction; /** * Sign the given transaction. * @param transaction The transaction in question. * @param jwk (Optional) The key to use to sign the transaction. * @param signatureOptions (Optional) Options to consider when signing the transaction. */ sign(transaction: ArweaveJSTransaction, jwk?: JWK, signatureOptions?: { saltLength?: number; }): Promise | void; /** * Verify the signature data of the given transaction. * @param transaction The transaction in question. */ verify(transaction: Transaction): Promise; }; } type MinimumTxFields = Omit; /** * Typing to match the arweave-js library's transaction, but only requiring the * minimum members. */ type ArweaveJSTransaction = Transaction & { /** * Convert this transaction to JSON. */ toJSON(): Transaction; /** * Add a tag to this transaction. * @param name The tag's name. * @param value The tag's value. */ addTag(name: string, value: string): void; }; /** * Options to consider when instantiating {@linkcode ArweaveJSSigner}. */ type Options = { /** * An interface matching the `Arweave` instance from the arweave-js library. * @link https://github.com/ArweaveTeam/arweave-js */ arweave: IArweaveJS; }; type SignMethodOptions = { key?: JWK; }; /** * Create a signer that uses arweave-js under the hood. * * @param options See {@linkcode Options} * * @example * ``` * import Arweave from "arweave"; * import { ArweaveJSSigner } from "@smartweaver/slick-transaction/standard/transactions/format-2/signers/ArweaveJSSigner"; * import { Transaction } from "@smartweaver/slick-transaction/standard/transactions/format-2/Transaction"; * import MyJWK from "./path/to/jwk.ts"; * * // Get the arweave-js instance * const arweave = Arweave.init({ * host: "arweave.net", * port: 443, * protocol: "https" * }); * * // Create this signer * const signer = new ArweaveJSSigner({ arweave }) * * // Create a transaction * const tx = Transaction * .builder() * .target("paxvhrSttpNtfCggtmOlmEOeECJDfJCSZVRHWLoYwCs") * .quantity("1") * .tags({ * "Test-1": "Value 1", * "Test-2": "Value 2", * }) * .build(); * * // Sign the transaction with this signer * const txSigned = await signer.sign(tx, { key: MyJWK }); * * // Verify the transaction's signature data * await signer.verify(txSigned) // => true * * // - end of example - * ``` */ declare class ArweaveJSSigner extends AbstractTransactionSigner { #private; protected options: Options; constructor(options: Options); sign(inputTx: Tx, options?: SignMethodOptions): Promise; verify(inputTx: Tx): Promise; } export { ArweaveJSSigner };