@fastnear/api 0.6.3 → 0.7.1

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.
@@ -0,0 +1,477 @@
1
+ /* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.7.0) */
2
+ /* https://www.npmjs.com/package/@fastnear/api/v/0.7.0 */
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ import Big from "big.js";
6
+ import {
7
+ lsSet,
8
+ lsGet,
9
+ tryParseJson,
10
+ fromBase64,
11
+ toBase64,
12
+ canSignWithLAK,
13
+ toBase58,
14
+ parseJsonFromBytes,
15
+ signHash,
16
+ publicKeyFromPrivate,
17
+ privateKeyFromRandom,
18
+ serializeTransaction,
19
+ serializeSignedTransaction,
20
+ bytesToBase64
21
+ } from "@fastnear/utils";
22
+ import {
23
+ _adapter,
24
+ _state,
25
+ DEFAULT_NETWORK_ID,
26
+ NETWORKS,
27
+ getTxHistory,
28
+ updateState,
29
+ updateTxHistory
30
+ } from "./state.js";
31
+ import {
32
+ getConfig,
33
+ setConfig,
34
+ resetTxHistory
35
+ } from "./state.js";
36
+ import { sha256 } from "@noble/hashes/sha2";
37
+ import * as reExportAllUtils from "@fastnear/utils";
38
+ Big.DP = 27;
39
+ const MaxBlockDelayMs = 1e3 * 60 * 60 * 6;
40
+ function withBlockId(params, blockId) {
41
+ if (blockId === "final" || blockId === "optimistic") {
42
+ return { ...params, finality: blockId };
43
+ }
44
+ return blockId ? { ...params, block_id: blockId } : { ...params, finality: "optimistic" };
45
+ }
46
+ __name(withBlockId, "withBlockId");
47
+ async function queryRpc(method, params) {
48
+ const config2 = getConfig();
49
+ if (!config2?.nodeUrl) {
50
+ throw new Error("fastnear: getConfig() returned invalid config: missing nodeUrl.");
51
+ }
52
+ const response = await fetch(config2.nodeUrl, {
53
+ method: "POST",
54
+ headers: { "Content-Type": "application/json" },
55
+ body: JSON.stringify({
56
+ jsonrpc: "2.0",
57
+ id: `fastnear-${Date.now()}`,
58
+ method,
59
+ params
60
+ })
61
+ });
62
+ const result = await response.json();
63
+ if (result.error) {
64
+ throw new Error(JSON.stringify(result.error));
65
+ }
66
+ return result.result;
67
+ }
68
+ __name(queryRpc, "queryRpc");
69
+ function afterTxSent(txId) {
70
+ const txHistory = getTxHistory();
71
+ queryRpc("tx", {
72
+ tx_hash: txHistory[txId]?.txHash,
73
+ sender_account_id: txHistory[txId]?.tx?.signerId,
74
+ wait_until: "EXECUTED_OPTIMISTIC"
75
+ }).then((result) => {
76
+ const successValue = result?.status?.SuccessValue;
77
+ updateTxHistory({
78
+ txId,
79
+ status: "Executed",
80
+ result,
81
+ successValue: successValue ? tryParseJson(fromBase64(successValue)) : void 0,
82
+ finalState: true
83
+ });
84
+ }).catch((error) => {
85
+ updateTxHistory({
86
+ txId,
87
+ status: "ErrorAfterIncluded",
88
+ error: tryParseJson(error.message) ?? error.message,
89
+ finalState: true
90
+ });
91
+ });
92
+ }
93
+ __name(afterTxSent, "afterTxSent");
94
+ async function sendTxToRpc(signedTxBase64, waitUntil, txId) {
95
+ waitUntil = waitUntil || "INCLUDED";
96
+ try {
97
+ const sendTxRes = await queryRpc("send_tx", {
98
+ signed_tx_base64: signedTxBase64,
99
+ wait_until: waitUntil
100
+ });
101
+ updateTxHistory({ txId, status: "Included", finalState: false });
102
+ afterTxSent(txId);
103
+ return sendTxRes;
104
+ } catch (error) {
105
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
106
+ updateTxHistory({
107
+ txId,
108
+ status: "Error",
109
+ error: tryParseJson(errorMessage) ?? errorMessage,
110
+ finalState: false
111
+ });
112
+ throw new Error(errorMessage);
113
+ }
114
+ }
115
+ __name(sendTxToRpc, "sendTxToRpc");
116
+ function generateTxId() {
117
+ const randomPart = crypto.getRandomValues(new Uint32Array(2)).join("");
118
+ return `tx-${Date.now()}-${parseInt(randomPart, 10).toString(36)}`;
119
+ }
120
+ __name(generateTxId, "generateTxId");
121
+ const accountId = /* @__PURE__ */ __name(() => _state.accountId, "accountId");
122
+ const publicKey = /* @__PURE__ */ __name(() => _state.publicKey, "publicKey");
123
+ const config = /* @__PURE__ */ __name((newConfig) => {
124
+ const current = getConfig();
125
+ if (newConfig) {
126
+ if (newConfig.networkId && current.networkId !== newConfig.networkId) {
127
+ setConfig(newConfig.networkId);
128
+ updateState({ accountId: null, privateKey: null, lastWalletId: null });
129
+ lsSet("block", null);
130
+ resetTxHistory();
131
+ }
132
+ setConfig({ ...getConfig(), ...newConfig });
133
+ }
134
+ return getConfig();
135
+ }, "config");
136
+ const authStatus = /* @__PURE__ */ __name(() => {
137
+ if (!_state.accountId) {
138
+ return "SignedOut";
139
+ }
140
+ return "SignedIn";
141
+ }, "authStatus");
142
+ const requestSignIn = /* @__PURE__ */ __name(async ({ contractId }) => {
143
+ const privateKey = privateKeyFromRandom();
144
+ updateState({ accessKeyContractId: contractId, accountId: null, privateKey });
145
+ const pubKey = publicKeyFromPrivate(privateKey);
146
+ const result = await _adapter.signIn({
147
+ networkId: getConfig().networkId,
148
+ contractId,
149
+ publicKey: pubKey
150
+ });
151
+ if (result.error) {
152
+ throw new Error(`Wallet error: ${result.error}`);
153
+ }
154
+ if (result.url) {
155
+ if (typeof window !== "undefined") {
156
+ setTimeout(() => {
157
+ window.location.href = result.url;
158
+ }, 100);
159
+ }
160
+ } else if (result.accountId) {
161
+ updateState({ accountId: result.accountId });
162
+ }
163
+ }, "requestSignIn");
164
+ const view = /* @__PURE__ */ __name(async ({
165
+ contractId,
166
+ methodName,
167
+ args,
168
+ argsBase64,
169
+ blockId
170
+ }) => {
171
+ const encodedArgs = argsBase64 || (args ? toBase64(JSON.stringify(args)) : "");
172
+ const result = await queryRpc(
173
+ "query",
174
+ withBlockId(
175
+ {
176
+ request_type: "call_function",
177
+ account_id: contractId,
178
+ method_name: methodName,
179
+ args_base64: encodedArgs
180
+ },
181
+ blockId
182
+ )
183
+ );
184
+ return parseJsonFromBytes(result.result);
185
+ }, "view");
186
+ const queryAccount = /* @__PURE__ */ __name(async ({
187
+ accountId: accountId2,
188
+ blockId
189
+ }) => {
190
+ return queryRpc(
191
+ "query",
192
+ withBlockId({ request_type: "view_account", account_id: accountId2 }, blockId)
193
+ );
194
+ }, "queryAccount");
195
+ const queryBlock = /* @__PURE__ */ __name(async ({ blockId }) => {
196
+ return queryRpc("block", withBlockId({}, blockId));
197
+ }, "queryBlock");
198
+ const queryAccessKey = /* @__PURE__ */ __name(async ({
199
+ accountId: accountId2,
200
+ publicKey: publicKey2,
201
+ blockId
202
+ }) => {
203
+ return queryRpc(
204
+ "query",
205
+ withBlockId(
206
+ { request_type: "view_access_key", account_id: accountId2, public_key: publicKey2 },
207
+ blockId
208
+ )
209
+ );
210
+ }, "queryAccessKey");
211
+ const queryTx = /* @__PURE__ */ __name(async ({ txHash, accountId: accountId2 }) => {
212
+ return queryRpc("tx", [txHash, accountId2]);
213
+ }, "queryTx");
214
+ const localTxHistory = /* @__PURE__ */ __name(() => {
215
+ return getTxHistory();
216
+ }, "localTxHistory");
217
+ const signOut = /* @__PURE__ */ __name(() => {
218
+ updateState({ accountId: null, privateKey: null, contractId: null });
219
+ setConfig(NETWORKS[DEFAULT_NETWORK_ID]);
220
+ }, "signOut");
221
+ const sendTx = /* @__PURE__ */ __name(async ({
222
+ receiverId,
223
+ actions: actions2,
224
+ waitUntil
225
+ }) => {
226
+ const signerId = _state.accountId;
227
+ if (!signerId) throw new Error("Must sign in");
228
+ const publicKey2 = _state.publicKey ?? "";
229
+ const privKey = _state.privateKey;
230
+ const txId = generateTxId();
231
+ if (!privKey || receiverId !== _state.accessKeyContractId || !canSignWithLAK(actions2)) {
232
+ const jsonTx = { signerId, receiverId, actions: actions2 };
233
+ updateTxHistory({ status: "Pending", txId, tx: jsonTx, finalState: false });
234
+ const url = new URL(typeof window !== "undefined" ? window.location.href : "");
235
+ url.searchParams.set("txIds", txId);
236
+ try {
237
+ const result = await _adapter.sendTransactions({
238
+ transactions: [jsonTx],
239
+ callbackUrl: url.toString()
240
+ });
241
+ if (result.url) {
242
+ if (typeof window !== "undefined") {
243
+ setTimeout(() => {
244
+ window.location.href = result.url;
245
+ }, 100);
246
+ }
247
+ } else if (result.outcomes?.length) {
248
+ result.outcomes.forEach(
249
+ (r) => updateTxHistory({
250
+ txId,
251
+ status: "Executed",
252
+ result: r,
253
+ txHash: r.transaction.hash,
254
+ finalState: true
255
+ })
256
+ );
257
+ } else if (result.rejected) {
258
+ updateTxHistory({ txId, status: "RejectedByUser", finalState: true });
259
+ } else if (result.error) {
260
+ updateTxHistory({
261
+ txId,
262
+ status: "Error",
263
+ error: tryParseJson(result.error),
264
+ finalState: true
265
+ });
266
+ }
267
+ return result;
268
+ } catch (err) {
269
+ console.error("fastnear: error sending tx using adapter:", err);
270
+ updateTxHistory({
271
+ txId,
272
+ status: "Error",
273
+ error: tryParseJson(err.message),
274
+ finalState: true
275
+ });
276
+ return Promise.reject(err);
277
+ }
278
+ }
279
+ let nonce = lsGet("nonce");
280
+ if (nonce == null) {
281
+ const accessKey = await queryAccessKey({ accountId: signerId, publicKey: publicKey2 });
282
+ if (accessKey.error) {
283
+ throw new Error(`Access key error: ${accessKey.error} when attempting to get nonce for ${signerId} for public key ${publicKey2}`);
284
+ }
285
+ nonce = accessKey.nonce;
286
+ lsSet("nonce", nonce);
287
+ }
288
+ let lastKnownBlock = lsGet("block");
289
+ if (!lastKnownBlock || parseFloat(lastKnownBlock.header.timestamp_nanosec) / 1e6 + MaxBlockDelayMs < Date.now()) {
290
+ const latestBlock = await queryBlock({ blockId: "final" });
291
+ lastKnownBlock = {
292
+ header: {
293
+ prev_hash: latestBlock.header.prev_hash,
294
+ timestamp_nanosec: latestBlock.header.timestamp_nanosec
295
+ }
296
+ };
297
+ lsSet("block", lastKnownBlock);
298
+ }
299
+ nonce += 1;
300
+ lsSet("nonce", nonce);
301
+ const blockHash = lastKnownBlock.header.prev_hash;
302
+ const plainTransactionObj = {
303
+ signerId,
304
+ publicKey: publicKey2,
305
+ nonce,
306
+ receiverId,
307
+ blockHash,
308
+ actions: actions2
309
+ };
310
+ const txBytes = serializeTransaction(plainTransactionObj);
311
+ const txHashBytes = sha256(txBytes);
312
+ const txHash58 = toBase58(txHashBytes);
313
+ const signatureBase58 = signHash(txHashBytes, privKey, { returnBase58: true });
314
+ const signedTransactionBytes = serializeSignedTransaction(plainTransactionObj, signatureBase58);
315
+ const signedTxBase64 = bytesToBase64(signedTransactionBytes);
316
+ updateTxHistory({
317
+ status: "Pending",
318
+ txId,
319
+ tx: plainTransactionObj,
320
+ signature: signatureBase58,
321
+ signedTxBase64,
322
+ txHash: txHash58,
323
+ finalState: false
324
+ });
325
+ try {
326
+ return await sendTxToRpc(signedTxBase64, waitUntil, txId);
327
+ } catch (error) {
328
+ console.error("Error Sending Transaction:", error, plainTransactionObj, signedTxBase64);
329
+ }
330
+ }, "sendTx");
331
+ const exp = {
332
+ utils: {},
333
+ // we will map this in a moment, giving keys, for IDE hints
334
+ borsh: reExportAllUtils.exp.borsh,
335
+ borshSchema: reExportAllUtils.exp.borshSchema.getBorshSchema()
336
+ };
337
+ for (const key in reExportAllUtils) {
338
+ exp.utils[key] = reExportAllUtils[key];
339
+ }
340
+ const utils = exp.utils;
341
+ try {
342
+ if (typeof window !== "undefined") {
343
+ const url = new URL(window.location.href);
344
+ const accId = url.searchParams.get("account_id");
345
+ const pubKey = url.searchParams.get("public_key");
346
+ const errCode = url.searchParams.get("errorCode");
347
+ const errMsg = url.searchParams.get("errorMessage");
348
+ const txHashes = url.searchParams.get("transactionHashes");
349
+ const txIds = url.searchParams.get("txIds");
350
+ if (errCode || errMsg) {
351
+ console.warn(new Error(`Wallet error: ${errCode} ${errMsg}`));
352
+ }
353
+ if (accId && pubKey) {
354
+ if (pubKey === _state.publicKey) {
355
+ updateState({ accountId: accId });
356
+ } else {
357
+ console.error(new Error("Public key mismatch from wallet redirect"), pubKey, _state.publicKey);
358
+ }
359
+ }
360
+ if (txHashes || txIds) {
361
+ const hashArr = txHashes ? txHashes.split(",") : [];
362
+ const idArr = txIds ? txIds.split(",") : [];
363
+ if (idArr.length > hashArr.length) {
364
+ idArr.forEach((id) => {
365
+ updateTxHistory({ txId: id, status: "RejectedByUser", finalState: true });
366
+ });
367
+ } else if (idArr.length === hashArr.length) {
368
+ idArr.forEach((id, i) => {
369
+ updateTxHistory({
370
+ txId: id,
371
+ status: "PendingGotTxHash",
372
+ txHash: hashArr[i],
373
+ finalState: false
374
+ });
375
+ afterTxSent(id);
376
+ });
377
+ } else {
378
+ console.error(new Error("Transaction hash mismatch from wallet redirect"), idArr, hashArr);
379
+ }
380
+ }
381
+ url.searchParams.delete("account_id");
382
+ url.searchParams.delete("public_key");
383
+ url.searchParams.delete("errorCode");
384
+ url.searchParams.delete("errorMessage");
385
+ url.searchParams.delete("all_keys");
386
+ url.searchParams.delete("transactionHashes");
387
+ url.searchParams.delete("txIds");
388
+ window.history.replaceState({}, "", url.toString());
389
+ }
390
+ } catch (e) {
391
+ console.error("Error handling wallet redirect:", e);
392
+ }
393
+ const actions = {
394
+ functionCall: /* @__PURE__ */ __name(({
395
+ methodName,
396
+ gas,
397
+ deposit,
398
+ args,
399
+ argsBase64
400
+ }) => ({
401
+ type: "FunctionCall",
402
+ methodName,
403
+ args,
404
+ argsBase64,
405
+ gas,
406
+ deposit
407
+ }), "functionCall"),
408
+ transfer: /* @__PURE__ */ __name((yoctoAmount) => ({
409
+ type: "Transfer",
410
+ deposit: yoctoAmount
411
+ }), "transfer"),
412
+ stakeNEAR: /* @__PURE__ */ __name(({ amount, publicKey: publicKey2 }) => ({
413
+ type: "Stake",
414
+ stake: amount,
415
+ publicKey: publicKey2
416
+ }), "stakeNEAR"),
417
+ addFullAccessKey: /* @__PURE__ */ __name(({ publicKey: publicKey2 }) => ({
418
+ type: "AddKey",
419
+ publicKey: publicKey2,
420
+ accessKey: { permission: "FullAccess" }
421
+ }), "addFullAccessKey"),
422
+ addLimitedAccessKey: /* @__PURE__ */ __name(({
423
+ publicKey: publicKey2,
424
+ allowance,
425
+ accountId: accountId2,
426
+ methodNames
427
+ }) => ({
428
+ type: "AddKey",
429
+ publicKey: publicKey2,
430
+ accessKey: {
431
+ permission: "FunctionCall",
432
+ allowance,
433
+ receiverId: accountId2,
434
+ methodNames
435
+ }
436
+ }), "addLimitedAccessKey"),
437
+ deleteKey: /* @__PURE__ */ __name(({ publicKey: publicKey2 }) => ({
438
+ type: "DeleteKey",
439
+ publicKey: publicKey2
440
+ }), "deleteKey"),
441
+ deleteAccount: /* @__PURE__ */ __name(({ beneficiaryId }) => ({
442
+ type: "DeleteAccount",
443
+ beneficiaryId
444
+ }), "deleteAccount"),
445
+ createAccount: /* @__PURE__ */ __name(() => ({
446
+ type: "CreateAccount"
447
+ }), "createAccount"),
448
+ deployContract: /* @__PURE__ */ __name(({ codeBase64 }) => ({
449
+ type: "DeployContract",
450
+ codeBase64
451
+ }), "deployContract")
452
+ };
453
+ export {
454
+ MaxBlockDelayMs,
455
+ accountId,
456
+ actions,
457
+ afterTxSent,
458
+ authStatus,
459
+ config,
460
+ exp,
461
+ generateTxId,
462
+ localTxHistory,
463
+ publicKey,
464
+ queryAccessKey,
465
+ queryAccount,
466
+ queryBlock,
467
+ queryRpc,
468
+ queryTx,
469
+ requestSignIn,
470
+ sendTx,
471
+ sendTxToRpc,
472
+ signOut,
473
+ utils,
474
+ view,
475
+ withBlockId
476
+ };
477
+ //# sourceMappingURL=near.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/near.ts"],"sourcesContent":["import Big from \"big.js\";\nimport {\n lsSet,\n lsGet,\n tryParseJson,\n fromBase64,\n toBase64,\n canSignWithLAK,\n toBase58,\n parseJsonFromBytes,\n signHash,\n publicKeyFromPrivate,\n privateKeyFromRandom,\n serializeTransaction,\n serializeSignedTransaction, bytesToBase64, PlainTransaction,\n} from \"@fastnear/utils\";\n\nimport {\n _adapter,\n _state,\n DEFAULT_NETWORK_ID,\n NETWORKS,\n getTxHistory,\n updateState,\n updateTxHistory,\n} from \"./state.js\";\n\nimport {\n getConfig,\n setConfig,\n resetTxHistory,\n} from \"./state.js\";\n\nimport { sha256 } from \"@noble/hashes/sha2\";\nimport * as reExportAllUtils from \"@fastnear/utils\";\n\nBig.DP = 27;\nexport const MaxBlockDelayMs = 1000 * 60 * 60 * 6; // 6 hours\n\ninterface AccessKeyWithError {\n nonce: number;\n permission?: any;\n error?: string;\n}\n\ninterface WalletTxResult {\n url?: string;\n outcomes?: Array<{ transaction: { hash: string } }>;\n rejected?: boolean;\n error?: string;\n}\n\ninterface BlockView {\n header: {\n prev_hash: string;\n timestamp_nanosec: string;\n };\n}\n\nexport function withBlockId(params: Record<string, any>, blockId?: string) {\n if (blockId === \"final\" || blockId === \"optimistic\") {\n return { ...params, finality: blockId };\n }\n return blockId ? { ...params, block_id: blockId } : { ...params, finality: \"optimistic\" };\n}\n\nexport async function queryRpc(method: string, params: Record<string, any> | any[]) {\n const config = getConfig();\n if (!config?.nodeUrl) {\n throw new Error(\"fastnear: getConfig() returned invalid config: missing nodeUrl.\");\n }\n const response = await fetch(config.nodeUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: `fastnear-${Date.now()}`,\n method,\n params,\n }),\n });\n const result = await response.json();\n if (result.error) {\n throw new Error(JSON.stringify(result.error));\n }\n return result.result;\n}\n\nexport function afterTxSent(txId: string) {\n const txHistory = getTxHistory();\n queryRpc(\"tx\", {\n tx_hash: txHistory[txId]?.txHash,\n sender_account_id: txHistory[txId]?.tx?.signerId,\n wait_until: \"EXECUTED_OPTIMISTIC\",\n })\n .then((result) => {\n const successValue = result?.status?.SuccessValue;\n updateTxHistory({\n txId,\n status: \"Executed\",\n result,\n successValue: successValue ? tryParseJson(fromBase64(successValue)) : undefined,\n finalState: true,\n });\n })\n .catch((error) => {\n updateTxHistory({\n txId,\n status: \"ErrorAfterIncluded\",\n error: tryParseJson(error.message) ?? error.message,\n finalState: true,\n });\n });\n}\n\nexport async function sendTxToRpc(signedTxBase64: string, waitUntil: string | undefined, txId: string) {\n // default to \"INCLUDED\"\n // see options: https://docs.near.org/api/rpc/transactions#tx-status-result\n waitUntil = waitUntil || \"INCLUDED\";\n\n try {\n const sendTxRes = await queryRpc(\"send_tx\", {\n signed_tx_base64: signedTxBase64,\n wait_until: waitUntil,\n });\n\n updateTxHistory({ txId, status: \"Included\", finalState: false });\n afterTxSent(txId);\n\n return sendTxRes;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error\";\n updateTxHistory({\n txId,\n status: \"Error\",\n error: tryParseJson(errorMessage) ?? errorMessage,\n finalState: false,\n });\n throw new Error(errorMessage);\n }\n}\n\nexport interface AccessKeyView {\n nonce: number;\n permission: any;\n}\n\n/**\n * Generates a mock transaction ID.\n *\n * This function creates a pseudo-unique transaction ID for testing or\n * non-production use. It combines the current timestamp with a\n * random component for uniqueness.\n *\n * **Note:** This is not cryptographically secure and should not be used\n * for actual transaction processing.\n *\n * @returns {string} A mock transaction ID in the format `tx-{timestamp}-{random}`\n */\nexport function generateTxId(): string {\n const randomPart = crypto.getRandomValues(new Uint32Array(2)).join(\"\");\n return `tx-${Date.now()}-${parseInt(randomPart, 10).toString(36)}`;\n}\n\nexport const accountId = () => _state.accountId;\nexport const publicKey = () => _state.publicKey;\n\nexport const config = (newConfig?: Record<string, any>) => {\n const current = getConfig();\n if (newConfig) {\n if (newConfig.networkId && current.networkId !== newConfig.networkId) {\n setConfig(newConfig.networkId);\n updateState({ accountId: null, privateKey: null, lastWalletId: null });\n lsSet(\"block\", null);\n resetTxHistory();\n }\n setConfig({ ...getConfig(), ...newConfig });\n }\n return getConfig();\n};\n\nexport const authStatus = (): string | Record<string, any> => {\n if (!_state.accountId) {\n return \"SignedOut\";\n }\n return \"SignedIn\";\n};\n\nexport const requestSignIn = async ({ contractId }: { contractId: string }) => {\n const privateKey = privateKeyFromRandom();\n updateState({ accessKeyContractId: contractId, accountId: null, privateKey });\n const pubKey = publicKeyFromPrivate(privateKey);\n\n const result = await _adapter.signIn({\n networkId: getConfig().networkId,\n contractId,\n publicKey: pubKey,\n });\n\n if (result.error) {\n throw new Error(`Wallet error: ${result.error}`);\n }\n if (result.url) {\n if (typeof window !== \"undefined\") {\n setTimeout(() => {\n window.location.href = result.url;\n }, 100);\n }\n } else if (result.accountId) {\n updateState({ accountId: result.accountId });\n }\n};\n\nexport const view = async ({\n contractId,\n methodName,\n args,\n argsBase64,\n blockId,\n }: {\n contractId: string;\n methodName: string;\n args?: any;\n argsBase64?: string;\n blockId?: string;\n}) => {\n const encodedArgs = argsBase64 || (args ? toBase64(JSON.stringify(args)) : \"\");\n const result = await queryRpc(\n \"query\",\n withBlockId(\n {\n request_type: \"call_function\",\n account_id: contractId,\n method_name: methodName,\n args_base64: encodedArgs,\n },\n blockId\n )\n );\n return parseJsonFromBytes(result.result);\n};\n\nexport const queryAccount = async ({\n accountId,\n blockId,\n }: {\n accountId: string;\n blockId?: string;\n}) => {\n return queryRpc(\n \"query\",\n withBlockId({ request_type: \"view_account\", account_id: accountId }, blockId)\n );\n};\n\nexport const queryBlock = async ({ blockId }: { blockId?: string }): Promise<BlockView> => {\n return queryRpc(\"block\", withBlockId({}, blockId));\n};\n\nexport const queryAccessKey = async ({\n accountId,\n publicKey,\n blockId,\n }: {\n accountId: string;\n publicKey: string;\n blockId?: string;\n}): Promise<AccessKeyWithError> => {\n return queryRpc(\n \"query\",\n withBlockId(\n { request_type: \"view_access_key\", account_id: accountId, public_key: publicKey },\n blockId\n )\n );\n};\n\nexport const queryTx = async ({ txHash, accountId }: { txHash: string; accountId: string }) => {\n return queryRpc(\"tx\", [txHash, accountId]);\n};\n\nexport const localTxHistory = () => {\n return getTxHistory();\n};\n\nexport const signOut = () => {\n updateState({ accountId: null, privateKey: null, contractId: null });\n setConfig(NETWORKS[DEFAULT_NETWORK_ID]);\n};\n\nexport const sendTx = async ({\n receiverId,\n actions,\n waitUntil,\n }: {\n receiverId: string;\n actions: any[];\n waitUntil?: string;\n}) => {\n const signerId = _state.accountId;\n if (!signerId) throw new Error(\"Must sign in\");\n\n const publicKey = _state.publicKey ?? \"\";\n const privKey = _state.privateKey;\n // this generates a mock transaction ID so we can keep track of each tx\n const txId = generateTxId();\n\n if (!privKey || receiverId !== _state.accessKeyContractId || !canSignWithLAK(actions)) {\n const jsonTx = { signerId, receiverId, actions };\n updateTxHistory({ status: \"Pending\", txId, tx: jsonTx, finalState: false });\n\n const url = new URL(typeof window !== \"undefined\" ? window.location.href : \"\");\n url.searchParams.set(\"txIds\", txId);\n\n try {\n const result: WalletTxResult = await _adapter.sendTransactions({\n transactions: [jsonTx],\n callbackUrl: url.toString(),\n });\n\n if (result.url) {\n if (typeof window !== \"undefined\") {\n setTimeout(() => {\n window.location.href = result.url!;\n }, 100);\n }\n } else if (result.outcomes?.length) {\n result.outcomes.forEach((r) =>\n updateTxHistory({\n txId,\n status: \"Executed\",\n result: r,\n txHash: r.transaction.hash,\n finalState: true,\n })\n );\n } else if (result.rejected) {\n updateTxHistory({ txId, status: \"RejectedByUser\", finalState: true });\n } else if (result.error) {\n updateTxHistory({\n txId,\n status: \"Error\",\n error: tryParseJson(result.error),\n finalState: true,\n });\n }\n\n return result;\n } catch (err) {\n console.error('fastnear: error sending tx using adapter:', err)\n updateTxHistory({\n txId,\n status: \"Error\",\n error: tryParseJson((err as Error).message),\n finalState: true,\n });\n\n return Promise.reject(err);\n }\n }\n\n //\n let nonce = lsGet(\"nonce\") as number | null;\n if (nonce == null) {\n const accessKey = await queryAccessKey({ accountId: signerId, publicKey: publicKey });\n if (accessKey.error) {\n throw new Error(`Access key error: ${accessKey.error} when attempting to get nonce for ${signerId} for public key ${publicKey}`);\n }\n nonce = accessKey.nonce;\n lsSet(\"nonce\", nonce);\n }\n\n let lastKnownBlock = lsGet(\"block\") as BlockView | null;\n if (\n !lastKnownBlock ||\n parseFloat(lastKnownBlock.header.timestamp_nanosec) / 1e6 + MaxBlockDelayMs < Date.now()\n ) {\n const latestBlock = await queryBlock({ blockId: \"final\" });\n lastKnownBlock = {\n header: {\n prev_hash: latestBlock.header.prev_hash,\n timestamp_nanosec: latestBlock.header.timestamp_nanosec,\n },\n };\n lsSet(\"block\", lastKnownBlock);\n }\n\n nonce += 1;\n lsSet(\"nonce\", nonce);\n\n const blockHash = lastKnownBlock.header.prev_hash;\n\n const plainTransactionObj: PlainTransaction = {\n signerId,\n publicKey,\n nonce,\n receiverId,\n blockHash,\n actions,\n };\n\n const txBytes = serializeTransaction(plainTransactionObj);\n const txHashBytes = sha256(txBytes);\n const txHash58 = toBase58(txHashBytes);\n\n const signatureBase58 = signHash(txHashBytes, privKey, { returnBase58: true });\n const signedTransactionBytes = serializeSignedTransaction(plainTransactionObj, signatureBase58);\n const signedTxBase64 = bytesToBase64(signedTransactionBytes);\n\n updateTxHistory({\n status: \"Pending\",\n txId,\n tx: plainTransactionObj,\n signature: signatureBase58,\n signedTxBase64,\n txHash: txHash58,\n finalState: false,\n });\n\n try {\n return await sendTxToRpc(signedTxBase64, waitUntil, txId);\n } catch (error) {\n console.error(\"Error Sending Transaction:\", error, plainTransactionObj, signedTxBase64);\n }\n};\n\n// exports\nexport const exp = {\n utils: {}, // we will map this in a moment, giving keys, for IDE hints\n borsh: reExportAllUtils.exp.borsh,\n borshSchema: reExportAllUtils.exp.borshSchema.getBorshSchema(),\n};\n\nfor (const key in reExportAllUtils) {\n exp.utils[key] = reExportAllUtils[key];\n}\n\nexport const utils = exp.utils;\n\n// Wallet redirect handling\ntry {\n if (typeof window !== \"undefined\") {\n const url = new URL(window.location.href);\n const accId = url.searchParams.get(\"account_id\");\n const pubKey = url.searchParams.get(\"public_key\");\n const errCode = url.searchParams.get(\"errorCode\");\n const errMsg = url.searchParams.get(\"errorMessage\");\n const txHashes = url.searchParams.get(\"transactionHashes\");\n const txIds = url.searchParams.get(\"txIds\");\n\n if (errCode || errMsg) {\n console.warn(new Error(`Wallet error: ${errCode} ${errMsg}`));\n }\n\n if (accId && pubKey) {\n if (pubKey === _state.publicKey) {\n updateState({ accountId: accId });\n } else {\n console.error(new Error(\"Public key mismatch from wallet redirect\"), pubKey, _state.publicKey);\n }\n }\n\n if (txHashes || txIds) {\n const hashArr = txHashes ? txHashes.split(\",\") : [];\n const idArr = txIds ? txIds.split(\",\") : [];\n if (idArr.length > hashArr.length) {\n idArr.forEach((id) => {\n updateTxHistory({ txId: id, status: \"RejectedByUser\", finalState: true });\n });\n } else if (idArr.length === hashArr.length) {\n idArr.forEach((id, i) => {\n updateTxHistory({\n txId: id,\n status: \"PendingGotTxHash\",\n txHash: hashArr[i],\n finalState: false,\n });\n afterTxSent(id);\n });\n } else {\n console.error(new Error(\"Transaction hash mismatch from wallet redirect\"), idArr, hashArr);\n }\n }\n\n url.searchParams.delete(\"account_id\");\n url.searchParams.delete(\"public_key\");\n url.searchParams.delete(\"errorCode\");\n url.searchParams.delete(\"errorMessage\");\n url.searchParams.delete(\"all_keys\");\n url.searchParams.delete(\"transactionHashes\");\n url.searchParams.delete(\"txIds\");\n window.history.replaceState({}, \"\", url.toString());\n }\n} catch (e) {\n console.error(\"Error handling wallet redirect:\", e);\n}\n\n// action helpers\nexport const actions = {\n functionCall: ({\n methodName,\n gas,\n deposit,\n args,\n argsBase64,\n }: {\n methodName: string;\n gas?: string;\n deposit?: string;\n args?: Record<string, any>;\n argsBase64?: string;\n }) => ({\n type: \"FunctionCall\",\n methodName,\n args,\n argsBase64,\n gas,\n deposit,\n }),\n\n transfer: (yoctoAmount: string) => ({\n type: \"Transfer\",\n deposit: yoctoAmount,\n }),\n\n stakeNEAR: ({amount, publicKey}: { amount: string; publicKey: string }) => ({\n type: \"Stake\",\n stake: amount,\n publicKey,\n }),\n\n addFullAccessKey: ({publicKey}: { publicKey: string }) => ({\n type: \"AddKey\",\n publicKey: publicKey,\n accessKey: {permission: \"FullAccess\"},\n }),\n\n addLimitedAccessKey: ({\n publicKey,\n allowance,\n accountId,\n methodNames,\n }: {\n publicKey: string;\n allowance: string;\n accountId: string;\n methodNames: string[];\n }) => ({\n type: \"AddKey\",\n publicKey: publicKey,\n accessKey: {\n permission: \"FunctionCall\",\n allowance,\n receiverId: accountId,\n methodNames,\n },\n }),\n\n deleteKey: ({publicKey}: { publicKey: string }) => ({\n type: \"DeleteKey\",\n publicKey,\n }),\n\n deleteAccount: ({beneficiaryId}: { beneficiaryId: string }) => ({\n type: \"DeleteAccount\",\n beneficiaryId,\n }),\n\n createAccount: () => ({\n type: \"CreateAccount\",\n }),\n\n deployContract: ({codeBase64}: { codeBase64: string }) => ({\n type: \"DeployContract\",\n codeBase64,\n }),\n};\n"],"mappings":";;;;AAAA,OAAO,SAAS;AAChB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAA4B;AAAA,OACvB;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,cAAc;AACvB,YAAY,sBAAsB;AAElC,IAAI,KAAK;AACF,MAAM,kBAAkB,MAAO,KAAK,KAAK;AAsBzC,SAAS,YAAY,QAA6B,SAAkB;AACzE,MAAI,YAAY,WAAW,YAAY,cAAc;AACnD,WAAO,EAAE,GAAG,QAAQ,UAAU,QAAQ;AAAA,EACxC;AACA,SAAO,UAAU,EAAE,GAAG,QAAQ,UAAU,QAAQ,IAAI,EAAE,GAAG,QAAQ,UAAU,aAAa;AAC1F;AALgB;AAOhB,eAAsB,SAAS,QAAgB,QAAqC;AAClF,QAAMA,UAAS,UAAU;AACzB,MAAI,CAACA,SAAQ,SAAS;AACpB,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AACA,QAAM,WAAW,MAAM,MA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