Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

woofipro: new dex #22196

Merged
merged 106 commits into from May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
f769021
woofipro: initialize new dex
sc0Vu Apr 18, 2024
9551ead
woofipro: add fetchMarkets
sc0Vu Apr 19, 2024
66fa8ed
woofipro: add fetchCurrencies
sc0Vu Apr 19, 2024
85f70f1
woofipro: add fetchTrades
sc0Vu Apr 19, 2024
66daeda
woofipro: update
sc0Vu Apr 19, 2024
c2226b5
woofipro: add fetchTime
sc0Vu Apr 19, 2024
58e4ed9
woofipro: add fetchFundingRate
sc0Vu Apr 19, 2024
fdc34c0
woofipro: add fetchFundingRates
sc0Vu Apr 19, 2024
fd5e83b
woofipro: add fetchFundingRateHistory
sc0Vu Apr 19, 2024
98aea7f
woofipro: update
sc0Vu Apr 19, 2024
f0c951c
woofipro: update signature
sc0Vu Apr 20, 2024
5d6de42
woofipro: add fetchOrderBook
sc0Vu Apr 21, 2024
a5f2345
woofipro: add fetchOHLCV
sc0Vu Apr 21, 2024
46fdb15
woofipro: add createOrder
sc0Vu Apr 21, 2024
c388596
woofipro: update
sc0Vu Apr 22, 2024
68ab2cb
woofipro: add cancelOrder
sc0Vu Apr 22, 2024
4ca61a4
woofipro: update
sc0Vu Apr 22, 2024
a139cb8
woofipro: add fetchOrders
sc0Vu Apr 22, 2024
f25e165
woofipro: add fetchOpenOrders
sc0Vu Apr 22, 2024
51152ec
woofipro: add fetchClosedOrders
sc0Vu Apr 22, 2024
dd5b7cd
woofipro: add fetchOrder
sc0Vu Apr 23, 2024
bfac8c6
woofipro: update
sc0Vu Apr 23, 2024
16b8ab5
woofipro: add fetchOrderTrades
sc0Vu Apr 23, 2024
bc290f1
woofipro: add fetchMyTrades
sc0Vu Apr 23, 2024
232cf5f
woofipro: add cancelAllOrders
sc0Vu Apr 23, 2024
5212499
woofipro: add cancelOrders
sc0Vu Apr 23, 2024
c9c589e
woofipro: add editOrder
sc0Vu Apr 23, 2024
f6028fa
woofipro: add fetchTradingFees
sc0Vu Apr 23, 2024
9bf50dc
woofipro: update
sc0Vu Apr 23, 2024
fc1e38e
woofipro: add fetchBalance
sc0Vu Apr 23, 2024
4f34e5c
woofipro: add fetchLeger functions
sc0Vu Apr 23, 2024
46d298a
woofipro: update
sc0Vu Apr 24, 2024
0a10f2c
woofipro: add setLeverage
sc0Vu Apr 24, 2024
57103b4
woofipro: add fetchLeverage
sc0Vu Apr 24, 2024
59d8ee4
woofipro: add fetchPosition
sc0Vu Apr 24, 2024
9869ac4
woofipro: add fetchPositions
sc0Vu Apr 24, 2024
1000f04
woofipro: updatw
sc0Vu Apr 24, 2024
004049f
woofipro: update
sc0Vu Apr 25, 2024
a2d318a
woofipro: update
sc0Vu Apr 25, 2024
c792a62
woofipro: update
sc0Vu Apr 25, 2024
92280ec
woofipro: update
sc0Vu Apr 25, 2024
a575cf9
woofipro: update crypto
sc0Vu Apr 25, 2024
a5ec739
woofipro: update
sc0Vu Apr 25, 2024
cfcc9a1
woofipro: update
sc0Vu Apr 26, 2024
c67af91
woofipro: update
sc0Vu Apr 26, 2024
bf2e5b6
Merge branch 'master' into add-woofipro
sc0Vu Apr 26, 2024
05975c5
woofipro: update
sc0Vu Apr 26, 2024
5c87aac
cs: update exchange
sc0Vu Apr 27, 2024
b006a0c
woofipro: update doc
sc0Vu Apr 29, 2024
0bae9b1
woofipro: add withdraw
sc0Vu Apr 29, 2024
ec08522
woofipro: update
sc0Vu Apr 29, 2024
79ae5ae
woofipro: update
sc0Vu Apr 29, 2024
25ac537
woofipro: update skip tests
sc0Vu Apr 30, 2024
cb8d261
woofipro: update static tests
sc0Vu Apr 30, 2024
8ab1973
woofipro: update static tests
sc0Vu Apr 30, 2024
068826f
woofipro: update
sc0Vu Apr 30, 2024
de16f3b
woofipro: update
sc0Vu Apr 30, 2024
9243925
Merge branch 'master' into add-woofipro
sc0Vu May 1, 2024
d5819c7
woofipro: update
sc0Vu May 1, 2024
548153f
woofipro: update
sc0Vu May 2, 2024
fb29f3d
woofipro: add ws
sc0Vu May 2, 2024
8c51170
woofipro: add watchTicker and watchTickers
sc0Vu May 2, 2024
5138258
woofipro: add watchOHLCV
sc0Vu May 2, 2024
a31d9d0
woofipro: add watchTrades
sc0Vu May 2, 2024
e49e7c0
woofipro: add watchOrders
sc0Vu May 3, 2024
c226f5b
woofipro: update
sc0Vu May 3, 2024
69c8a7e
woofipro: add watchPositions
sc0Vu May 3, 2024
378e1dc
woofipro: update
sc0Vu May 3, 2024
700e8d4
woofipro: add watchBalance
sc0Vu May 3, 2024
c417706
Merge branch 'master' of github.com:ccxt/ccxt into add-woofipro
carlosmiei May 3, 2024
3880f41
fix ts syntax
carlosmiei May 3, 2024
c814511
fix transpilation
carlosmiei May 3, 2024
cca81ea
add brokerId
carlosmiei May 3, 2024
bf7943b
update docs
carlosmiei May 3, 2024
4d81205
fix tests
carlosmiei May 3, 2024
8db9588
improve editOrder
carlosmiei May 3, 2024
b9e9679
more static tests
carlosmiei May 3, 2024
0e1bd00
add symbol to editOrder
carlosmiei May 3, 2024
69e156f
more tests
carlosmiei May 3, 2024
5f05c7a
woofipro: update
sc0Vu May 6, 2024
632d438
woofipro: replace uid with accountId
sc0Vu May 6, 2024
2d496a4
fix delete request
carlosmiei May 6, 2024
f23822a
woofipro: add createOrders (need to remove keysort of params)
sc0Vu May 7, 2024
107f03e
woofipro: update createOrders
sc0Vu May 7, 2024
068a55a
woofipro: update createOrders
sc0Vu May 7, 2024
889dfa8
fix ts syntax
carlosmiei May 7, 2024
84fd0c7
static tests setup
carlosmiei May 7, 2024
5b0e8b7
fix static tests
carlosmiei May 7, 2024
f4e2f82
fix c# build
carlosmiei May 7, 2024
5b3576e
fix python syntax
carlosmiei May 7, 2024
ba380f5
add secret to response tests
carlosmiei May 8, 2024
66099c9
add woofipro id test
carlosmiei May 8, 2024
a505f0a
fix idtest
carlosmiei May 8, 2024
33c2706
ws fixes
carlosmiei May 8, 2024
eb513db
add watchMyTrades
carlosmiei May 8, 2024
b66bc92
fix args
carlosmiei May 8, 2024
1dc16de
add more tests
carlosmiei May 8, 2024
0e0b094
woofipro: update default id
sc0Vu May 9, 2024
f645219
woofipro: update
sc0Vu May 9, 2024
0bb63ee
woofipro: use watchMultiple
sc0Vu May 9, 2024
2d73b8c
fixing linting
carlosmiei May 9, 2024
f4d83bc
fix handleUNtilOption
carlosmiei May 9, 2024
94bbf13
add logo
carlosmiei May 9, 2024
1d9235b
add referral
carlosmiei May 9, 2024
2cca55d
woofipro: update
sc0Vu May 10, 2024
d4dd9f4
woofipro: update doc
sc0Vu May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions cs/ccxt/base/Exchange.Crypto.cs
Expand Up @@ -73,7 +73,7 @@ public static string Hmac(object request2, object secret2, Delegate algorithm2 =
break;
}

return digest == "hex" ? binaryToHex(signature) : binaryToBase64(signature);
return digest == "hex" ? binaryToHex(signature) : Exchange.BinaryToBase64(signature);
}

public string hmac(object request2, object secret2, Delegate algorithm2 = null, string digest = "hex") => Hmac(request2, secret2, algorithm2, digest);
Expand Down Expand Up @@ -115,7 +115,7 @@ public static object Hash(object request2, Delegate hash = null, object digest2
{
return signature;
}
return digest == "hex" ? binaryToHex(signature) : binaryToBase64(signature);
return digest == "hex" ? binaryToHex(signature) : Exchange.BinaryToBase64(signature);
}

private static byte[] HashBytes(object request2, Delegate hash = null)
Expand Down Expand Up @@ -167,25 +167,25 @@ public static string Jwt(object data, object secret, Delegate hash = null, bool
header.Remove("iat");
}
var stringHeader = Exchange.Json(header);
var encodedHeader = Exchange.Base64urlEncode(Exchange.StringToBase64(stringHeader));
var encodedData = Exchange.Base64urlEncode(Exchange.StringToBase64(Exchange.Json(data)));
var encodedHeader = Exchange.Base64urlEncode(stringHeader);
var encodedData = Exchange.Base64urlEncode(Exchange.Json(data));
var token = encodedHeader + "." + encodedData;
string signature = null;
var algoType = alg.Substring(0, 2);
if (isRsa)
{
signature = Exchange.Base64urlEncode(Exchange.Rsa(token, secret, hash));
signature = Exchange.Base64urlEncode(Exchange.Base64ToBinary(Exchange.Rsa(token, secret, hash) as object));
}
else if (algoType == "ES")
{
var ec = Ecdsa(token, secret, p256, hash) as Dictionary<string, object>;
var r = ec["r"] as string;
var s = ec["s"] as string;
signature = Exchange.Base64urlEncode(Exchange.binaryToBase64(Exchange.ConvertHexStringToByteArray(r + s)));
signature = Exchange.Base64urlEncode(Exchange.ConvertHexStringToByteArray(r + s));
}
else
{
signature = Exchange.Base64urlEncode(Exchange.Hmac(token, secret, hash, "binary"));
signature = Exchange.Base64urlEncode(Exchange.Base64ToBinary(Exchange.Hmac(token, secret, hash, "binary") as object));
}
var res = token + "." + signature;
return res;
Expand Down Expand Up @@ -461,9 +461,9 @@ public object signMessageString(object str, object privateKey = null)
public object eddsa(object request, object secret, object alg = null)
{
alg ??= "ed25519";
var msg = Hex.HexToBytes((string)request);
var msg = Encoding.UTF8.GetBytes((string)request);
var signer = new Ed25519Signer();
var privateKey = ReadEDDSAPrivateKeyFromPem(secret as string);
var privateKey = (secret is string) ? ReadEDDSAPrivateKeyFromPem(secret as string) : new Ed25519PrivateKeyParameters(secret as byte[]);
signer.Init(true, privateKey);
signer.BlockUpdate(msg, 0, msg.Length);
byte[] signature = signer.GenerateSignature();
Expand Down
27 changes: 16 additions & 11 deletions cs/ccxt/base/Exchange.Encode.cs
@@ -1,6 +1,7 @@
namespace ccxt;
using System.Security.Cryptography;
using System.Text;
using Cryptography.ECDSA;

using MiniMessagePack;

Expand Down Expand Up @@ -61,9 +62,11 @@ public static byte[] Base64ToBinary(object pt)
return base64EncodedBytes;
}

public string base58ToBinary(object str)
public byte[] base58ToBinary(object pt) => Base58ToBinary(pt);

public static byte[] Base58ToBinary(object pt)
{
return (string)str; // stub
return Base58.Decode(pt as string);
}

public object binaryConcat(object a, object b)
Expand Down Expand Up @@ -125,12 +128,13 @@ public string binaryToBase58(object buff2)
return binaryToHex(buff);
}

public static string binaryToBase64(byte[] buff)
{
return Convert.ToBase64String(buff);
}
public string binaryToBase64(byte[] buff) => BinaryToBase64(buff);

public byte[] stringToBinary(string buff)
public static string BinaryToBase64(byte[] buff) => Convert.ToBase64String(buff);

public byte[] stringToBinary(string buff) => StringToBinary(buff);

public static byte[] StringToBinary(string buff)
{
return Encoding.UTF8.GetBytes(buff);
}
Expand Down Expand Up @@ -268,12 +272,13 @@ public string encodeURIComponent(object str2)
return result.ToString();
}

public static string Base64urlEncode(string s)
public string urlencodeBase64(object s) => Base64urlEncode(s);

public static string Base64urlEncode(object s)
{
char[] padding = { '=' };
// var toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(s);
// string returnValue = System.Convert.ToBase64String(toEncodeAsBytes)
string returnValue = s.TrimEnd(padding).Replace('+', '-').Replace('/', '_');
string str = (s is string) ? Exchange.StringToBase64(s as string) : Exchange.BinaryToBase64(s as byte[]);
string returnValue = str.TrimEnd(padding).Replace('+', '-').Replace('/', '_');
return returnValue;
}

