Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add RPC API #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 227 additions & 0 deletions btcjson/wormholecmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,216 @@ func NewWhcGetFrozenBalanceForAddressCmd(address string) *WhcGetFrozenBalanceFor
}
}

//whc_getERC721PropertyNews
type WhcGetERC721PropertyNewsCmd struct {
PropertyId string
}

func NewWhcGetERC721PropertyNewsCmd(propertyId string) *WhcGetERC721PropertyNewsCmd{
return &WhcGetERC721PropertyNewsCmd{
PropertyId:propertyId,
}
}

//whc_getERC721PropertyDestroyTokens
type WhcGetERC721PropertyDestoryTokensCmd struct {
PropertyId string
}

func NewWhcGetERC721PropertyDestoryTokensCmd(propertyId string) *WhcGetERC721PropertyDestoryTokensCmd{
return &WhcGetERC721PropertyDestoryTokensCmd{
PropertyId:propertyId,
}
}

//whc_getERC721TokenNews
type WhcGetERC721TokenNewsCmd struct {
PropertyId string
TokenId string
}

func NewWhcGetERC721TokenNewsCmd(propertyId, tokenId string) *WhcGetERC721TokenNewsCmd{
return &WhcGetERC721TokenNewsCmd{
PropertyId:propertyId,
TokenId:tokenId,
}
}

//whc_getERC721AddressTokens
type WhcGetERC721AddressTokensCmd struct {
Address string
PropertyId string
}
func NewWhcGetERC721AddressTokensCmd(address string, id string) *WhcGetERC721AddressTokensCmd{
return &WhcGetERC721AddressTokensCmd{
Address:address,
PropertyId:id,
}
}

//whc_ownerOfERC721Token
type WhcOwnerOfERC721TokenCmd struct {
PropertyId string
TokenId string
Address string
}

func NewWhcOwnerOfERC721TokenCmd ( propertyId,tokenId string,address string,) *WhcOwnerOfERC721TokenCmd{
return &WhcOwnerOfERC721TokenCmd{
PropertyId:propertyId,
TokenId:tokenId,
Address:address,
}

}

//whc_listERC721PropertyTokens
type WhcListERC721PropertyTokensCmd struct {
Propertyid string
}

func NewWhcListERC721PropertyTokensCmd (propertyId string) *WhcListERC721PropertyTokensCmd {
return &WhcListERC721PropertyTokensCmd{
Propertyid:propertyId,
}
}

//whc_issuanceERC721property
type WhcIssuanceERC721PropertyCmd struct {
IssueAddress string
Name string
Symbol string
Data string
Url string
TotalNumber string
}

func NewWhcIssuanceERC721PropertyCmd(issueAddress, name, symbol, data, url,totalNumber string) *WhcIssuanceERC721PropertyCmd{
return &WhcIssuanceERC721PropertyCmd{
IssueAddress:issueAddress,
Name:name,
Symbol:symbol,
Data:data,
Url:url,
TotalNumber:totalNumber,
}
}

//whc_transferERC721Token
type WhcTransferERC721TokenCmd struct {
OwnerAddress string
ReceiveAddress string
PropertyID string
TokenID string
}

func NewWhcTransferERC721TokenCmd(ownerAddress, receiveAddress string, propertyId, tokenId string) *WhcTransferERC721TokenCmd{
return &WhcTransferERC721TokenCmd{
OwnerAddress:ownerAddress,
ReceiveAddress:receiveAddress,
PropertyID:propertyId,
TokenID:tokenId,
}
}

//whc_destroyERC721Token
type WhcDestoryERC721TokenCmd struct {
OwnerAddress string
PropertyID string
TokenID string
}

func NewWhcDestoryERC721TokenCmd(ownerAddress string, propertyId,tokenId string) *WhcDestoryERC721TokenCmd{
return &WhcDestoryERC721TokenCmd{
OwnerAddress:ownerAddress,
PropertyID:propertyId,
TokenID:tokenId,
}
}

//whc_issuanceERC721Token
type WhcIssuanceERC721TokenCmd struct {
IssueAddress string
ReceiveAddress string
PropertyID string
TokenID string
TokenAttributes string
TokenUrl string
}
func NewWhcIssuanceERC721TokenCmd (issueAddress, receiveAddress, propertyId, tokenId, tokenAttributes, tokenUrl string) *WhcIssuanceERC721TokenCmd{
return &WhcIssuanceERC721TokenCmd{
IssueAddress:issueAddress,
ReceiveAddress:receiveAddress,
PropertyID:propertyId,
TokenID:tokenId,
TokenAttributes:tokenAttributes,
TokenUrl:tokenUrl,
}
}

