Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add prefix to user address when processing flow.json #1331

Merged
merged 9 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/onflow/cadence-tools/languageserver v0.33.3
github.com/onflow/cadence-tools/test v0.14.5
github.com/onflow/fcl-dev-wallet v0.7.4
github.com/onflow/flixkit-go v1.0.0
github.com/onflow/flixkit-go v1.0.2
github.com/onflow/flow-cli/flowkit v1.6.1-0.20231110211255-b41f57a8b8c7
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f
github.com/onflow/flow-emulator v0.59.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,8 @@ github.com/onflow/cadence-tools/test v0.14.5 h1:u1kYkotKdwKEf9c3h65mI3VMevBkHY+7
github.com/onflow/cadence-tools/test v0.14.5/go.mod h1:ix09Bb3GQ/fZMNpSR8E+vSFItGF54fzP9gFxU7AsOIw=
github.com/onflow/fcl-dev-wallet v0.7.4 h1:vI6t3U0AO88R/Iitn5KsnniSpbN9Lqsqwvi9EJT4C0k=
github.com/onflow/fcl-dev-wallet v0.7.4/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw=
github.com/onflow/flixkit-go v1.0.0 h1:SY2H4iB3kW8CEOxnofJZYm3sEZXnz3x0qiWkIe4l1LI=
github.com/onflow/flixkit-go v1.0.0/go.mod h1:KGL7oMu4uzt7s0qsNkaqGBYIt+Z38Qbf0JG56qK/Sg0=
github.com/onflow/flixkit-go v1.0.2 h1:6PVLLb8qQj9L6cs57HUO3wszzbgPD46pc9MAGWHnb1s=
github.com/onflow/flixkit-go v1.0.2/go.mod h1:KGL7oMu4uzt7s0qsNkaqGBYIt+Z38Qbf0JG56qK/Sg0=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f h1:Ep+Mpo2miWMe4pjPGIaEvEzshRep30dvNgxqk+//FrQ=
Expand Down
11 changes: 7 additions & 4 deletions internal/super/flix.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ import (

"github.com/onflow/flixkit-go/flixkit"

"github.com/onflow/flow-go-sdk"
"github.com/spf13/cobra"

"github.com/onflow/flow-cli/flowkit"
"github.com/onflow/flow-cli/flowkit/config"
"github.com/onflow/flow-cli/flowkit/output"
"github.com/onflow/flow-cli/internal/command"
"github.com/onflow/flow-cli/internal/scripts"
"github.com/onflow/flow-cli/internal/transactions"

"github.com/spf13/cobra"
)

type flixFlags struct {
Expand Down Expand Up @@ -283,24 +284,26 @@ func GetDeployedContracts(state *flowkit.State) flixkit.ContractInfos {
// get all deployed and alias contracts for configured networks
for _, network := range depNetworks {
contracts, err := state.DeploymentContractsByNetwork(config.Network{Name: network})
fmt.Println("contracts len", network, len(contracts))
if err != nil {
continue
}
for _, c := range contracts {
if _, ok := allContracts[c.Name]; !ok {
allContracts[c.Name] = make(flixkit.NetworkAddressMap)
}
allContracts[c.Name][network] = c.AccountAddress.String()
allContracts[c.Name][network] = c.AccountAddress.Hex()
}
locAliases := state.AliasesForNetwork(config.Network{Name: network})
for name, addr := range locAliases {
address := flow.BytesToAddress([]byte(addr))
if isPath(name) {
continue
}
if _, ok := allContracts[name]; !ok {
allContracts[name] = make(flixkit.NetworkAddressMap)
}
allContracts[name][network] = addr
allContracts[name][network] = address.Hex()
}
}
return allContracts
Expand Down
60 changes: 60 additions & 0 deletions internal/super/flix_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package super

import (
"testing"

"github.com/onflow/flow-cli/flowkit"
"github.com/onflow/flow-cli/flowkit/config"
"github.com/onflow/flow-cli/flowkit/tests"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
)

func Test_flix_generate(t *testing.T) {
configJson := []byte(`{
"contracts": {},
"accounts": {
"emulator-account": {
"address": "f8d6e0586b0a20c7",
"key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
}
},
"networks": {
"emulator": "127.0.0.1.3569"
},
"deployments": {
}
}`)

af := afero.Afero{Fs: afero.NewMemMapFs()}
err := afero.WriteFile(af.Fs, "flow.json", configJson, 0644)
assert.NoError(t, err)
err = afero.WriteFile(af.Fs, tests.ContractHelloString.Filename, []byte(tests.ContractHelloString.Source), 0644)
assert.NoError(t, err)
paths := []string{"flow.json"}
state, err := flowkit.Load(paths, af)
assert.NotNil(t, state)
assert.NoError(t, err)
d := config.Deployment{
Network: "emulator",
Account: "emulator-account",
Contracts: []config.ContractDeployment{{
Name: tests.ContractHelloString.Name,
Args: nil,
}},
}
state.Deployments().AddOrUpdate(d)
c := config.Contract{
Name: tests.ContractHelloString.Name,
Location: tests.ContractHelloString.Filename,
}
state.Contracts().AddOrUpdate(c)

contracts, err := state.DeploymentContractsByNetwork(config.Network{Name: "emulator"})
assert.NoError(t, err)
assert.Equal(t, 1, len(contracts))

cs := GetDeployedContracts(state)
assert.Equal(t, 1, len(cs))

}
Loading