{"version":3,"file":"createOrder.cjs","names":["getSignerAddress","SignatureTypeV2","getContractConfig","buildOrderCreationArgs","ROUNDING_CONFIG","exchangeContract: string","buildOrder"],"sources":["../../../src/order-builder/helpers/createOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type { Chain, CreateOrderOptions, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { buildOrderCreationArgs } from \"./buildOrderCreationArgs.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\n\tconst orderData = await buildOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\tversion,\n\t);\n\tlet exchangeContract: string;\n\tswitch (version) {\n\t\tcase 1:\n\t\t\tif (signatureType === SignatureTypeV2.POLY_1271) {\n\t\t\t\tthrow new Error(`signature type POLY_1271 is not supported for v1 orders`);\n\t\t\t}\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchange\n\t\t\t\t: contractConfig.exchange;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchangeV2\n\t\t\t\t: contractConfig.exchangeV2;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`unsupported order version ${version}`);\n\t}\n\treturn buildOrder(eoaSigner, exchangeContract, chainId, orderData, version);\n};\n"],"mappings":";;;;;;;;AASA,MAAa,cAAc,OAC1B,WACA,SACA,eACA,eACA,WACA,SACA,YAC4C;CAC5C,MAAM,mBAAmB,MAAMA,gCAAiB,UAAU;CAG1D,MAAM,QAAQ,kBAAkB,SAAY,mBAAmB;CAG/D,MAAM,iBAAiB,kBAAkBC,wCAAgB,YAAY,QAAQ;CAC7E,MAAM,iBAAiBC,iCAAkB,QAAQ;CAEjD,MAAM,YAAY,MAAMC,sDACvB,gBACA,OACA,eACA,WACAC,uCAAgB,QAAQ,WACxB,QACA;CACD,IAAIC;AACJ,SAAQ,SAAR;EACC,KAAK;AACJ,OAAI,kBAAkBJ,wCAAgB,UACrC,OAAM,IAAI,MAAM,0DAA0D;AAE3E,sBAAmB,QAAQ,UACxB,eAAe,kBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,QAAQ,UACxB,eAAe,oBACf,eAAe;AAClB;EACD,QACC,OAAM,IAAI,MAAM,6BAA6B,UAAU;;AAEzD,QAAOK,8BAAW,WAAW,kBAAkB,SAAS,WAAW,QAAQ"}