@bronlabs/intents-sdk 1.0.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/README.md +114 -0
- package/abi/OracleAggregator.json +219 -0
- package/abi/OrderEngine.json +499 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/contracts.d.ts +3 -0
- package/dist/contracts.js +8 -0
- package/dist/contracts.js.map +1 -0
- package/dist/eventQueue.d.ts +9 -0
- package/dist/eventQueue.js +21 -0
- package/dist/eventQueue.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/networks/evm.d.ts +13 -0
- package/dist/networks/evm.js +95 -0
- package/dist/networks/evm.js.map +1 -0
- package/dist/networks/index.d.ts +14 -0
- package/dist/networks/index.js +2 -0
- package/dist/networks/index.js.map +1 -0
- package/dist/orderIndexer.d.ts +28 -0
- package/dist/orderIndexer.js +122 -0
- package/dist/orderIndexer.js.map +1 -0
- package/dist/orderProcessor.d.ts +14 -0
- package/dist/orderProcessor.js +35 -0
- package/dist/orderProcessor.js.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +9 -0
- package/dist/utils.js.map +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @bron/intents-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for building Intents DeFi applications with order indexing, processing, and smart contract interactions.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @bron/intents-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Core Components
|
|
12
|
+
|
|
13
|
+
### OrderIndexer
|
|
14
|
+
|
|
15
|
+
Monitors blockchain events and indexes order status changes.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { OrderIndexer, IntentsConfig } from '@bron/intents-sdk';
|
|
19
|
+
|
|
20
|
+
const config: IntentsConfig = {
|
|
21
|
+
rpcUrl: 'https://your-rpc-url',
|
|
22
|
+
orderEngineAddress: '0x...',
|
|
23
|
+
startBlockOffset: 100,
|
|
24
|
+
pollingInterval: 5000,
|
|
25
|
+
maxRetries: 3,
|
|
26
|
+
retryDelay: 1000,
|
|
27
|
+
networks: {}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const indexer = new OrderIndexer(config);
|
|
31
|
+
|
|
32
|
+
indexer.addProcessor(async (event) => {
|
|
33
|
+
console.log(`Order ${event.data.orderId} status: ${event.data.status}`);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await indexer.start();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### OrderProcessor (Abstract)
|
|
40
|
+
|
|
41
|
+
Base class for implementing custom order processing logic.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { OrderProcessor } from '@bron/intents-sdk';
|
|
45
|
+
|
|
46
|
+
class CustomOrderProcessor extends OrderProcessor {
|
|
47
|
+
async process(orderId: string, status: string): Promise<void> {
|
|
48
|
+
// Implement your processing logic
|
|
49
|
+
console.log(`Processing order ${orderId} with status ${status}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const processor = new CustomOrderProcessor();
|
|
54
|
+
await processor.stop();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Network Configuration
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { NetworkConfig, IntentsConfig } from '@bron/intents-sdk';
|
|
61
|
+
|
|
62
|
+
const config: IntentsConfig = {
|
|
63
|
+
rpcUrl: 'https://mainnet.infura.io/v3/your-key',
|
|
64
|
+
orderEngineAddress: '0x123...',
|
|
65
|
+
startBlockOffset: 0,
|
|
66
|
+
pollingInterval: 10000,
|
|
67
|
+
maxRetries: 5,
|
|
68
|
+
retryDelay: 2000,
|
|
69
|
+
networks: {
|
|
70
|
+
ethereum: {
|
|
71
|
+
rpcUrl: 'https://mainnet.infura.io/v3/your-key',
|
|
72
|
+
walletAddress: '0x456...',
|
|
73
|
+
walletPrivateKey: 'your-private-key'
|
|
74
|
+
},
|
|
75
|
+
polygon: {
|
|
76
|
+
rpcUrl: 'https://polygon-rpc.com',
|
|
77
|
+
walletAddress: '0x789...'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Configuration Schema
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
interface IntentsConfig {
|
|
87
|
+
rpcUrl: string;
|
|
88
|
+
orderEngineAddress: string;
|
|
89
|
+
oracleAggregatorAddress?: string;
|
|
90
|
+
oraclePrivateKey?: string;
|
|
91
|
+
solverPrivateKey?: string;
|
|
92
|
+
startBlockOffset: number;
|
|
93
|
+
pollingInterval: number;
|
|
94
|
+
maxRetries: number;
|
|
95
|
+
retryDelay: number;
|
|
96
|
+
networks: {
|
|
97
|
+
[key: string]: NetworkConfig;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface NetworkConfig {
|
|
102
|
+
rpcUrl: string;
|
|
103
|
+
walletAddress?: string;
|
|
104
|
+
walletPrivateKey?: string;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Error Handling
|
|
109
|
+
|
|
110
|
+
The SDK includes built-in retry mechanisms and error handling:
|
|
111
|
+
|
|
112
|
+
- Events are retried up to `maxRetries` times
|
|
113
|
+
- Failed events are logged and can be monitored
|
|
114
|
+
- Graceful shutdown ensures all queued events are processed
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [],
|
|
4
|
+
"name": "OA_ONLY_ORACLE_OR_OWNER",
|
|
5
|
+
"type": "error"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"inputs": [],
|
|
9
|
+
"name": "OA_ORACLE_ALREADY_INACTIVE",
|
|
10
|
+
"type": "error"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"inputs": [],
|
|
14
|
+
"name": "OA_ORACLE_ALREADY_REGISTERED",
|
|
15
|
+
"type": "error"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"inputs": [],
|
|
19
|
+
"name": "OA_ORACLE_NOT_ACTIVE",
|
|
20
|
+
"type": "error"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"inputs": [],
|
|
24
|
+
"name": "OA_ORACLE_NOT_PENDING",
|
|
25
|
+
"type": "error"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"anonymous": false,
|
|
29
|
+
"inputs": [
|
|
30
|
+
{
|
|
31
|
+
"indexed": false,
|
|
32
|
+
"internalType": "uint8",
|
|
33
|
+
"name": "version",
|
|
34
|
+
"type": "uint8"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"name": "Initialized",
|
|
38
|
+
"type": "event"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"anonymous": false,
|
|
42
|
+
"inputs": [
|
|
43
|
+
{
|
|
44
|
+
"indexed": true,
|
|
45
|
+
"internalType": "address",
|
|
46
|
+
"name": "previousOwner",
|
|
47
|
+
"type": "address"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"indexed": true,
|
|
51
|
+
"internalType": "address",
|
|
52
|
+
"name": "newOwner",
|
|
53
|
+
"type": "address"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"name": "OwnershipTransferred",
|
|
57
|
+
"type": "event"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"inputs": [
|
|
61
|
+
{
|
|
62
|
+
"internalType": "address",
|
|
63
|
+
"name": "_oracle",
|
|
64
|
+
"type": "address"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"name": "activateOracle",
|
|
68
|
+
"outputs": [],
|
|
69
|
+
"stateMutability": "nonpayable",
|
|
70
|
+
"type": "function"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"inputs": [
|
|
74
|
+
{
|
|
75
|
+
"internalType": "address",
|
|
76
|
+
"name": "_oracle",
|
|
77
|
+
"type": "address"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"name": "deactivateOracle",
|
|
81
|
+
"outputs": [],
|
|
82
|
+
"stateMutability": "nonpayable",
|
|
83
|
+
"type": "function"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"inputs": [
|
|
87
|
+
{
|
|
88
|
+
"internalType": "contract IOrderEngine",
|
|
89
|
+
"name": "_orderEngine",
|
|
90
|
+
"type": "address"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"name": "initialize",
|
|
94
|
+
"outputs": [],
|
|
95
|
+
"stateMutability": "nonpayable",
|
|
96
|
+
"type": "function"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"inputs": [
|
|
100
|
+
{
|
|
101
|
+
"internalType": "string",
|
|
102
|
+
"name": "_orderId",
|
|
103
|
+
"type": "string"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"internalType": "bool",
|
|
107
|
+
"name": "_isConfirmed",
|
|
108
|
+
"type": "bool"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"name": "oracleConfirmSolverTx",
|
|
112
|
+
"outputs": [],
|
|
113
|
+
"stateMutability": "nonpayable",
|
|
114
|
+
"type": "function"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"inputs": [
|
|
118
|
+
{
|
|
119
|
+
"internalType": "string",
|
|
120
|
+
"name": "_orderId",
|
|
121
|
+
"type": "string"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"internalType": "bool",
|
|
125
|
+
"name": "_isConfirmed",
|
|
126
|
+
"type": "bool"
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"name": "oracleConfirmUserTx",
|
|
130
|
+
"outputs": [],
|
|
131
|
+
"stateMutability": "nonpayable",
|
|
132
|
+
"type": "function"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"inputs": [
|
|
136
|
+
{
|
|
137
|
+
"internalType": "address",
|
|
138
|
+
"name": "",
|
|
139
|
+
"type": "address"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"name": "oracles",
|
|
143
|
+
"outputs": [
|
|
144
|
+
{
|
|
145
|
+
"internalType": "enum OracleAggregatorStorage.OracleStatus",
|
|
146
|
+
"name": "",
|
|
147
|
+
"type": "uint8"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"stateMutability": "view",
|
|
151
|
+
"type": "function"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"inputs": [],
|
|
155
|
+
"name": "orderEngine",
|
|
156
|
+
"outputs": [
|
|
157
|
+
{
|
|
158
|
+
"internalType": "contract IOrderEngine",
|
|
159
|
+
"name": "",
|
|
160
|
+
"type": "address"
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"stateMutability": "view",
|
|
164
|
+
"type": "function"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"inputs": [],
|
|
168
|
+
"name": "owner",
|
|
169
|
+
"outputs": [
|
|
170
|
+
{
|
|
171
|
+
"internalType": "address",
|
|
172
|
+
"name": "",
|
|
173
|
+
"type": "address"
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"stateMutability": "view",
|
|
177
|
+
"type": "function"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"inputs": [],
|
|
181
|
+
"name": "registerOracle",
|
|
182
|
+
"outputs": [],
|
|
183
|
+
"stateMutability": "nonpayable",
|
|
184
|
+
"type": "function"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"inputs": [],
|
|
188
|
+
"name": "renounceOwnership",
|
|
189
|
+
"outputs": [],
|
|
190
|
+
"stateMutability": "nonpayable",
|
|
191
|
+
"type": "function"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"inputs": [
|
|
195
|
+
{
|
|
196
|
+
"internalType": "contract IOrderEngine",
|
|
197
|
+
"name": "_orderEngine",
|
|
198
|
+
"type": "address"
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"name": "setOrderEngine",
|
|
202
|
+
"outputs": [],
|
|
203
|
+
"stateMutability": "nonpayable",
|
|
204
|
+
"type": "function"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"inputs": [
|
|
208
|
+
{
|
|
209
|
+
"internalType": "address",
|
|
210
|
+
"name": "newOwner",
|
|
211
|
+
"type": "address"
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"name": "transferOwnership",
|
|
215
|
+
"outputs": [],
|
|
216
|
+
"stateMutability": "nonpayable",
|
|
217
|
+
"type": "function"
|
|
218
|
+
}
|
|
219
|
+
]
|