From 191e2f40db691d1da099f2bc26a804f3863d0841 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:46:20 +0200 Subject: [PATCH 01/33] feat: add MsgUpdateParams file and spec file --- .../permissions/msgs/MsgUpdateParams.spec.ts | 58 ++++++++++ .../permissions/msgs/MsgUpdateParams.ts | 103 ++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.spec.ts create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.ts diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.spec.ts new file mode 100644 index 000000000..f9cba66d7 --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.spec.ts @@ -0,0 +1,58 @@ +import snakecaseKeys from 'snakecase-keys'; +import MsgUpdateParams from './MsgUpdateParams'; +import { mockFactory } from '@injectivelabs/test-utils'; + +const params: MsgUpdateParams['params'] = { + authority: mockFactory.injectiveAddress, + params: { + wasmHookQueryMaxGas: 50000, + }, +}; + +const protoType = '/injective.permissions.v1beta1.MsgUpdateParams'; +const protoTypeShort = 'permissions/MsgUpdateParams'; +const protoParams = { + authority: params.authority, + params: { + wasmHookQueryMaxGas: params.params.wasmHookQueryMaxGas, + }, +}; + +const protoParamsAmino = snakecaseKeys(protoParams); + +const message = MsgUpdateParams.fromJSON(params); + +describe('MsgUpdateParams', () => { + it('generates proper proto', () => { + const proto = message.toProto(); + + expect(proto).toStrictEqual(protoParams); + }); + + it('generates proper data', () => { + const data = message.toData(); + + expect(data).toStrictEqual({ + '@type': protoType, + ...protoParams, + }); + }); + + it('generates proper amino', () => { + const amino = message.toAmino(); + + expect(amino).toStrictEqual({ + type: protoTypeShort, + value: protoParamsAmino, + }); + }); + + it('generates proper web3', () => { + const web3 = message.toWeb3(); + + expect(web3).toStrictEqual({ + '@type': protoType, + ...protoParamsAmino, + }); + }); +}); diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.ts new file mode 100644 index 000000000..475c988c5 --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.ts @@ -0,0 +1,103 @@ +import { MsgBase } from '../../MsgBase'; +import snakecaseKeys from 'snakecase-keys'; + +// future imports + +// import { +// InjectivePermissionsV1Beta1Tx +// } from '@injectivelabs/care-proto-ts' + +export declare namespace MsgUpdateParams { + export interface Params { + authority: string; + params: { + wasmHookQueryMaxGas: number; + }; + } + + // Temporary Proto declaration + export type Proto = { + authority: string; + params: { + wasmHookQueryMaxGas: number; + }; + }; + + // future Proto declaration + // export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateParams +} + +/** + * @category Messages + */ +export default class MsgUpdateParams extends MsgBase< + MsgUpdateParams.Params, + MsgUpdateParams.Proto +> { + static fromJSON(params: MsgUpdateParams.Params): MsgUpdateParams { + return new MsgUpdateParams(params); + } + + public toProto() { + const { params } = this; + + const message = { + authority: params.authority, + params: { + wasmHookQueryMaxGas: params.params.wasmHookQueryMaxGas, + }, + }; + + return message; + } + + public toData() { + const proto = this.toProto(); + + return { + '@type': '/injective.permissions.v1beta1.MsgUpdateParams', + ...proto, + }; + } + + public toAmino() { + const proto = this.toProto(); + const message = { + ...snakecaseKeys(proto), + }; + + return { + type: 'permissions/MsgUpdateParams', + value: message, + }; + } + + public toWeb3() { + const amino = this.toAmino(); + const { value } = amino; + + return { + '@type': '/injective.permissions.v1beta1.MsgUpdateParams', + ...value, + }; + } + + public toDirectSign() { + const proto = this.toProto(); + + return { + type: '/injective.permissions.v1beta1.MsgUpdateParams', + message: proto, + }; + } + + public toBinary(): Uint8Array { + // Placeholder for binary encoding + return new Uint8Array(); + + //// Expected binary encoding + // return InjectivePermissionsV1Beta1Tx.MsgUpdateParams.encode() + // this.toProto(), + // ).finish() + } +} From c24aae2231925992ee6a2288b8e46a6b27978cbf Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:46:52 +0200 Subject: [PATCH 02/33] feat: add MsgClaimVoucher file and spec file --- .../permissions/msgs/MsgClaimVoucher.spec.ts | 54 +++++++++++ .../permissions/msgs/MsgClaimVoucher.ts | 97 +++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.spec.ts create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.ts diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.spec.ts new file mode 100644 index 000000000..22547e2de --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.spec.ts @@ -0,0 +1,54 @@ +import snakecaseKeys from 'snakecase-keys'; +import MsgClaimVoucher from './MsgClaimVoucher'; +import { mockFactory } from '@injectivelabs/test-utils'; + +const params: MsgClaimVoucher['params'] = { + sender: mockFactory.injectiveAddress, + originator: mockFactory.injectiveAddress2, +}; + +const protoType = '/injective.permissions.v1beta1.MsgClaimVoucher'; +const protoTypeShort = 'permissions/MsgClaimVoucher'; +const protoParams = { + sender: params.sender, + originator: params.originator, +}; + +const protoParamsAmino = snakecaseKeys(protoParams); + +const message = MsgClaimVoucher.fromJSON(params); + +describe('MsgClaimVoucher', () => { + it('generates proper proto', () => { + const proto = message.toProto(); + + expect(proto).toStrictEqual(protoParams); + }); + + it('generates proper data', () => { + const data = message.toData(); + + expect(data).toStrictEqual({ + '@type': protoType, + ...protoParams, + }); + }); + + it('generates proper amino', () => { + const amino = message.toAmino(); + + expect(amino).toStrictEqual({ + type: protoTypeShort, + value: protoParamsAmino, + }); + }); + + it('generates proper web3', () => { + const web3 = message.toWeb3(); + + expect(web3).toStrictEqual({ + '@type': protoType, + ...protoParamsAmino, + }); + }); +}); diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.ts new file mode 100644 index 000000000..7fa472a58 --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.ts @@ -0,0 +1,97 @@ +import { MsgBase } from '../../MsgBase'; +import snakecaseKeys from 'snakecase-keys'; + +// future imports + +// import { +// InjectivePermissionsV1Beta1Tx +// } from '@injectivelabs/care-proto-ts' + +export declare namespace MsgClaimVoucher { + export interface Params { + sender: string; + originator: string; + } + + // Temporary Proto declaration + export type Proto = { + sender: string; + originator: string; + }; + + // future Proto declaration + // export type Proto = InjectivePermissionsV1Beta1Tx.MsgClaimVoucher +} + +/** + * @category Messages + */ +export default class MsgClaimVoucher extends MsgBase< + MsgClaimVoucher.Params, + MsgClaimVoucher.Proto +> { + static fromJSON(params: MsgClaimVoucher.Params): MsgClaimVoucher { + return new MsgClaimVoucher(params); + } + + public toProto() { + const { params } = this; + + const message = { + sender: params.sender, + originator: params.originator, + }; + + return message; + } + + public toData() { + const proto = this.toProto(); + + return { + '@type': '/injective.permissions.v1beta1.MsgClaimVoucher', + ...proto, + }; + } + + public toAmino() { + const proto = this.toProto(); + const message = { + ...snakecaseKeys(proto), + }; + + return { + type: 'permissions/MsgClaimVoucher', + value: message, + }; + } + + public toWeb3() { + const amino = this.toAmino(); + const { value } = amino; + + return { + '@type': '/injective.permissions.v1beta1.MsgClaimVoucher', + ...value, + }; + } + + public toDirectSign() { + const proto = this.toProto(); + + return { + type: '/injective.permissions.v1beta1.MsgClaimVoucher', + message: proto, + }; + } + + public toBinary(): Uint8Array { + // Placeholder for binary encoding + return new Uint8Array(); + + //// Expected binary encoding + // return InjectivePermissionsV1Beta1Tx.MsgClaimVoucher.encode() + // this.toProto(), + // ).finish() + } +} From 6c6208918181018cad94e232334788a535aca653 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:47:22 +0200 Subject: [PATCH 03/33] feat: add MsgCreateNamespace file and spec file --- .../msgs/MsgCreateNamespace.spec.ts | 74 +++++++++++ .../permissions/msgs/MsgCreateNamespace.ts | 122 ++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.spec.ts create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.ts diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.spec.ts new file mode 100644 index 000000000..636acb18e --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.spec.ts @@ -0,0 +1,74 @@ +import snakecaseKeys from 'snakecase-keys'; +import MsgCreateNamespace from './MsgCreateNamespace'; +import { mockFactory } from '@injectivelabs/test-utils'; + +const params: MsgCreateNamespace['params'] = { + sender: mockFactory.injectiveAddress, + denom: 'denom', + wasmHook: 'wasmHookAddress', + mintsPaused: true, + sendsPaused: false, + burnsPaused: true, + rolePermissions: [{ role: 'admin', permissions: 1 }], + addressRoles: [{ address: mockFactory.injectiveAddress2, roles: ['admin'] }], +}; + +const protoType = '/injective.permissions.v1beta1.MsgCreateNamespace'; +const protoTypeShort = 'permissions/MsgCreateNamespace'; +const protoParams = { + sender: params.sender, + namespace: { + denom: params.denom, + wasmHook: params.wasmHook, + mintsPaused: params.mintsPaused, + sendsPaused: params.sendsPaused, + burnsPaused: params.burnsPaused, + rolePermissions: params.rolePermissions.map((rp) => ({ + role: rp.role, + permissions: rp.permissions, + })), + addressRoles: params.addressRoles.map((ar) => ({ + address: ar.address, + roles: ar.roles, + })), + }, +}; + +const protoParamsAmino = snakecaseKeys(protoParams) + +const message = MsgCreateNamespace.fromJSON(params); + +describe('MsgCreateNamespace', () => { + it('generates proper proto', () => { + const proto = message.toProto(); + + expect(proto).toStrictEqual(protoParams); + }); + + it('generates proper data', () => { + const data = message.toData(); + + expect(data).toStrictEqual({ + '@type': protoType, + ...protoParams, + }); + }); + + it('generates proper amino', () => { + const amino = message.toAmino(); + + expect(amino).toStrictEqual({ + type: protoTypeShort, + value: protoParamsAmino, + }); + }); + + it('generates proper web3', () => { + const web3 = message.toWeb3(); + + expect(web3).toStrictEqual({ + '@type': protoType, + ...protoParamsAmino, + }); + }); +}); diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.ts new file mode 100644 index 000000000..0740917fb --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.ts @@ -0,0 +1,122 @@ +import { MsgBase } from '../../MsgBase'; +import snakecaseKeys from 'snakecase-keys'; + +// future imports + +// import { +// InjectivePermissionsV1Beta1Tx +// } from '@injectivelabs/core-proto-ts' + +export declare namespace MsgCreateNamespace { + export interface Params { + sender: string; + denom: string; + wasmHook: string; + mintsPaused: boolean; + sendsPaused: boolean; + burnsPaused: boolean; + rolePermissions: { role: string; permissions: number }[]; + addressRoles: { address: string; roles: string[] }[]; + } + + // Temporary Proto declaration + export type Proto = { + sender: string; + namespace: { + denom: string; + wasmHook: string; + mintsPaused: boolean; + sendsPaused: boolean; + burnsPaused: boolean; + rolePermissions: { role: string; permissions: number }[]; + addressRoles: { address: string; roles: string[] }[]; + }; + }; + + // future Proto declaration + // export type Proto = InjectivePermissionsV1Beta1Tx.MsgCreateNamespace +} + +/** + * @category Messages + */ +export default class MsgCreateNamespace extends MsgBase< + MsgCreateNamespace.Params, + MsgCreateNamespace.Proto +> { + static fromJSON(params: MsgCreateNamespace.Params): MsgCreateNamespace { + return new MsgCreateNamespace(params); + } + + public toProto() { + const { params } = this; + + const namespace = { + denom: params.denom, + wasmHook: params.wasmHook, + mintsPaused: params.mintsPaused, + sendsPaused: params.sendsPaused, + burnsPaused: params.burnsPaused, + rolePermissions: params.rolePermissions, + addressRoles: params.addressRoles, + }; + + const message = { + sender: params.sender, + namespace, + }; + + return message; + } + + public toData() { + const proto = this.toProto(); + + return { + '@type': '/injective.permissions.v1beta1.MsgCreateNamespace', + ...proto, + }; + } + + public toAmino() { + const proto = this.toProto(); + const message = { + ...snakecaseKeys(proto), + }; + + return { + type: 'permissions/MsgCreateNamespace', + value: message, + }; + } + + public toWeb3() { + const amino = this.toAmino(); + const { value } = amino; + + return { + '@type': '/injective.permissions.v1beta1.MsgCreateNamespace', + ...value, + }; + } + + public toDirectSign() { + const proto = this.toProto(); + + return { + type: '/injective.permissions.v1beta1.MsgCreateNamespace', + message: proto, + }; + } + + public toBinary(): Uint8Array { + // Placeholder for binary encoding + return new Uint8Array(); + + //// Expected binary encoding + // return InjectivePermissionsV1Beta1Tx.MsgCreateNamespace.encode() + // this.toProto(), + // ).finish() + + } +} From fd13581eb7c140c351e25d5cf757e993081b5652 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:47:35 +0200 Subject: [PATCH 04/33] feat: add MsgDeleteNamespace file and spec file --- .../msgs/MsgDeleteNamespace.spec.ts | 54 +++++++++++ .../permissions/msgs/MsgDeleteNamespace.ts | 97 +++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.spec.ts create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.ts diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.spec.ts new file mode 100644 index 000000000..950895bba --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.spec.ts @@ -0,0 +1,54 @@ +import snakecaseKeys from 'snakecase-keys'; +import MsgDeleteNamespace from './MsgDeleteNamespace'; +import { mockFactory } from '@injectivelabs/test-utils'; + +const params: MsgDeleteNamespace['params'] = { + sender: mockFactory.injectiveAddress, + namespaceDenom: 'namespace_denom', +}; + +const protoType = '/injective.permissions.v1beta1.MsgDeleteNamespace'; +const protoTypeShort = 'permissions/MsgDeleteNamespace'; +const protoParams = { + sender: params.sender, + namespaceDenom: params.namespaceDenom, +}; + +const protoParamsAmino = snakecaseKeys(protoParams); + +const message = MsgDeleteNamespace.fromJSON(params); + +describe('MsgDeleteNamespace', () => { + it('generates proper proto', () => { + const proto = message.toProto(); + + expect(proto).toStrictEqual(protoParams); + }); + + it('generates proper data', () => { + const data = message.toData(); + + expect(data).toStrictEqual({ + '@type': protoType, + ...protoParams, + }); + }); + + it('generates proper amino', () => { + const amino = message.toAmino(); + + expect(amino).toStrictEqual({ + type: protoTypeShort, + value: protoParamsAmino, + }); + }); + + it('generates proper web3', () => { + const web3 = message.toWeb3(); + + expect(web3).toStrictEqual({ + '@type': protoType, + ...protoParamsAmino, + }); + }); +}); diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.ts new file mode 100644 index 000000000..b56be8770 --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.ts @@ -0,0 +1,97 @@ +import { MsgBase } from '../../MsgBase'; +import snakecaseKeys from 'snakecase-keys'; + +// future imports + +// import { +// InjectivePermissionsV1Beta1Tx +// } from '@injectivelabs/care-proto-ts' + +export declare namespace MsgDeleteNamespace { + export interface Params { + sender: string; + namespaceDenom: string; + } + + // Temporary Proto declaration + export type Proto = { + sender: string; + namespaceDenom: string; + }; + + // future Proto declaration + // export type Proto = InjectivePermissionsV1Beta1Tx.MsgDeleteNamespace +} + +/** + * @category Messages + */ +export default class MsgDeleteNamespace extends MsgBase< + MsgDeleteNamespace.Params, + MsgDeleteNamespace.Proto +> { + static fromJSON(params: MsgDeleteNamespace.Params): MsgDeleteNamespace { + return new MsgDeleteNamespace(params); + } + + public toProto() { + const { params } = this; + + const message = { + sender: params.sender, + namespaceDenom: params.namespaceDenom, + }; + + return message; + } + + public toData() { + const proto = this.toProto(); + + return { + '@type': '/injective.permissions.v1beta1.MsgDeleteNamespace', + ...proto, + }; + } + + public toAmino() { + const proto = this.toProto(); + const message = { + ...snakecaseKeys(proto), + }; + + return { + type: 'permissions/MsgDeleteNamespace', + value: message, + }; + } + + public toWeb3() { + const amino = this.toAmino(); + const { value } = amino; + + return { + '@type': '/injective.permissions.v1beta1.MsgDeleteNamespace', + ...value, + }; + } + + public toDirectSign() { + const proto = this.toProto(); + + return { + type: '/injective.permissions.v1beta1.MsgDeleteNamespace', + message: proto, + }; + } + + public toBinary(): Uint8Array { + // Placeholder for binary encoding + return new Uint8Array(); + + //// Expected binary encoding + // return InjectivePermissionsV1Beta1Tx.MsgDeleteNamespace.encode() + // this.toProto(), + // ).finish() + } +} From 0e16f25cd035ec95a0363ccd8fb039a288a5d71d Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:48:06 +0200 Subject: [PATCH 05/33] feat: add MsgRevokeNamespaceRoles file and spec file --- .../msgs/MsgRevokeNamespaceRoles.spec.ts | 59 +++++++++++ .../msgs/MsgRevokeNamespaceRoles.ts | 100 ++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.spec.ts create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.ts diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.spec.ts new file mode 100644 index 000000000..83a6b82aa --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.spec.ts @@ -0,0 +1,59 @@ +import snakecaseKeys from 'snakecase-keys'; +import MsgRevokeNamespaceRoles from './MsgRevokeNamespaceRoles'; +import { mockFactory } from '@injectivelabs/test-utils'; + +const params: MsgRevokeNamespaceRoles['params'] = { + sender: mockFactory.injectiveAddress, + namespaceDenom: 'namespace_denom', + addressRolesToRevoke: [{ address: mockFactory.injectiveAddress2, roles: ['admin'] }], +}; + +const protoType = '/injective.permissions.v1beta1.MsgRevokeNamespaceRoles'; +const protoTypeShort = 'permissions/MsgRevokeNamespaceRoles'; +const protoParams = { + sender: params.sender, + namespaceDenom: params.namespaceDenom, + addressRolesToRevoke: params.addressRolesToRevoke.map((ar) => ({ + address: ar.address, + roles: ar.roles, + })), +}; + +const protoParamsAmino = snakecaseKeys(protoParams); + +const message = MsgRevokeNamespaceRoles.fromJSON(params); + +describe('MsgRevokeNamespaceRoles', () => { + it('generates proper proto', () => { + const proto = message.toProto(); + + expect(proto).toStrictEqual(protoParams); + }); + + it('generates proper data', () => { + const data = message.toData(); + + expect(data).toStrictEqual({ + '@type': protoType, + ...protoParams, + }); + }); + + it('generates proper amino', () => { + const amino = message.toAmino(); + + expect(amino).toStrictEqual({ + type: protoTypeShort, + value: protoParamsAmino, + }); + }); + + it('generates proper web3', () => { + const web3 = message.toWeb3(); + + expect(web3).toStrictEqual({ + '@type': protoType, + ...protoParamsAmino, + }); + }); +}); diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.ts new file mode 100644 index 000000000..4eabcc90a --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.ts @@ -0,0 +1,100 @@ +import { MsgBase } from '../../MsgBase'; +import snakecaseKeys from 'snakecase-keys'; + +// future imports + +// import { +// InjectivePermissionsV1Beta1Tx +// } from '@injectivelabs/care-proto-ts' + +export declare namespace MsgRevokeNamespaceRoles { + export interface Params { + sender: string; + namespaceDenom: string; + addressRolesToRevoke: { address: string; roles: string[] }[]; + } + + // Temporary Proto declaration + export type Proto = { + sender: string; + namespaceDenom: string; + addressRolesToRevoke: { address: string; roles: string[] }[]; + }; + + // future Proto declaration + // export type Proto = InjectivePermissionsV1Beta1Tx.MsgRevokeNamespaceRoles +} + +/** + * @category Messages + */ +export default class MsgRevokeNamespaceRoles extends MsgBase< + MsgRevokeNamespaceRoles.Params, + MsgRevokeNamespaceRoles.Proto +> { + static fromJSON(params: MsgRevokeNamespaceRoles.Params): MsgRevokeNamespaceRoles { + return new MsgRevokeNamespaceRoles(params); + } + + public toProto() { + const { params } = this; + + const message = { + sender: params.sender, + namespaceDenom: params.namespaceDenom, + addressRolesToRevoke: params.addressRolesToRevoke, + }; + + return message; + } + + public toData() { + const proto = this.toProto(); + + return { + '@type': '/injective.permissions.v1beta1.MsgRevokeNamespaceRoles', + ...proto, + }; + } + + public toAmino() { + const proto = this.toProto(); + const message = { + ...snakecaseKeys(proto), + }; + + return { + type: 'permissions/MsgRevokeNamespaceRoles', + value: message, + }; + } + + public toWeb3() { + const amino = this.toAmino(); + const { value } = amino; + + return { + '@type': '/injective.permissions.v1beta1.MsgRevokeNamespaceRoles', + ...value, + }; + } + + public toDirectSign() { + const proto = this.toProto(); + + return { + type: '/injective.permissions.v1beta1.MsgRevokeNamespaceRoles', + message: proto, + }; + } + + public toBinary(): Uint8Array { + // Placeholder for binary encoding + return new Uint8Array(); + + //// Expected binary encoding + // return InjectivePermissionsV1Beta1Tx.MsgRevokeNamespaceRoles.encode() + // this.toProto(), + // ).finish() + } +} From 3de8410dd1d81ad1af2c13446c308116aa0594f9 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:48:20 +0200 Subject: [PATCH 06/33] feat: add MsgUpdateNamespace file and spec file --- .../msgs/MsgUpdateNamespace.spec.ts | 70 ++++++++++ .../permissions/msgs/MsgUpdateNamespace.ts | 125 ++++++++++++++++++ 2 files changed, 195 insertions(+) create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.spec.ts create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.ts diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.spec.ts new file mode 100644 index 000000000..4e896e8d1 --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.spec.ts @@ -0,0 +1,70 @@ +import snakecaseKeys from 'snakecase-keys'; +import MsgUpdateNamespace from './MsgUpdateNamespace'; +import { mockFactory } from '@injectivelabs/test-utils'; + +const params: MsgUpdateNamespace['params'] = { + sender: mockFactory.injectiveAddress, + namespaceDenom: 'namespace_denom', + wasmHook: 'wasmHookAddress', + mintsPaused: true, + sendsPaused: false, + burnsPaused: true, +}; + +const protoType = '/injective.permissions.v1beta1.MsgUpdateNamespace'; +const protoTypeShort = 'permissions/MsgUpdateNamespace'; +const protoParams = { + sender: params.sender, + namespaceDenom: params.namespaceDenom, + wasmHook: { + newValue: params.wasmHook, + }, + mintsPaused: { + newValue: params.mintsPaused, + }, + sendsPaused: { + newValue: params.sendsPaused, + }, + burnsPaused: { + newValue: params.burnsPaused, + }, +}; + +const protoParamsAmino = snakecaseKeys(protoParams); + +const message = MsgUpdateNamespace.fromJSON(params); + +describe('MsgUpdateNamespace', () => { + it('generates proper proto', () => { + const proto = message.toProto(); + + expect(proto).toStrictEqual(protoParams); + }); + + it('generates proper data', () => { + const data = message.toData(); + + expect(data).toStrictEqual({ + '@type': protoType, + ...protoParams, + }); + }); + + it('generates proper amino', () => { + const amino = message.toAmino(); + + expect(amino).toStrictEqual({ + type: protoTypeShort, + value: protoParamsAmino, + }); + }); + + it('generates proper web3', () => { + const web3 = message.toWeb3(); + + expect(web3).toStrictEqual({ + '@type': protoType, + ...protoParamsAmino, + }); + }); +}); diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.ts new file mode 100644 index 000000000..8cb186e1e --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.ts @@ -0,0 +1,125 @@ +import { MsgBase } from '../../MsgBase'; +import snakecaseKeys from 'snakecase-keys'; + +// future imports + +// import { +// InjectivePermissionsV1Beta1Tx +// } from '@injectivelabs/care-proto-ts' + +export declare namespace MsgUpdateNamespace { + export interface Params { + sender: string; + namespaceDenom: string; + wasmHook: string; + mintsPaused: boolean; + sendsPaused: boolean; + burnsPaused: boolean; + } + + // Temporary Proto declaration + export type Proto = { + sender: string; + namespaceDenom: string; + wasmHook: { + newValue: string; + }; + mintsPaused: { + newValue: boolean; + }; + sendsPaused: { + newValue: boolean; + }; + burnsPaused: { + newValue: boolean; + }; + }; + + // future Proto declaration + // export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateNamespace +} + +/** + * @category Messages + */ +export default class MsgUpdateNamespace extends MsgBase< + MsgUpdateNamespace.Params, + MsgUpdateNamespace.Proto +> { + static fromJSON(params: MsgUpdateNamespace.Params): MsgUpdateNamespace { + return new MsgUpdateNamespace(params); + } + + public toProto() { + const { params } = this; + + const message = { + sender: params.sender, + namespaceDenom: params.namespaceDenom, + wasmHook: { + newValue: params.wasmHook, + }, + mintsPaused: { + newValue: params.mintsPaused, + }, + sendsPaused: { + newValue: params.sendsPaused, + }, + burnsPaused: { + newValue: params.burnsPaused, + }, + }; + + return message; + } + + public toData() { + const proto = this.toProto(); + + return { + '@type': '/injective.permissions.v1beta1.MsgUpdateNamespace', + ...proto, + }; + } + + public toAmino() { + const proto = this.toProto(); + const message = { + ...snakecaseKeys(proto), + }; + + return { + type: 'permissions/MsgUpdateNamespace', + value: message, + }; + } + + public toWeb3() { + const amino = this.toAmino(); + const { value } = amino; + + return { + '@type': '/injective.permissions.v1beta1.MsgUpdateNamespace', + ...value, + }; + } + + public toDirectSign() { + const proto = this.toProto(); + + return { + type: '/injective.permissions.v1beta1.MsgUpdateNamespace', + message: proto, + }; + } + + public toBinary(): Uint8Array { + // Placeholder for binary encoding + return new Uint8Array(); + + //// Expected binary encoding + // return InjectivePermissionsV1Beta1Tx.MsgUpdateNamespace.encode() + // this.toProto(), + // ).finish() + } +} From 13c0dadb4737e24397e20952706904faf83af3f4 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:48:39 +0200 Subject: [PATCH 07/33] feat: add MsgUpdateNamespaceRoles file and spec file --- .../msgs/MsgUpdateNamespaceRoles.spec.ts | 64 +++++++++++ .../msgs/MsgUpdateNamespaceRoles.ts | 103 ++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.spec.ts create mode 100644 packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.ts diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.spec.ts new file mode 100644 index 000000000..46b1878cb --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.spec.ts @@ -0,0 +1,64 @@ +import snakecaseKeys from 'snakecase-keys'; +import MsgUpdateNamespaceRoles from './MsgUpdateNamespaceRoles'; +import { mockFactory } from '@injectivelabs/test-utils'; + +const params: MsgUpdateNamespaceRoles['params'] = { + sender: mockFactory.injectiveAddress, + namespaceDenom: 'namespace_denom', + rolePermissions: [{ role: 'admin', permissions: 1 }], + addressRoles: [{ address: mockFactory.injectiveAddress2, roles: ['admin'] }], +}; + +const protoType = '/injective.permissions.v1beta1.MsgUpdateNamespaceRoles'; +const protoTypeShort = 'permissions/MsgUpdateNamespaceRoles'; +const protoParams = { + sender: params.sender, + namespaceDenom: params.namespaceDenom, + rolePermissions: params.rolePermissions.map((rp) => ({ + role: rp.role, + permissions: rp.permissions, + })), + addressRoles: params.addressRoles.map((ar) => ({ + address: ar.address, + roles: ar.roles, + })), +}; + +const protoParamsAmino = snakecaseKeys(protoParams); + +const message = MsgUpdateNamespaceRoles.fromJSON(params); + +describe('MsgUpdateNamespaceRoles', () => { + it('generates proper proto', () => { + const proto = message.toProto(); + + expect(proto).toStrictEqual(protoParams); + }); + + it('generates proper data', () => { + const data = message.toData(); + + expect(data).toStrictEqual({ + '@type': protoType, + ...protoParams, + }); + }); + + it('generates proper amino', () => { + const amino = message.toAmino(); + + expect(amino).toStrictEqual({ + type: protoTypeShort, + value: protoParamsAmino, + }); + }); + + it('generates proper web3', () => { + const web3 = message.toWeb3(); + + expect(web3).toStrictEqual({ + '@type': protoType, + ...protoParamsAmino, + }); + }); +}); diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.ts new file mode 100644 index 000000000..4c6f53275 --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.ts @@ -0,0 +1,103 @@ +import { MsgBase } from '../../MsgBase'; +import snakecaseKeys from 'snakecase-keys'; + +// future imports + +// import { +// InjectivePermissionsV1Beta1Tx +// } from '@injectivelabs/care-proto-ts' + +export declare namespace MsgUpdateNamespaceRoles { + export interface Params { + sender: string; + namespaceDenom: string; + rolePermissions: { role: string; permissions: number }[]; + addressRoles: { address: string; roles: string[] }[]; + } + + // Temporary Proto declaration + export type Proto = { + sender: string; + namespaceDenom: string; + rolePermissions: { role: string; permissions: number }[]; + addressRoles: { address: string; roles: string[] }[]; + }; + + // future Proto declaration + // export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateNamespaceRoles +} + +/** + * @category Messages + */ +export default class MsgUpdateNamespaceRoles extends MsgBase< + MsgUpdateNamespaceRoles.Params, + MsgUpdateNamespaceRoles.Proto +> { + static fromJSON(params: MsgUpdateNamespaceRoles.Params): MsgUpdateNamespaceRoles { + return new MsgUpdateNamespaceRoles(params); + } + + public toProto() { + const { params } = this; + + const message = { + sender: params.sender, + namespaceDenom: params.namespaceDenom, + rolePermissions: params.rolePermissions, + addressRoles: params.addressRoles, + }; + + return message; + } + + public toData() { + const proto = this.toProto(); + + return { + '@type': '/injective.permissions.v1beta1.MsgUpdateNamespaceRoles', + ...proto, + }; + } + + public toAmino() { + const proto = this.toProto(); + const message = { + ...snakecaseKeys(proto), + }; + + return { + type: 'permissions/MsgUpdateNamespaceRoles', + value: message, + }; + } + + public toWeb3() { + const amino = this.toAmino(); + const { value } = amino; + + return { + '@type': '/injective.permissions.v1beta1.MsgUpdateNamespaceRoles', + ...value, + }; + } + + public toDirectSign() { + const proto = this.toProto(); + + return { + type: '/injective.permissions.v1beta1.MsgUpdateNamespaceRoles', + message: proto, + }; + } + + public toBinary(): Uint8Array { + // Placeholder for binary encoding + return new Uint8Array(); + + //// Expected binary encoding + // return InjectivePermissionsV1Beta1Tx.MsgUpdateNamespaceRoles.encode() + // this.toProto(), + // ).finish() + } +} From b8c9b06178de39e6acfd9aa9acf9975513a624cb Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:49:12 +0200 Subject: [PATCH 08/33] feat: add index file to export permission fns --- .../src/core/modules/permissions/index.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 packages/sdk-ts/src/core/modules/permissions/index.ts diff --git a/packages/sdk-ts/src/core/modules/permissions/index.ts b/packages/sdk-ts/src/core/modules/permissions/index.ts new file mode 100644 index 000000000..8a82869f8 --- /dev/null +++ b/packages/sdk-ts/src/core/modules/permissions/index.ts @@ -0,0 +1,17 @@ +import MsgClaimVoucher from "./msgs/MsgClaimVoucher"; +import MsgCreateNamespace from "./msgs/MsgCreateNamespace"; +import MsgDeleteNamespace from "./msgs/MsgDeleteNamespace"; +import MsgRevokeNamespaceRoles from "./msgs/MsgRevokeNamespaceRoles"; +import MsgUpdateNamespace from "./msgs/MsgUpdateNamespace"; +import MsgUpdateNamespaceRoles from "./msgs/MsgUpdateNamespaceRoles"; +import MsgUpdateParams from "./msgs/MsgUpdateParams"; + +export { + MsgClaimVoucher, + MsgCreateNamespace, + MsgDeleteNamespace, + MsgRevokeNamespaceRoles, + MsgUpdateNamespace, + MsgUpdateNamespaceRoles, + MsgUpdateParams +}; From 2f784e3961b49708bccca4885d5f635cb0e13273 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Mon, 15 Jul 2024 08:49:39 +0200 Subject: [PATCH 09/33] chore: Add permissions to sdk-ts index file --- packages/sdk-ts/src/core/modules/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sdk-ts/src/core/modules/index.ts b/packages/sdk-ts/src/core/modules/index.ts index e108a6fb6..3d9065dca 100644 --- a/packages/sdk-ts/src/core/modules/index.ts +++ b/packages/sdk-ts/src/core/modules/index.ts @@ -13,3 +13,4 @@ export * from './wasm' export * from './tx' export * from './msgs' export * from './feegrant' +export * from './permissions' From 44bb4b60ecf37cdd60872e1a53295cd58634a422 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Tue, 6 Aug 2024 22:31:14 +0200 Subject: [PATCH 10/33] style: Ensure spec files matches existing formatting --- .../permissions/msgs/MsgClaimVoucher.spec.ts | 51 ++++++------- .../msgs/MsgCreateNamespace.spec.ts | 75 ++++++++++--------- .../msgs/MsgDeleteNamespace.spec.ts | 43 +++++------ .../msgs/MsgRevokeNamespaceRoles.spec.ts | 47 ++++++------ .../msgs/MsgUpdateNamespace.spec.ts | 71 ++++++++++-------- .../msgs/MsgUpdateNamespaceRoles.spec.ts | 47 ++++++------ .../permissions/msgs/MsgUpdateParams.spec.ts | 49 ++++++------ 7 files changed, 200 insertions(+), 183 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.spec.ts index 22547e2de..50d9a148d 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.spec.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.spec.ts @@ -1,54 +1,55 @@ -import snakecaseKeys from 'snakecase-keys'; -import MsgClaimVoucher from './MsgClaimVoucher'; -import { mockFactory } from '@injectivelabs/test-utils'; +import snakecaseKeys from 'snakecase-keys' +import MsgClaimVoucher from './MsgClaimVoucher' +import { mockFactory } from '@injectivelabs/test-utils' const params: MsgClaimVoucher['params'] = { sender: mockFactory.injectiveAddress, - originator: mockFactory.injectiveAddress2, -}; + denom: 'inj', +} -const protoType = '/injective.permissions.v1beta1.MsgClaimVoucher'; -const protoTypeShort = 'permissions/MsgClaimVoucher'; +const protoType = '/injective.permissions.v1beta1.MsgClaimVoucher' +const protoTypeShort = 'permissions/MsgClaimVoucher' const protoParams = { sender: params.sender, - originator: params.originator, -}; + denom: params.denom, +} -const protoParamsAmino = snakecaseKeys(protoParams); - -const message = MsgClaimVoucher.fromJSON(params); +const protoParamsAmino = snakecaseKeys(protoParams) +const message = MsgClaimVoucher.fromJSON(params) describe('MsgClaimVoucher', () => { it('generates proper proto', () => { - const proto = message.toProto(); + const proto = message.toProto() - expect(proto).toStrictEqual(protoParams); - }); + expect(proto).toStrictEqual({ + ...protoParams, + }) + }) it('generates proper data', () => { - const data = message.toData(); + const data = message.toData() expect(data).toStrictEqual({ '@type': protoType, ...protoParams, - }); - }); + }) + }) it('generates proper amino', () => { - const amino = message.toAmino(); + const amino = message.toAmino() expect(amino).toStrictEqual({ type: protoTypeShort, value: protoParamsAmino, - }); - }); + }) + }) it('generates proper web3', () => { - const web3 = message.toWeb3(); + const web3 = message.toWeb3() expect(web3).toStrictEqual({ '@type': protoType, ...protoParamsAmino, - }); - }); -}); + }) + }) +}) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.spec.ts index 636acb18e..b1d582b68 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.spec.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.spec.ts @@ -1,74 +1,77 @@ -import snakecaseKeys from 'snakecase-keys'; -import MsgCreateNamespace from './MsgCreateNamespace'; -import { mockFactory } from '@injectivelabs/test-utils'; +import snakecaseKeys from 'snakecase-keys' +import MsgCreateNamespace from './MsgCreateNamespace' +import { mockFactory } from '@injectivelabs/test-utils' const params: MsgCreateNamespace['params'] = { sender: mockFactory.injectiveAddress, - denom: 'denom', - wasmHook: 'wasmHookAddress', - mintsPaused: true, - sendsPaused: false, - burnsPaused: true, - rolePermissions: [{ role: 'admin', permissions: 1 }], - addressRoles: [{ address: mockFactory.injectiveAddress2, roles: ['admin'] }], -}; + namespace: { + denom: 'inj', + wasmHook: 'wasmHookAddress', + mintsPaused: true, + sendsPaused: false, + burnsPaused: true, + rolePermissions: [{ role: 'admin', permissions: 1 }], + addressRoles: [{ address: mockFactory.injectiveAddress2, roles: ['admin'] }], + } +} -const protoType = '/injective.permissions.v1beta1.MsgCreateNamespace'; -const protoTypeShort = 'permissions/MsgCreateNamespace'; +const protoType = '/injective.permissions.v1beta1.MsgCreateNamespace' +const protoTypeShort = 'permissions/MsgCreateNamespace' const protoParams = { sender: params.sender, namespace: { - denom: params.denom, - wasmHook: params.wasmHook, - mintsPaused: params.mintsPaused, - sendsPaused: params.sendsPaused, - burnsPaused: params.burnsPaused, - rolePermissions: params.rolePermissions.map((rp) => ({ + denom: params.namespace.denom, + wasmHook: params.namespace.wasmHook, + mintsPaused: params.namespace.mintsPaused, + sendsPaused: params.namespace.sendsPaused, + burnsPaused: params.namespace.burnsPaused, + rolePermissions: params.namespace.rolePermissions.map((rp) => ({ role: rp.role, permissions: rp.permissions, })), - addressRoles: params.addressRoles.map((ar) => ({ + addressRoles: params.namespace.addressRoles.map((ar) => ({ address: ar.address, roles: ar.roles, })), }, -}; +} const protoParamsAmino = snakecaseKeys(protoParams) - -const message = MsgCreateNamespace.fromJSON(params); +const message = MsgCreateNamespace.fromJSON(params) describe('MsgCreateNamespace', () => { it('generates proper proto', () => { - const proto = message.toProto(); + const proto = message.toProto() - expect(proto).toStrictEqual(protoParams); - }); + expect(proto).toStrictEqual({ + ...protoParams, + }) + }) it('generates proper data', () => { - const data = message.toData(); + const data = message.toData() expect(data).toStrictEqual({ '@type': protoType, ...protoParams, - }); - }); + }) + }) it('generates proper amino', () => { - const amino = message.toAmino(); + const amino = message.toAmino() expect(amino).toStrictEqual({ type: protoTypeShort, value: protoParamsAmino, - }); - }); + }) + }) it('generates proper web3', () => { - const web3 = message.toWeb3(); + const web3 = message.toWeb3() expect(web3).toStrictEqual({ '@type': protoType, ...protoParamsAmino, - }); - }); -}); + }) + }) +}) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.spec.ts index 950895bba..bd2caf49d 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.spec.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.spec.ts @@ -1,54 +1,55 @@ -import snakecaseKeys from 'snakecase-keys'; -import MsgDeleteNamespace from './MsgDeleteNamespace'; -import { mockFactory } from '@injectivelabs/test-utils'; +import snakecaseKeys from 'snakecase-keys' +import MsgDeleteNamespace from './MsgDeleteNamespace' +import { mockFactory } from '@injectivelabs/test-utils' const params: MsgDeleteNamespace['params'] = { sender: mockFactory.injectiveAddress, namespaceDenom: 'namespace_denom', -}; +} const protoType = '/injective.permissions.v1beta1.MsgDeleteNamespace'; const protoTypeShort = 'permissions/MsgDeleteNamespace'; const protoParams = { sender: params.sender, namespaceDenom: params.namespaceDenom, -}; +} -const protoParamsAmino = snakecaseKeys(protoParams); - -const message = MsgDeleteNamespace.fromJSON(params); +const protoParamsAmino = snakecaseKeys(protoParams) +const message = MsgDeleteNamespace.fromJSON(params) describe('MsgDeleteNamespace', () => { it('generates proper proto', () => { - const proto = message.toProto(); + const proto = message.toProto() - expect(proto).toStrictEqual(protoParams); - }); + expect(proto).toStrictEqual({ + ...protoParams, + }) + }) it('generates proper data', () => { - const data = message.toData(); + const data = message.toData() expect(data).toStrictEqual({ '@type': protoType, ...protoParams, - }); - }); + }) + }) it('generates proper amino', () => { - const amino = message.toAmino(); + const amino = message.toAmino() expect(amino).toStrictEqual({ type: protoTypeShort, value: protoParamsAmino, - }); - }); + }) + }) it('generates proper web3', () => { - const web3 = message.toWeb3(); + const web3 = message.toWeb3() expect(web3).toStrictEqual({ '@type': protoType, ...protoParamsAmino, - }); - }); -}); + }) + }) +}) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.spec.ts index 83a6b82aa..fbfe80528 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.spec.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.spec.ts @@ -1,15 +1,15 @@ -import snakecaseKeys from 'snakecase-keys'; -import MsgRevokeNamespaceRoles from './MsgRevokeNamespaceRoles'; -import { mockFactory } from '@injectivelabs/test-utils'; +import snakecaseKeys from 'snakecase-keys' +import MsgRevokeNamespaceRoles from './MsgRevokeNamespaceRoles' +import { mockFactory } from '@injectivelabs/test-utils' const params: MsgRevokeNamespaceRoles['params'] = { sender: mockFactory.injectiveAddress, namespaceDenom: 'namespace_denom', addressRolesToRevoke: [{ address: mockFactory.injectiveAddress2, roles: ['admin'] }], -}; +} -const protoType = '/injective.permissions.v1beta1.MsgRevokeNamespaceRoles'; -const protoTypeShort = 'permissions/MsgRevokeNamespaceRoles'; +const protoType = '/injective.permissions.v1beta1.MsgRevokeNamespaceRoles' +const protoTypeShort = 'permissions/MsgRevokeNamespaceRoles' const protoParams = { sender: params.sender, namespaceDenom: params.namespaceDenom, @@ -17,43 +17,44 @@ const protoParams = { address: ar.address, roles: ar.roles, })), -}; +} -const protoParamsAmino = snakecaseKeys(protoParams); - -const message = MsgRevokeNamespaceRoles.fromJSON(params); +const protoParamsAmino = snakecaseKeys(protoParams) +const message = MsgRevokeNamespaceRoles.fromJSON(params) describe('MsgRevokeNamespaceRoles', () => { it('generates proper proto', () => { - const proto = message.toProto(); + const proto = message.toProto() - expect(proto).toStrictEqual(protoParams); - }); + expect(proto).toStrictEqual({ + ...protoParams + }) + }) it('generates proper data', () => { - const data = message.toData(); + const data = message.toData() expect(data).toStrictEqual({ '@type': protoType, ...protoParams, - }); - }); + }) + }) it('generates proper amino', () => { - const amino = message.toAmino(); + const amino = message.toAmino() expect(amino).toStrictEqual({ type: protoTypeShort, value: protoParamsAmino, - }); - }); + }) + }) it('generates proper web3', () => { - const web3 = message.toWeb3(); + const web3 = message.toWeb3() expect(web3).toStrictEqual({ '@type': protoType, ...protoParamsAmino, - }); - }); -}); + }) + }) +}) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.spec.ts index 4e896e8d1..0e92c4a69 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.spec.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.spec.ts @@ -1,70 +1,79 @@ -import snakecaseKeys from 'snakecase-keys'; -import MsgUpdateNamespace from './MsgUpdateNamespace'; -import { mockFactory } from '@injectivelabs/test-utils'; +import snakecaseKeys from 'snakecase-keys' +import MsgUpdateNamespace from './MsgUpdateNamespace' +import { mockFactory } from '@injectivelabs/test-utils' const params: MsgUpdateNamespace['params'] = { sender: mockFactory.injectiveAddress, namespaceDenom: 'namespace_denom', - wasmHook: 'wasmHookAddress', - mintsPaused: true, - sendsPaused: false, - burnsPaused: true, -}; + wasmHook: { + newValue: 'wasmHookAddress', + }, + mintsPaused: { + newValue: true, + }, + sendsPaused: { + newValue: false, + }, + burnsPaused: { + newValue: true, + } +} -const protoType = '/injective.permissions.v1beta1.MsgUpdateNamespace'; -const protoTypeShort = 'permissions/MsgUpdateNamespace'; +const protoType = '/injective.permissions.v1beta1.MsgUpdateNamespace' +const protoTypeShort = 'permissions/MsgUpdateNamespace' const protoParams = { sender: params.sender, namespaceDenom: params.namespaceDenom, wasmHook: { - newValue: params.wasmHook, + newValue: params.wasmHook.newValue, }, mintsPaused: { - newValue: params.mintsPaused, + newValue: params.mintsPaused.newValue, }, sendsPaused: { - newValue: params.sendsPaused, + newValue: params.sendsPaused.newValue, }, burnsPaused: { - newValue: params.burnsPaused, + newValue: params.burnsPaused.newValue, }, -}; - -const protoParamsAmino = snakecaseKeys(protoParams); +} -const message = MsgUpdateNamespace.fromJSON(params); +const protoParamsAmino = snakecaseKeys(protoParams) +const message = MsgUpdateNamespace.fromJSON(params) describe('MsgUpdateNamespace', () => { it('generates proper proto', () => { - const proto = message.toProto(); + const proto = message.toProto() - expect(proto).toStrictEqual(protoParams); - }); + expect(proto).toStrictEqual({ + ...protoParams + }) + }) it('generates proper data', () => { - const data = message.toData(); + const data = message.toData() expect(data).toStrictEqual({ '@type': protoType, ...protoParams, - }); - }); + }) + }) it('generates proper amino', () => { - const amino = message.toAmino(); + const amino = message.toAmino() expect(amino).toStrictEqual({ type: protoTypeShort, value: protoParamsAmino, - }); - }); + }) + }) it('generates proper web3', () => { - const web3 = message.toWeb3(); + const web3 = message.toWeb3() expect(web3).toStrictEqual({ '@type': protoType, ...protoParamsAmino, - }); - }); -}); + }) + }) +}) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.spec.ts index 46b1878cb..7b4c60d9f 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.spec.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.spec.ts @@ -1,16 +1,16 @@ -import snakecaseKeys from 'snakecase-keys'; -import MsgUpdateNamespaceRoles from './MsgUpdateNamespaceRoles'; -import { mockFactory } from '@injectivelabs/test-utils'; +import snakecaseKeys from 'snakecase-keys' +import MsgUpdateNamespaceRoles from './MsgUpdateNamespaceRoles' +import { mockFactory } from '@injectivelabs/test-utils' const params: MsgUpdateNamespaceRoles['params'] = { sender: mockFactory.injectiveAddress, namespaceDenom: 'namespace_denom', rolePermissions: [{ role: 'admin', permissions: 1 }], addressRoles: [{ address: mockFactory.injectiveAddress2, roles: ['admin'] }], -}; +} -const protoType = '/injective.permissions.v1beta1.MsgUpdateNamespaceRoles'; -const protoTypeShort = 'permissions/MsgUpdateNamespaceRoles'; +const protoType = '/injective.permissions.v1beta1.MsgUpdateNamespaceRoles' +const protoTypeShort = 'permissions/MsgUpdateNamespaceRoles' const protoParams = { sender: params.sender, namespaceDenom: params.namespaceDenom, @@ -22,43 +22,44 @@ const protoParams = { address: ar.address, roles: ar.roles, })), -}; +} -const protoParamsAmino = snakecaseKeys(protoParams); - -const message = MsgUpdateNamespaceRoles.fromJSON(params); +const protoParamsAmino = snakecaseKeys(protoParams) +const message = MsgUpdateNamespaceRoles.fromJSON(params) describe('MsgUpdateNamespaceRoles', () => { it('generates proper proto', () => { - const proto = message.toProto(); + const proto = message.toProto() - expect(proto).toStrictEqual(protoParams); - }); + expect(proto).toStrictEqual({ + ...protoParams + }) + }) it('generates proper data', () => { - const data = message.toData(); + const data = message.toData() expect(data).toStrictEqual({ '@type': protoType, ...protoParams, - }); - }); + }) + }) it('generates proper amino', () => { - const amino = message.toAmino(); + const amino = message.toAmino() expect(amino).toStrictEqual({ type: protoTypeShort, value: protoParamsAmino, - }); - }); + }) + }) it('generates proper web3', () => { - const web3 = message.toWeb3(); + const web3 = message.toWeb3() expect(web3).toStrictEqual({ '@type': protoType, ...protoParamsAmino, - }); - }); -}); + }) + }) +}) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.spec.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.spec.ts index f9cba66d7..1f844e4f5 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.spec.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.spec.ts @@ -1,58 +1,59 @@ -import snakecaseKeys from 'snakecase-keys'; -import MsgUpdateParams from './MsgUpdateParams'; -import { mockFactory } from '@injectivelabs/test-utils'; +import snakecaseKeys from 'snakecase-keys' +import MsgUpdateParams from './MsgUpdateParams' +import { mockFactory } from '@injectivelabs/test-utils' const params: MsgUpdateParams['params'] = { authority: mockFactory.injectiveAddress, params: { - wasmHookQueryMaxGas: 50000, + wasmHookQueryMaxGas: '50000', }, -}; +} -const protoType = '/injective.permissions.v1beta1.MsgUpdateParams'; -const protoTypeShort = 'permissions/MsgUpdateParams'; +const protoType = '/injective.permissions.v1beta1.MsgUpdateParams' +const protoTypeShort = 'permissions/MsgUpdateParams' const protoParams = { authority: params.authority, params: { wasmHookQueryMaxGas: params.params.wasmHookQueryMaxGas, }, -}; +} -const protoParamsAmino = snakecaseKeys(protoParams); - -const message = MsgUpdateParams.fromJSON(params); +const protoParamsAmino = snakecaseKeys(protoParams) +const message = MsgUpdateParams.fromJSON(params) describe('MsgUpdateParams', () => { it('generates proper proto', () => { - const proto = message.toProto(); + const proto = message.toProto() - expect(proto).toStrictEqual(protoParams); - }); + expect(proto).toStrictEqual({ + ...protoParams, + }) + }) it('generates proper data', () => { - const data = message.toData(); + const data = message.toData() expect(data).toStrictEqual({ '@type': protoType, ...protoParams, - }); - }); + }) + }) it('generates proper amino', () => { - const amino = message.toAmino(); + const amino = message.toAmino() expect(amino).toStrictEqual({ type: protoTypeShort, value: protoParamsAmino, - }); - }); + }) + }) it('generates proper web3', () => { - const web3 = message.toWeb3(); + const web3 = message.toWeb3() expect(web3).toStrictEqual({ '@type': protoType, ...protoParamsAmino, - }); - }); -}); + }) + }) +}) From 9efc4c9a59ba108022b15baea13fb6b968ef32b2 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Tue, 6 Aug 2024 22:33:45 +0200 Subject: [PATCH 11/33] fix: update proto definition in MsgClaimVoucher --- .../permissions/msgs/MsgClaimVoucher.ts | 66 ++++++++----------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.ts index 7fa472a58..441c8d9e7 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgClaimVoucher.ts @@ -1,26 +1,15 @@ import { MsgBase } from '../../MsgBase'; import snakecaseKeys from 'snakecase-keys'; - -// future imports - -// import { -// InjectivePermissionsV1Beta1Tx -// } from '@injectivelabs/care-proto-ts' +import { InjectivePermissionsV1Beta1Tx } from '@injectivelabs/core-proto-ts'; export declare namespace MsgClaimVoucher { export interface Params { - sender: string; - originator: string; + sender: string + denom: string } - // Temporary Proto declaration - export type Proto = { - sender: string; - originator: string; - }; - // future Proto declaration - // export type Proto = InjectivePermissionsV1Beta1Tx.MsgClaimVoucher + export type Proto = InjectivePermissionsV1Beta1Tx.MsgClaimVoucher } /** @@ -30,68 +19,67 @@ export default class MsgClaimVoucher extends MsgBase< MsgClaimVoucher.Params, MsgClaimVoucher.Proto > { - static fromJSON(params: MsgClaimVoucher.Params): MsgClaimVoucher { - return new MsgClaimVoucher(params); + static fromJSON( + params: MsgClaimVoucher.Params, + ): MsgClaimVoucher { + return new MsgClaimVoucher(params) } public toProto() { - const { params } = this; + const { params } = this - const message = { - sender: params.sender, - originator: params.originator, - }; + const message = InjectivePermissionsV1Beta1Tx.MsgClaimVoucher.create() + message.sender = params.sender + message.denom = params.denom - return message; + return InjectivePermissionsV1Beta1Tx.MsgClaimVoucher.fromPartial( + message, + ) } public toData() { - const proto = this.toProto(); + const proto = this.toProto() return { '@type': '/injective.permissions.v1beta1.MsgClaimVoucher', ...proto, - }; + } } public toAmino() { - const proto = this.toProto(); + const proto = this.toProto() const message = { ...snakecaseKeys(proto), - }; + } return { type: 'permissions/MsgClaimVoucher', value: message, - }; + } } public toWeb3() { const amino = this.toAmino(); - const { value } = amino; + const { value } = amino return { '@type': '/injective.permissions.v1beta1.MsgClaimVoucher', ...value, - }; + } } public toDirectSign() { - const proto = this.toProto(); + const proto = this.toProto() return { type: '/injective.permissions.v1beta1.MsgClaimVoucher', message: proto, - }; + } } public toBinary(): Uint8Array { - // Placeholder for binary encoding - return new Uint8Array(); - - //// Expected binary encoding - // return InjectivePermissionsV1Beta1Tx.MsgClaimVoucher.encode() - // this.toProto(), - // ).finish() + return InjectivePermissionsV1Beta1Tx.MsgClaimVoucher.encode( + this.toProto(), + ).finish() } } From b043cfb9539e76086d69af47bf29fabcc8417874 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Tue, 6 Aug 2024 22:34:13 +0200 Subject: [PATCH 12/33] fix: update proto definition in MsgCreateNamespace --- .../permissions/msgs/MsgCreateNamespace.ts | 60 +++++-------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.ts index 0740917fb..64ba8fe4d 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgCreateNamespace.ts @@ -1,26 +1,9 @@ import { MsgBase } from '../../MsgBase'; import snakecaseKeys from 'snakecase-keys'; - -// future imports - -// import { -// InjectivePermissionsV1Beta1Tx -// } from '@injectivelabs/core-proto-ts' +import { InjectivePermissionsV1Beta1Tx } from '@injectivelabs/core-proto-ts' export declare namespace MsgCreateNamespace { export interface Params { - sender: string; - denom: string; - wasmHook: string; - mintsPaused: boolean; - sendsPaused: boolean; - burnsPaused: boolean; - rolePermissions: { role: string; permissions: number }[]; - addressRoles: { address: string; roles: string[] }[]; - } - - // Temporary Proto declaration - export type Proto = { sender: string; namespace: { denom: string; @@ -30,11 +13,10 @@ export declare namespace MsgCreateNamespace { burnsPaused: boolean; rolePermissions: { role: string; permissions: number }[]; addressRoles: { address: string; roles: string[] }[]; - }; - }; + } + } - // future Proto declaration - // export type Proto = InjectivePermissionsV1Beta1Tx.MsgCreateNamespace + export type Proto = InjectivePermissionsV1Beta1Tx.MsgCreateNamespace } /** @@ -44,29 +26,23 @@ export default class MsgCreateNamespace extends MsgBase< MsgCreateNamespace.Params, MsgCreateNamespace.Proto > { - static fromJSON(params: MsgCreateNamespace.Params): MsgCreateNamespace { + static fromJSON( + params: MsgCreateNamespace.Params + ): MsgCreateNamespace { return new MsgCreateNamespace(params); } public toProto() { const { params } = this; - const namespace = { - denom: params.denom, - wasmHook: params.wasmHook, - mintsPaused: params.mintsPaused, - sendsPaused: params.sendsPaused, - burnsPaused: params.burnsPaused, - rolePermissions: params.rolePermissions, - addressRoles: params.addressRoles, - }; + const message = InjectivePermissionsV1Beta1Tx.MsgCreateNamespace.create() - const message = { - sender: params.sender, - namespace, - }; + message.sender = params.sender + message.namespace = params.namespace - return message; + return InjectivePermissionsV1Beta1Tx.MsgCreateNamespace.fromPartial( + message, + ) } public toData() { @@ -110,13 +86,9 @@ export default class MsgCreateNamespace extends MsgBase< } public toBinary(): Uint8Array { - // Placeholder for binary encoding - return new Uint8Array(); - - //// Expected binary encoding - // return InjectivePermissionsV1Beta1Tx.MsgCreateNamespace.encode() - // this.toProto(), - // ).finish() + return InjectivePermissionsV1Beta1Tx.MsgCreateNamespace.encode( + this.toProto(), + ).finish() } } From fc25c3dde8cbff42e2b186df912fedc9483e4a09 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Tue, 6 Aug 2024 22:34:25 +0200 Subject: [PATCH 13/33] fix: update proto definition in MsgDeleteNamespace --- .../permissions/msgs/MsgDeleteNamespace.ts | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.ts index b56be8770..05d2b6215 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgDeleteNamespace.ts @@ -1,11 +1,6 @@ import { MsgBase } from '../../MsgBase'; import snakecaseKeys from 'snakecase-keys'; - -// future imports - -// import { -// InjectivePermissionsV1Beta1Tx -// } from '@injectivelabs/care-proto-ts' +import { InjectivePermissionsV1Beta1Tx } from '@injectivelabs/core-proto-ts'; export declare namespace MsgDeleteNamespace { export interface Params { @@ -13,14 +8,7 @@ export declare namespace MsgDeleteNamespace { namespaceDenom: string; } - // Temporary Proto declaration - export type Proto = { - sender: string; - namespaceDenom: string; - }; - - // future Proto declaration - // export type Proto = InjectivePermissionsV1Beta1Tx.MsgDeleteNamespace + export type Proto = InjectivePermissionsV1Beta1Tx.MsgDeleteNamespace } /** @@ -30,19 +18,23 @@ export default class MsgDeleteNamespace extends MsgBase< MsgDeleteNamespace.Params, MsgDeleteNamespace.Proto > { - static fromJSON(params: MsgDeleteNamespace.Params): MsgDeleteNamespace { + static fromJSON( + params: MsgDeleteNamespace.Params + ): MsgDeleteNamespace { return new MsgDeleteNamespace(params); } public toProto() { const { params } = this; - const message = { - sender: params.sender, - namespaceDenom: params.namespaceDenom, - }; + const message = InjectivePermissionsV1Beta1Tx.MsgDeleteNamespace.create() - return message; + message.sender = params.sender + message.namespaceDenom = params.namespaceDenom + + return InjectivePermissionsV1Beta1Tx.MsgDeleteNamespace.fromPartial( + message, + ) } public toData() { @@ -86,12 +78,8 @@ export default class MsgDeleteNamespace extends MsgBase< } public toBinary(): Uint8Array { - // Placeholder for binary encoding - return new Uint8Array(); - - //// Expected binary encoding - // return InjectivePermissionsV1Beta1Tx.MsgDeleteNamespace.encode() - // this.toProto(), - // ).finish() + return InjectivePermissionsV1Beta1Tx.MsgDeleteNamespace.encode( + this.toProto(), + ).finish() } } From 14a4b30dd30ea02626077f0c8cf6ec43c9a40118 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Tue, 6 Aug 2024 22:34:40 +0200 Subject: [PATCH 14/33] fix: update proto definition in MsgRevokeNamespaceRoles --- .../msgs/MsgRevokeNamespaceRoles.ts | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.ts index 4eabcc90a..887064228 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgRevokeNamespaceRoles.ts @@ -1,11 +1,6 @@ import { MsgBase } from '../../MsgBase'; import snakecaseKeys from 'snakecase-keys'; - -// future imports - -// import { -// InjectivePermissionsV1Beta1Tx -// } from '@injectivelabs/care-proto-ts' +import { InjectivePermissionsV1Beta1Tx } from '@injectivelabs/core-proto-ts' export declare namespace MsgRevokeNamespaceRoles { export interface Params { @@ -14,15 +9,7 @@ export declare namespace MsgRevokeNamespaceRoles { addressRolesToRevoke: { address: string; roles: string[] }[]; } - // Temporary Proto declaration - export type Proto = { - sender: string; - namespaceDenom: string; - addressRolesToRevoke: { address: string; roles: string[] }[]; - }; - - // future Proto declaration - // export type Proto = InjectivePermissionsV1Beta1Tx.MsgRevokeNamespaceRoles + export type Proto = InjectivePermissionsV1Beta1Tx.MsgRevokeNamespaceRoles } /** @@ -32,20 +19,24 @@ export default class MsgRevokeNamespaceRoles extends MsgBase< MsgRevokeNamespaceRoles.Params, MsgRevokeNamespaceRoles.Proto > { - static fromJSON(params: MsgRevokeNamespaceRoles.Params): MsgRevokeNamespaceRoles { + static fromJSON( + params: MsgRevokeNamespaceRoles.Params + ): MsgRevokeNamespaceRoles { return new MsgRevokeNamespaceRoles(params); } public toProto() { const { params } = this; - const message = { - sender: params.sender, - namespaceDenom: params.namespaceDenom, - addressRolesToRevoke: params.addressRolesToRevoke, - }; + const message = InjectivePermissionsV1Beta1Tx.MsgRevokeNamespaceRoles.create(); - return message; + message.sender = params.sender + message.namespaceDenom = params.namespaceDenom + message.addressRolesToRevoke = params.addressRolesToRevoke + + return InjectivePermissionsV1Beta1Tx.MsgRevokeNamespaceRoles.fromPartial( + message, + ) } public toData() { @@ -89,12 +80,8 @@ export default class MsgRevokeNamespaceRoles extends MsgBase< } public toBinary(): Uint8Array { - // Placeholder for binary encoding - return new Uint8Array(); - - //// Expected binary encoding - // return InjectivePermissionsV1Beta1Tx.MsgRevokeNamespaceRoles.encode() - // this.toProto(), - // ).finish() + return InjectivePermissionsV1Beta1Tx.MsgRevokeNamespaceRoles.encode( + this.toProto(), + ).finish() } } From d7140b82333f44af41e494b856c9eb287966a548 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Tue, 6 Aug 2024 22:34:52 +0200 Subject: [PATCH 15/33] fix: update proto definition in MsgUpdateNamespace --- .../permissions/msgs/MsgUpdateNamespace.ts | 81 ++++++++----------- 1 file changed, 32 insertions(+), 49 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.ts index 8cb186e1e..366459a21 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespace.ts @@ -1,42 +1,26 @@ import { MsgBase } from '../../MsgBase'; import snakecaseKeys from 'snakecase-keys'; - -// future imports - -// import { -// InjectivePermissionsV1Beta1Tx -// } from '@injectivelabs/care-proto-ts' +import { InjectivePermissionsV1Beta1Tx } from '@injectivelabs/core-proto-ts'; export declare namespace MsgUpdateNamespace { export interface Params { - sender: string; - namespaceDenom: string; - wasmHook: string; - mintsPaused: boolean; - sendsPaused: boolean; - burnsPaused: boolean; - } - - // Temporary Proto declaration - export type Proto = { sender: string; namespaceDenom: string; wasmHook: { newValue: string; - }; + } mintsPaused: { newValue: boolean; - }; + } sendsPaused: { newValue: boolean; - }; + } burnsPaused: { newValue: boolean; - }; - }; + } + } - // future Proto declaration - // export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateNamespace + export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateNamespace } /** @@ -46,31 +30,34 @@ export default class MsgUpdateNamespace extends MsgBase< MsgUpdateNamespace.Params, MsgUpdateNamespace.Proto > { - static fromJSON(params: MsgUpdateNamespace.Params): MsgUpdateNamespace { + static fromJSON( + params: MsgUpdateNamespace.Params + ): MsgUpdateNamespace { return new MsgUpdateNamespace(params); } public toProto() { const { params } = this; - const message = { - sender: params.sender, - namespaceDenom: params.namespaceDenom, - wasmHook: { - newValue: params.wasmHook, - }, - mintsPaused: { - newValue: params.mintsPaused, - }, - sendsPaused: { - newValue: params.sendsPaused, - }, - burnsPaused: { - newValue: params.burnsPaused, - }, - }; - - return message; + const message = InjectivePermissionsV1Beta1Tx.MsgUpdateNamespace.create() + message.sender = params.sender + message.namespaceDenom = params.namespaceDenom + message.wasmHook = { + newValue: params.wasmHook.newValue, + } + message.mintsPaused = { + newValue: params.mintsPaused.newValue, + } + message.sendsPaused = { + newValue: params.sendsPaused.newValue, + } + message.burnsPaused = { + newValue: params.burnsPaused.newValue, + } + + return InjectivePermissionsV1Beta1Tx.MsgUpdateNamespace.fromPartial( + message, + ) } public toData() { @@ -114,12 +101,8 @@ export default class MsgUpdateNamespace extends MsgBase< } public toBinary(): Uint8Array { - // Placeholder for binary encoding - return new Uint8Array(); - - //// Expected binary encoding - // return InjectivePermissionsV1Beta1Tx.MsgUpdateNamespace.encode() - // this.toProto(), - // ).finish() + return InjectivePermissionsV1Beta1Tx.MsgUpdateNamespace.encode( + this.toProto(), + ).finish() } } From 3dcdbe4f4052aca769c490581f218a4b604a8fd1 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Tue, 6 Aug 2024 22:35:10 +0200 Subject: [PATCH 16/33] fix: update proto definition in MsgUpdateNamespaceRoles --- .../msgs/MsgUpdateNamespaceRoles.ts | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.ts index 4c6f53275..a96767794 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateNamespaceRoles.ts @@ -1,11 +1,6 @@ import { MsgBase } from '../../MsgBase'; import snakecaseKeys from 'snakecase-keys'; - -// future imports - -// import { -// InjectivePermissionsV1Beta1Tx -// } from '@injectivelabs/care-proto-ts' +import { InjectivePermissionsV1Beta1Tx } from '@injectivelabs/core-proto-ts' export declare namespace MsgUpdateNamespaceRoles { export interface Params { @@ -15,16 +10,7 @@ export declare namespace MsgUpdateNamespaceRoles { addressRoles: { address: string; roles: string[] }[]; } - // Temporary Proto declaration - export type Proto = { - sender: string; - namespaceDenom: string; - rolePermissions: { role: string; permissions: number }[]; - addressRoles: { address: string; roles: string[] }[]; - }; - - // future Proto declaration - // export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateNamespaceRoles + export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateNamespaceRoles } /** @@ -34,21 +20,25 @@ export default class MsgUpdateNamespaceRoles extends MsgBase< MsgUpdateNamespaceRoles.Params, MsgUpdateNamespaceRoles.Proto > { - static fromJSON(params: MsgUpdateNamespaceRoles.Params): MsgUpdateNamespaceRoles { + static fromJSON( + params: MsgUpdateNamespaceRoles.Params + ): MsgUpdateNamespaceRoles { return new MsgUpdateNamespaceRoles(params); } public toProto() { const { params } = this; - const message = { - sender: params.sender, - namespaceDenom: params.namespaceDenom, - rolePermissions: params.rolePermissions, - addressRoles: params.addressRoles, - }; + const message = InjectivePermissionsV1Beta1Tx.MsgUpdateNamespaceRoles.create(); - return message; + message.sender = params.sender + message.namespaceDenom = params.namespaceDenom + message.rolePermissions = params.rolePermissions + message.addressRoles = params.addressRoles + + return InjectivePermissionsV1Beta1Tx.MsgUpdateNamespaceRoles.fromPartial( + message, + ) } public toData() { @@ -92,12 +82,8 @@ export default class MsgUpdateNamespaceRoles extends MsgBase< } public toBinary(): Uint8Array { - // Placeholder for binary encoding - return new Uint8Array(); - - //// Expected binary encoding - // return InjectivePermissionsV1Beta1Tx.MsgUpdateNamespaceRoles.encode() - // this.toProto(), - // ).finish() + return InjectivePermissionsV1Beta1Tx.MsgUpdateNamespaceRoles.encode( + this.toProto(), + ).finish() } } From cb695c2293d72f08d335fe97540cf83a1e1a8e65 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Tue, 6 Aug 2024 22:35:30 +0200 Subject: [PATCH 17/33] fix: update proto definition in MsgUpdateParams --- .../permissions/msgs/MsgUpdateParams.ts | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.ts b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.ts index 475c988c5..fba679cf2 100644 --- a/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.ts +++ b/packages/sdk-ts/src/core/modules/permissions/msgs/MsgUpdateParams.ts @@ -1,30 +1,18 @@ import { MsgBase } from '../../MsgBase'; import snakecaseKeys from 'snakecase-keys'; +import { InjectivePermissionsV1Beta1Tx } from '@injectivelabs/core-proto-ts'; -// future imports - -// import { -// InjectivePermissionsV1Beta1Tx -// } from '@injectivelabs/care-proto-ts' export declare namespace MsgUpdateParams { export interface Params { authority: string; params: { - wasmHookQueryMaxGas: number; + wasmHookQueryMaxGas: string; }; } - // Temporary Proto declaration - export type Proto = { - authority: string; - params: { - wasmHookQueryMaxGas: number; - }; - }; - // future Proto declaration - // export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateParams + export type Proto = InjectivePermissionsV1Beta1Tx.MsgUpdateParams } /** @@ -34,21 +22,22 @@ export default class MsgUpdateParams extends MsgBase< MsgUpdateParams.Params, MsgUpdateParams.Proto > { - static fromJSON(params: MsgUpdateParams.Params): MsgUpdateParams { + static fromJSON( + params: MsgUpdateParams.Params, + ): MsgUpdateParams { return new MsgUpdateParams(params); } public toProto() { const { params } = this; - const message = { - authority: params.authority, - params: { - wasmHookQueryMaxGas: params.params.wasmHookQueryMaxGas, - }, - }; + const message = InjectivePermissionsV1Beta1Tx.MsgUpdateParams.create() + message.authority = params.authority + message.params = params.params - return message; + return InjectivePermissionsV1Beta1Tx.MsgUpdateParams.fromPartial( + message, + ) } public toData() { @@ -92,12 +81,8 @@ export default class MsgUpdateParams extends MsgBase< } public toBinary(): Uint8Array { - // Placeholder for binary encoding - return new Uint8Array(); - - //// Expected binary encoding - // return InjectivePermissionsV1Beta1Tx.MsgUpdateParams.encode() - // this.toProto(), - // ).finish() + return InjectivePermissionsV1Beta1Tx.MsgUpdateParams.encode( + this.toProto(), + ).finish() } } From fb1bfb0c45910bbb8d6f3940f5f48f7d8b7db36c Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 29 Aug 2024 11:33:10 +0200 Subject: [PATCH 18/33] feat: add permissions types --- .../src/client/chain/types/permissions.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 packages/sdk-ts/src/client/chain/types/permissions.ts diff --git a/packages/sdk-ts/src/client/chain/types/permissions.ts b/packages/sdk-ts/src/client/chain/types/permissions.ts new file mode 100644 index 000000000..c74687d85 --- /dev/null +++ b/packages/sdk-ts/src/client/chain/types/permissions.ts @@ -0,0 +1,46 @@ +import { + InjectivePermissionsV1Beta1Exchange, + } from '@injectivelabs/core-proto-ts' +import { Coin } from '@injectivelabs/ts-types' + + export interface PermissionsModuleNamespace { + denom: string + wasmHook: string + mintsPaused: boolean + sendsPaused: boolean + burnsPaused: boolean + rolePermissions: Role[] + addressRoles: AddressRoles[] + + } + + export interface AddressRoles { + address: string + roles: string[] + } + + export interface Role { + role: string + permissions: number + } + + + export interface RoleIDs { + roleIds: number[] + } + + export interface Voucher { + coins: Coin[] + } + + export interface AddressVoucher { + address: string + voucher: Voucher | undefined + } + + export type GrpcPermissionsNamespace = InjectivePermissionsV1Beta1Exchange.Namespace + export type GrpcPermissionsAddressRoles = InjectivePermissionsV1Beta1Exchange.AddressRoles + export type GrpcPermissionsRole = InjectivePermissionsV1Beta1Exchange.Role + export type GrpcPermissionsRoleIDs = InjectivePermissionsV1Beta1Exchange.RoleIDs + export type GrpcPermissionsAddressVoucher = InjectivePermissionsV1Beta1Exchange.AddressVoucher + export type GrpcPermissionVoucher = InjectivePermissionsV1Beta1Exchange.Voucher From 236bf34acc355b31f54345eeed624cb9c3300fde Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 29 Aug 2024 11:34:16 +0200 Subject: [PATCH 19/33] chore: export permissions types in index.ts --- packages/sdk-ts/src/client/chain/types/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sdk-ts/src/client/chain/types/index.ts b/packages/sdk-ts/src/client/chain/types/index.ts index 971dd41f2..6ff38514f 100644 --- a/packages/sdk-ts/src/client/chain/types/index.ts +++ b/packages/sdk-ts/src/client/chain/types/index.ts @@ -17,6 +17,7 @@ export * from './insurance' export * from './distribution' export * from './tokenfactory' export * from './tendermint-rest' +export * from './permissions' export interface RestApiResponse { data: T From 73de2ab904d8b9334ef246865c43463801a56b37 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Fri, 30 Aug 2024 14:05:22 +0200 Subject: [PATCH 20/33] fix: declare interface using pattern of other files --- packages/sdk-ts/src/client/chain/types/permissions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk-ts/src/client/chain/types/permissions.ts b/packages/sdk-ts/src/client/chain/types/permissions.ts index c74687d85..81686d3d3 100644 --- a/packages/sdk-ts/src/client/chain/types/permissions.ts +++ b/packages/sdk-ts/src/client/chain/types/permissions.ts @@ -35,7 +35,7 @@ import { Coin } from '@injectivelabs/ts-types' export interface AddressVoucher { address: string - voucher: Voucher | undefined + voucher?: Voucher } export type GrpcPermissionsNamespace = InjectivePermissionsV1Beta1Exchange.Namespace From dbfa6dcda6e04157f8b7557ee91e384f31b6162c Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Fri, 30 Aug 2024 14:06:56 +0200 Subject: [PATCH 21/33] chore: add permissions api to chain grpc client --- packages/sdk-ts/src/client/chain/ChainGrpcClient.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/sdk-ts/src/client/chain/ChainGrpcClient.ts b/packages/sdk-ts/src/client/chain/ChainGrpcClient.ts index 66e603fd0..87db6d979 100644 --- a/packages/sdk-ts/src/client/chain/ChainGrpcClient.ts +++ b/packages/sdk-ts/src/client/chain/ChainGrpcClient.ts @@ -9,6 +9,7 @@ import { ChainGrpcInsuranceFundApi } from './grpc/ChainGrpcInsuranceFundApi' import { ChainGrpcMintApi } from './grpc/ChainGrpcMintApi' import { ChainGrpcOracleApi } from './grpc/ChainGrpcOracleApi' import { ChainGrpcPeggyApi } from './grpc/ChainGrpcPeggyApi' +import { ChainGrpcPermissionsApi } from './grpc/ChainGrpcPermissionsApi' import { ChainGrpcStakingApi } from './grpc/ChainGrpcStakingApi' import { ChainGrpcTokenFactoryApi } from './grpc/ChainGrpcTokenFactoryApi' import { ChainGrpcWasmApi } from './grpc/ChainGrpcWasmApi' @@ -41,6 +42,8 @@ export class ChainGrpcClient { peggy: ChainGrpcPeggyApi + permissions: ChainGrpcPermissionsApi + staking: ChainGrpcStakingApi tokenfactory: ChainGrpcTokenFactoryApi @@ -61,6 +64,7 @@ export class ChainGrpcClient { this.mint = new ChainGrpcMintApi(endpoint) this.oracle = new ChainGrpcOracleApi(endpoint) this.peggy = new ChainGrpcPeggyApi(endpoint) + this.permissions = new ChainGrpcPermissionsApi(endpoint) this.staking = new ChainGrpcStakingApi(endpoint) this.tokenfactory = new ChainGrpcTokenFactoryApi(endpoint) this.wasm = new ChainGrpcWasmApi(endpoint) From b48f69893036b968c9e0df8476cbff0f3baa7ffd Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:28:34 +0200 Subject: [PATCH 22/33] fix: update naming structure in types file --- packages/sdk-ts/src/client/chain/types/permissions.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/sdk-ts/src/client/chain/types/permissions.ts b/packages/sdk-ts/src/client/chain/types/permissions.ts index 81686d3d3..d68f6470a 100644 --- a/packages/sdk-ts/src/client/chain/types/permissions.ts +++ b/packages/sdk-ts/src/client/chain/types/permissions.ts @@ -1,9 +1,11 @@ import { InjectivePermissionsV1Beta1Exchange, + InjectivePermissionsV1Beta1Params } from '@injectivelabs/core-proto-ts' + import { Coin } from '@injectivelabs/ts-types' - export interface PermissionsModuleNamespace { + export interface Namespace { denom: string wasmHook: string mintsPaused: boolean @@ -14,11 +16,17 @@ import { Coin } from '@injectivelabs/ts-types' } + export interface PermissionsModuleParams { + wasmHookQueryMaxGas: string + } + + export interface AddressRoles { address: string roles: string[] } + export interface Role { role: string permissions: number @@ -44,3 +52,4 @@ import { Coin } from '@injectivelabs/ts-types' export type GrpcPermissionsRoleIDs = InjectivePermissionsV1Beta1Exchange.RoleIDs export type GrpcPermissionsAddressVoucher = InjectivePermissionsV1Beta1Exchange.AddressVoucher export type GrpcPermissionVoucher = InjectivePermissionsV1Beta1Exchange.Voucher + export type GrpcPermissionsParams = InjectivePermissionsV1Beta1Params.Params From 428deb17fe6ba084cc242cce4be29750139aa660 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:29:40 +0200 Subject: [PATCH 23/33] chore: Include permissions in transformer index file --- packages/sdk-ts/src/client/chain/transformers/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sdk-ts/src/client/chain/transformers/index.ts b/packages/sdk-ts/src/client/chain/transformers/index.ts index a26eba0df..3cabfb99e 100644 --- a/packages/sdk-ts/src/client/chain/transformers/index.ts +++ b/packages/sdk-ts/src/client/chain/transformers/index.ts @@ -9,6 +9,7 @@ export * from './ChainGrpcGovTransformer' export * from './ChainGrpcInsuranceFundTransformer' export * from './ChainGrpcMintTransformer' export * from './ChainGrpcPeggyTransformer' +export * from './ChainGrpcPermissionsTransformer' export * from './ChainGrpcStakingTransformer' export * from './ChainGrpcTokenFactoryTransformer' export * from './ChainGrpcWasmTransformer' From 0cc3e446aa7b95a18540d5b19c40f8929d04fe26 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:32:24 +0200 Subject: [PATCH 24/33] feat: add fetchModuleParams fn with tests and transformer --- .../grpc/ChainGrpcPermissionsApi.spec.ts | 31 +++++++++++ .../chain/grpc/ChainGrpcPermissionsApi.ts | 54 +++++++++++++++++++ .../ChainGrpcPermissionsTransformer.ts | 25 +++++++++ 3 files changed, 110 insertions(+) create mode 100644 packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts create mode 100644 packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts create mode 100644 packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts new file mode 100644 index 000000000..076bcb384 --- /dev/null +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts @@ -0,0 +1,31 @@ +import { getNetworkEndpoints, Network } from '@injectivelabs/networks' +import { ChainGrpcPermissionsTransformer } from '../transformers' +import { mockFactory } from '@injectivelabs/test-utils' +import { ChainGrpcPermissionsApi } from './ChainGrpcPermissionsApi' +import { INJ_DENOM } from '@injectivelabs/utils' + +const endpoints = getNetworkEndpoints(Network.MainnetSentry) +const chainGrpcPermissionsApi = new ChainGrpcPermissionsApi(endpoints.grpc) +const injectiveAddress = mockFactory.injectiveAddress + + +describe('ChainGrpcPermissionsApi', () => { + test('fetchModuleParams', async () => { + try { + const response = await chainGrpcPermissionsApi.fetchModuleParams() + + expect(response).toBeDefined() + expect(response).toEqual( + expect.objectContaining< + ReturnType< + typeof ChainGrpcPermissionsTransformer.moduleParamsResponseToModuleParams + > + >(response), + ) + } catch (e) { + console.error( + 'chainGrpcPermissionsApi.fetchModuleParams => ' + (e as any).message, + ) + } + }) +}) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts new file mode 100644 index 000000000..f8ef11498 --- /dev/null +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -0,0 +1,54 @@ +import { + GrpcUnaryRequestException, + UnspecifiedErrorCode, +} from '@injectivelabs/exceptions' +import { InjectivePermissionsV1Beta1Query } from '@injectivelabs/core-proto-ts' +import BaseGrpcConsumer from '../../base/BaseGrpcConsumer' +import { ChainGrpcPermissionsTransformer } from '../transformers' + +/** + * @category Chain Grpc API + */ +export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { + //protected module: string = ChainModule. + + protected client: InjectivePermissionsV1Beta1Query.QueryClientImpl + + constructor(endpoint: string) { + super(endpoint) + + this.client = new InjectivePermissionsV1Beta1Query.QueryClientImpl( + this.getGrpcWebImpl(endpoint), + ) + } + + + + async fetchModuleParams() { + const request = InjectivePermissionsV1Beta1Query.QueryParamsRequest.create() + + try { + const response = + await this.retry(() => + this.client.Params(request, this.metadata), + ) + + return ChainGrpcPermissionsTransformer.moduleParamsResponseToModuleParams( + response, + ) + } catch (e: unknown) { + if (e instanceof InjectivePermissionsV1Beta1Query.GrpcWebError) { + throw new GrpcUnaryRequestException(new Error(e.toString()), { + code: e.code, + context: 'Params', + }) + } + + throw new GrpcUnaryRequestException(e as Error, { + code: UnspecifiedErrorCode, + context: 'Params', + }) + } + } + +} diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts new file mode 100644 index 000000000..67e79c2c0 --- /dev/null +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -0,0 +1,25 @@ +import { + Namespace, + PermissionsModuleParams, + AddressRoles, + Voucher, + GrpcPermissionsAddressRoles, + GrpcPermissionsNamespace, + GrpcPermissionVoucher, +} from '../types/permissions'; +import { InjectivePermissionsV1Beta1Query } from '@injectivelabs/core-proto-ts'; + +/** + * @category Chain Grpc Transformer + */ +export class ChainGrpcPermissionsTransformer { + static moduleParamsResponseToModuleParams( + response: InjectivePermissionsV1Beta1Query.QueryParamsResponse, + ): PermissionsModuleParams { + const params = response.params! + + return { + wasmHookQueryMaxGas: params.wasmHookQueryMaxGas, + } + } +} From b3e6bb89705a2b02f1aa1465eabaf4ed7fe23c4c Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:37:41 +0200 Subject: [PATCH 25/33] feat: add fetchAddressesByRole fn with test and transformer --- .../grpc/ChainGrpcPermissionsApi.spec.ts | 21 +++++++++++ .../chain/grpc/ChainGrpcPermissionsApi.ts | 35 +++++++++++++++++++ .../ChainGrpcPermissionsTransformer.ts | 9 +++++ 3 files changed, 65 insertions(+) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts index 076bcb384..7ac9e57c3 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts @@ -28,4 +28,25 @@ describe('ChainGrpcPermissionsApi', () => { ) } }) + test('fetchAddressesByRoles', async () => { + try { + const response = await chainGrpcPermissionsApi.fetchAddressesByRole({ + denom: INJ_DENOM, + role: "role", + }) + + expect(response).toBeDefined() + expect(response).toEqual( + expect.objectContaining< + ReturnType< + typeof ChainGrpcPermissionsTransformer.AddressesByRolesResponseToAddressesByRoles + > + >(response), + ) + } catch (e) { + console.error( + 'chainGrpcPermissionsApi.fetchAddressesByRoles => ' + (e as any).message, + ) + } + }) }) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts index f8ef11498..3be01a91c 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -22,6 +22,41 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { ) } + async fetchAddressesByRole({ + denom, + role, + }: { + denom: string + role: string + }) { + const request = InjectivePermissionsV1Beta1Query.QueryAddressesByRoleRequest.create() + + request.denom = denom + request.role = role + + try { + const response = + await this.retry( + () => this.client.AddressesByRole(request, this.metadata), + ) + + return ChainGrpcPermissionsTransformer.AddressesByRolesResponseToAddressesByRoles( + response, + ) + } catch (e: unknown) { + if (e instanceof InjectivePermissionsV1Beta1Query.GrpcWebError) { + throw new GrpcUnaryRequestException(new Error(e.toString()), { + code: e.code, + context: 'AddressesByRole', + }) + } + + throw new GrpcUnaryRequestException(e as Error, { + code: UnspecifiedErrorCode, + context: 'AddressesByRole', + }) + } + } async fetchModuleParams() { diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts index 67e79c2c0..cc1c1b748 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -22,4 +22,13 @@ export class ChainGrpcPermissionsTransformer { wasmHookQueryMaxGas: params.wasmHookQueryMaxGas, } } + + static AddressesByRolesResponseToAddressesByRoles ( + response: InjectivePermissionsV1Beta1Query.QueryAddressesByRoleResponse, + ){ return response.addresses.map((address) => { + return { + addresses: address, + } + }) + } } From be65227969f4e69d21465d45800c9b2960f8814a Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:40:58 +0200 Subject: [PATCH 26/33] feat: add AddressRoles fn with test and tranformer --- .../grpc/ChainGrpcPermissionsApi.spec.ts | 25 +++++++++++++ .../chain/grpc/ChainGrpcPermissionsApi.ts | 35 +++++++++++++++++++ .../ChainGrpcPermissionsTransformer.ts | 9 +++++ 3 files changed, 69 insertions(+) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts index 7ac9e57c3..1c44ab678 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts @@ -28,6 +28,31 @@ describe('ChainGrpcPermissionsApi', () => { ) } }) + test('fetchAddressRoles', async () => { + try { + const response = await chainGrpcPermissionsApi.fetchAddressRoles({ + address: injectiveAddress, + denom: INJ_DENOM, + }) + + if (response.length === 0) { + console.warn('fetchAddressRoles.arrayIsEmpty') + } + + expect(response).toBeDefined() + expect(response).toEqual( + expect.objectContaining< + ReturnType< + typeof ChainGrpcPermissionsTransformer.addressRolesResponseToAddressRoles + > + >(response), + ) + } catch (e) { + console.error( + 'chainGrpcPermissionsApi.fetchAddressRoles => ' + (e as any).message, + ) + } + }) test('fetchAddressesByRoles', async () => { try { const response = await chainGrpcPermissionsApi.fetchAddressesByRole({ diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts index 3be01a91c..d61f80120 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -58,6 +58,41 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { } } + async fetchAddressRoles({ + address, + denom, + }: { + address: string + denom: string + }) { + const request = InjectivePermissionsV1Beta1Query.QueryAddressRolesRequest.create() + + request.address = address + request.denom = denom + + try { + const response = + await this.retry( + () => this.client.AddressRoles(request, this.metadata), + ) + + return ChainGrpcPermissionsTransformer.addressRolesResponseToAddressRoles( + response, + ) + } catch (e: unknown) { + if (e instanceof InjectivePermissionsV1Beta1Query.GrpcWebError) { + throw new GrpcUnaryRequestException(new Error(e.toString()), { + code: e.code, + context: 'AddressRoles', + }) + } + + throw new GrpcUnaryRequestException(e as Error, { + code: UnspecifiedErrorCode, + context: 'AddressRoles', + }) + } + } async fetchModuleParams() { const request = InjectivePermissionsV1Beta1Query.QueryParamsRequest.create() diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts index cc1c1b748..3e5f55785 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -23,6 +23,15 @@ export class ChainGrpcPermissionsTransformer { } } + static addressRolesResponseToAddressRoles( + response: InjectivePermissionsV1Beta1Query.QueryAddressRolesResponse, + ){ return response.roles.map((role) => { + return { + roles: role, + } + }) + } + static AddressesByRolesResponseToAddressesByRoles ( response: InjectivePermissionsV1Beta1Query.QueryAddressesByRoleResponse, ){ return response.addresses.map((address) => { From 0911b588a342f0f1f5fd55be2f4eb8603c15e2e1 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:43:48 +0200 Subject: [PATCH 27/33] feat: add fetchAllNamespaces fn with test and transformers --- .../grpc/ChainGrpcPermissionsApi.spec.ts | 18 +++++++++++++ .../chain/grpc/ChainGrpcPermissionsApi.ts | 27 +++++++++++++++++++ .../ChainGrpcPermissionsTransformer.ts | 22 +++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts index 1c44ab678..c42130a83 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts @@ -74,4 +74,22 @@ describe('ChainGrpcPermissionsApi', () => { ) } }) + test('fetchAllNamespaces', async () => { + try { + const response = await chainGrpcPermissionsApi.fetchAllNamespaces() + + expect(response).toBeDefined() + expect(response).toEqual( + expect.objectContaining< + ReturnType< + typeof ChainGrpcPermissionsTransformer.allNamespacesResponseToAllNamespaces + > + >(response), + ) + } catch (e) { + console.error( + 'chainGrpcPermissionsApi.fetchAllNamespaces => ' + (e as any).message, + ) + } + }) }) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts index d61f80120..80e3636fe 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -94,6 +94,33 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { } } + async fetchAllNamespaces() { + const request = InjectivePermissionsV1Beta1Query.QueryAllNamespacesRequest.create() + + try { + const response = + await this.retry(() => + this.client.AllNamespaces(request, this.metadata), + ) + + return ChainGrpcPermissionsTransformer.allNamespacesResponseToAllNamespaces( + response, + ) + } catch (e: unknown) { + if (e instanceof InjectivePermissionsV1Beta1Query.GrpcWebError) { + throw new GrpcUnaryRequestException(new Error(e.toString()), { + code: e.code, + context: 'AllNamespaces', + }) + } + + throw new GrpcUnaryRequestException(e as Error, { + code: UnspecifiedErrorCode, + context: 'AllNamespaces', + }) + } + } + async fetchModuleParams() { const request = InjectivePermissionsV1Beta1Query.QueryParamsRequest.create() diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts index 3e5f55785..bfc09152e 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -23,6 +23,20 @@ export class ChainGrpcPermissionsTransformer { } } + static grpcNamespaceToNamespace ( + grpcNamespace: GrpcPermissionsNamespace, + ): Namespace { + return { + denom: grpcNamespace.denom, + wasmHook: grpcNamespace.wasmHook, + mintsPaused: grpcNamespace.mintsPaused, + sendsPaused: grpcNamespace.sendsPaused, + burnsPaused: grpcNamespace.burnsPaused, + rolePermissions: grpcNamespace.rolePermissions, + addressRoles: grpcNamespace.addressRoles, + } + } + static addressRolesResponseToAddressRoles( response: InjectivePermissionsV1Beta1Query.QueryAddressRolesResponse, ){ return response.roles.map((role) => { @@ -40,4 +54,12 @@ export class ChainGrpcPermissionsTransformer { } }) } + + static allNamespacesResponseToAllNamespaces ( + response: InjectivePermissionsV1Beta1Query.QueryAllNamespacesResponse, + ) { + return response.namespaces.map((namespace) => { + ChainGrpcPermissionsTransformer.grpcNamespaceToNamespace(namespace) + }) + } } From 9544df78a2c1c73894667ed9816ace37623b15c6 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:45:59 +0200 Subject: [PATCH 28/33] feat: add getchNamespaceByDenom fn with test and transformer --- .../grpc/ChainGrpcPermissionsApi.spec.ts | 21 +++++++++++ .../chain/grpc/ChainGrpcPermissionsApi.ts | 36 +++++++++++++++++++ .../ChainGrpcPermissionsTransformer.ts | 6 ++++ 3 files changed, 63 insertions(+) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts index c42130a83..9c5d6037d 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts @@ -92,4 +92,25 @@ describe('ChainGrpcPermissionsApi', () => { ) } }) + test('fetchNamespaceByDenom', async () => { + try { + const response = await chainGrpcPermissionsApi.fetchNamespaceByDenom({ + denom: INJ_DENOM, + include_roles: true, + }) + + expect(response).toBeDefined() + expect(response).toEqual( + expect.objectContaining< + ReturnType< + typeof ChainGrpcPermissionsTransformer.namespaceByDenomResponceToNamespaceByDenom + > + >(response), + ) + } catch (e) { + console.error( + 'chainGrpcPermissionsApi.fetchNamespaceByDenom=> ' + (e as any).message, + ) + } + }) }) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts index 80e3636fe..631d54fe1 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -148,4 +148,40 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { } } + + async fetchNamespaceByDenom({ + denom, + include_roles, + }: { + denom: string + include_roles: boolean + }) { + const request = InjectivePermissionsV1Beta1Query.QueryNamespaceByDenomRequest.create() + + request.denom = denom + request.includeRoles = include_roles + + try { + const response = + await this.retry( + () => this.client.NamespaceByDenom(request, this.metadata), + ) + + return ChainGrpcPermissionsTransformer.namespaceByDenomResponceToNamespaceByDenom( + response, + ) + } catch (e: unknown) { + if (e instanceof InjectivePermissionsV1Beta1Query.GrpcWebError) { + throw new GrpcUnaryRequestException(new Error(e.toString()), { + code: e.code, + context: 'NamespaceByDenom', + }) + } + + throw new GrpcUnaryRequestException(e as Error, { + code: UnspecifiedErrorCode, + context: 'NamespaceByDenom', + }) + } + } } diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts index bfc09152e..ad2f7c677 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -62,4 +62,10 @@ export class ChainGrpcPermissionsTransformer { ChainGrpcPermissionsTransformer.grpcNamespaceToNamespace(namespace) }) } + + static namespaceByDenomResponceToNamespaceByDenom ( + response: InjectivePermissionsV1Beta1Query.QueryNamespaceByDenomResponse, + ) { + return ChainGrpcPermissionsTransformer.grpcNamespaceToNamespace(response.namespace!) + } } From 4e7e31af0a14bf05d1b2382990bdf6838ade2453 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:49:41 +0200 Subject: [PATCH 29/33] feat: add fetchVouchersForAddress fn with test and transformer --- .../grpc/ChainGrpcPermissionsApi.spec.ts | 20 +++++++++++ .../chain/grpc/ChainGrpcPermissionsApi.ts | 33 +++++++++++++++++++ .../ChainGrpcPermissionsTransformer.ts | 11 +++++++ 3 files changed, 64 insertions(+) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts index 9c5d6037d..c95ee2f68 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts @@ -113,4 +113,24 @@ describe('ChainGrpcPermissionsApi', () => { ) } }) + test('fetchVouchersForAddress', async () => { + try { + const response = await chainGrpcPermissionsApi.fetchVouchersForAddress({ + address: injectiveAddress + }) + + expect(response).toBeDefined() + expect(response).toEqual( + expect.objectContaining< + ReturnType< + typeof ChainGrpcPermissionsTransformer.vouchersForAddressResponseToVouchersForAddress + > + >(response), + ) + } catch (e) { + console.error( + 'chainGrpcPermissionsApi.fetchVouchersForAddress => ' + (e as any).message, + ) + } + }) }) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts index 631d54fe1..2b683eda3 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -184,4 +184,37 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { }) } } + + async fetchVouchersForAddress({ + address, + }: { + address: string + }) { + const request = InjectivePermissionsV1Beta1Query.QueryVouchersForAddressRequest.create() + + request.address = address + + try { + const response = + await this.retry( + () => this.client.VouchersForAddress(request, this.metadata), + ) + + return ChainGrpcPermissionsTransformer.vouchersForAddressResponseToVouchersForAddress( + response, + ) + } catch (e: unknown) { + if (e instanceof InjectivePermissionsV1Beta1Query.GrpcWebError) { + throw new GrpcUnaryRequestException(new Error(e.toString()), { + code: e.code, + context: 'VouchersForAddress', + }) + } + + throw new GrpcUnaryRequestException(e as Error, { + code: UnspecifiedErrorCode, + context: 'VouchersForAddress', + }) + } + } } diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts index ad2f7c677..51118bc35 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -68,4 +68,15 @@ export class ChainGrpcPermissionsTransformer { ) { return ChainGrpcPermissionsTransformer.grpcNamespaceToNamespace(response.namespace!) } + + + static vouchersForAddressResponseToVouchersForAddress ( + response: InjectivePermissionsV1Beta1Query.QueryVouchersForAddressResponse, + ) { + return response.vouchers.map((voucher) => { + return { + vouchers: voucher, + } + }) + } } From f28d1046430205931af64c97c393715f3c677b40 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 00:52:56 +0200 Subject: [PATCH 30/33] fix: format documents uniformly and remove unnneeded imports --- .../sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts | 1 - .../chain/transformers/ChainGrpcPermissionsTransformer.ts | 5 ----- 2 files changed, 6 deletions(-) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts index 2b683eda3..5df31050e 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -148,7 +148,6 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { } } - async fetchNamespaceByDenom({ denom, include_roles, diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts index 51118bc35..78003614a 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -1,11 +1,7 @@ import { Namespace, PermissionsModuleParams, - AddressRoles, - Voucher, - GrpcPermissionsAddressRoles, GrpcPermissionsNamespace, - GrpcPermissionVoucher, } from '../types/permissions'; import { InjectivePermissionsV1Beta1Query } from '@injectivelabs/core-proto-ts'; @@ -69,7 +65,6 @@ export class ChainGrpcPermissionsTransformer { return ChainGrpcPermissionsTransformer.grpcNamespaceToNamespace(response.namespace!) } - static vouchersForAddressResponseToVouchersForAddress ( response: InjectivePermissionsV1Beta1Query.QueryVouchersForAddressResponse, ) { From fd0cc4d2bf5fbd840aef982b0a8efc5404c75e96 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 01:20:35 +0200 Subject: [PATCH 31/33] style: Fix capitalization error in fn name --- .../src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts | 2 +- .../sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts | 2 +- .../chain/transformers/ChainGrpcPermissionsTransformer.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts index c95ee2f68..4506effb6 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.spec.ts @@ -64,7 +64,7 @@ describe('ChainGrpcPermissionsApi', () => { expect(response).toEqual( expect.objectContaining< ReturnType< - typeof ChainGrpcPermissionsTransformer.AddressesByRolesResponseToAddressesByRoles + typeof ChainGrpcPermissionsTransformer.addressesByRolesResponseToAddressesByRoles > >(response), ) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts index 5df31050e..ba449444e 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -40,7 +40,7 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { () => this.client.AddressesByRole(request, this.metadata), ) - return ChainGrpcPermissionsTransformer.AddressesByRolesResponseToAddressesByRoles( + return ChainGrpcPermissionsTransformer.addressesByRolesResponseToAddressesByRoles( response, ) } catch (e: unknown) { diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts index 78003614a..9a9beb73d 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -42,7 +42,7 @@ export class ChainGrpcPermissionsTransformer { }) } - static AddressesByRolesResponseToAddressesByRoles ( + static addressesByRolesResponseToAddressesByRoles ( response: InjectivePermissionsV1Beta1Query.QueryAddressesByRoleResponse, ){ return response.addresses.map((address) => { return { From 2c8effdfde1f190e46f99e916a20974db8a002b2 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 13:58:34 +0200 Subject: [PATCH 32/33] fix: add linebrakes in transformer file --- .../ChainGrpcPermissionsTransformer.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts index 9a9beb73d..b3e4c7a6f 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcPermissionsTransformer.ts @@ -35,20 +35,22 @@ export class ChainGrpcPermissionsTransformer { static addressRolesResponseToAddressRoles( response: InjectivePermissionsV1Beta1Query.QueryAddressRolesResponse, - ){ return response.roles.map((role) => { + ){ + return response.roles.map((role) => { return { roles: role, - } + } }) } static addressesByRolesResponseToAddressesByRoles ( response: InjectivePermissionsV1Beta1Query.QueryAddressesByRoleResponse, - ){ return response.addresses.map((address) => { - return { - addresses: address, - } - }) + ){ + return response.addresses.map((address) => { + return { + addresses: address, + } + }) } static allNamespacesResponseToAllNamespaces ( From be2ede623d3ed955d618b606507a81d64731a611 Mon Sep 17 00:00:00 2001 From: Juan-LukeKlopper Date: Thu, 5 Sep 2024 14:00:46 +0200 Subject: [PATCH 33/33] style: use camelCase in variable name --- .../sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts index ba449444e..60bc90c8c 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcPermissionsApi.ts @@ -150,15 +150,15 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer { async fetchNamespaceByDenom({ denom, - include_roles, + includeRoles, }: { denom: string - include_roles: boolean + includeRoles: boolean }) { const request = InjectivePermissionsV1Beta1Query.QueryNamespaceByDenomRequest.create() request.denom = denom - request.includeRoles = include_roles + request.includeRoles = includeRoles try { const response =