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
/* | |
MonetaryCoinEro token contract ABI | |
0x227412a7d92bca453b5e2f790fc8282ca2e1a686 | |
MonetaryCoinChi token contract ABI | |
0x6644fc3e5224d28ba9172bfaa21359d43bbd4190 | |
Gdp oracle, PoS forging and optional m5 token | |
Verified code: | |
https://etherscan.io/address/0x227412a7d92bca453b5e2f790fc8282ca2e1a686#code | |
Source: | |
https://github.com/Monetary-Foundation/MonetaryCoin |
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
/** | |
* Saga.js usage example | |
* The mental model is that a saga is like a separate thread in your application | |
* that's solely responsible for side effects. redux-saga is a redux middleware, | |
* which means this thread can be started, paused and cancelled from the main | |
* application with normal redux actions, it has access to the full redux application | |
* state and it can dispatch redux actions as well. | |
*/ | |
export function* checkFaucetApi() { | |
const requestURL = checkFaucetAddress; |
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
/** | |
* Generate new seed and password | |
* https://github.com/PaulLaux/eth-hot-wallet/blob/master/app/containers/HomePage/saga.js#L69 | |
*/ | |
export function* generateWallet() { | |
try { | |
const password = generateString(generatedPasswordLength); | |
const extraEntropy = generateString(generatedPasswordLength); | |
const seed = lightwallet.keystore.generateRandomSeed(extraEntropy); |
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
import localStore from 'store/dist/store.modern'; | |
/* keystore will be saved to local storage under this key */ | |
export const localStorageKey = 'ks'; | |
/** | |
* Save wallet to localStorage | |
*/ | |
export function* saveWalletS() { | |
try { |
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
// https://github.com/PaulLaux/eth-hot-wallet/blob/master/app/containers/Header/saga.js#L203 | |
export function* SendTransaction() { | |
try { | |
// ... | |
let tx; | |
const sendAmount = new BigNumber(amount).times(Ether); | |
const sendParams = { from: fromAddress, to: toAddress, value: sendAmount, gasPrice, gas: maxGasForEthSend }; | |
function sendTransactionPromise(params) { | |
return new Promise((resolve, reject) => { |
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
// Automatically determines the use of call or sendTransaction based on the method type | |
myContractInstance.myMethod(param1 [, ...][, callback]); | |
// Explicitly calling this method - simulate execution and return result | |
// No cost, no actual transaction is sent to the blockchain | |
myContractInstance.myMethod.call(param1 [, ...] [, callback]); | |
// Explicitly sending a transaction to this method | |
myContractInstance.myMethod.sendTransaction(param1 [, ...] [, callback]); | |
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
// full source: https://github.com/PaulLaux/eth-hot-wallet/blob/master/app/containers/Header/saga.js#L203 | |
export function* SendTransaction() { | |
try { | |
// ... | |
const contractAddress = tokenInfo.contractAddress; | |
const sendParams = { from: fromAddress, value: '0x0', gasPrice, gas: maxGasForTokenSend }; | |
const tokenAmount = amount * (10 ** tokenInfo.decimals); | |
function sendTokenPromise(tokenContractAddress, sendToAddress, sendAmount, params) { | |
return new Promise((resolve, reject) => { |
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
import { channel } from 'redux-saga'; | |
const transactionChannel = channel(); | |
/* Init Dapp */ | |
function* initDappAsync(action) { | |
// ... | |
// fork to handle channel events | |
yield fork(handleChannelEvents); | |
} |
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
function* commitEthSendAsync() { | |
try { | |
const web3 = yield select(makeSelectWeb3()); | |
// ... | |
contractInstance.methods.commit().send({ | |
from: defaultAccount, | |
gasPrice, | |
value: web3.utils.toWei(amount.toString(), 'ether'), | |
}).once('transactionHash', (tx) => { | |
transactionChannel.put({ |
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
export default function* defaultSaga() { | |
// ... | |
// The polling will start only after the first CHECK_BALANCES ends | |
yield [ | |
fork(watchPollData), | |
takeLatest(CHECK_BALANCES, checkAllBalances), | |
]; | |
} | |
// Start Polling when first call to checkAllBalances succeded or fails |
OlderNewer