@polymarket/clob-client-v2 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/client.d.ts +15 -29
  2. package/dist/client.js +723 -862
  3. package/dist/client.js.map +1 -1
  4. package/dist/config.js +1 -6
  5. package/dist/config.js.map +1 -1
  6. package/dist/constants.js +6 -9
  7. package/dist/constants.js.map +1 -1
  8. package/dist/endpoints.d.ts +1 -0
  9. package/dist/endpoints.js +54 -56
  10. package/dist/endpoints.js.map +1 -1
  11. package/dist/errors.js +2 -5
  12. package/dist/errors.js.map +1 -1
  13. package/dist/headers/index.d.ts +4 -5
  14. package/dist/headers/index.js +10 -15
  15. package/dist/headers/index.js.map +1 -1
  16. package/dist/http-helpers/index.d.ts +1 -1
  17. package/dist/http-helpers/index.js +41 -53
  18. package/dist/http-helpers/index.js.map +1 -1
  19. package/dist/index.d.ts +7 -5
  20. package/dist/index.js +7 -8
  21. package/dist/index.js.map +1 -1
  22. package/dist/order-builder/helpers/buildMarketOrderCreationArgs.d.ts +2 -2
  23. package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js +12 -19
  24. package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js.map +1 -1
  25. package/dist/order-builder/helpers/buildOrder.d.ts +5 -6
  26. package/dist/order-builder/helpers/buildOrder.js +11 -18
  27. package/dist/order-builder/helpers/buildOrder.js.map +1 -1
  28. package/dist/order-builder/helpers/buildOrderCreationArgs.d.ts +2 -2
  29. package/dist/order-builder/helpers/buildOrderCreationArgs.js +13 -19
  30. package/dist/order-builder/helpers/buildOrderCreationArgs.js.map +1 -1
  31. package/dist/order-builder/helpers/calculateBuyMarketPrice.d.ts +1 -1
  32. package/dist/order-builder/helpers/calculateBuyMarketPrice.js +3 -7
  33. package/dist/order-builder/helpers/calculateBuyMarketPrice.js.map +1 -1
  34. package/dist/order-builder/helpers/calculateSellMarketPrice.d.ts +1 -1
  35. package/dist/order-builder/helpers/calculateSellMarketPrice.js +3 -7
  36. package/dist/order-builder/helpers/calculateSellMarketPrice.js.map +1 -1
  37. package/dist/order-builder/helpers/createMarketOrder.d.ts +5 -6
  38. package/dist/order-builder/helpers/createMarketOrder.js +15 -19
  39. package/dist/order-builder/helpers/createMarketOrder.js.map +1 -1
  40. package/dist/order-builder/helpers/createOrder.d.ts +5 -6
  41. package/dist/order-builder/helpers/createOrder.js +15 -19
  42. package/dist/order-builder/helpers/createOrder.js.map +1 -1
  43. package/dist/order-builder/helpers/getMarketOrderRawAmounts.d.ts +1 -1
  44. package/dist/order-builder/helpers/getMarketOrderRawAmounts.js +17 -21
  45. package/dist/order-builder/helpers/getMarketOrderRawAmounts.js.map +1 -1
  46. package/dist/order-builder/helpers/getOrderRawAmounts.d.ts +1 -1
  47. package/dist/order-builder/helpers/getOrderRawAmounts.js +17 -21
  48. package/dist/order-builder/helpers/getOrderRawAmounts.js.map +1 -1
  49. package/dist/order-builder/helpers/index.d.ts +10 -10
  50. package/dist/order-builder/helpers/index.js +10 -23
  51. package/dist/order-builder/helpers/index.js.map +1 -1
  52. package/dist/order-builder/helpers/roundingConfig.d.ts +1 -1
  53. package/dist/order-builder/helpers/roundingConfig.js +1 -4
  54. package/dist/order-builder/helpers/roundingConfig.js.map +1 -1
  55. package/dist/order-builder/index.d.ts +1 -1
  56. package/dist/order-builder/index.js +1 -4
  57. package/dist/order-builder/index.js.map +1 -1
  58. package/dist/order-builder/orderBuilder.d.ts +5 -6
  59. package/dist/order-builder/orderBuilder.js +34 -29
  60. package/dist/order-builder/orderBuilder.js.map +1 -1
  61. package/dist/order-utils/abi/ExchangeV1.js +1 -4
  62. package/dist/order-utils/abi/ExchangeV1.js.map +1 -1
  63. package/dist/order-utils/abi/ExchangeV2.js +1 -4
  64. package/dist/order-utils/abi/ExchangeV2.js.map +1 -1
  65. package/dist/order-utils/exchangeOrderBuilderV1.d.ts +5 -6
  66. package/dist/order-utils/exchangeOrderBuilderV1.js +77 -78
  67. package/dist/order-utils/exchangeOrderBuilderV1.js.map +1 -1
  68. package/dist/order-utils/exchangeOrderBuilderV2.d.ts +6 -7
  69. package/dist/order-utils/exchangeOrderBuilderV2.js +50 -51
  70. package/dist/order-utils/exchangeOrderBuilderV2.js.map +1 -1
  71. package/dist/order-utils/index.js +8 -11
  72. package/dist/order-utils/index.js.map +1 -1
  73. package/dist/order-utils/model/abi.js +1 -2
  74. package/dist/order-utils/model/ctfExchangeV1TypedData.js +3 -6
  75. package/dist/order-utils/model/ctfExchangeV1TypedData.js.map +1 -1
  76. package/dist/order-utils/model/ctfExchangeV2TypedData.js +3 -6
  77. package/dist/order-utils/model/ctfExchangeV2TypedData.js.map +1 -1
  78. package/dist/order-utils/model/eip712.js +1 -4
  79. package/dist/order-utils/model/eip712.js.map +1 -1
  80. package/dist/order-utils/model/order.js +1 -2
  81. package/dist/order-utils/model/orderDataV1.d.ts +4 -4
  82. package/dist/order-utils/model/orderDataV1.js +1 -2
  83. package/dist/order-utils/model/orderDataV2.d.ts +12 -13
  84. package/dist/order-utils/model/orderDataV2.js +1 -2
  85. package/dist/order-utils/model/side.d.ts +0 -4
  86. package/dist/order-utils/model/side.js +4 -12
  87. package/dist/order-utils/model/side.js.map +1 -1
  88. package/dist/order-utils/model/signatureTypeV1.js +2 -5
  89. package/dist/order-utils/model/signatureTypeV1.js.map +1 -1
  90. package/dist/order-utils/model/signatureTypeV2.js +2 -5
  91. package/dist/order-utils/model/signatureTypeV2.js.map +1 -1
  92. package/dist/order-utils/utils.js +1 -4
  93. package/dist/order-utils/utils.js.map +1 -1
  94. package/dist/signing/constants.js +7 -10
  95. package/dist/signing/constants.js.map +1 -1
  96. package/dist/signing/eip712.d.ts +3 -4
  97. package/dist/signing/eip712.js +7 -12
  98. package/dist/signing/eip712.js.map +1 -1
  99. package/dist/signing/hmac.js +3 -8
  100. package/dist/signing/hmac.js.map +1 -1
  101. package/dist/signing/index.d.ts +3 -2
  102. package/dist/signing/index.js +3 -5
  103. package/dist/signing/index.js.map +1 -1
  104. package/dist/signing/signer.d.ts +9 -0
  105. package/dist/signing/signer.js +30 -0
  106. package/dist/signing/signer.js.map +1 -0
  107. package/dist/types/clob.d.ts +19 -6
  108. package/dist/types/clob.js +10 -13
  109. package/dist/types/clob.js.map +1 -1
  110. package/dist/types/index.d.ts +4 -4
  111. package/dist/types/index.js +4 -7
  112. package/dist/types/index.js.map +1 -1
  113. package/dist/types/ordersV1.d.ts +3 -2
  114. package/dist/types/ordersV1.js +22 -2
  115. package/dist/types/ordersV1.js.map +1 -1
  116. package/dist/types/ordersV2.d.ts +14 -5
  117. package/dist/types/ordersV2.js +23 -2
  118. package/dist/types/ordersV2.js.map +1 -1
  119. package/dist/types/unifiedOrder.d.ts +4 -4
  120. package/dist/types/unifiedOrder.js +1 -4
  121. package/dist/types/unifiedOrder.js.map +1 -1
  122. package/dist/utilities.d.ts +1 -5
  123. package/dist/utilities.js +15 -88
  124. package/dist/utilities.js.map +1 -1
  125. package/package.json +47 -42
