Skip to content

Commit

Permalink
chore(example): Update Group Tag
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Dec 7, 2023
1 parent 933498d commit a79696f
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion examples/nextjs/src/components/group/update/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { client } from '@/client';
import { toTimestamp } from '@bnb-chain/greenfield-js-sdk';
import { GRNToString, newBucketGRN, newGroupGRN, toTimestamp } from '@bnb-chain/greenfield-js-sdk';
import { useState } from 'react';
import { zeroAddress } from 'viem';
import { useAccount } from 'wagmi';
Expand All @@ -17,6 +17,7 @@ export const GroupUpdate = () => {
setGroupName(e.target.value);
}}
/>
<br />
<button
onClick={async () => {
if (!address) return;
Expand Down Expand Up @@ -56,6 +57,7 @@ export const GroupUpdate = () => {
>
update group (add)
</button>
<br />
<button
onClick={async () => {
if (!address) return;
Expand Down Expand Up @@ -87,6 +89,7 @@ export const GroupUpdate = () => {
>
update group (delete)
</button>
<br />
<button
onClick={async () => {
if (!address) return;
Expand Down Expand Up @@ -117,6 +120,45 @@ export const GroupUpdate = () => {
>
updateGroupExtra
</button>
<br />
<button
onClick={async () => {
if (!address) return;

const resource = GRNToString(newGroupGRN(address, 'zzxc1'));

const updateGroupTx = await client.storage.setTag({
operator: address,
resource,
tags: {
tags: [
{
key: 'x',
value: 'xx',
},
],
},
});

const simulateInfo = await updateGroupTx.simulate({
denom: 'BNB',
});

console.log(simulateInfo);

const res = await updateGroupTx.broadcast({
denom: 'BNB',
gasLimit: Number(simulateInfo.gasLimit),
gasPrice: simulateInfo.gasPrice,
payer: address,
granter: '',
});

console.log('res', res);
}}
>
update group tags
</button>
</div>
);
};

0 comments on commit a79696f

Please sign in to comment.