forked from cerc-io/laconic-sdk
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42230659c1 |
@@ -1,3 +1,4 @@
|
||||
node_modules
|
||||
dist
|
||||
.env
|
||||
.idea/
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/laconic-sdk",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.4",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"repository": "git@github.com:cerc-io/laconic-sdk.git",
|
||||
|
||||
@@ -75,12 +75,10 @@ export const parseMsgSetRecordResponse = (data: string) => {
|
||||
const responseBytes = Buffer.from(data, 'hex')
|
||||
|
||||
// TODO: Decode response using protobuf.
|
||||
// const msgSetRecordResponse = nameserviceTx.vulcanize.nameservice.v1beta1.MsgSetRecordResponse.deserialize(responseBytes);
|
||||
// const msgSetRecordResponse = registryTx.vulcanize.registry.v1beta1.MsgSetRecordResponse.deserialize(responseBytes);
|
||||
// return msgSetRecordResponse.toObject();
|
||||
|
||||
// Workaround as proto based decoding is not working.
|
||||
const [_, id] = responseBytes.toString().split(';')
|
||||
|
||||
return { id }
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ const nameserviceExpiryTests = () => {
|
||||
fee
|
||||
)
|
||||
|
||||
const [record] = await registry.queryRecords({ type: watcher.record.type, version: watcher.record.version }, true);
|
||||
const [record] = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
|
||||
recordExpiryTime = new Date(record.expiryTime);
|
||||
|
||||
const [bond] = await registry.getBondsByIds([bondId]);
|
||||
@@ -63,7 +63,7 @@ const nameserviceExpiryTests = () => {
|
||||
});
|
||||
|
||||
test('Check record expiry time', async() => {
|
||||
const [record] = await registry.queryRecords({ type: watcher.record.type, version: watcher.record.version }, true);
|
||||
const [record] = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
|
||||
const updatedExpiryTime = new Date(record.expiryTime);
|
||||
expect(updatedExpiryTime.getTime()).toBeGreaterThan(recordExpiryTime.getTime());
|
||||
recordExpiryTime = updatedExpiryTime;
|
||||
@@ -87,7 +87,7 @@ const nameserviceExpiryTests = () => {
|
||||
});
|
||||
|
||||
test('Check record deleted without bond balance', async() => {
|
||||
const records = await registry.queryRecords({ type: watcher.record.type, version: watcher.record.version }, true);
|
||||
const records = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
|
||||
expect(records).toHaveLength(0);
|
||||
})
|
||||
|
||||
|
||||
@@ -244,6 +244,7 @@ const namingTests = () => {
|
||||
|
||||
const records = await registry.lookupNames([crn], true);
|
||||
expect(records).toBeDefined();
|
||||
expect(records).toBeDefined();
|
||||
expect(records).toHaveLength(1);
|
||||
|
||||
const [{ latest }] = records;
|
||||
|
||||
@@ -4,4 +4,4 @@ record:
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.18
|
||||
version: 1.0.17
|
||||
|
||||
+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);
|
||||
watcher = await getBaseConfig(WATCHER_YML_PATH); //this overwrites version to 0.0.1
|
||||
const result = await registry.setRecord(
|
||||
{
|
||||
privateKey,
|
||||
|
||||
+17
-1
@@ -2,6 +2,8 @@ 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
|
||||
@@ -86,15 +88,29 @@ 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