diff --git a/examples/nextjs/src/components/vg/index.tsx b/examples/nextjs/src/components/vg/index.tsx
new file mode 100644
index 00000000..1c846356
--- /dev/null
+++ b/examples/nextjs/src/components/vg/index.tsx
@@ -0,0 +1,48 @@
+import { client, selectSp } from '@/client';
+import { useAccount } from 'wagmi';
+
+export const VirtualGroup = () => {
+ const { address, connector } = useAccount();
+
+ return (
+
+
Virtual Group
+
+
+
+
+ );
+};
diff --git a/examples/nextjs/src/pages/tx.tsx b/examples/nextjs/src/pages/tx.tsx
index a2c79f5f..2567e73c 100644
--- a/examples/nextjs/src/pages/tx.tsx
+++ b/examples/nextjs/src/pages/tx.tsx
@@ -15,6 +15,7 @@ import { PaymentComponent } from '@/components/payment';
import { Validator } from '@/components/validator';
import { Proposal } from '@/components/proposal';
import { Distribution } from '@/components/distribution';
+import { VirtualGroup } from '@/components/vg';
export default function Tx() {
const isMounted = useIsMounted();
@@ -56,6 +57,8 @@ export default function Tx() {
+
+
>
)}
diff --git a/packages/chain-sdk/src/api/distribution.ts b/packages/chain-sdk/src/api/distribution.ts
index 920dc352..3a0d5206 100644
--- a/packages/chain-sdk/src/api/distribution.ts
+++ b/packages/chain-sdk/src/api/distribution.ts
@@ -46,7 +46,6 @@ export interface IDistribution {
@injectable()
export class Distribution implements IDistribution {
constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {}
- private queryClient: RpcQueryClient = container.resolve(RpcQueryClient);
public async setWithdrawAddress(msg: MsgSetWithdrawAddress) {
return await this.txClient.tx(
diff --git a/packages/chain-sdk/src/api/virtualGroup.ts b/packages/chain-sdk/src/api/virtualGroup.ts
index 7857b3f2..54d05217 100644
--- a/packages/chain-sdk/src/api/virtualGroup.ts
+++ b/packages/chain-sdk/src/api/virtualGroup.ts
@@ -1,3 +1,5 @@
+import { TxClient } from '@/clients/txClient';
+import { MsgSettleSDKTypeEIP712 } from '@/messages/greenfield/virtualgroup/MsgSettle';
import {
QueryGlobalVirtualGroupByFamilyIDRequest,
QueryGlobalVirtualGroupByFamilyIDResponse,
@@ -9,7 +11,9 @@ import {
QueryGlobalVirtualGroupResponse,
QueryParamsResponse,
} from '@bnb-chain/greenfield-cosmos-types/greenfield/virtualgroup/query';
-import { container, injectable } from 'tsyringe';
+import { MsgSettle } from '@bnb-chain/greenfield-cosmos-types/greenfield/virtualgroup/tx';
+import { container, delay, inject, injectable } from 'tsyringe';
+import { MsgSettleTypeUrl, TxResponse } from '..';
import { RpcQueryClient } from '../clients/queryclient';
export interface IVirtualGroup {
@@ -30,10 +34,13 @@ export interface IVirtualGroup {
getGlobalVirtualGroupFamily(
request: QueryGlobalVirtualGroupFamilyRequest,
): Promise;
+
+ settle(address: string, msg: MsgSettle): Promise;
}
@injectable()
export class VirtualGroup implements IVirtualGroup {
+ constructor(@inject(delay(() => TxClient)) private txClient: TxClient) {}
private queryClient = container.resolve(RpcQueryClient);
public async params() {
@@ -60,4 +67,14 @@ export class VirtualGroup implements IVirtualGroup {
const rpc = await this.queryClient.getVirtualGroupClient();
return await rpc.GlobalVirtualGroupFamily(request);
}
+
+ public async settle(address: string, msg: MsgSettle) {
+ return await this.txClient.tx(
+ MsgSettleTypeUrl,
+ address,
+ MsgSettleSDKTypeEIP712,
+ MsgSettle.toSDK(msg),
+ MsgSettle.encode(msg).finish(),
+ );
+ }
}
diff --git a/packages/chain-sdk/src/clients/txClient.ts b/packages/chain-sdk/src/clients/txClient.ts
index d5404b84..859a16ca 100644
--- a/packages/chain-sdk/src/clients/txClient.ts
+++ b/packages/chain-sdk/src/clients/txClient.ts
@@ -17,7 +17,7 @@ import {
import { makeAuthInfoBytes } from '@cosmjs/proto-signing';
import { DeliverTxResponse, StargateClient } from '@cosmjs/stargate';
import { Tendermint37Client } from '@cosmjs/tendermint-rpc';
-import { arrayify } from '@ethersproject/bytes';
+import { arrayify, hexlify } from '@ethersproject/bytes';
import { signTypedData, SignTypedDataVersion } from '@metamask/eth-sig-util';
import { container, inject, injectable } from 'tsyringe';
import {
diff --git a/packages/chain-sdk/src/constants/typeUrl.ts b/packages/chain-sdk/src/constants/typeUrl.ts
index 1e997aa9..c8b085ad 100644
--- a/packages/chain-sdk/src/constants/typeUrl.ts
+++ b/packages/chain-sdk/src/constants/typeUrl.ts
@@ -39,3 +39,4 @@ export const MsgSetWithdrawAddressTypeUrl = '/cosmos.distribution.v1beta1.MsgSet
export const MsgWithdrawValidatorCommissionTypeUrl =
'/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission';
export const MsgFundCommunityPoolTypeUrl = '/cosmos.distribution.v1beta1.MsgFundCommunityPool';
+export const MsgSettleTypeUrl = '/greenfield.virtualgroup.MsgSettle';
diff --git a/packages/chain-sdk/src/messages/greenfield/virtualgroup/MsgSettle.ts b/packages/chain-sdk/src/messages/greenfield/virtualgroup/MsgSettle.ts
new file mode 100644
index 00000000..2d2677e5
--- /dev/null
+++ b/packages/chain-sdk/src/messages/greenfield/virtualgroup/MsgSettle.ts
@@ -0,0 +1,20 @@
+export const MsgSettleSDKTypeEIP712 = {
+ Msg1: [
+ {
+ name: 'global_virtual_group_family_id',
+ type: 'uint32',
+ },
+ {
+ name: 'global_virtual_group_ids',
+ type: 'uint32[]',
+ },
+ {
+ name: 'storage_provider',
+ type: 'string',
+ },
+ {
+ name: 'type',
+ type: 'string',
+ },
+ ],
+};