Skip to content

Commit

Permalink
docs: update docs for XDEFI wallet integration
Browse files Browse the repository at this point in the history
  • Loading branch information
HoangVD2 committed Mar 11, 2024
1 parent 0c2a081 commit 403ddc2
Show file tree
Hide file tree
Showing 23 changed files with 1,294 additions and 65 deletions.
2 changes: 1 addition & 1 deletion about/xdefi-technologies/extension-wallet.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Extension Wallet
# Extension Wallet
1 change: 0 additions & 1 deletion developers/cosmoskit-xdefi-integration.md

This file was deleted.

86 changes: 85 additions & 1 deletion developers/extension-binance.md
Original file line number Diff line number Diff line change
@@ -1 +1,85 @@
# Extension Wallet Binance Integration
# Extension Wallet Binance Integration

Develop Binance dApps

## Transfer request

- [Parameters description](https://docs.xdefi.io/docs/technical-documentation/xdefi-extension-integration/detect-xdefi-providers#parameters)

```javascript
const { asset, from, recipient, amount, memo } \= {
asset: {
chain: "BNB",
symbol: "BNB",
ticker: "BNB",
},
from: 'xxxx',
recipient: 'yyyy',
amount: {
amount: 500,
decimals: 8
},

memo: 'hint'
};

window.xfi.binance.request({
method: "transfer",
params: [{
asset,
from,
recipient,
amount,
memo,
}],
},

(error, result) => {
console.debug(error, result);
this.lastResult \= { error, result };
});
```

## Accounts request

```javascript
if (window.xfi && window.xfi.binance) {
window.xfi.binance.request(
{ method: "request_accounts", params: [] },
(error, accounts) => console.log(`Binance accounts ${accounts}`),
);
}
```

### Result example

```json
{
"error": null,
"result": ["bitcoincash:qzxr6zwfhez9g06xmpe4n8xxls36rlkqlyv606v7zh"]
}
```

## Events

### chainChanged

```javascript
if (window.xfi && window.xfi.binance) {
const provider = window.xfi.binance;
provider.on("chainChanged", (obj) => {
console.log(`chainChanged::${obj.chainId}`, obj);
});
}
```

#### accountsChanged

```javascript
if (window.xfi && window.xfi.binance) {
const provider = window.xfi.binance;
provider.on("accountsChanged", (obj) => {
console.log(`accountsChanged::${obj.chainId}`, obj);
});
}
```
73 changes: 72 additions & 1 deletion developers/extension-bitcoin-cash.md
Original file line number Diff line number Diff line change
@@ -1 +1,72 @@
# Extension Wallet Bitcoin Cash Integration
# Extension Wallet Bitcoin Cash Integration

Develop BitcoinCash dApps

## Transfer request

- [Parameters description](https://docs.xdefi.io/docs/technical-documentation/xdefi-extension-integration/detect-xdefi-providers#parameters)

```javascript
window.xfi.bitcoincash.request(
{
method: "transfer",
params: [
{
feeRate,
from,
recipient,
amount,
memo,
},
],
},
(error, result) => {
console.debug(error, result);
this.lastResult = { error, result };
},
);
```

## Accounts request

```javascript
if (window.xfi && window.xfi.bitcoincash) {
window.xfi.bitcoincash.request(
{ method: "request_accounts", params: [] },
(error, accounts) => console.log(`Bitcoincash accounts ${accounts}`),
);
}
```

### Result example

```json
{
"error": null,
"result": ["bitcoincash:qzxr6zwfhez9g06xmpe4n8xxls36rlkqlyv606v7zh"]
}
```

## Events

### chainChanged

```javascript
if (window.xfi && window.xfi.bitcoincash) {
const provider = window.xfi.bitcoincash;
provider.on("chainChanged", (obj) => {
console.log(`chainChanged::${obj.chainId}`, obj);
});
}
```

### accountsChanged

```javascript
if (window.xfi && window.xfi.bitcoincash) {
const provider = window.xfi.bitcoincash;
provider.on("accountsChanged", (obj) => {
console.log(`accountsChanged::${obj.chainId}`, obj);
});
}
```
103 changes: 102 additions & 1 deletion developers/extension-bitcoin.md
Original file line number Diff line number Diff line change
@@ -1 +1,102 @@
# Extension Wallet Bitcoin Integration
# Extension Wallet Bitcoin Integration

Develop Bitcoin dApps

Our BTC connection also implements the [sats-connect](https://docs.xverse.app/sats-connect/) interface for signing transactions. To use please install this [library](https://www.npmjs.com/package/@xdefi/btc-connect).

## Transfer request

- [Parameters description](https://docs.xdefi.io/docs/technical-documentation/xdefi-extension-integration)

```javascript
window.xfi.bitcoin.request(
{
method: "transfer",
params: [
{
feeRate,
from,
recipient,
amount,
memo,
},
],
},
(error, result) => {
console.debug(error, result);
this.lastResult = { error, result };
},
);
```

## Change network

```javascript
window.xfi.bitcoin.changeNetwork("testnet"); //active network becomes testnet
window.xfi.bitcoin.changeNetwork("mainnet"); //active network becomes mainnet
```

## Accounts request (Mainnet)

```javascript
if (window.xfi && window.xfi.bitcoin) {
window.xfi.bitcoin.request(
{ method: "request_accounts", params: [] },
(error, accounts) => console.log(`Bitcoin accounts ${accounts}`),
);
}
```

### Result example

```json
{
"error": null,
"result": ["bc1qst9xyekxekaep7tk4wd7lmrwdyc9laqngx5qpr"]
}
```

## Accounts Request (Testnet)

```javascript
if (window.xfi && window.xfi.bitcoin) {
window.xfi.bitcoin.changeNetwork("testnet");
window.xfi.bitcoin.request(
{ method: "request_accounts", params: [] },
(error, accounts) => console.log(`Bitcoin accounts ${accounts}`),
);
}
```

### Result example

```json
{
"error": null,
"result": ["tb1......"]
}
```

## Events

### chainChanged

```javascript
if (window.xfi && window.xfi.bitcoin) {
const provider = window.xfi.bitcoin;
provider.on("chainChanged", (obj) => {
console.log(`chainChanged::${obj.chainId}`, obj);
});
}
```

### accountsChanged

```javascript
if (window.xfi && window.xfi.bitcoin) {
const provider = window.xfi.bitcoin;
provider.on("accountsChanged", (obj) => {
console.log(`accountsChanged::${obj.chainId}`, obj);
});
}
```
Loading

0 comments on commit 403ddc2

Please sign in to comment.