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

I can not generate address, please help me #801

Open
godlovericea opened this issue Jan 7, 2025 · 9 comments
Open

I can not generate address, please help me #801

godlovericea opened this issue Jan 7, 2025 · 9 comments

Comments

@godlovericea
Copy link

gen := flow.NewAddressGenerator(flow.Mainnet)
address := gen.Address()
fmt.Println(address.Hex())
fmt.Println(address.String())

When I want to generate flow address, it panic :
windows:

# github.com/onflow/atree
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\typeinfo.go:33:15: undefined: cbor.StreamEncoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\typeinfo.go:39:16: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\encode.go:31:26: undefined: cbor.StreamEncoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\encode.go:61:16: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\array.go:273:34: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\array.go:605:12: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:454:32: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:535:39: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:588:45: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:798:52: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:798:52: too many errors (exit status 1)

mac os:

# github.com/onflow/atree
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/typeinfo.go:33:15: undefined: cbor.StreamEncoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/typeinfo.go:39:16: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/encode.go:31:26: undefined: cbor.StreamEncoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/encode.go:61:16: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/array.go:273:34: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/array.go:605:12: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:454:32: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:535:39: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:588:45: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:798:52: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:798:52: too many errors (exit status 1)
@nvdtf
Copy link
Member

nvdtf commented Jan 7, 2025

this sounds like a versioning issue in go.mod

can you post your full project with go.mod so I can debug?

@godlovericea
Copy link
Author

@nvdtf Thank you very much, I have resolved it

@godlovericea
Copy link
Author

I still can not create account via examples in this repo:
I have created an account via Flow Wallet, then I wan to create an account via Golang Program, But it failed with error:

panic: get transaction ID ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755 failed: Flow resource not found: no known transaction with ID ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755 [recovered]
	panic: get transaction ID ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755 failed: Flow resource not found: no known transaction with ID ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755

I debug my program , it panic from the code on this line:

accountCreationTxRes := examples.WaitForSeal(ctx, flowClient, createAccountTx.ID())

I have replace my address and key in the json file:

my address is : ad25383c17a21ef7

I have upload my code below, please check

create_flow_account.zip

@nvdtf
Copy link
Member

nvdtf commented Jan 9, 2025

The Go SDK examples connect to the Emulator, so they use a local signer:

serviceAcctAddr, serviceAcctKey, serviceSigner := examples.ServiceAccount(flowClient)

You updated the example to connect to Mainnet, so you need an actual mainnet account with a private key. You can't use the emulator service account on Mainnet.

@godlovericea
Copy link
Author

I have indeed replaced it with the address and private key of the main network. In the file I uploaded above, the address and private key of the main network were exported from Flow Wallet, including the AccountKey information of the account.

@jribbink
Copy link
Contributor

jribbink commented Jan 10, 2025

It looks like the transaction sent was successful https://www.flowdiver.io/tx/ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755.

I have a feeling this just has to do with an incorrect WaitForSeal implementation in the example. The transaction may not exist yet right after it has been submitted. This implementation does not account for this factor and may prematurely error.

func WaitForSeal(ctx context.Context, c access.Client, id flow.Identifier) *flow.TransactionResult {
result, err := c.GetTransactionResult(ctx, id)
Handle(err)
fmt.Printf("Waiting for transaction %s to be sealed...\n", id)
for result.Status != flow.TransactionStatusSealed {
time.Sleep(time.Second)
fmt.Print(".")
result, err = c.GetTransactionResult(ctx, id)
Handle(err)
}
fmt.Println()
fmt.Printf("Transaction %s sealed\n", id)
return result
}

@godlovericea
Copy link
Author

godlovericea commented Jan 13, 2025

kerying_learn.zip

@jribbink Thank you, I have already created a Flow Account for a new project, but I cannot migrate my code to the existing project.
I have uploaded my code in a zip file below, along with the go.mod file. My project name is kerying_learn below ,Please help check where the incompatibility might be.

The code for create the Flow account is in the flow_test.go file under the address package, and the method is Test_Make_Flow_Address. You can run debug test to reproduce my error.

Error info:

Starting: C:\Users\Administrator\go\bin\dlv.exe dap --listen=127.0.0.1:59644 from d:\kerying_all\dev_keyring_gitee\kerying_learn\address
DAP server listening at: 127.0.0.1:59644
Build Error: go test -c -o d:\kerying_all\dev_keyring_gitee\kerying_learn\address\__debug_bin988134674.exe -gcflags all=-N -l .
# github.com/onflow/atree
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\typeinfo.go:33:15: undefined: cbor.StreamEncoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\typeinfo.go:39:16: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\encode.go:31:26: undefined: cbor.StreamEncoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\encode.go:61:16: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\array.go:273:34: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\array.go:605:12: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:454:32: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:535:39: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:588:45: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:798:52: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:798:52: too many errors (exit status 1)

@bluesign
Copy link
Contributor

bluesign commented Jan 14, 2025

@godlovericea

From Discord: ( from @SupunS )

it seems like the project has multiple cbor versions (through transitive dependencies), and picks the wrong version.
i.e: atree v0.8.1 needs cbor v2.4.*, but for some reason its picking v2.5.*
it's coming from github.com/everFinance/[email protected] --> github.com/everFinance/[email protected] --> github.com/fxamacker/cbor/[email protected]
If github.com/everFinance/arseeding is a library they own, they may have to downgrade the cbor version to v2.4.* there, and use that

@godlovericea
Copy link
Author

@bluesign Thank you, I want make a new project for Flow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

4 participants