Skip to content

Commit

Permalink
Merge pull request #279 from multiversx/latest-libs-2023.12.22
Browse files Browse the repository at this point in the history
Latest libs 2023.12.22
  • Loading branch information
iulianpascalau authored Dec 22, 2023
2 parents 4ea5f75 + 0069390 commit 7551e1f
Show file tree
Hide file tree
Showing 25 changed files with 362 additions and 201 deletions.
4 changes: 2 additions & 2 deletions bridges/ethMultiversX/topology/topologyHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func (t *topologyHandler) MyTurnAsLeader() bool {
}

t.log.Debug(msg,
"leader", t.addressConverter.ToBech32String(leaderAddress),
"leader", t.addressConverter.ToBech32StringSilent(leaderAddress),
"index", index,
"self address", t.addressConverter.ToBech32String(t.addressBytes))
"self address", t.addressConverter.ToBech32StringSilent(t.addressBytes))

return isLeader
}
Expand Down
2 changes: 1 addition & 1 deletion clients/ethereum/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (c *client) GetBatch(ctx context.Context, nonce uint64) (*clients.TransferB
depositTransfer := &clients.DepositTransfer{
Nonce: deposit.Nonce.Uint64(),
ToBytes: toBytes,
DisplayableTo: c.addressConverter.ToBech32String(toBytes),
DisplayableTo: c.addressConverter.ToBech32StringSilent(toBytes),
FromBytes: fromBytes,
DisplayableFrom: c.addressConverter.ToHexString(fromBytes),
TokenBytes: tokenBytes,
Expand Down
6 changes: 4 additions & 2 deletions clients/ethereum/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,15 @@ func TestClient_GetBatch(t *testing.T) {
},
}

bech32Recipient1Address, _ := recipient1.AddressAsBech32String()
bech32Recipient2Address, _ := recipient2.AddressAsBech32String()
expectedBatch := &clients.TransferBatch{
ID: 112243,
Deposits: []*clients.DepositTransfer{
{
Nonce: 10,
ToBytes: recipient1.AddressBytes(),
DisplayableTo: recipient1.AddressAsBech32String(),
DisplayableTo: bech32Recipient1Address,
FromBytes: from1[:],
DisplayableFrom: hex.EncodeToString(from1[:]),
TokenBytes: token1[:],
Expand All @@ -330,7 +332,7 @@ func TestClient_GetBatch(t *testing.T) {
{
Nonce: 30,
ToBytes: recipient2.AddressBytes(),
DisplayableTo: recipient2.AddressAsBech32String(),
DisplayableTo: bech32Recipient2Address,
FromBytes: from2[:],
DisplayableFrom: hex.EncodeToString(from2[:]),
TokenBytes: token2[:],
Expand Down
15 changes: 10 additions & 5 deletions clients/multiversx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func NewClient(args ClientArgs) (*client, error) {
argNonceHandler := nonceHandlerV2.ArgsNonceTransactionsHandlerV2{
Proxy: args.Proxy,
IntervalToResend: time.Second * time.Duration(args.IntervalToResendTxsInSeconds),
Creator: &nonceHandlerV2.AddressNonceHandlerCreator{},
}
nonceTxsHandler, err := nonceHandlerV2.NewNonceTransactionHandlerV2(argNonceHandler)
if err != nil {
Expand Down Expand Up @@ -112,11 +111,16 @@ func NewClient(args ClientArgs) (*client, error) {
return nil, clients.ErrNilAddressConverter
}

bech23MultisigAddress, err := args.MultisigContractAddress.AddressAsBech32String()
if err != nil {
return nil, fmt.Errorf("%w for %x", err, args.MultisigContractAddress.AddressBytes())

Check warning on line 116 in clients/multiversx/client.go

View check run for this annotation

Codecov / codecov/patch

clients/multiversx/client.go#L116

Added line #L116 was not covered by tests
}

c := &client{
txHandler: &transactionHandler{
proxy: args.Proxy,
relayerAddress: relayerAddress,
multisigAddressAsBech32: args.MultisigContractAddress.AddressAsBech32String(),
multisigAddressAsBech32: bech23MultisigAddress,
nonceTxHandler: nonceTxsHandler,
relayerPrivateKey: args.RelayerPrivateKey,
singleSigner: &singlesig.Ed25519Signer{},
Expand All @@ -134,9 +138,10 @@ func NewClient(args ClientArgs) (*client, error) {
allowDelta: args.AllowDelta,
}

bech32RelayerAddress, _ := relayerAddress.AddressAsBech32String()
c.log.Info("NewMultiversXClient",
"relayer address", relayerAddress.AddressAsBech32String(),
"safe contract address", args.MultisigContractAddress.AddressAsBech32String())
"relayer address", bech32RelayerAddress,
"safe contract address", bech23MultisigAddress)

return c, nil
}
Expand Down Expand Up @@ -237,7 +242,7 @@ func (c *client) createPendingBatchFromResponse(ctx context.Context, responseDat
deposit := &clients.DepositTransfer{
Nonce: depositNonce,
FromBytes: responseData[i+2],
DisplayableFrom: c.addressPublicKeyConverter.ToBech32String(responseData[i+2]),
DisplayableFrom: c.addressPublicKeyConverter.ToBech32StringSilent(responseData[i+2]),
ToBytes: responseData[i+3],
DisplayableTo: c.addressPublicKeyConverter.ToHexStringWithPrefix(responseData[i+3]),
TokenBytes: responseData[i+4],
Expand Down
32 changes: 19 additions & 13 deletions clients/multiversx/mxClientDataGetter.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ type ArgsMXClientDataGetter struct {
}

type mxClientDataGetter struct {
multisigContractAddress core.AddressHandler
relayerAddress core.AddressHandler
proxy Proxy
log logger.Logger
mutNodeStatus sync.Mutex
wasShardIDFetched bool
shardID uint32
multisigContractAddress core.AddressHandler
bech32MultisigContractAddress string
relayerAddress core.AddressHandler
proxy Proxy
log logger.Logger
mutNodeStatus sync.Mutex
wasShardIDFetched bool
shardID uint32
}

// NewMXClientDataGetter creates a new instance of the dataGetter type
Expand All @@ -67,12 +68,17 @@ func NewMXClientDataGetter(args ArgsMXClientDataGetter) (*mxClientDataGetter, er
if check.IfNil(args.MultisigContractAddress) {
return nil, fmt.Errorf("%w for the MultisigContractAddress argument", errNilAddressHandler)
}
bech32Address, err := args.MultisigContractAddress.AddressAsBech32String()
if err != nil {
return nil, fmt.Errorf("%w for %x", err, args.MultisigContractAddress.AddressBytes())

Check warning on line 73 in clients/multiversx/mxClientDataGetter.go

View check run for this annotation

Codecov / codecov/patch

clients/multiversx/mxClientDataGetter.go#L73

Added line #L73 was not covered by tests
}

return &mxClientDataGetter{
multisigContractAddress: args.MultisigContractAddress,
relayerAddress: args.RelayerAddress,
proxy: args.Proxy,
log: args.Log,
multisigContractAddress: args.MultisigContractAddress,
bech32MultisigContractAddress: bech32Address,
relayerAddress: args.RelayerAddress,
proxy: args.Proxy,
log: args.Log,
}, nil
}

Expand Down Expand Up @@ -131,7 +137,7 @@ func (dataGetter *mxClientDataGetter) getShardID(ctx context.Context) (uint32, e
}

var err error
dataGetter.shardID, err = dataGetter.proxy.GetShardOfAddress(ctx, dataGetter.multisigContractAddress.AddressAsBech32String())
dataGetter.shardID, err = dataGetter.proxy.GetShardOfAddress(ctx, dataGetter.bech32MultisigContractAddress)
if err == nil {
dataGetter.wasShardIDFetched = true
}
Expand Down Expand Up @@ -327,7 +333,7 @@ func (dataGetter *mxClientDataGetter) GetTransactionsStatuses(ctx context.Contex
return nil, fmt.Errorf("%w for batch ID %v", errNoStatusForBatchID, batchID)
}

isFinished, err := dataGetter.parseBool(values[0], getStatusesAfterExecutionFuncName, dataGetter.multisigContractAddress.AddressAsBech32String())
isFinished, err := dataGetter.parseBool(values[0], getStatusesAfterExecutionFuncName, dataGetter.bech32MultisigContractAddress)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 7551e1f

Please sign in to comment.