Skip to content

Commit

Permalink
make CI happy
Browse files Browse the repository at this point in the history
  • Loading branch information
fbac committed Dec 20, 2024
1 parent e29d1c0 commit 695aafd
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 34 deletions.
10 changes: 10 additions & 0 deletions contracts/script/output/31337/GroupMessages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"addresses": {
"groupMessagesDeployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"groupMessagesImpl": "0xc0F115A19107322cFBf1cDBC7ea011C19EbDB4F8",
"groupMessagesProxy": "0xc96304e3c037f81dA488ed9dEa1D8F2a48278a75",
"groupMessagesProxyAdmin": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
},
"deploymentBlock": 107,
"latestUpgradeBlock": 107
}
10 changes: 10 additions & 0 deletions contracts/script/output/31337/IdentityUpdates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"addresses": {
"identityUpdatesDeployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"identityUpdatesImpl": "0x34B40BA116d5Dec75548a9e9A8f15411461E8c70",
"identityUpdatesProxy": "0xD0141E899a65C95a556fE2B27e5982A6DE7fDD7A",
"identityUpdatesProxyAdmin": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
},
"deploymentBlock": 109,
"latestUpgradeBlock": 109
}
10 changes: 0 additions & 10 deletions contracts/script/output/31337/group_messages_deployment.json

This file was deleted.

10 changes: 0 additions & 10 deletions contracts/script/output/31337/identity_updates_deployment.json

This file was deleted.

4 changes: 2 additions & 2 deletions contracts/script/utils/Environment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pragma solidity 0.8.28;
import "forge-std/src/Script.sol";

contract Environment is Script {
string public constant XMTP_GROUP_MESSAGES_OUTPUT_JSON = "group_messages_deployment";
string public constant XMTP_IDENTITY_UPDATES_OUTPUT_JSON = "identity_updates_deployment";
string public constant XMTP_GROUP_MESSAGES_OUTPUT_JSON = "GroupMessages";
string public constant XMTP_IDENTITY_UPDATES_OUTPUT_JSON = "IdentityUpdates";
}
4 changes: 2 additions & 2 deletions dev/baked/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ RUN dev/docker/anvil-background && \
sleep 5

RUN echo "export XMTPD_CONTRACTS_NODES_ADDRESS="$(jq -r '.deployedTo' build/Nodes.json)"" >> contracts.env && \
echo "export XMTPD_CONTRACTS_MESSAGES_ADDRESS="$(jq -r '.deployedTo' build/GroupMessages.json)"" >> contracts.env && \
echo "export XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS="$(jq -r '.deployedTo' build/IdentityUpdates.json)"" >> contracts.env
echo "export XMTPD_CONTRACTS_MESSAGES_ADDRESS="$(jq -r '.addresses.groupMessagesProxy' contracts/script/output/31337/GroupMessages.json)"" >> contracts.env && \
echo "export XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS="$(jq -r '.addresses.identityUpdatesProxy' contracts/script/output/31337/IdentityUpdates.json)"" >> contracts.env

