This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b3d62b
commit 1e6ede4
Showing
53 changed files
with
5,521 additions
and
5,525 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"semi": true, | ||
"trailingComma": "none", | ||
"singleQuote": false, | ||
"singleQuote": true, | ||
"printWidth": 160, | ||
"tabWidth": 4 | ||
"tabWidth": 2 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,166 +1,166 @@ | ||
import { IndexedOrder, OrderResponse, FullOrder } from "@airswap/types"; | ||
import { FullOrderERC20 } from "@airswap/types"; | ||
import { AddressZero } from "@ethersproject/constants"; | ||
import { DbOrderERC20, DbOrder } from "./model/DbOrderTypes.js"; | ||
import { JsonRpcResponse } from "@airswap/libraries"; | ||
import { IndexedOrder, OrderResponse, FullOrder } from '@airswap/types'; | ||
import { FullOrderERC20 } from '@airswap/types'; | ||
import { AddressZero } from '@ethersproject/constants'; | ||
import { DbOrderERC20, DbOrder } from './model/DbOrderTypes.js'; | ||
import { JsonRpcResponse } from '@airswap/libraries'; | ||
|
||
export function forgeIndexedOrderERC20(expectedAddedDate: number, expiryDate: number, hash = "hash"): IndexedOrder<DbOrderERC20> { | ||
return { order: forgeDbOrderERC20(expiryDate), addedOn: expectedAddedDate, hash }; | ||
export function forgeIndexedOrderERC20(expectedAddedDate: number, expiryDate: number, hash = 'hash'): IndexedOrder<DbOrderERC20> { | ||
return { order: forgeDbOrderERC20(expiryDate), addedOn: expectedAddedDate, hash }; | ||
} | ||
|
||
export function forgeIndexedOrder(expectedAddedDate: number, expiryDate: number, hash = "hash"): IndexedOrder<DbOrder> { | ||
return { order: forgeDbOrder(expiryDate), addedOn: expectedAddedDate, hash }; | ||
export function forgeIndexedOrder(expectedAddedDate: number, expiryDate: number, hash = 'hash'): IndexedOrder<DbOrder> { | ||
return { order: forgeDbOrder(expiryDate), addedOn: expectedAddedDate, hash }; | ||
} | ||
|
||
export function forgeIndexedOrderResponseERC20(expectedAddedDate: number, expiryDate: number, hash = "hash"): IndexedOrder<FullOrderERC20> { | ||
return { | ||
hash, | ||
addedOn: expectedAddedDate, | ||
order: forgeFullOrderERC20(expiryDate) | ||
}; | ||
export function forgeIndexedOrderResponseERC20(expectedAddedDate: number, expiryDate: number, hash = 'hash'): IndexedOrder<FullOrderERC20> { | ||
return { | ||
hash, | ||
addedOn: expectedAddedDate, | ||
order: forgeFullOrderERC20(expiryDate) | ||
}; | ||
} | ||
export function forgeIndexedOrderResponse(expectedAddedDate: number, expiryDate: number, hash = "hash"): IndexedOrder<FullOrder> { | ||
return { | ||
hash, | ||
addedOn: expectedAddedDate, | ||
order: forgeFullOrder(expiryDate) | ||
}; | ||
export function forgeIndexedOrderResponse(expectedAddedDate: number, expiryDate: number, hash = 'hash'): IndexedOrder<FullOrder> { | ||
return { | ||
hash, | ||
addedOn: expectedAddedDate, | ||
order: forgeFullOrder(expiryDate) | ||
}; | ||
} | ||
|
||
export function forgeDbOrderERC20(expiryDate: number): DbOrderERC20 { | ||
return { | ||
nonce: "123", | ||
expiry: expiryDate / 1000, | ||
signerWallet: AddressZero, | ||
signerToken: AddressZero, | ||
signerAmount: "5", | ||
senderToken: AddressZero, | ||
senderAmount: "10", | ||
protocolFee: "4", | ||
senderWallet: AddressZero, | ||
approximatedSignerAmount: BigInt(5), | ||
approximatedSenderAmount: BigInt(10), | ||
r: "0x3e1010e70f178443d0e3437464db2f910be150259cfcbe8916a6267247bea0f7", | ||
s: "0x5a12fdf12c2b966a98d238916a670bdfd83e207e54a9c7d0af923839582de79f", | ||
v: "28", | ||
chainId: 5, | ||
swapContract: AddressZero | ||
}; | ||
return { | ||
nonce: '123', | ||
expiry: expiryDate / 1000, | ||
signerWallet: AddressZero, | ||
signerToken: AddressZero, | ||
signerAmount: '5', | ||
senderToken: AddressZero, | ||
senderAmount: '10', | ||
protocolFee: '4', | ||
senderWallet: AddressZero, | ||
approximatedSignerAmount: BigInt(5), | ||
approximatedSenderAmount: BigInt(10), | ||
r: '0x3e1010e70f178443d0e3437464db2f910be150259cfcbe8916a6267247bea0f7', | ||
s: '0x5a12fdf12c2b966a98d238916a670bdfd83e207e54a9c7d0af923839582de79f', | ||
v: '28', | ||
chainId: 5, | ||
swapContract: AddressZero | ||
}; | ||
} | ||
|
||
export function forgeDbOrder(expiryDate: number): DbOrder { | ||
return { | ||
nonce: "123", | ||
expiry: expiryDate / 1000, | ||
protocolFee: "100", | ||
signer: { | ||
wallet: AddressZero, | ||
token: AddressZero, | ||
kind: "akind", | ||
id: "aid", | ||
amount: "100", | ||
approximatedAmount: BigInt("100") | ||
}, | ||
sender: { | ||
wallet: AddressZero, | ||
token: AddressZero, | ||
kind: "akind", | ||
id: "aid", | ||
amount: "100", | ||
approximatedAmount: BigInt("100") | ||
}, | ||
r: "0x3e1010e70f178443d0e3437464db2f910be150259cfcbe8916a6267247bea0f7", | ||
s: "0x5a12fdf12c2b966a98d238916a670bdfd83e207e54a9c7d0af923839582de79f", | ||
v: "28", | ||
chainId: 5, | ||
swapContract: AddressZero, | ||
affiliateWallet: AddressZero, | ||
affiliateAmount: "13" | ||
}; | ||
return { | ||
nonce: '123', | ||
expiry: expiryDate / 1000, | ||
protocolFee: '100', | ||
signer: { | ||
wallet: AddressZero, | ||
token: AddressZero, | ||
kind: 'akind', | ||
id: 'aid', | ||
amount: '100', | ||
approximatedAmount: BigInt('100') | ||
}, | ||
sender: { | ||
wallet: AddressZero, | ||
token: AddressZero, | ||
kind: 'akind', | ||
id: 'aid', | ||
amount: '100', | ||
approximatedAmount: BigInt('100') | ||
}, | ||
r: '0x3e1010e70f178443d0e3437464db2f910be150259cfcbe8916a6267247bea0f7', | ||
s: '0x5a12fdf12c2b966a98d238916a670bdfd83e207e54a9c7d0af923839582de79f', | ||
v: '28', | ||
chainId: 5, | ||
swapContract: AddressZero, | ||
affiliateWallet: AddressZero, | ||
affiliateAmount: '13' | ||
}; | ||
} | ||
|
||
export function forgeFullOrderERC20(expiryDate: number): FullOrderERC20 { | ||
return { | ||
nonce: "123", | ||
expiry: `${expiryDate / 1000}`, | ||
signerWallet: AddressZero, | ||
signerToken: AddressZero, | ||
signerAmount: "5", | ||
senderToken: AddressZero, | ||
senderAmount: "10", | ||
protocolFee: "4", | ||
senderWallet: AddressZero, | ||
r: "0x3e1010e70f178443d0e3437464db2f910be150259cfcbe8916a6267247bea0f7", | ||
s: "0x5a12fdf12c2b966a98d238916a670bdfd83e207e54a9c7d0af923839582de79f", | ||
v: "28", | ||
chainId: 5, | ||
swapContract: AddressZero | ||
}; | ||
return { | ||
nonce: '123', | ||
expiry: `${expiryDate / 1000}`, | ||
signerWallet: AddressZero, | ||
signerToken: AddressZero, | ||
signerAmount: '5', | ||
senderToken: AddressZero, | ||
senderAmount: '10', | ||
protocolFee: '4', | ||
senderWallet: AddressZero, | ||
r: '0x3e1010e70f178443d0e3437464db2f910be150259cfcbe8916a6267247bea0f7', | ||
s: '0x5a12fdf12c2b966a98d238916a670bdfd83e207e54a9c7d0af923839582de79f', | ||
v: '28', | ||
chainId: 5, | ||
swapContract: AddressZero | ||
}; | ||
} | ||
|
||
export function forgeFullOrder(expiryDate: number): FullOrder { | ||
return { | ||
nonce: "123", | ||
expiry: String(expiryDate / 1000), | ||
protocolFee: "100", | ||
signer: { | ||
wallet: AddressZero, | ||
token: AddressZero, | ||
kind: "akind", | ||
id: "aid", | ||
amount: "100" | ||
}, | ||
sender: { | ||
wallet: AddressZero, | ||
token: AddressZero, | ||
kind: "akind", | ||
id: "aid", | ||
amount: "100" | ||
}, | ||
r: "0x3e1010e70f178443d0e3437464db2f910be150259cfcbe8916a6267247bea0f7", | ||
s: "0x5a12fdf12c2b966a98d238916a670bdfd83e207e54a9c7d0af923839582de79f", | ||
v: "28", | ||
chainId: 5, | ||
swapContract: AddressZero, | ||
affiliateWallet: AddressZero, | ||
affiliateAmount: "13" | ||
}; | ||
return { | ||
nonce: '123', | ||
expiry: String(expiryDate / 1000), | ||
protocolFee: '100', | ||
signer: { | ||
wallet: AddressZero, | ||
token: AddressZero, | ||
kind: 'akind', | ||
id: 'aid', | ||
amount: '100' | ||
}, | ||
sender: { | ||
wallet: AddressZero, | ||
token: AddressZero, | ||
kind: 'akind', | ||
id: 'aid', | ||
amount: '100' | ||
}, | ||
r: '0x3e1010e70f178443d0e3437464db2f910be150259cfcbe8916a6267247bea0f7', | ||
s: '0x5a12fdf12c2b966a98d238916a670bdfd83e207e54a9c7d0af923839582de79f', | ||
v: '28', | ||
chainId: 5, | ||
swapContract: AddressZero, | ||
affiliateWallet: AddressZero, | ||
affiliateAmount: '13' | ||
}; | ||
} | ||
|
||
export function forgeOrderERC20Response(): OrderResponse<FullOrderERC20> { | ||
return { | ||
orders: { | ||
aze: { | ||
addedOn: 1653900784696, | ||
hash: "hash", | ||
order: forgeFullOrderERC20(1653900784706) | ||
} | ||
}, | ||
pagination: { | ||
limit: 10, | ||
offset: 0, | ||
total: 1 | ||
} | ||
}; | ||
return { | ||
orders: { | ||
aze: { | ||
addedOn: 1653900784696, | ||
hash: 'hash', | ||
order: forgeFullOrderERC20(1653900784706) | ||
} | ||
}, | ||
pagination: { | ||
limit: 10, | ||
offset: 0, | ||
total: 1 | ||
} | ||
}; | ||
} | ||
|
||
export function forgeOrderResponse(): OrderResponse<FullOrder> { | ||
return { | ||
orders: { | ||
aze: { | ||
addedOn: 1653900784696, | ||
hash: "hash", | ||
order: forgeFullOrder(1653900784706) | ||
} | ||
}, | ||
pagination: { | ||
limit: 10, | ||
offset: 0, | ||
total: 1 | ||
} | ||
}; | ||
return { | ||
orders: { | ||
aze: { | ||
addedOn: 1653900784696, | ||
hash: 'hash', | ||
order: forgeFullOrder(1653900784706) | ||
} | ||
}, | ||
pagination: { | ||
limit: 10, | ||
offset: 0, | ||
total: 1 | ||
} | ||
}; | ||
} | ||
|
||
export function forgeJsonRpcResponse(id: string, response: OrderResponse<FullOrderERC20 | FullOrder>): JsonRpcResponse<FullOrderERC20 | FullOrder> { | ||
return new JsonRpcResponse(id, response); | ||
return new JsonRpcResponse(id, response); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import axios from "axios"; | ||
import axios from 'axios'; | ||
export class BroadcastClient { | ||
async broadcastTo(method: string, url: string, data?: any) { | ||
console.log("S--->", method, url, data); | ||
try { | ||
switch (method) { | ||
case "GET": | ||
return await axios.get(url); | ||
case "POST": | ||
return await axios.post(url, data); | ||
case "PUT": | ||
return await axios.put(url, data); | ||
case "DELETE": | ||
return await axios.delete(url); | ||
} | ||
} catch (e) { | ||
console.log("Client did not answer !", method, url, data, e); | ||
} | ||
async broadcastTo(method: string, url: string, data?: any) { | ||
console.log('S--->', method, url, data); | ||
try { | ||
switch (method) { | ||
case 'GET': | ||
return await axios.get(url); | ||
case 'POST': | ||
return await axios.post(url, data); | ||
case 'PUT': | ||
return await axios.put(url, data); | ||
case 'DELETE': | ||
return await axios.delete(url); | ||
} | ||
} catch (e) { | ||
console.log('Client did not answer !', method, url, data, e); | ||
} | ||
} | ||
} |
Oops, something went wrong.