Skip to content

Commit

Permalink
Add MsgUpdateMetadata and update BridgeInfo/OpchildParams
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed Apr 25, 2024
1 parent b8d68a0 commit f5f590e
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 30 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/initia.js",
"version": "0.1.45",
"version": "0.1.46",
"description": "The JavaScript SDK for Initia",
"license": "MIT",
"author": "InitiaLabs",
Expand Down Expand Up @@ -87,7 +87,7 @@
},
"dependencies": {
"@initia/initia.proto": "^0.1.33",
"@initia/opinit.proto": "^0.0.7",
"@initia/opinit.proto": "^0.0.8",
"@ledgerhq/hw-transport": "^6.27.12",
"@ledgerhq/hw-transport-webhid": "^6.27.12",
"@ledgerhq/hw-transport-webusb": "^6.27.12",
Expand Down
7 changes: 7 additions & 0 deletions src/core/Msg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ import {
MsgUpdateProposer,
MsgUpdateChallenger,
MsgUpdateBatchInfo,
MsgUpdateMetadata,
MsgUpdateOphostParams,
} from './ophost';
import {
Expand Down Expand Up @@ -591,6 +592,8 @@ export namespace Msg {
return MsgUpdateChallenger.fromAmino(data);
case 'ophost/MsgUpdateBatchInfo':
return MsgUpdateBatchInfo.fromAmino(data);
case 'ophost/MsgUpdateMetadata':
return MsgUpdateMetadata.fromAmino(data);
case 'ophost/MsgUpdateParams':
return MsgUpdateOphostParams.fromAmino(data);

Expand Down Expand Up @@ -983,6 +986,8 @@ export namespace Msg {
return MsgUpdateChallenger.fromData(data);
case '/opinit.ophost.v1.MsgUpdateBatchInfo':
return MsgUpdateBatchInfo.fromData(data);
case '/opinit.ophost.v1.MsgUpdateMetadata':
return MsgUpdateMetadata.fromData(data);
case '/opinit.ophost.v1.MsgUpdateParams':
return MsgUpdateOphostParams.fromData(data);

Expand Down Expand Up @@ -1378,6 +1383,8 @@ export namespace Msg {
return MsgUpdateChallenger.unpackAny(proto);
case '/opinit.ophost.v1.MsgUpdateBatchInfo':
return MsgUpdateBatchInfo.unpackAny(proto);
case '/opinit.ophost.v1.MsgUpdateMetadata':
return MsgUpdateMetadata.unpackAny(proto);
case '/opinit.ophost.v1.MsgUpdateParams':
return MsgUpdateOphostParams.unpackAny(proto);

Expand Down
35 changes: 30 additions & 5 deletions src/core/opchild/BridgeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,64 @@ export class BridgeInfo extends JSONSerializable<
/**
* @param bridge_id the unique identifier of the bridge which is assigned from l1
* @param bridge_addr the address of the bridge on l1
* @param l1_chain_id the chain id of the l1 chain
* @param l1_client_id the IBC client ID, which is allocated for l1 chain, in l2 chain state
* @param bridge_config the configuration of the bridge
*/
constructor(
public bridge_id: number,
public bridge_addr: string,
public l1_chain_id: string,
public l1_client_id: string,
public bridge_config: BridgeConfig
) {
super();
}

public static fromAmino(data: BridgeInfo.Amino): BridgeInfo {
const { bridge_id, bridge_addr, bridge_config } = data;
const { bridge_id, bridge_addr, l1_chain_id, l1_client_id, bridge_config } =
data;
return new BridgeInfo(
Number.parseInt(bridge_id),
bridge_addr,
l1_chain_id,
l1_client_id,
BridgeConfig.fromAmino(bridge_config)
);
}

public toAmino(): BridgeInfo.Amino {
const { bridge_id, bridge_addr, bridge_config } = this;
const { bridge_id, bridge_addr, l1_chain_id, l1_client_id, bridge_config } =
this;
return {
bridge_id: bridge_id.toString(),
bridge_addr,
l1_chain_id,
l1_client_id,
bridge_config: bridge_config.toAmino(),
};
}

public static fromData(data: BridgeInfo.Data): BridgeInfo {
const { bridge_id, bridge_addr, bridge_config } = data;
const { bridge_id, bridge_addr, l1_chain_id, l1_client_id, bridge_config } =
data;
return new BridgeInfo(
Number.parseInt(bridge_id),
bridge_addr,
l1_chain_id,
l1_client_id,
BridgeConfig.fromData(bridge_config)
);
}

public toData(): BridgeInfo.Data {
const { bridge_id, bridge_addr, bridge_config } = this;
const { bridge_id, bridge_addr, l1_chain_id, l1_client_id, bridge_config } =
this;
return {
bridge_id: bridge_id.toString(),
bridge_addr,
l1_chain_id,
l1_client_id,
bridge_config: bridge_config.toData(),
};
}
Expand All @@ -61,15 +77,20 @@ export class BridgeInfo extends JSONSerializable<
return new BridgeInfo(
data.bridgeId.toNumber(),
data.bridgeAddr,
data.l1ChainId,
data.l1ClientId,
BridgeConfig.fromProto(data.bridgeConfig as BridgeConfig.Proto)
);
}

public toProto(): BridgeInfo.Proto {
const { bridge_id, bridge_addr, bridge_config } = this;
const { bridge_id, bridge_addr, l1_chain_id, l1_client_id, bridge_config } =
this;
return BridgeInfo_pb.fromPartial({
bridgeId: Long.fromNumber(bridge_id),
bridgeAddr: bridge_addr,
l1ChainId: l1_chain_id,
l1ClientId: l1_client_id,
bridgeConfig: bridge_config.toProto(),
});
}
Expand All @@ -79,12 +100,16 @@ export namespace BridgeInfo {
export interface Amino {
bridge_id: string;
bridge_addr: string;
l1_chain_id: string;
l1_client_id: string;
bridge_config: BridgeConfig.Amino;
}

export interface Data {
bridge_id: string;
bridge_addr: string;
l1_chain_id: string;
l1_client_id: string;
bridge_config: BridgeConfig.Data;
}

Expand Down
15 changes: 0 additions & 15 deletions src/core/opchild/OpchildParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class OpchildParams extends JSONSerializable<
* @param historical_entries the number of historical entries to persist
* @param min_gas_prices
* @param bridge_executor the account address of bridge executor who can execute permissioned bridge messages
* @param host_chain_id the host(l1) chain id
* @param admin the account address of admin who can execute permissioned cosmos messages
* @param fee_whitelist the list of addresses that are allowed to pay zero fee
*/
Expand All @@ -24,7 +23,6 @@ export class OpchildParams extends JSONSerializable<
public historical_entries: number,
min_gas_prices: Coins.Input,
public bridge_executor: AccAddress,
public host_chain_id: string,
public admin: AccAddress,
public fee_whitelist: string[]
) {
Expand All @@ -39,7 +37,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
min_gas_prices,
bridge_executor,
host_chain_id,
admin,
fee_whitelist,
},
Expand All @@ -50,7 +47,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
Coins.fromAmino(min_gas_prices),
bridge_executor,
host_chain_id,
admin,
fee_whitelist
);
Expand All @@ -62,7 +58,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
min_gas_prices,
bridge_executor,
host_chain_id,
admin,
fee_whitelist,
} = this;
Expand All @@ -74,7 +69,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
min_gas_prices: min_gas_prices.toAmino(),
bridge_executor,
host_chain_id,
admin,
fee_whitelist,
},
Expand All @@ -87,7 +81,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
min_gas_prices,
bridge_executor,
host_chain_id,
admin,
fee_whitelist,
} = data;
Expand All @@ -97,7 +90,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
Coins.fromData(min_gas_prices),
bridge_executor,
host_chain_id,
admin,
fee_whitelist
);
Expand All @@ -109,7 +101,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
min_gas_prices,
bridge_executor,
host_chain_id,
admin,
fee_whitelist,
} = this;
Expand All @@ -120,7 +111,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
min_gas_prices: min_gas_prices.toData(),
bridge_executor,
host_chain_id,
admin,
fee_whitelist,
};
Expand All @@ -132,7 +122,6 @@ export class OpchildParams extends JSONSerializable<
data.historicalEntries,
Coins.fromProto(data.minGasPrices),
data.bridgeExecutor,
data.hostChainId,
data.admin,
data.feeWhitelist
);
Expand All @@ -144,7 +133,6 @@ export class OpchildParams extends JSONSerializable<
historical_entries,
min_gas_prices,
bridge_executor,
host_chain_id,
admin,
fee_whitelist,
} = this;
Expand All @@ -154,7 +142,6 @@ export class OpchildParams extends JSONSerializable<
historicalEntries: historical_entries,
minGasPrices: min_gas_prices.toProto(),
bridgeExecutor: bridge_executor,
hostChainId: host_chain_id,
admin,
feeWhitelist: fee_whitelist,
});
Expand All @@ -169,7 +156,6 @@ export namespace OpchildParams {
historical_entries: number;
min_gas_prices: Coins.Amino;
bridge_executor: AccAddress;
host_chain_id: string;
admin: AccAddress;
fee_whitelist: string[];
};
Expand All @@ -181,7 +167,6 @@ export namespace OpchildParams {
historical_entries: number;
min_gas_prices: Coins.Data;
bridge_executor: AccAddress;
host_chain_id: string;
admin: AccAddress;
fee_whitelist: string[];
}
Expand Down
Loading

0 comments on commit f5f590e

Please sign in to comment.