Skip to content

Commit

Permalink
Merge pull request #252 from ar-io/PE-6226-freeze-contract
Browse files Browse the repository at this point in the history
chore: reset all token balances
  • Loading branch information
dtfiedler committed Jun 19, 2024
2 parents 7cad6ac + 1c0822b commit dde0d98
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/actions/write/evolveState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { NON_CONTRACT_OWNER_MESSAGE } from '../../constants';
import { ContractWriteResult, Fees, IOState, PstAction } from '../../types';
import { NON_CONTRACT_OWNER_MESSAGE, TOTAL_IO_SUPPLY } from '../../constants';
import {
ContractWriteResult,
IOState,
PstAction,
WalletAddress,
} from '../../types';

// Updates this contract to new source code
export const evolveState = async (
Expand All @@ -12,14 +17,16 @@ export const evolveState = async (
throw new ContractError(NON_CONTRACT_OWNER_MESSAGE);
}

const updatedFees = Object.keys(state.fees).reduce((acc: Fees, key) => {
const existingFee = state.fees[key];
// convert the base fee to mIO
acc[key] = existingFee / 1_000_000;
return acc;
}, {});

state.fees = updatedFees;
const updatedBalances = Object.keys(state.balances).reduce(
(acc: Record<WalletAddress, number>, address) => {
// convert the base fee to mIO
acc[address] = 0;
return acc;
},
{},
);

updatedBalances[owner] = TOTAL_IO_SUPPLY.valueOf();
state.balances = updatedBalances;
return { state };
};

0 comments on commit dde0d98

Please sign in to comment.