Skip to content

Commit

Permalink
contracts: move creation code
Browse files Browse the repository at this point in the history
  • Loading branch information
attente committed Feb 26, 2025
1 parent f2092df commit 4b135c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/sequence/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/0xsequence/ethkit/go-ethereum/common"
"github.com/0xsequence/ethkit/go-ethereum/common/hexutil"
"github.com/0xsequence/go-sequence/contracts"
"github.com/spf13/cobra"
)
Expand All @@ -15,7 +16,7 @@ func calculateAddress(params *AddressCalculateParams) (string, error) {

creationCode := params.CreationCode
if creationCode == "" {
creationCode = contracts.V3_CREATION_CODE
creationCode = hexutil.Encode(contracts.V3.CreationCode)
}

address, err := contracts.GetCounterfactualAddress(factory, module, imageHash, creationCode)
Expand Down
13 changes: 7 additions & 6 deletions contracts/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/0xsequence/ethkit/ethartifact"
"github.com/0xsequence/ethkit/ethcontract"
"github.com/0xsequence/ethkit/go-ethereum/common"
"github.com/0xsequence/ethkit/go-ethereum/common/hexutil"
"github.com/0xsequence/ethkit/go-ethereum/crypto"
"github.com/0xsequence/go-sequence/contracts/gen/gasestimator"
"github.com/0xsequence/go-sequence/contracts/gen/ierc1271"
Expand Down Expand Up @@ -54,6 +55,7 @@ var V1 struct {
WalletUtils ethartifact.Artifact
WalletRequireFreshSigner ethartifact.Artifact
WalletGasEstimator ethartifact.Artifact
CreationCode []byte
}

var V2 struct {
Expand All @@ -63,6 +65,7 @@ var V2 struct {
WalletGuestModule ethartifact.Artifact
WalletUtils ethartifact.Artifact
WalletGasEstimator ethartifact.Artifact
CreationCode []byte
}

var V3 struct {
Expand All @@ -71,19 +74,14 @@ var V3 struct {
WalletStage2Module ethartifact.Artifact
WalletGuestModule ethartifact.Artifact
WalletGasEstimator ethartifact.Artifact
CreationCode []byte
}

var (
//go:embed artifacts/erc1155/mocks/ERC20Mock.sol/ERC20Mock.json
artifact_erc20mock string
)

const (
V1_CREATION_CODE = "0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3"
V2_CREATION_CODE = "0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3"
V3_CREATION_CODE = "0x603e600e3d39601e805130553df33d3d34601c57363d3d373d363d30545af43d82803e903d91601c57fd5bf3"
)

func init() {
V1.WalletFactory = artifact("WALLET_FACTORY", walletfactory1.WalletFactoryABI, walletfactory1.WalletFactoryBin)
V1.WalletMainModule = artifact("WALLET_MAIN", walletmain1.WalletMainABI, walletmain1.WalletMainBin)
Expand All @@ -92,18 +90,21 @@ func init() {
V1.WalletUtils = artifact("WALLET_UTILS", walletutils1.WalletUtilsABI, walletutils1.WalletUtilsBin)
V1.WalletRequireFreshSigner = artifact("WALLET_REQUIRE_FRESH_SIGNER", walletutils1.WalletRequireFreshSignerABI, walletutils1.WalletRequireFreshSignerBin)
V1.WalletGasEstimator = artifact("WALLET_GAS_ESTIMATOR", walletgasestimator1.WalletGasEstimatorABI, walletgasestimator1.WalletGasEstimatorBin, walletgasestimator1.WalletGasEstimatorDeployedBin)
V1.CreationCode = hexutil.MustDecode("0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3")

V2.WalletFactory = artifact("WALLET_FACTORY", walletfactory2.WalletFactoryABI, walletfactory2.WalletFactoryBin)
V2.WalletMainModule = artifact("WALLET_MAIN", walletmain2.WalletMainABI, walletmain2.WalletMainBin)
V2.WalletMainModuleUpgradable = artifact("WALLET_UPGRADABLE", walletupgradable2.WalletUpgradableABI, walletupgradable2.WalletUpgradableBin)
V2.WalletGuestModule = artifact("WALLET_GUEST", walletguest2.WalletGuestABI, walletguest2.WalletGuestBin)
V2.WalletUtils = artifact("WALLET_UTILS", walletutils2.WalletUtilsABI, walletutils2.WalletUtilsBin)
V2.WalletGasEstimator = artifact("WALLET_GAS_ESTIMATOR", walletgasestimator2.WalletGasEstimatorABI, walletgasestimator2.WalletGasEstimatorBin, walletgasestimator2.WalletGasEstimatorDeployedBin)
V2.CreationCode = hexutil.MustDecode("0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3")

V3.WalletFactory = artifact("WALLET_FACTORY", walletfactory3.WalletFactoryABI, walletfactory3.WalletFactoryBin)
V3.WalletStage1Module = artifact("WALLET_STAGE_1", walletstage13.WalletStage1ABI, walletstage13.WalletStage1Bin)
V3.WalletStage2Module = artifact("WALLET_STAGE_2", walletstage23.WalletStage2ABI, walletstage23.WalletStage2Bin)
V3.WalletGuestModule = artifact("WALLET_GUEST", walletguest3.WalletGuestABI, walletguest3.WalletGuestBin)
V3.CreationCode = hexutil.MustDecode("0x603e600e3d39601e805130553df33d3d34601c57363d3d373d363d30545af43d82803e903d91601c57fd5bf3")

// TODO: Update w/ v3 gas estimator
V3.WalletGasEstimator = artifact("WALLET_GAS_ESTIMATOR", walletgasestimator2.WalletGasEstimatorABI, walletgasestimator2.WalletGasEstimatorBin, walletgasestimator2.WalletGasEstimatorDeployedBin)
Expand Down

0 comments on commit 4b135c6

Please sign in to comment.