-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
240 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
## Contributing | ||
|
||
### Fork and set up your local env | ||
|
||
Install bun | ||
|
||
```bash | ||
curl https://bun.sh/install | bash | ||
``` | ||
|
||
Install deps | ||
|
||
```bash | ||
bun install | ||
``` | ||
|
||
### Useful scripts | ||
|
||
Build packages | ||
|
||
```bash | ||
bun run build:packages | ||
``` | ||
|
||
Run tests | ||
|
||
```bash | ||
bun run test | ||
``` | ||
|
||
Run tests watch mode | ||
|
||
```bash | ||
bun run test:watch | ||
``` | ||
|
||
### Test locally | ||
|
||
If you wish to test a package inside the extension, let's say solana: | ||
|
||
```bash | ||
cd packages/solana | ||
npm link | ||
``` | ||
|
||
Then you can run in the extension workspace: | ||
|
||
```bash | ||
npm link @trustwallet/web3-provider-solana | ||
``` | ||
|
||
--- | ||
|
||
## Adding a new chain | ||
|
||
[Adding a new chain](/docs/NEW.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## Adding a new chain | ||
|
||
Run the generate command | ||
|
||
```bash | ||
bun run generate awesomeNewChain | ||
``` | ||
|
||
This will generate all the boilerplate structure for your new chain: | ||
|
||
``` | ||
📦 newChain | ||
├─ tests | ||
├─ exceptions | ||
├─ types | ||
├─ index.ts | ||
├─ NewChainProvider.ts | ||
└─ package.json | ||
``` | ||
|
||
Then you can build it using the command | ||
|
||
```bash | ||
bun run build:packages | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
## Using the library | ||
|
||
# 1. Run | ||
|
||
```bash | ||
npm i @trustwallet/web3-provider-core | ||
``` | ||
|
||
# 2. Install your desired chain | ||
|
||
Let's use for example, ethereum | ||
|
||
```bash | ||
npm i @trustwallet/web3-provider-ethereum | ||
``` | ||
|
||
# 3. Example usage | ||
|
||
```typescript | ||
import { Web3Provider } from '@trustwallet/web3-provider-core'; | ||
import { EthereumProvider } from '@trustwallet/web3-provider-ethereum'; | ||
|
||
const ethereum = new EthereumProvider(); | ||
|
||
new Web3Provider({ | ||
strategy: AdapterStrategy.PROMISES, | ||
handler: (params: IHandlerParams) => {}, | ||
}).registerProvider(ethereum); | ||
|
||
// Register the ethereum provider | ||
window.ethereum = ethereum; | ||
``` | ||
|
||
dApps that use EIP-1193 will be able to connect to your wallet now. | ||
|
||
--- | ||
|
||
## Find more about the chains | ||
|
||
- Cosmos [Docs](/packages/cosmos/README.md) | ||
- Solana - _Wallet Standard fully compatible_ [Docs](/packages/solana/README.md) | ||
- Ethereum _EIP-1193_ [Docs](/packages/ethereum/README.md) | ||
|
||
### Using the callback Adapter | ||
|
||
```typescript | ||
const provider = new Web3Provider({ | ||
strategy: AdapterStrategy.CALLBACK, | ||
}).registerProvider(ethereum); | ||
|
||
const handler = (params: IHandlerParams) => { | ||
provider.sendResponse(params.id, ['0x0....']); | ||
}; | ||
|
||
provider.setHandler(handler); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters