import { Models, Chain, ChainJsPlugin, Crypto, Interfaces } from '@open-rights-exchange/chain-js'; import { AlgorandAddress, AlgorandChainActionType, AlgorandDecomposeReturn, AlgorandSymbol, AlgorandTxAction, AlgorandUnit } from './models'; import * as algoCrypto from './algoCrypto'; import { toAlgorandPrivateKey, toAlgorandPublicKey, toAlgorandSignature } from './helpers'; import { AlgorandChainEndpoint, AlgorandChainInfo, AlgorandChainSettings } from './models/chainModels'; declare class Plugin implements Chain { private _endpoints; private _chainState; private _plugins; constructor(endpoints: AlgorandChainEndpoint[], settings?: AlgorandChainSettings); /** Connect to chain endpoint to verify that it is operational and to get latest block info */ connect(): Promise; /** Return unique chain ID string */ get chainId(): string; /** Retrieve lastest chain info including head block number and time */ get chainInfo(): AlgorandChainInfo; get endpoints(): AlgorandChainEndpoint[]; /** Returns the supported expiration option metadata */ get transactionExpirationOptions(): Models.TransactionExpirationOptions; get plugins(): ChainJsPlugin[]; /** Fetch data from an on-chain contract table */ fetchContractData: () => any; /** Compose an object for a chain contract action */ composeAction: (actionType: Models.ChainActionType | AlgorandChainActionType, args: any) => Promise; /** Decompose an action and return the action type (if any) and its data */ decomposeAction: (action: AlgorandTxAction) => Promise; /** Returns a chain Account class * Note: Does NOT create a new account - to create an account, use new.CreateAccount */ private newAccount; /** Return a ChainAccount class used to perform any function with the chain account */ private newCreateAccount; /** Return a ChainTransaction class used to compose and send transactions */ private newTransaction; private newSignMessage; new: { /** Returns a new chain Account object * If an account name is provided, it will be fetched from the chain and loaded into the returned account object * Note: Does NOT create a new account - to create an account, use new.CreateAccount */ Account: any; /** Return a new CreateAccount object used to help with creating a new chain account */ CreateAccount: any; /** Return a chain Transaction object used to compose and send transactions */ Transaction: any; /** Return a Signed Message object */ SignMessage: any; }; /** Gets an executed or pending transaction (by transaction hash) * A transaction that has enough fees will appear on the chain and quickly be confirmed * Until the transaction is processed by the chain, this function will throw a TxNotFoundOnChain chain error */ fetchTransaction(transactionId: string): Promise<{ status: Models.TransactionStatus; transaction: any; }>; /** Primary cryptography curve used by this chain */ cryptoCurve: Models.CryptoCurve.Ed25519; /** Decrypts the encrypted value with a password, and using ed25519 algorithm and SHA512 hash function */ decryptWithPassword: typeof algoCrypto.decryptWithPassword; /** Encrypts a string with a password, and using ed25519 algorithm and SHA512 hash function * The returned, encrypted value is a stringified JSON object */ encryptWithPassword: typeof algoCrypto.encryptWithPassword; /** Decrypts the encrypted value using a private key * The encrypted value is either a stringified JSON object or a JSON object * ... and must have been encrypted with the public key that matches the private ley provided */ decryptWithPrivateKey: typeof algoCrypto.decryptWithPrivateKey; /** Encrypts a string using a public key * The encrypted result can be decrypted with the matching private key */ encryptWithPublicKey: typeof algoCrypto.encryptWithPublicKey; /** Unwraps an object produced by encryptWithPublicKeys() - resulting in the original ecrypted string * each pass uses a private keys from privateKeys array param * put the keys in the same order as public keys provided to encryptWithPublicKeys() - they will be applied in the right (reverse) order * The result is the decrypted string */ decryptWithPrivateKeys: typeof algoCrypto.decryptWithPrivateKeys; /** Use assymmetric encryption with multiple public keys - wrapping with each * Returns an array of results with the last one including the final cipertext * Encrypts using publicKeys in the order they appear in the array */ encryptWithPublicKeys: typeof algoCrypto.encryptWithPublicKeys; /** Generates and returns a new public/private key pair */ generateKeyPair: typeof algoCrypto.generateKeyPair; /** Returns a public key given a signature and the original data was signed */ getPublicKeyFromSignature: () => any; /** Verifies that the value is a valid, stringified JSON asymmetric encryption result */ isSymEncryptedDataString: typeof algoCrypto.isSymEncryptedDataString; /** Ensures that the value comforms to a well-formed stringified JSON encryption result */ toSymEncryptedDataString: typeof algoCrypto.toSymEncryptedDataString; /** Verifies that the value is a valid, stringified JSON asymmetric encryption result */ isAsymEncryptedDataString: typeof Crypto.Asymmetric.isAsymEncryptedDataString; /** Ensures that the value comforms to a well-formed stringified JSON encryption result */ toAsymEncryptedDataString: typeof Crypto.Asymmetric.toAsymEncryptedDataString; /** Ensures that the value comforms to a well-formed private Key */ isValidPrivateKey: (value: string) => boolean; /** Ensures that the value comforms to a well-formed public Key */ isValidPublicKey: (value: string) => boolean; /** Generates new key pairs (public and private) * Encrypts private key with provided password * Returns: { privateKey, publicKey, encryptedPrivateKey } */ generateNewAccountKeysWithEncryptedPrivateKeys: typeof algoCrypto.generateNewAccountKeysAndEncryptPrivateKeys; /** Generate a signature given some data and a private key */ sign: typeof algoCrypto.sign; /** Signs data as a message using private key (Algorand does not append additional fields for a message) */ signMessage: typeof algoCrypto.signMessage; /** Whether the chain supports resources */ supportsFee: boolean; /** Whether chain supports ability to get a publicKey from a signature */ supportsGetPublicKeyFromSignature: boolean; /** Whether the chain supports resources */ supportsResources: boolean; /** Whether the chain's signMessage feature supports signing a typed data object (ex: ERC712 data type for Ethereum) */ supportsSignMessageTypedData: boolean; /** Verify that a 'personal message' was signed using the given key (Algorand does not append additional fields for a message) */ verifySignedMessage: typeof algoCrypto.verifySignedMessage; /** Verify that the signed data was signed using the given key (signed with the private key for the provided public key) */ verifySignedWithPublicKey: typeof algoCrypto.verifySignedWithPublicKey; /** Verifies that the value is a valid chain entity name (e.g. an account name) */ isValidEntityName: () => any; /** Verifies that the value is a valid chain date */ isValidDate: () => any; /** Ensures that the value comforms to a well-formed chain entity name (e.g. an account name) */ toEntityName: (value: string) => Models.ChainEntityName; /** Ensures that the value comforms to a well-formed chain date string */ toDate: () => any; /** Ensures that the value comforms to a well-formed public Key */ toPublicKey: typeof toAlgorandPublicKey; /** Ensures that the value comforms to a well-formed private Key */ toPrivateKey: typeof toAlgorandPrivateKey; /** Ensures that the value comforms to a well-formed EOS signature */ toSignature: typeof toAlgorandSignature; /** Returns chain type enum - resolves to chain family as a string e.g. 'eos' */ get chainType(): Models.ChainType; static chainType: Models.ChainType; /** Returns chain plug-in name */ get description(): string; /** Returns chain native token symbol and default token contract address */ get nativeToken(): { defaultUnit: AlgorandUnit; symbol: AlgorandSymbol; tokenAddress: AlgorandAddress; precision: number; }; /** Get the balance for an account from the chain * If symbol = 'algo', returns Algo balance (in units of Algo) * Else returns the asset balance of the account for the provided symbol (asset symbol), if the symbol is valid * Returns a string representation of the value to accomodate large numbers */ fetchBalance(account: AlgorandAddress, symbol: AlgorandSymbol, tokenAddress?: AlgorandAddress): Promise<{ balance: string; }>; /** Whether any info has been retrieved from the chain */ get isConnected(): boolean; /** Map error from chain into a well-known ChainError type */ mapChainError: () => any; /** Confirm that we've connected to the chain - throw if not */ assertIsConnected(): void; /** Install a plugin to this chain connection */ installPlugin(plugin: ChainJsPlugin, options?: Interfaces.ChainJsPluginOptions): Promise; /** rules to check tha plugin is well-formed and supported */ private assertValidPlugin; /** Access to underlying algoSdk * Warning! You use chainjs functions wherever possible and only use this sdk as an escape hatch */ get algoClient(): import("algosdk").Algodv2; /** Access to underlying algoSdk indexer */ get algoClientIndexer(): import("algosdk").Indexer; } export default Plugin;