Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blindbox-sdk

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blindbox-sdk - npm Package Compare versions

Comparing version 0.3.8 to 0.3.9

2

package.json
{
"name": "blindbox-sdk",
"version": "0.3.8",
"version": "0.3.9",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "author": "Lucklyric",

## SDK Package
[![npm version](https://badge.fury.io/js/blindbox-sdk.svg)](https://badge.fury.io/js/blindbox-sdk)

@@ -8,2 +9,4 @@ - [Install](#install)

- [Interface](#interface)
- [RiverBox](#riverbox-interface)
- [RiverBoxEx(change)](#riverboxex-interface)
- [MockClient Example](#mockclient-example)

@@ -128,20 +131,33 @@

JsonRpcProvider or WebSocketProvider or APIProviders:
Use low-level etherjs contract interface directly
```typescript
import { riverBoxProvider, IClient } from 'blindbox-sdk';
import { WebSocketProvider } from '@ethersproject/providers';
import { ethers, Signer, Wallet } from 'ethers';
import {
RiverBox,
RiverBox__factory,
RiverBoxExchange,
RiverBoxExchange__factory,
} from "blindbox-sdk";
import { JsonRpcProvider } from "@ethersproject/providers";
import { ethers, Signer, Wallet } from "ethers";
const CONTRACT_ADDRESS = '0x5FbDB2315678afecb367f032d93F642f64180aa3'; // example
const RIVERBOX_CONTRACT_ADDRESS = "0x0f522004467899fcbde46d3dec324e8f3238db14"; // v 0.2.0 contract deployed on BSC-Testnet
const RIVERBOX_EX_CONTRACT_ADDRESS =
"0xA54eB5997260aeE8BC6b572B7CCdb599bad27280"; // v 0.1.0 exchange contract deployed on BSC-Testnet
const PRIVATE_KEY =
'0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e';
"c1c9223e46ba4b7e3c5bc221fa92cba079999f853d6fb683b95579007fd8c873";
// https://docs.ethers.io/v5/api/providers/
const provider: WebSocketProvider = new ethers.providers.WebSocketProvider(
'http://localhost:8545'
const provider: JsonRpcProvider = new ethers.providers.JsonRpcProvider(
"https://data-seed-prebsc-1-s1.binance.org:8545/"
);
const signer: Wallet = new Wallet(PRIVATE_KEY).connect(provider);
const client: IClient = riverBoxProvider(CONTRACT_ADDRESS, provider, signer);
const client = await client.symbol();
// console> RB
async function main() {
const riverBox: RiverBox = RiverBox__factory.connect(
RIVERBOX_CONTRACT_ADDRESS,
signer
);
console.log(`total balance ${await riverBox.totalSupply()}`);
}
main();
```

@@ -151,26 +167,9 @@

### Interface
#### RiverBox Interface
[riverbox-client.ts](./src/client/riverbox-client.ts)
```typescript
export interface IBuyResult {
transactionHash: string;
newTokenIds: BigNumber[];
}
export interface IFuseResult {
transactionHash: string;
newTokenId: BigNumber;
}
export interface IAwardedBoxEvent {
payer: string;
tokenId: BigNumber;
}
export interface IProductDetail {
locationId: BigNumber;
signature: BigNumber; // item properties hash - uint256
creationTime: BigNumber; // unix time
fused: BigNumber; // number of times used to fuse item
parts: BigNumber[]; // a list of token ids which are used to fuse this item
}
export interface IClient {
connectProvider(address: string, provider: Provider): IClient;
export interface RiverBoxClient {
connectProvider(address: string, provider: Provider): RiverBoxClient;
connectSigner(signer: Signer): IClient;
connectSigner(signer: Signer): RiverBoxClient;

@@ -182,3 +181,3 @@ setWaitConfirmations(num: number): void;

*/
contract?(): RiverBox | undefined;
riverBoxContract?(): Promise<RiverBox>;

@@ -189,6 +188,5 @@ /*======== RiverBox specific ======*/

/**
* Return current box price
* Return on current box price
*/
boxPrice(
): Promise<BigNumber>;
boxPrice(): Promise<BigNumber>;

@@ -201,6 +199,6 @@ /**

*/
tokenDetails(
tokenDetail(
tokenId: BigNumber,
config?: PayableOverrides
): Promise<IProductDetail>;
): Promise<ContractTokenDetail>;

@@ -248,9 +246,6 @@ /**

* Fetch number of paid boxes
* @param address
* @param address
* @return number of paid boxes
*/
paidBoxes(
account: string,
config?: PayableOverrides
): Promise<BigNumber>;
paidBoxes(account: string, config?: PayableOverrides): Promise<BigNumber>;
/* transactions */

@@ -264,3 +259,6 @@

*/
buy(quality: BigNumber, config?: PayableOverrides): Promise<IBuyResult>;
buy(
quality: BigNumber,
config?: PayableOverrides
): Promise<ContractBuyResult>;

@@ -273,3 +271,6 @@ /**

*/
fuse(tokenIds: BigNumber[], config?: PayableOverrides): Promise<IFuseResult>;
fuse(
tokenIds: BigNumber[],
config?: PayableOverrides
): Promise<ContractFuseResult>;

@@ -291,9 +292,47 @@ /*======== ERC721 standard API ======*/

tokenByIndex(index: BigNumber, config?: PayableOverrides): Promise<BigNumber>;
}
```
#### RiverBoxEx Interface
[riverbox-ex-client.ts](./src/client/riverbox-ex-client.ts)
```typescript
export interface RiverBoxExClient {
connectProvider(address: string, provider: Provider): RiverBoxExClient;
/* transactions */
// TODO
connectSigner(signer: Signer): RiverBoxExClient;
setWaitConfirmations(num: number): void;
/**
* Backup interface
* @return RiverBox typechain interface for RiverBox contract
*/
contract?(): Promise<RiverBoxExchange>;
/**
* Post a new deal
* @param tokenId
* @param price in BNB wei 18d
* @param config ethers PayableOverrides
* @return ContractPostDealResult {dealId, transactionHash}
*/
postDeal(tokenId: BigNumber, price: BigNumber, config?: PayableOverrides): Promise<ContractPostDealResult>;
/**
* Cancel an existing deal
* @param dealId
* @param config ethers PayableOverrides
* @return transactionHash
*/
cancelDeal(dealId: BigNumber, config?: PayableOverrides): Promise<string>;
/**
* Buy a deal
* @param dealId
* @param config ethers PayableOverrides {value: should >= deal price}
* @return dealId
*/
buyDeal(dealId: BigNumber, config?: PayableOverrides): Promise<string>;
}
}
```
```
### MockClient Example

@@ -300,0 +339,0 @@ Usage - (MockClient ([sdk-mock.spec.ts](./test/sdk-mock.spec.ts)) output shown by test console output)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc