feat(ens-usernames)_: preparing release transaction data

This commit is contained in:
Sale Djenic 2023-11-29 12:34:16 +01:00 committed by saledjenic
parent adb79c5a82
commit 5e6768a42a
2 changed files with 33 additions and 1 deletions

View File

@ -1 +1 @@
0.171.23
0.171.24

View File

@ -374,6 +374,38 @@ func (api *API) Release(ctx context.Context, chainID uint64, txArgs transactions
return tx.Hash().String(), nil
}
func (api *API) ReleasePrepareTxCallMsg(ctx context.Context, chainID uint64, txArgs transactions.SendTxArgs, username string) (ethereum.CallMsg, error) {
registrarABI, err := abi.JSON(strings.NewReader(registrar.UsernameRegistrarABI))
if err != nil {
return ethereum.CallMsg{}, err
}
data, err := registrarABI.Pack("release", usernameToLabel(username))
if err != nil {
return ethereum.CallMsg{}, err
}
sntAddress, err := snt.ContractAddress(chainID)
if err != nil {
return ethereum.CallMsg{}, err
}
return ethereum.CallMsg{
From: common.Address(txArgs.From),
To: &sntAddress,
Value: big.NewInt(0),
Data: data,
}, nil
}
func (api *API) ReleasePrepareTx(ctx context.Context, chainID uint64, txArgs transactions.SendTxArgs, username string) (interface{}, error) {
callMsg, err := api.ReleasePrepareTxCallMsg(ctx, chainID, txArgs, username)
if err != nil {
return nil, err
}
return toCallArg(callMsg), nil
}
func (api *API) ReleaseEstimate(ctx context.Context, chainID uint64, txArgs transactions.SendTxArgs, username string) (uint64, error) {
registrarABI, err := abi.JSON(strings.NewReader(registrar.UsernameRegistrarABI))
if err != nil {