@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.
- package/dist/client.d.ts +15 -29
- package/dist/client.js +723 -862
- package/dist/client.js.map +1 -1
- package/dist/config.js +1 -6
- package/dist/config.js.map +1 -1
- package/dist/constants.js +6 -9
- package/dist/constants.js.map +1 -1
- package/dist/endpoints.d.ts +1 -0
- package/dist/endpoints.js +54 -56
- package/dist/endpoints.js.map +1 -1
- package/dist/errors.js +2 -5
- package/dist/errors.js.map +1 -1
- package/dist/headers/index.d.ts +4 -5
- package/dist/headers/index.js +10 -15
- package/dist/headers/index.js.map +1 -1
- package/dist/http-helpers/index.d.ts +1 -1
- package/dist/http-helpers/index.js +41 -53
- package/dist/http-helpers/index.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.d.ts +2 -2
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js +12 -19
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js.map +1 -1
- package/dist/order-builder/helpers/buildOrder.d.ts +5 -6
- package/dist/order-builder/helpers/buildOrder.js +11 -18
- package/dist/order-builder/helpers/buildOrder.js.map +1 -1
- package/dist/order-builder/helpers/buildOrderCreationArgs.d.ts +2 -2
- package/dist/order-builder/helpers/buildOrderCreationArgs.js +13 -19
- package/dist/order-builder/helpers/buildOrderCreationArgs.js.map +1 -1
- package/dist/order-builder/helpers/calculateBuyMarketPrice.d.ts +1 -1
- package/dist/order-builder/helpers/calculateBuyMarketPrice.js +3 -7
- package/dist/order-builder/helpers/calculateBuyMarketPrice.js.map +1 -1
- package/dist/order-builder/helpers/calculateSellMarketPrice.d.ts +1 -1
- package/dist/order-builder/helpers/calculateSellMarketPrice.js +3 -7
- package/dist/order-builder/helpers/calculateSellMarketPrice.js.map +1 -1
- package/dist/order-builder/helpers/createMarketOrder.d.ts +5 -6
- package/dist/order-builder/helpers/createMarketOrder.js +15 -19
- package/dist/order-builder/helpers/createMarketOrder.js.map +1 -1
- package/dist/order-builder/helpers/createOrder.d.ts +5 -6
- package/dist/order-builder/helpers/createOrder.js +15 -19
- package/dist/order-builder/helpers/createOrder.js.map +1 -1
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.d.ts +1 -1
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.js +17 -21
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.js.map +1 -1
- package/dist/order-builder/helpers/getOrderRawAmounts.d.ts +1 -1
- package/dist/order-builder/helpers/getOrderRawAmounts.js +17 -21
- package/dist/order-builder/helpers/getOrderRawAmounts.js.map +1 -1
- package/dist/order-builder/helpers/index.d.ts +10 -10
- package/dist/order-builder/helpers/index.js +10 -23
- package/dist/order-builder/helpers/index.js.map +1 -1
- package/dist/order-builder/helpers/roundingConfig.d.ts +1 -1
- package/dist/order-builder/helpers/roundingConfig.js +1 -4
- package/dist/order-builder/helpers/roundingConfig.js.map +1 -1
- package/dist/order-builder/index.d.ts +1 -1
- package/dist/order-builder/index.js +1 -4
- package/dist/order-builder/index.js.map +1 -1
- package/dist/order-builder/orderBuilder.d.ts +5 -6
- package/dist/order-builder/orderBuilder.js +34 -29
- package/dist/order-builder/orderBuilder.js.map +1 -1
- package/dist/order-utils/abi/ExchangeV1.js +1 -4
- package/dist/order-utils/abi/ExchangeV1.js.map +1 -1
- package/dist/order-utils/abi/ExchangeV2.js +1 -4
- package/dist/order-utils/abi/ExchangeV2.js.map +1 -1
- package/dist/order-utils/exchangeOrderBuilderV1.d.ts +5 -6
- package/dist/order-utils/exchangeOrderBuilderV1.js +77 -78
- package/dist/order-utils/exchangeOrderBuilderV1.js.map +1 -1
- package/dist/order-utils/exchangeOrderBuilderV2.d.ts +6 -7
- package/dist/order-utils/exchangeOrderBuilderV2.js +50 -51
- package/dist/order-utils/exchangeOrderBuilderV2.js.map +1 -1
- package/dist/order-utils/index.js +8 -11
- package/dist/order-utils/index.js.map +1 -1
- package/dist/order-utils/model/abi.js +1 -2
- package/dist/order-utils/model/ctfExchangeV1TypedData.js +3 -6
- package/dist/order-utils/model/ctfExchangeV1TypedData.js.map +1 -1
- package/dist/order-utils/model/ctfExchangeV2TypedData.js +3 -6
- package/dist/order-utils/model/ctfExchangeV2TypedData.js.map +1 -1
- package/dist/order-utils/model/eip712.js +1 -4
- package/dist/order-utils/model/eip712.js.map +1 -1
- package/dist/order-utils/model/order.js +1 -2
- package/dist/order-utils/model/orderDataV1.d.ts +4 -4
- package/dist/order-utils/model/orderDataV1.js +1 -2
- package/dist/order-utils/model/orderDataV2.d.ts +12 -13
- package/dist/order-utils/model/orderDataV2.js +1 -2
- package/dist/order-utils/model/side.d.ts +0 -4
- package/dist/order-utils/model/side.js +4 -12
- package/dist/order-utils/model/side.js.map +1 -1
- package/dist/order-utils/model/signatureTypeV1.js +2 -5
- package/dist/order-utils/model/signatureTypeV1.js.map +1 -1
- package/dist/order-utils/model/signatureTypeV2.js +2 -5
- package/dist/order-utils/model/signatureTypeV2.js.map +1 -1
- package/dist/order-utils/utils.js +1 -4
- package/dist/order-utils/utils.js.map +1 -1
- package/dist/signing/constants.js +7 -10
- package/dist/signing/constants.js.map +1 -1
- package/dist/signing/eip712.d.ts +3 -4
- package/dist/signing/eip712.js +7 -12
- package/dist/signing/eip712.js.map +1 -1
- package/dist/signing/hmac.js +3 -8
- package/dist/signing/hmac.js.map +1 -1
- package/dist/signing/index.d.ts +3 -2
- package/dist/signing/index.js +3 -5
- package/dist/signing/index.js.map +1 -1
- package/dist/signing/signer.d.ts +9 -0
- package/dist/signing/signer.js +30 -0
- package/dist/signing/signer.js.map +1 -0
- package/dist/types/clob.d.ts +19 -6
- package/dist/types/clob.js +10 -13
- package/dist/types/clob.js.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.js +4 -7
- package/dist/types/index.js.map +1 -1
- package/dist/types/ordersV1.d.ts +3 -2
- package/dist/types/ordersV1.js +22 -2
- package/dist/types/ordersV1.js.map +1 -1
- package/dist/types/ordersV2.d.ts +14 -5
- package/dist/types/ordersV2.js +23 -2
- package/dist/types/ordersV2.js.map +1 -1
- package/dist/types/unifiedOrder.d.ts +4 -4
- package/dist/types/unifiedOrder.js +1 -4
- package/dist/types/unifiedOrder.js.map +1 -1
- package/dist/utilities.d.ts +1 -5
- package/dist/utilities.js +15 -88
- package/dist/utilities.js.map +1 -1
- package/package.json +47 -42
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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:
|
|
71
|
-
Order:
|
|
70
|
+
EIP712Domain: EIP712_DOMAIN,
|
|
71
|
+
Order: CTF_EXCHANGE_V2_ORDER_STRUCT,
|
|
72
72
|
},
|
|
73
73
|
domain: {
|
|
74
|
-
name:
|
|
75
|
-
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
|
|
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 =
|
|
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":"
|
|
1
|
+
{"version":3,"file":"exchangeOrderBuilderV2.js","sourceRoot":"","sources":["../../src/order-utils/exchangeOrderBuilderV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAmB,gBAAgB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EACN,2BAA2B,EAC3B,8BAA8B,EAC9B,4BAA4B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAwB,MAAM,mBAAmB,CAAC;AAGxE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,OAAO,sBAAsB;IAEhB;IACA;IACA;IACA;IAJlB,YACkB,eAAuB,EACvB,OAAe,EACf,MAAkB,EAClB,eAAe,iBAAiB;QAHhC,oBAAe,GAAf,eAAe,CAAQ;QACvB,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAY;QAClB,iBAAY,GAAZ,YAAY,CAAoB;IAC/C,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,SAAsB;QAC5C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACvD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;QAEtE,OAAO;YACN,GAAG,KAAK;YACR,SAAS,EAAE,cAAc;SACR,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,EAChB,KAAK,EACL,OAAO,EACP,WAAW,EACX,WAAW,EACX,IAAI,EACJ,MAAM,EACN,aAAa,EACb,SAAS,EACT,QAAQ,EACR,OAAO,EACP,UAAU,GACG;QACb,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,GAAG,KAAK,CAAC;QAChB,CAAC;QAED,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,MAAM,KAAK,aAAa,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC1C,CAAC;QAED,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE;YACzB,KAAK;YACL,MAAM;YACN,OAAO;YACP,WAAW;YACX,WAAW;YACX,IAAI;YACJ,aAAa,EAAE,aAAa,IAAI,eAAe,CAAC,GAAG;YACnD,QAAQ,EAAE,QAAQ,IAAI,WAAW;YACjC,OAAO,EAAE,OAAO,IAAI,WAAW;YAC/B,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;YAC7C,UAAU,EAAE,UAAU,IAAI,GAAG;SAC7B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,KAAc;QACjC,OAAO;YACN,WAAW,EAAE,OAAO;YACpB,KAAK,EAAE;gBACN,YAAY,EAAE,aAAa;gBAC3B,KAAK,EAAE,4BAA4B;aACnC;YACD,MAAM,EAAE;gBACP,IAAI,EAAE,2BAA2B;gBACjC,OAAO,EAAE,8BAA8B;gBACvC,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,iBAAiB,EAAE,IAAI,CAAC,eAAe;aACvC;YACD,OAAO,EAAE;gBACR,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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":"
|
|
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,9 +1,6 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
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":"
|
|
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
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
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":"
|
|
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
|
-
|
|
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":"
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import type { Side } from "../../types/index.
|
|
2
|
-
import type { EIP712Object } from "./eip712.
|
|
3
|
-
import type { OrderSignature } from "./order.
|
|
4
|
-
import type { SignatureTypeV1 } from "./signatureTypeV1.
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import type { Side } from "../../types/index.
|
|
2
|
-
import type { EIP712Object } from "./eip712.
|
|
3
|
-
import type { OrderSignature } from "./order.
|
|
4
|
-
import type { SignatureTypeV2 } from "./signatureTypeV2.
|
|
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,14 +1,6 @@
|
|
|
1
|
-
|
|
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[
|
|
7
|
-
Side[
|
|
8
|
-
})(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":"
|
|
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
|
-
|
|
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 || (
|
|
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":"
|
|
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
|
-
|
|
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 || (
|
|
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":"
|
|
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
|
-
|
|
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":"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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":"
|
|
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"}
|
package/dist/signing/eip712.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
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:
|
|
9
|
+
export declare const buildClobEip712Signature: (signer: ClobSigner, chainId: Chain, timestamp: number, nonce: number) => Promise<string>;
|
package/dist/signing/eip712.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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) =>
|
|
13
|
-
const address =
|
|
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:
|
|
29
|
+
message: MSG_TO_SIGN,
|
|
33
30
|
};
|
|
34
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../src/signing/eip712.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAmB,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAC5C,MAAkB,EAClB,OAAc,EACd,SAAiB,EACjB,KAAa,EACK,EAAE;IACpB,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/C,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,WAAW;KACpB,CAAC;IACF,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9D,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC"}
|
package/dist/signing/hmac.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
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 =
|
|
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
|
package/dist/signing/hmac.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;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;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACrC,MAAc,EACd,SAAiB,EACjB,MAAc,EACd,WAAmB,EACnB,IAAa,EACJ,EAAE;IACX,IAAI,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;IAC/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,IAAI,CAAC;IACjB,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,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"}
|
package/dist/signing/index.d.ts
CHANGED
|
@@ -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";
|
package/dist/signing/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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":"
|
|
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>;
|