@vleap/warps-adapter-near 0.1.0-beta.12 → 0.1.0-beta.13
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 +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +77 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WarpChainAsset, ChainAdapterFactory,
|
|
1
|
+
import { WarpChainAsset, ChainAdapterFactory, WarpChainName, WarpChainEnv, AdapterWarpDataLoader, WarpClientConfig, WarpChainInfo, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecutionResult, AdapterWarpExplorer, AdapterWarpOutput, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionOutput, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction, WarpWalletDetails, WarpWalletProvider } from '@vleap/warps';
|
|
2
2
|
|
|
3
3
|
declare const NativeTokenNear: WarpChainAsset;
|
|
4
4
|
declare const NearAdapter: ChainAdapterFactory;
|
|
@@ -36,9 +36,9 @@ declare const NearExplorerNames: {
|
|
|
36
36
|
declare const NearExplorerUrls: Record<ExplorerName, string>;
|
|
37
37
|
|
|
38
38
|
declare const NearTokens: WarpChainAsset[];
|
|
39
|
-
declare const KnownTokens: Record<
|
|
40
|
-
declare const findKnownTokenById: (chain:
|
|
41
|
-
declare const getKnownTokensForChain: (chainName:
|
|
39
|
+
declare const KnownTokens: Partial<Record<WarpChainName, Record<string, WarpChainAsset[]>>>;
|
|
40
|
+
declare const findKnownTokenById: (chain: WarpChainName, env: WarpChainEnv, id: string) => WarpChainAsset | null;
|
|
41
|
+
declare const getKnownTokensForChain: (chainName: WarpChainName, env?: string) => WarpChainAsset[];
|
|
42
42
|
|
|
43
43
|
declare class WarpNearDataLoader implements AdapterWarpDataLoader {
|
|
44
44
|
private readonly config;
|
|
@@ -140,8 +140,8 @@ declare class WarpNearWallet implements AdapterWarpWallet {
|
|
|
140
140
|
signMessage(message: string): Promise<string>;
|
|
141
141
|
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
142
142
|
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
143
|
-
importFromMnemonic(
|
|
144
|
-
importFromPrivateKey(
|
|
143
|
+
importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails>;
|
|
144
|
+
importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
|
|
145
145
|
export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
146
146
|
generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
147
147
|
getAddress(): string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WarpChainAsset, ChainAdapterFactory,
|
|
1
|
+
import { WarpChainAsset, ChainAdapterFactory, WarpChainName, WarpChainEnv, AdapterWarpDataLoader, WarpClientConfig, WarpChainInfo, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecutionResult, AdapterWarpExplorer, AdapterWarpOutput, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionOutput, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction, WarpWalletDetails, WarpWalletProvider } from '@vleap/warps';
|
|
2
2
|
|
|
3
3
|
declare const NativeTokenNear: WarpChainAsset;
|
|
4
4
|
declare const NearAdapter: ChainAdapterFactory;
|
|
@@ -36,9 +36,9 @@ declare const NearExplorerNames: {
|
|
|
36
36
|
declare const NearExplorerUrls: Record<ExplorerName, string>;
|
|
37
37
|
|
|
38
38
|
declare const NearTokens: WarpChainAsset[];
|
|
39
|
-
declare const KnownTokens: Record<
|
|
40
|
-
declare const findKnownTokenById: (chain:
|
|
41
|
-
declare const getKnownTokensForChain: (chainName:
|
|
39
|
+
declare const KnownTokens: Partial<Record<WarpChainName, Record<string, WarpChainAsset[]>>>;
|
|
40
|
+
declare const findKnownTokenById: (chain: WarpChainName, env: WarpChainEnv, id: string) => WarpChainAsset | null;
|
|
41
|
+
declare const getKnownTokensForChain: (chainName: WarpChainName, env?: string) => WarpChainAsset[];
|
|
42
42
|
|
|
43
43
|
declare class WarpNearDataLoader implements AdapterWarpDataLoader {
|
|
44
44
|
private readonly config;
|
|
@@ -140,8 +140,8 @@ declare class WarpNearWallet implements AdapterWarpWallet {
|
|
|
140
140
|
signMessage(message: string): Promise<string>;
|
|
141
141
|
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
142
142
|
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
143
|
-
importFromMnemonic(
|
|
144
|
-
importFromPrivateKey(
|
|
143
|
+
importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails>;
|
|
144
|
+
importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
|
|
145
145
|
export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
146
146
|
generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
147
147
|
getAddress(): string | null;
|
package/dist/index.js
CHANGED
|
@@ -51,8 +51,11 @@ __export(index_exports, {
|
|
|
51
51
|
});
|
|
52
52
|
module.exports = __toCommonJS(index_exports);
|
|
53
53
|
|
|
54
|
+
// src/chains/near.ts
|
|
55
|
+
var import_warps10 = require("@vleap/warps");
|
|
56
|
+
|
|
54
57
|
// src/WarpNearDataLoader.ts
|
|
55
|
-
var
|
|
58
|
+
var import_warps2 = require("@vleap/warps");
|
|
56
59
|
var import_near_api_js = require("near-api-js");
|
|
57
60
|
|
|
58
61
|
// src/constants.ts
|
|
@@ -93,9 +96,10 @@ var NearExplorerNames = {
|
|
|
93
96
|
var NearExplorerUrls = ExplorerUrls;
|
|
94
97
|
|
|
95
98
|
// src/tokens.ts
|
|
99
|
+
var import_warps = require("@vleap/warps");
|
|
96
100
|
var NearTokens = [];
|
|
97
101
|
var KnownTokens = {
|
|
98
|
-
|
|
102
|
+
[import_warps.WarpChainName.Near]: {
|
|
99
103
|
mainnet: NearTokens,
|
|
100
104
|
testnet: NearTokens,
|
|
101
105
|
devnet: NearTokens
|
|
@@ -114,8 +118,8 @@ var WarpNearDataLoader = class {
|
|
|
114
118
|
constructor(config, chain) {
|
|
115
119
|
this.config = config;
|
|
116
120
|
this.chain = chain;
|
|
117
|
-
this.cache = new
|
|
118
|
-
const providerConfig = (0,
|
|
121
|
+
this.cache = new import_warps2.WarpCache(config.cache?.type);
|
|
122
|
+
const providerConfig = (0, import_warps2.getProviderConfig)(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
119
123
|
this.nearConfig = {
|
|
120
124
|
networkId: this.config.env === "mainnet" ? "mainnet" : this.config.env === "testnet" ? "testnet" : "testnet",
|
|
121
125
|
nodeUrl: providerConfig.url,
|
|
@@ -171,7 +175,7 @@ var WarpNearDataLoader = class {
|
|
|
171
175
|
if (identifier === this.chain.nativeToken.identifier || identifier === WarpNearConstants.NativeToken.Identifier) {
|
|
172
176
|
return this.chain.nativeToken;
|
|
173
177
|
}
|
|
174
|
-
const cacheKey =
|
|
178
|
+
const cacheKey = import_warps2.WarpCacheKey.Asset(this.config.env, this.chain.name, identifier);
|
|
175
179
|
const cachedAsset = this.cache.get(cacheKey);
|
|
176
180
|
if (cachedAsset) {
|
|
177
181
|
return cachedAsset;
|
|
@@ -206,7 +210,7 @@ var WarpNearDataLoader = class {
|
|
|
206
210
|
decimals: metadata.decimals || WarpNearConstants.NativeToken.Decimals,
|
|
207
211
|
logoUrl: metadata.icon || ""
|
|
208
212
|
};
|
|
209
|
-
this.cache.set(cacheKey, asset,
|
|
213
|
+
this.cache.set(cacheKey, asset, import_warps2.CacheTtl.OneHour);
|
|
210
214
|
return asset;
|
|
211
215
|
} catch {
|
|
212
216
|
const asset = {
|
|
@@ -259,18 +263,18 @@ var WarpNearDataLoader = class {
|
|
|
259
263
|
};
|
|
260
264
|
|
|
261
265
|
// src/WarpNearExecutor.ts
|
|
262
|
-
var
|
|
266
|
+
var import_warps5 = require("@vleap/warps");
|
|
263
267
|
var import_near_api_js3 = require("near-api-js");
|
|
264
268
|
|
|
265
269
|
// src/WarpNearOutput.ts
|
|
266
|
-
var
|
|
270
|
+
var import_warps4 = require("@vleap/warps");
|
|
267
271
|
var import_near_api_js2 = require("near-api-js");
|
|
268
272
|
|
|
269
273
|
// src/WarpNearSerializer.ts
|
|
270
|
-
var
|
|
274
|
+
var import_warps3 = require("@vleap/warps");
|
|
271
275
|
var WarpNearSerializer = class {
|
|
272
276
|
constructor() {
|
|
273
|
-
this.coreSerializer = new
|
|
277
|
+
this.coreSerializer = new import_warps3.WarpSerializer();
|
|
274
278
|
}
|
|
275
279
|
typedToString(value) {
|
|
276
280
|
if (typeof value === "string") {
|
|
@@ -303,15 +307,15 @@ var WarpNearSerializer = class {
|
|
|
303
307
|
if (typeof value === "object" && value !== null && "identifier" in value && "amount" in value) {
|
|
304
308
|
const asset = value;
|
|
305
309
|
if (asset.decimals !== void 0) {
|
|
306
|
-
return `asset:${asset.identifier}${
|
|
310
|
+
return `asset:${asset.identifier}${import_warps3.WarpConstants.ArgCompositeSeparator}${asset.amount.toString()}${import_warps3.WarpConstants.ArgCompositeSeparator}${asset.decimals}`;
|
|
307
311
|
}
|
|
308
|
-
return `asset:${asset.identifier}${
|
|
312
|
+
return `asset:${asset.identifier}${import_warps3.WarpConstants.ArgCompositeSeparator}${asset.amount.toString()}`;
|
|
309
313
|
}
|
|
310
314
|
if (Array.isArray(value)) {
|
|
311
315
|
if (value.length === 0) return `list:string:`;
|
|
312
|
-
const types = value.map((item) => this.typedToString(item).split(
|
|
316
|
+
const types = value.map((item) => this.typedToString(item).split(import_warps3.WarpConstants.ArgParamsSeparator)[0]);
|
|
313
317
|
const type = types[0];
|
|
314
|
-
const values = value.map((item) => this.typedToString(item).split(
|
|
318
|
+
const values = value.map((item) => this.typedToString(item).split(import_warps3.WarpConstants.ArgParamsSeparator)[1]);
|
|
315
319
|
return `list:${type}:${values.join(",")}`;
|
|
316
320
|
}
|
|
317
321
|
if (value === null || value === void 0) {
|
|
@@ -321,8 +325,8 @@ var WarpNearSerializer = class {
|
|
|
321
325
|
}
|
|
322
326
|
typedToNative(value) {
|
|
323
327
|
const stringValue = this.typedToString(value);
|
|
324
|
-
const [type, ...valueParts] = stringValue.split(
|
|
325
|
-
const nativeValue = valueParts.join(
|
|
328
|
+
const [type, ...valueParts] = stringValue.split(import_warps3.WarpConstants.ArgParamsSeparator);
|
|
329
|
+
const nativeValue = valueParts.join(import_warps3.WarpConstants.ArgParamsSeparator);
|
|
326
330
|
return [type, this.parseNativeValue(type, nativeValue)];
|
|
327
331
|
}
|
|
328
332
|
nativeToTyped(type, value) {
|
|
@@ -378,7 +382,7 @@ var WarpNearSerializer = class {
|
|
|
378
382
|
}
|
|
379
383
|
}
|
|
380
384
|
stringToTyped(value) {
|
|
381
|
-
const parts = value.split(
|
|
385
|
+
const parts = value.split(import_warps3.WarpConstants.ArgParamsSeparator, 2);
|
|
382
386
|
if (parts.length < 2) {
|
|
383
387
|
return value;
|
|
384
388
|
}
|
|
@@ -400,7 +404,7 @@ var WarpNearSerializer = class {
|
|
|
400
404
|
case "hex":
|
|
401
405
|
return stringValue;
|
|
402
406
|
case "asset":
|
|
403
|
-
const assetParts = stringValue.split(
|
|
407
|
+
const assetParts = stringValue.split(import_warps3.WarpConstants.ArgCompositeSeparator);
|
|
404
408
|
const identifier = assetParts[0] || "";
|
|
405
409
|
const amount = assetParts[1] ? BigInt(assetParts[1]) : 0n;
|
|
406
410
|
const decimals = assetParts[2] ? parseInt(assetParts[2], 10) : void 0;
|
|
@@ -443,17 +447,17 @@ var WarpNearOutput = class {
|
|
|
443
447
|
this.config = config;
|
|
444
448
|
this.chain = chain;
|
|
445
449
|
this.serializer = new WarpNearSerializer();
|
|
446
|
-
const providerConfig = (0,
|
|
450
|
+
const providerConfig = (0, import_warps4.getProviderConfig)(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
447
451
|
this.nearConfig = {
|
|
448
452
|
networkId: this.config.env === "mainnet" ? "mainnet" : this.config.env === "testnet" ? "testnet" : "testnet",
|
|
449
453
|
nodeUrl: providerConfig.url,
|
|
450
454
|
keyStore: new import_near_api_js2.keyStores.InMemoryKeyStore()
|
|
451
455
|
};
|
|
452
|
-
this.cache = new
|
|
456
|
+
this.cache = new import_warps4.WarpCache(config.cache?.type);
|
|
453
457
|
}
|
|
454
458
|
async getActionExecution(warp, actionIndex, tx) {
|
|
455
|
-
const inputs = this.cache.get(
|
|
456
|
-
const resolvedInputs = (0,
|
|
459
|
+
const inputs = this.cache.get(import_warps4.WarpCacheKey.WarpExecutable(this.config.env, warp.meta?.hash || "", actionIndex)) ?? [];
|
|
460
|
+
const resolvedInputs = (0, import_warps4.extractResolvedInputValues)(inputs);
|
|
457
461
|
if (!tx) {
|
|
458
462
|
return this.createFailedExecution(warp, actionIndex, resolvedInputs);
|
|
459
463
|
}
|
|
@@ -470,7 +474,7 @@ var WarpNearOutput = class {
|
|
|
470
474
|
status: "error",
|
|
471
475
|
warp,
|
|
472
476
|
action: actionIndex,
|
|
473
|
-
user: (0,
|
|
477
|
+
user: (0, import_warps4.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
|
|
474
478
|
txHash: "",
|
|
475
479
|
tx: null,
|
|
476
480
|
next: null,
|
|
@@ -490,7 +494,7 @@ var WarpNearOutput = class {
|
|
|
490
494
|
status: success ? "success" : "error",
|
|
491
495
|
warp,
|
|
492
496
|
action: actionIndex,
|
|
493
|
-
user: (0,
|
|
497
|
+
user: (0, import_warps4.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
|
|
494
498
|
txHash: transactionHash,
|
|
495
499
|
tx,
|
|
496
500
|
next: null,
|
|
@@ -517,7 +521,7 @@ var WarpNearOutput = class {
|
|
|
517
521
|
status: success ? "success" : "error",
|
|
518
522
|
warp,
|
|
519
523
|
action: actionIndex,
|
|
520
|
-
user: (0,
|
|
524
|
+
user: (0, import_warps4.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
|
|
521
525
|
txHash: hash,
|
|
522
526
|
tx: {
|
|
523
527
|
hash,
|
|
@@ -552,8 +556,8 @@ var WarpNearOutput = class {
|
|
|
552
556
|
return value;
|
|
553
557
|
};
|
|
554
558
|
for (const [key, path] of Object.entries(warp.output)) {
|
|
555
|
-
if (path.startsWith(
|
|
556
|
-
const currentActionIndex = (0,
|
|
559
|
+
if (path.startsWith(import_warps4.WarpConstants.Transform.Prefix)) continue;
|
|
560
|
+
const currentActionIndex = (0, import_warps4.parseOutputOutIndex)(path);
|
|
557
561
|
if (currentActionIndex !== null && currentActionIndex !== actionIndex) {
|
|
558
562
|
output[key] = null;
|
|
559
563
|
continue;
|
|
@@ -564,7 +568,7 @@ var WarpNearOutput = class {
|
|
|
564
568
|
output[key] = path;
|
|
565
569
|
}
|
|
566
570
|
}
|
|
567
|
-
return { values, output: await (0,
|
|
571
|
+
return { values, output: await (0, import_warps4.evaluateOutputCommon)(warp, output, actionIndex, inputs, this.serializer.coreSerializer, this.config) };
|
|
568
572
|
}
|
|
569
573
|
async getTransactionStatus(txHash) {
|
|
570
574
|
try {
|
|
@@ -608,7 +612,7 @@ var WarpNearExecutor = class {
|
|
|
608
612
|
this.config = config;
|
|
609
613
|
this.chain = chain;
|
|
610
614
|
this.serializer = new WarpNearSerializer();
|
|
611
|
-
const providerConfig = (0,
|
|
615
|
+
const providerConfig = (0, import_warps5.getProviderConfig)(this.config, chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
612
616
|
this.nearConfig = {
|
|
613
617
|
networkId: this.config.env === "mainnet" ? "mainnet" : this.config.env === "testnet" ? "testnet" : "testnet",
|
|
614
618
|
nodeUrl: providerConfig.url,
|
|
@@ -617,7 +621,7 @@ var WarpNearExecutor = class {
|
|
|
617
621
|
this.output = new WarpNearOutput(config, this.chain);
|
|
618
622
|
}
|
|
619
623
|
async createTransaction(executable) {
|
|
620
|
-
const action = (0,
|
|
624
|
+
const action = (0, import_warps5.getWarpActionByIndex)(executable.warp, executable.action);
|
|
621
625
|
let tx = null;
|
|
622
626
|
if (action.type === "transfer") {
|
|
623
627
|
tx = await this.createTransferTransaction(executable);
|
|
@@ -632,7 +636,7 @@ var WarpNearExecutor = class {
|
|
|
632
636
|
return tx;
|
|
633
637
|
}
|
|
634
638
|
async createTransferTransaction(executable) {
|
|
635
|
-
const userWallet = (0,
|
|
639
|
+
const userWallet = (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
|
|
636
640
|
if (!userWallet) throw new Error("WarpNearExecutor: createTransfer - user address not set");
|
|
637
641
|
if (!executable.destination) throw new Error("WarpNearExecutor: Destination address is required");
|
|
638
642
|
if (executable.transfers && executable.transfers.length > 0) {
|
|
@@ -653,9 +657,9 @@ var WarpNearExecutor = class {
|
|
|
653
657
|
};
|
|
654
658
|
}
|
|
655
659
|
async createContractCallTransaction(executable) {
|
|
656
|
-
const userWallet = (0,
|
|
660
|
+
const userWallet = (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
|
|
657
661
|
if (!userWallet) throw new Error("WarpNearExecutor: createContractCall - user address not set");
|
|
658
|
-
const action = (0,
|
|
662
|
+
const action = (0, import_warps5.getWarpActionByIndex)(executable.warp, executable.action);
|
|
659
663
|
if (!action || !("func" in action) || !action.func) throw new Error("WarpNearExecutor: Contract action must have a function name");
|
|
660
664
|
if (!executable.destination) throw new Error("WarpNearExecutor: Contract address is required");
|
|
661
665
|
try {
|
|
@@ -714,7 +718,7 @@ var WarpNearExecutor = class {
|
|
|
714
718
|
}
|
|
715
719
|
async createSingleTokenTransfer(executable, transfer) {
|
|
716
720
|
if (!executable.destination) throw new Error("WarpNearExecutor: Destination address is required");
|
|
717
|
-
const userWallet = (0,
|
|
721
|
+
const userWallet = (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
|
|
718
722
|
if (!userWallet) throw new Error("WarpNearExecutor: User wallet not set");
|
|
719
723
|
const args = {
|
|
720
724
|
receiver_id: executable.destination,
|
|
@@ -736,7 +740,7 @@ var WarpNearExecutor = class {
|
|
|
736
740
|
};
|
|
737
741
|
}
|
|
738
742
|
async executeQuery(executable) {
|
|
739
|
-
const action = (0,
|
|
743
|
+
const action = (0, import_warps5.getWarpActionByIndex)(executable.warp, executable.action);
|
|
740
744
|
if (action.type !== "query") throw new Error(`WarpNearExecutor: Invalid action type for executeQuery: ${action.type}`);
|
|
741
745
|
if (!action.func) throw new Error("WarpNearExecutor: Query action must have a function name");
|
|
742
746
|
let queryAddress;
|
|
@@ -762,21 +766,21 @@ var WarpNearExecutor = class {
|
|
|
762
766
|
executable.action,
|
|
763
767
|
executable.resolvedInputs
|
|
764
768
|
);
|
|
765
|
-
const next = (0,
|
|
769
|
+
const next = (0, import_warps5.getNextInfo)(this.config, [], executable.warp, executable.action, output);
|
|
766
770
|
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
767
771
|
const destination = destinationInput?.value || executable.destination;
|
|
768
|
-
const resolvedInputs = (0,
|
|
772
|
+
const resolvedInputs = (0, import_warps5.extractResolvedInputValues)(executable.resolvedInputs);
|
|
769
773
|
return {
|
|
770
774
|
status: "success",
|
|
771
775
|
warp: executable.warp,
|
|
772
776
|
action: executable.action,
|
|
773
|
-
user: (0,
|
|
777
|
+
user: (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name),
|
|
774
778
|
txHash: null,
|
|
775
779
|
tx: null,
|
|
776
780
|
next,
|
|
777
781
|
values,
|
|
778
782
|
output: { ...output, _DATA: result },
|
|
779
|
-
messages: (0,
|
|
783
|
+
messages: (0, import_warps5.applyOutputToMessages)(executable.warp, output, this.config),
|
|
780
784
|
destination,
|
|
781
785
|
resolvedInputs
|
|
782
786
|
};
|
|
@@ -784,12 +788,12 @@ var WarpNearExecutor = class {
|
|
|
784
788
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
785
789
|
const destinationInput = executable.resolvedInputs.find((i) => i.input.position === "receiver" || i.input.position === "destination");
|
|
786
790
|
const destination = destinationInput?.value || executable.destination;
|
|
787
|
-
const resolvedInputs = (0,
|
|
791
|
+
const resolvedInputs = (0, import_warps5.extractResolvedInputValues)(executable.resolvedInputs);
|
|
788
792
|
return {
|
|
789
793
|
status: "error",
|
|
790
794
|
warp: executable.warp,
|
|
791
795
|
action: executable.action,
|
|
792
|
-
user: (0,
|
|
796
|
+
user: (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, executable.chain.name),
|
|
793
797
|
txHash: null,
|
|
794
798
|
tx: null,
|
|
795
799
|
next: null,
|
|
@@ -929,14 +933,14 @@ var WarpNearExplorer = class {
|
|
|
929
933
|
};
|
|
930
934
|
|
|
931
935
|
// src/WarpNearWallet.ts
|
|
932
|
-
var
|
|
936
|
+
var import_warps9 = require("@vleap/warps");
|
|
933
937
|
var import_near_api_js6 = require("near-api-js");
|
|
934
938
|
|
|
935
939
|
// src/providers/MnemonicWalletProvider.ts
|
|
936
940
|
var import_crypto = require("@near-js/crypto");
|
|
937
941
|
var bip39 = __toESM(require("@scure/bip39"), 1);
|
|
938
942
|
var import_english = require("@scure/bip39/wordlists/english.js");
|
|
939
|
-
var
|
|
943
|
+
var import_warps6 = require("@vleap/warps");
|
|
940
944
|
var import_bs58 = __toESM(require("bs58"), 1);
|
|
941
945
|
var import_near_api_js4 = require("near-api-js");
|
|
942
946
|
var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
@@ -946,7 +950,7 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
946
950
|
this.keypair = null;
|
|
947
951
|
}
|
|
948
952
|
async getAddress() {
|
|
949
|
-
const address = (0,
|
|
953
|
+
const address = (0, import_warps6.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
950
954
|
if (address) return address;
|
|
951
955
|
try {
|
|
952
956
|
const keypair = this.getKeyPair();
|
|
@@ -990,7 +994,7 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
990
994
|
privateKey: keyPair.toString(),
|
|
991
995
|
mnemonic
|
|
992
996
|
};
|
|
993
|
-
(0,
|
|
997
|
+
(0, import_warps6.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
|
|
994
998
|
return walletDetails;
|
|
995
999
|
}
|
|
996
1000
|
async importFromPrivateKey(privateKey) {
|
|
@@ -1003,13 +1007,13 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
1003
1007
|
privateKey: keyPair.toString(),
|
|
1004
1008
|
mnemonic: null
|
|
1005
1009
|
};
|
|
1006
|
-
(0,
|
|
1010
|
+
(0, import_warps6.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
|
|
1007
1011
|
return walletDetails;
|
|
1008
1012
|
}
|
|
1009
1013
|
async export() {
|
|
1010
1014
|
const keypair = this.getKeyPair();
|
|
1011
|
-
const mnemonic = (0,
|
|
1012
|
-
const privateKey = (0,
|
|
1015
|
+
const mnemonic = (0, import_warps6.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
1016
|
+
const privateKey = (0, import_warps6.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
1013
1017
|
const publicKey = keypair.getPublicKey();
|
|
1014
1018
|
const accountId = (0, import_crypto.keyToImplicitAddress)(publicKey.toString());
|
|
1015
1019
|
return {
|
|
@@ -1035,7 +1039,7 @@ var _MnemonicWalletProvider = class _MnemonicWalletProvider {
|
|
|
1035
1039
|
}
|
|
1036
1040
|
getKeyPair() {
|
|
1037
1041
|
if (this.keypair) return this.keypair;
|
|
1038
|
-
const mnemonic = (0,
|
|
1042
|
+
const mnemonic = (0, import_warps6.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
1039
1043
|
if (!mnemonic) throw new Error("No mnemonic provided");
|
|
1040
1044
|
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
1041
1045
|
const secretKey = seed.slice(0, 32);
|
|
@@ -1049,7 +1053,7 @@ var MnemonicWalletProvider = _MnemonicWalletProvider;
|
|
|
1049
1053
|
// src/providers/PrivateKeyWalletProvider.ts
|
|
1050
1054
|
var import_crypto2 = require("@near-js/crypto");
|
|
1051
1055
|
var bip392 = __toESM(require("@scure/bip39"), 1);
|
|
1052
|
-
var
|
|
1056
|
+
var import_warps7 = require("@vleap/warps");
|
|
1053
1057
|
var import_bs582 = __toESM(require("bs58"), 1);
|
|
1054
1058
|
var import_near_api_js5 = require("near-api-js");
|
|
1055
1059
|
var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
@@ -1059,7 +1063,7 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
|
1059
1063
|
this.keypair = null;
|
|
1060
1064
|
}
|
|
1061
1065
|
async getAddress() {
|
|
1062
|
-
const address = (0,
|
|
1066
|
+
const address = (0, import_warps7.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1063
1067
|
if (address) return address;
|
|
1064
1068
|
try {
|
|
1065
1069
|
const keypair = this.getKeyPair();
|
|
@@ -1103,7 +1107,7 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
|
1103
1107
|
privateKey: keyPair.toString(),
|
|
1104
1108
|
mnemonic
|
|
1105
1109
|
};
|
|
1106
|
-
(0,
|
|
1110
|
+
(0, import_warps7.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
|
|
1107
1111
|
return walletDetails;
|
|
1108
1112
|
}
|
|
1109
1113
|
async importFromPrivateKey(privateKey) {
|
|
@@ -1116,13 +1120,13 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
|
1116
1120
|
privateKey: keyPair.toString(),
|
|
1117
1121
|
mnemonic: null
|
|
1118
1122
|
};
|
|
1119
|
-
(0,
|
|
1123
|
+
(0, import_warps7.setWarpWalletInConfig)(this.config, this.chain.name, walletDetails);
|
|
1120
1124
|
return walletDetails;
|
|
1121
1125
|
}
|
|
1122
1126
|
async export() {
|
|
1123
1127
|
const keypair = this.getKeyPair();
|
|
1124
|
-
const privateKey = (0,
|
|
1125
|
-
const mnemonic = (0,
|
|
1128
|
+
const privateKey = (0, import_warps7.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
1129
|
+
const mnemonic = (0, import_warps7.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
|
|
1126
1130
|
const publicKey = keypair.getPublicKey();
|
|
1127
1131
|
const accountId = (0, import_crypto2.keyToImplicitAddress)(publicKey.toString());
|
|
1128
1132
|
return {
|
|
@@ -1145,7 +1149,7 @@ var _PrivateKeyWalletProvider = class _PrivateKeyWalletProvider {
|
|
|
1145
1149
|
}
|
|
1146
1150
|
getKeyPair() {
|
|
1147
1151
|
if (this.keypair) return this.keypair;
|
|
1148
|
-
const privateKey = (0,
|
|
1152
|
+
const privateKey = (0, import_warps7.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
1149
1153
|
if (!privateKey) throw new Error("No private key provided");
|
|
1150
1154
|
try {
|
|
1151
1155
|
return import_near_api_js5.KeyPair.fromString(privateKey);
|
|
@@ -1161,14 +1165,14 @@ _PrivateKeyWalletProvider.PROVIDER_NAME = "privateKey";
|
|
|
1161
1165
|
var PrivateKeyWalletProvider = _PrivateKeyWalletProvider;
|
|
1162
1166
|
|
|
1163
1167
|
// src/providers/ReadOnlyWalletProvider.ts
|
|
1164
|
-
var
|
|
1168
|
+
var import_warps8 = require("@vleap/warps");
|
|
1165
1169
|
var ReadOnlyWalletProvider = class {
|
|
1166
1170
|
constructor(config, chain) {
|
|
1167
1171
|
this.config = config;
|
|
1168
1172
|
this.chain = chain;
|
|
1169
1173
|
}
|
|
1170
1174
|
async getAddress() {
|
|
1171
|
-
return (0,
|
|
1175
|
+
return (0, import_warps8.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1172
1176
|
}
|
|
1173
1177
|
async getPublicKey() {
|
|
1174
1178
|
return null;
|
|
@@ -1182,19 +1186,19 @@ var ReadOnlyWalletProvider = class {
|
|
|
1182
1186
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1183
1187
|
}
|
|
1184
1188
|
async importFromMnemonic(mnemonic) {
|
|
1185
|
-
const address = (0,
|
|
1189
|
+
const address = (0, import_warps8.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1186
1190
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1187
1191
|
}
|
|
1188
1192
|
async importFromPrivateKey(privateKey) {
|
|
1189
|
-
const address = (0,
|
|
1193
|
+
const address = (0, import_warps8.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1190
1194
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1191
1195
|
}
|
|
1192
1196
|
async export() {
|
|
1193
|
-
const address = (0,
|
|
1197
|
+
const address = (0, import_warps8.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1194
1198
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1195
1199
|
}
|
|
1196
1200
|
async generate() {
|
|
1197
|
-
const address = (0,
|
|
1201
|
+
const address = (0, import_warps8.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
1198
1202
|
throw new Error(`Wallet can not be used for signing: ${address}`);
|
|
1199
1203
|
}
|
|
1200
1204
|
};
|
|
@@ -1206,7 +1210,7 @@ var WarpNearWallet = class {
|
|
|
1206
1210
|
this.chain = chain;
|
|
1207
1211
|
this.cachedAddress = null;
|
|
1208
1212
|
this.cachedPublicKey = null;
|
|
1209
|
-
const providerConfig = (0,
|
|
1213
|
+
const providerConfig = (0, import_warps9.getProviderConfig)(config, chain.name, config.env, chain.defaultApiUrl);
|
|
1210
1214
|
this.nearConfig = {
|
|
1211
1215
|
networkId: this.config.env === "mainnet" ? "mainnet" : this.config.env === "testnet" ? "testnet" : "testnet",
|
|
1212
1216
|
nodeUrl: providerConfig.url,
|
|
@@ -1278,12 +1282,12 @@ var WarpNearWallet = class {
|
|
|
1278
1282
|
async sendTransactions(txs) {
|
|
1279
1283
|
return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
|
|
1280
1284
|
}
|
|
1281
|
-
async importFromMnemonic(
|
|
1282
|
-
const walletProvider = this.createProviderForOperation(
|
|
1285
|
+
async importFromMnemonic(mnemonic) {
|
|
1286
|
+
const walletProvider = this.createProviderForOperation("mnemonic");
|
|
1283
1287
|
return await walletProvider.importFromMnemonic(mnemonic);
|
|
1284
1288
|
}
|
|
1285
|
-
async importFromPrivateKey(
|
|
1286
|
-
const walletProvider = this.createProviderForOperation(
|
|
1289
|
+
async importFromPrivateKey(privateKey) {
|
|
1290
|
+
const walletProvider = this.createProviderForOperation("privateKey");
|
|
1287
1291
|
return await walletProvider.importFromPrivateKey(privateKey);
|
|
1288
1292
|
}
|
|
1289
1293
|
async export(provider) {
|
|
@@ -1307,7 +1311,7 @@ var WarpNearWallet = class {
|
|
|
1307
1311
|
return this.createProviderForOperation(wallet.provider);
|
|
1308
1312
|
}
|
|
1309
1313
|
initializeCache() {
|
|
1310
|
-
(0,
|
|
1314
|
+
(0, import_warps9.initializeWalletCache)(this.walletProvider).then((cache) => {
|
|
1311
1315
|
this.cachedAddress = cache.address;
|
|
1312
1316
|
this.cachedPublicKey = cache.publicKey;
|
|
1313
1317
|
});
|
|
@@ -1348,7 +1352,7 @@ var createNearAdapter = (chainName, chainInfos) => {
|
|
|
1348
1352
|
|
|
1349
1353
|
// src/chains/near.ts
|
|
1350
1354
|
var NativeTokenNear = {
|
|
1351
|
-
chain:
|
|
1355
|
+
chain: import_warps10.WarpChainName.Near,
|
|
1352
1356
|
identifier: "NEAR",
|
|
1353
1357
|
symbol: "NEAR",
|
|
1354
1358
|
name: "NEAR",
|
|
@@ -1358,9 +1362,9 @@ var NativeTokenNear = {
|
|
|
1358
1362
|
dark: "https://joai.ai/images/tokens/near-black.svg"
|
|
1359
1363
|
}
|
|
1360
1364
|
};
|
|
1361
|
-
var NearAdapter = createNearAdapter(
|
|
1365
|
+
var NearAdapter = createNearAdapter(import_warps10.WarpChainName.Near, {
|
|
1362
1366
|
mainnet: {
|
|
1363
|
-
name:
|
|
1367
|
+
name: import_warps10.WarpChainName.Near,
|
|
1364
1368
|
displayName: "NEAR Mainnet",
|
|
1365
1369
|
chainId: "mainnet",
|
|
1366
1370
|
blockTime: 1200,
|
|
@@ -1373,7 +1377,7 @@ var NearAdapter = createNearAdapter("near", {
|
|
|
1373
1377
|
nativeToken: NativeTokenNear
|
|
1374
1378
|
},
|
|
1375
1379
|
testnet: {
|
|
1376
|
-
name:
|
|
1380
|
+
name: import_warps10.WarpChainName.Near,
|
|
1377
1381
|
displayName: "NEAR Testnet",
|
|
1378
1382
|
chainId: "testnet",
|
|
1379
1383
|
blockTime: 1200,
|
|
@@ -1386,7 +1390,7 @@ var NearAdapter = createNearAdapter("near", {
|
|
|
1386
1390
|
nativeToken: NativeTokenNear
|
|
1387
1391
|
},
|
|
1388
1392
|
devnet: {
|
|
1389
|
-
name:
|
|
1393
|
+
name: import_warps10.WarpChainName.Near,
|
|
1390
1394
|
displayName: "NEAR Devnet",
|
|
1391
1395
|
chainId: "testnet",
|
|
1392
1396
|
blockTime: 1200,
|