Skip to content

Commit

Permalink
Merge branch 'main' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Jan 5, 2024
2 parents 3a4e8a5 + cfa55a5 commit 17b4313
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: checksums
title: cacluting checksum is slow
title: calculating checksum is slow
order: 1
---

Expand All @@ -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

Expand Down Expand Up @@ -126,7 +126,7 @@ If the file is larger, this method may cause the page to freeze when calculating
</TabItem>
<TabItem value="nodejs" label="Nodejs">

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')
Expand Down
2 changes: 1 addition & 1 deletion doc-site/docs/client/greenfield.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

:::

Expand Down
22 changes: 11 additions & 11 deletions doc-site/docs/client/query-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
4 changes: 2 additions & 2 deletions doc-site/docs/client/sp-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions doc-site/docs/client/tx-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand Down
4 changes: 2 additions & 2 deletions doc-site/docs/getting-started/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ Create Bucket Tx:
<Image img={require('/img/quick-start/create-bucket.png')} />
### 5. Create a Object
### 5. Create an Object
Creat Object Tx / Upload File / Download File:
Create Object Tx / Upload File / Download File:
<Image img={require('/img/quick-start/create-object.png')} />
21 changes: 15 additions & 6 deletions examples/nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 8 additions & 0 deletions packages/js-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/js-sdk/src/api/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/js-sdk/src/api/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion packages/js-sdk/src/api/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions packages/js-sdk/src/clients/spclient/auth.ts
Original file line number Diff line number Diff line change
@@ -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<ReqMeta>, reqHeaders: Headers) => {
const sortedHeaders = getSortedHeaders(reqHeaders, SUPPORTED_HEADERS);
Expand Down
20 changes: 1 addition & 19 deletions packages/js-sdk/src/clients/spclient/spClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions packages/js-sdk/src/types/auth.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 8 additions & 0 deletions packages/reed-solomon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/reed-solomon/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 0 additions & 3 deletions packages/reed-solomon/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ export class ReedSolomon {
};
}

/**
* @param {Array[{index, segChecksum, encodeDataHash}]} encodeShards
*/
getChecksumsByEncodeShards(encodeShards) {
let hashList = [];
let segChecksumList = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/reed-solomon/src/matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit 17b4313

Please sign in to comment.