diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index ed63457..056bb47 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -14,11 +14,3 @@ Run following scripts when [proto files](./proto/) are updated. ```bash ./scripts/proto-gen.sh ``` - -3. Remove GRPC code from generated code - - ```bash - ./scripts/remove-grpc.sh - ``` - - Reference: https://github.com/tharsis/evmosjs/tree/main/packages/proto#note diff --git a/scripts/proto-gen.sh b/scripts/proto-gen.sh index d3c9060..e5fd389 100755 --- a/scripts/proto-gen.sh +++ b/scripts/proto-gen.sh @@ -23,6 +23,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then fi echo "Removing gRPC references..." +# https://github.com/tharsis/evmosjs/tree/main/packages/proto#note for file in $(find $REPO_ROOT/src/proto -type f) do diff --git a/src/bond.test.ts b/src/bond.test.ts index 2b7f93c..cfb4e99 100644 --- a/src/bond.test.ts +++ b/src/bond.test.ts @@ -97,17 +97,17 @@ const bondTests = () => { // Create a new record. version1 = await publishNewWatcherVersion(bondId1); - let [record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true); + let [record1] = await registry.queryRecords({ type: watcher.record.type, version: version1 }, true); expect(record1.bondId).toBe(bondId1); // Dissociate record, query and confirm. await registry.dissociateBond({ recordId: record1.id }, privateKey, fee); - [record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true); + [record1] = await registry.queryRecords({ type: watcher.record.type, version: version1 }, true); expect(record1.bondId).toBe(''); // Associate record with bond, query and confirm. await registry.associateBond({ recordId: record1.id, bondId: bondId1 }, privateKey, fee); - [record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true); + [record1] = await registry.queryRecords({ type: watcher.record.type, version: version1 }, true); expect(record1.bondId).toBe(bondId1); }); @@ -117,9 +117,9 @@ const bondTests = () => { // Check version1, version2 as associated with bondId1. let records; - records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true); + records = await registry.queryRecords({ type: watcher.record.type, version: version1 }, true); expect(records[0].bondId).toBe(bondId1); - records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true); + records = await registry.queryRecords({ type: watcher.record.type, version: version2 }, true); expect(records[0].bondId).toBe(bondId1); // Create another bond. @@ -131,16 +131,16 @@ const bondTests = () => { // Reassociate records from bondId1 to bondId2, verify change. await registry.reassociateRecords({ oldBondId: bondId1, newBondId: bondId2 }, privateKey, fee); - records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true); + records = await registry.queryRecords({ type: watcher.record.type, version: version1 }, true); expect(records[0].bondId).toBe(bondId2); - records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true); + records = await registry.queryRecords({ type: watcher.record.type, version: version2 }, true); expect(records[0].bondId).toBe(bondId2); // Dissociate all records from bond, verify change. await registry.dissociateRecords({ bondId: bondId2 }, privateKey, fee); - records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true); + records = await registry.queryRecords({ type: watcher.record.type, version: version1 }, true); expect(records[0].bondId).toBe(''); - records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true); + records = await registry.queryRecords({ type: watcher.record.type, version: version2 }, true); expect(records[0].bondId).toBe(''); }); }; diff --git a/src/sdk.test.ts b/src/sdk.test.ts index b366c6b..56ce747 100644 --- a/src/sdk.test.ts +++ b/src/sdk.test.ts @@ -55,7 +55,7 @@ describe('Querying', () => { test('Query records by attributes.', async () => { const { version, url } = watcher.record; - const records = await registry.queryRecords({ version, url }, true); + const records = await registry.queryRecords({ version, url, type: undefined }, true); expect(records.length).toBe(1); [ watcher ] = records; diff --git a/src/util.ts b/src/util.ts index 93f6ce6..c42b444 100644 --- a/src/util.ts +++ b/src/util.ts @@ -35,7 +35,11 @@ export class Util { static toGQLAttributes(obj: any) { const vars: any[] = []; Object.keys(obj).forEach(key => { - vars.push({ key, value: this.toGQLValue(obj[key]) }); + const value = this.toGQLValue(obj[key]); + + if (value !== undefined) { + vars.push({ key, value }); + } }); return vars; } @@ -61,6 +65,8 @@ export class Util { return { 'array': obj }; } return { 'map': obj }; + case 'undefined': + return undefined; default: throw new Error(`Unknown object type '${type}': ${obj}`); }