[#102] nns: Add DeleteDomain
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
49e5270f67
commit
beb6a6a166
3 changed files with 42 additions and 0 deletions
|
@ -15,6 +15,7 @@ safemethods:
|
|||
- "tokens"
|
||||
- "resolve"
|
||||
- "roots"
|
||||
- "deleteDomain"
|
||||
events:
|
||||
- name: Transfer
|
||||
parameters:
|
||||
|
|
|
@ -366,6 +366,25 @@ func SetAdmin(name string, admin interop.Hash160) {
|
|||
putNameState(ctx, ns)
|
||||
}
|
||||
|
||||
func DeleteDomain(name string) {
|
||||
ctx := storage.GetContext()
|
||||
deleteDomain(ctx, name)
|
||||
}
|
||||
|
||||
func deleteDomain(ctx storage.Context, name string) {
|
||||
nameKey := append([]byte{prefixName}, getTokenKey([]byte(name))...)
|
||||
tldBytes := storage.Get(ctx, nameKey)
|
||||
if tldBytes == nil {
|
||||
return
|
||||
}
|
||||
|
||||
DeleteRecords(name, TXT)
|
||||
DeleteRecords(name, A)
|
||||
DeleteRecords(name, AAAA)
|
||||
DeleteRecords(name, CNAME)
|
||||
storage.Delete(ctx, nameKey)
|
||||
}
|
||||
|
||||
// SetRecord adds a new record of the specified type to the provided domain.
|
||||
func SetRecord(name string, typ RecordType, id byte, data string) {
|
||||
tokenID := []byte(tokenIDFromName(name))
|
||||
|
|
|
@ -121,6 +121,28 @@ func (c *Contract) AddRecordUnsigned(name string, typ *big.Int, data string) (*t
|
|||
return c.actor.MakeUnsignedCall(c.hash, "addRecord", nil, name, typ, data)
|
||||
}
|
||||
|
||||
// DeleteDomain creates a transaction invoking `deleteDomain` method of the contract.
|
||||
// This transaction is signed and immediately sent to the network.
|
||||
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||
func (c *Contract) DeleteDomain(name string) (util.Uint256, uint32, error) {
|
||||
return c.actor.SendCall(c.hash, "deleteDomain", name)
|
||||
}
|
||||
|
||||
// DeleteDomainTransaction creates a transaction invoking `deleteDomain` method of the contract.
|
||||
// This transaction is signed, but not sent to the network, instead it's
|
||||
// returned to the caller.
|
||||
func (c *Contract) DeleteDomainTransaction(name string) (*transaction.Transaction, error) {
|
||||
return c.actor.MakeCall(c.hash, "deleteDomain", name)
|
||||
}
|
||||
|
||||
// DeleteDomainUnsigned creates a transaction invoking `deleteDomain` method of the contract.
|
||||
// This transaction is not signed, it's simply returned to the caller.
|
||||
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||
func (c *Contract) DeleteDomainUnsigned(name string) (*transaction.Transaction, error) {
|
||||
return c.actor.MakeUnsignedCall(c.hash, "deleteDomain", nil, name)
|
||||
}
|
||||
|
||||
// DeleteRecords creates a transaction invoking `deleteRecords` method of the contract.
|
||||
// This transaction is signed and immediately sent to the network.
|
||||
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||
|
|
Loading…
Reference in a new issue