//whc_createpayload_issueERC721property
type WhcCreatePayloadIssueERC721PropertyCmd struct {
Name string
Symbol string
Data string
Url string
TotalNumber string
}

func NewWhcCreatePayloadIssueERC721PropertyCmd(name, symbol, data, url, total string) *WhcCreatePayloadIssueERC721PropertyCmd {
return &WhcCreatePayloadIssueERC721PropertyCmd{
Name: name,
Symbol:symbol,
Data:data,
Url: url,
TotalNumber:total,
}
}

//whc_createpayload_issueERC721token
type WhcCreatePayloadIssueERC721TokenCmd struct{
PropertyId string
TokenId string
TokenAttributes string
TokenUrl string
}

func NewWhcCreatePayloadIssueERC721TokenCmd(propertyId, tokenId string, tokenAttributes, tokenUrl string) *WhcCreatePayloadIssueERC721TokenCmd{
return &WhcCreatePayloadIssueERC721TokenCmd{
PropertyId:propertyId,
TokenId:tokenId,
TokenAttributes:tokenAttributes,
TokenUrl:tokenUrl,
}
}

//whc_createpayload_transferERC721token
type WhcCreatePayloadTransferERC721TokenCmd struct {
PropertyId string
TokenId string
}

func NewWhcCreatePayloadTransferERC721TokenCmd(propertyId, tokenId string) *WhcCreatePayloadTransferERC721TokenCmd{
return &WhcCreatePayloadTransferERC721TokenCmd{
PropertyId:propertyId,
TokenId:tokenId,
}
}

//whc_createpayload_destroyERC721token
type WhcCreatePayloadDestoryERC721TokenCmd struct {
PropertyId string
TokenId string
}

func NewWhcCreatePayloadDestoryERC721TokenCmd(propertyId, tokenId string) *WhcCreatePayloadDestoryERC721TokenCmd{
return &WhcCreatePayloadDestoryERC721TokenCmd{
PropertyId:propertyId,
TokenId:tokenId,
}
}


