@firefly-dao/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/LICENSE +16 -0
- package/README.md +265 -0
- package/_cjs/package.json +1 -0
- package/_cjs/src/api/index.js +29 -0
- package/_cjs/src/api/index.js.map +1 -0
- package/_cjs/src/client/client.js +180 -0
- package/_cjs/src/client/client.js.map +1 -0
- package/_cjs/src/constants/index.js +11 -0
- package/_cjs/src/constants/index.js.map +1 -0
- package/_cjs/src/index.js +6 -0
- package/_cjs/src/index.js.map +1 -0
- package/_cjs/src/test.js +35 -0
- package/_cjs/src/test.js.map +1 -0
- package/_cjs/src/types/Execute.js +3 -0
- package/_cjs/src/types/Execute.js.map +1 -0
- package/_cjs/src/types/index.js +5 -0
- package/_cjs/src/types/index.js.map +1 -0
- package/_cjs/src/utils/axios.js +18 -0
- package/_cjs/src/utils/axios.js.map +1 -0
- package/_cjs/src/utils/index.js +48 -0
- package/_cjs/src/utils/index.js.map +1 -0
- package/_cjs/src/utils/log.js +2 -0
- package/_cjs/src/utils/log.js.map +1 -0
- package/_cjs/src/utils/request.js +55 -0
- package/_cjs/src/utils/request.js.map +1 -0
- package/_cjs/tsconfig.build.tsbuildinfo +1 -0
- package/_esm/package.json +1 -0
- package/_esm/src/api/index.js +22 -0
- package/_esm/src/api/index.js.map +1 -0
- package/_esm/src/client/client.js +179 -0
- package/_esm/src/client/client.js.map +1 -0
- package/_esm/src/constants/index.js +8 -0
- package/_esm/src/constants/index.js.map +1 -0
- package/_esm/src/index.js +3 -0
- package/_esm/src/index.js.map +1 -0
- package/_esm/src/test.js +33 -0
- package/_esm/src/test.js.map +1 -0
- package/_esm/src/types/Execute.js +2 -0
- package/_esm/src/types/Execute.js.map +1 -0
- package/_esm/src/types/index.js +2 -0
- package/_esm/src/types/index.js.map +1 -0
- package/_esm/src/utils/axios.js +15 -0
- package/_esm/src/utils/axios.js.map +1 -0
- package/_esm/src/utils/index.js +45 -0
- package/_esm/src/utils/index.js.map +1 -0
- package/_esm/src/utils/log.js +2 -0
- package/_esm/src/utils/log.js.map +1 -0
- package/_esm/src/utils/request.js +49 -0
- package/_esm/src/utils/request.js.map +1 -0
- package/_esm/tsconfig.build.tsbuildinfo +1 -0
- package/_types/src/api/index.d.ts +9 -0
- package/_types/src/api/index.d.ts.map +1 -0
- package/_types/src/client/client.d.ts +33 -0
- package/_types/src/client/client.d.ts.map +1 -0
- package/_types/src/constants/index.d.ts +7 -0
- package/_types/src/constants/index.d.ts.map +1 -0
- package/_types/src/index.d.ts +3 -0
- package/_types/src/index.d.ts.map +1 -0
- package/_types/src/test.d.ts +2 -0
- package/_types/src/test.d.ts.map +1 -0
- package/_types/src/types/Execute.d.ts +107 -0
- package/_types/src/types/Execute.d.ts.map +1 -0
- package/_types/src/types/index.d.ts +3 -0
- package/_types/src/types/index.d.ts.map +1 -0
- package/_types/src/utils/axios.d.ts +2 -0
- package/_types/src/utils/axios.d.ts.map +1 -0
- package/_types/src/utils/index.d.ts +5 -0
- package/_types/src/utils/index.d.ts.map +1 -0
- package/_types/src/utils/log.d.ts +1 -0
- package/_types/src/utils/log.d.ts.map +1 -0
- package/_types/src/utils/request.d.ts +12 -0
- package/_types/src/utils/request.d.ts.map +1 -0
- package/_types/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Firefly Labs
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# Firefly-SDK
|
|
2
|
+
|
|
3
|
+
Firefly Labs: The ultimate gateway for lightning-fast, cost-effective cross-chain maneuvers.
|
|
4
|
+
|
|
5
|
+
This SDK simplifies how you interact with the Firefly protocol. To get started, browse our <a href="https://docs.fireflylabs.app/developer">docs</a>. For technical setup and configuration, visit the <a href="https://docs.fireflylabs.app/developer">sdk docs</a> to accelerate your build process.
|
|
6
|
+
<br/>
|
|
7
|
+
<br/>
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
You can use the following ways to get the latest version of Firefly SDK:
|
|
12
|
+
|
|
13
|
+
**npm**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @firefly-dao/firefly-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**yarn**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add @firefly-dao/firefly-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**pnpm**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add @firefly-dao/firefly-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### Set up the SDK
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import {
|
|
37
|
+
FireflyClient,
|
|
38
|
+
MAINNET_FIREFLY_API,
|
|
39
|
+
TESTNET_FIREFLY_API,
|
|
40
|
+
LogLevel,
|
|
41
|
+
} from "@firefly-dao/firefly-sdk";
|
|
42
|
+
|
|
43
|
+
const client = new FireflyClient({
|
|
44
|
+
baseApiUrl: MAINNET_FIREFLY_API, // or TESTNET_FIREFLY_API
|
|
45
|
+
referrer: "firefly-sdk", // optional, default: 'firefly-sdk'
|
|
46
|
+
logLevel: LogLevel.Info, // optional, default: LogLevel.Info
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Get a Quote
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const quote = await client.getQuote({
|
|
54
|
+
fromChainId: 8453,
|
|
55
|
+
fromTokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
|
|
56
|
+
toChainId: 10,
|
|
57
|
+
toTokenAddress: "0x0000000000000000000000000000000000000000", // USDC
|
|
58
|
+
amount: "2000000", // 1 USDC (6 decimals)
|
|
59
|
+
recipient: "0x...", // destination address
|
|
60
|
+
sender: "0x...", // optional, source address
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Quote contains:
|
|
64
|
+
// - steps: Transaction steps (approve, deposit)
|
|
65
|
+
// - fees: Fee breakdown (gas, service fees)
|
|
66
|
+
// - details: Rate, impact, time estimate, currencies info
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Execute the Transfer
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { createWalletClient, http } from "viem";
|
|
73
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
74
|
+
import { base } from "viem/chains";
|
|
75
|
+
|
|
76
|
+
// Connect wallet
|
|
77
|
+
const wallet = createWalletClient({
|
|
78
|
+
chain: base,
|
|
79
|
+
transport: http(),
|
|
80
|
+
account: privateKeyToAccount(`0x`),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Execute with progress tracking
|
|
84
|
+
const result = await client.execute({
|
|
85
|
+
quote,
|
|
86
|
+
wallet,
|
|
87
|
+
onProgress: (info) => {
|
|
88
|
+
console.log(`Step: ${info.step}`);
|
|
89
|
+
console.log(`Status: ${info.status}`);
|
|
90
|
+
|
|
91
|
+
if (info.status === "success") {
|
|
92
|
+
console.log(`Transaction hash: ${info.hash}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (info.status === "failed") {
|
|
96
|
+
console.error(`Error: ${info.error}`);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (result.status === "success") {
|
|
102
|
+
console.log("✅ Cross-chain transfer completed!");
|
|
103
|
+
} else {
|
|
104
|
+
console.error(`❌ Transfer failed: ${result.message}`);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 📖 API Reference
|
|
109
|
+
|
|
110
|
+
### FireflyClient Constructor
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
new FireflyClient(options: FireflyClientOptions)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Parameters:**
|
|
117
|
+
|
|
118
|
+
| Parameter | Type | Required | Default | Description |
|
|
119
|
+
| ------------ | ---------- | -------- | --------------- | ------------------------------------------------------------- |
|
|
120
|
+
| `baseApiUrl` | `string` | Yes | - | API endpoint (`MAINNET_FIREFLY_API` or `TESTNET_FIREFLY_API`) |
|
|
121
|
+
| `referrer` | `string` | No | `'firefly-sdk'` | Application identifier for tracking |
|
|
122
|
+
| `logLevel` | `LogLevel` | No | `LogLevel.Info` | Logging level (`Info` or `Silent`) |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### getQuote()
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
async getQuote(parameters: GetQuoteParameters): Promise<Execute>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Fetches a quote for cross-chain token transfer.
|
|
133
|
+
|
|
134
|
+
**Parameters:**
|
|
135
|
+
|
|
136
|
+
| Parameter | Type | Required | Description |
|
|
137
|
+
| ------------------- | -------- | -------- | ---------------------------------- |
|
|
138
|
+
| `fromChainId` | `number` | Yes | Source chain ID |
|
|
139
|
+
| `fromTokenAddress` | `string` | Yes | Source token contract address |
|
|
140
|
+
| `toChainId` | `number` | Yes | Destination chain ID |
|
|
141
|
+
| `toTokenAddress` | `string` | Yes | Destination token contract address |
|
|
142
|
+
| `amount` | `string` | Yes | Amount in smallest unit |
|
|
143
|
+
| `recipient` | `string` | Yes | Recipient address |
|
|
144
|
+
| `sender` | `string` | No | Sender address |
|
|
145
|
+
| `referrer` | `string` | No | Referrer |
|
|
146
|
+
| `slippageTolerance` | `string` | No | Cross-chain slip pointID |
|
|
147
|
+
|
|
148
|
+
**Returns:**
|
|
149
|
+
|
|
150
|
+
`Execute` object containing:
|
|
151
|
+
|
|
152
|
+
- `steps`: Array of transaction steps
|
|
153
|
+
- `fees`: Fee breakdown (gas, service fees)
|
|
154
|
+
- `details`: Transfer details (currencies, rate, impact, time estimate)
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### execute()
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
async execute(options: ExecuteOptions): Promise<ExecuteResponse>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Executes the cross-chain transfer.
|
|
165
|
+
|
|
166
|
+
**Parameters:**
|
|
167
|
+
|
|
168
|
+
| Parameter | Type | Required | Description |
|
|
169
|
+
| ------------ | ------------------------- | -------- | -------------------------- |
|
|
170
|
+
| `quote` | `Execute` | Yes | Quote from `getQuote()` |
|
|
171
|
+
| `wallet` | `WalletClient` | Yes | Viem wallet client |
|
|
172
|
+
| `onProgress` | `ExecuteProgressCallback` | No | Progress callback function |
|
|
173
|
+
|
|
174
|
+
**Progress Callback:**
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
interface ExecuteProgressInfo {
|
|
178
|
+
step: "approve" | "deposit";
|
|
179
|
+
status: "success" | "failed";
|
|
180
|
+
hash?: string;
|
|
181
|
+
error?: any;
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Returns:**
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
interface ExecuteResponse {
|
|
189
|
+
status: "idle" | "failed" | "success";
|
|
190
|
+
message: string;
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Complete Example
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
import {
|
|
198
|
+
FireflyClient,
|
|
199
|
+
MAINNET_FIREFLY_API,
|
|
200
|
+
LogLevel,
|
|
201
|
+
} from "@firefly-dao/firefly-sdk";
|
|
202
|
+
import { createWalletClient } from "viem";
|
|
203
|
+
import { base } from "viem/chains";
|
|
204
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
205
|
+
|
|
206
|
+
async function main() {
|
|
207
|
+
// 1. Initialize client
|
|
208
|
+
const client = new FireflyClient({
|
|
209
|
+
baseApiUrl: MAINNET_FIREFLY_API,
|
|
210
|
+
referrer: "my-dapp",
|
|
211
|
+
logLevel: LogLevel.Info,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// 2. Setup wallet
|
|
215
|
+
const wallet = createWalletClient({
|
|
216
|
+
chain: base,
|
|
217
|
+
transport: http(),
|
|
218
|
+
account: privateKeyToAccount(`0x`),
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
try {
|
|
222
|
+
// 3. Get quote
|
|
223
|
+
console.log("Getting quote...");
|
|
224
|
+
const quote = await client.getQuote({
|
|
225
|
+
fromChainId: 8453, // Base Mainnet
|
|
226
|
+
fromTokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
|
|
227
|
+
toChainId: 10, // Optimism Mainnet
|
|
228
|
+
toTokenAddress: "0x0000000000000000000000000000000000000000", // Optimism USDC
|
|
229
|
+
amount: "2000000", // 2 USDC (6 decimals)
|
|
230
|
+
recipient: "0x...", // destination address
|
|
231
|
+
sender: "0x...", // optional, source address
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
console.log("Quote result:", quote);
|
|
235
|
+
|
|
236
|
+
// 4. Execute transfer
|
|
237
|
+
console.log("Executing transfer...");
|
|
238
|
+
const result = await client.execute({
|
|
239
|
+
quote,
|
|
240
|
+
wallet,
|
|
241
|
+
onProgress: (info) => {
|
|
242
|
+
if (info.step === "approve") {
|
|
243
|
+
console.log("Approval:", info.status);
|
|
244
|
+
} else if (info.step === "deposit") {
|
|
245
|
+
console.log("Deposit:", info.status);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (info.hash) {
|
|
249
|
+
console.log("Transaction:", info.hash);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
if (result.status === "success") {
|
|
255
|
+
console.log("Transfer completed successfully!");
|
|
256
|
+
} else {
|
|
257
|
+
console.error("Transfer failed:", result.message);
|
|
258
|
+
}
|
|
259
|
+
} catch (error) {
|
|
260
|
+
console.error("Error:", error);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
main();
|
|
265
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSwapTransferStatusAPI = getSwapTransferStatusAPI;
|
|
4
|
+
exports.actionReportApi = actionReportApi;
|
|
5
|
+
exports.getChainsApi = getChainsApi;
|
|
6
|
+
exports.getTokensApi = getTokensApi;
|
|
7
|
+
exports.postSpeedActionApi = postSpeedActionApi;
|
|
8
|
+
const axios_1 = require("../utils/axios");
|
|
9
|
+
function getSwapTransferStatusAPI({ chainId, hash }) {
|
|
10
|
+
return axios_1.axios.get('https://api.fireflylabs.app/quote/transaction', {
|
|
11
|
+
params: {
|
|
12
|
+
chainId,
|
|
13
|
+
hash,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function actionReportApi(action) {
|
|
18
|
+
return axios_1.axios.post('https://api.fireflylabs.app/action', action);
|
|
19
|
+
}
|
|
20
|
+
function getChainsApi() {
|
|
21
|
+
return axios_1.axios.get('https://api.fireflylabs.app/quote/chains');
|
|
22
|
+
}
|
|
23
|
+
function getTokensApi() {
|
|
24
|
+
return axios_1.axios.get('https://api.fireflylabs.app/bridge/tokens');
|
|
25
|
+
}
|
|
26
|
+
function postSpeedActionApi(action) {
|
|
27
|
+
return axios_1.axios.post('https://api.fireflylabs.app/action/speed', action);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":";;AAEA,4DAOC;AAED,0CAEC;AAED,oCAEC;AAED,oCAEC;AAED,gDAEC;AAzBD,0CAAuC;AAEvC,SAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAqC;IAC3F,OAAO,aAAK,CAAC,GAAG,CAAC,+CAA+C,EAAE;QAChE,MAAM,EAAE;YACN,OAAO;YACP,IAAI;SACL;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,eAAe,CAAC,MAAW;IACzC,OAAO,aAAK,CAAC,IAAI,CAAC,oCAAoC,EAAE,MAAM,CAAC,CAAA;AACjE,CAAC;AAED,SAAgB,YAAY;IAC1B,OAAO,aAAK,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;AAC9D,CAAC;AAED,SAAgB,YAAY;IAC1B,OAAO,aAAK,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;AAC/D,CAAC;AAED,SAAgB,kBAAkB,CAAC,MAAW;IAC5C,OAAO,aAAK,CAAC,IAAI,CAAC,0CAA0C,EAAE,MAAM,CAAC,CAAA;AACvE,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FireflyClient = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const axios_1 = require("axios");
|
|
6
|
+
const request_js_1 = require("../utils/request.js");
|
|
7
|
+
const index_js_1 = require("../constants/index.js");
|
|
8
|
+
const index_js_2 = require("../utils/index.js");
|
|
9
|
+
class FireflyClient {
|
|
10
|
+
constructor({ referrer = 'firefly-sdk', baseApiUrl, logLevel = index_js_1.LogLevel.Info }) {
|
|
11
|
+
Object.defineProperty(this, "baseApiUrl", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: void 0
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "referrer", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "logLevel", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
this.referrer = referrer;
|
|
30
|
+
this.baseApiUrl = baseApiUrl;
|
|
31
|
+
this.logLevel = logLevel;
|
|
32
|
+
}
|
|
33
|
+
async getQuote(parameters) {
|
|
34
|
+
const { fromChainId, fromTokenAddress, toChainId, toTokenAddress, amount, recipient, sender, slippageTolerance } = parameters;
|
|
35
|
+
const query = {
|
|
36
|
+
sender: sender || "0x000000000000000000000000000000000000dead",
|
|
37
|
+
recipient,
|
|
38
|
+
fromChainId,
|
|
39
|
+
fromTokenAddress,
|
|
40
|
+
toChainId,
|
|
41
|
+
toTokenAddress,
|
|
42
|
+
amount,
|
|
43
|
+
referrer: this.referrer,
|
|
44
|
+
...(slippageTolerance && { slippageTolerance: slippageTolerance.toString() }),
|
|
45
|
+
};
|
|
46
|
+
const request = {
|
|
47
|
+
url: `${this.baseApiUrl}/quote`,
|
|
48
|
+
method: 'post',
|
|
49
|
+
data: query,
|
|
50
|
+
};
|
|
51
|
+
const res = await axios_1.default.request(request);
|
|
52
|
+
if (res.data.code !== 200) {
|
|
53
|
+
throw new request_js_1.APIError(res?.data?.message, res.status, res.data);
|
|
54
|
+
}
|
|
55
|
+
return { ...res.data.data, request };
|
|
56
|
+
}
|
|
57
|
+
async execute({ quote, wallet, onProgress }) {
|
|
58
|
+
let response = {
|
|
59
|
+
status: 'idle',
|
|
60
|
+
message: 'execute function: transaction execution incomplete'
|
|
61
|
+
};
|
|
62
|
+
const quoteRequest = quote.request;
|
|
63
|
+
if (!quoteRequest) {
|
|
64
|
+
return {
|
|
65
|
+
status: 'failed',
|
|
66
|
+
message: 'execute function: quote request information is missing',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
70
|
+
chain: wallet.chain,
|
|
71
|
+
transport: (0, viem_1.http)(),
|
|
72
|
+
});
|
|
73
|
+
for (let i = 0; i < quote.steps.length; i++) {
|
|
74
|
+
const step = quote.steps[i];
|
|
75
|
+
if (step.id === 'approve') {
|
|
76
|
+
try {
|
|
77
|
+
this.logs('Starting approval...');
|
|
78
|
+
const params = (0, index_js_2.handleWaitTransactionReceiptParams)(step);
|
|
79
|
+
const approveHash = await wallet.sendTransaction(params);
|
|
80
|
+
this.logs(`Approval tx hash: ${approveHash}.`);
|
|
81
|
+
await publicClient.waitForTransactionReceipt({
|
|
82
|
+
hash: approveHash,
|
|
83
|
+
});
|
|
84
|
+
this.logs('Approval successful');
|
|
85
|
+
onProgress?.({ step: 'approve', status: 'success', hash: approveHash });
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
onProgress?.({ step: 'approve', status: 'failed', error });
|
|
89
|
+
return {
|
|
90
|
+
status: 'failed',
|
|
91
|
+
message: `execute function approve step failed: ${error}`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (step.id === 'deposit') {
|
|
96
|
+
this.logs('Starting deposit...');
|
|
97
|
+
const txData = step.data;
|
|
98
|
+
const params = {
|
|
99
|
+
to: txData.to,
|
|
100
|
+
value: BigInt(txData.value),
|
|
101
|
+
data: txData.data,
|
|
102
|
+
chainId: txData.chainId,
|
|
103
|
+
kzg: undefined,
|
|
104
|
+
};
|
|
105
|
+
if (txData.maxFeePerGas)
|
|
106
|
+
params.maxFeePerGas = BigInt(txData.maxFeePerGas);
|
|
107
|
+
if (txData.maxPriorityFeePerGas)
|
|
108
|
+
params.maxPriorityFeePerGas = BigInt(txData.maxPriorityFeePerGas);
|
|
109
|
+
if (txData.gasLimit)
|
|
110
|
+
params.gasLimit = BigInt(txData.gasLimit);
|
|
111
|
+
let tx;
|
|
112
|
+
try {
|
|
113
|
+
tx = await wallet.sendTransaction(params);
|
|
114
|
+
(0, axios_1.default)({
|
|
115
|
+
method: "POST",
|
|
116
|
+
url: `${index_js_1.MAINNET_FIREFLY_API}/action`,
|
|
117
|
+
data: {
|
|
118
|
+
chainId: txData.chainId,
|
|
119
|
+
dstChainId: quoteRequest.data.toChainId,
|
|
120
|
+
hash: tx,
|
|
121
|
+
wallet: wallet?.account?.address,
|
|
122
|
+
dstWallet: quoteRequest.data.recipient,
|
|
123
|
+
fromToken: quoteRequest.data.fromTokenAddress,
|
|
124
|
+
dstToken: quoteRequest.data.toTokenAddress,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
this.logs(`Deposit tx hash: ${tx}.`);
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
onProgress?.({ step: 'deposit', status: 'failed', error: err });
|
|
131
|
+
return {
|
|
132
|
+
status: 'failed',
|
|
133
|
+
message: `execute function deposit step failed: ${err}`,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
while (true) {
|
|
138
|
+
await new Promise((resolve) => setTimeout(resolve, 1 * 1000));
|
|
139
|
+
const transaction = await (0, axios_1.default)({
|
|
140
|
+
method: "GET",
|
|
141
|
+
url: `${this.baseApiUrl}/quote/transaction`,
|
|
142
|
+
params: {
|
|
143
|
+
chainId: quoteRequest.data.fromChainId,
|
|
144
|
+
hash: tx,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
if (transaction.data.data.status !== 1) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
else if (transaction.data.data.status === 1) {
|
|
151
|
+
this.logs('Deposit successful.');
|
|
152
|
+
this.logs(`Cross-chain successful. Tx hash: ${transaction.data.data.dstHash}.`);
|
|
153
|
+
onProgress?.({ step: 'deposit', status: 'success', hash: transaction.data.data.dstHash });
|
|
154
|
+
response = {
|
|
155
|
+
status: 'success',
|
|
156
|
+
message: 'transaction successful'
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
onProgress?.({ step: 'deposit', status: 'failed', error: err });
|
|
164
|
+
return {
|
|
165
|
+
status: 'failed',
|
|
166
|
+
message: `execute function check transaction status failed: ${err}`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return response;
|
|
172
|
+
}
|
|
173
|
+
async logs(message) {
|
|
174
|
+
if (this.logLevel === index_js_1.LogLevel.Info) {
|
|
175
|
+
console.log(message);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.FireflyClient = FireflyClient;
|
|
180
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/client/client.ts"],"names":[],"mappings":";;;AAAA,+BAAmE;AACnE,iCAAuD;AACvD,oDAA+C;AAC/C,oDAA2F;AAC3F,gDAAuE;AAiBvE,MAAa,aAAa;IAKxB,YA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,EAAE,CAAC;4BAC9C,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;4BAChC,IAAI,CAAC,IAAI,CAAC,oCAAoC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;4BAC/E,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;4BAC1F,QAAQ,GAAG;gCACT,MAAM,EAAE,SAAS;gCACjB,OAAO,EAAE,wBAAwB;6BAClC,CAAA;wBACH,CAAC;wBACD,MAAM;oBACR,CAAC;gBACH,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;oBAChE,OAAO;wBACL,MAAM,EAAE,QAAQ;wBAChB,OAAO,EAAE,qDAAqD,GAAG,EAAE;qBACpE,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,OAAe;QAChC,IAAI,IAAI,CAAC,QAAQ,KAAK,mBAAQ,CAAC,IAAI,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;CAEF;AA3KD,sCA2KC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevel = exports.TESTNET_FIREFLY_API = exports.MAINNET_FIREFLY_API = void 0;
|
|
4
|
+
exports.MAINNET_FIREFLY_API = 'https://api.fireflylabs.app';
|
|
5
|
+
exports.TESTNET_FIREFLY_API = 'https://api.testnets.fireflylabs.app';
|
|
6
|
+
var LogLevel;
|
|
7
|
+
(function (LogLevel) {
|
|
8
|
+
LogLevel[LogLevel["Info"] = 1] = "Info";
|
|
9
|
+
LogLevel[LogLevel["None"] = 0] = "None";
|
|
10
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,6BAA6B,CAAA;AACnD,QAAA,mBAAmB,GAAG,sCAAsC,CAAA;AAGzE,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,uCAAQ,CAAA;IACR,uCAAQ,CAAA;AACV,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./client/client.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./constants/index.js"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,+DAAoC"}
|
package/_cjs/src/test.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const client_js_1 = require("./client/client.js");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const accounts_1 = require("viem/accounts");
|
|
7
|
+
const index_js_1 = require("./constants/index.js");
|
|
8
|
+
async function main() {
|
|
9
|
+
const client = new client_js_1.FireflyClient({
|
|
10
|
+
baseApiUrl: index_js_1.MAINNET_FIREFLY_API,
|
|
11
|
+
referrer: 'firefly-sdk',
|
|
12
|
+
logLevel: index_js_1.LogLevel.Info,
|
|
13
|
+
});
|
|
14
|
+
const quote = await client.getQuote({
|
|
15
|
+
"fromChainId": 8453,
|
|
16
|
+
"fromTokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
17
|
+
"recipient": "0x0955e7ad74ca25be76d7309532a40147e08ec8da",
|
|
18
|
+
"amount": "600000",
|
|
19
|
+
"toChainId": 42161,
|
|
20
|
+
"toTokenAddress": "0xaf88d065e77c8cc2239327c5edb3a432268e5831"
|
|
21
|
+
});
|
|
22
|
+
console.dir(quote, { depth: null });
|
|
23
|
+
const wallet = (0, viem_1.createWalletClient)({
|
|
24
|
+
chain: chains_1.base,
|
|
25
|
+
transport: (0, viem_1.http)(),
|
|
26
|
+
account: (0, accounts_1.privateKeyToAccount)(`0x`),
|
|
27
|
+
});
|
|
28
|
+
const response = await client.execute({
|
|
29
|
+
quote,
|
|
30
|
+
wallet: wallet,
|
|
31
|
+
});
|
|
32
|
+
console.dir(response, { depth: null });
|
|
33
|
+
}
|
|
34
|
+
main();
|
|
35
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":";;AAAA,wCAAmC;AACnC,kDAAmD;AACnD,+BAAgD;AAChD,4CAAoD;AACpD,mDAAqE;AAErE,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAI,yBAAa,CAAC;QAC/B,UAAU,EAAE,8BAAmB;QAC/B,QAAQ,EAAE,aAAa;QACvB,QAAQ,EAAE,mBAAQ,CAAC,IAAI;KACxB,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;QAClC,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAChB,4CAA4C;QAC9C,WAAW,EAAE,4CAA4C;QACzD,QAAQ,EAAE,QAAQ;QAClB,WAAW,EAAE,KAAK;QAClB,gBAAgB,EAAE,4CAA4C;KAC/D,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAGnC,MAAM,MAAM,GAAG,IAAA,yBAAkB,EAAC;QAChC,KAAK,EAAE,aAAI;QACX,SAAS,EAAE,IAAA,WAAI,GAAE;QACjB,OAAO,EAAE,IAAA,8BAAmB,EAAC,IAAI,CAAC;KACnC,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACpC,KAAK;QACL,MAAM,EAAE,MAAM;KACf,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACxC,CAAC;AAED,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Execute.js","sourceRoot":"","sources":["../../../src/types/Execute.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AAkBA,uDAA4B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.axios = void 0;
|
|
4
|
+
const axios_1 = require("axios");
|
|
5
|
+
const request_js_1 = require("./request.js");
|
|
6
|
+
exports.axios = axios_1.default.create();
|
|
7
|
+
exports.axios.interceptors.response.use((_res) => {
|
|
8
|
+
if (_res.headers['Deprecation'] === 'true') {
|
|
9
|
+
console.warn(`Warning: API ${_res.config.url} is deprecated. Stability and performance may be affected.`);
|
|
10
|
+
}
|
|
11
|
+
return _res;
|
|
12
|
+
}, (error) => {
|
|
13
|
+
return Promise.reject(new request_js_1.APIError(error.response?.data?.message, error.response?.data?.statusCode || 500, {
|
|
14
|
+
...error.response?.data,
|
|
15
|
+
endpoint: error.config?.url
|
|
16
|
+
}));
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=axios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../../src/utils/axios.ts"],"names":[],"mappings":";;;AAAA,iCAA0B;AAE1B,6CAAuC;AAE1B,QAAA,KAAK,GAAG,eAAM,CAAC,MAAM,EAAE,CAAA;AAEpC,aAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAC7B,CAAC,IAAmB,EAAE,EAAE;IACtB,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,MAAM,EAAE,CAAC;QAC3C,OAAO,CAAC,IAAI,CACV,gBAAgB,IAAI,CAAC,MAAM,CAAC,GAAG,4DAA4D,CAC5F,CAAA;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,qBAAQ,CACV,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAC7B,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,IAAI,GAAG,EACvC;QACE,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI;QACvB,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG;KAC5B,CACF,CACF,CAAA;AACH,CAAC,CACF,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEcoTypeByChainId = exports.handleWaitTransactionReceiptParams = void 0;
|
|
4
|
+
const handleWaitTransactionReceiptParams = (step) => {
|
|
5
|
+
const params = {
|
|
6
|
+
to: step.data.to,
|
|
7
|
+
from: step.data.from,
|
|
8
|
+
data: step.data.data,
|
|
9
|
+
value: BigInt(step.data.value),
|
|
10
|
+
chainId: step.data.chainId,
|
|
11
|
+
};
|
|
12
|
+
if (Number(step.data.gas)) {
|
|
13
|
+
params.gas = BigInt(step.data.gas);
|
|
14
|
+
}
|
|
15
|
+
if (Number(step.data.gasPrice)) {
|
|
16
|
+
params.gasPrice = BigInt(step.data.gasPrice || '0');
|
|
17
|
+
}
|
|
18
|
+
if (Number(step.data.maxFeePerGas)) {
|
|
19
|
+
params.maxFeePerGas = BigInt(step.data.maxFeePerGas);
|
|
20
|
+
}
|
|
21
|
+
if (Number(step.data.maxPriorityFeePerGas)) {
|
|
22
|
+
params.maxPriorityFeePerGas = BigInt(step.data.maxPriorityFeePerGas);
|
|
23
|
+
}
|
|
24
|
+
return params;
|
|
25
|
+
};
|
|
26
|
+
exports.handleWaitTransactionReceiptParams = handleWaitTransactionReceiptParams;
|
|
27
|
+
const getEcoTypeByChainId = (chainId) => {
|
|
28
|
+
const mapType = {
|
|
29
|
+
1024001: 'Ton',
|
|
30
|
+
1024002: 'Fuel',
|
|
31
|
+
1024003: 'Eclipse',
|
|
32
|
+
1024004: 'Solana',
|
|
33
|
+
1024005: 'Soon',
|
|
34
|
+
1024006: 'Sui',
|
|
35
|
+
1024007: 'ICP',
|
|
36
|
+
1024008: 'Tron',
|
|
37
|
+
1024009: 'Starknet',
|
|
38
|
+
1024010: 'ZksLite',
|
|
39
|
+
1024011: 'Movement',
|
|
40
|
+
1024012: 'SvmBnb',
|
|
41
|
+
1024013: 'SvmBase',
|
|
42
|
+
1024014: 'SonicSVM',
|
|
43
|
+
1024015: 'Aptos',
|
|
44
|
+
};
|
|
45
|
+
return mapType?.[chainId] || 'EVM';
|
|
46
|
+
};
|
|
47
|
+
exports.getEcoTypeByChainId = getEcoTypeByChainId;
|
|
48
|
+
//# sourceMappingURL=index.js.map
|