Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bucket availability method to Smart Contract module #115

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### vNext

- Add bucket availability method to Smart Contract module
- Get $CERE decimals value from blockchain properties instead of hardcoded value
- Fix RPC error handling in Smart Contract module
- Update build and publish to use Lerna.js
Expand Down
4 changes: 4 additions & 0 deletions packages/smart-contract/src/SmartContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export class SmartContract extends SmartContractBase {
await this.submit(this.contract.tx.bucketAllocIntoCluster, bucketId, resource);
}

async bucketSetAvailability(bucketId: BucketId, isPublic: boolean) {
await this.submit(this.contract.tx.bucketSetAvailability, bucketId, isPublic);
}

async accountDeposit(value: Balance) {
await this.submitWithOptions(this.contract.tx.accountDeposit, {value: this.toUnits(value)});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const TESTNET: SmartContractOptions = {

export const DEVNET: SmartContractOptions = {
rpcUrl: 'wss://archive.devnet.cere.network/ws',
contractAddress: '6T6VK3YfpsTfK4HtHkjGKubU322pmEmbUfmf1GLdydh772t1',
contractAddress: '6U7MUyRTQNLVwTao9JuvDFoiJxsk6HNtQZ8XFswPrkLmQPjx',
abi: ddcBucketAbi,
};

Expand Down
7 changes: 7 additions & 0 deletions tests/SmartContract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ describe('Smart Contract', () => {
expect(foundBucket.bucketId).toEqual(createdBucketId);
});

test('set bucket availability', async () => {
await userContract.bucketSetAvailability(createdBucketId, true);
const foundBucket = await userContract.bucketGet(createdBucketId);

expect(foundBucket.bucket.publicAvailability).toEqual(true);
});

test('get all buckets', async () => {
const [buckets, totalCount] = await userContract.bucketList();

Expand Down
Loading