@epoch-protocol/epoch-commons-sdk 0.1.3 → 0.1.5

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.
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COMPACT_ADDRESS = void 0;
4
1
  // The Compact is deployed at the same address on all networks
5
- exports.COMPACT_ADDRESS = '0x00000000000000171ede64904551eeDF3C6C9788';
2
+ export const COMPACT_ADDRESS = '0x00000000000000171ede64904551eeDF3C6C9788';
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CONTRACT_ADDRESSES = exports.SAFE_MULTISEND_CALL_ONLY_ADDRESS = exports.SAFE_MULTISEND_ADDRESS = exports.EPOCH_ESCROW_ADDRESS = exports.METAMASK_EXEC_MANAGER = exports.EIP7702_SAFE_PROXY_ADDRESS = exports.SAFE_7579_REGISTRY_ADDRESS = exports.SAFE_7579_MODULE_ADDRESS = exports.SAFE_7702_SINGLETON_ADDRESS = exports.SAFE_SINGLETON_ADDRESS = exports.SAFE_PROXY_FACTORY_ADDRESS = exports.FCLP256Verifier = exports.SAFE_WEBAUTHN_SIGNER_FACTORY = exports.SAFE_WEBAUTHN_SHARED_SIGNER = exports.SAFE_INIT_SETUP_FORWARDER = exports.EPOCH_SAFE_INIT_SETUP = exports.EPOCH_MODULE_SAFE_ADDRESS = exports.INTENT_REGISTRY_ADDRESS = void 0;
4
- exports.INTENT_REGISTRY_ADDRESS = {
1
+ export const INTENT_REGISTRY_ADDRESS = {
5
2
  11155111: "0x299Ea355dBeDF225b3a88D67827a0a04dF943749",
6
3
  11155420: "0x299Ea355dBeDF225b3a88D67827a0a04dF943749",
7
4
  84532: "0x299Ea355dBeDF225b3a88D67827a0a04dF943749",
@@ -10,7 +7,7 @@ exports.INTENT_REGISTRY_ADDRESS = {
10
7
  11155931: "0x299Ea355dBeDF225b3a88D67827a0a04dF943749",
11
8
  129399: "0x299Ea355dBeDF225b3a88D67827a0a04dF943749",
12
9
  };
13
- exports.EPOCH_MODULE_SAFE_ADDRESS = {
10
+ export const EPOCH_MODULE_SAFE_ADDRESS = {
14
11
  11155111: "0x1b4a3398102d42CA600Cb7e3f40a5495B4954071",
15
12
  11155420: "0x1b4a3398102d42CA600Cb7e3f40a5495B4954071",
16
13
  84532: "0x1b4a3398102d42CA600Cb7e3f40a5495B4954071",
@@ -19,7 +16,7 @@ exports.EPOCH_MODULE_SAFE_ADDRESS = {
19
16
  11155931: "0x1b4a3398102d42CA600Cb7e3f40a5495B4954071",
20
17
  129399: "0x1b4a3398102d42CA600Cb7e3f40a5495B4954071",
21
18
  };
22
- exports.EPOCH_SAFE_INIT_SETUP = {
19
+ export const EPOCH_SAFE_INIT_SETUP = {
23
20
  11155111: "0xf460890181cB9C76EE404edE779555c9fEefB10e",
24
21
  11155420: "0xf460890181cB9C76EE404edE779555c9fEefB10e",
25
22
  84532: "0xf460890181cB9C76EE404edE779555c9fEefB10e",
@@ -28,7 +25,7 @@ exports.EPOCH_SAFE_INIT_SETUP = {
28
25
  11155931: "0xf460890181cB9C76EE404edE779555c9fEefB10e",
29
26
  129399: "0xf460890181cB9C76EE404edE779555c9fEefB10e",
30
27
  };
31
- exports.SAFE_INIT_SETUP_FORWARDER = {
28
+ export const SAFE_INIT_SETUP_FORWARDER = {
32
29
  11155111: "0x8c7192D248361844DBDdDa5dE58DF591996C44CB",
33
30
  11155420: "0x8c7192D248361844DBDdDa5dE58DF591996C44CB",
34
31
  84532: "0x8c7192D248361844DBDdDa5dE58DF591996C44CB",
@@ -37,7 +34,7 @@ exports.SAFE_INIT_SETUP_FORWARDER = {
37
34
  11155931: "0x8c7192D248361844DBDdDa5dE58DF591996C44CB",
38
35
  129399: "0x8c7192D248361844DBDdDa5dE58DF591996C44CB",
39
36
  };
40
- exports.SAFE_WEBAUTHN_SHARED_SIGNER = {
37
+ export const SAFE_WEBAUTHN_SHARED_SIGNER = {
41
38
  11155111: "0x049b3EA3f45460dec04438312e70876f9325a737",
42
39
  11155420: "0x049b3EA3f45460dec04438312e70876f9325a737",
43
40
  84532: "0x049b3EA3f45460dec04438312e70876f9325a737",
@@ -46,7 +43,7 @@ exports.SAFE_WEBAUTHN_SHARED_SIGNER = {
46
43
  80002: "0x049b3EA3f45460dec04438312e70876f9325a737",
47
44
  11155931: "0x049b3EA3f45460dec04438312e70876f9325a737",
48
45
  };
49
- exports.SAFE_WEBAUTHN_SIGNER_FACTORY = {
46
+ export const SAFE_WEBAUTHN_SIGNER_FACTORY = {
50
47
  11155111: "0xE66584AFFD075E9224d3B0f36978ec0263cEd6FD",
51
48
  11155420: "0xE66584AFFD075E9224d3B0f36978ec0263cEd6FD",
52
49
  84532: "0xE66584AFFD075E9224d3B0f36978ec0263cEd6FD",
@@ -55,7 +52,7 @@ exports.SAFE_WEBAUTHN_SIGNER_FACTORY = {
55
52
  80002: "0xE66584AFFD075E9224d3B0f36978ec0263cEd6FD",
56
53
  11155931: "0xE66584AFFD075E9224d3B0f36978ec0263cEd6FD",
57
54
  };
58
- exports.FCLP256Verifier = {
55
+ export const FCLP256Verifier = {
59
56
  11155111: "0xFB5D9DAddC16Bd61566c82Bf3F0659ce2B538bEE",
60
57
  11155420: "0xFB5D9DAddC16Bd61566c82Bf3F0659ce2B538bEE",
61
58
  84532: "0xFB5D9DAddC16Bd61566c82Bf3F0659ce2B538bEE",
@@ -65,7 +62,7 @@ exports.FCLP256Verifier = {
65
62
  11155931: "0xFB5D9DAddC16Bd61566c82Bf3F0659ce2B538bEE",
66
63
  };
67
64
  //todo: update for testnets
68
- exports.SAFE_PROXY_FACTORY_ADDRESS = {
65
+ export const SAFE_PROXY_FACTORY_ADDRESS = {
69
66
  11155111: "0x6F0035ed7325d0DAaC2eB12562422Ae53faa682C",
70
67
  11155420: "0x6F0035ed7325d0DAaC2eB12562422Ae53faa682C",
71
68
  84532: "0x6F0035ed7325d0DAaC2eB12562422Ae53faa682C",
@@ -75,7 +72,7 @@ exports.SAFE_PROXY_FACTORY_ADDRESS = {
75
72
  11155931: "0x6F0035ed7325d0DAaC2eB12562422Ae53faa682C",
76
73
  };
77
74
  //todo: update for testnets
78
- exports.SAFE_SINGLETON_ADDRESS = {
75
+ export const SAFE_SINGLETON_ADDRESS = {
79
76
  11155111: "0x5FdB4DaE6733008c82652D4e1B4a8c02dA3F5175",
80
77
  11155420: "0x5FdB4DaE6733008c82652D4e1B4a8c02dA3F5175",
81
78
  84532: "0x5FdB4DaE6733008c82652D4e1B4a8c02dA3F5175",
@@ -85,7 +82,7 @@ exports.SAFE_SINGLETON_ADDRESS = {
85
82
  11155931: "0x5FdB4DaE6733008c82652D4e1B4a8c02dA3F5175",
86
83
  };
87
84
  //todo: update for testnets
88
- exports.SAFE_7702_SINGLETON_ADDRESS = {
85
+ export const SAFE_7702_SINGLETON_ADDRESS = {
89
86
  11155111: "0x18F2d1EB128e64fE5EDcCa6A0Fa7702Aa44cf664",
90
87
  11155420: "0x18F2d1EB128e64fE5EDcCa6A0Fa7702Aa44cf664",
91
88
  84532: "0x18F2d1EB128e64fE5EDcCa6A0Fa7702Aa44cf664",
@@ -94,7 +91,7 @@ exports.SAFE_7702_SINGLETON_ADDRESS = {
94
91
  80002: "0x18F2d1EB128e64fE5EDcCa6A0Fa7702Aa44cf664",
95
92
  11155931: "0x18F2d1EB128e64fE5EDcCa6A0Fa7702Aa44cf664",
96
93
  };
97
- exports.SAFE_7579_MODULE_ADDRESS = {
94
+ export const SAFE_7579_MODULE_ADDRESS = {
98
95
  11155111: "0x5f73D1792f81Ee2356f99764904Cb03956F577d0",
99
96
  11155420: "0x5f73D1792f81Ee2356f99764904Cb03956F577d0",
100
97
  84532: "0x5f73D1792f81Ee2356f99764904Cb03956F577d0",
@@ -104,7 +101,7 @@ exports.SAFE_7579_MODULE_ADDRESS = {
104
101
  11155931: "0x5f73D1792f81Ee2356f99764904Cb03956F577d0",
105
102
  };
106
103
  //todo: update for testnets
107
- exports.SAFE_7579_REGISTRY_ADDRESS = {
104
+ export const SAFE_7579_REGISTRY_ADDRESS = {
108
105
  11155111: "0x6F1aBD911DBec98EEd1DfA470Ee98b61D3131A55",
109
106
  11155420: "0x6F1aBD911DBec98EEd1DfA470Ee98b61D3131A55",
110
107
  84532: "0x6F1aBD911DBec98EEd1DfA470Ee98b61D3131A55",
@@ -114,7 +111,7 @@ exports.SAFE_7579_REGISTRY_ADDRESS = {
114
111
  11155931: "0x6F1aBD911DBec98EEd1DfA470Ee98b61D3131A55",
115
112
  };
116
113
  //todo: update for testnets
117
- exports.EIP7702_SAFE_PROXY_ADDRESS = {
114
+ export const EIP7702_SAFE_PROXY_ADDRESS = {
118
115
  11155111: "0xE60EcE6588DCcFb7373538034963B4D20a280DB0",
119
116
  11155420: "0xc8490cDee50174A00105598AD615e2d00f0Cfb10",
120
117
  84532: "0xc8490cDee50174A00105598AD615e2d00f0Cfb10",
@@ -123,7 +120,7 @@ exports.EIP7702_SAFE_PROXY_ADDRESS = {
123
120
  80002: "0xc8490cDee50174A00105598AD615e2d00f0Cfb10",
124
121
  11155931: "0xc8490cDee50174A00105598AD615e2d00f0Cfb10",
125
122
  };
126
- exports.METAMASK_EXEC_MANAGER = {
123
+ export const METAMASK_EXEC_MANAGER = {
127
124
  11155111: "0xC913903b10f8Aa3bEf3e368EbDAeb13D73603524",
128
125
  11155420: "0xC913903b10f8Aa3bEf3e368EbDAeb13D73603524",
129
126
  84532: "0xC913903b10f8Aa3bEf3e368EbDAeb13D73603524",
@@ -132,7 +129,7 @@ exports.METAMASK_EXEC_MANAGER = {
132
129
  80002: "0xC913903b10f8Aa3bEf3e368EbDAeb13D73603524",
133
130
  11155931: "0xC913903b10f8Aa3bEf3e368EbDAeb13D73603524",
134
131
  };
135
- exports.EPOCH_ESCROW_ADDRESS = {
132
+ export const EPOCH_ESCROW_ADDRESS = {
136
133
  11155111: "0xA88Ea7EB5f687d05e20b7232d698864A7c17e20C",
137
134
  11155420: "0xA88Ea7EB5f687d05e20b7232d698864A7c17e20C",
138
135
  84532: "0xA88Ea7EB5f687d05e20b7232d698864A7c17e20C",
@@ -141,7 +138,7 @@ exports.EPOCH_ESCROW_ADDRESS = {
141
138
  80002: "0xA88Ea7EB5f687d05e20b7232d698864A7c17e20C",
142
139
  11155931: "0xA88Ea7EB5f687d05e20b7232d698864A7c17e20C",
143
140
  };
144
- exports.SAFE_MULTISEND_ADDRESS = {
141
+ export const SAFE_MULTISEND_ADDRESS = {
145
142
  11155111: "0x328AB3a53287503DF0EFED81928a2b45b3205B2A",
146
143
  11155420: "0x328AB3a53287503DF0EFED81928a2b45b3205B2A",
147
144
  84532: "0x328AB3a53287503DF0EFED81928a2b45b3205B2A",
@@ -150,7 +147,7 @@ exports.SAFE_MULTISEND_ADDRESS = {
150
147
  80002: "0x328AB3a53287503DF0EFED81928a2b45b3205B2A",
151
148
  11155931: "0x328AB3a53287503DF0EFED81928a2b45b3205B2A",
152
149
  };
153
- exports.SAFE_MULTISEND_CALL_ONLY_ADDRESS = {
150
+ export const SAFE_MULTISEND_CALL_ONLY_ADDRESS = {
154
151
  11155111: "0x944b129a384265D916fbEA3440CD2caA4925145c",
155
152
  11155420: "0x944b129a384265D916fbEA3440CD2caA4925145c",
156
153
  84532: "0x944b129a384265D916fbEA3440CD2caA4925145c",
@@ -160,22 +157,22 @@ exports.SAFE_MULTISEND_CALL_ONLY_ADDRESS = {
160
157
  11155931: "0x944b129a384265D916fbEA3440CD2caA4925145c",
161
158
  };
162
159
  const CONTRACT_ADDRESSES = {
163
- METAMASK_EXEC_MANAGER: exports.METAMASK_EXEC_MANAGER,
164
- SAFE_PROXY_FACTORY_ADDRESS: exports.SAFE_PROXY_FACTORY_ADDRESS,
165
- SAFE_SINGLETON_ADDRESS: exports.SAFE_SINGLETON_ADDRESS,
166
- SAFE_7702_SINGLETON_ADDRESS: exports.SAFE_7702_SINGLETON_ADDRESS,
167
- SAFE_7579_MODULE_ADDRESS: exports.SAFE_7579_MODULE_ADDRESS,
168
- SAFE_7579_REGISTRY_ADDRESS: exports.SAFE_7579_REGISTRY_ADDRESS,
169
- EIP7702_SAFE_PROXY_ADDRESS: exports.EIP7702_SAFE_PROXY_ADDRESS,
170
- EPOCH_MODULE_SAFE_ADDRESS: exports.EPOCH_MODULE_SAFE_ADDRESS,
171
- EPOCH_SAFE_INIT_SETUP: exports.EPOCH_SAFE_INIT_SETUP,
172
- INTENT_REGISTRY_ADDRESS: exports.INTENT_REGISTRY_ADDRESS,
173
- SAFE_INIT_SETUP_FORWARDER: exports.SAFE_INIT_SETUP_FORWARDER,
174
- SAFE_WEBAUTHN_SHARED_SIGNER: exports.SAFE_WEBAUTHN_SHARED_SIGNER,
175
- SAFE_WEBAUTHN_SIGNER_FACTORY: exports.SAFE_WEBAUTHN_SIGNER_FACTORY,
176
- FCLP256Verifier: exports.FCLP256Verifier,
177
- EPOCH_ESCROW_ADDRESS: exports.EPOCH_ESCROW_ADDRESS,
178
- SAFE_MULTISEND_ADDRESS: exports.SAFE_MULTISEND_ADDRESS,
179
- SAFE_MULTISEND_CALL_ONLY_ADDRESS: exports.SAFE_MULTISEND_CALL_ONLY_ADDRESS,
180
- };
181
- exports.CONTRACT_ADDRESSES = CONTRACT_ADDRESSES;
160
+ METAMASK_EXEC_MANAGER,
161
+ SAFE_PROXY_FACTORY_ADDRESS,
162
+ SAFE_SINGLETON_ADDRESS,
163
+ SAFE_7702_SINGLETON_ADDRESS,
164
+ SAFE_7579_MODULE_ADDRESS,
165
+ SAFE_7579_REGISTRY_ADDRESS,
166
+ EIP7702_SAFE_PROXY_ADDRESS,
167
+ EPOCH_MODULE_SAFE_ADDRESS,
168
+ EPOCH_SAFE_INIT_SETUP,
169
+ INTENT_REGISTRY_ADDRESS,
170
+ SAFE_INIT_SETUP_FORWARDER,
171
+ SAFE_WEBAUTHN_SHARED_SIGNER,
172
+ SAFE_WEBAUTHN_SIGNER_FACTORY,
173
+ FCLP256Verifier,
174
+ EPOCH_ESCROW_ADDRESS,
175
+ SAFE_MULTISEND_ADDRESS,
176
+ SAFE_MULTISEND_CALL_ONLY_ADDRESS,
177
+ };
178
+ export { CONTRACT_ADDRESSES };
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./contractAddresses"), exports);
18
- __exportStar(require("./compact"), exports);
1
+ export * from "./contractAddresses";
2
+ export * from "./compact";
@@ -1,10 +1,3 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.testnetGraph = exports.mainnetGraph = void 0;
7
- const epochgraphmainnet_json_1 = __importDefault(require("./epochgraphmainnet.json"));
8
- exports.mainnetGraph = epochgraphmainnet_json_1.default;
9
- const epochgraphtestnet_json_1 = __importDefault(require("./epochgraphtestnet.json"));
10
- exports.testnetGraph = epochgraphtestnet_json_1.default;
1
+ import mainnetGraph from "./epochgraphmainnet.json";
2
+ import testnetGraph from "./epochgraphtestnet.json";
3
+ export { mainnetGraph, testnetGraph };
package/dist/index.js CHANGED
@@ -1,22 +1,6 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
1
  // Export types
18
- __exportStar(require("./types"), exports);
19
- __exportStar(require("./data"), exports);
20
- __exportStar(require("./constants"), exports);
21
- __exportStar(require("./utils"), exports);
22
- __exportStar(require("./web3"), exports);
2
+ export * from "./types";
3
+ export * from "./data";
4
+ export * from "./constants";
5
+ export * from "./utils";
6
+ export * from "./web3";
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskType = exports.QueueExecutionType = exports.TransactionStatus = exports.ProtocolType = exports.WalletType = void 0;
4
- var WalletType;
1
+ export var WalletType;
5
2
  (function (WalletType) {
6
3
  WalletType["safe"] = "safe";
7
4
  WalletType["metamask"] = "metamask";
8
- })(WalletType || (exports.WalletType = WalletType = {}));
5
+ })(WalletType || (WalletType = {}));
9
6
  // Define types for various entities
10
- var ProtocolType;
7
+ export var ProtocolType;
11
8
  (function (ProtocolType) {
12
9
  ProtocolType["lending"] = "lending:deposit";
13
10
  ProtocolType["bridge"] = "bridge";
@@ -16,22 +13,22 @@ var ProtocolType;
16
13
  ProtocolType["yield"] = "yield";
17
14
  ProtocolType["swapandbridge"] = "swapandbridge";
18
15
  ProtocolType["protocolInteraction"] = "protocol-interaction";
19
- })(ProtocolType || (exports.ProtocolType = ProtocolType = {}));
20
- var TransactionStatus;
16
+ })(ProtocolType || (ProtocolType = {}));
17
+ export var TransactionStatus;
21
18
  (function (TransactionStatus) {
22
19
  TransactionStatus["PENDING"] = "pending";
23
20
  TransactionStatus["SUCCESS"] = "success";
24
21
  TransactionStatus["FAILED"] = "failed";
25
- })(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
26
- var QueueExecutionType;
22
+ })(TransactionStatus || (TransactionStatus = {}));
23
+ export var QueueExecutionType;
27
24
  (function (QueueExecutionType) {
28
25
  QueueExecutionType["ADD_AND_EXECUTE"] = "addAndExecute";
29
26
  QueueExecutionType["ADD_INTENT"] = "addIntent";
30
27
  QueueExecutionType["SIMPLE_EXECUTION"] = "simpleExecution";
31
- })(QueueExecutionType || (exports.QueueExecutionType = QueueExecutionType = {}));
32
- var TaskType;
28
+ })(QueueExecutionType || (QueueExecutionType = {}));
29
+ export var TaskType;
33
30
  (function (TaskType) {
34
31
  TaskType["GetTokenOut"] = "gettokenout";
35
32
  TaskType["Deposit"] = "deposit";
36
33
  TaskType["ProtocolInteraction"] = "protocol-interaction";
37
- })(TaskType || (exports.TaskType = TaskType = {}));
34
+ })(TaskType || (TaskType = {}));
@@ -1,20 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCompactTypehash = getCompactTypehash;
4
- exports.getClaimHash = getClaimHash;
5
- const viem_1 = require("viem");
6
- const utils_1 = require("viem/utils");
7
- function getCompactTypehash(witnessTypeString) {
1
+ import { keccak256, toBytes, } from 'viem';
2
+ import { hashStruct } from 'viem/utils';
3
+ export function getCompactTypehash(witnessTypeString) {
8
4
  if (witnessTypeString) {
9
5
  const typestring = `Compact(address arbiter,address sponsor,uint256 nonce,uint256 expires,bytes12 lockTag,address token,uint256 amount,Mandate mandate)Mandate(${witnessTypeString})`;
10
6
  console.log('typestring: ', typestring);
11
- return (0, viem_1.keccak256)((0, viem_1.toBytes)(typestring));
7
+ return keccak256(toBytes(typestring));
12
8
  }
13
9
  const typestring = 'Compact(address arbiter,address sponsor,uint256 nonce,uint256 expires,bytes12 lockTag,address token,uint256 amount)';
14
10
  console.log('typestring: ', typestring);
15
- return (0, viem_1.keccak256)((0, viem_1.toBytes)(typestring));
11
+ return keccak256(toBytes(typestring));
16
12
  }
17
- function getClaimHash(message, witnessTypeString) {
13
+ export function getClaimHash(message, witnessTypeString) {
18
14
  // Convert lockTag bigint to bytes12 hex string and token bigint to address
19
15
  const messageWithFormattedData = {
20
16
  ...message,
@@ -27,7 +23,7 @@ function getClaimHash(message, witnessTypeString) {
27
23
  console.log('Hererererere');
28
24
  console.log('getTypes(message): ', getTypes(message, witnessTypeString));
29
25
  console.log('herererere: ');
30
- return (0, utils_1.hashStruct)({
26
+ return hashStruct({
31
27
  types: getTypes(messageWithFormattedData, witnessTypeString),
32
28
  primaryType: 'Compact',
33
29
  data: messageWithFormattedData,
@@ -1 +1,2 @@
1
1
  export * from "./compact";
2
+ export * from "./path";
@@ -1,17 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./compact"), exports);
1
+ export * from "./compact";
2
+ export * from "./path";
@@ -0,0 +1,10 @@
1
+ import type { Path } from "../types";
2
+ /**
3
+ * Extracts tokenIn (first token amount) and tokenOut (last token amount) from a path.
4
+ * Path structure: path[chainPathIndex][entityRow][item].
5
+ * Rows per chain: chain, protocol, tokens, calldata.
6
+ */
7
+ export declare function parseQuoteFromPath(path: Path): {
8
+ tokenIn: string;
9
+ tokenOut: string;
10
+ } | null;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Extracts tokenIn (first token amount) and tokenOut (last token amount) from a path.
3
+ * Path structure: path[chainPathIndex][entityRow][item].
4
+ * Rows per chain: chain, protocol, tokens, calldata.
5
+ */
6
+ export function parseQuoteFromPath(path) {
7
+ if (!path || path.length === 0)
8
+ return null;
9
+ let tokenIn;
10
+ for (const chainPath of path) {
11
+ for (const entityRow of chainPath) {
12
+ for (const item of entityRow) {
13
+ if (item.token?.amount) {
14
+ tokenIn = item.token.amount;
15
+ break;
16
+ }
17
+ }
18
+ if (tokenIn)
19
+ break;
20
+ }
21
+ if (tokenIn)
22
+ break;
23
+ }
24
+ // Last chain path, row before calldata (at(-2)), last item's token.amount
25
+ const tokenOut = path.at(-1)?.at(-2)?.at(-1)?.token?.amount;
26
+ if (tokenIn && tokenOut)
27
+ return { tokenIn, tokenOut };
28
+ return null;
29
+ }
@@ -1,23 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.COMPACT_ABI = void 0;
21
- const COMPACT_ABI_json_1 = __importDefault(require("./abis/COMPACT_ABI.json"));
22
- exports.COMPACT_ABI = COMPACT_ABI_json_1.default;
23
- __exportStar(require("./intents"), exports);
1
+ import COMPACT_ABI from "./abis/COMPACT_ABI.json";
2
+ export * from "./intents";
3
+ export { COMPACT_ABI };
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEIP191IntentHash = exports.getIntentHash = exports.getEncodedIntent = void 0;
4
- const ethers_1 = require("ethers");
1
+ import { ethers } from "ethers";
5
2
  const getEncodedIntent = (intent) => {
6
- const abiCoder = new ethers_1.ethers.AbiCoder();
3
+ const abiCoder = new ethers.AbiCoder();
7
4
  const intentParamsType = `tuple(
8
5
  address sender,
9
6
  tuple(address tokenAddress, address spenderAddress, uint256 amount, uint256 chainId)[] approvals,
@@ -16,17 +13,15 @@ const getEncodedIntent = (intent) => {
16
13
  tuple(address target, uint256 value, bytes data)[] calldatas
17
14
  )`;
18
15
  const encodedIntent = abiCoder.encode([intentParamsType], [intent]);
19
- return ethers_1.ethers.getBytes(encodedIntent);
16
+ return ethers.getBytes(encodedIntent);
20
17
  };
21
- exports.getEncodedIntent = getEncodedIntent;
22
18
  const getIntentHash = (intent) => {
23
19
  const encodedIntent = getEncodedIntent(intent);
24
- const messageHash = ethers_1.ethers.keccak256(encodedIntent);
20
+ const messageHash = ethers.keccak256(encodedIntent);
25
21
  return messageHash;
26
22
  };
27
- exports.getIntentHash = getIntentHash;
28
23
  const getEIP191IntentHash = (intent) => {
29
24
  const encodedIntent = getEncodedIntent(intent);
30
- return ethers_1.ethers.hashMessage(encodedIntent);
25
+ return ethers.hashMessage(encodedIntent);
31
26
  };
32
- exports.getEIP191IntentHash = getEIP191IntentHash;
27
+ export { getEncodedIntent, getIntentHash, getEIP191IntentHash };
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@epoch-protocol/epoch-commons-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "SDK for interacting with Epoch Commons Protocol",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "scripts": {
@@ -1,9 +0,0 @@
1
- import { ethers } from "ethers";
2
- import { SignAuthorizationReturnType } from "viem/_types/accounts/utils/signAuthorization";
3
- import { AuthorizationListEntryAny } from "../types";
4
- export declare const encodeRLPAuthorizationEntryUnsigned: (chainId: number, address: any, nonce: bigint) => string;
5
- export declare const getAuthorizationList: (chainId: number, nonce: bigint, authorizer: string, signer: ethers.Wallet | ethers.VoidSigner) => Promise<AuthorizationListEntryAny[]>;
6
- export declare const getSignedTransaction: (provider: ethers.Provider, relayer: ethers.SigningKey, authorizationList: SignAuthorizationReturnType | AuthorizationListEntryAny[], to?: string, value?: bigint | number, data?: string, nonce?: number) => Promise<string>;
7
- export declare const serializeEip7702: (tx: any, _sig: null | ethers.Signature) => string;
8
- export declare const ACCOUNT_CODE_PREFIX = "0xef0100";
9
- export declare const isAccountDelegatedToAddress: (provider: ethers.Provider, account: string, authority: string) => Promise<boolean>;
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAccountDelegatedToAddress = exports.ACCOUNT_CODE_PREFIX = exports.serializeEip7702 = exports.getSignedTransaction = exports.getAuthorizationList = exports.encodeRLPAuthorizationEntryUnsigned = void 0;
4
- const ethers_1 = require("ethers");
5
- const formatNumber = (_value) => {
6
- const value = typeof _value === "bigint" ? _value : BigInt(_value);
7
- // Convert bigint to hex string, then to bytes for RLP encoding
8
- const hexValue = ethers_1.ethers.toBeHex(value);
9
- return ethers_1.ethers.getBytes(hexValue);
10
- };
11
- const encodeRLPAuthorizationEntryUnsigned = (chainId, address, nonce) => {
12
- // MAGIC = "0x05" defined in ERC-7702
13
- return ethers_1.ethers.concat([
14
- "0x05",
15
- ethers_1.ethers.encodeRlp([formatNumber(chainId), address, formatNumber(nonce)]),
16
- ]);
17
- };
18
- exports.encodeRLPAuthorizationEntryUnsigned = encodeRLPAuthorizationEntryUnsigned;
19
- const getAuthorizationList = async (chainId, nonce, authorizer, signer) => {
20
- const dataToSign = (0, exports.encodeRLPAuthorizationEntryUnsigned)(chainId, authorizer, nonce);
21
- const authHash = ethers_1.ethers.keccak256(dataToSign);
22
- // TODO: should be signDigest
23
- const sig = await signer.signMessage(authHash);
24
- // In ethers v6, splitSignature is removed, we need to parse manually
25
- const sigBytes = ethers_1.ethers.getBytes(sig);
26
- const r = ethers_1.ethers.hexlify(sigBytes.slice(0, 32));
27
- const s = ethers_1.ethers.hexlify(sigBytes.slice(32, 64));
28
- const v = sigBytes[64];
29
- const yParity = v - 27;
30
- return [
31
- {
32
- chainId: chainId,
33
- address: authorizer,
34
- nonce: nonce,
35
- yParity: yParity,
36
- r: r,
37
- s: s,
38
- },
39
- ];
40
- };
41
- exports.getAuthorizationList = getAuthorizationList;
42
- const getSignedTransaction = async (provider, relayer, authorizationList, to = ethers_1.ethers.ZeroAddress, value = 0, data = "0x", nonce) => {
43
- const relayerAddress = ethers_1.ethers.computeAddress(relayer.publicKey);
44
- const relayerNonce = nonce || (await provider.getTransactionCount(relayerAddress));
45
- const valueBigInt = typeof value === "bigint" ? value : BigInt(value);
46
- const tx = {
47
- from: relayerAddress,
48
- nonce: relayerNonce,
49
- gasLimit: 21000000,
50
- gasPrice: 3100,
51
- data: data,
52
- to: to,
53
- value: valueBigInt,
54
- chainId: (await provider.getNetwork()).chainId,
55
- type: 4,
56
- maxFeePerGas: 30000,
57
- maxPriorityFeePerGas: 30000,
58
- accessList: [],
59
- authorizationList: authorizationList,
60
- };
61
- const encodedTx = (0, exports.serializeEip7702)(tx, null);
62
- const txHashToSign = ethers_1.ethers.keccak256(encodedTx);
63
- const signature = relayer.sign(txHashToSign);
64
- return (0, exports.serializeEip7702)(tx, signature);
65
- };
66
- exports.getSignedTransaction = getSignedTransaction;
67
- const serializeEip7702 = (tx, _sig) => {
68
- const fields = [
69
- formatNumber(tx.chainId),
70
- formatNumber(tx.nonce),
71
- formatNumber(tx.maxPriorityFeePerGas || 0),
72
- formatNumber(tx.maxFeePerGas || 0),
73
- formatNumber(tx.gasLimit),
74
- tx.to,
75
- formatNumber(tx.value),
76
- tx.data,
77
- formatAccessList(tx.accessList || []),
78
- formatAuthorizationList(tx.authorizationList || []),
79
- ];
80
- if (_sig) {
81
- // In ethers v6, Signature object has r, s, v properties
82
- const yParity = _sig.v - 27;
83
- fields.push(formatNumber(yParity));
84
- fields.push(ethers_1.ethers.getBytes(_sig.r));
85
- fields.push(ethers_1.ethers.getBytes(_sig.s));
86
- }
87
- return ethers_1.ethers.concat(["0x04", ethers_1.ethers.encodeRlp(fields)]);
88
- };
89
- exports.serializeEip7702 = serializeEip7702;
90
- const formatAccessList = (value) => {
91
- return ethers_1.ethers
92
- .accessListify(value)
93
- .map((set) => [set.address, set.storageKeys]);
94
- };
95
- const formatAuthorizationList = (value) => {
96
- return value.map((set) => formatAuthorizationEntry(set));
97
- };
98
- const formatAuthorizationEntry = (set) => {
99
- return [
100
- formatNumber(set.chainId),
101
- set.address,
102
- formatNumber(set.nonce),
103
- formatNumber(set.yParity),
104
- ethers_1.ethers.getBytes(set.r),
105
- ethers_1.ethers.getBytes(set.s),
106
- ];
107
- };
108
- exports.ACCOUNT_CODE_PREFIX = "0xef0100";
109
- const isAccountDelegatedToAddress = async (provider, account, authority) => {
110
- const codeAtEOA = await provider.getCode(account);
111
- return (codeAtEOA.length === 48 &&
112
- codeAtEOA.startsWith(exports.ACCOUNT_CODE_PREFIX) &&
113
- ethers_1.ethers.getAddress("0x" + codeAtEOA.slice(8)) === authority);
114
- };
115
- exports.isAccountDelegatedToAddress = isAccountDelegatedToAddress;
@@ -1,2 +0,0 @@
1
- declare const _default: "[\n {\n \"type\": \"function\",\n \"name\": \"addIntentWithSignatureAndExecute\",\n \"inputs\": [\n { \"name\": \"user\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"dispatcher\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"params\", \"type\": \"bytes\", \"internalType\": \"bytes\" },\n { \"name\": \"signature\", \"type\": \"bytes\", \"internalType\": \"bytes\" },\n {\n \"name\": \"executions\",\n \"type\": \"tuple[]\",\n \"internalType\": \"struct Execution[]\",\n \"components\": [\n { \"name\": \"target\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"value\", \"type\": \"uint256\", \"internalType\": \"uint256\" },\n { \"name\": \"callData\", \"type\": \"bytes\", \"internalType\": \"bytes\" }\n ]\n },\n {\n \"name\": \"callType\",\n \"type\": \"uint8\",\n \"internalType\": \"enum Enum.Operation\"\n },\n {\n \"name\": \"intermediaryApprovals\",\n \"type\": \"tuple[]\",\n \"internalType\": \"struct IntentRegistry.Approval[]\",\n \"components\": [\n {\n \"name\": \"tokenAddress\",\n \"type\": \"address\",\n \"internalType\": \"address\"\n },\n {\n \"name\": \"spenderAddress\",\n \"type\": \"address\",\n \"internalType\": \"address\"\n },\n { \"name\": \"amount\", \"type\": \"uint256\", \"internalType\": \"uint256\" },\n { \"name\": \"chainId\", \"type\": \"uint256\", \"internalType\": \"uint256\" }\n ]\n }\n ],\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\"\n },\n {\n \"type\": \"function\",\n \"name\": \"approvalsMapping\",\n \"inputs\": [\n { \"name\": \"\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"\", \"type\": \"uint256\", \"internalType\": \"uint256\" },\n { \"name\": \"\", \"type\": \"address\", \"internalType\": \"address\" }\n ],\n \"outputs\": [{ \"name\": \"\", \"type\": \"bool\", \"internalType\": \"bool\" }],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"executeEscrowTransfer\",\n \"inputs\": [\n { \"name\": \"user\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"intentIndex\", \"type\": \"uint256\", \"internalType\": \"uint256\" }\n ],\n \"outputs\": [{ \"name\": \"success\", \"type\": \"bool\", \"internalType\": \"bool\" }],\n \"stateMutability\": \"nonpayable\"\n },\n {\n \"type\": \"function\",\n \"name\": \"executeIntent\",\n \"inputs\": [\n { \"name\": \"user\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"_nonce\", \"type\": \"uint256\", \"internalType\": \"uint256\" },\n { \"name\": \"dispatcher\", \"type\": \"address\", \"internalType\": \"address\" },\n {\n \"name\": \"executions\",\n \"type\": \"tuple[]\",\n \"internalType\": \"struct Execution[]\",\n \"components\": [\n { \"name\": \"target\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"value\", \"type\": \"uint256\", \"internalType\": \"uint256\" },\n { \"name\": \"callData\", \"type\": \"bytes\", \"internalType\": \"bytes\" }\n ]\n },\n {\n \"name\": \"callType\",\n \"type\": \"uint8\",\n \"internalType\": \"enum Enum.Operation\"\n },\n {\n \"name\": \"intermediaryApprovals\",\n \"type\": \"tuple[]\",\n \"internalType\": \"struct IntentRegistry.Approval[]\",\n \"components\": [\n {\n \"name\": \"tokenAddress\",\n \"type\": \"address\",\n \"internalType\": \"address\"\n },\n {\n \"name\": \"spenderAddress\",\n \"type\": \"address\",\n \"internalType\": \"address\"\n },\n { \"name\": \"amount\", \"type\": \"uint256\", \"internalType\": \"uint256\" },\n { \"name\": \"chainId\", \"type\": \"uint256\", \"internalType\": \"uint256\" }\n ]\n }\n ],\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\"\n },\n {\n \"type\": \"function\",\n \"name\": \"intentRegistry\",\n \"inputs\": [],\n \"outputs\": [{ \"name\": \"\", \"type\": \"address\", \"internalType\": \"address\" }],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"isInitialized\",\n \"inputs\": [{ \"name\": \"\", \"type\": \"address\", \"internalType\": \"address\" }],\n \"outputs\": [{ \"name\": \"\", \"type\": \"bool\", \"internalType\": \"bool\" }],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"isModuleType\",\n \"inputs\": [\n { \"name\": \"typeID\", \"type\": \"uint256\", \"internalType\": \"uint256\" }\n ],\n \"outputs\": [{ \"name\": \"\", \"type\": \"bool\", \"internalType\": \"bool\" }],\n \"stateMutability\": \"pure\"\n },\n {\n \"type\": \"function\",\n \"name\": \"onInstall\",\n \"inputs\": [{ \"name\": \"data\", \"type\": \"bytes\", \"internalType\": \"bytes\" }],\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\"\n },\n {\n \"type\": \"function\",\n \"name\": \"onUninstall\",\n \"inputs\": [{ \"name\": \"data\", \"type\": \"bytes\", \"internalType\": \"bytes\" }],\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\"\n },\n {\n \"type\": \"function\",\n \"name\": \"setIntentRegistry\",\n \"inputs\": [\n {\n \"name\": \"_intentRegistry\",\n \"type\": \"address\",\n \"internalType\": \"address\"\n }\n ],\n \"outputs\": [],\n \"stateMutability\": \"nonpayable\"\n },\n {\n \"type\": \"function\",\n \"name\": \"userApprovalsMapping\",\n \"inputs\": [\n { \"name\": \"\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"\", \"type\": \"uint256\", \"internalType\": \"uint256\" },\n { \"name\": \"\", \"type\": \"address\", \"internalType\": \"address\" }\n ],\n \"outputs\": [{ \"name\": \"\", \"type\": \"bool\", \"internalType\": \"bool\" }],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"verifySignature\",\n \"inputs\": [\n { \"name\": \"sender\", \"type\": \"address\", \"internalType\": \"address\" },\n { \"name\": \"data\", \"type\": \"bytes\", \"internalType\": \"bytes\" },\n { \"name\": \"signature\", \"type\": \"bytes\", \"internalType\": \"bytes\" }\n ],\n \"outputs\": [],\n \"stateMutability\": \"view\"\n },\n {\n \"type\": \"event\",\n \"name\": \"TaskCompleted\",\n \"inputs\": [\n {\n \"name\": \"user\",\n \"type\": \"address\",\n \"indexed\": true,\n \"internalType\": \"address\"\n },\n {\n \"name\": \"intentIndex\",\n \"type\": \"uint256\",\n \"indexed\": false,\n \"internalType\": \"uint256\"\n },\n {\n \"name\": \"solver\",\n \"type\": \"address\",\n \"indexed\": false,\n \"internalType\": \"address\"\n }\n ],\n \"anonymous\": false\n },\n {\n \"type\": \"error\",\n \"name\": \"AlreadyInitialized\",\n \"inputs\": [\n { \"name\": \"smartAccount\", \"type\": \"address\", \"internalType\": \"address\" }\n ]\n },\n { \"type\": \"error\", \"name\": \"BalanceDecreasedAfterExecution\", \"inputs\": [] },\n { \"type\": \"error\", \"name\": \"DeadlinePassed\", \"inputs\": [] },\n { \"type\": \"error\", \"name\": \"NotAllowedToExecuteIntent\", \"inputs\": [] },\n { \"type\": \"error\", \"name\": \"NotAllowedToUseToken\", \"inputs\": [] },\n {\n \"type\": \"error\",\n \"name\": \"NotInitialized\",\n \"inputs\": [\n { \"name\": \"smartAccount\", \"type\": \"address\", \"internalType\": \"address\" }\n ]\n },\n { \"type\": \"error\", \"name\": \"TaskCompleted\", \"inputs\": [] }\n]\n";
2
- export default _default;