-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from consenlabs/feature/add-rfq
Support to sign RFQ order
- Loading branch information
Showing
15 changed files
with
545 additions
and
132 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
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
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
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,6 +1,6 @@ | ||
export const version = (ctx) => { | ||
ctx.body = { | ||
result: true, | ||
version: '5.1.2', | ||
version: '5.2.0-alpha.0', | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { utils } from 'ethers' | ||
import { RFQOrder } from './types' | ||
|
||
const EIP712_DOMAIN_NAME = 'Tokenlon' | ||
const EIP712_DOMAIN_VERSION = 'v5' | ||
|
||
var RFQ_ORDER_SCHEMA = { | ||
Order: [ | ||
{ name: 'takerAddr', type: 'address' }, | ||
{ name: 'makerAddr', type: 'address' }, | ||
{ name: 'takerAssetAddr', type: 'address' }, | ||
{ name: 'makerAssetAddr', type: 'address' }, | ||
{ name: 'takerAssetAmount', type: 'uint256' }, | ||
{ name: 'makerAssetAmount', type: 'uint256' }, | ||
{ name: 'salt', type: 'uint256' }, | ||
{ name: 'deadline', type: 'uint256' }, | ||
{ name: 'feeFactor', type: 'uint256' }, | ||
], | ||
} | ||
|
||
export function getOrderSignDigest(order: RFQOrder, chainId: number, address: string): string { | ||
const domain = { | ||
name: EIP712_DOMAIN_NAME, | ||
version: EIP712_DOMAIN_VERSION, | ||
chainId: chainId, | ||
verifyingContract: address, | ||
} | ||
// The data to sign | ||
const value = { | ||
...order, | ||
takerAssetAmount: order.takerAssetAmount.toString(), | ||
makerAssetAmount: order.makerAssetAmount.toString(), | ||
salt: order.salt.toString(), | ||
} | ||
|
||
return utils._TypedDataEncoder.hash(domain, RFQ_ORDER_SCHEMA, value) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.