Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #250 from ar-io/PE-6226-freeze-contract
Browse files Browse the repository at this point in the history
feat(PE-6226): freeze contract
  • Loading branch information
dtfiedler authored Jun 17, 2024
2 parents 55f69c2 + 2e3d315 commit 7cad6ac
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ import {
PstAction,
} from './types';

export const FORKED_AO_BLOCK_HEIGHT = 144900; // approximately July 21, 2024

const writeInteractions = [
'joinNetwork',
'leaveNetwork',
'increaseOperatorStake',
'decreaseOperatorStake',
'updateGatewaySettings',
'saveObservations',
'submitAuctionBid',
'buyRecord',
'extendRecord',
'increaseUndernameCount',
'transfer',
'vaultedTransfer',
'createVault',
'extendVault',
'increaseVault',
];

export async function handle(
state: IOState,
action: PstAction,
Expand All @@ -58,6 +78,18 @@ export async function handle(
// all the remaining interactions require a ticked state, even when reading, so users get the most recent evaluation
const { state: tickedState } = await tick(state);

const blockHeight = +SmartWeave.block.height;

// check if it's a write interaction and if it's being called after the forked block height
if (
writeInteractions.includes(input.function) &&
blockHeight >= FORKED_AO_BLOCK_HEIGHT
) {
throw new ContractError(
`This contract is being forked to AO. Write interactions are disabled. Follow along for migration updates: https://twitter.com/ar_io_network`,
);
}

switch (input.function as IOContractFunctions) {
// owner wallet functions
case 'createReservedName':
Expand Down

0 comments on commit 7cad6ac

Please sign in to comment.