Skip to content

Commit

Permalink
fix: Migrate archway and neturon network id to chain ids
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonAndell committed Nov 29, 2023
1 parent 7291763 commit 5ce843c
Showing 1 changed file with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,54 @@ public class IBCConnection {
protected final BranchDB<String, DictDB<Address, BigInteger>> unclaimedPacketFees = Context.newBranchDB("unclaimedPacketFees", BigInteger.class);

public IBCConnection(Address _xCall, Address _ibc, String _port) {
PORT = _port;
if( ibc.get() == null) {
ibc.set(_ibc);
xCall.set(_xCall);
admin.set(Context.getCaller());
PORT = _port;
} else {
String oldNeutronNid = "neutron";
String newNeutronNid = "neutron-1";
String oldArchwayNid = "archway";
String newArchwayNid = "archway-1";

Context.require(configuredNetworkIds.at("connection-2").get("xcall").equals(oldNeutronNid));
configuredNetworkIds.at("connection-2").set("xcall", newNeutronNid);

Context.require(configuredNetworkIds.at("connection-0").get("xcall").equals(oldArchwayNid));
configuredNetworkIds.at("connection-0").set("xcall", newArchwayNid);

String neutronChannel = channels.get(oldNeutronNid);
String archwayChannel = channels.get(oldArchwayNid);

Context.require(neutronChannel.equals("channel-1"));
Context.require(archwayChannel.equals("channel-0"));

channels.set(oldNeutronNid, null);
channels.set(oldArchwayNid, null);

channels.set(newNeutronNid, neutronChannel);
channels.set(newArchwayNid, archwayChannel);

networkIds.set(neutronChannel, newNeutronNid);
networkIds.set(archwayChannel, newArchwayNid);

BigInteger oldPacketFeeNeutron = sendPacketFee.get(oldNeutronNid);
BigInteger oldAckFeeNeutron = ackFee.get(oldNeutronNid);
sendPacketFee.set(newNeutronNid, oldPacketFeeNeutron);
ackFee.set(newNeutronNid, oldAckFeeNeutron);

sendPacketFee.set(oldNeutronNid, null);
ackFee.set(oldNeutronNid, null);

BigInteger oldPacketFeeArchway = sendPacketFee.get(oldArchwayNid);
BigInteger oldAckFeeArchway = ackFee.get(oldArchwayNid);
sendPacketFee.set(newArchwayNid, oldPacketFeeArchway);
ackFee.set(newArchwayNid, oldAckFeeArchway);

sendPacketFee.set(oldArchwayNid, null);
ackFee.set(oldArchwayNid, null);
}
}

private void checkCallerOrThrow(Address caller, String errMsg) {
Expand Down

0 comments on commit 5ce843c

Please sign in to comment.