Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/chains/src/decorators/AVMChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CAIP002Namespace.Algorand | CAIP002Namespace.AVM>) {
super(params);
}
Expand Down Expand Up @@ -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<CAIP002Namespace.Algorand | CAIP002Namespace.AVM> {
return (this.constructor as typeof AVMChain).networkConfiguration;
}
}
63 changes: 63 additions & 0 deletions packages/chains/src/decorators/AbstractChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CAIP002Namespace>} The network configuration associated with the given namespace.
* @public
* @abstract
*/
public abstract networkConfiguration(): NetworkConfiguration<CAIP002Namespace>;

/**
* public methods
*/
Expand All @@ -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;
}
}