diff --git a/doc-site/docs/FAQs/caclute-checksum-is-slow.mdx b/doc-site/docs/FAQs/calculating-checksum-is-slow.mdx similarity index 94% rename from doc-site/docs/FAQs/caclute-checksum-is-slow.mdx rename to doc-site/docs/FAQs/calculating-checksum-is-slow.mdx index fe946163..5928e14e 100644 --- a/doc-site/docs/FAQs/caclute-checksum-is-slow.mdx +++ b/doc-site/docs/FAQs/calculating-checksum-is-slow.mdx @@ -1,6 +1,6 @@ --- id: checksums -title: cacluting checksum is slow +title: calculating checksum is slow order: 1 --- @@ -21,7 +21,7 @@ If not counting big files (how big is depending on the user's device), here are Note, you don't have to have webworker or worker_threads on to get faster performance. Because running worker also has performance loss. -When calculating small files, using core is faster than using worker. +When calculating small files, using the core is faster than using the worker. ## Usage @@ -126,7 +126,7 @@ If the file is larger, this method may cause the page to freeze when calculating -Nodejs can also be used in two ways, directly with core library, or with [worker_threads](https://nodejs.org/api/worker_threads.html) (calculating large files). +Nodejs can also be used in two ways, directly with the core library, or with [worker_threads](https://nodejs.org/api/worker_threads.html) (calculating large files). ```js title="core lib" const { ReedSolomon } = require('@bnb-chain/reed-solomon') diff --git a/doc-site/docs/client/greenfield.mdx b/doc-site/docs/client/greenfield.mdx index 2db85d11..cbb03c7b 100644 --- a/doc-site/docs/client/greenfield.mdx +++ b/doc-site/docs/client/greenfield.mdx @@ -26,7 +26,7 @@ const client = Client.create(GRPC_URL, String(GREEN_CHAIN_ID), { :::tip -Browser need load wasm manually. +The browser needs to load wasm manually. ::: diff --git a/doc-site/docs/client/query-client.mdx b/doc-site/docs/client/query-client.mdx index a8b0722b..83bee74f 100644 --- a/doc-site/docs/client/query-client.mdx +++ b/doc-site/docs/client/query-client.mdx @@ -4,7 +4,7 @@ title: 'Query Client' sidebar_position: 2 --- -It's actually an encapsulation of the +It's an encapsulation of the [Blockchain API](https://docs.bnbchain.org/greenfield-docs/docs/api/blockchain-rest). :::info @@ -22,7 +22,7 @@ await rpc.Account({ }); ``` -More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/account-info +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/account-info ## getBankQueryClient @@ -34,7 +34,7 @@ await rpc.Balance({ }); ``` -More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/account-info +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/account-info ## getBridgeQueryClient @@ -43,7 +43,7 @@ const rpc = await client.queryClient.getBridgeQueryClient(); await rpc.Params(); ``` -More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/bridge-params +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/bridge-params ## getChallengeQueryClient @@ -52,7 +52,7 @@ const rpc = await client.queryClient.getChallengeQueryClient(); await rpc.Params(); ``` -More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/attested-challenge +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/attested-challenge ## getCrosschainQueryClient @@ -70,7 +70,7 @@ const rpc = await client.queryClient.getFeeGrantQueryClient(); await rpc.Params(); ``` -More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/allowance +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/allowance ## getGashubClient @@ -79,7 +79,7 @@ const rpc = await this.queryClient.getGashubClient(); await rpc.MsgGasParams(request); ``` -More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/msg-gas-params +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/msg-gas-params ## getPaymentQueryClient @@ -88,7 +88,7 @@ const rpc = await this.queryClient.getPaymentQueryClient(); await rpc.Params(); ``` -More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/msg-gas-params +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/msg-gas-params ## getSpQueryClient @@ -97,7 +97,7 @@ const rpc = await this.queryClient.getSpQueryClient(); await rpc.Params(); ``` -More apis: +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/query-global-sp-store-price-by-time ## getStorageQueryClient @@ -109,7 +109,7 @@ await rpc.HeadBucketById({ }); ``` -More apis: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/query-group-members-exist +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/query-group-members-exist ## getVirtualGroupClient @@ -118,5 +118,5 @@ const rpc = await client.queryClient.getVirtualGroupClient(); await rpc.Params(); ``` -More apis: +More APIs: https://docs.bnbchain.org/greenfield-docs/docs/greenfield-api/available-global-virtual-group-families diff --git a/doc-site/docs/client/sp-client.mdx b/doc-site/docs/client/sp-client.mdx index abed83b0..fbed06a9 100644 --- a/doc-site/docs/client/sp-client.mdx +++ b/doc-site/docs/client/sp-client.mdx @@ -7,7 +7,7 @@ title: 'Storage Provider Client' import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -The api related to storage provider are some troublesome. +The API related to storage providers is troublesome. ## AuthType @@ -43,7 +43,7 @@ This is the sp service information you want to use. ## OffchainAuth -If you use SDK in browser, you have to get it manually (because you can't get private key in +If you use SDK in the browser, you have to get it manually (because you can't get the private key in the browser). --> ## Sp Api Example diff --git a/doc-site/docs/client/tx-client.mdx b/doc-site/docs/client/tx-client.mdx index 7bd9e843..3bccfc51 100644 --- a/doc-site/docs/client/tx-client.mdx +++ b/doc-site/docs/client/tx-client.mdx @@ -11,20 +11,20 @@ import TabItem from '@theme/TabItem'; A transaction contains at least: -1. construct a transaction: The sdk already provides each transaction type +1. construct a transaction: The SDK already provides each transaction type 2. simulate: [txClient.simulate](#simulate) 3. broadcast [txClient.broadcast](#broadcast) ## simulate -Just Simulate a transaction and valid transaction. +Just Simulate a transaction and a valid transaction. | params | description | | ------ | ------------------------------------ | | denom | the coin denom to query balances for | ```jsx title="simulate tx" -// `tx` is a transaction constructed by the sdk +// `tx` is a transaction constructed by the SDK const simulateInfo = await tx.simulate({ denom: 'BNB', }); diff --git a/doc-site/docs/getting-started/quick-start.mdx b/doc-site/docs/getting-started/quick-start.mdx index c98152dd..f09e36d0 100644 --- a/doc-site/docs/getting-started/quick-start.mdx +++ b/doc-site/docs/getting-started/quick-start.mdx @@ -116,8 +116,8 @@ Create Bucket Tx: -### 5. Create a Object +### 5. Create an Object -Creat Object Tx / Upload File / Download File: +Create Object Tx / Upload File / Download File: diff --git a/examples/nextjs/CHANGELOG.md b/examples/nextjs/CHANGELOG.md index 042775af..7b478585 100644 --- a/examples/nextjs/CHANGELOG.md +++ b/examples/nextjs/CHANGELOG.md @@ -1,15 +1,23 @@ # @demo/wallet -## 0.0.24 +## 0.0.25 ### Patch Changes - Updated dependencies - [[`24ec472`](https://github.com/bnb-chain/greenfield-js-sdk/commit/24ec472b4507d0f3cba3c8fc55b4e9f924d5b1c7), - [`b41fdf0`](https://github.com/bnb-chain/greenfield-js-sdk/commit/b41fdf057b7b4b0f416a74fb04ed0793c52c51f7), - [`865be47`](https://github.com/bnb-chain/greenfield-js-sdk/commit/865be476dfd78f86b9d0a7dba3074fbf7ae32bb7), - [`865be47`](https://github.com/bnb-chain/greenfield-js-sdk/commit/865be476dfd78f86b9d0a7dba3074fbf7ae32bb7)]: - - @bnb-chain/greenfield-js-sdk@1.2.0 + [[`159cb9c`](https://github.com/bnb-chain/greenfield-js-sdk/commit/159cb9c896d3d44b92715b2c12a6db1aeed20081)]: + - @bnb-chain/greenfield-js-sdk@1.1.3 + +## 0.0.24 + +### Patch Changes + +- Updated dependencies +[[`24ec472`](https://github.com/bnb-chain/greenfield-js-sdk/commit/24ec472b4507d0f3cba3c8fc55b4e9f924d5b1c7), +[`b41fdf0`](https://github.com/bnb-chain/greenfield-js-sdk/commit/b41fdf057b7b4b0f416a74fb04ed0793c52c51f7), +[`865be47`](https://github.com/bnb-chain/greenfield-js-sdk/commit/865be476dfd78f86b9d0a7dba3074fbf7ae32bb7), +[`865be47`](https://github.com/bnb-chain/greenfield-js-sdk/commit/865be476dfd78f86b9d0a7dba3074fbf7ae32bb7)]: +- @bnb-chain/greenfield-js-sdk@1.2.0 ## 0.0.24-alpha.2 @@ -36,6 +44,7 @@ [`865be47`](https://github.com/bnb-chain/greenfield-js-sdk/commit/865be476dfd78f86b9d0a7dba3074fbf7ae32bb7)]: - @bnb-chain/greenfield-js-sdk@1.2.0-alpha.0 + ## 0.0.23 ### Patch Changes diff --git a/examples/nextjs/package.json b/examples/nextjs/package.json index 13ad34e9..ab73cfc9 100644 --- a/examples/nextjs/package.json +++ b/examples/nextjs/package.json @@ -1,6 +1,6 @@ { "name": "@demo/wallet", - "version": "0.0.24", + "version": "0.0.25", "private": true, "scripts": { "dev": "cross-env NODE_ENV=development next dev", diff --git a/packages/js-sdk/CHANGELOG.md b/packages/js-sdk/CHANGELOG.md index 18b28a25..a2e29482 100644 --- a/packages/js-sdk/CHANGELOG.md +++ b/packages/js-sdk/CHANGELOG.md @@ -50,6 +50,14 @@ [`865be47`](https://github.com/bnb-chain/greenfield-js-sdk/commit/865be476dfd78f86b9d0a7dba3074fbf7ae32bb7) Thanks [@rrr523](https://github.com/rrr523)! - feat: Upgrade cosmos types to 0.4.0-alpha.30 +## 1.1.3 + +### Patch Changes + +- [#466](https://github.com/bnb-chain/greenfield-js-sdk/pull/466) + [`159cb9c`](https://github.com/bnb-chain/greenfield-js-sdk/commit/159cb9c896d3d44b92715b2c12a6db1aeed20081) + Thanks [@rrr523](https://github.com/rrr523)! - feat: Export Auth type + ## 1.1.2 ### Patch Changes diff --git a/packages/js-sdk/src/api/bucket.ts b/packages/js-sdk/src/api/bucket.ts index 1ddd2d44..71c23769 100644 --- a/packages/js-sdk/src/api/bucket.ts +++ b/packages/js-sdk/src/api/bucket.ts @@ -29,6 +29,7 @@ import { bytesToUtf8, hexToBytes } from 'ethereum-cryptography/utils'; import Long from 'long'; import { container, delay, inject, injectable } from 'tsyringe'; import { + AuthType, GRNToString, MsgCreateBucketTypeUrl, MsgDeleteBucketTypeUrl, @@ -65,7 +66,7 @@ import { getQueryBucketReadQuotaMetaInfo, parseReadQuotaResponse, } from '../clients/spclient/spApis/queryBucketReadQuota'; -import { AuthType, SpClient } from '../clients/spclient/spClient'; +import { SpClient } from '../clients/spclient/spClient'; import { TxClient } from '../clients/txClient'; import { METHOD_GET, NORMAL_ERROR_CODE } from '../constants/http'; import { MsgCreateBucketSDKTypeEIP712 } from '../messages/greenfield/storage/MsgCreateBucket'; diff --git a/packages/js-sdk/src/api/objects.ts b/packages/js-sdk/src/api/objects.ts index 53641df1..316f47ae 100644 --- a/packages/js-sdk/src/api/objects.ts +++ b/packages/js-sdk/src/api/objects.ts @@ -66,8 +66,9 @@ import { newObjectGRN, } from '..'; import { RpcQueryClient } from '../clients/queryclient'; -import { AuthType, SpClient } from '../clients/spclient/spClient'; +import { SpClient } from '../clients/spclient/spClient'; import { + AuthType, CreateObjectApprovalRequest, CreateObjectApprovalResponse, GetListObjectPoliciesRequest, diff --git a/packages/js-sdk/src/api/payment.ts b/packages/js-sdk/src/api/payment.ts index 1039e48a..77e062c5 100644 --- a/packages/js-sdk/src/api/payment.ts +++ b/packages/js-sdk/src/api/payment.ts @@ -29,6 +29,7 @@ import { } from '@bnb-chain/greenfield-cosmos-types/greenfield/payment/tx'; import { container, delay, inject, injectable } from 'tsyringe'; import { + AuthType, MsgDepositTypeUrl, MsgDisableRefundTypeUrl, MsgWithdrawTypeUrl, @@ -41,7 +42,7 @@ import { getListUserPaymentAccountMetaInfo, parseListUserPaymentAccountResponse, } from '../clients/spclient/spApis/listUserPaymentAccounts'; -import { AuthType, SpClient } from '../clients/spclient/spClient'; +import { SpClient } from '../clients/spclient/spClient'; import { TxClient } from '../clients/txClient'; import { MsgDepositSDKTypeEIP712 } from '../messages/greenfield/payment/MsgDeposit'; import { MsgDisableRefundSDKTypeEIP712 } from '../messages/greenfield/payment/MsgDisableRefund'; diff --git a/packages/js-sdk/src/clients/spclient/auth.ts b/packages/js-sdk/src/clients/spclient/auth.ts index 9fea4cd2..8d50a96e 100644 --- a/packages/js-sdk/src/clients/spclient/auth.ts +++ b/packages/js-sdk/src/clients/spclient/auth.ts @@ -1,11 +1,10 @@ import { signSignatureByEddsa } from '@/offchainauth'; -import { ReqMeta } from '@/types/auth'; +import { AuthType, ReqMeta } from '@/types/auth'; import { hexlify, joinSignature } from '@ethersproject/bytes'; import { SigningKey } from '@ethersproject/signing-key'; import { Headers } from 'cross-fetch'; import { keccak256 } from 'ethereum-cryptography/keccak.js'; import { utf8ToBytes } from 'ethereum-cryptography/utils.js'; -import { AuthType } from './spClient'; export const getCanonicalHeaders = (reqMeta: Partial, reqHeaders: Headers) => { const sortedHeaders = getSortedHeaders(reqHeaders, SUPPORTED_HEADERS); diff --git a/packages/js-sdk/src/clients/spclient/spClient.ts b/packages/js-sdk/src/clients/spclient/spClient.ts index 05db7865..9f748199 100644 --- a/packages/js-sdk/src/clients/spclient/spClient.ts +++ b/packages/js-sdk/src/clients/spclient/spClient.ts @@ -7,29 +7,11 @@ import { } from '@/clients/spclient/auth'; import { parseError } from '@/clients/spclient/spApis/parseError'; import { SP_NOT_AVAILABLE_ERROR_CODE, SP_NOT_AVAILABLE_ERROR_MSG } from '@/constants/http'; -import { ReqMeta } from '@/types/auth'; +import { AuthType, ReqMeta } from '@/types/auth'; import { injectable } from 'tsyringe'; import { getGetObjectMetaInfo } from './spApis/getObject'; import { getPutObjectMetaInfo } from './spApis/putObject'; -/** - * ECDSA Signature - */ -export type ECDSA = { - type: 'ECDSA'; - privateKey: string; -}; -/** - * EDDSA Signature - */ -export type EDDSA = { - type: 'EDDSA'; - seed: string; - domain: string; - address: string; -}; -export type AuthType = ECDSA | EDDSA; - export interface ISpClient { callApi( url: string, diff --git a/packages/js-sdk/src/types/auth.ts b/packages/js-sdk/src/types/auth.ts index a577d7c9..e77959b7 100644 --- a/packages/js-sdk/src/types/auth.ts +++ b/packages/js-sdk/src/types/auth.ts @@ -1,5 +1,23 @@ import { METHOD_GET, METHOD_POST, METHOD_PUT } from '@/constants/http'; +/** + * ECDSA Signature + */ +export type ECDSA = { + type: 'ECDSA'; + privateKey: string; +}; +/** + * EDDSA Signature + */ +export type EDDSA = { + type: 'EDDSA'; + seed: string; + domain: string; + address: string; +}; +export type AuthType = ECDSA | EDDSA; + export interface ReqMeta { method: typeof METHOD_GET | typeof METHOD_POST | typeof METHOD_PUT; contentType: string; diff --git a/packages/reed-solomon/CHANGELOG.md b/packages/reed-solomon/CHANGELOG.md index f989cd52..4b441220 100644 --- a/packages/reed-solomon/CHANGELOG.md +++ b/packages/reed-solomon/CHANGELOG.md @@ -1,5 +1,13 @@ # @bnb-chain/reed-solomon +## 1.1.3 + +### Patch Changes + +- [#458](https://github.com/bnb-chain/greenfield-js-sdk/pull/458) + [`4cf4abc`](https://github.com/bnb-chain/greenfield-js-sdk/commit/4cf4abc348c080f73abd8578f0092ca6ab318fe3) + Thanks [@rrr523](https://github.com/rrr523)! - fix: SwapRows + ## 1.1.2 ### Patch Changes diff --git a/packages/reed-solomon/package.json b/packages/reed-solomon/package.json index af41177e..4fc77da0 100644 --- a/packages/reed-solomon/package.json +++ b/packages/reed-solomon/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/reed-solomon", - "version": "1.1.2", + "version": "1.1.3", "description": "lighting implement for reed solomon", "module": "./dist/index.esm.js", "main": "./dist/index.js", diff --git a/packages/reed-solomon/src/index.js b/packages/reed-solomon/src/index.js index d4dd77d3..fa4e7ad2 100644 --- a/packages/reed-solomon/src/index.js +++ b/packages/reed-solomon/src/index.js @@ -178,9 +178,6 @@ export class ReedSolomon { }; } - /** - * @param {Array[{index, segChecksum, encodeDataHash}]} encodeShards - */ getChecksumsByEncodeShards(encodeShards) { let hashList = []; let segChecksumList = []; diff --git a/packages/reed-solomon/src/matrix.js b/packages/reed-solomon/src/matrix.js index d4fde507..84e1f731 100644 --- a/packages/reed-solomon/src/matrix.js +++ b/packages/reed-solomon/src/matrix.js @@ -125,7 +125,7 @@ function gaussianElimination(m) { if (m[r][r] === 0) { for (let rowBelow = r + 1; rowBelow < rows; rowBelow++) { if (m[rowBelow][r] !== 0) { - let err = SwapRows(r, rowBelow); + let err = SwapRows(m, r, rowBelow); if (err !== null) { return err; } diff --git a/packages/reed-solomon/src/web.adapter.js b/packages/reed-solomon/src/web.adapter.js index e400befc..3088736c 100644 --- a/packages/reed-solomon/src/web.adapter.js +++ b/packages/reed-solomon/src/web.adapter.js @@ -12,6 +12,9 @@ export class WebAdapterReedSolomon extends ReedSolomon { } async encodeInWorker(sourceData) { + if (!this.workerNum || !this.workers) + throw new Error('`initWorkers` must be executed first to ensure the number of workers'); + // RES is `encodeShards` Array let RES = []; const chunkList = splitPrice(sourceData, this.segmentSize);