diff --git a/packages/chains/src/decorators/AVMChain.ts b/packages/chains/src/decorators/AVMChain.ts index 8e59f70..0429c6e 100644 --- a/packages/chains/src/decorators/AVMChain.ts +++ b/packages/chains/src/decorators/AVMChain.ts @@ -14,9 +14,16 @@ import type { AVMNode, AVMNodeCollection, AVMTransactionParamsResponse, + NetworkConfiguration, } from '@/types'; export default class AVMChain extends AbstractChain { + /** + * public static variables + */ + + public static readonly namespace: CAIP002Namespace.Algorand | CAIP002Namespace.AVM; + protected constructor(params: ChainParameters) { super(params); } @@ -78,4 +85,16 @@ export default class AVMChain extends AbstractChain { urlSafe: true, }); } + + /** + * public methods + */ + + public namespace(): CAIP002Namespace.Algorand | CAIP002Namespace.AVM { + return (this.constructor as typeof AVMChain).namespace; + } + + public networkConfiguration(): NetworkConfiguration { + return (this.constructor as typeof AVMChain).networkConfiguration; + } } diff --git a/packages/chains/src/decorators/AbstractChain.ts b/packages/chains/src/decorators/AbstractChain.ts index 7d1733f..f606be8 100644 --- a/packages/chains/src/decorators/AbstractChain.ts +++ b/packages/chains/src/decorators/AbstractChain.ts @@ -81,6 +81,29 @@ export default abstract class AbstractChain { this.reference = reference; } + /** + * public abstract methods + */ + + /** + * Retrieves the CAIP-002 namespace associated with the current implementation. + * + * @return {CAIP002Namespace} An instance representing the CAIP-002 namespace. + * @public + * @abstract + */ + public abstract namespace(): CAIP002Namespace; + + /** + * Abstract method to retrieve the network configuration for the specified CAIP-002 namespace. + * This method must be implemented to define how network configurations are fetched, created or managed. + * + * @return {NetworkConfiguration} The network configuration associated with the given namespace. + * @public + * @abstract + */ + public abstract networkConfiguration(): NetworkConfiguration; + /** * public methods */ @@ -95,4 +118,44 @@ export default abstract class AbstractChain { public chainID(): string { return (this.constructor as typeof AbstractChain).namespace + ':' + this.reference; } + + /** + * Retrieves the display name of the chain. + * + * @return {string} The display name of the chain. + * @public + */ + public displayName(): string { + return (this.constructor as typeof AbstractChain).displayName; + } + + /** + * Retrieves the URI of the icon associated with the chain. + * + * @return {string} The URI of the chain icon. + * @public + */ + public iconURI(): string { + return (this.constructor as typeof AbstractChain).iconURI; + } + + /** + * Retrieves the native currency associated with the chain. + * + * @return {NativeCurrency} The native currency of the chain as an instance of NativeCurrency. + * @public + */ + public nativeCurrency(): NativeCurrency { + return (this.constructor as typeof AbstractChain).nativeCurrency; + } + + /** + * Determines whether the current instance is operating on a testnet or not. + * + * @return {boolean} Returns true if the instance is associated with a testnet, otherwise false. + * @public + */ + public testnet(): boolean { + return (this.constructor as typeof AbstractChain).testnet; + } }