@@ -1,15 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExchangeOrderBuilderV2 = void 0;
4
- const tslib_1 = require("tslib");
5
- const viem_1 = require("viem");
6
- const constants_1 = require("../constants");
7
- const ctfExchangeV2TypedData_1 = require("./model/ctfExchangeV2TypedData");
8
- const eip712_1 = require("./model/eip712");
9
- const signatureTypeV2_js_1 = require("./model/signatureTypeV2.js");
10
- const utils_1 = require("./utils");
11
- class ExchangeOrderBuilderV2 {
12
- constructor(contractAddress, chainId, signer, generateSalt = utils_1.generateOrderSalt) {
1
+ import { hashTypedData } from "viem";
2
+ import { bytes32Zero } from "../constants.js";
3
+ import { getSignerAddress, signTypedData } from "../signing/signer.js";
4
+ import { CTF_EXCHANGE_V2_DOMAIN_NAME, CTF_EXCHANGE_V2_DOMAIN_VERSION, CTF_EXCHANGE_V2_ORDER_STRUCT, } from "./model/ctfExchangeV2TypedData.js";
5
+ import { EIP712_DOMAIN } from "./model/eip712.js";
6
+ import { SignatureTypeV2 } from "./model/signatureTypeV2.js";
7
+ import { generateOrderSalt } from "./utils.js";
8
+ export class ExchangeOrderBuilderV2 {
9
+ contractAddress;
10
+ chainId;
11
+ signer;
12
+ generateSalt;
13
+ constructor(contractAddress, chainId, signer, generateSalt = generateOrderSalt) {
13
14
  this.contractAddress = contractAddress;
14
15
  this.chainId = chainId;
15
16
  this.signer = signer;
@@ -20,43 +21,42 @@ class ExchangeOrderBuilderV2 {
20
21
  * @param orderData
21
22
  * @returns a SignedOrder object (order + signature)
22
23
  */
23
- buildSignedOrder(orderData) {
24
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
- const order = yield this.buildOrder(orderData);
26
- const orderTypedData = this.buildOrderTypedData(order);
27
- const orderSignature = yield this.buildOrderSignature(orderTypedData);
28
- return Object.assign(Object.assign({}, order), { signature: orderSignature });
29
- });
24
+ async buildSignedOrder(orderData) {
25
+ const order = await this.buildOrder(orderData);
26
+ const orderTypedData = this.buildOrderTypedData(order);
27
+ const orderSignature = await this.buildOrderSignature(orderTypedData);
28
+ return {
29
+ ...order,
30
+ signature: orderSignature,
31
+ };
30
32
  }
31
33
  /**
32
34
  * Creates an Order object from order data.
33
35
  * @param OrderData
34
36
  * @returns a Order object (not signed)
35
37
  */
36
- buildOrder(_a) {
37
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ maker, tokenId, makerAmount, takerAmount, side, signer, expiration, signatureType, timestamp, metadata, builder, }) {
38
- if (!signer) {
39
- signer = maker;
40
- }
41
- const signerAddress = yield this.signer.getAddress();
42
- if (signer !== signerAddress) {
43
- throw new Error("signer does not match");
44
- }
45
- return {
46
- salt: this.generateSalt(),
47
- maker,
48
- signer,
49
- tokenId,
50
- makerAmount,
51
- takerAmount,
52
- side,
53
- expiration: expiration !== null && expiration !== void 0 ? expiration : "0",
54
- signatureType: signatureType !== null && signatureType !== void 0 ? signatureType : signatureTypeV2_js_1.SignatureTypeV2.EOA,
55
- metadata: metadata !== null && metadata !== void 0 ? metadata : constants_1.bytes32Zero,
56
- builder: builder !== null && builder !== void 0 ? builder : constants_1.bytes32Zero,
57
- timestamp: timestamp !== null && timestamp !== void 0 ? timestamp : Math.floor(Date.now() / 1000).toString(),
58
- };
59
- });
38
+ async buildOrder({ maker, tokenId, makerAmount, takerAmount, side, signer, signatureType, timestamp, metadata, builder, expiration, }) {
39
+ if (!signer) {
40
+ signer = maker;
41
+ }
42
+ const signerAddress = await getSignerAddress(this.signer);
43
+ if (signer !== signerAddress) {
44
+ throw new Error("signer does not match");
45
+ }
46
+ return {
47
+ salt: this.generateSalt(),
48
+ maker,
49
+ signer,
50
+ tokenId,
51
+ makerAmount,
52
+ takerAmount,
53
+ side,
54
+ signatureType: signatureType ?? SignatureTypeV2.EOA,
55
+ metadata: metadata ?? bytes32Zero,
56
+ builder: builder ?? bytes32Zero,
57
+ timestamp: timestamp ?? Date.now().toString(),
58
+ expiration: expiration ?? "0",
59
+ };
60
60
  }
61
61
  /**
62
62
  * Parses an Order object to EIP712 typed data
@@ -67,12 +67,12 @@ class ExchangeOrderBuilderV2 {
67
67
  return {
68
68
  primaryType: "Order",
69
69
  types: {
70
- EIP712Domain: eip712_1.EIP712_DOMAIN,
71
- Order: ctfExchangeV2TypedData_1.CTF_EXCHANGE_V2_ORDER_STRUCT,
70
+ EIP712Domain: EIP712_DOMAIN,
71
+ Order: CTF_EXCHANGE_V2_ORDER_STRUCT,
72
72
  },
73
73
  domain: {
74
- name: ctfExchangeV2TypedData_1.CTF_EXCHANGE_V2_DOMAIN_NAME,
75
- version: ctfExchangeV2TypedData_1.CTF_EXCHANGE_V2_DOMAIN_VERSION,
74
+ name: CTF_EXCHANGE_V2_DOMAIN_NAME,
75
+ version: CTF_EXCHANGE_V2_DOMAIN_VERSION,
76
76
  chainId: this.chainId,
77
77
  verifyingContract: this.contractAddress,
78
78
  },
@@ -84,7 +84,7 @@ class ExchangeOrderBuilderV2 {
84
84
  makerAmount: order.makerAmount,
85
85
  takerAmount: order.takerAmount,
86
86
  timestamp: order.timestamp,
87
- side: order.side,
87
+ side: order.side === "BUY" ? 0 : 1,
88
88
  signatureType: order.signatureType,
89
89
  metadata: order.metadata,
90
90
  builder: order.builder,
@@ -98,7 +98,7 @@ class ExchangeOrderBuilderV2 {
98
98
  */
99
99
  buildOrderSignature(typedData) {
100
100
  delete typedData.types.EIP712Domain;
101
- return this.signer._signTypedData(typedData.domain, typedData.types, typedData.message);
101
+ return signTypedData(this.signer, typedData.domain, typedData.types, typedData.message);
102
102
  }
103
103
  /**
104
104
  * Generates the hash of the order from a EIP712TypedData object.
@@ -106,9 +106,8 @@ class ExchangeOrderBuilderV2 {
106
106
  * @returns a OrderHash that is an string
107
107
  */
108
108
  buildOrderHash(orderTypedData) {
109
- const digest = (0, viem_1.hashTypedData)(orderTypedData);
109
+ const digest = hashTypedData(orderTypedData);
110
110
  return digest;
111
111
  }
112
112
  }
113
- exports.ExchangeOrderBuilderV2 = ExchangeOrderBuilderV2;
114
113
  //# sourceMappingURL=exchangeOrderBuilderV2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exchangeOrderBuilderV2.js","sourceRoot":"","sources":["../../src/order-utils/exchangeOrderBuilderV2.ts"],"names":[],"mappings":";;;;AAEA,+BAAqC;AAErC,4CAA2C;AAC3C,2EAIwC;AACxC,2CAAqE;AAGrE,mEAA6D;AAC7D,mCAA4C;AAE5C,MAAa,sBAAsB;IAClC,YACkB,eAAuB,EACvB,OAAe,EACf,MAA8B,EAC9B,eAAe,yBAAiB;QAHhC,oBAAe,GAAf,eAAe,CAAQ;QACvB,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAwB;QAC9B,iBAAY,GAAZ,YAAY,CAAoB;IAC/C,CAAC;IAEJ;;;;OAIG;IACG,gBAAgB,CAAC,SAAsB;;YAC5C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAC/C,MAAM,cAA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C,CAAC;gBAClC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,OAAO,EAAE,KAAK,CAAC,OAAO;aACtB;SACD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,SAA0B;QAC7C,OAAO,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC;QACpC,OAAO,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzF,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,cAA+B;QAC7C,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;QAC7C,OAAO,MAAM,CAAC;IACf,CAAC;CACD"}
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./exchangeOrderBuilderV1.js"), exports);
5
- tslib_1.__exportStar(require("./exchangeOrderBuilderV2.js"), exports);
1
+ export * from "./exchangeOrderBuilderV1.js";
2
+ export * from "./exchangeOrderBuilderV2.js";
6
3
  // export * from "./eip712TypedDataV1.js";
7
- tslib_1.__exportStar(require("./model/abi.js"), exports);
8
- tslib_1.__exportStar(require("./model/eip712.js"), exports);
9
- tslib_1.__exportStar(require("./model/orderDataV1.js"), exports);
10
- tslib_1.__exportStar(require("./model/orderDataV2.js"), exports);
11
- tslib_1.__exportStar(require("./model/signatureTypeV1.js"), exports);
12
- tslib_1.__exportStar(require("./model/signatureTypeV2.js"), exports);
4
+ export * from "./model/abi.js";
5
+ export * from "./model/eip712.js";
6
+ export * from "./model/orderDataV1.js";
7
+ export * from "./model/orderDataV2.js";
8
+ export * from "./model/signatureTypeV1.js";
9
+ export * from "./model/signatureTypeV2.js";
13
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/order-utils/index.ts"],"names":[],"mappings":";;;AAAA,sEAA4C;AAC5C,sEAA4C;AAC5C,0CAA0C;AAE1C,yDAA+B;AAC/B,4DAAkC;AAClC,iEAAuC;AACvC,iEAAuC;AACvC,qEAA2C;AAC3C,qEAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/order-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,0CAA0C;AAE1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC"}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=abi.js.map
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CTF_EXCHANGE_V1_ORDER_STRUCT = exports.CTF_EXCHANGE_V1_DOMAIN_VERSION = exports.CTF_EXCHANGE_V1_DOMAIN_NAME = void 0;
4
- exports.CTF_EXCHANGE_V1_DOMAIN_NAME = "Polymarket CTF Exchange";
5
- exports.CTF_EXCHANGE_V1_DOMAIN_VERSION = "1";
6
- exports.CTF_EXCHANGE_V1_ORDER_STRUCT = [
1
+ export const CTF_EXCHANGE_V1_DOMAIN_NAME = "Polymarket CTF Exchange";
2
+ export const CTF_EXCHANGE_V1_DOMAIN_VERSION = "1";
3
+ export const CTF_EXCHANGE_V1_ORDER_STRUCT = [
7
4
  { name: "salt", type: "uint256" },
8
5
  { name: "maker", type: "address" },
9
6
  { name: "signer", type: "address" },
@@ -1 +1 @@
1
- {"version":3,"file":"ctfExchangeV1TypedData.js","sourceRoot":"","sources":["../../../src/order-utils/model/ctfExchangeV1TypedData.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG,yBAAyB,CAAC;AAExD,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAErC,QAAA,4BAA4B,GAAG;IAC3C,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;IACnC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACvC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACvC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE;CACxC,CAAC"}
1
+ {"version":3,"file":"ctfExchangeV1TypedData.js","sourceRoot":"","sources":["../../../src/order-utils/model/ctfExchangeV1TypedData.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAErE,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAElD,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC3C,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;IACnC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACvC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;IACvC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE;CACxC,CAAC"}
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CTF_EXCHANGE_V2_ORDER_STRUCT = exports.CTF_EXCHANGE_V2_DOMAIN_VERSION = exports.CTF_EXCHANGE_V2_DOMAIN_NAME = void 0;
4
- exports.CTF_EXCHANGE_V2_DOMAIN_NAME = "Polymarket CTF Exchange";
5
- exports.CTF_EXCHANGE_V2_DOMAIN_VERSION = "2";
6
- exports.CTF_EXCHANGE_V2_ORDER_STRUCT = [
1
+ export const CTF_EXCHANGE_V2_DOMAIN_NAME = "Polymarket CTF Exchange";
2
+ export const CTF_EXCHANGE_V2_DOMAIN_VERSION = "2";
3
+ export const CTF_EXCHANGE_V2_ORDER_STRUCT = [
7
4
  { name: "salt", type: "uint256" },
8
5
  { name: "maker", type: "address" },
9
6
  { name: "signer", type: "address" },
@@ -1 +1 @@
1
- {"version":3,"file":"ctfExchangeV2TypedData.js","sourceRoot":"","sources":["../../../src/order-utils/model/ctfExchangeV2TypedData.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG,yBAAyB,CAAC;AAExD,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAErC,QAAA,4BAA4B,GAAG;IAC3C,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;IACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE;IACxC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;IACtC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;IACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;CACpC,CAAC"}
1
+ {"version":3,"file":"ctfExchangeV2TypedData.js","sourceRoot":"","sources":["../../../src/order-utils/model/ctfExchangeV2TypedData.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAErE,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAElD,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC3C,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;IACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;IACxC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE;IACxC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;IACtC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;IACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;CACpC,CAAC"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EIP712_DOMAIN = void 0;
4
- exports.EIP712_DOMAIN = [
1
+ export const EIP712_DOMAIN = [
5
2
  { name: "name", type: "string" },
6
3
  { name: "version", type: "string" },
7
4
  { name: "chainId", type: "uint256" },
@@ -1 +1 @@
1
- {"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../../src/order-utils/model/eip712.ts"],"names":[],"mappings":";;;AAgCa,QAAA,aAAa,GAAG;IAC5B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;IAChC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;CAC9C,CAAC"}
1
+ {"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../../src/order-utils/model/eip712.ts"],"names":[],"mappings":"AAgCA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;IAChC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;CAC9C,CAAC"}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=order.js.map
@@ -1,7 +1,7 @@
1
- import type { Side } from "../../types/index.ts";
2
- import type { EIP712Object } from "./eip712.ts";
3
- import type { OrderSignature } from "./order.ts";
4
- import type { SignatureTypeV1 } from "./signatureTypeV1.ts";
1
+ import type { Side } from "../../types/index.js";
2
+ import type { EIP712Object } from "./eip712.js";
3
+ import type { OrderSignature } from "./order.js";
4
+ import type { SignatureTypeV1 } from "./signatureTypeV1.js";
5
5
  export interface OrderDataV1 {
6
6
  /**
7
7
  * Maker of the order, i.e the source of funds for the order
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=orderDataV1.js.map
@@ -1,7 +1,7 @@
1
- import type { Side } from "../../types/index.ts";
2
- import type { EIP712Object } from "./eip712.ts";
3
- import type { OrderSignature } from "./order.ts";
4
- import type { SignatureTypeV2 } from "./signatureTypeV2.ts";
1
+ import type { Side } from "../../types/index.js";
2
+ import type { EIP712Object } from "./eip712.js";
3
+ import type { OrderSignature } from "./order.js";
4
+ import type { SignatureTypeV2 } from "./signatureTypeV2.js";
5
5
  export interface OrderDataV2 {
6
6
  /**
7
7
  * Maker of the order, i.e the source of funds for the order
@@ -29,11 +29,6 @@ export interface OrderDataV2 {
29
29
  * Signer of the order. Optional, if it is not present the signer is the maker of the order.
30
30
  */
31
31
  signer?: string;
32
- /**
33
- * Timestamp after which the order is expired.
34
- * Optional, if it is not present the value is '0' (no expiration)
35
- */
36
- expiration?: string;
37
32
  /**
38
33
  * Signature type used by the Order. Default value 'EOA'
39
34
  */
@@ -50,6 +45,10 @@ export interface OrderDataV2 {
50
45
  * Builder of the order
51
46
  */
52
47
  readonly builder?: string;
48
+ /**
49
+ * Expiration timestamp of the order (unix seconds, "0" = no expiration)
50
+ */
51
+ expiration?: string;
53
52
  }
54
53
  export interface OrderV2 extends EIP712Object {
55
54
  /**
@@ -78,10 +77,6 @@ export interface OrderV2 extends EIP712Object {
78
77
  * Taker amount, i.e the minimum amount of tokens to be received
79
78
  */
80
79
  readonly takerAmount: string;
81
- /**
82
- * Timestamp after which the order is expired
83
- */
84
- readonly expiration: string;
85
80
  /**
86
81
  * The side of the order, BUY or SELL
87
82
  */
@@ -102,6 +97,10 @@ export interface OrderV2 extends EIP712Object {
102
97
  * Builder of the order
103
98
  */
104
99
  readonly builder: string;
100
+ /**
101
+ * Expiration timestamp of the order (unix seconds, "0" = no expiration)
102
+ */
103
+ readonly expiration: string;
105
104
  }
106
105
  export interface SignedOrderV2 extends OrderV2 {
107
106
  /**
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=orderDataV2.js.map
@@ -1,8 +1,4 @@
1
1
  export declare enum Side {
2
- BUY = 0,
3
- SELL = 1
4
- }
5
- export declare enum SideString {
6
2
  BUY = "BUY",
7
3
  SELL = "SELL"
8
4
  }
@@ -1,14 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SideString = exports.Side = void 0;
4
- var Side;
1
+ export var Side;
5
2
  (function (Side) {
6
- Side[Side["BUY"] = 0] = "BUY";
7
- Side[Side["SELL"] = 1] = "SELL";
8
- })(Side || (exports.Side = Side = {}));
9
- var SideString;
10
- (function (SideString) {
11
- SideString["BUY"] = "BUY";
12
- SideString["SELL"] = "SELL";
13
- })(SideString || (exports.SideString = SideString = {}));
3
+ Side["BUY"] = "BUY";
4
+ Side["SELL"] = "SELL";
5
+ })(Side || (Side = {}));
14
6
  //# sourceMappingURL=side.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"side.js","sourceRoot":"","sources":["../../../src/order-utils/model/side.ts"],"names":[],"mappings":";;;AAAA,IAAY,IAGX;AAHD,WAAY,IAAI;IACf,6BAAG,CAAA;IACH,+BAAI,CAAA;AACL,CAAC,EAHW,IAAI,oBAAJ,IAAI,QAGf;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IACrB,yBAAW,CAAA;IACX,2BAAa,CAAA;AACd,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB"}
1
+ {"version":3,"file":"side.js","sourceRoot":"","sources":["../../../src/order-utils/model/side.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,IAGX;AAHD,WAAY,IAAI;IACf,mBAAW,CAAA;IACX,qBAAa,CAAA;AACd,CAAC,EAHW,IAAI,KAAJ,IAAI,QAGf"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SignatureTypeV1 = void 0;
4
- var SignatureTypeV1;
1
+ export var SignatureTypeV1;
5
2
  (function (SignatureTypeV1) {
6
3
  /**
7
4
  * ECDSA EIP712 signatures signed by EOAs
@@ -15,5 +12,5 @@ var SignatureTypeV1;
15
12
  * EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
16
13
  */
17
14
  SignatureTypeV1[SignatureTypeV1["POLY_GNOSIS_SAFE"] = 2] = "POLY_GNOSIS_SAFE";
18
- })(SignatureTypeV1 || (exports.SignatureTypeV1 = SignatureTypeV1 = {}));
15
+ })(SignatureTypeV1 || (SignatureTypeV1 = {}));
19
16
  //# sourceMappingURL=signatureTypeV1.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signatureTypeV1.js","sourceRoot":"","sources":["../../../src/order-utils/model/signatureTypeV1.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAeX;AAfD,WAAY,eAAe;IAC1B;;OAEG;IACH,mDAAO,CAAA;IAEP;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,6EAAoB,CAAA;AACrB,CAAC,EAfW,eAAe,+BAAf,eAAe,QAe1B"}
1
+ {"version":3,"file":"signatureTypeV1.js","sourceRoot":"","sources":["../../../src/order-utils/model/signatureTypeV1.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,eAeX;AAfD,WAAY,eAAe;IAC1B;;OAEG;IACH,mDAAO,CAAA;IAEP;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,6EAAoB,CAAA;AACrB,CAAC,EAfW,eAAe,KAAf,eAAe,QAe1B"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SignatureTypeV2 = void 0;
4
- var SignatureTypeV2;
1
+ export var SignatureTypeV2;
5
2
  (function (SignatureTypeV2) {
6
3
  /**
7
4
  * ECDSA EIP712 signatures signed by EOAs
@@ -19,5 +16,5 @@ var SignatureTypeV2;
19
16
  * EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults
20
17
  */
21
18
  SignatureTypeV2[SignatureTypeV2["POLY_1271"] = 3] = "POLY_1271";
22
- })(SignatureTypeV2 || (exports.SignatureTypeV2 = SignatureTypeV2 = {}));
19
+ })(SignatureTypeV2 || (SignatureTypeV2 = {}));
23
20
  //# sourceMappingURL=signatureTypeV2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signatureTypeV2.js","sourceRoot":"","sources":["../../../src/order-utils/model/signatureTypeV2.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAoBX;AApBD,WAAY,eAAe;IAC1B;;OAEG;IACH,mDAAO,CAAA;IAEP;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,6EAAoB,CAAA;IAEpB;;OAEG;IACH,+DAAa,CAAA;AACd,CAAC,EApBW,eAAe,+BAAf,eAAe,QAoB1B"}
1
+ {"version":3,"file":"signatureTypeV2.js","sourceRoot":"","sources":["../../../src/order-utils/model/signatureTypeV2.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,eAoBX;AApBD,WAAY,eAAe;IAC1B;;OAEG;IACH,mDAAO,CAAA;IAEP;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,6EAAoB,CAAA;IAEpB;;OAEG;IACH,+DAAa,CAAA;AACd,CAAC,EApBW,eAAe,KAAf,eAAe,QAoB1B"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateOrderSalt = generateOrderSalt;
4
- function generateOrderSalt() {
1
+ export function generateOrderSalt() {
5
2
  return `${Math.round(Math.random() * Date.now())}`;
6
3
  }
7
4
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/order-utils/utils.ts"],"names":[],"mappings":";;AAAA,8CAEC;AAFD,SAAgB,iBAAiB;IAChC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;AACpD,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/order-utils/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB;IAChC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;AACpD,CAAC"}
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CLOB_TYPES = exports.CLOB_DOMAIN = exports.MSG_TO_SIGN = exports.CLOB_VERSION = exports.CLOB_DOMAIN_NAME = void 0;
4
- exports.CLOB_DOMAIN_NAME = "ClobAuthDomain";
5
- exports.CLOB_VERSION = "1";
6
- exports.MSG_TO_SIGN = "This message attests that I control the given wallet";
7
- exports.CLOB_DOMAIN = {
8
- name: exports.CLOB_DOMAIN_NAME,
9
- version: exports.CLOB_VERSION,
1
+ export const CLOB_DOMAIN_NAME = "ClobAuthDomain";
2
+ export const CLOB_VERSION = "1";
3
+ export const MSG_TO_SIGN = "This message attests that I control the given wallet";
4
+ export const CLOB_DOMAIN = {
5
+ name: CLOB_DOMAIN_NAME,
6
+ version: CLOB_VERSION,
10
7
  chainId: 1,
11
8
  };
12
- exports.CLOB_TYPES = {
9
+ export const CLOB_TYPES = {
13
10
  ClobAuth: [
14
11
  { name: "address", type: "address" },
15
12
  { name: "timestamp", type: "string" },
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/signing/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AACpC,QAAA,YAAY,GAAG,GAAG,CAAC;AACnB,QAAA,WAAW,GAAG,sDAAsD,CAAC;AAErE,QAAA,WAAW,GAAG;IAC1B,IAAI,EAAE,wBAAgB;IACtB,OAAO,EAAE,oBAAY;IACrB,OAAO,EAAE,CAAC;CACV,CAAC;AAEW,QAAA,UAAU,GAAG;IACzB,QAAQ,EAAE;QACT,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;QACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;QACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;KACnC;CACD,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/signing/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AACjD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG,sDAAsD,CAAC;AAElF,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,CAAC;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,QAAQ,EAAE;QACT,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;QACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;QACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;KACnC;CACD,CAAC"}
@@ -1,10 +1,9 @@
1
- import type { JsonRpcSigner } from "@ethersproject/providers";
2
- import type { Wallet } from "@ethersproject/wallet";
3
- import type { Chain } from "../types";
1
+ import type { Chain } from "../types/index.js";
2
+ import { type ClobSigner } from "./signer.js";
4
3
  /**
5
4
  * Builds the canonical Polymarket CLOB EIP712 signature
6
5
  * @param signer
7
6
  * @param ts
8
7
  * @returns string
9
8
  */
10
- export declare const buildClobEip712Signature: (signer: Wallet | JsonRpcSigner, chainId: Chain, timestamp: number, nonce: number) => Promise<string>;
9
+ export declare const buildClobEip712Signature: (signer: ClobSigner, chainId: Chain, timestamp: number, nonce: number) => Promise<string>;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildClobEip712Signature = void 0;
4
- const tslib_1 = require("tslib");
5
- const constants_1 = require("./constants");
1
+ import { MSG_TO_SIGN } from "./constants.js";
2
+ import { getSignerAddress, signTypedData } from "./signer.js";
6
3
  /**
7
4
  * Builds the canonical Polymarket CLOB EIP712 signature
8
5
  * @param signer
9
6
  * @param ts
10
7
  * @returns string
11
8
  */
12
- const buildClobEip712Signature = (signer, chainId, timestamp, nonce) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
13
- const address = yield signer.getAddress();
9
+ export const buildClobEip712Signature = async (signer, chainId, timestamp, nonce) => {
10
+ const address = await getSignerAddress(signer);
14
11
  const ts = timestamp.toString();
15
12
  const domain = {
16
13
  name: "ClobAuthDomain",
@@ -29,11 +26,9 @@ const buildClobEip712Signature = (signer, chainId, timestamp, nonce) => tslib_1.
29
26
  address,
30
27
  timestamp: ts,
31
28
  nonce,
32
- message: constants_1.MSG_TO_SIGN,
29
+ message: MSG_TO_SIGN,
33
30
  };
34
- // eslint-disable-next-line no-underscore-dangle
35
- const sig = yield signer._signTypedData(domain, types, value);
31
+ const sig = await signTypedData(signer, domain, types, value);
36
32
  return sig;
37
- });
38
- exports.buildClobEip712Signature = buildClobEip712Signature;
33
+ };
39
34
  //# sourceMappingURL=eip712.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../src/signing/eip712.ts"],"names":[],"mappings":";;;;AAKA,2CAA0C;AAE1C;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,CACvC,MAA8B,EAC9B,OAAc,EACd,SAAiB,EACjB,KAAa,EACK,EAAE;IACpB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1C,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;IAEhC,MAAM,MAAM,GAAG;QACd,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,OAAO;KAChB,CAAC;IAEF,MAAM,KAAK,GAAG;QACb,QAAQ,EAAE;YACT,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;YACrC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;SACnC;KACD,CAAC;IACF,MAAM,KAAK,GAAG;QACb,OAAO;QACP,SAAS,EAAE,EAAE;QACb,KAAK;QACL,OAAO,EAAE,uBAAW;KACpB,CAAC;IACF,gDAAgD;IAChD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,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,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildPolyHmacSignature = void 0;
4
- const tslib_1 = require("tslib");
5
- const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
1
+ import crypto from "node:crypto";
6
2
  function replaceAll(s, search, replace) {
7
3
  return s.split(search).join(replace);
8
4
  }
@@ -14,13 +10,13 @@ function replaceAll(s, search, replace) {
14
10
  * @param passphrase
15
11
  * @returns string
16
12
  */
17
- const buildPolyHmacSignature = (secret, timestamp, method, requestPath, body) => {
13
+ export const buildPolyHmacSignature = (secret, timestamp, method, requestPath, body) => {
18
14
  let message = timestamp + method + requestPath;
19
15
  if (body !== undefined) {
20
16
  message += body;
21
17
  }
22
18
  const base64Secret = Buffer.from(secret, "base64");
23
- const hmac = node_crypto_1.default.createHmac("sha256", base64Secret);
19
+ const hmac = crypto.createHmac("sha256", base64Secret);
24
20
  const sig = hmac.update(message).digest("base64");
25
21
  // NOTE: Must be url safe base64 encoding, but keep base64 "=" suffix
26
22
  // Convert '+' to '-'
@@ -28,5 +24,4 @@ const buildPolyHmacSignature = (secret, timestamp, method, requestPath, body) =>
28
24
  const sigUrlSafe = replaceAll(replaceAll(sig, "+", "-"), "/", "_");
29
25
  return sigUrlSafe;
30
26
  };
31
- exports.buildPolyHmacSignature = buildPolyHmacSignature;
32
27
  //# sourceMappingURL=hmac.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":";;;;AAAA,sEAAiC;AAEjC,SAAS,UAAU,CAAC,CAAS,EAAE,MAAc,EAAE,OAAe;IAC7D,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CACrC,MAAc,EACd,SAAiB,EACjB,MAAc,EACd,WAAmB,EACnB,IAAa,EACJ,EAAE;IAC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,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAElD,qEAAqE;IACrE,qBAAqB;IACrB,qBAAqB;IACrB,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC"}
@@ -1,2 +1,3 @@
1
- export * from "./eip712";
2
- export * from "./hmac";
1
+ export * from "./eip712.js";
2
+ export * from "./hmac.js";
3
+ export * from "./signer.js";
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./eip712"), exports);
5
- tslib_1.__exportStar(require("./hmac"), exports);
1
+ export * from "./eip712.js";
2
+ export * from "./hmac.js";
3
+ export * from "./signer.js";
6
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,iDAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { JsonRpcSigner } from "@ethersproject/providers";
2
+ import type { Wallet } from "@ethersproject/wallet";
3
+ import type { WalletClient } from "viem";
4
+ export type ClobSigner = Wallet | JsonRpcSigner | WalletClient;
5
+ export declare const getSignerAddress: (signer: ClobSigner) => Promise<string>;
6
+ export declare const signTypedData: (signer: ClobSigner, domain: Record<string, unknown>, types: Record<string, {
7
+ name: string;
8
+ type: string;
9
+ }[]>, message: Record<string, unknown>) => Promise<string>;