func init() {
// No special flags for commands in this file.
flags := UsageFlag(0)
Expand Down Expand Up @@ -887,4 +1097,21 @@ func init() {
MustRegisterCmd("whc_getfrozenbalance", (*GetFrozenBalanceCmd)(nil), flags)
MustRegisterCmd("whc_getfrozenbalanceforid", (*WhcGetFrozenBalanceForIdCmd)(nil), flags)
MustRegisterCmd("whc_getfrozenbalanceforaddress", (*WhcGetFrozenBalanceForAddressCmd)(nil), flags)
MustRegisterCmd("whc_getERC721AddressTokens", (*WhcGetERC721AddressTokensCmd)(nil), flags)
MustRegisterCmd("whc_getERC721PropertyDestroyTokens", (*WhcGetERC721PropertyDestoryTokensCmd)(nil), flags)
MustRegisterCmd("whc_ownerOfERC721Token", (*WhcOwnerOfERC721TokenCmd)(nil), flags)
MustRegisterCmd("whc_listERC721PropertyTokens", (*WhcListERC721PropertyTokensCmd)(nil), flags)
MustRegisterCmd("whc_getERC721PropertyNews", (*WhcGetERC721PropertyNewsCmd)(nil), flags)
MustRegisterCmd("whc_getERC721TokenNews", (*WhcGetERC721TokenNewsCmd)(nil), flags)
MustRegisterCmd("whc_issuanceERC721property", (*WhcIssuanceERC721PropertyCmd)(nil), flags)
MustRegisterCmd("whc_transferERC721Token", (*WhcTransferERC721TokenCmd)(nil), flags)
MustRegisterCmd("whc_destroyERC721Token", (*WhcDestoryERC721TokenCmd)(nil), flags)
MustRegisterCmd("whc_issuanceERC721Token", (*WhcIssuanceERC721TokenCmd)(nil), flags)
MustRegisterCmd("whc_createpayload_issueERC721property", (*WhcCreatePayloadIssueERC721PropertyCmd)(nil), flags)
MustRegisterCmd("whc_createpayload_issueERC721token", (*WhcCreatePayloadIssueERC721TokenCmd)(nil), flags)
MustRegisterCmd("whc_createpayload_transferERC721token", (*WhcCreatePayloadTransferERC721TokenCmd)(nil), flags)
MustRegisterCmd("whc_createpayload_destroyERC721token", (*WhcCreatePayloadDestoryERC721TokenCmd)(nil), flags)



}
49 changes: 49 additions & 0 deletions btcjson/wormholeresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,52 @@ type FrozenBalanceResult struct {
Address *string `json:"address"`
PropertyID *int64 `json:"propertyid,omitempty"`
}

type ERC721AddressTokensResult struct {
TokenId string `json:"tokenid"`
Attribute string `json:"attribute"`
TokenUrl string `json:"tokenurl"`
Txid string `json:"creationtxid"`
}

type OwnerOfERC721TokenResult struct {
Own bool `json:"own"`
}

type WhcListERC721PropertyTokensResult struct {
TokenId string `json:"tokenid"`
Owner string `json:"owner"`
}

type WhcGetERC721PropertyNewsResult struct {
PropertyId string `json:"propertyid"`
Owner string `json:"owner"`
CreationTxid string `json:"creationtxid"`
CreationBlock string `json:"creationblock"`
Attribute string `json:"attribute"`
TokenUrl string `json:"tokenurl"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Data string `json:"data"`
PropertyUrl string `json:"propertyurl"`
TotalTokenNumber int `json:"totalTokenNumber"`
HaveIssuedNumber int `json:"haveIssuedNumber"`
CurrentValidIssuedNumer int `json:"currentValidIssuedNumer"`
}

type WhcGetERC721TokenNewsResult struct {
PropertyId string `json:"propertyid"`
TokenId string `json:"tokenid"`
Owner string `json:"owner"`
CreationTxid string `json:"creationtxid"`
CreationBlock string `json:"creationblock"`
Attribute string `json:"attribute"`
TokenUrl string `json:"tokenurl"`
}

type WhcGetERC721PropertyDestoryTokensResult struct {
TokenId int64 `json:"tokenid"`
Attribute string `json:"attribute"`
TokenUrl string `json:"tokenurl"`
CreationTxid string `json:"creationtxid"`
}
97 changes: 97 additions & 0 deletions doc/create-transaction-payload.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,100 @@ client. WhcCreatePayloadUnFreeze("bchreg:qzrck6dmz5lgs7v87dr5lp4g56aldg9knucnuqy
// result:
0000004600000022
```
##### `whc_createpayload_destroyERC721token`

Creates the payload to destroy ERC721 token

**Arguments**

- propertyId `string`The token within the property that will be destroy
- tokenId`string`The tokenid that will be destroy

**Result**

- `hash`the hex-encoded transaction hash

**Examples**

```go
//request
rpc.NewRPCInstance().WhcGetERC721PropertyDestoryTokens("9")

//result
000000090407000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000
```

##### `whc_createpayload_issueERC721property`

Creates the payload to issue ERC721 property.

**Argument**

- name `string` required:the name of created property
- symbol`string`required:the symbol of created property
- data`string`required:the Data of created property
- url`string`required:the URL of created property
- totalNumber`string`required:the number of token that created property will issued in the future

**Result**

- `payload`the hex-encoded payload

**Examples**

```go
//request
rpc.NewRPCInstance().WhcCreatePayloadIssueERC721Property("payload1","pp","data","url","5")
//result
00000009017061796c6f61643100707000646174610075726c000000000000000005
```

##### `whc_createpayload_issueERC721token`

Creates the payload to issue ERC721 token.

**Argument**

- propertyId `string` required:The ID of the special property that will be issued token
- tokenId`string`required:The tokenID that will be issued
- tokenAttributes`string`required:The Attributes of the new created token
- tokenURL`string`required:The URL of the new created token

**Result**

- `payload` the hex-encoded payload

**Examples**

```go
//request
rpc.NewRPCInstance().WhcCreatePayloadIssueERC721Token("6","6","0000E","SDF")

//result
0000000902060000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000053444600
```

##### `whc_createpayload_transferERC721token`

Creates the payload to transfer ERC721 token.

**Arguments**

- propertyId `string`required:The propertyid within the token that will be transfer
- tokenId`string`required:The tokenid that will be transfer

**Result**

- `hash`the hex-encoded transaction hash

**Examples**

```go
//request
rpc.NewRPCInstance().WhcCreatePayloadTransferERC721Token("7","1")

//result
000000090307000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000
```

#####
Loading