@vleap/warps-adapter-fastset 0.1.0-alpha.13 → 0.1.0-alpha.15
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/index.d.cts +363 -0
- package/dist/index.d.ts +120 -62
- package/dist/index.js +1057 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +525 -335
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/dist/index.mjs
CHANGED
|
@@ -1,118 +1,16 @@
|
|
|
1
1
|
// src/constants.ts
|
|
2
2
|
var WarpFastsetConstants = {
|
|
3
|
-
|
|
4
|
-
Identifier: "PI",
|
|
5
|
-
DisplayName: "Pi",
|
|
6
|
-
Decimals: 18
|
|
7
|
-
},
|
|
8
|
-
GasLimit: {
|
|
9
|
-
Default: 21e3,
|
|
10
|
-
ContractCall: 1e5,
|
|
11
|
-
ContractDeploy: 5e5,
|
|
12
|
-
Transfer: 21e3,
|
|
13
|
-
Approve: 46e3,
|
|
14
|
-
Swap: 2e5
|
|
15
|
-
},
|
|
16
|
-
GasPrice: {
|
|
17
|
-
Default: "20000000000",
|
|
18
|
-
// 20 gwei
|
|
19
|
-
Low: "10000000000",
|
|
20
|
-
// 10 gwei
|
|
21
|
-
Medium: "20000000000",
|
|
22
|
-
// 20 gwei
|
|
23
|
-
High: "50000000000"
|
|
24
|
-
// 50 gwei
|
|
25
|
-
},
|
|
26
|
-
Validation: {
|
|
27
|
-
AddressLength: 42,
|
|
28
|
-
HexPrefix: "0x",
|
|
29
|
-
MinGasLimit: 21e3,
|
|
30
|
-
MaxGasLimit: 3e7
|
|
31
|
-
},
|
|
32
|
-
Timeouts: {
|
|
33
|
-
DefaultRpcTimeout: 3e4,
|
|
34
|
-
// 30 seconds
|
|
35
|
-
GasEstimationTimeout: 1e4,
|
|
36
|
-
// 10 seconds
|
|
37
|
-
QueryTimeout: 15e3
|
|
38
|
-
// 15 seconds
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/WarpFastsetDataLoader.ts
|
|
43
|
-
var WarpFastsetDataLoader = class {
|
|
44
|
-
constructor(config, chain) {
|
|
45
|
-
this.config = config;
|
|
46
|
-
this.chain = chain;
|
|
47
|
-
}
|
|
48
|
-
async getAccount(address) {
|
|
49
|
-
return {
|
|
50
|
-
address,
|
|
51
|
-
balance: BigInt(0)
|
|
52
|
-
// TODO: Implement actual balance fetching from Fastset API
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
async getAccountAssets(address) {
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
3
|
+
// Placeholder for future FastSet-specific constants
|
|
58
4
|
};
|
|
59
5
|
|
|
60
|
-
// src/
|
|
61
|
-
import {
|
|
62
|
-
getProviderUrl,
|
|
63
|
-
getWarpActionByIndex
|
|
64
|
-
} from "@vleap/warps";
|
|
65
|
-
|
|
66
|
-
// src/config.ts
|
|
67
|
-
var FASTSET_CHAIN_CONFIGS = {
|
|
68
|
-
fastset: {
|
|
69
|
-
mainnet: {
|
|
70
|
-
defaultApiUrl: "http://157.90.201.117:8765",
|
|
71
|
-
proxyUrl: "http://136.243.61.168:44444",
|
|
72
|
-
explorerUrl: "https://explorer.fastset.com",
|
|
73
|
-
chainId: "1",
|
|
74
|
-
registryAddress: "0x0000000000000000000000000000000000000000",
|
|
75
|
-
nativeToken: "PI",
|
|
76
|
-
blockTime: 12e3
|
|
77
|
-
},
|
|
78
|
-
testnet: {
|
|
79
|
-
defaultApiUrl: "http://157.90.201.117:8765",
|
|
80
|
-
proxyUrl: "http://136.243.61.168:44444",
|
|
81
|
-
explorerUrl: "https://testnet-explorer.fastset.com",
|
|
82
|
-
chainId: "11155111",
|
|
83
|
-
registryAddress: "0x0000000000000000000000000000000000000000",
|
|
84
|
-
nativeToken: "PI",
|
|
85
|
-
blockTime: 12e3
|
|
86
|
-
},
|
|
87
|
-
devnet: {
|
|
88
|
-
defaultApiUrl: "http://157.90.201.117:8765",
|
|
89
|
-
proxyUrl: "http://136.243.61.168:44444",
|
|
90
|
-
explorerUrl: "http://localhost:4000",
|
|
91
|
-
chainId: "1337",
|
|
92
|
-
registryAddress: "0x0000000000000000000000000000000000000000",
|
|
93
|
-
nativeToken: "PI",
|
|
94
|
-
blockTime: 12e3
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var DEFAULT_CHAIN = "fastset";
|
|
99
|
-
var getFastsetChainConfig = (chain = DEFAULT_CHAIN, env) => {
|
|
100
|
-
const chainConfigs = FASTSET_CHAIN_CONFIGS[chain];
|
|
101
|
-
if (!chainConfigs) {
|
|
102
|
-
throw new Error(`Unsupported Fastset chain: ${chain}`);
|
|
103
|
-
}
|
|
104
|
-
const config = chainConfigs[env];
|
|
105
|
-
if (!config) {
|
|
106
|
-
throw new Error(`Unsupported environment ${env} for chain ${chain}`);
|
|
107
|
-
}
|
|
108
|
-
return config;
|
|
109
|
-
};
|
|
110
|
-
var getFastsetApiUrl = (env, chain = DEFAULT_CHAIN) => {
|
|
111
|
-
return getFastsetChainConfig(chain, env).apiUrl;
|
|
112
|
-
};
|
|
6
|
+
// src/main.ts
|
|
7
|
+
import { WarpChainName } from "@vleap/warps";
|
|
113
8
|
|
|
114
9
|
// src/sdk/FastsetClient.ts
|
|
115
|
-
import { getPublicKey
|
|
10
|
+
import { getPublicKey } from "@noble/ed25519";
|
|
11
|
+
|
|
12
|
+
// src/sdk/TransactionSigner.ts
|
|
13
|
+
import { sign } from "@noble/ed25519";
|
|
116
14
|
|
|
117
15
|
// src/sdk/types.ts
|
|
118
16
|
import { bcs } from "@mysten/bcs";
|
|
@@ -139,7 +37,7 @@ var Transfer = bcs.struct("Transfer", {
|
|
|
139
37
|
var ClaimType = bcs.enum("ClaimType", {
|
|
140
38
|
Transfer
|
|
141
39
|
});
|
|
142
|
-
var
|
|
40
|
+
var BcsTransaction = bcs.struct("Transaction", {
|
|
143
41
|
sender: PublicKey,
|
|
144
42
|
nonce: Nonce,
|
|
145
43
|
timestamp_nanos: bcs.u128(),
|
|
@@ -149,15 +47,179 @@ function hexToDecimal(hex) {
|
|
|
149
47
|
return BigInt(`0x${hex}`).toString();
|
|
150
48
|
}
|
|
151
49
|
|
|
50
|
+
// src/sdk/TransactionSigner.ts
|
|
51
|
+
var TransactionSigner = class {
|
|
52
|
+
static async signTransaction(transaction, privateKey) {
|
|
53
|
+
const msg = BcsTransaction.serialize(transaction);
|
|
54
|
+
const msgBytes = msg.toBytes();
|
|
55
|
+
const prefix = new TextEncoder().encode("Transaction::");
|
|
56
|
+
const dataToSign = new Uint8Array(prefix.length + msgBytes.length);
|
|
57
|
+
dataToSign.set(prefix, 0);
|
|
58
|
+
dataToSign.set(msgBytes, prefix.length);
|
|
59
|
+
return sign(dataToSign, privateKey);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/sdk/Wallet.ts
|
|
64
|
+
import * as bech32 from "bech32";
|
|
65
|
+
|
|
66
|
+
// src/sdk/Claim.ts
|
|
67
|
+
var Claim = class {
|
|
68
|
+
static fromTransaction(transaction) {
|
|
69
|
+
const claimType = Object.keys(transaction.claim)[0];
|
|
70
|
+
const claimData = transaction.claim[claimType];
|
|
71
|
+
switch (claimType) {
|
|
72
|
+
case "Transfer":
|
|
73
|
+
return TransferClaim.fromData(claimData);
|
|
74
|
+
default:
|
|
75
|
+
throw new Error(`Unknown claim type: ${claimType}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var TransferClaim = class _TransferClaim extends Claim {
|
|
80
|
+
constructor(recipient, amount, userData) {
|
|
81
|
+
super();
|
|
82
|
+
this.type = "Transfer";
|
|
83
|
+
this.data = { recipient, amount, userData };
|
|
84
|
+
}
|
|
85
|
+
toTransactionData() {
|
|
86
|
+
return {
|
|
87
|
+
Transfer: {
|
|
88
|
+
recipient: { FastSet: this.data.recipient },
|
|
89
|
+
amount: this.data.amount,
|
|
90
|
+
user_data: this.data.userData ?? null
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
static fromData(data) {
|
|
95
|
+
const recipient = data.recipient.FastSet || data.recipient.External;
|
|
96
|
+
return new _TransferClaim(recipient, data.amount, data.user_data);
|
|
97
|
+
}
|
|
98
|
+
getRecipient() {
|
|
99
|
+
return this.data.recipient;
|
|
100
|
+
}
|
|
101
|
+
getAmount() {
|
|
102
|
+
return this.data.amount;
|
|
103
|
+
}
|
|
104
|
+
getUserData() {
|
|
105
|
+
return this.data.userData;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/sdk/ed25519-setup.ts
|
|
110
|
+
import * as ed from "@noble/ed25519";
|
|
111
|
+
import { sha512 } from "@noble/hashes/sha512";
|
|
112
|
+
if (ed.etc) {
|
|
113
|
+
ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/sdk/Transaction.ts
|
|
117
|
+
var Transaction = class _Transaction {
|
|
118
|
+
constructor(sender, nonce, claim, options = {}) {
|
|
119
|
+
this.sender = sender;
|
|
120
|
+
this.nonce = nonce;
|
|
121
|
+
this.claim = claim;
|
|
122
|
+
this.timestamp = options.timestamp ?? BigInt(Date.now()) * 1000000n;
|
|
123
|
+
}
|
|
124
|
+
toTransaction() {
|
|
125
|
+
return {
|
|
126
|
+
sender: this.sender,
|
|
127
|
+
nonce: this.nonce,
|
|
128
|
+
timestamp_nanos: this.timestamp,
|
|
129
|
+
claim: this.claim.toTransactionData()
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
getSender() {
|
|
133
|
+
return this.sender;
|
|
134
|
+
}
|
|
135
|
+
getNonce() {
|
|
136
|
+
return this.nonce;
|
|
137
|
+
}
|
|
138
|
+
getClaim() {
|
|
139
|
+
return this.claim;
|
|
140
|
+
}
|
|
141
|
+
getTimestamp() {
|
|
142
|
+
return this.timestamp;
|
|
143
|
+
}
|
|
144
|
+
static fromTransaction(transaction) {
|
|
145
|
+
const claim = Claim.fromTransaction(transaction);
|
|
146
|
+
return new _Transaction(transaction.sender, transaction.nonce, claim, { timestamp: transaction.timestamp_nanos });
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// src/sdk/Wallet.ts
|
|
151
|
+
var Wallet = class _Wallet {
|
|
152
|
+
constructor(privateKeyHex) {
|
|
153
|
+
const cleanPrivateKey = privateKeyHex.replace(/^0x/, "");
|
|
154
|
+
this.privateKey = Buffer.from(cleanPrivateKey, "hex");
|
|
155
|
+
this.publicKey = ed.getPublicKey(this.privateKey);
|
|
156
|
+
this.publicKeyHex = Buffer.from(this.publicKey).toString("hex");
|
|
157
|
+
}
|
|
158
|
+
toBech32() {
|
|
159
|
+
const words = bech32.bech32m.toWords(this.publicKey);
|
|
160
|
+
return bech32.bech32m.encode("set", words);
|
|
161
|
+
}
|
|
162
|
+
getWalletInfo() {
|
|
163
|
+
return {
|
|
164
|
+
publicKeyHex: this.publicKeyHex,
|
|
165
|
+
address: this.toBech32()
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
createTransferClaim(recipientAddress, amount, assetType) {
|
|
169
|
+
const recipientBytes = _Wallet.decodeBech32Address(recipientAddress);
|
|
170
|
+
const assetTypeBytes = new TextEncoder().encode(assetType);
|
|
171
|
+
const userData = new Uint8Array(32);
|
|
172
|
+
userData.set(assetTypeBytes.slice(0, 32));
|
|
173
|
+
return new TransferClaim(recipientBytes, amount.toString(), userData);
|
|
174
|
+
}
|
|
175
|
+
createTransaction(nonce, claim) {
|
|
176
|
+
return new Transaction(this.publicKey, nonce, claim);
|
|
177
|
+
}
|
|
178
|
+
async signTransaction(transaction) {
|
|
179
|
+
const transactionData = transaction.toTransaction();
|
|
180
|
+
return await TransactionSigner.signTransaction(transactionData, this.privateKey);
|
|
181
|
+
}
|
|
182
|
+
static decodeBech32Address(address) {
|
|
183
|
+
try {
|
|
184
|
+
const decoded = bech32.bech32m.decode(address);
|
|
185
|
+
return new Uint8Array(bech32.bech32m.fromWords(decoded.words));
|
|
186
|
+
} catch (error) {
|
|
187
|
+
const decoded = bech32.bech32.decode(address);
|
|
188
|
+
return new Uint8Array(bech32.bech32.fromWords(decoded.words));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
static encodeBech32Address(publicKey) {
|
|
192
|
+
const words = bech32.bech32m.toWords(publicKey);
|
|
193
|
+
return bech32.bech32m.encode("set", words);
|
|
194
|
+
}
|
|
195
|
+
static fromPrivateKey(privateKeyHex) {
|
|
196
|
+
return new _Wallet(privateKeyHex);
|
|
197
|
+
}
|
|
198
|
+
static generateNew() {
|
|
199
|
+
const privateKey = ed.utils.randomPrivateKey();
|
|
200
|
+
const privateKeyHex = Buffer.from(privateKey).toString("hex");
|
|
201
|
+
return new _Wallet(privateKeyHex);
|
|
202
|
+
}
|
|
203
|
+
static async fromPrivateKeyFile(filePath) {
|
|
204
|
+
const fs = await import("fs/promises");
|
|
205
|
+
const privateKeyHex = (await fs.readFile(filePath, "utf8")).trim();
|
|
206
|
+
return new _Wallet(privateKeyHex);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
152
210
|
// src/sdk/FastsetClient.ts
|
|
211
|
+
BigInt.prototype.toJSON = function() {
|
|
212
|
+
return Number(this);
|
|
213
|
+
};
|
|
153
214
|
var FastsetClient = class {
|
|
154
215
|
constructor(config) {
|
|
155
216
|
this.config = config;
|
|
156
217
|
}
|
|
157
218
|
async getAccountInfo(address) {
|
|
158
219
|
try {
|
|
220
|
+
const addressBytes = Wallet.decodeBech32Address(address);
|
|
159
221
|
const response = await this.requestValidator("set_getAccountInfo", {
|
|
160
|
-
address: Array.from(
|
|
222
|
+
address: Array.from(addressBytes)
|
|
161
223
|
});
|
|
162
224
|
if (response.error) {
|
|
163
225
|
return null;
|
|
@@ -171,10 +233,11 @@ var FastsetClient = class {
|
|
|
171
233
|
const accountInfo = await this.getAccountInfo(senderAddress);
|
|
172
234
|
return accountInfo?.next_nonce ?? 0;
|
|
173
235
|
}
|
|
174
|
-
async fundFromFaucet(
|
|
236
|
+
async fundFromFaucet(recipientAddress, amount) {
|
|
237
|
+
const recipientBytes = Wallet.decodeBech32Address(recipientAddress);
|
|
175
238
|
const response = await this.requestProxy("faucetDrip", {
|
|
176
|
-
recipient: Array.from(
|
|
177
|
-
amount
|
|
239
|
+
recipient: Array.from(recipientBytes),
|
|
240
|
+
amount
|
|
178
241
|
});
|
|
179
242
|
if (response.error) {
|
|
180
243
|
throw new Error(`Faucet request failed: ${response.error.message}`);
|
|
@@ -183,7 +246,7 @@ var FastsetClient = class {
|
|
|
183
246
|
}
|
|
184
247
|
async submitTransaction(request) {
|
|
185
248
|
const response = await this.requestValidator("set_submitTransaction", {
|
|
186
|
-
transaction:
|
|
249
|
+
transaction: request.transaction,
|
|
187
250
|
signature: Array.from(request.signature)
|
|
188
251
|
});
|
|
189
252
|
if (response.error) {
|
|
@@ -198,7 +261,7 @@ var FastsetClient = class {
|
|
|
198
261
|
}
|
|
199
262
|
async submitCertificate(request) {
|
|
200
263
|
const response = await this.requestValidator("set_submitTransactionCertificate", {
|
|
201
|
-
transaction:
|
|
264
|
+
transaction: request.transaction,
|
|
202
265
|
signature: Array.from(request.signature),
|
|
203
266
|
validator_signatures: request.validator_signatures.map(([validator, signature]) => [Array.from(validator), Array.from(signature)])
|
|
204
267
|
});
|
|
@@ -208,14 +271,16 @@ var FastsetClient = class {
|
|
|
208
271
|
}
|
|
209
272
|
async executeTransfer(senderPrivateKey, recipient, amount, userData) {
|
|
210
273
|
const senderPublicKey = await getPublicKey(senderPrivateKey);
|
|
211
|
-
const
|
|
274
|
+
const senderAddress = Wallet.encodeBech32Address(senderPublicKey);
|
|
275
|
+
const nonce = await this.getNextNonce(senderAddress);
|
|
276
|
+
const recipientBytes = Wallet.decodeBech32Address(recipient);
|
|
212
277
|
const transaction = {
|
|
213
278
|
sender: senderPublicKey,
|
|
214
279
|
nonce,
|
|
215
280
|
timestamp_nanos: BigInt(Date.now()) * 1000000n,
|
|
216
281
|
claim: {
|
|
217
282
|
Transfer: {
|
|
218
|
-
recipient: { FastSet:
|
|
283
|
+
recipient: { FastSet: recipientBytes },
|
|
219
284
|
amount,
|
|
220
285
|
user_data: userData ?? null
|
|
221
286
|
}
|
|
@@ -233,17 +298,67 @@ var FastsetClient = class {
|
|
|
233
298
|
});
|
|
234
299
|
return submitResponse.transaction_hash;
|
|
235
300
|
}
|
|
301
|
+
async submitClaim(senderPrivateKey, claim) {
|
|
302
|
+
const senderPublicKey = await getPublicKey(senderPrivateKey);
|
|
303
|
+
const senderAddress = Wallet.encodeBech32Address(senderPublicKey);
|
|
304
|
+
const nonce = await this.getNextNonce(senderAddress);
|
|
305
|
+
const transaction = {
|
|
306
|
+
sender: senderPublicKey,
|
|
307
|
+
nonce,
|
|
308
|
+
timestamp_nanos: BigInt(Date.now()) * 1000000n,
|
|
309
|
+
claim
|
|
310
|
+
};
|
|
311
|
+
const signature = await this.signTransaction(transaction, senderPrivateKey);
|
|
312
|
+
const submitResponse = await this.submitTransaction({
|
|
313
|
+
transaction,
|
|
314
|
+
signature
|
|
315
|
+
});
|
|
316
|
+
await this.submitCertificate({
|
|
317
|
+
transaction,
|
|
318
|
+
signature,
|
|
319
|
+
validator_signatures: [[submitResponse.validator, submitResponse.signature]]
|
|
320
|
+
});
|
|
321
|
+
return submitResponse.transaction_hash;
|
|
322
|
+
}
|
|
236
323
|
async signTransaction(transaction, privateKey) {
|
|
237
|
-
|
|
238
|
-
const msgBytes = msg.toBytes();
|
|
239
|
-
const prefix = new TextEncoder().encode("Transaction::");
|
|
240
|
-
const dataToSign = new Uint8Array(prefix.length + msgBytes.length);
|
|
241
|
-
dataToSign.set(prefix, 0);
|
|
242
|
-
dataToSign.set(msgBytes, prefix.length);
|
|
243
|
-
return sign(dataToSign, privateKey);
|
|
324
|
+
return await TransactionSigner.signTransaction(transaction, privateKey);
|
|
244
325
|
}
|
|
245
|
-
|
|
246
|
-
|
|
326
|
+
async getTransactionStatus(txHash) {
|
|
327
|
+
try {
|
|
328
|
+
const response = await this.requestValidator("set_getTransactionStatus", {
|
|
329
|
+
hash: txHash
|
|
330
|
+
});
|
|
331
|
+
if (response.error) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
return response.result;
|
|
335
|
+
} catch (error) {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async getTransactionInfo(txHash) {
|
|
340
|
+
try {
|
|
341
|
+
const response = await this.requestValidator("set_getTransactionInfo", {
|
|
342
|
+
hash: txHash
|
|
343
|
+
});
|
|
344
|
+
if (response.error) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
return response.result;
|
|
348
|
+
} catch (error) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
async getNetworkInfo() {
|
|
353
|
+
try {
|
|
354
|
+
const response = await this.requestValidator("set_getNetworkInfo", {});
|
|
355
|
+
if (response.error) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
return response.result;
|
|
359
|
+
} catch (error) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
247
362
|
}
|
|
248
363
|
async requestValidator(method, params) {
|
|
249
364
|
return this.request(this.config.validatorUrl, method, params);
|
|
@@ -276,69 +391,131 @@ var FastsetClient = class {
|
|
|
276
391
|
}
|
|
277
392
|
};
|
|
278
393
|
|
|
279
|
-
// src/
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
394
|
+
// src/WarpFastsetDataLoader.ts
|
|
395
|
+
var WarpFastsetDataLoader = class {
|
|
396
|
+
constructor(config, chain) {
|
|
397
|
+
this.config = config;
|
|
398
|
+
this.chain = chain;
|
|
399
|
+
const validatorUrl = this.chain.defaultApiUrl;
|
|
400
|
+
const proxyUrl = this.chain.defaultApiUrl;
|
|
401
|
+
this.client = new FastsetClient({
|
|
402
|
+
validatorUrl,
|
|
403
|
+
proxyUrl
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
async getAccount(address) {
|
|
407
|
+
try {
|
|
408
|
+
const accountInfo = await this.client.getAccountInfo(address);
|
|
409
|
+
if (!accountInfo) {
|
|
410
|
+
return {
|
|
411
|
+
chain: this.chain.name,
|
|
412
|
+
address,
|
|
413
|
+
balance: BigInt(0)
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
chain: this.chain.name,
|
|
418
|
+
address,
|
|
419
|
+
balance: BigInt(parseInt(accountInfo.balance, 16))
|
|
420
|
+
};
|
|
421
|
+
} catch (error) {
|
|
422
|
+
return {
|
|
423
|
+
chain: this.chain.name,
|
|
424
|
+
address,
|
|
425
|
+
balance: BigInt(0)
|
|
426
|
+
};
|
|
427
|
+
}
|
|
284
428
|
}
|
|
285
|
-
|
|
286
|
-
|
|
429
|
+
async getAccountAssets(address) {
|
|
430
|
+
try {
|
|
431
|
+
const account = await this.getAccount(address);
|
|
432
|
+
if (account.balance > 0) {
|
|
433
|
+
return [
|
|
434
|
+
{
|
|
435
|
+
chain: this.chain.name,
|
|
436
|
+
identifier: this.chain.nativeToken?.identifier || "SET",
|
|
437
|
+
name: this.chain.nativeToken?.name || "SET",
|
|
438
|
+
decimals: this.chain.nativeToken?.decimals || 6,
|
|
439
|
+
amount: account.balance,
|
|
440
|
+
logoUrl: this.chain.nativeToken?.logoUrl
|
|
441
|
+
}
|
|
442
|
+
];
|
|
443
|
+
}
|
|
444
|
+
return [];
|
|
445
|
+
} catch (error) {
|
|
446
|
+
return [];
|
|
447
|
+
}
|
|
287
448
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
return decoded.length === 32;
|
|
291
|
-
} catch {
|
|
292
|
-
return false;
|
|
449
|
+
async getAccountActions(address, options) {
|
|
450
|
+
return [];
|
|
293
451
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const bigInt = BigInt(amount);
|
|
313
|
-
return bigInt >= 0;
|
|
314
|
-
} catch {
|
|
315
|
-
return false;
|
|
452
|
+
async getAccountInfo(address) {
|
|
453
|
+
try {
|
|
454
|
+
const accountInfo = await this.client.getAccountInfo(address);
|
|
455
|
+
if (!accountInfo) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
const balanceDecimal = parseInt(accountInfo.balance, 16);
|
|
459
|
+
return {
|
|
460
|
+
address,
|
|
461
|
+
balance: accountInfo.balance,
|
|
462
|
+
balanceDecimal,
|
|
463
|
+
nextNonce: accountInfo.next_nonce,
|
|
464
|
+
sequenceNumber: accountInfo.sequence_number
|
|
465
|
+
};
|
|
466
|
+
} catch (error) {
|
|
467
|
+
console.error("Error getting account info:", error);
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
316
470
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
471
|
+
async getTransactionInfo(txHash) {
|
|
472
|
+
try {
|
|
473
|
+
return {
|
|
474
|
+
hash: txHash,
|
|
475
|
+
hashHex: txHash.startsWith("0x") ? txHash.slice(2) : txHash,
|
|
476
|
+
status: "submitted",
|
|
477
|
+
details: {
|
|
478
|
+
hash: txHash,
|
|
479
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
} catch (error) {
|
|
483
|
+
console.error("Error getting transaction info:", error);
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
324
486
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
487
|
+
async checkTransferStatus(fromAddress, toAddress, amount) {
|
|
488
|
+
try {
|
|
489
|
+
const fromAccount = await this.getAccountInfo(fromAddress);
|
|
490
|
+
const toAccount = await this.getAccountInfo(toAddress);
|
|
491
|
+
if (!fromAccount || !toAccount) {
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
const transferAmount = parseInt(amount);
|
|
495
|
+
const fromBalance = fromAccount.balanceDecimal;
|
|
496
|
+
return fromBalance < transferAmount;
|
|
497
|
+
} catch (error) {
|
|
498
|
+
console.error("Error checking transfer status:", error);
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
332
501
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
502
|
+
async getAccountBalance(address) {
|
|
503
|
+
const accountInfo = await this.getAccountInfo(address);
|
|
504
|
+
if (!accountInfo) {
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
return {
|
|
508
|
+
balance: accountInfo.balance,
|
|
509
|
+
balanceDecimal: accountInfo.balanceDecimal
|
|
510
|
+
};
|
|
340
511
|
}
|
|
341
|
-
}
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// src/WarpFastsetExecutor.ts
|
|
515
|
+
import {
|
|
516
|
+
getProviderUrl,
|
|
517
|
+
getWarpActionByIndex
|
|
518
|
+
} from "@vleap/warps";
|
|
342
519
|
|
|
343
520
|
// src/WarpFastsetSerializer.ts
|
|
344
521
|
import {
|
|
@@ -359,7 +536,7 @@ var WarpFastsetSerializer = class {
|
|
|
359
536
|
return `boolean:${value}`;
|
|
360
537
|
}
|
|
361
538
|
if (typeof value === "bigint") {
|
|
362
|
-
return `
|
|
539
|
+
return `biguint:${value.toString()}`;
|
|
363
540
|
}
|
|
364
541
|
if (Array.isArray(value)) {
|
|
365
542
|
const items = value.map((item) => this.typedToString(item)).join(",");
|
|
@@ -384,7 +561,7 @@ var WarpFastsetSerializer = class {
|
|
|
384
561
|
return ["boolean", value];
|
|
385
562
|
}
|
|
386
563
|
if (typeof value === "bigint") {
|
|
387
|
-
return ["
|
|
564
|
+
return ["biguint", value.toString()];
|
|
388
565
|
}
|
|
389
566
|
return ["string", String(value)];
|
|
390
567
|
}
|
|
@@ -396,8 +573,12 @@ var WarpFastsetSerializer = class {
|
|
|
396
573
|
return Number(value);
|
|
397
574
|
case "boolean":
|
|
398
575
|
return Boolean(value);
|
|
399
|
-
case "
|
|
576
|
+
case "biguint":
|
|
400
577
|
return BigInt(value);
|
|
578
|
+
case "address":
|
|
579
|
+
return String(value);
|
|
580
|
+
case "hex":
|
|
581
|
+
return String(value);
|
|
401
582
|
default:
|
|
402
583
|
return String(value);
|
|
403
584
|
}
|
|
@@ -410,8 +591,12 @@ var WarpFastsetSerializer = class {
|
|
|
410
591
|
return "number";
|
|
411
592
|
case "boolean":
|
|
412
593
|
return "boolean";
|
|
413
|
-
case "
|
|
414
|
-
return "
|
|
594
|
+
case "biguint":
|
|
595
|
+
return "biguint";
|
|
596
|
+
case "address":
|
|
597
|
+
return "address";
|
|
598
|
+
case "hex":
|
|
599
|
+
return "hex";
|
|
415
600
|
default:
|
|
416
601
|
return "string";
|
|
417
602
|
}
|
|
@@ -430,7 +615,7 @@ var WarpFastsetSerializer = class {
|
|
|
430
615
|
return Number(stringValue);
|
|
431
616
|
case "boolean":
|
|
432
617
|
return stringValue === "true";
|
|
433
|
-
case "
|
|
618
|
+
case "biguint":
|
|
434
619
|
return BigInt(stringValue);
|
|
435
620
|
case "array":
|
|
436
621
|
return stringValue.split(",").map((item) => this.stringToTyped(item));
|
|
@@ -450,10 +635,10 @@ var WarpFastsetExecutor = class {
|
|
|
450
635
|
this.config = config;
|
|
451
636
|
this.chain = chain;
|
|
452
637
|
this.serializer = new WarpFastsetSerializer();
|
|
453
|
-
const
|
|
638
|
+
const validatorUrl = getProviderUrl(this.config, chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
454
639
|
const proxyUrl = getProviderUrl(this.config, chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
455
640
|
this.fastsetClient = new FastsetClient({
|
|
456
|
-
validatorUrl
|
|
641
|
+
validatorUrl,
|
|
457
642
|
proxyUrl
|
|
458
643
|
});
|
|
459
644
|
}
|
|
@@ -475,15 +660,15 @@ var WarpFastsetExecutor = class {
|
|
|
475
660
|
async createTransferTransaction(executable) {
|
|
476
661
|
const userWallet = this.config.user?.wallets?.[executable.chain.name];
|
|
477
662
|
if (!userWallet) throw new Error("WarpFastsetExecutor: createTransfer - user address not set");
|
|
478
|
-
if (!isValidFastsetAddress(executable.destination)) {
|
|
663
|
+
if (!this.isValidFastsetAddress(executable.destination)) {
|
|
479
664
|
throw new Error(`WarpFastsetExecutor: Invalid destination address: ${executable.destination}`);
|
|
480
665
|
}
|
|
481
666
|
if (executable.value < 0) {
|
|
482
667
|
throw new Error(`WarpFastsetExecutor: Transfer value cannot be negative: ${executable.value}`);
|
|
483
668
|
}
|
|
484
|
-
const recipientAddress = fromBase64(executable.destination);
|
|
485
|
-
const amount = normalizeAmount(executable.value.toString());
|
|
486
|
-
const userData = executable.data ? fromBase64(this.serializer.stringToTyped(executable.data)) : void 0;
|
|
669
|
+
const recipientAddress = this.fromBase64(executable.destination);
|
|
670
|
+
const amount = this.normalizeAmount(executable.value.toString());
|
|
671
|
+
const userData = executable.data ? this.fromBase64(this.serializer.stringToTyped(executable.data)) : void 0;
|
|
487
672
|
return {
|
|
488
673
|
type: "fastset-transfer",
|
|
489
674
|
recipient: recipientAddress,
|
|
@@ -499,14 +684,14 @@ var WarpFastsetExecutor = class {
|
|
|
499
684
|
if (!action || !("func" in action) || !action.func) {
|
|
500
685
|
throw new Error("WarpFastsetExecutor: Contract action must have a function name");
|
|
501
686
|
}
|
|
502
|
-
if (!isValidFastsetAddress(executable.destination)) {
|
|
687
|
+
if (!this.isValidFastsetAddress(executable.destination)) {
|
|
503
688
|
throw new Error(`WarpFastsetExecutor: Invalid contract address: ${executable.destination}`);
|
|
504
689
|
}
|
|
505
690
|
if (executable.value < 0) {
|
|
506
691
|
throw new Error(`WarpFastsetExecutor: Contract call value cannot be negative: ${executable.value}`);
|
|
507
692
|
}
|
|
508
693
|
try {
|
|
509
|
-
const contractAddress = fromBase64(executable.destination);
|
|
694
|
+
const contractAddress = this.fromBase64(executable.destination);
|
|
510
695
|
const encodedData = this.encodeFunctionData(action.func, executable.args);
|
|
511
696
|
return {
|
|
512
697
|
type: "fastset-contract-call",
|
|
@@ -528,11 +713,11 @@ var WarpFastsetExecutor = class {
|
|
|
528
713
|
if (!action.func) {
|
|
529
714
|
throw new Error("WarpFastsetExecutor: Query action must have a function name");
|
|
530
715
|
}
|
|
531
|
-
if (!isValidFastsetAddress(executable.destination)) {
|
|
716
|
+
if (!this.isValidFastsetAddress(executable.destination)) {
|
|
532
717
|
throw new Error(`WarpFastsetExecutor: Invalid contract address for query: ${executable.destination}`);
|
|
533
718
|
}
|
|
534
719
|
try {
|
|
535
|
-
const contractAddress = fromBase64(executable.destination);
|
|
720
|
+
const contractAddress = this.fromBase64(executable.destination);
|
|
536
721
|
const result = await this.executeFastsetQuery(contractAddress, action.func, executable.args);
|
|
537
722
|
return {
|
|
538
723
|
success: true,
|
|
@@ -548,57 +733,7 @@ var WarpFastsetExecutor = class {
|
|
|
548
733
|
}
|
|
549
734
|
}
|
|
550
735
|
async preprocessInput(chain, input, type, value) {
|
|
551
|
-
|
|
552
|
-
switch (type) {
|
|
553
|
-
case "address":
|
|
554
|
-
if (!isValidFastsetAddress(typedValue)) {
|
|
555
|
-
throw new Error(`Invalid Fastset address format: ${typedValue}`);
|
|
556
|
-
}
|
|
557
|
-
return typedValue;
|
|
558
|
-
case "hex":
|
|
559
|
-
const hexValue = typedValue.startsWith("0x") ? typedValue.slice(2) : typedValue;
|
|
560
|
-
if (!/^[0-9a-fA-F]+$/.test(hexValue)) {
|
|
561
|
-
throw new Error(`Invalid hex format: ${typedValue}`);
|
|
562
|
-
}
|
|
563
|
-
return typedValue;
|
|
564
|
-
case "number":
|
|
565
|
-
const numValue = Number(typedValue);
|
|
566
|
-
if (isNaN(numValue)) {
|
|
567
|
-
throw new Error(`Invalid number format: ${typedValue}`);
|
|
568
|
-
}
|
|
569
|
-
return numValue.toString();
|
|
570
|
-
case "biguint":
|
|
571
|
-
const bigIntValue = BigInt(typedValue);
|
|
572
|
-
if (bigIntValue < 0) {
|
|
573
|
-
throw new Error(`Negative value not allowed`);
|
|
574
|
-
}
|
|
575
|
-
return bigIntValue.toString();
|
|
576
|
-
default:
|
|
577
|
-
return String(typedValue);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
encodeFunctionData(functionName, args) {
|
|
581
|
-
return JSON.stringify({
|
|
582
|
-
function: functionName,
|
|
583
|
-
arguments: args
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
async executeFastsetQuery(contractAddress, functionName, args) {
|
|
587
|
-
const response = await fetch(`${getFastsetApiUrl(this.config.env, "fastset")}/query`, {
|
|
588
|
-
method: "POST",
|
|
589
|
-
headers: {
|
|
590
|
-
"Content-Type": "application/json"
|
|
591
|
-
},
|
|
592
|
-
body: JSON.stringify({
|
|
593
|
-
contract: Array.from(contractAddress),
|
|
594
|
-
function: functionName,
|
|
595
|
-
arguments: args
|
|
596
|
-
})
|
|
597
|
-
});
|
|
598
|
-
if (!response.ok) {
|
|
599
|
-
throw new Error(`Fastset query failed: ${response.statusText}`);
|
|
600
|
-
}
|
|
601
|
-
return response.json();
|
|
736
|
+
return value;
|
|
602
737
|
}
|
|
603
738
|
async signMessage(message, privateKey) {
|
|
604
739
|
throw new Error("Not implemented");
|
|
@@ -618,7 +753,7 @@ var WarpFastsetExecutor = class {
|
|
|
618
753
|
const userWallet = this.config.user?.wallets?.[executable.chain.name];
|
|
619
754
|
if (!userWallet) throw new Error("WarpFastsetExecutor: executeTransfer - user wallet not set");
|
|
620
755
|
const transaction = await this.createTransferTransaction(executable);
|
|
621
|
-
const privateKeyBytes = fromBase64(privateKey);
|
|
756
|
+
const privateKeyBytes = this.fromBase64(privateKey);
|
|
622
757
|
const transactionHash = await this.fastsetClient.executeTransfer(
|
|
623
758
|
privateKeyBytes,
|
|
624
759
|
transaction.recipient,
|
|
@@ -631,35 +766,70 @@ var WarpFastsetExecutor = class {
|
|
|
631
766
|
chain: executable.chain.name
|
|
632
767
|
};
|
|
633
768
|
}
|
|
769
|
+
encodeFunctionData(functionName, args) {
|
|
770
|
+
return JSON.stringify({
|
|
771
|
+
function: functionName,
|
|
772
|
+
arguments: args
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
async executeFastsetQuery(contractAddress, functionName, args) {
|
|
776
|
+
const validatorUrl = getProviderUrl(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
777
|
+
const response = await fetch(`${validatorUrl}/query`, {
|
|
778
|
+
method: "POST",
|
|
779
|
+
headers: {
|
|
780
|
+
"Content-Type": "application/json"
|
|
781
|
+
},
|
|
782
|
+
body: JSON.stringify({
|
|
783
|
+
contract: Array.from(contractAddress),
|
|
784
|
+
function: functionName,
|
|
785
|
+
arguments: args
|
|
786
|
+
})
|
|
787
|
+
});
|
|
788
|
+
if (!response.ok) {
|
|
789
|
+
throw new Error(`Fastset query failed: ${response.statusText}`);
|
|
790
|
+
}
|
|
791
|
+
return response.json();
|
|
792
|
+
}
|
|
793
|
+
isValidFastsetAddress(address) {
|
|
794
|
+
if (typeof address !== "string" || address.length === 0) {
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
if (address.startsWith("fs") || address.startsWith("pi")) {
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
try {
|
|
801
|
+
const decoded = this.fromBase64(address);
|
|
802
|
+
return decoded.length === 32;
|
|
803
|
+
} catch {
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
fromBase64(base64) {
|
|
808
|
+
return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
|
809
|
+
}
|
|
810
|
+
normalizeAmount(amount) {
|
|
811
|
+
return amount.startsWith("0x") ? amount.slice(2) : amount;
|
|
812
|
+
}
|
|
634
813
|
};
|
|
635
814
|
|
|
636
815
|
// src/WarpFastsetExplorer.ts
|
|
637
816
|
var WarpFastsetExplorer = class {
|
|
638
|
-
constructor(
|
|
639
|
-
this.
|
|
817
|
+
constructor(_chainInfo, _config) {
|
|
818
|
+
this._chainInfo = _chainInfo;
|
|
819
|
+
this._config = _config;
|
|
820
|
+
this.explorerUrl = "https://explorer.fastset.xyz";
|
|
640
821
|
}
|
|
641
822
|
getAccountUrl(address) {
|
|
642
|
-
|
|
643
|
-
return `${baseUrl}/address/${address}`;
|
|
823
|
+
return `${this.explorerUrl}/account/${address}`;
|
|
644
824
|
}
|
|
645
825
|
getTransactionUrl(hash) {
|
|
646
|
-
|
|
647
|
-
return `${baseUrl}/tx/${hash}`;
|
|
648
|
-
}
|
|
649
|
-
getBlockUrl(blockNumber) {
|
|
650
|
-
const baseUrl = this.getDefaultExplorerUrl();
|
|
651
|
-
return `${baseUrl}/block/${blockNumber}`;
|
|
652
|
-
}
|
|
653
|
-
getContractUrl(address) {
|
|
654
|
-
const baseUrl = this.getDefaultExplorerUrl();
|
|
655
|
-
return `${baseUrl}/contract/${address}`;
|
|
826
|
+
return `${this.explorerUrl}/transaction/${hash}`;
|
|
656
827
|
}
|
|
657
828
|
getAssetUrl(identifier) {
|
|
658
|
-
|
|
659
|
-
return `${baseUrl}/token/${identifier}`;
|
|
829
|
+
return `${this.explorerUrl}/asset/${identifier}`;
|
|
660
830
|
}
|
|
661
|
-
|
|
662
|
-
return
|
|
831
|
+
getContractUrl(address) {
|
|
832
|
+
return `${this.explorerUrl}/account/${address}`;
|
|
663
833
|
}
|
|
664
834
|
};
|
|
665
835
|
|
|
@@ -670,26 +840,26 @@ import {
|
|
|
670
840
|
WarpConstants
|
|
671
841
|
} from "@vleap/warps";
|
|
672
842
|
var WarpFastsetResults = class {
|
|
673
|
-
constructor(config) {
|
|
843
|
+
constructor(config, chain) {
|
|
674
844
|
this.config = config;
|
|
845
|
+
this.chain = chain;
|
|
675
846
|
this.serializer = new WarpFastsetSerializer();
|
|
676
847
|
}
|
|
677
848
|
async getTransactionExecutionResults(warp, tx) {
|
|
678
849
|
const success = this.isTransactionSuccessful(tx);
|
|
679
|
-
const gasUsed = this.extractGasUsed(tx);
|
|
680
|
-
const gasPrice = this.extractGasPrice(tx);
|
|
681
|
-
const blockNumber = this.extractBlockNumber(tx);
|
|
682
850
|
const transactionHash = this.extractTransactionHash(tx);
|
|
683
|
-
const
|
|
851
|
+
const blockNumber = this.extractBlockNumber(tx);
|
|
852
|
+
const timestamp = this.extractTimestamp(tx);
|
|
684
853
|
return {
|
|
685
854
|
success,
|
|
686
855
|
warp,
|
|
687
856
|
action: 0,
|
|
688
|
-
user: this.config.user?.wallets?.
|
|
857
|
+
user: this.config.user?.wallets?.[this.chain.name] || null,
|
|
689
858
|
txHash: transactionHash,
|
|
690
859
|
tx,
|
|
691
860
|
next: null,
|
|
692
|
-
values: [transactionHash, blockNumber,
|
|
861
|
+
values: [transactionHash, blockNumber, timestamp],
|
|
862
|
+
valuesRaw: [transactionHash, blockNumber, timestamp],
|
|
693
863
|
results: {},
|
|
694
864
|
messages: {}
|
|
695
865
|
};
|
|
@@ -700,6 +870,11 @@ var WarpFastsetResults = class {
|
|
|
700
870
|
let results = {};
|
|
701
871
|
if (!warp.results) return { values, results };
|
|
702
872
|
const getNestedValue = (path) => {
|
|
873
|
+
const match = path.match(/^out\[(\d+)\]$/);
|
|
874
|
+
if (match) {
|
|
875
|
+
const index = parseInt(match[1]) - 1;
|
|
876
|
+
return valuesRaw[index];
|
|
877
|
+
}
|
|
703
878
|
const indices = path.split(".").slice(1).map((i) => parseInt(i) - 1);
|
|
704
879
|
if (indices.length === 0) return void 0;
|
|
705
880
|
let value = valuesRaw[indices[0]];
|
|
@@ -717,7 +892,8 @@ var WarpFastsetResults = class {
|
|
|
717
892
|
continue;
|
|
718
893
|
}
|
|
719
894
|
if (path.startsWith("out.") || path === "out" || path.startsWith("out[")) {
|
|
720
|
-
|
|
895
|
+
const value = getNestedValue(path);
|
|
896
|
+
results[key] = value || null;
|
|
721
897
|
} else {
|
|
722
898
|
results[key] = path;
|
|
723
899
|
}
|
|
@@ -725,71 +901,92 @@ var WarpFastsetResults = class {
|
|
|
725
901
|
return { values, results: await evaluateResultsCommon(warp, results, actionIndex, inputs, this.config.transform?.runner) };
|
|
726
902
|
}
|
|
727
903
|
isTransactionSuccessful(tx) {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
904
|
+
if (!tx) return false;
|
|
905
|
+
if (tx.success === false) return false;
|
|
906
|
+
if (tx.success === true) return true;
|
|
907
|
+
if (tx.status === "success") return true;
|
|
908
|
+
if (tx.status === 1) return true;
|
|
909
|
+
if (tx.result && tx.result.success === true) return true;
|
|
910
|
+
return false;
|
|
732
911
|
}
|
|
733
|
-
|
|
734
|
-
|
|
912
|
+
extractTransactionHash(tx) {
|
|
913
|
+
if (!tx) return "";
|
|
914
|
+
return tx.transaction_hash || tx.transactionHash || tx.hash || tx.result && tx.result.transaction_hash || "";
|
|
735
915
|
}
|
|
736
916
|
extractBlockNumber(tx) {
|
|
737
|
-
|
|
917
|
+
if (!tx) return "0";
|
|
918
|
+
return tx.block_number?.toString() || tx.blockNumber?.toString() || tx.result && tx.result.block_number?.toString() || "0";
|
|
738
919
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
extractLogs(tx) {
|
|
743
|
-
const logs = tx.logs || tx.events || [];
|
|
744
|
-
return logs.map((log) => ({
|
|
745
|
-
address: log.address || log.contract,
|
|
746
|
-
topics: log.topics || log.topics || [],
|
|
747
|
-
data: log.data || log.payload || "",
|
|
748
|
-
blockNumber: log.blockNumber?.toString() || log.block_number?.toString() || "0",
|
|
749
|
-
transactionHash: log.transactionHash || log.transaction_hash || "",
|
|
750
|
-
index: log.index?.toString() || "0"
|
|
751
|
-
}));
|
|
920
|
+
extractTimestamp(tx) {
|
|
921
|
+
if (!tx) return "0";
|
|
922
|
+
return tx.timestamp?.toString() || tx.timestamp_nanos?.toString() || tx.result && tx.result.timestamp?.toString() || Date.now().toString();
|
|
752
923
|
}
|
|
753
924
|
};
|
|
754
925
|
|
|
755
926
|
// src/main.ts
|
|
756
|
-
var ChainName = "fastset";
|
|
757
927
|
var NativeTokenSet = {
|
|
928
|
+
chain: WarpChainName.Fastset,
|
|
758
929
|
identifier: "SET",
|
|
759
930
|
name: "SET",
|
|
760
|
-
decimals:
|
|
931
|
+
decimals: 6,
|
|
761
932
|
logoUrl: "https://vleap.ai/images/tokens/set.svg"
|
|
762
933
|
};
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
registry: fallback.registry,
|
|
783
|
-
explorer: new WarpFastsetExplorer(ChainInfo),
|
|
784
|
-
abiBuilder: () => fallback.abiBuilder(),
|
|
785
|
-
brandBuilder: () => fallback.brandBuilder(),
|
|
786
|
-
dataLoader: new WarpFastsetDataLoader(config, ChainInfo)
|
|
934
|
+
function createFastsetAdapter(chainName, chainPrefix, chainInfos) {
|
|
935
|
+
return (config, fallback) => {
|
|
936
|
+
const chainInfo = chainInfos[config.env];
|
|
937
|
+
if (!chainInfo) throw new Error(`FastsetAdapter: chain info not found for chain ${chainName}`);
|
|
938
|
+
if (!fallback) throw new Error("Fastset adapter requires a fallback adapter");
|
|
939
|
+
return {
|
|
940
|
+
chain: chainName,
|
|
941
|
+
chainInfo,
|
|
942
|
+
prefix: chainPrefix,
|
|
943
|
+
builder: () => fallback.builder(),
|
|
944
|
+
executor: new WarpFastsetExecutor(config, chainInfo),
|
|
945
|
+
results: new WarpFastsetResults(config, chainInfo),
|
|
946
|
+
serializer: new WarpFastsetSerializer(),
|
|
947
|
+
registry: fallback.registry,
|
|
948
|
+
explorer: new WarpFastsetExplorer(chainInfo, config),
|
|
949
|
+
abiBuilder: () => fallback.abiBuilder(),
|
|
950
|
+
brandBuilder: () => fallback.brandBuilder(),
|
|
951
|
+
dataLoader: new WarpFastsetDataLoader(config, chainInfo)
|
|
952
|
+
};
|
|
787
953
|
};
|
|
788
|
-
}
|
|
954
|
+
}
|
|
955
|
+
var getFastsetAdapter = createFastsetAdapter(WarpChainName.Fastset, "fastset", {
|
|
956
|
+
mainnet: {
|
|
957
|
+
name: WarpChainName.Fastset,
|
|
958
|
+
displayName: "FastSet",
|
|
959
|
+
chainId: "1",
|
|
960
|
+
blockTime: 1e3,
|
|
961
|
+
addressHrp: "set",
|
|
962
|
+
defaultApiUrl: "https://rpc.fastset.xyz",
|
|
963
|
+
nativeToken: NativeTokenSet
|
|
964
|
+
},
|
|
965
|
+
testnet: {
|
|
966
|
+
name: WarpChainName.Fastset,
|
|
967
|
+
displayName: "FastSet Testnet",
|
|
968
|
+
chainId: "testnet",
|
|
969
|
+
blockTime: 1e3,
|
|
970
|
+
addressHrp: "set",
|
|
971
|
+
defaultApiUrl: "https://rpc.fastset.xyz",
|
|
972
|
+
nativeToken: NativeTokenSet
|
|
973
|
+
},
|
|
974
|
+
devnet: {
|
|
975
|
+
name: WarpChainName.Fastset,
|
|
976
|
+
displayName: "FastSet Devnet",
|
|
977
|
+
chainId: "devnet",
|
|
978
|
+
blockTime: 1e3,
|
|
979
|
+
addressHrp: "set",
|
|
980
|
+
defaultApiUrl: "https://rpc.fastset.xyz",
|
|
981
|
+
nativeToken: NativeTokenSet
|
|
982
|
+
}
|
|
983
|
+
});
|
|
789
984
|
export {
|
|
790
985
|
Address,
|
|
791
986
|
Amount,
|
|
987
|
+
BcsTransaction,
|
|
792
988
|
Bytes32,
|
|
989
|
+
Claim,
|
|
793
990
|
ClaimType,
|
|
794
991
|
FastsetClient,
|
|
795
992
|
NativeTokenSet,
|
|
@@ -797,22 +994,15 @@ export {
|
|
|
797
994
|
PublicKey,
|
|
798
995
|
Transaction,
|
|
799
996
|
Transfer,
|
|
997
|
+
TransferClaim,
|
|
800
998
|
UserData,
|
|
999
|
+
Wallet,
|
|
801
1000
|
WarpFastsetConstants,
|
|
1001
|
+
WarpFastsetDataLoader,
|
|
802
1002
|
WarpFastsetExecutor,
|
|
803
1003
|
WarpFastsetExplorer,
|
|
804
1004
|
WarpFastsetResults,
|
|
805
1005
|
WarpFastsetSerializer,
|
|
806
|
-
|
|
807
|
-
fromBase64,
|
|
808
|
-
getFastsetAdapter,
|
|
809
|
-
hexToDecimal2 as hexToDecimal,
|
|
810
|
-
isValidFastsetAddress,
|
|
811
|
-
normalizeAmount,
|
|
812
|
-
toBase64String,
|
|
813
|
-
toHexString,
|
|
814
|
-
validateAmount,
|
|
815
|
-
validatePrivateKey,
|
|
816
|
-
validatePublicKey
|
|
1006
|
+
getFastsetAdapter
|
|
817
1007
|
};
|
|
818
1008
|
//# sourceMappingURL=index.mjs.map
|