Skip to content

Commit 843ab10

Browse files
committed
@bitte-ai/react
0 parents  commit 843ab10

25 files changed

+77343
-0
lines changed

.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const path = require('path');
2+
module.exports = {
3+
"extends": "../../.eslintrc.json",
4+
"parserOptions": {
5+
"project": path.resolve(__dirname, "../../tsconfig.lint.json"),
6+
}
7+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
[//]: # `{ "title": "@mintbase-js/react", "order": "3" }`
2+
3+
# @mintbase-js/react
4+
5+
This package contains React helpers for interacting with Mintbase JS.
6+
7+
<p align="center">
8+
9+
<img src='https://img.shields.io/npm/dw/@mintbase-js/react' />
10+
11+
<img src='https://img.shields.io/bundlephobia/min/@mintbase-js/react'>
12+
13+
</p>
14+
15+
Example:
16+
You can check a [quick example of Simple Login](https://github.com/Mintbase/examples/tree/main/starter) using Next.js 14 and @mintbase-js/react
17+
18+
19+
[Check our Templates repository for Mintbase.js](https://github.com/Mintbase/templates)
20+
21+
[Live Demo](https://starter.mintbase.xyz/)
22+
23+
## Summary
24+
25+
- [Installing](#Installing)
26+
27+
- [BitteWalletContextProvider (default)](#bittewalletcontextprovider) : The default Bitte Wallet provider
28+
29+
30+
# Installing
31+
32+
`@mintbase-js/react relies on React and React Dom version v18.2.0 due to @near-wallet-selector/modal-ui`
33+
34+
### NPM:
35+
36+
```
37+
npm install @mintbase-js/react
38+
npm install @near-wallet-selector/modal-ui
39+
```
40+
41+
### Yarn:
42+
43+
```
44+
yarn add @mintbase-js/react
45+
yarn add @near-wallet-selector/modal-ui
46+
```
47+
48+
### PNPM:
49+
50+
```
51+
pnpm install @mintbase-js/react
52+
pnpm install @near-wallet-selector/modal-ui
53+
```
54+
55+
# BitteWalletContextProvider
56+
57+
the default way of interacting with Mintbase Wallet is using the BitteWalletContextProvider
58+
59+
{% code title="app.tsx" overflow="wrap" lineNumbers="true" %}
60+
61+
## properties:
62+
63+
**contractAddress** (optional): `If you set this it will connect the user using Limited Access Keys, set with your near contract address / your mintbase store address`
64+
65+
**network** : ` mainnet | testnet`
66+
67+
**callbackUrl** : `a valid https/http address to the user be sent after the transaction`
68+
69+
**onlyMbWallet** : `boolean, it sets up only MintbaseWallet or if false(default) MintbaseWallet + default wallets`
70+
71+
**additionalWallets** : `WalletModuleFactory[] extra wallets setup`
72+
73+
```typescript
74+
import "@near-wallet-selector/modal-ui/styles.css";
75+
import { BitteWalletContextProvider } from '@mintbase-js/react'
76+
77+
<BitteWalletContextProvider
78+
contractAddress="mycontract.mintbase1.near"
79+
network="mainnet"
80+
callbackUrl="https://www.mywebsite.com/callback"
81+
>
82+
<Component {...pageProps} />
83+
</BitteWalletContextProvider>
84+
85+
```
86+
87+
# Troubleshooting
88+
The wallet runs only on client-side.
89+
90+
Any other questions or issues you can contact support on our [Telegram Channel](https://telegram.me/mintdev).
91+
92+
93+
## License
94+
95+
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

dist/index.d.mts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import { WalletSelector, AccountState, VerifyOwnerParams, VerifiedOwner, WalletModuleFactory } from '@near-wallet-selector/core';
3+
export { Account, BrowserWallet, Wallet, WalletBehaviourFactory, WalletModule, WalletModuleFactory } from '@near-wallet-selector/core';
4+
import { WalletSelectorModal } from '@near-wallet-selector/modal-ui';
5+
6+
interface ContextProviderType {
7+
children: React.ReactNode;
8+
callbackUrl?: string;
9+
network?: string;
10+
onlyMbWallet?: boolean;
11+
contractAddress?: string;
12+
additionalWallets?: Array<WalletModuleFactory>;
13+
successUrl?: string;
14+
failureUrl?: string;
15+
onlyBitteWallet?: boolean;
16+
}
17+
type BitteWalletContext = {
18+
selector: WalletSelector | undefined;
19+
modal: WalletSelectorModal | undefined;
20+
accounts: AccountState[];
21+
activeAccountId: string | null;
22+
isConnected: boolean;
23+
isWaitingForConnection: boolean;
24+
isWalletSelectorSetup: boolean;
25+
errorMessage: string | null;
26+
connect: () => Promise<void>;
27+
disconnect: () => Promise<void>;
28+
signMessage: (params: VerifyOwnerParams) => Promise<VerifiedOwner>;
29+
};
30+
declare const BitteWalletContext: React.Context<BitteWalletContext | null>;
31+
declare const BitteWalletContextProvider: React.FC<ContextProviderType>;
32+
declare const useBitteWallet: () => BitteWalletContext;
33+
34+
type UseNearPriceReturn = {
35+
nearPrice: number;
36+
error: string | null;
37+
};
38+
declare const useNearPrice: () => UseNearPriceReturn;
39+
40+
export { BitteWalletContext, BitteWalletContextProvider, useBitteWallet, useNearPrice };

dist/index.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import { WalletSelector, AccountState, VerifyOwnerParams, VerifiedOwner, WalletModuleFactory } from '@near-wallet-selector/core';
3+
export { Account, BrowserWallet, Wallet, WalletBehaviourFactory, WalletModule, WalletModuleFactory } from '@near-wallet-selector/core';
4+
import { WalletSelectorModal } from '@near-wallet-selector/modal-ui';
5+
6+
interface ContextProviderType {
7+
children: React.ReactNode;
8+
callbackUrl?: string;
9+
network?: string;
10+
onlyMbWallet?: boolean;
11+
contractAddress?: string;
12+
additionalWallets?: Array<WalletModuleFactory>;
13+
successUrl?: string;
14+
failureUrl?: string;
15+
onlyBitteWallet?: boolean;
16+
}
17+
type BitteWalletContext = {
18+
selector: WalletSelector | undefined;
19+
modal: WalletSelectorModal | undefined;
20+
accounts: AccountState[];
21+
activeAccountId: string | null;
22+
isConnected: boolean;
23+
isWaitingForConnection: boolean;
24+
isWalletSelectorSetup: boolean;
25+
errorMessage: string | null;
26+
connect: () => Promise<void>;
27+
disconnect: () => Promise<void>;
28+
signMessage: (params: VerifyOwnerParams) => Promise<VerifiedOwner>;
29+
};
30+
declare const BitteWalletContext: React.Context<BitteWalletContext | null>;
31+
declare const BitteWalletContextProvider: React.FC<ContextProviderType>;
32+
declare const useBitteWallet: () => BitteWalletContext;
33+
34+
type UseNearPriceReturn = {
35+
nearPrice: number;
36+
error: string | null;
37+
};
38+
declare const useNearPrice: () => UseNearPriceReturn;
39+
40+
export { BitteWalletContext, BitteWalletContextProvider, useBitteWallet, useNearPrice };

0 commit comments

Comments
 (0)