Skip to content

Commit

Permalink
feat: helper functions for NameTransferTx, NameRevokeTx
Browse files Browse the repository at this point in the history
  • Loading branch information
randomshinichi committed May 27, 2019
1 parent 14fa242 commit 4f5ba90
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion aeternity/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,38 @@ func (n *Aens) NameUpdateTx(name string, targetAddress string) (tx NameUpdateTx,
if err != nil {
return NameUpdateTx{}, err
}
// create and sign the transaction
// create the transaction
tx = NewNameUpdateTx(n.owner.Address, encodedNameHash, []string{targetAddress}, absNameTTL, Config.Client.Names.ClientTTL, Config.Client.Names.UpdateFee, txTTL, accountNonce)

return
}

// NameTransferTx transfer a name to another owner
func (n *Aens) NameTransferTx(name string, recipientAddress string) (tx NameTransferTx, err error) {
txTTL, accountNonce, err := getTTLNonce(n.nodeClient, n.owner.Address, Config.Client.TTL)
if err != nil {
return
}

encodedNameHash := Encode(PrefixName, Namehash(name))

tx = NewNameTransferTx(n.owner.Address, encodedNameHash, recipientAddress, Config.Client.Fee, txTTL, accountNonce)
return
}

// NameRevokeTx revoke a name
func (n *Aens) NameRevokeTx(name string, recipientAddress string) (tx NameRevokeTx, err error) {
txTTL, accountNonce, err := getTTLNonce(n.nodeClient, n.owner.Address, Config.Client.TTL)
if err != nil {
return
}

encodedNameHash := Encode(PrefixName, Namehash(name))

tx = NewNameRevokeTx(n.owner.Address, encodedNameHash, Config.Client.Fee, txTTL, accountNonce)
return
}

// OracleRegisterTx create a new oracle
func (o *Oracle) OracleRegisterTx(querySpec, responseSpec string, queryFee utils.BigInt, oracleTTLType, oracleTTLValue, abiVersion uint64, vmVersion uint64) (tx OracleRegisterTx, err error) {
ttl, nonce, err := getTTLNonce(o.nodeClient, o.owner.Address, Config.Client.TTL)
Expand Down

0 comments on commit 4f5ba90

Please sign in to comment.