forked from MetaMask/metamask-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Removed codepen examples added components to documentati…
…on (MetaMask#93) * Added Sending Eth Transaction Example * removed codepen examples and added example components * finished accessing accounts refactor * finished codepend reactor in guide section * cleaned package.json and packagelog.json
- Loading branch information
Showing
15 changed files
with
266 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<div> | ||
<button type="button" class="btn primaryBtn" @click="getAccount()"> | ||
Enable Ethereum | ||
</button> | ||
<h3>Current Account: {{ currentAccount }}</h3> | ||
<h3> Account Changed to:{{checkAddress}}</h3> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
mounted() { | ||
console.log('heyy') | ||
const handler = (accounts) => { | ||
this.checkAddress = accounts[0] | ||
} | ||
window.ethereum.on('accountsChanged', handler) | ||
this.$on('hook:beforeDestroy', () => { | ||
window.ethereum.off('accountsChanged', handler) | ||
}) | ||
}, | ||
data() { | ||
return { | ||
currentAccount: '', | ||
checkAddress: null | ||
}; | ||
}, | ||
methods: { | ||
async getAccount() { | ||
const accounts = await window.ethereum.enable(); | ||
this.currentAccount = accounts[0]; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped></style> |
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 @@ | ||
<template> | ||
<div> | ||
<button type="button" class="btn primaryBtn" @click="getAccount()"> | ||
Enable Ethereum | ||
</button> | ||
<p>Account: {{ethAccount}}</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
ethereum: window.ethereum, | ||
ethAccount: '' | ||
}; | ||
}, | ||
methods: { | ||
async getAccount() { | ||
const accounts = await ethereum.enable() // We currently only ever provide a single account, | ||
this.ethAccount = accounts[0] // but the array gives us some room to grow. | ||
}, | ||
}, | ||
}; | ||
</script> |
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,21 @@ | ||
<template> | ||
<button class="btn primaryBtn" @click="connectToEthereumNetwork()"> | ||
Enable Ethereum | ||
</button> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
ethereum: window.ethereum, | ||
}; | ||
}, | ||
methods: { | ||
connectToEthereumNetwork() { | ||
this.ethereum.enable(); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
<template> | ||
<div> | ||
<eth-connect-button></eth-connect-button> | ||
<button class="btn greenBtn" @click="sendEthTransaction()">Send Eth</button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import EthConnectButton from "./EthConnectButton"; | ||
export default { | ||
components: { | ||
EthConnectButton, | ||
}, | ||
data() { | ||
return { | ||
accounts: [], | ||
}; | ||
}, | ||
methods: { | ||
sendEthTransaction() { | ||
web3.eth.sendTransaction( | ||
{ | ||
from: this.accounts[0], | ||
to: "0x2f318C334780961FB129D2a6c30D0763d9a5C970", | ||
value: "0x29a2241af62c0000", | ||
gas: 21000, | ||
gasPrice: 20000000000, | ||
}, | ||
(result) => { | ||
console.log(result); | ||
} | ||
); | ||
}, | ||
}, | ||
}; | ||
</script> |
49 changes: 0 additions & 49 deletions
49
docs/.vuepress/components/diagram-markdown-slot-relationship.vue
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,19 @@ | ||
|
||
|
||
import EthConnectButton from './components/EthConnectButton'; | ||
import EthAsyncConnectButton from './components/EthAsyncConnectButton'; | ||
import ChangeAccount from './components/ChangeAccount'; | ||
import SendTransaction from './components/SendTransaction'; | ||
|
||
export default ({ Vue, isServer }) => { | ||
if (!isServer) { | ||
import('vue-toasted' /* webpackChunkName: "notification" */).then((module) => { | ||
Vue.use(module.default) | ||
}) | ||
} | ||
|
||
Vue.component('EthConnectButton', EthConnectButton); | ||
Vue.component('EthAsyncConnectButton', EthAsyncConnectButton); | ||
Vue.component('ChangeAccount', ChangeAccount); | ||
Vue.component('SendTransaction', SendTransaction); | ||
} |
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
Oops, something went wrong.