Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Luphia1984 committed Oct 25, 2021
2 parents bcbc63c + 1c44ea7 commit 1eb52c8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,26 @@ lunar.on((event) => {
const env = lunar.env

// if lunar connect with wallet -> return boolean
const connected = lunar.connected
const isConnected = lunar.isConnected

// get supported wallet
// return Metamask|imToken|TideWallet
const walletList = l.env.wallets;
const walletList = lunar.env.wallets;

// connect with injected javascript
lunar.connect({ wallet: Lunar.Wallets.Metamask, blockchain: Lunar.Blockchains.Ropsten });

// switch blockchain
lunar.switchBlockchain(Lunar.Blockchains.AvaxTestnet);

// connect with wallet connect
const qrcode = await lunar.walletConnect();

// get blockchains
const blockchain = lunar.blockchain;

// get wallets
const wallets = lunar.wallets;

// get wallet
const wallet = await lunar.getWallet({ type: 'ethereum' });

// get address
const address = wallet.address;
const address = lunar.address;

// get ERC20
const data = await wallet.getAsset({ contract });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cafeca/lunar",
"version": "0.1.0",
"version": "0.2.0",
"description": "Blockchain Connect Module",
"main": "./build/lunar.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/constants/blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Blockchains {
chainId: "0x38",
chainName: "Binance Smart Chain Mainnet",
nativeCurrency: {
symbol: "AVAX",
symbol: "BNB",
},
rpcUrls: [ "https://bsc-dataseed.binance.org/" ],
blockExplorerUrls: [ "https://bscscan.com/" ],
Expand All @@ -21,7 +21,7 @@ class Blockchains {
chainId: "0x61",
chainName: "Binance Smart Chain Testnet",
nativeCurrency: {
symbol: "AVAX",
symbol: "BNB",
},
rpcUrls: [ "https://data-seed-prebsc-1-s1.binance.org:8545/" ],
blockExplorerUrls: [ "https://testnet.bscscan.com" ],
Expand Down
19 changes: 16 additions & 3 deletions src/lunar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,20 @@ class Lunar {
false;
}

get address() {
return this._connector ?
this._connector.address:
false;
}

get blockchain() {
return this._blockchain;
}

findConnector({ walletType }) {
return this._connectors.find((v) => {
return this._connectors
.filter((v) => !!v)
.find((v) => {
return v.type = walletType;
})
}
Expand All @@ -49,11 +61,12 @@ class Lunar {
this._connector = newConnector;
}
this._blockchain = await this._connector.connect({ blockchain });
return this.isConnected;
return this.address;
}

async switchBlockchain({ chainId }) {
this._connector._switchBlockchain({ chainId });
awaitthis._connector._switchBlockchain({ chainId });
return this.address;
}

async disconnect() {
Expand Down
2 changes: 2 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ module.exports = {
output: {
path: path.resolve(__dirname, 'build'),
filename: 'lunar.js',
library: 'Lunar',
libraryTarget:'umd'
},
};

0 comments on commit 1eb52c8

Please sign in to comment.