Skip to content

Commit

Permalink
Merge pull request #2 from PhyrexTsai/master
Browse files Browse the repository at this point in the history
Add PayloadCreation
  • Loading branch information
PhyrexTsai authored Oct 4, 2018
2 parents 35b71f2 + f21d349 commit e52fe02
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 6 deletions.
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Creates a transaction to set address with BCNS.
```javascript
(async () => {
try {
const register = await bcns.DataWrite.register("portalnetwork", "bchtest:qzfklzftxegmm48cms8ha99dem3mz0gheysqgfvuex", "[email protected]")
const register = await bcns.DataWrite.address("portalnetwork", "bchtest:qzfklzftxegmm48cms8ha99dem3mz0gheysqgfvuex", "[email protected]")
console.log(register);
} catch (error) {
console.error(error)
Expand All @@ -149,7 +149,7 @@ Creates a transaction to set multihash with BCNS.
```javascript
(async () => {
try {
const register = await bcns.DataWrite.register("portalnetwork", "QmSpuwejUGjREmgsvm8eq3ZdsS7mVTHCRPZmLiUq84S9x8", "[email protected]")
const register = await bcns.DataWrite.multihash("portalnetwork", "QmSpuwejUGjREmgsvm8eq3ZdsS7mVTHCRPZmLiUq84S9x8", "[email protected]")
console.log(register);
} catch (error) {
console.error(error)
Expand All @@ -165,3 +165,64 @@ Creates a transaction to set multihash with BCNS.
}
```

## PayloadCreation

### Register
Return the payload of register.

#### Example
```javascript
(async () => {
try {
const register = await bcns.PayloadCreation.register("bitcoincash", "bchtest:qzfklzftxegmm48cms8ha99dem3mz0gheysqgfvuex")
console.log(register);
} catch (error) {
console.error(error)
}
})()
```

#### Result
```javascript
"000001f4626974636f696e6361736800626368746573743a7171326a3967703937676d3961366c7776687863347a7532387176716d3078346a356537327637656a6700"
```

### SetAddress
Return the payload of set address.

#### Example
```javascript
(async () => {
try {
const register = await bcns.PayloadCreation.address("bitcoincash", "bchtest:qzfklzftxegmm48cms8ha99dem3mz0gheysqgfvuex")
console.log(register);
} catch (error) {
console.error(error)
}
})()
```

#### Result
```javascript
"00000212706f7274616c6e6574776f726b00626368746573743a717a666b6c7a66747865676d6d3438636d73386861393964656d336d7a3067686579737167667675657800"
```

### SetMultihash
Return the payload of set multihash.

#### Example
```javascript
(async () => {
try {
const register = await bcns.PayloadCreation.multihash("bitcoincash", "QmSpuwejUGjREmgsvm8eq3ZdsS7mVTHCRPZmLiUq84S9x8")
console.log(register);
} catch (error) {
console.error(error)
}
})()
```

#### Result
```javascript
"00000213626974636f696e6361736800516d53707577656a55476a52456d6773766d386571335a647353376d5654484352505a6d4c69557138345339783800"
```
4 changes: 2 additions & 2 deletions lib/PayloadCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var PayloadCreation = function () {
key: "resolutionAddress",
value: async function resolutionAddress(domain, address) {
try {
var response = await _axios2.default.post(this.restURL + "payloadCreation/BCNS/resolution/address/" + domain + "/" + address);
var response = await _axios2.default.post(this.restURL + "payloadCreation/BCNS/address/" + domain + "/" + address);
return response.data;
} catch (error) {
throw error.response.data;
Expand All @@ -65,7 +65,7 @@ var PayloadCreation = function () {
key: "resolutionMultihash",
value: async function resolutionMultihash(domain, protocol, multihash) {
try {
var response = await _axios2.default.post(this.restURL + "payloadCreation/BCNS/resolution/multihash/" + domain + "/" + protocol + "/" + multihash);
var response = await _axios2.default.post(this.restURL + "payloadCreation/BCNS/multihash/" + domain + "/" + protocol + "/" + multihash);
return response.data;
} catch (error) {
throw error.response.data;
Expand Down
4 changes: 2 additions & 2 deletions src/PayloadCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PayloadCreation {
async resolutionAddress(domain, address) {
try {
let response = await axios.post(
`${this.restURL}payloadCreation/BCNS/resolution/address/${domain}/${address}`
`${this.restURL}payloadCreation/BCNS/address/${domain}/${address}`
)
return response.data
} catch (error) {
Expand All @@ -53,7 +53,7 @@ class PayloadCreation {
async resolutionMultihash(domain, protocol, multihash) {
try {
let response = await axios.post(
`${this.restURL}payloadCreation/BCNS/resolution/multihash/${domain}/${protocol}/${multihash}`
`${this.restURL}payloadCreation/BCNS/multihash/${domain}/${protocol}/${multihash}`
)
return response.data
} catch (error) {
Expand Down

0 comments on commit e52fe02

Please sign in to comment.