Comments (11)
on hold
from sips.
Есть предложение разделить Flow на две части:
- setup
- withdraw
Шаги убрать, вместо этого добавить список проверок, делать их можно в любом порядке. Это значит, почти весь код из Flow перенести в классы ***Swap. А Flow сведется к
// BTC2ETH
try {
await btcSwap.setup()
await ethSwap.check()
await ethSwap.withdraw()
} catch () {
await btcSwap.refund()
}
Например, список необходимых действий для обменов BTC<->ETH
ETHSwap | |
---|---|
Sender | Recipient |
lock funds | check contract balance |
withdraw |
BTCSwap | |
---|---|
Sender | Recipient |
request sign | request script values |
submit secret | check script |
sync balance | verify script |
lock funds | withdraw |
send script values |
from sips.
All in all, state has two parts:
- informational flags
- crypto data
On exiting every step, Flow should have this data:
step | flags | data |
---|---|---|
setup | meSigned,participantSigned | |
sync balance | balanceEnough | balance |
lock base | baseLocked | scriptValues, (secret), secretHash, lockedBalance, lockTxHash |
lock seco | secondaryLocked | lockedBalance, lockTxHash |
withdraw seco | secondaryWithdrawn | withdrawTxHash, (secret) |
withdraw base | baseWithdrawn | withdrawTxHash |
Also, for every step, there is a person, who decides step's finished.
step | responsible |
---|---|
setup | both |
sync balance | both |
lock base | secondaryOwner |
lock seco | baseOwner |
withdraw seco | secondaryOwner |
withdraw base | baseOwner |
finish | both |
from sips.
this.state = {
step: 0,
signTransactionHash: null,
isSignFetching: false,
isMeSigned: false,
secretHash: null,
btcScriptValues: null,
btcScriptVerified: false,
isBalanceFetching: false,
isBalanceEnough: false,
balance: null,
btcScriptCreatingTransactionHash: null,
ethSwapCreationTransactionHash: null,
isEthContractFunded: false,
secret: null,
isEthWithdrawn: false,
isBtcWithdrawn: false,
refundTransactionHash: null,
isRefunded: false,
isFinished: false,
}
from sips.
полностью за, это как Игорь сделал EOS - BTC только ты хочешь более явно разделить
from sips.
чеклист перенести в темплейты ишью и закрыть можно думаю
from sips.
@noxonsu ишью о том, чтоб учесть эти все проблемы в архитектуре. Можно временно закрыть, наверное
from sips.
перенести в вики тогда и закрыть
from sips.
Это более общий вариант #4
from sips.
Пока что мы пришли примерно к такому, если вкратце:
Вначале берем BTC2EOS Игоря, а дальше смотрим:
pull Handlers
Это круто, более того, они нужны везде, поэтому логично положить из в swap.swap/Room.js
push Handlers
По сути являются сообщениями, чаще всего это ответы на pull. Их можно сделать структурами данных без кода вовсе.
import { scriptValuesMessageGenerator } from '../btc/push'
room.sendMessage(scriptValuesMessageGenerator(state))
transaction Handlers
Тут самый сок. Это именно то, что отвечает прямо за действия.
Но почему бы не класть их напрямую в BtcSwap, EthSwap ? Это как раз действия с блокчейном.
Примеры идей:
caffeinum/swap.core@fd5925a
from sips.
устарело
from sips.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sips.