forked from cerc-io/laconic-sdk
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6a37ac419 | ||
|
|
80348594f8 | ||
|
|
55675c7b55 | ||
|
|
10d58ca028 | ||
|
|
95bdacb4a1 |
@@ -1,4 +1,3 @@
|
||||
node_modules
|
||||
dist
|
||||
.env
|
||||
.idea/
|
||||
@@ -57,7 +57,7 @@ Follow these steps to run the tests:
|
||||
- In laconicd repo run:
|
||||
|
||||
```bash
|
||||
TEST_NAMESERVICE_EXPIRY=true ./init.sh
|
||||
TEST_REGISTRY_EXPIRY=true ./init.sh
|
||||
```
|
||||
|
||||
- Export the private key and change it in `.env` file again using:
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/laconic-sdk",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"repository": "git@github.com:cerc-io/laconic-sdk.git",
|
||||
|
||||
@@ -75,10 +75,12 @@ export const parseMsgSetRecordResponse = (data: string) => {
|
||||
const responseBytes = Buffer.from(data, 'hex')
|
||||
|
||||
// TODO: Decode response using protobuf.
|
||||
// const msgSetRecordResponse = registryTx.vulcanize.registry.v1beta1.MsgSetRecordResponse.deserialize(responseBytes);
|
||||
// const msgSetRecordResponse = nameserviceTx.vulcanize.nameservice.v1beta1.MsgSetRecordResponse.deserialize(responseBytes);
|
||||
// return msgSetRecordResponse.toObject();
|
||||
|
||||
// Workaround as proto based decoding is not working.
|
||||
const [_, id] = responseBytes.toString().split(';')
|
||||
|
||||
return { id }
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,6 @@ const namingTests = () => {
|
||||
|
||||
const records = await registry.lookupNames([crn], true);
|
||||
expect(records).toBeDefined();
|
||||
expect(records).toBeDefined();
|
||||
expect(records).toHaveLength(1);
|
||||
|
||||
const [{ latest }] = records;
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ const utilTests = () => {
|
||||
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
|
||||
|
||||
// Create watcher.
|
||||
watcher = await getBaseConfig(WATCHER_YML_PATH); //this overwrites version to 0.0.1
|
||||
watcher = await getBaseConfig(WATCHER_YML_PATH);
|
||||
const result = await registry.setRecord(
|
||||
{
|
||||
privateKey,
|
||||
|
||||
+1
-17
@@ -2,8 +2,6 @@ import * as Block from 'multiformats/block'
|
||||
import { sha256 as hasher } from 'multiformats/hashes/sha2'
|
||||
import * as dagCBOR from '@ipld/dag-cbor'
|
||||
import * as dagJSON from '@ipld/dag-json'
|
||||
//import { CID } from 'multiformats/cid'
|
||||
//import * as json from 'multiformats/codecs/json'
|
||||
|
||||
/**
|
||||
* Utils
|
||||
@@ -88,29 +86,15 @@ export class Util {
|
||||
* Get record content ID.
|
||||
*/
|
||||
static async getContentId(record: any) {
|
||||
//this encode/decode does nothing, afaict
|
||||
const serialized = dagJSON.encode(record)
|
||||
const recordData = dagJSON.decode(serialized)
|
||||
//these are for version 0.0.1 of watcher.yml test data:
|
||||
//const dside = {"build_artifact_cid":"QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9","repo_registration_record_cid":"QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D","tls_cert_cid":"QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR","type":"WebsiteRegistrationRecord","url":"https://cerc.io","version":"0.0.1"}
|
||||
//bafyreiek4hnoqmits66bjyxswapplweuoqe4en2ux6u772o4y3askpd3ny is the CBOR encoding w/ sha 256 hasher
|
||||
//bafyreifalhff7dp6o4hd573b5zdbbnl2wml5q2nrms474lrzp7dgptwxkm is expected DAG-CBOR w/ sha 256 hasher
|
||||
//bafyreihpfkdvib5muloxlj5b3tgdwibjdcu3zdsuhyft33z7gtgnlzlkpm is CBOR??? encoding of empty json payload.
|
||||
|
||||
const block = await Block.encode({
|
||||
value: recordData,
|
||||
codec: dagCBOR,
|
||||
hasher
|
||||
})
|
||||
|
||||
//manual CID construction
|
||||
//const dbytes = dagCBOR.encode(dside)
|
||||
//console.log("BYTES: " + dbytes)
|
||||
//const hash = await hasher.digest(dbytes)
|
||||
//console.log("HASH: " + hash)
|
||||
//const cid = CID.create(1, dagCBOR.code, hash)
|
||||
|
||||
//console.log("TEST CID: " + cid.toString())
|
||||
|
||||
return block.cid.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user