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
1 change: 1 addition & 0 deletions packages/chains/src/chains/Algorand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class Algorand extends AVMChain {
name: 'Algo',
symbol: 'ALGO',
};
public static readonly shortName = 'algo';
public static readonly transports: Transports<CAIP002Namespace.Algorand> = {
algods: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/AlgorandBetanet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class AlgorandBetanet extends AVMChain {
name: 'Algo',
symbol: 'ALGO',
};
public static readonly shortName = 'algo';
public static readonly transports: Transports<CAIP002Namespace.Algorand> = {
algods: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/AlgorandFNet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class AlgorandFNet extends AVMChain {
name: 'Algo',
symbol: 'ALGO',
};
public static readonly shortName = 'algo';
public static readonly transports: Transports<CAIP002Namespace.Algorand> = {
algods: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/AlgorandTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class AlgorandTestnet extends AVMChain {
name: 'Algo',
symbol: 'ALGO',
};
public static readonly shortName = 'algo';
public static readonly transports: Transports<CAIP002Namespace.Algorand> = {
algods: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/ChiadoTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class ChiadoTestnet extends EVMChain {
name: 'Testnet xDai',
symbol: 'xDAI',
};
public static readonly shortName = 'gno';
public static readonly transports: Transports<CAIP002Namespace.EIP155> = {
https: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/Ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class Ethereum extends EVMChain {
name: 'Ether',
symbol: 'ETH',
};
public static readonly shortName = 'eth';
public static readonly transports: Transports<CAIP002Namespace.EIP155> = {
https: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/EthereumSepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class EthereumSepolia extends EVMChain {
name: 'Ether',
symbol: 'ETH',
};
public static readonly shortName = 'eth';
public static readonly transports: Transports<CAIP002Namespace.EIP155> = {
https: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/GnosisChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class GnosisChain extends EVMChain {
name: 'xDai',
symbol: 'xDAI',
};
public static readonly shortName = 'gno';
public static readonly transports: Transports<CAIP002Namespace.EIP155> = {
https: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/Voi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class Voi extends AVMChain {
name: 'Voi',
symbol: 'VOI',
};
public static readonly shortName = 'voi';
public static readonly transports: Transports<CAIP002Namespace.AVM> = {
algods: {
default: 0,
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/chains/VoiTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class VoiTestnet extends AVMChain {
name: 'Voi',
symbol: 'VOI',
};
public static readonly shortName = 'voi';
public static readonly transports: Transports<CAIP002Namespace.AVM> = {
algods: {
default: 0,
Expand Down
5 changes: 5 additions & 0 deletions packages/chains/src/decorators/AVMChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default class AVMChain extends AbstractChain {
*/

public static readonly namespace: CAIP002Namespace.Algorand | CAIP002Namespace.AVM;
public static readonly shortName: string;
public static readonly transports: Transports<CAIP002Namespace.Algorand>;

protected constructor(params: ChainParameters<CAIP002Namespace.Algorand | CAIP002Namespace.AVM>) {
Expand Down Expand Up @@ -98,6 +99,10 @@ export default class AVMChain extends AbstractChain {
return (this.constructor as typeof AVMChain).namespace;
}

public shortName(): string {
return (this.constructor as typeof AVMChain).shortName;
}

public transports(): Transports<CAIP002Namespace.Algorand> {
return (this.constructor as typeof AVMChain).transports;
}
Expand Down
15 changes: 15 additions & 0 deletions packages/chains/src/decorators/AbstractChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export default abstract class AbstractChain {
* @readonly
*/
public static readonly namespace: CAIP002Namespace;
/**
* The chain's short name, as per [ERC-3770]{@link https://eips.ethereum.org/EIPS/eip-3770}.
* @static
* @readonly
*/
public static readonly shortName: string;
/**
* Details relating to the native currency of the chain.
* @static
Expand Down Expand Up @@ -97,6 +103,15 @@ export default abstract class AbstractChain {
*/
public abstract namespace(): CAIP002Namespace;

/**
* Gets the chain's short name, as per [ERC-3770]{@link https://eips.ethereum.org/EIPS/eip-3770}.
*
* @return {string} The chain's short name, as per [ERC-3770]{@link https://eips.ethereum.org/EIPS/eip-3770}.
* @public
* @abstract
*/
public abstract shortName(): string;

/**
* Gets the transport configuration to communicate with the chain for the specified
* [CAIP-002]{@link https://chainagnostic.org/CAIPs/caip-2} namespace.
Expand Down
5 changes: 5 additions & 0 deletions packages/chains/src/decorators/EVMChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class EVMChain extends AbstractChain {
*/

public static readonly namespace: CAIP002Namespace.EIP155;
public static readonly shortName: string;
public static readonly transports: Transports<CAIP002Namespace.EIP155>;

protected constructor(params: ChainParameters<CAIP002Namespace.EIP155>) {
Expand Down Expand Up @@ -71,6 +72,10 @@ export default class EVMChain extends AbstractChain {
return (this.constructor as typeof EVMChain).namespace;
}

public shortName(): string {
return (this.constructor as typeof EVMChain).shortName;
}

public transports(): Transports<CAIP002Namespace.EIP155> {
return (this.constructor as typeof EVMChain).transports;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/chains/src/types/chains/Chain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// decorators
import { AVMChain } from '@/decorators';
import { AVMChain, EVMChain } from '@/decorators';

type Chain = AVMChain;
type Chain = AVMChain | EVMChain;

export default Chain;
4 changes: 2 additions & 2 deletions packages/chains/src/types/chains/ChainConstructor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// decorators
import { AVMChain } from '@/decorators';
import { AVMChain, EVMChain } from '@/decorators';

type ChainConstructor = typeof AVMChain;
type ChainConstructor = typeof AVMChain | typeof EVMChain;

export default ChainConstructor;
4 changes: 2 additions & 2 deletions packages/chains/src/types/chains/NetworkInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { CAIP002Namespace } from '@/enums';
// types
import { AVMNetworkInformation, EVMNetworkInformation } from '@/types';

type NetworkInfomration<Namespace = CAIP002Namespace> = Namespace extends CAIP002Namespace.Algorand
type NetworkInformation<Namespace = CAIP002Namespace> = Namespace extends CAIP002Namespace.Algorand
? AVMNetworkInformation
: Namespace extends CAIP002Namespace.AVM
? AVMNetworkInformation
: Namespace extends CAIP002Namespace.EIP155
? EVMNetworkInformation
: never;

export default NetworkInfomration;
export default NetworkInformation;