Giter Site home page Giter Site logo

Stability for Flow about sips HOT 11 CLOSED

caffeinum avatar caffeinum commented on July 19, 2024
Stability for Flow

from sips.

Comments (11)

caffeinum avatar caffeinum commented on July 19, 2024 1

on hold

from sips.

caffeinum avatar caffeinum commented on July 19, 2024 1

Есть предложение разделить 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.

caffeinum avatar caffeinum commented on July 19, 2024

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.

caffeinum avatar caffeinum commented on July 19, 2024
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.

0xZick avatar 0xZick commented on July 19, 2024

полностью за, это как Игорь сделал EOS - BTC только ты хочешь более явно разделить

from sips.

noxonsu avatar noxonsu commented on July 19, 2024

чеклист перенести в темплейты ишью и закрыть можно думаю

from sips.

caffeinum avatar caffeinum commented on July 19, 2024

@noxonsu ишью о том, чтоб учесть эти все проблемы в архитектуре. Можно временно закрыть, наверное

from sips.

noxonsu avatar noxonsu commented on July 19, 2024

перенести в вики тогда и закрыть

from sips.

caffeinum avatar caffeinum commented on July 19, 2024

Это более общий вариант #4

from sips.

caffeinum avatar caffeinum commented on July 19, 2024

Пока что мы пришли примерно к такому, если вкратце:

Вначале берем 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.

noxonsu avatar noxonsu commented on July 19, 2024

устарело

from sips.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.