Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 7766d99

Browse files
feat: Support delegateUpload feature (#49)
* chore: fix chore: fix dependencies versions in the example project & upgrade some packages (#40) * chore: fix dependencies versions in the example project, migrate @tot… (#36) * chore: fix dependencies versions in the example project, migrate @totejs/walletkit to @node-real/walletkit. * chore: upgrade the publish flow * chore: config commit-msg * chore: update versions (alpha) (#37) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix: greenfield-uploadkit auto upgrade version error (#38) * chore: update versions (alpha) (#39) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update versions (#41) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: unify the default visibility (#46) * chore: unify the default visibility * chore: unify the default visibility * chore: update versions (#47) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * feat: Support deletegateUpload feature --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent f01f67d commit 7766d99

File tree

47 files changed

+478
-536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+478
-536
lines changed

.changeset/honest-houses-dream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@node-real/greenfield-uploadkit": minor
3+
---
4+
5+
support delegateUpload feature

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"@node-real/uikit": "^2.54.2",
1919
"@node-real/walletkit": "^1.0.10-alpha.1",
2020
"@node-real/greenfield-uploadkit": "workspace:*",
21-
"@bnb-chain/greenfield-cosmos-types": "0.4.0",
22-
"@bnb-chain/greenfield-js-sdk": "1.2.0",
21+
"@bnb-chain/greenfield-cosmos-types": "0.4.0-alpha.31",
22+
"@bnb-chain/greenfield-js-sdk": "2.0.0-alpha.6",
2323
"@bnb-chain/reed-solomon": "^1.1.3",
2424
"prism-react-renderer": "~1.3.5",
2525
"react": "^18.2.0",
Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { bsc, mainnet } from 'wagmi/chains';
1+
import { bscTestnet } from 'viem/chains';
22

33
export const chains = [
44
{
55
id: 5600,
6-
name: 'BNB Greenfield Testnet',
7-
network: 'BNB Greenfield Testnet',
6+
name: 'BNB Greenfield Chain Testnet',
7+
network: 'BNB Greenfield Chain Testnet',
88
nativeCurrency: {
99
name: 'tBNB',
1010
symbol: 'tBNB',
@@ -20,59 +20,14 @@ export const chains = [
2020
},
2121
blockExplorers: {
2222
etherscan: {
23-
name: `BNB Greenfield Testnet Scan`,
23+
name: `BNB Greenfield Chain Testnet Scan`,
2424
url: 'https://greenfield-chain.bnbchain.org',
2525
},
2626
default: {
27-
name: `BNB Greenfield Testnet Scan`,
27+
name: `BNB Greenfield Chain Testnet Scan`,
2828
url: 'https://greenfield-chain.bnbchain.org',
2929
},
3030
},
3131
},
32-
{
33-
id: 204,
34-
name: 'opBNB Mainnet',
35-
network: 'opBNB Mainnet',
36-
nativeCurrency: {
37-
name: 'tcBNB',
38-
symbol: 'tcBNB',
39-
decimals: 18,
40-
},
41-
rpcUrls: {
42-
default: {
43-
http: ['https://opbnb-mainnet-rpc.bnbchain.org'],
44-
},
45-
public: {
46-
http: ['https://opbnb-mainnet-rpc.bnbchain.org'],
47-
},
48-
},
49-
blockExplorers: {
50-
etherscan: { name: 'opBNBScan', url: `https://mainnet.opbnbscan.com` },
51-
default: { name: 'opBNBScan', url: `https://mainnet.opbnbscan.com` },
52-
},
53-
},
54-
{
55-
id: 97,
56-
name: 'BSC Testnet',
57-
network: 'BSC Testnet',
58-
nativeCurrency: {
59-
name: 'tBNB',
60-
symbol: 'tBNB',
61-
decimals: 18,
62-
},
63-
rpcUrls: {
64-
default: {
65-
http: [`https://data-seed-prebsc-1-s1.binance.org:8545`],
66-
},
67-
public: {
68-
http: [`https://data-seed-prebsc-1-s1.binance.org:8545`],
69-
},
70-
},
71-
blockExplorers: {
72-
etherscan: { name: 'BSC Testnet Scan', url: `https://testnet.bscscan.com` },
73-
default: { name: 'BSC Testnet Scan', url: `https://testnet.bscscan.com` },
74-
},
75-
},
76-
bsc,
77-
mainnet,
32+
bscTestnet,
7833
];

docs/src/components/UploadKit/client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ const GRPC_URL = 'https://gnfd-testnet-fullnode-tendermint-us.bnbchain.org';
44

55
const GREEN_CHAIN_ID = 5600;
66

7-
export const client = Client.create(GRPC_URL, String(GREEN_CHAIN_ID), {
8-
zkCryptoUrl: 'https://unpkg.com/@bnb-chain/[email protected]/dist/node/zk-crypto.wasm',
9-
});
7+
export const client = Client.create(GRPC_URL, String(GREEN_CHAIN_ID));

docs/src/components/UploadKit/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { chains } from './chains';
1818
import { Box, useColorMode } from '@node-real/uikit';
1919
import { client } from './client';
20+
import { VisibilityType } from '@bnb-chain/greenfield-js-sdk';
2021

2122
const config = createConfig(
2223
getDefaultConfig({
@@ -34,11 +35,12 @@ const options: WalletKitOptions = {
3435

3536
const uploadOptions: UploadKitOptions = {
3637
client: client,
38+
delegateUpload: true,
3739
sp: {
3840
operatorAddress: '0x89A1CC91B642DECbC4789474694C606E0E0c420b',
3941
endpoint: 'https://gnfd-testnet-sp1.bnbchain.org',
4042
},
41-
visibility: 'VISIBILITY_TYPE_PUBLIC_READ',
43+
visibility: VisibilityType.VISIBILITY_TYPE_PUBLIC_READ,
4244
};
4345

4446
export default function App() {

docs/src/pages/index.mdx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ Greenfield UploadKit is a React component library for easily uploading objects t
55
## Installation
66

77
```bash
8-
npm i wagmi viem @node-real/greenfield-uploadkit @bnb-chain/greenfield-js-sdk @bnb-chain/greenfield-cosmos-types @bnb-chain/reed-solomon
8+
npm i wagmi@1 viem@1 @node-real/greenfield-uploadkit @bnb-chain/greenfield-js-sdk@2.0.0-alpha.6 @bnb-chain/greenfield-cosmos-types@0.4.0-alpha.31 @bnb-chain/reed-solomon
99
```
1010

11-
- wagmi > 1.0.0
12-
- viem > 1.0.0
13-
- @bnb-chain/greenfield-js-sdk >= 1.2.0
11+
- wagmi >= 1.0.0
12+
- viem >= 1.0.0
13+
- @bnb-chain/greenfield-js-sdk = 2.0.0-alpha.6
14+
- @bnb-chain/greenfield-cosmos-types = 0.4.0-alpha.31
1415
- @bnb-chain/reed-solomon >= 1.1.3
15-
- @bnb-chain/greenfield-cosmos-types >= 0.4.0
1616

1717
## Examples
1818

@@ -360,19 +360,21 @@ export interface UploadKitProviderProps {
360360
}
361361

362362
/**
363-
* Configuration options for upload.
363+
* UploadKitOptions is the options of the Greenfield UploadKit.
364364
*
365365
* @property {Client} client - The Greenfield js sdk client, Reference: https://docs.bnbchain.org/greenfield-js-sdk/client/greenfield-client
366366
*
367367
* @property {string} seedString -seedString is used to authenticate yourself to the provider. If not specified, the provider will generate one.
368368
* @property {(data: Uint8Array) => Promise<string[]>} [checksumFn] - The function to calculate the checksum of the object. If not specified, the provider will use the default checksum function.
369369
*
370-
* @property {string} [bucketName] - The name of the bucket. If not specified, the default bucket will be used.
370+
* @property {boolean} delegateUpload - Specifies whether to use the delegate upload mode. If not specified, the default is set to true.
371+
*
372+
* @property {string} bucketName - The name of the bucket. If not specified, the default bucket will be used.
371373
* @property {Sp} [sp] - The storage service provider. If not specified, a random one will be selected.
372-
* @property {keyof typeof VisibilityType} [visibility='VISIBILITY_TYPE_PUBLIC_READ'] - The visibility of the object. If not specified, 'VISIBILITY_TYPE_PUBLIC_READ' will be used.
374+
* @property {VisibilityType} visibility - The visibility of the object. If not specified, {VisibilityType.VISIBILITY_TYPE_PUBLIC_READ} will be used.
373375
*
374-
* @property {number} [maxObjectSize=56 * 1024 * 1024] - If not specified, the default is set to 56MB, resulting in an encoding time of under 6 seconds. Larger files may experience extended encoding times, and it is recommended to utilize a web worker for encoding large files. Reference: https://github.com/bnb-chain/greenfield-js-sdk/blob/main/packages/reed-solomon/examples/web-worker.html
375-
* @property {number} [maxObjectCount=100] - The maximum count of objects. If not specified, 100 will be used.
376+
* @property {number} [maxObjectSize=56 * 1024 * 1024] - If the delegateUpload is false and this field not specified, the default is set to 56MB, resulting in an encoding time of under 6 seconds. Larger files may experience extended encoding times, and it is recommended to utilize a web worker for encoding large files. Reference: https://github.com/bnb-chain/greenfield-js-sdk/blob/main/packages/reed-solomon/examples/web-worker.html. But if the delegateUpload is true, the default is set to 1GB.
377+
* @property {number} [maxObjectCount=100] - The maximum count of objects. If the delegateUpload is false and this field not specified, the default is set to 100. But if the delegateUpload is true, the default is set to 500.
376378
*
377379
* @property {boolean} [taskManagementButton=true] - Specifies whether to show the task management button.
378380
*
@@ -384,9 +386,11 @@ export interface UploadKitOptions {
384386
seedString?: string;
385387
checksumFn?: (data: Uint8Array) => Promise<string[]>;
386388

389+
delegateUpload?: boolean;
390+
387391
bucketName?: string;
388392
sp?: Sp;
389-
visibility?: keyof typeof VisibilityType;
393+
visibility?: VisibilityType;
390394

391395
maxObjectSize?: number;
392396
maxObjectCount?: number;

examples/uploadkit-with-nextjs-rainbowkit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@bnb-chain/greenfield-cosmos-types": "0.4.0",
13-
"@bnb-chain/greenfield-js-sdk": "1.2.0",
12+
"@bnb-chain/greenfield-cosmos-types": "0.4.0-alpha.31",
13+
"@bnb-chain/greenfield-js-sdk": "2.0.0-alpha.6",
1414
"@bnb-chain/reed-solomon": "1.1.3",
1515
"@node-real/greenfield-uploadkit": "workspace:*",
1616
"@rainbow-me/rainbowkit": "^1.3.3",
Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { bsc, bscTestnet } from 'wagmi/chains';
1+
import { bscTestnet } from 'wagmi/chains';
22

33
const bnbGreenfieldIcon =
44
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyOCIgaGVpZ2h0PSIyOCIgZmlsbD0ibm9uZSI+PGcgY2xpcC1wYXRoPSJ1cmwoI2EpIj48cGF0aCBmaWxsPSIjRjBCOTBCIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNCAwYzcuNzMzIDAgMTQgNi4yNjcgMTQgMTRzLTYuMjY3IDE0LTE0IDE0UzAgMjEuNzMzIDAgMTQgNi4yNjcgMCAxNCAwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTcuNjk0IDE0IC4wMSAzLjcwMiAzLjE0NiAxLjg1djIuMTY4bC00Ljk4Ni0yLjkyNHYtNS44NzhMNy42OTQgMTRabTAtMy43MDJ2Mi4xNTdsLTEuODMyLTEuMDgzVjkuMjE0bDEuODMyLTEuMDgzIDEuODQxIDEuMDgzLTEuODQgMS4wODRabTQuNDctMS4wODQgMS44MzItMS4wODMgMS44NCAxLjA4My0xLjg0IDEuMDg0LTEuODMyLTEuMDg0WiIvPjxwYXRoIGZpbGw9IiNmZmYiIGQ9Ik05LjAxOCAxNi45MzV2LTIuMTY4bDEuODMyIDEuMDg0djIuMTU3bC0xLjgzMi0xLjA3M1ptMy4xNDYgMy4zOTQgMS44MzIgMS4wODQgMS44NC0xLjA4NHYyLjE1N2wtMS44NCAxLjA4NC0xLjgzMi0xLjA4NFYyMC4zM1ptNi4zLTExLjExNSAxLjgzMi0xLjA4MyAxLjg0IDEuMDgzdjIuMTU4bC0xLjg0IDEuMDgzdi0yLjE1N2wtMS44MzItMS4wODRabTEuODMyIDguNDg4LjAxLTMuNzAyIDEuODMxLTEuMDg0djUuODc5bC00Ljk4NiAyLjkyNHYtMi4xNjdsMy4xNDUtMS44NVoiLz48cGF0aCBmaWxsPSIjZmZmIiBkPSJtMTguOTgyIDE2LjkzNS0xLjgzMiAxLjA3M3YtMi4xNTdsMS44MzItMS4wODR2Mi4xNjhaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTE4Ljk4MiAxMS4wNjUuMDEgMi4xNjgtMy4xNTUgMS44NXYzLjcxMmwtMS44MzEgMS4wNzMtMS44MzItMS4wNzN2LTMuNzExbC0zLjE1NS0xLjg1MXYtMi4xNjhsMS44NC0xLjA4MyAzLjEzNSAxLjg2IDMuMTU1LTEuODYgMS44NCAxLjA4M2gtLjAwN1ptLTkuOTY0LTMuNyA0Ljk3Ny0yLjkzNSA0Ljk4NyAyLjkzNS0xLjgzMiAxLjA4My0zLjE1NC0xLjg2LTMuMTQ2IDEuODYtMS44MzItMS4wODNaIi8+PC9nPjxkZWZzPjxjbGlwUGF0aCBpZD0iYSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTAgMGgyOHYyOEgweiIvPjwvY2xpcFBhdGg+PC9kZWZzPjwvc3ZnPg==';
@@ -33,35 +33,5 @@ export const chainList = [
3333
},
3434
iconUrl: bnbGreenfieldIcon,
3535
},
36-
{
37-
id: 1017,
38-
name: 'BNB Greenfield Chain',
39-
network: 'BNB Greenfield Chain',
40-
nativeCurrency: {
41-
name: 'BNB',
42-
symbol: 'BNB',
43-
decimals: 18,
44-
},
45-
rpcUrls: {
46-
default: {
47-
http: ['https://greenfield-chain.bnbchain.org'],
48-
},
49-
public: {
50-
http: ['https://greenfield-chain.bnbchain.org'],
51-
},
52-
},
53-
blockExplorers: {
54-
etherscan: {
55-
name: `BNB Greenfield Mainnet Scan`,
56-
url: 'https://greenfieldscan.com',
57-
},
58-
default: {
59-
name: `BNB Greenfield Mainnet Scan`,
60-
url: 'https://greenfieldscan.com',
61-
},
62-
},
63-
iconUrl: bnbGreenfieldIcon,
64-
},
6536
bscTestnet,
66-
bsc,
6737
];

examples/uploadkit-with-nextjs-rainbowkit/src/app/client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ import { Client } from '@bnb-chain/greenfield-js-sdk';
33
const GRPC_URL = 'https://gnfd-testnet-fullnode-tendermint-us.bnbchain.org';
44
const GREEN_CHAIN_ID = 5600;
55

6-
export const client = Client.create(GRPC_URL, String(GREEN_CHAIN_ID), {
7-
zkCryptoUrl: 'https://unpkg.com/@bnb-chain/[email protected]/dist/node/zk-crypto.wasm',
8-
});
6+
export const client = Client.create(GRPC_URL, String(GREEN_CHAIN_ID));

examples/uploadkit-with-nextjs-rainbowkit/src/app/providers.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { client } from './client';
1212
import '@node-real/greenfield-uploadkit/styles.css';
1313
import '@rainbow-me/rainbowkit/styles.css';
1414
import { publicProvider } from 'wagmi/providers/public';
15+
import { VisibilityType } from '@bnb-chain/greenfield-js-sdk';
1516

1617
const { chains, publicClient } = configureChains(chainList, [publicProvider()]);
1718

@@ -32,7 +33,8 @@ const wagmiConfig = createConfig({
3233

3334
const uploadOptions: UploadKitOptions = {
3435
client: client,
35-
visibility: 'VISIBILITY_TYPE_PUBLIC_READ',
36+
visibility: VisibilityType.VISIBILITY_TYPE_PUBLIC_READ,
37+
delegateUpload: true,
3638
};
3739

3840
export default function Providers({ children }: { children: React.ReactNode }) {

0 commit comments

Comments
 (0)