[#905] morph/client: Fetch NNS hash once on init
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m19s
Pre-commit hooks / Pre-commit (push) Successful in 1m41s
Build / Build Components (push) Successful in 1m43s
Tests and linters / Run gofumpt (push) Successful in 3m38s
Tests and linters / gopls check (push) Successful in 3m41s
Tests and linters / Lint (push) Successful in 3m50s
Tests and linters / Staticcheck (push) Successful in 4m6s
Tests and linters / Tests with -race (push) Successful in 4m22s
Tests and linters / Tests (push) Successful in 4m32s
OCI image / Build container images (push) Successful in 5m0s

NNS contract hash is taken from the contract with ID=1.
Because morph client is expected to work with the same chain,
and because contract hash doesn't change on update, there is no need to
fetch it from each new endpoint.

Change-Id: Ic6dc18283789da076d6a0b3701139b97037714cc
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2025-03-21 15:40:40 +03:00 committed by Dmitrii Stepanov
parent 30099194ba
commit a4da1da767
3 changed files with 10 additions and 54 deletions

View file

@ -145,6 +145,11 @@ func New(ctx context.Context, key *keys.PrivateKey, opts ...Option) (*Client, er
if cli.client == nil {
return nil, ErrNoHealthyEndpoint
}
cs, err := cli.client.GetContractStateByID(nnsContractID)
if err != nil {
return nil, fmt.Errorf("resolve nns hash: %w", err)
}
cli.nnsHash = cs.Hash
cli.setActor(act)
go cli.closeWaiter(ctx)