# ACTUAL IMAGE -------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions dev/contracts/common
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function forge_deploy_script() {
fi

echo -e "✅ GroupMessages contract deployed.\n"
cat script/output/31337/group_messages_deployment.json
cat script/output/31337/GroupMessages.json
echo -e "\n"
;;

Expand All @@ -23,7 +23,7 @@ function forge_deploy_script() {
fi

echo -e "✅ IdentityUpdates contract deployed.\n"
cat script/output/31337/identity_updates_deployment.json
cat script/output/31337/IdentityUpdates.json
echo -e "\n"
;;

Expand Down
9 changes: 6 additions & 3 deletions dev/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

source dev/contracts/.env

# Anvil scripts output folder
ANVIL_SCRIPTS_OUTPUT=contracts/script/output/31337

# DB Options
export XMTPD_DB_WRITER_CONNECTION_STRING="postgres://postgres:xmtp@localhost:8765/postgres?sslmode=disable"

# Contract Options
export XMTPD_CONTRACTS_RPC_URL=$DOCKER_RPC_URL # From contracts/.env
XMTPD_CONTRACTS_NODES_ADDRESS="$(jq -r '.deployedTo' build/Nodes.json)" # Built by contracts/deploy-local
XMTPD_CONTRACTS_NODES_ADDRESS="$(jq -r '.deployedTo' build/Nodes.json)" # Built by contracts/deploy-local - TODO: move deployment to forge script
export XMTPD_CONTRACTS_NODES_ADDRESS
XMTPD_CONTRACTS_MESSAGES_ADDRESS="$(jq -r '.deployedTo' build/GroupMessages.json)" # Built by contracts/deploy-local
XMTPD_CONTRACTS_MESSAGES_ADDRESS="$(jq -r '.addresses.groupMessagesProxy' ${ANVIL_SCRIPTS_OUTPUT}/GroupMessages.json)" # Built by contracts/deploy-local
export XMTPD_CONTRACTS_MESSAGES_ADDRESS
XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS="$(jq -r '.deployedTo' build/IdentityUpdates.json)" # Built by contracts/deploy-local
XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS="$(jq -r '.addresses.identityUpdatesProxy' ${ANVIL_SCRIPTS_OUTPUT}/IdentityUpdates.json)" # Built by contracts/deploy-local
export XMTPD_CONTRACTS_IDENTITY_UPDATES_ADDRESS

export ANVIL_ACC_1_PRIVATE_KEY="0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
require (
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/valyala/fastjson v1.6.4
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,8 @@ github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3C
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vbatts/tar-split v0.11.6 h1:4SjTW5+PU11n6fZenf2IPoV8/tz3AaYHMWjf23envGs=
Expand Down
2 changes: 1 addition & 1 deletion pkg/blockchain/blockchainPublisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestPublishIdentityUpdate(t *testing.T) {
{
name: "happy path",
inboxId: testutils.RandomGroupID(),
identityUpdate: testutils.RandomBytes(100),
identityUpdate: testutils.RandomBytes(104),
ctx: context.Background(),
wantErr: false,
},
Expand Down
32 changes: 28 additions & 4 deletions pkg/testutils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"os"
"path"
"path/filepath"
"strings"
"testing"
"time"

"github.com/stretchr/testify/require"
"github.com/valyala/fastjson"
"github.com/xmtp/xmtpd/pkg/config"
)

Expand Down Expand Up @@ -48,6 +50,7 @@ func rootPath(t *testing.T) string {
/*
*
Parse the JSON file at this location to get the deployed contract info
TODO: deprecate in favor of getProxyAddress
*
*/
func getDeployedTo(t *testing.T, fileName string) string {
Expand All @@ -65,19 +68,40 @@ func getDeployedTo(t *testing.T, fileName string) string {
return info.DeployedTo
}

/*
*
Parse the JSON file at this location to get the deployed contract proxy address
*
*/
func getProxyAddress(t *testing.T, fileName string) string {
data, err := os.ReadFile(fileName)
if err != nil {
t.Fatalf("Failed to read json: %v", err)
}

switch {
case strings.Contains(fileName, "GroupMessages.json"):
return fastjson.GetString(data, "addresses", "groupMessagesProxy")
case strings.Contains(fileName, "IdentityUpdates.json"):
return fastjson.GetString(data, "addresses", "identityUpdatesProxy")
default:
return ""
}
}

func GetContractsOptions(t *testing.T) config.ContractsOptions {
rootDir := rootPath(t)

return config.ContractsOptions{
RpcUrl: BLOCKCHAIN_RPC_URL,
MessagesContractAddress: getDeployedTo(
MessagesContractAddress: getProxyAddress(
t,
path.Join(rootDir, "./build/GroupMessages.json"),
path.Join(rootDir, "./contracts/script/output/31337/GroupMessages.json"),
),
NodesContractAddress: getDeployedTo(t, path.Join(rootDir, "./build/Nodes.json")),
IdentityUpdatesContractAddress: getDeployedTo(
IdentityUpdatesContractAddress: getProxyAddress(
t,
path.Join(rootDir, "./build/IdentityUpdates.json"),
path.Join(rootDir, "./contracts/script/output/31337/IdentityUpdates.json"),
),
RefreshInterval: 100 * time.Millisecond,
ChainID: 31337,
Expand Down

0 comments on commit 695aafd

Please sign in to comment.