Skip to content

Commit

Permalink
chore: Update feegranet example
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Dec 25, 2023
1 parent 7559ea0 commit 53cf25e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
11 changes: 5 additions & 6 deletions examples/nextjs/src/components/feegrant/createObj.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Wallet } from '@ethersproject/wallet';
import { ChangeEvent, useState } from 'react';
import { parseEther } from 'viem';
import { useAccount } from 'wagmi';
import { ReedSolomon } from '@bnb-chain/reed-solomon';

/**
* fee grant for creat object
Expand Down Expand Up @@ -124,11 +125,9 @@ export const CreateObj = () => {

console.log('temp account', granteeAddr, privateKey);

const rs = new ReedSolomon();
const fileBytes = await file.arrayBuffer();
const hashResult = await (window as any).FileHandle.getCheckSums(
new Uint8Array(fileBytes),
);
const { contentLength, expectCheckSums } = hashResult;
const expectCheckSums = rs.encode(new Uint8Array(fileBytes));

const createObjectTx = await client.object.createObject(
{
Expand All @@ -137,13 +136,13 @@ export const CreateObj = () => {
objectName: objectName,
visibility: 'VISIBILITY_TYPE_PUBLIC_READ',
redundancyType: 'REDUNDANCY_EC_TYPE',
contentLength,
contentLength: fileBytes.byteLength,
expectCheckSums,
fileType: file.type,
},
{
type: 'ECDSA',
privateKey: ACCOUNT_PRIVATEKEY,
privateKey: privateKey,
},
);

Expand Down
6 changes: 0 additions & 6 deletions examples/nextjs/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ export default function Document() {
<Main />
<NextScript />
</body>
<script src="https://unpkg.com/@bnb-chain/[email protected]/dist/browser/umd/index.js"></script>
<script
dangerouslySetInnerHTML={{
__html: `window.__PUBLIC_FILE_HANDLE_WASM_PATH__ = 'https://unpkg.com/@bnb-chain/[email protected]/dist/node/file-handle.wasm'`,
}}
></script>
</Html>
);
}

0 comments on commit 53cf25e

Please sign in to comment.