|
|
|
@ -3,6 +3,7 @@ package services |
|
|
|
|
import ( |
|
|
|
|
"context" |
|
|
|
|
"fmt" |
|
|
|
|
"github.com/harmony-one/harmony/core/vm" |
|
|
|
|
"math/big" |
|
|
|
|
|
|
|
|
|
"github.com/coinbase/rosetta-sdk-go/server" |
|
|
|
@ -161,6 +162,43 @@ func newAccountIdentifier( |
|
|
|
|
}, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// newAccountIdentifier ..
|
|
|
|
|
func newRosettaAccountIdentifier(address *vm.RosettaLogAddressItem) (*types.AccountIdentifier, *types.Error) { |
|
|
|
|
b32Address, err := internalCommon.AddressToBech32(*address.Account) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, common.NewError(common.SanityCheckError, map[string]interface{}{ |
|
|
|
|
"message": err.Error(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
metadata, err := types.MarshalMap(AccountMetadata{Address: address.Account.String()}) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, common.NewError(common.CatchAllError, map[string]interface{}{ |
|
|
|
|
"message": err.Error(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ai := &types.AccountIdentifier{ |
|
|
|
|
Address: b32Address, |
|
|
|
|
Metadata: metadata, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if address.SubAccount != nil { |
|
|
|
|
b32Address, err := internalCommon.AddressToBech32(*address.SubAccount) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, common.NewError(common.SanityCheckError, map[string]interface{}{ |
|
|
|
|
"message": err.Error(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ai.SubAccount = &types.SubAccountIdentifier{ |
|
|
|
|
Address: b32Address, |
|
|
|
|
Metadata: address.Metadata, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ai, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func newSubAccountIdentifier( |
|
|
|
|
address ethCommon.Address, metadata map[string]interface{}, |
|
|
|
|
) (*types.SubAccountIdentifier, *types.Error) { |
|
|
|
|