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 #213 from ar-io/bark-record
Browse files Browse the repository at this point in the history
chore: create bark record for AO team
  • Loading branch information
dtfiedler authored Feb 26, 2024
2 parents 26a5c78 + 7103a00 commit 46ee1ec
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions src/actions/write/evolveState.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import {
EPOCH_BLOCK_LENGTH,
GATEWAY_REGISTRY_SETTINGS,
DEFAULT_UNDERNAME_COUNT,
NON_CONTRACT_OWNER_MESSAGE,
SECONDS_IN_A_YEAR,
} from '../../constants';
import {
getEpochDataForHeight,
getPrescribedObserversForEpoch,
} from '../../observers';
import {
BlockHeight,
ContractWriteResult,
IOState,
PstAction,
} from '../../types';
import { ContractWriteResult, IOState, PstAction } from '../../types';

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

const { epochStartHeight, epochEndHeight } = getEpochDataForHeight({
currentBlockHeight: new BlockHeight(+SmartWeave.block.height),
epochZeroStartHeight: new BlockHeight(
state.distributions.epochZeroStartHeight,
),
epochBlockLength: new BlockHeight(EPOCH_BLOCK_LENGTH),
});

const prescribedObservers = await getPrescribedObserversForEpoch({
gateways: state.gateways,
distributions: state.distributions,
epochStartHeight,
epochEndHeight,
minOperatorStake: GATEWAY_REGISTRY_SETTINGS.minOperatorStake,
});

state.prescribedObservers = {
[epochStartHeight.valueOf()]: prescribedObservers,
// expires in one year
state.records['bark'] = {
contractTxId: 'uxYtKoLadnS-MH1AZ2ORhDNH5vJIbvjSWvXa6QLjzVg',
startTimestamp: +SmartWeave.block.timestamp,
endTimestamp: +SmartWeave.block.timestamp + SECONDS_IN_A_YEAR,
undernames: DEFAULT_UNDERNAME_COUNT,
type: 'lease',
purchasePrice: 0,
};

return { state };
Expand Down

0 comments on commit 46ee1ec

Please sign in to comment.