Skip to content

Commit

Permalink
add setupVMBridge and first step for setup
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Feb 18, 2025
1 parent b505c94 commit 010edc2
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 40 deletions.
3 changes: 1 addition & 2 deletions fvm/blueprints/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package blueprints

import (
_ "embed"
"fmt"

"github.com/onflow/cadence"
jsoncdc "github.com/onflow/cadence/encoding/json"
Expand All @@ -16,12 +15,12 @@ import (
// CreateCOATransaction returns the transaction body for the create COA transaction
func CreateCOATransaction(service flow.Address, bridgeEnv bridge.Environment, env templates.Environment) *flow.TransactionBody {
txScript, _ := bridge.GetCadenceTransactionCode("cadence/transactions/evm/create_account.cdc", bridgeEnv, env)
fmt.Println(string(txScript))
return flow.NewTransactionBody().
SetScript([]byte(
txScript,
),
).
AddArgument(jsoncdc.MustEncode(cadence.UFix64(0.0))).
AddAuthorizer(service)
}

Expand Down
58 changes: 47 additions & 11 deletions fvm/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,20 +1018,56 @@ func (b *bootstrapExecutor) setupVMBridge(serviceAddress flow.Address, env *temp
)
panicOnMetaInvokeErrf("failed to create COA in Service Account: %s", txError, err)

gasLimit := 15000000
deploymentValue := 0.0
// gasLimit := 15000000
// deploymentValue := 0.0

// Retrieve the factory bytecode from the JSON args
factoryBytecode := bridge.GetBytecodeFromArgsJSON("cadence/args/deploy-factory-args.json")
// // Retrieve the factory bytecode from the JSON args
// factoryBytecode := bridge.GetBytecodeFromArgsJSON("cadence/args/deploy-factory-args.json")

// deploy the Solidity Factory contract to the service account's COA
tx = blueprints.DeployEVMContractTransaction(serviceAddress, factoryBytecode, gasLimit, deploymentValue, bridgeEnv, *env)
// // deploy the Solidity Factory contract to the service account's COA
// tx = blueprints.DeployEVMContractTransaction(serviceAddress, factoryBytecode, gasLimit, deploymentValue, bridgeEnv, *env)

// txError, err = b.invokeMetaTransaction(
// NewContextFromParent(b.ctx, WithEVMEnabled(true)),
// Transaction(tx, 0),
// )
// panicOnMetaInvokeErrf("failed to deploy the Factory in the Service Account COA: %s", txError, err)

// // Retrieve the factory bytecode from the JSON args
// registryBytecode := bridge.GetBytecodeFromArgsJSON("cadence/args/deploy-registry-args.json")

// // deploy the Solidity Registry contract to the service account's COA
// tx = blueprints.DeployEVMContractTransaction(serviceAddress, registryBytecode, gasLimit, deploymentValue, bridgeEnv, *env)

// txError, err = b.invokeMetaTransaction(
// NewContextFromParent(b.ctx, WithEVMEnabled(true)),
// Transaction(tx, 0),
// )
// panicOnMetaInvokeErrf("failed to deploy the Registry in the Service Account COA: %s", txError, err)

// // Retrieve the erc20Deployer bytecode from the JSON args
// erc20DeployerBytecode := bridge.GetBytecodeFromArgsJSON("cadence/args/deploy-erc20-deployer-args.json")

// // deploy the Solidity ERC20 Deployer contract to the service account's COA
// tx = blueprints.DeployEVMContractTransaction(serviceAddress, erc20DeployerBytecode, gasLimit, deploymentValue, bridgeEnv, *env)

// txError, err = b.invokeMetaTransaction(
// NewContextFromParent(b.ctx, WithEVMEnabled(true)),
// Transaction(tx, 0),
// )
// panicOnMetaInvokeErrf("failed to deploy the ERC20 Deployer in the Service Account COA: %s", txError, err)

// erc721DeployerBytecode := bridge.GetBytecodeFromArgsJSON("cadence/args/deploy-erc721-deployer-args.json")

// // deploy the Solidity Registry contract to the service account's COA
// tx = blueprints.DeployEVMContractTransaction(serviceAddress, erc721DeployerBytecode, gasLimit, deploymentValue, bridgeEnv, *env)

// txError, err = b.invokeMetaTransaction(
// NewContextFromParent(b.ctx, WithEVMEnabled(true)),
// Transaction(tx, 0),
// )
// panicOnMetaInvokeErrf("failed to deploy the ERC721 Deployer in the Service Account COA: %s", txError, err)

txError, err = b.invokeMetaTransaction(
NewContextFromParent(b.ctx, WithEVMEnabled(true)),
Transaction(tx, 0),
)
panicOnMetaInvokeErrf("failed to deploy the Factory in the Service Account COA: %s", txError, err)
}
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ require (
github.com/onflow/cadence v1.3.1
github.com/onflow/crypto v0.25.2
github.com/onflow/flow v0.3.4
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0
github.com/onflow/flow-go-sdk v1.3.1
github.com/onflow/flow/protobuf/go/flow v0.4.9
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
Expand Down Expand Up @@ -108,7 +108,7 @@ require (
github.com/libp2p/go-libp2p-routing-helpers v0.7.4
github.com/mitchellh/mapstructure v1.5.0
github.com/onflow/bridged-usdc/lib/go/contracts v1.0.0
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7
github.com/onflow/go-ethereum v1.14.7
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0
github.com/onflow/wal v1.0.2
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -921,12 +921,12 @@ github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns=
github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY=
github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE=
github.com/onflow/flow v0.3.4/go.mod h1:lzyAYmbu1HfkZ9cfnL5/sjrrsnJiUU8fRL26CqLP7+c=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview h1:W+QkNQcIbhtR+zXVROKq0bdDEnvzUfUrQrCmegmwzvc=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview/go.mod h1:LyCICUK6sK1jtEyb+3GuRw5tYfHT1uxACLwLTLxw/0I=
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview h1:C0PraQFfwpav4nJAf/RPE9BJyYD6lUMvt+cJyiMDeis=
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304 h1:Xs+uHo0+5Yv3TcchCNhkTbGsRkSFZJPfY62FMzxCKyo=
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304/go.mod h1:nkSI3mdfrDuu8uIZjEbONmMbsK/LuF3fgEFTteJ9LHA=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0 h1:zbJaqR3bHicNz68YFJ/6gieUkxnMYz8dKxQrUUCc+/M=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0/go.mod h1:ufT77Epq1gfXAHQQk13WcAHWEv+Aarecn5PMnljWJ1A=
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0 h1:hVlyGbZ+gkeX0mTxTC4D65HulJCUbbVFgOvVWdMfRI8=
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7 h1:ZOfbkNg8KaoJgarpv3Jxj6mNyWHnKLaf5aZPF334ycI=
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7/go.mod h1:9mPDXd/YuYabK0KIx2K7/EzWP980gPBwPjFM23aS1/A=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
Expand Down
6 changes: 3 additions & 3 deletions insecure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ require (
github.com/onflow/atree v0.9.0 // indirect
github.com/onflow/bridged-usdc/lib/go/contracts v1.0.0 // indirect
github.com/onflow/cadence v1.3.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview // indirect
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0 // indirect
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
github.com/onflow/flow-go-sdk v1.3.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions insecure/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -867,12 +867,12 @@ github.com/onflow/cadence v1.3.1 h1:bs9TFHQy8HHbwTtCtg5cLdyndWhmwq55RSwID1cb220=
github.com/onflow/cadence v1.3.1/go.mod h1:6/47FljVAdl3/31tShI8JOJW0sXYZHK1PwXkE+yk0qA=
github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns=
github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview h1:W+QkNQcIbhtR+zXVROKq0bdDEnvzUfUrQrCmegmwzvc=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview/go.mod h1:LyCICUK6sK1jtEyb+3GuRw5tYfHT1uxACLwLTLxw/0I=
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview h1:C0PraQFfwpav4nJAf/RPE9BJyYD6lUMvt+cJyiMDeis=
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304 h1:Xs+uHo0+5Yv3TcchCNhkTbGsRkSFZJPfY62FMzxCKyo=
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304/go.mod h1:nkSI3mdfrDuu8uIZjEbONmMbsK/LuF3fgEFTteJ9LHA=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0 h1:zbJaqR3bHicNz68YFJ/6gieUkxnMYz8dKxQrUUCc+/M=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0/go.mod h1:ufT77Epq1gfXAHQQk13WcAHWEv+Aarecn5PMnljWJ1A=
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0 h1:hVlyGbZ+gkeX0mTxTC4D65HulJCUbbVFgOvVWdMfRI8=
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7 h1:ZOfbkNg8KaoJgarpv3Jxj6mNyWHnKLaf5aZPF334ycI=
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7/go.mod h1:9mPDXd/YuYabK0KIx2K7/EzWP980gPBwPjFM23aS1/A=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
Expand Down
6 changes: 3 additions & 3 deletions integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ require (
github.com/libp2p/go-libp2p v0.38.2
github.com/onflow/cadence v1.3.1
github.com/onflow/crypto v0.25.2
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0
github.com/onflow/flow-go v0.38.0-preview.0.0.20241021221952-af9cd6e99de1
github.com/onflow/flow-go-sdk v1.3.1
github.com/onflow/flow-go/insecure v0.0.0-00010101000000-000000000000
Expand Down Expand Up @@ -245,7 +245,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.9.0 // indirect
github.com/onflow/bridged-usdc/lib/go/contracts v1.0.0 // indirect
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304 // indirect
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.2.3 // indirect
Expand Down
12 changes: 6 additions & 6 deletions integration/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,12 @@ github.com/onflow/cadence v1.3.1 h1:bs9TFHQy8HHbwTtCtg5cLdyndWhmwq55RSwID1cb220=
github.com/onflow/cadence v1.3.1/go.mod h1:6/47FljVAdl3/31tShI8JOJW0sXYZHK1PwXkE+yk0qA=
github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns=
github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview h1:W+QkNQcIbhtR+zXVROKq0bdDEnvzUfUrQrCmegmwzvc=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.5.1-preview/go.mod h1:LyCICUK6sK1jtEyb+3GuRw5tYfHT1uxACLwLTLxw/0I=
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview h1:C0PraQFfwpav4nJAf/RPE9BJyYD6lUMvt+cJyiMDeis=
github.com/onflow/flow-core-contracts/lib/go/templates v1.5.1-preview/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304 h1:Xs+uHo0+5Yv3TcchCNhkTbGsRkSFZJPfY62FMzxCKyo=
github.com/onflow/flow-evm-bridge v0.0.0-20250211192700-061a964fb304/go.mod h1:nkSI3mdfrDuu8uIZjEbONmMbsK/LuF3fgEFTteJ9LHA=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0 h1:zbJaqR3bHicNz68YFJ/6gieUkxnMYz8dKxQrUUCc+/M=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.6.0/go.mod h1:ufT77Epq1gfXAHQQk13WcAHWEv+Aarecn5PMnljWJ1A=
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0 h1:hVlyGbZ+gkeX0mTxTC4D65HulJCUbbVFgOvVWdMfRI8=
github.com/onflow/flow-core-contracts/lib/go/templates v1.6.0/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7 h1:ZOfbkNg8KaoJgarpv3Jxj6mNyWHnKLaf5aZPF334ycI=
github.com/onflow/flow-evm-bridge v0.0.0-20250218172042-26b9284449c7/go.mod h1:9mPDXd/YuYabK0KIx2K7/EzWP980gPBwPjFM23aS1/A=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
Expand Down

0 comments on commit 010edc2

Please sign in to comment.