Expand Down
3 changes: 3 additions & 0 deletions cs/ccxt/base/Exchange.Options.cs
Expand Up @@ -79,6 +79,7 @@ public partial class Exchange
public string apiKey { get; set; }
public string password { get; set; }
public string uid { get; set; }
public string accountId { get; set; }

public dict userAgents { get; set; } = new dict(){
{"chrome", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"},
Expand Down Expand Up @@ -317,6 +318,7 @@ public virtual object describe()
{ "apiKey", true },
{ "secret", true },
{ "uid", false },
{ "accountId", false },
{ "login", false },
{ "password", false },
{ "twofa", false },
Expand Down Expand Up @@ -421,6 +423,7 @@ void initializeProperties(dict userConfig = null)
this.walletAddress = SafeString(extendedProperties, "walletAddress", "");
this.token = SafeString(extendedProperties, "token", "");
this.uid = SafeString(extendedProperties, "uid", "");
this.accountId = SafeString(extendedProperties, "accountId", "");

this.userAgents = SafeValue(extendedProperties, "userAgents", userAgents) as dict;
this.userAgent = SafeString(extendedProperties, "userAgent");
Expand Down
22 changes: 14 additions & 8 deletions php/Exchange.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions php/test/test_async.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions python/ccxt/base/exchange.py
Expand Up @@ -38,7 +38,7 @@
# rsa jwt signing
from cryptography.hazmat import backends
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.asymmetric import padding, ed25519
# from cryptography.hazmat.primitives.asymmetric.utils import decode_dss_signature
from cryptography.hazmat.primitives.serialization import load_pem_private_key

Expand Down Expand Up @@ -199,6 +199,7 @@ class Exchange(object):
secret = ''
password = ''
uid = ''
accountId = None
privateKey = '' # a "0x"-prefixed hexstring private key for a wallet
walletAddress = '' # the wallet address "0x"-prefixed hexstring
token = '' # reserved for HTTP auth in some cases
Expand Down Expand Up @@ -273,6 +274,7 @@ class Exchange(object):
'apiKey': True,
'secret': True,
'uid': False,
'accountId': False,
'login': False,
'password': False,
'twofa': False, # 2-factor authentication (one-time password key)
Expand Down Expand Up @@ -1299,7 +1301,7 @@ def binary_concat_array(array):
return result

@staticmethod
def base64urlencode(s):
def urlencode_base64(s):
return Exchange.decode(base64.urlsafe_b64encode(s)).replace('=', '')

@staticmethod
Expand Down Expand Up @@ -1337,8 +1339,8 @@ def jwt(request, secret, algorithm='sha256', is_rsa=False, opts={}):
if 'nonce' in opts and opts['nonce'] is not None:
header_opts['nonce'] = opts['nonce']
header = Exchange.encode(Exchange.json(header_opts))
encoded_header = Exchange.base64urlencode(header)
encoded_data = Exchange.base64urlencode(Exchange.encode(Exchange.json(request)))
encoded_header = Exchange.urlencode_base64(header)
encoded_data = Exchange.urlencode_base64(Exchange.encode(Exchange.json(request)))
token = encoded_header + '.' + encoded_data
algoType = alg[0:2]
if is_rsa or algoType == 'RS':
Expand All @@ -1348,7 +1350,7 @@ def jwt(request, secret, algorithm='sha256', is_rsa=False, opts={}):
signature = Exchange.base16_to_binary(rawSignature['r'].rjust(64, "0") + rawSignature['s'].rjust(64, "0"))
else:
signature = Exchange.hmac(Exchange.encode(token), secret, algos[algorithm], 'binary')
return token + '.' + Exchange.base64urlencode(signature)
return token + '.' + Exchange.urlencode_base64(signature)

@staticmethod
def rsa(request, secret, alg='sha256'):
Expand Down Expand Up @@ -1430,7 +1432,9 @@ def ecdsa(request, secret, algorithm='p256', hash=None, fixed_length=False):

@staticmethod
def eddsa(request, secret, curve='ed25519'):
private_key = load_pem_private_key(Exchange.encode(secret), None)
if isinstance(secret, str):
Exchange.encode(secret)
private_key = ed25519.Ed25519PrivateKey.from_private_bytes(secret) if len(secret) == 32 else load_pem_private_key(secret, None)
return Exchange.binary_to_base64(private_key.sign(request))

@staticmethod
Expand Down
14 changes: 14 additions & 0 deletions python/ccxt/test/test_async.py
Expand Up @@ -889,6 +889,13 @@ def load_currencies_from_file(self, id):
content = io_file_read(filename)
return content

def load_credentials_from_file(self, id):
filename = self.root_dir + './ts/src/test/static/credentials/' + id + '.json'
if not io_file_exists(filename):
return None
content = io_file_read(filename)
return content

def load_static_data(self, folder, target_exchange=None):
result = {}
if target_exchange:
Expand Down Expand Up @@ -1104,6 +1111,7 @@ async def test_response_statically(self, exchange, method, skip_keys, data):
def init_offline_exchange(self, exchange_name):
markets = self.load_markets_from_file(exchange_name)
currencies = self.load_currencies_from_file(exchange_name)
credentials = self.load_credentials_from_file(exchange_name)
exchange = init_exchange(exchange_name, {
'markets': markets,
'currencies': currencies,
Expand Down Expand Up @@ -1134,6 +1142,12 @@ def init_offline_exchange(self, exchange_name):
},
})
exchange.currencies = currencies # not working in python if assigned in the config dict
if credentials is not None:
objkeys = list(credentials.keys())
for i in range(0, len(objkeys)):
credential = objkeys[i]
credential_value = credentials[credential]
set_exchange_prop(exchange, credential, credential_value)
return exchange

async def test_exchange_request_statically(self, exchange_name, exchange_data, test_name=None):
Expand Down
12 changes: 12 additions & 0 deletions skip-tests.json
Expand Up @@ -1525,6 +1525,18 @@
}
}
},
"woofipro": {
"skipMethods":{
"loadMarkets":{
"active": "undefined",
"currencyIdAndCode": "messed"
},
"fetchCurrencies":{
"withdraw": "undefined",
"deposit": "undefined"
}
}
},
"yobit": {
"skipMethods": {
"loadMarkets":{
Expand Down