mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-22 21:59:44 +03:00
make fields in signOrder optional
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@orionprotocol/sdk",
|
"name": "@orionprotocol/sdk",
|
||||||
"version": "0.20.42-rc5",
|
"version": "0.20.42-rc6",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@orionprotocol/sdk",
|
"name": "@orionprotocol/sdk",
|
||||||
"version": "0.20.42-rc5",
|
"version": "0.20.42-rc6",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@orionprotocol/sdk",
|
"name": "@orionprotocol/sdk",
|
||||||
"version": "0.20.42-rc5",
|
"version": "0.20.42-rc6",
|
||||||
"description": "Orion Protocol SDK",
|
"description": "Orion Protocol SDK",
|
||||||
"main": "./lib/index.cjs",
|
"main": "./lib/index.cjs",
|
||||||
"module": "./lib/index.js",
|
"module": "./lib/index.js",
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ export type LockOrderProps = {
|
|||||||
senderAddress: string // broker
|
senderAddress: string // broker
|
||||||
asset: string
|
asset: string
|
||||||
amount: ethers.BigNumberish
|
amount: ethers.BigNumberish
|
||||||
targetChainId: ethers.BigNumberish
|
|
||||||
sign: string // подпись юзера
|
sign: string // подпись юзера
|
||||||
signer: ethers.Signer
|
signer: ethers.Signer
|
||||||
chainId: SupportedChainId
|
chainId: SupportedChainId
|
||||||
|
targetChainId: SupportedChainId
|
||||||
}
|
}
|
||||||
|
|
||||||
export const signLockOrder = async ({
|
export const signLockOrder = async ({
|
||||||
|
|||||||
@@ -25,13 +25,15 @@ export const signOrder = async (
|
|||||||
serviceFeeAssetAddr: string,
|
serviceFeeAssetAddr: string,
|
||||||
signer: ethers.Signer,
|
signer: ethers.Signer,
|
||||||
chainId: SupportedChainId,
|
chainId: SupportedChainId,
|
||||||
targetChainId?: ethers.BigNumberish,
|
targetChainId?: SupportedChainId,
|
||||||
) => {
|
) => {
|
||||||
const nonce = Date.now();
|
const nonce = Date.now();
|
||||||
const expiration = nonce + DEFAULT_EXPIRATION;
|
const expiration = nonce + DEFAULT_EXPIRATION;
|
||||||
const secret = generateSecret();
|
const secret = generateSecret();
|
||||||
const secretHash = ethers.keccak256(secret);
|
const secretHash = ethers.keccak256(secret);
|
||||||
|
|
||||||
|
const isCrossChain = targetChainId === undefined || targetChainId === chainId;
|
||||||
|
|
||||||
const order: Order = {
|
const order: Order = {
|
||||||
senderAddress,
|
senderAddress,
|
||||||
matcherAddress,
|
matcherAddress,
|
||||||
@@ -55,7 +57,7 @@ export const signOrder = async (
|
|||||||
)),
|
)),
|
||||||
nonce,
|
nonce,
|
||||||
expiration,
|
expiration,
|
||||||
...(targetChainId !== undefined
|
...(isCrossChain
|
||||||
? {
|
? {
|
||||||
secretHash,
|
secretHash,
|
||||||
targetChainId
|
targetChainId
|
||||||
@@ -83,7 +85,7 @@ export const signOrder = async (
|
|||||||
...order,
|
...order,
|
||||||
id: hashOrder(order),
|
id: hashOrder(order),
|
||||||
signature: fixedSignature,
|
signature: fixedSignature,
|
||||||
secret
|
...(isCrossChain ? { secret } : {})
|
||||||
};
|
};
|
||||||
return signedOrder;
|
return signedOrder;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export type Order = {
|
|||||||
expiration: number // uint64
|
expiration: number // uint64
|
||||||
buySide: 0 | 1 // uint8, 1=buy, 0=sell
|
buySide: 0 | 1 // uint8, 1=buy, 0=sell
|
||||||
secretHash?: string // uint64
|
secretHash?: string // uint64
|
||||||
targetChainId?: ethers.BigNumberish // uint64
|
targetChainId?: SupportedChainId // uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LockOrder = {
|
export type LockOrder = {
|
||||||
@@ -60,14 +60,14 @@ export type LockOrder = {
|
|||||||
expiration: ethers.BigNumberish // uint64
|
expiration: ethers.BigNumberish // uint64
|
||||||
asset: string // address(?)
|
asset: string // address(?)
|
||||||
amount: ethers.BigNumberish // uint64
|
amount: ethers.BigNumberish // uint64
|
||||||
targetChainId: ethers.BigNumberish // uint64
|
targetChainId: SupportedChainId // uint64
|
||||||
secretHash: string // uint64
|
secretHash: string // uint64
|
||||||
sign: string // uint64 // подпись юзера
|
sign: string // uint64 // подпись юзера
|
||||||
}
|
}
|
||||||
|
|
||||||
type SignedOrderAdditionalProps = {
|
type SignedOrderAdditionalProps = {
|
||||||
signature: string // bytes
|
signature: string // bytes
|
||||||
secret: string
|
secret?: string
|
||||||
needWithdraw?: boolean // bool (not supported yet by smart-contract)
|
needWithdraw?: boolean // bool (not supported yet by smart-contract)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
"noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */,
|
"noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */,
|
||||||
"noUnusedParameters": true /* Raise an error when a function parameter isn't read */,
|
"noUnusedParameters": true /* Raise an error when a function parameter isn't read */,
|
||||||
"noUncheckedIndexedAccess": true,
|
"noUncheckedIndexedAccess": true,
|
||||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
||||||
|
"exactOptionalPropertyTypes": false, /* allow ? in interfaces */
|
||||||
},
|
},
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
// Tell ts-node CLI to install the --loader automatically, explained below
|
// Tell ts-node CLI to install the --loader automatically, explained below
|
||||||
|
|||||||
Reference in New Issue
Block a user