-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
85 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Chain, defineChain } from 'viem'; | ||
import { ChainAsset } from '../asset'; | ||
|
||
export interface GetViemChainParams { | ||
id: number; | ||
name: string; | ||
nativeAsset: ChainAsset; | ||
rpc: string; | ||
} | ||
|
||
export function getViemChain({ | ||
id, | ||
name, | ||
nativeAsset, | ||
rpc, | ||
}: GetViemChainParams): Chain { | ||
return defineChain({ | ||
id, | ||
name, | ||
nativeCurrency: { | ||
decimals: nativeAsset.decimals, | ||
name: nativeAsset.originSymbol, | ||
symbol: nativeAsset.originSymbol, | ||
}, | ||
rpcUrls: { | ||
default: { | ||
http: [rpc], | ||
}, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Chain as ViemChain } from 'viem'; | ||
import { Chain, ChainConstructorParams } from './Chain'; | ||
import { getViemChain } from './Chain.utils'; | ||
|
||
export interface EvmChainConstructorParams extends ChainConstructorParams { | ||
id: number; | ||
rpc: string; | ||
} | ||
|
||
export class EvmChain extends Chain { | ||
readonly id: number; | ||
|
||
readonly rpc: string; | ||
|
||
static is(obj: unknown): obj is EvmChain { | ||
return obj instanceof EvmChain; | ||
} | ||
|
||
constructor({ id, rpc, ...others }: EvmChainConstructorParams) { | ||
super(others); | ||
|
||
this.id = id; | ||
this.rpc = rpc; | ||
} | ||
|
||
getViemChain(): ViemChain { | ||
return getViemChain(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './Chain'; | ||
export * from './Chain.interfaces'; | ||
export * from './EvmChain'; | ||
export * from './parachain'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters