File tree Expand file tree Collapse file tree 4 files changed +52
-4
lines changed Expand file tree Collapse file tree 4 files changed +52
-4
lines changed Original file line number Diff line number Diff line change 11CHAIN_A_RPC_URL="http://localhost:8080"
22CHAIN_A_NETWORK_ID="tc"
33CHAIN_A_FAUCET_ADDRESS="tccqym6znlgc48qeelrzccehkcaut7yz39wwq96q3y7"
4+ CHAIN_A_COUNTERPARTY_CLIENT_ID="BClient"
5+ CHAIN_A_COUNTERPARTY_CONNECTION_ID="BConnection"
6+ CHAIN_A_COUNTERPARTY_CHANNEL_ID="BChannel"
47CHAIN_B_RPC_URL="http://localhost:8081"
58CHAIN_B_NETWORK_ID="fc"
69CHAIN_B_FAUCET_ADDRESS="fccqyd6clszl2aeq4agrk8sgq8whkty6ktljuemc9y3"
10+ CHAIN_B_COUNTERPARTY_CLIENT_ID="AClient"
11+ CHAIN_B_COUNTERPARTY_CONNECTION_ID="AConnection"
12+ CHAIN_B_COUNTERPARTY_CHANNEL_ID="AChannel"
Original file line number Diff line number Diff line change @@ -4,28 +4,47 @@ import { H256, PlatformAddress } from "codechain-primitives";
44import { IBC } from "./foundry/transaction" ;
55import { delay } from "./util" ;
66import Debug from "debug" ;
7+ import { ClientState } from "./foundry/types" ;
78
89const debug = Debug ( "common:tx" ) ;
910
11+ export interface CounterpartyIdentifiers {
12+ /**
13+ * Identifier for counter party chain's light client saved in this chain
14+ */
15+ client : string ;
16+ /**
17+ * Identifier for connection with counterparty chain
18+ */
19+ connection : string ;
20+ /**
21+ * Identifier for channel with counterparty chain
22+ */
23+ channel : string ;
24+ }
25+
1026export interface ChainConfig {
1127 /**
1228 * Example: "http://localhost:8080"
1329 */
1430 server : string ;
1531 networkId : string ;
1632 faucetAddress : PlatformAddress ;
33+ counterpartyIdentifiers : CounterpartyIdentifiers ;
1734}
1835
1936export class Chain {
2037 private readonly sdk : SDK ;
2138 private readonly faucetAddress : PlatformAddress ;
39+ private readonly counterpartyIdentifiers : CounterpartyIdentifiers ;
2240
2341 public constructor ( config : ChainConfig ) {
2442 this . sdk = new SDK ( {
2543 server : config . server ,
2644 networkId : config . networkId
2745 } ) ;
2846 this . faucetAddress = config . faucetAddress ;
47+ this . counterpartyIdentifiers = config . counterpartyIdentifiers ;
2948 }
3049
3150 public async submitDatagram ( datagram : Datagram ) : Promise < void > {
Original file line number Diff line number Diff line change @@ -11,19 +11,32 @@ interface FoundryChainConfig {
1111 rpcURL : string ;
1212 networkId : string ;
1313 faucetAddress : string ;
14+ counterpartyClientId : string ;
15+ counterpartyConnectionId : string ;
16+ counterpartyChannelId : string ;
1417}
1518
1619export function getConfig ( ) : Config {
1720 return {
1821 chainA : {
1922 rpcURL : getEnv ( "CHAIN_A_RPC_URL" ) ,
2023 networkId : getEnv ( "CHAIN_A_NETWORK_ID" ) ,
21- faucetAddress : getEnv ( "CHAIN_A_FAUCET_ADDRESS" )
24+ faucetAddress : getEnv ( "CHAIN_A_FAUCET_ADDRESS" ) ,
25+ counterpartyClientId : getEnv ( "CHAIN_A_COUNTERPARTY_CLIENT_ID" ) ,
26+ counterpartyConnectionId : getEnv (
27+ "CHAIN_A_COUNTERPARTY_CONNECTION_ID"
28+ ) ,
29+ counterpartyChannelId : getEnv ( "CHAIN_A_COUNTERPARTY_CHANNEL_ID" )
2230 } ,
2331 chainB : {
2432 rpcURL : getEnv ( "CHAIN_B_RPC_URL" ) ,
2533 networkId : getEnv ( "CHAIN_B_NETWORK_ID" ) ,
26- faucetAddress : getEnv ( "CHAIN_B_FAUCET_ADDRESS" )
34+ faucetAddress : getEnv ( "CHAIN_B_FAUCET_ADDRESS" ) ,
35+ counterpartyClientId : getEnv ( "CHAIN_B_COUNTERPARTY_CLIENT_ID" ) ,
36+ counterpartyConnectionId : getEnv (
37+ "CHAIN_B_COUNTERPARTY_CONNECTION_ID"
38+ ) ,
39+ counterpartyChannelId : getEnv ( "CHAIN_B_COUNTERPARTY_CHANNEL_ID" )
2740 }
2841 } ;
2942}
Original file line number Diff line number Diff line change @@ -14,12 +14,22 @@ async function main() {
1414 const chainA = new Chain ( {
1515 server : config . chainA . rpcURL ,
1616 networkId : config . chainA . networkId ,
17- faucetAddress : PlatformAddress . fromString ( config . chainA . faucetAddress )
17+ faucetAddress : PlatformAddress . fromString ( config . chainA . faucetAddress ) ,
18+ counterpartyIdentifiers : {
19+ client : config . chainA . counterpartyClientId ,
20+ connection : config . chainA . counterpartyConnectionId ,
21+ channel : config . chainA . counterpartyChannelId
22+ }
1823 } ) ;
1924 const chainB = new Chain ( {
2025 server : config . chainB . rpcURL ,
2126 networkId : config . chainB . networkId ,
22- faucetAddress : PlatformAddress . fromString ( config . chainB . faucetAddress )
27+ faucetAddress : PlatformAddress . fromString ( config . chainB . faucetAddress ) ,
28+ counterpartyIdentifiers : {
29+ client : config . chainB . counterpartyClientId ,
30+ connection : config . chainB . counterpartyConnectionId ,
31+ channel : config . chainB . counterpartyChannelId
32+ }
2333 } ) ;
2434
2535 while ( true ) {
You can’t perform that action at this time.
0 commit comments