Skip to content

Commit

Permalink
Merge branch 'jt/net-80-upgrade-diff-report-render' into jt/net-61-ci…
Browse files Browse the repository at this point in the history
…-implementation
  • Loading branch information
jterzis committed Sep 9, 2024
2 parents 5577ba4 + b4518a4 commit 6ac5f84
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 22 deletions.
35 changes: 35 additions & 0 deletions contracts/src/utils/libraries/CustomRevert.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Library for reverting with custom errors efficiently
/// @notice Contains functions for reverting with custom errors with different argument types efficiently
/// @dev To use this library, declare `using CustomRevert for bytes4;` and replace `revert CustomError()` with
/// `CustomError.selector.revertWith()`
/// @dev The functions may tamper with the free memory pointer but it is fine since the call context is exited immediately
library CustomRevert {
/// @dev Reverts with the selector of a custom error in the scratch space
function revertWith(bytes4 selector) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
revert(0, 0x04)
}
}

/// @dev Reverts with a custom error with a uint256 argument in the scratch space
function revertWith(bytes4 selector, uint256 value) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, value)
revert(0, 0x24)
}
}

/// @dev Reverts with a custom error with an address argument in the scratch space
function revertWith(bytes4 selector, address addr) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, and(addr, 0xffffffffffffffffffffffffffffffffffffffff))
revert(0, 0x24)
}
}
}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.0.59",
"version": "0.0.61",
"packages": ["packages/*", "protocol"],
"npmClient": "yarn"
}
2 changes: 1 addition & 1 deletion packages/dlog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/dlog",
"version": "0.0.59",
"version": "0.0.61",
"packageManager": "[email protected]",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/encryption/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/encryption",
"version": "0.0.59",
"version": "0.0.61",
"packageManager": "[email protected]",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/eslint-config",
"version": "0.0.59",
"version": "0.0.61",
"license": "MIT",
"main": "typescript.js"
}
2 changes: 1 addition & 1 deletion packages/generated/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/generated",
"version": "0.0.59",
"version": "0.0.61",
"packageManager": "[email protected]",
"scripts": {
"preinstall": "node ./scripts/make-config.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/prettier-config",
"version": "0.0.59",
"version": "0.0.61",
"license": "MIT",
"main": "config.js",
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/proto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/proto",
"version": "0.0.59",
"version": "0.0.61",
"packageManager": "[email protected]",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/react-sdk",
"version": "0.0.59",
"version": "0.0.61",
"description": "React Hooks for River SDK",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/sdk",
"version": "0.0.59",
"version": "0.0.61",
"packageManager": "[email protected]",
"type": "module",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/sync-agent/spaces/models/channel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlainMessage } from '@bufbuild/protobuf'
import { PersistedObservable, persistedObservable } from '../../../observable/persistedObservable'
import { Identifiable, Store } from '../../../store/store'
import { Identifiable, LoadPriority, Store } from '../../../store/store'
import { RiverConnection } from '../../river-connection/riverConnection'
import { ChannelMessage_Post_Attachment, ChannelMessage_Post_Mention } from '@river-build/proto'
import { Timeline } from '../../timeline/timeline'
Expand Down Expand Up @@ -29,7 +29,7 @@ export class Channel extends PersistedObservable<ChannelModel> {
private spaceDapp: SpaceDapp,
store: Store,
) {
super({ id, spaceId, isJoined: false }, store)
super({ id, spaceId, isJoined: false }, store, LoadPriority.high)
this.timeline = new Timeline(riverConnection.userId)
this.members = new Members(id, riverConnection, store)
}
Expand Down
11 changes: 8 additions & 3 deletions packages/sdk/src/sync-agent/spaces/models/space.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { check, dlogger } from '@river-build/dlog'
import { isDefined } from '../../../check'
import { makeDefaultChannelStreamId, makeUniqueChannelStreamId } from '../../../id'
import {
isChannelStreamId,
makeDefaultChannelStreamId,
makeUniqueChannelStreamId,
} from '../../../id'
import { PersistedObservable, persistedObservable } from '../../../observable/persistedObservable'
import { Identifiable, Store } from '../../../store/store'
import { Identifiable, LoadPriority, Store } from '../../../store/store'
import { RiverConnection } from '../../river-connection/riverConnection'
import { Channel } from './channel'
import { ethers } from 'ethers'
Expand All @@ -28,7 +32,7 @@ export class Space extends PersistedObservable<SpaceModel> {
store: Store,
private spaceDapp: SpaceDapp,
) {
super({ id, channelIds: [], initialized: false }, store)
super({ id, channelIds: [], initialized: false }, store, LoadPriority.high)
this.channels = {
[makeDefaultChannelStreamId(id)]: new Channel(
makeDefaultChannelStreamId(id),
Expand Down Expand Up @@ -111,6 +115,7 @@ export class Space extends PersistedObservable<SpaceModel> {
}

getChannel(channelId: string): Channel {
check(isChannelStreamId(channelId), 'channelId is not a channel stream id')
if (!this.channels[channelId]) {
this.channels[channelId] = new Channel(
channelId,
Expand Down
5 changes: 5 additions & 0 deletions packages/stream-metadata/src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as dotenv from 'dotenv'
import { getWeb3Deployment } from '@river-build/web3'
import { z } from 'zod'
import { v4 } from 'uuid'

dotenv.config({
path: ['.env', '.env.local'],
Expand Down Expand Up @@ -52,6 +53,10 @@ function makeConfig() {
pretty: envMain.LOG_PRETTY,
},
aws: envAws?.success ? envAws.data : undefined,
instance: {
id: v4(),
deployedAt: new Date().toISOString(),
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/stream-metadata/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ const pinoOptions: LoggerOptions = {
const baseLogger = pino(pinoOptions)

export function getLogger(name: string, meta: Record<string, unknown> = {}) {
return baseLogger.child({ name, ...meta })
return baseLogger.child({ name, instance: config.instance, ...meta })
}
14 changes: 9 additions & 5 deletions packages/stream-metadata/src/opensea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import { FastifyBaseLogger } from 'fastify'
import { config } from './environment'
import { spaceDapp } from './contract-utils'

const getOpenSeaAPIUrl = (space: SpaceInfo) => {
const getOpenSeaAPIUrl = (logger: FastifyBaseLogger, space: SpaceInfo) => {
const spaceOwnerAddress = config.web3Config.base.addresses.spaceOwner
const chainId = config.web3Config.base.chainId
const tokenId = BigNumber.from(space.tokenId).toString()

if (space.networkId === String(BASE_MAINNET)) {
if (chainId === BASE_MAINNET) {
return `https://api.opensea.io/api/v2/chain/base/contract/${spaceOwnerAddress}/nfts/${tokenId}/refresh`
} else if (space.networkId === String(BASE_SEPOLIA)) {
} else if (chainId === BASE_SEPOLIA) {
return `https://testnets-api.opensea.io/api/v2/chain/base_sepolia/contract/${spaceOwnerAddress}/nfts/${tokenId}/refresh`
} else if (chainId === 31337) {
return `https://testnets-api.opensea.io/api/v2/chain/base_sepolia/contract/${spaceOwnerAddress}/nfts/${tokenId}/refresh`
} else {
throw new Error('Unsupported network')
logger.error({ chainId }, 'Unsupported network')
throw new Error(`Unsupported network ${chainId}`)
}
}

Expand All @@ -40,7 +44,7 @@ export const refreshOpenSea = async ({
throw new Error('Space not found')
}

const url = getOpenSeaAPIUrl(space)
const url = getOpenSeaAPIUrl(logger, space)
logger.info({ url, spaceAddress }, 'refreshing openSea')

const response = await fetch(url, {
Expand Down
2 changes: 1 addition & 1 deletion packages/web3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/web3",
"version": "0.0.59",
"version": "0.0.61",
"packageManager": "[email protected]",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion protocol/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@river-build/proto-source",
"version": "0.0.59",
"version": "0.0.61",
"packageManager": "[email protected]",
"files": [
"*.proto"
Expand Down

0 comments on commit 6ac5f84

Please sign in to comment.