eidoo / hybrid-exchange-sdk Goto Github PK
View Code? Open in Web Editor NEWThe Eidoo Hybrid Exchange Node.js SDK
Home Page: https://eidoo.io
License: MIT License
The Eidoo Hybrid Exchange Node.js SDK
Home Page: https://eidoo.io
License: MIT License
As a user I want to retrieve pair fee.
The command will create and submit an order creation.
This is a creation order payload:
{
exchangeAddress: "0xExchangeAddress",
ย ย ย "expirationBlock": "1000000000",
ย ย ย "offerTokenAddress": "0x0000000000000000000000000000000000000000",
ย ย ย "offerTokenAmount": "5742943699999999955", (BASED ON TOKEN DECIMAL)
ย ย ย "wantTokenAmount": "883000000000000000000",
ย ย ย "exchangeAddress": "0xbfd9aaac82281b54ecf60b7d53ccc9cdf13cd14e", (?)
ย ย ย "wantTokenAddress": "0x2b2c319799df9d98b0fd34c961a2e1181239de27",
ย ย ย "salt": "81861121702282757272785826314277177144908563551874336254236098011739278507166",
ย ย ย "maker": "0x721adc8c8635d1146b0025c740d094e65f83e49d" (EOA)
}
eidoo-hybrid-exchange-cli os createย
--cli-input-json <value>
--prv <privatekeyFilePath>
As a user I want to generate my personal keystore file using a cli command.
The command should be:
eidoo-hybrid-exchange-cli ethereum-wallet key-generate
--keystore-file-path The destination file path where keystore will be stored
[--hd-path] The derivation path used to retrieve the private key from seed. (default: m/44'/60'/0/0)
so you need to type your seed (12 words) and after that you have to insert a password (used to build the keystore json file).
The output will be a json file strucred as follows:
{
"address": "fakeAddress",
"crypto": {
"cipher": "aes-128-ctr",
"ciphertext": "fakeChyper",
"cipherparams": {
"iv": "fakeIv"
},
"mac": "fakeMac",
"kdf": "scrypt",
"kdfparams": {
"dklen": 32,
"n": 262144,
"r": 1,
"p": 8,
"salt": "fakesalt"
}
},
"id": "f99105b6-ef46-418c-9811-13a4f6004b70",
"version": 3
}
Under the hood will be used keythereum dump
generating a keystore file.
const options = const options = {
kdf: "scrypt",
cipher: "aes-128-ctr",
kdfparams: {
c: 262144,
dklen: 32,
prf: "hmac-sha256"
}
}
// privateKey retrieved from hd_path and mnemonic
const iv = randomBytes
const salt = randomBytes
const result = keythereum.dump(password, privateKey, salt, iv, options)
Every error at cli level will be wrapped in a CommandError in a proper way.
The private key service is a class that is exporting more than one thing.
Refactor it taking out the errors.
Enable the update exchange command for trading wallets in the cli.
Add related low level functions.
As a user I want to retrieve the ERC20 token allowance.
Given an owner address and a spender address, allowance
is the remaining amount that the spender is approved to withdraw from the owner.
The first development part of this issue is a refactor of the Erc20TokenService
and It will be added an Erc20TransactionBuilde
factory.
The second it s about allowance implementation.
Move cli and commands
directory at the same level of src
directory.
If you have time and you should do somenthing perfect you have to create another project, for istance hybrid-exchange-cli which will use the hybrid-exchange-sdk.
The approve command is under trading wallet commands right know. Make it more generic and move it under the token commands.
The override.json
for staging configuration is not working.
The command will create and submit an order creation.
This is a creation order payload:
{
exchangeAddress: "0xExchangeAddress",
ย ย ย "expirationBlock": "1000000000",
ย ย ย "offerTokenAddress": "0x0000000000000000000000000000000000000000",
ย ย ย "offerTokenAmount": "5742943699999999955", (BASED ON TOKEN DECIMAL)
ย ย ย "wantTokenAmount": "883000000000000000000",
ย ย ย "exchangeAddress": "0xbfd9aaac82281b54ecf60b7d53ccc9cdf13cd14e", (?)
ย ย ย "wantTokenAddress": "0x2b2c319799df9d98b0fd34c961a2e1181239de27",
ย ย ย "salt": "81861121702282757272785826314277177144908563551874336254236098011739278507166",
ย ย ย "maker": "0x721adc8c8635d1146b0025c740d094e65f83e49d" (EOA)
}
eidoo-hybrid-exchange-cli os createย
--cli-input-json <value>
--prv <privatekeyFilePath>
[--generate-cli-skeleton <value>]
A good example: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-skeleton.html
Change trading wallet service getAssetBalanceAsync to eventually accept trading wallet address as input.
Since a trading wallet can be outdated (meaning that it can be still registered on an old Exchange contract) the trading wallet service should not automatically retrieve the trading wallet address during a get asset balance.
As a user I want to use the cli to withdraw token from trading wallet to my EOA.
Command synopsis
eidoo-hybrid-exchange-cli tws withdraw
--from (should be the EOA aka TW owner)
--toย (should be the TW address)
--quantity (WEI)
--tokenย (ETH - TokenAddress)
[--draft]
[--raw-tx]
If draft is set toi true then it will returns the TramsactionObjectDraft object to eventually execute withdraw asset transaction manually.
If raw-tx is set to true then it will returns the signed transaction data.
Improve issue management.
Add more specific issue templates.
As a user I want to know how to install the cli command of hybrid eidoo exchange, and how to use the commands.
The command will cancel an order.
Command synopsis
eidoo-hybrid-exchange-cli os cancel
--id (the order id you are going to cancel)
--prv (the private key file path)
Retrieve the exchange smart contract address from a given trading wallet.
Add related low level functions.
Add factories for Erc20TokenService
and TradingWalletService
in order to instiantiate relative objects easier.
As a user I want to use the CLI to check the ETH or Token balance of an account.
Command synopsis
eidoo-hybrid-exchange-cli tws get-balance
--from (who is asking for the balance)
--to (trading wallet address to check the balance)
--token (eth 0x0... or tokenAddress)
As a user I want to use the CLI to check the allowance an owner gave to a spender.
Command synopsis
eidoo-hybrid-exchange-cli tks get-allowance
--from (who is asking for the balance, used also as owner parameter)
--spender (could be the trading wallet address)
--token (it's the token address)
[-- prv] (optional private key)
[-- draft] (optional draft. If set to true shows the transactionObject)
As a user I want to get the private key from tmnemonic.
Add missing trades endpoints to the Hybrid Exchange SDK.
Add at the lib level a service to retrieve all Eidoo exchange trades and all the trades by pair.
Refactor remove private key usage in CLI GetAllowance.
Add a CI system to reduce the error propagation into dev
branch.
Refactor remove private key usage in CLI GetAddress.
Fix approve tests.
Like the other services create a PrivateKeyService Builder
As a user I want to use the CLI to approve transfer of ERC20 token from my EOA to my trading.
Command synopsis
eidoo-hybrid-exchange-cli tws approve
--from (should be the EOA aka TW owner)
--toย (should be the TW address)
--quantity (WEI)
--tokenย (ETH - 0xAddress)
[--draft]
[--raw-tx]
If draft is set to true then it will returns the TramsactionObjectDraft object to eventually execute approve
transaction manually.
If raw-tx is set to true then it will returns the signed transaction data.
As a user I want to deposit token without allowance check and manual approve operation.
If you are going to deposit token , you need actually to run the following operations:
Erc20TokenService
)Erc20TokenService
)TradingWalletService
)For this it will be implemented a function which manages the flow described above.
Use the new keystore flow for the Order sign command.
Improve the project README adding a dedicated section for the CLI with usage info.
The ABaseCommand has as dependency the private key services, it means that all commands will need it also if they are not using it.
Use the new keystore flow for the Withdraw command.
As a user I want to use the CLI to deposit ETH from my EOA to my trading.
Command synopsis
eidoo-hybrid-exchange-cli tws deposit-eth
--from (should be the EOA aka TW owner)
--toย (should be the TW address)
--quantity (WEI)
[--draft]
[--raw-tx]
If draft is set to true then it will returns the TramsactionObjectDraft object to eventually execute deposit ETH transaction manually.
If raw-tx is set to true then it will returns the signed transaction data.
tokenAddress = 0x00..
Upgrade packages due to security warnings.
The commands
dir should be structered in the same way the cli command is.
The config must be injected to the services to allows a better app development.
Refactor remove private key usage in CLI GetBalance.
buildTransactionDraft
method should be called one and only one time in doExecuteAsync in each command.
In doExecuteAsync
buildTransactionDraft was called 2 times.
The first one before draft flag check and the second one inside the specific service method call.
For istance in WithdrawCommand class buildWithdrawTransactionDraft was called in doExecuteAsync and in withdrawAsync
method of tradingWalletService.
As a user I want to use the CLI to deposit Tokens from my EOA to my trading wallet.
Command synopsis
eidoo-hybrid-exchange-cli tws deposit-tkn
--from (should be the EOA aka TW owner)
--toย (should be the TW address)
--quantity (WEI)
--token (token address)
[--draft]
[--raw-tx]
[--with-approve] (default true)
If draft is set to true then it will returns the TramsactionObjectDraft object to eventually execute deposit token transaction manually. (it will not consider the --with-approve
)
If raw-tx is set to true then it will returns the signed transaction data. (it will not consider the --with-approve
)
Refactor the commandList
file using a builder for each command.
Use the new keystore flow for the Order create command.
Use the new keystore flow for the DepositToken command.
Use the new keystore flow for the Order cancel command.
As a user I want to retrieve pair price.
Use the new keystore flow for the CreateWallet command.
Use the new keystore flow for the Approve command.
Retrieve the owner address from a given trading wallet.
Add related low level functions.
Right know the deposit eth command takes as input a private key file path containing the plain private key:
const privateKeyFilePathArg = new CommandArg('private-key-path',
'string', 'prv', 'The private key file path.', 1, false)
We need to replace it with --keystore-file-path
.
Once the command is launched a password prompt must be showed asking the password to unlock the account.
Args:
--from (EOA - demand)
--to (Trading Wallet - demand)
--quantity (Amount - demand)
--keystore-file-path (demand)
--draft
--raw-tx
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.