@fastnear/api 0.9.4 → 0.9.6
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/cjs/index.cjs +5 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/near.cjs +2 -2
- package/dist/cjs/state.cjs +3 -3
- package/dist/cjs/state.cjs.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/near.js +2 -2
- package/dist/esm/state.js +3 -3
- package/dist/esm/state.js.map +1 -1
- package/dist/umd/browser.global.js +31 -191
- package/dist/umd/browser.global.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.9.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.9.6) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.6 */
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -15,9 +15,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
};
|
|
16
16
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
module.exports = __toCommonJS(
|
|
20
|
-
__reExport(
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("./near.js"), module.exports);
|
|
21
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
22
|
0 && (module.exports = {
|
|
23
23
|
...require("./near.js")
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// See tsup.config.ts for additional banner/footer js\nexport * from \"./near.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AACA,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// See tsup.config.ts for additional banner/footer js\nexport * from \"./near.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AACA,0BAAc,sBADd;","names":[]}
|
package/dist/cjs/near.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.9.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.9.6) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.6 */
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
package/dist/cjs/state.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.9.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.9.6) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.6 */
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -72,7 +72,7 @@ const getWalletAdapterState = /* @__PURE__ */ __name(() => {
|
|
|
72
72
|
publicKey: _state.publicKey,
|
|
73
73
|
accountId: _state.accountId,
|
|
74
74
|
lastWalletId: _state.lastWalletId,
|
|
75
|
-
networkId:
|
|
75
|
+
networkId: _config.networkId
|
|
76
76
|
};
|
|
77
77
|
}, "getWalletAdapterState");
|
|
78
78
|
let _adapter = new import_wallet_adapter.WalletAdapter({
|
package/dist/cjs/state.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/state.ts"],"sourcesContent":["import {\n lsSet,\n lsGet,\n publicKeyFromPrivate,\n} from \"@fastnear/utils\";\nimport {WalletAdapter} from \"@fastnear/wallet-adapter\";\n\nexport const WIDGET_URL = \"https://js.cdn.fastnear.com\";\n\nexport const DEFAULT_NETWORK_ID = \"mainnet\";\nexport const NETWORKS = {\n testnet: {\n networkId: \"testnet\",\n nodeUrl: \"https://rpc.testnet.fastnear.com/\",\n },\n mainnet: {\n networkId: \"mainnet\",\n nodeUrl: \"https://rpc.mainnet.fastnear.com/\",\n },\n};\n\nexport interface NetworkConfig {\n networkId: string;\n nodeUrl?: string;\n walletUrl?: string;\n helperUrl?: string;\n explorerUrl?: string;\n\n [key: string]: any;\n}\n\nexport interface AppState {\n accountId?: string | null;\n privateKey?: string | null;\n lastWalletId?: string | null;\n publicKey?: string | null;\n accessKeyContractId?: string | null;\n\n [key: string]: any;\n}\n\nexport interface TxStatus {\n txId: string;\n updateTimestamp?: number;\n\n [key: string]: any;\n}\n\nexport type TxHistory = Record<string, TxStatus>;\n\nexport interface EventListeners {\n account: Set<(accountId: string) => void>;\n tx: Set<(tx: TxStatus) => void>;\n}\n\nexport interface UnbroadcastedEvents {\n account: string[];\n tx: TxStatus[];\n}\n\nexport interface WalletAdapterState {\n publicKey?: string | null;\n privateKey?: string | null;\n accountId?: string | null;\n lastWalletId?: string | null;\n networkId: string;\n}\n\n\n// Load config from localStorage or default to the network's config\nexport let _config: NetworkConfig = lsGet(\"config\") || {\n ...NETWORKS[DEFAULT_NETWORK_ID]\n};\n\n// Load application state from localStorage\nexport let _state: AppState = lsGet(\"state\") || {};\n\n// Triggered by the wallet adapter\nexport const onAdapterStateUpdate = (state: WalletAdapterState) => {\n console.log(\"Adapter state update:\", state);\n const { accountId, lastWalletId, privateKey } = state;\n update({\n accountId: accountId || undefined,\n lastWalletId: lastWalletId || undefined,\n ...(privateKey ? { privateKey } : {}),\n });\n}\n\nexport const getWalletAdapterState = (): WalletAdapterState => {\n return {\n publicKey: _state.publicKey,\n accountId: _state.accountId,\n lastWalletId: _state.lastWalletId,\n networkId:
|
|
1
|
+
{"version":3,"sources":["../../src/state.ts"],"sourcesContent":["import {\n lsSet,\n lsGet,\n publicKeyFromPrivate,\n} from \"@fastnear/utils\";\nimport {WalletAdapter} from \"@fastnear/wallet-adapter\";\n\nexport const WIDGET_URL = \"https://js.cdn.fastnear.com\";\n\nexport const DEFAULT_NETWORK_ID = \"mainnet\";\nexport const NETWORKS = {\n testnet: {\n networkId: \"testnet\",\n nodeUrl: \"https://rpc.testnet.fastnear.com/\",\n },\n mainnet: {\n networkId: \"mainnet\",\n nodeUrl: \"https://rpc.mainnet.fastnear.com/\",\n },\n};\n\nexport interface NetworkConfig {\n networkId: string;\n nodeUrl?: string;\n walletUrl?: string;\n helperUrl?: string;\n explorerUrl?: string;\n\n [key: string]: any;\n}\n\nexport interface AppState {\n accountId?: string | null;\n privateKey?: string | null;\n lastWalletId?: string | null;\n publicKey?: string | null;\n accessKeyContractId?: string | null;\n\n [key: string]: any;\n}\n\nexport interface TxStatus {\n txId: string;\n updateTimestamp?: number;\n\n [key: string]: any;\n}\n\nexport type TxHistory = Record<string, TxStatus>;\n\nexport interface EventListeners {\n account: Set<(accountId: string) => void>;\n tx: Set<(tx: TxStatus) => void>;\n}\n\nexport interface UnbroadcastedEvents {\n account: string[];\n tx: TxStatus[];\n}\n\nexport interface WalletAdapterState {\n publicKey?: string | null;\n privateKey?: string | null;\n accountId?: string | null;\n lastWalletId?: string | null;\n networkId: string;\n}\n\n\n// Load config from localStorage or default to the network's config\nexport let _config: NetworkConfig = lsGet(\"config\") || {\n ...NETWORKS[DEFAULT_NETWORK_ID]\n};\n\n// Load application state from localStorage\nexport let _state: AppState = lsGet(\"state\") || {};\n\n// Triggered by the wallet adapter\nexport const onAdapterStateUpdate = (state: WalletAdapterState) => {\n console.log(\"Adapter state update:\", state);\n const { accountId, lastWalletId, privateKey } = state;\n update({\n accountId: accountId || undefined,\n lastWalletId: lastWalletId || undefined,\n ...(privateKey ? { privateKey } : {}),\n });\n}\n\nexport const getWalletAdapterState = (): WalletAdapterState => {\n return {\n publicKey: _state.publicKey,\n accountId: _state.accountId,\n lastWalletId: _state.lastWalletId,\n networkId: _config.networkId,\n };\n}\n\n// We can create an adapter instance here\nexport let _adapter = new WalletAdapter({\n onStateUpdate: onAdapterStateUpdate,\n lastState: getWalletAdapterState(),\n widgetUrl: WIDGET_URL,\n});\n\n// Attempt to set publicKey if we have a privateKey\ntry {\n _state.publicKey = _state.privateKey\n ? publicKeyFromPrivate(_state.privateKey)\n : null;\n} catch (e) {\n console.error(\"Error parsing private key:\", e);\n _state.privateKey = null;\n lsSet(\"nonce\", null);\n}\n\n// Transaction history\nexport let _txHistory: TxHistory = lsGet(\"txHistory\") || {};\n\n\nexport const _unbroadcastedEvents: UnbroadcastedEvents = {\n account: [],\n tx: [],\n};\n\n// events / listeners\nexport const events = {\n _eventListeners: {\n account: new Set(),\n tx: new Set(),\n },\n\n notifyAccountListeners: (accountId: string) => {\n if (events._eventListeners.account.size === 0) {\n _unbroadcastedEvents.account.push(accountId);\n return;\n }\n events._eventListeners.account.forEach((callback: any) => {\n try {\n callback(accountId);\n } catch (e) {\n console.error(e);\n }\n });\n },\n\n notifyTxListeners: (tx: TxStatus) => {\n if (events._eventListeners.tx.size === 0) {\n _unbroadcastedEvents.tx.push(tx);\n return;\n }\n events._eventListeners.tx.forEach((callback: any) => {\n try {\n callback(tx);\n } catch (e) {\n console.error(e);\n }\n });\n },\n\n onAccount: (callback: (accountId: string) => void) => {\n events._eventListeners.account.add(callback);\n if (_unbroadcastedEvents.account.length > 0) {\n const accountEvent = _unbroadcastedEvents.account;\n _unbroadcastedEvents.account = [];\n accountEvent.forEach(events.notifyAccountListeners);\n }\n },\n\n onTx: (callback: (tx: TxStatus) => void): void => {\n events._eventListeners.tx.add(callback);\n if (_unbroadcastedEvents.tx.length > 0) {\n const txEvent = _unbroadcastedEvents.tx;\n _unbroadcastedEvents.tx = [];\n txEvent.forEach(events.notifyTxListeners);\n }\n }\n}\n\n// Mutators\n// @todo: in favor of limiting when out of alpha\n// but haven't given it enough thought ~ mike\nexport const update = (newState: Partial<AppState>) => {\n const oldState = _state;\n _state = {..._state, ...newState};\n\n lsSet(\"state\", {\n accountId: _state.accountId,\n privateKey: _state.privateKey,\n lastWalletId: _state.lastWalletId,\n accessKeyContractId: _state.accessKeyContractId,\n });\n\n if (\n newState.hasOwnProperty(\"privateKey\") &&\n newState.privateKey !== oldState.privateKey\n ) {\n _state.publicKey = newState.privateKey\n ? publicKeyFromPrivate(newState.privateKey as string)\n : null;\n lsSet(\"nonce\", null);\n }\n\n if (newState.accountId !== oldState.accountId) {\n events.notifyAccountListeners(newState.accountId as string);\n }\n\n if (\n (newState.hasOwnProperty(\"lastWalletId\") &&\n newState.lastWalletId !== oldState.lastWalletId) ||\n (newState.hasOwnProperty(\"accountId\") &&\n newState.accountId !== oldState.accountId) ||\n (newState.hasOwnProperty(\"privateKey\") &&\n newState.privateKey !== oldState.privateKey)\n ) {\n _adapter.setState(getWalletAdapterState());\n }\n}\n\nexport const updateTxHistory = (txStatus: TxStatus) => {\n const txId = txStatus.txId;\n _txHistory[txId] = {\n ...(_txHistory[txId] || {}),\n ...txStatus,\n updateTimestamp: Date.now(),\n };\n lsSet(\"txHistory\", _txHistory);\n events.notifyTxListeners(_txHistory[txId]);\n}\n\nexport const getConfig = (): NetworkConfig => {\n return _config;\n}\n\nexport const getTxHistory = (): TxHistory => {\n return _txHistory;\n}\n\n// Exposed \"write\" functions\nexport const setConfig = (newConf: NetworkConfig): void => {\n _config = { ...NETWORKS[newConf.networkId], ...newConf };\n lsSet(\"config\", _config);\n}\n\nexport const resetTxHistory = (): void => {\n _txHistory = {};\n lsSet(\"txHistory\", _txHistory);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAIO;AACP,4BAA4B;AAErB,MAAM,aAAa;AAEnB,MAAM,qBAAqB;AAC3B,MAAM,WAAW;AAAA,EACtB,SAAS;AAAA,IACP,WAAW;AAAA,IACX,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,WAAW;AAAA,IACX,SAAS;AAAA,EACX;AACF;AAmDO,IAAI,cAAyB,oBAAM,QAAQ,KAAK;AAAA,EACrD,GAAG,SAAS,kBAAkB;AAChC;AAGO,IAAI,aAAmB,oBAAM,OAAO,KAAK,CAAC;AAG1C,MAAM,uBAAuB,wBAAC,UAA8B;AACjE,UAAQ,IAAI,yBAAyB,KAAK;AAC1C,QAAM,EAAE,WAAW,cAAc,WAAW,IAAI;AAChD,SAAO;AAAA,IACL,WAAW,aAAa;AAAA,IACxB,cAAc,gBAAgB;AAAA,IAC9B,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;AAAA,EACrC,CAAC;AACH,GARoC;AAU7B,MAAM,wBAAwB,6BAA0B;AAC7D,SAAO;AAAA,IACL,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,cAAc,OAAO;AAAA,IACrB,WAAW,QAAQ;AAAA,EACrB;AACF,GAPqC;AAU9B,IAAI,WAAW,IAAI,oCAAc;AAAA,EACtC,eAAe;AAAA,EACf,WAAW,sBAAsB;AAAA,EACjC,WAAW;AACb,CAAC;AAGD,IAAI;AACF,SAAO,YAAY,OAAO,iBACtB,mCAAqB,OAAO,UAAU,IACtC;AACN,SAAS,GAAG;AACV,UAAQ,MAAM,8BAA8B,CAAC;AAC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E,GAAG,SAAS,QAAQ,SAAS,GAAG,GAAG,QAAQ;AACvD,0BAAM,UAAU,OAAO;AACzB,GAHyB;AAKlB,MAAM,iBAAiB,6BAAY;AACxC,eAAa,CAAC;AACd,0BAAM,aAAa,UAAU;AAC/B,GAH8B;","names":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.9.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.9.6) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.6 */
|
|
3
3
|
export * from "./near.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/near.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.9.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.9.6) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.6 */
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
5
|
import Big from "big.js";
|
package/dist/esm/state.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.9.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.9.6) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.6 */
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
5
|
import {
|
|
@@ -38,7 +38,7 @@ const getWalletAdapterState = /* @__PURE__ */ __name(() => {
|
|
|
38
38
|
publicKey: _state.publicKey,
|
|
39
39
|
accountId: _state.accountId,
|
|
40
40
|
lastWalletId: _state.lastWalletId,
|
|
41
|
-
networkId:
|
|
41
|
+
networkId: _config.networkId
|
|
42
42
|
};
|
|
43
43
|
}, "getWalletAdapterState");
|
|
44
44
|
let _adapter = new WalletAdapter({
|
package/dist/esm/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/state.ts"],"sourcesContent":["import {\n lsSet,\n lsGet,\n publicKeyFromPrivate,\n} from \"@fastnear/utils\";\nimport {WalletAdapter} from \"@fastnear/wallet-adapter\";\n\nexport const WIDGET_URL = \"https://js.cdn.fastnear.com\";\n\nexport const DEFAULT_NETWORK_ID = \"mainnet\";\nexport const NETWORKS = {\n testnet: {\n networkId: \"testnet\",\n nodeUrl: \"https://rpc.testnet.fastnear.com/\",\n },\n mainnet: {\n networkId: \"mainnet\",\n nodeUrl: \"https://rpc.mainnet.fastnear.com/\",\n },\n};\n\nexport interface NetworkConfig {\n networkId: string;\n nodeUrl?: string;\n walletUrl?: string;\n helperUrl?: string;\n explorerUrl?: string;\n\n [key: string]: any;\n}\n\nexport interface AppState {\n accountId?: string | null;\n privateKey?: string | null;\n lastWalletId?: string | null;\n publicKey?: string | null;\n accessKeyContractId?: string | null;\n\n [key: string]: any;\n}\n\nexport interface TxStatus {\n txId: string;\n updateTimestamp?: number;\n\n [key: string]: any;\n}\n\nexport type TxHistory = Record<string, TxStatus>;\n\nexport interface EventListeners {\n account: Set<(accountId: string) => void>;\n tx: Set<(tx: TxStatus) => void>;\n}\n\nexport interface UnbroadcastedEvents {\n account: string[];\n tx: TxStatus[];\n}\n\nexport interface WalletAdapterState {\n publicKey?: string | null;\n privateKey?: string | null;\n accountId?: string | null;\n lastWalletId?: string | null;\n networkId: string;\n}\n\n\n// Load config from localStorage or default to the network's config\nexport let _config: NetworkConfig = lsGet(\"config\") || {\n ...NETWORKS[DEFAULT_NETWORK_ID]\n};\n\n// Load application state from localStorage\nexport let _state: AppState = lsGet(\"state\") || {};\n\n// Triggered by the wallet adapter\nexport const onAdapterStateUpdate = (state: WalletAdapterState) => {\n console.log(\"Adapter state update:\", state);\n const { accountId, lastWalletId, privateKey } = state;\n update({\n accountId: accountId || undefined,\n lastWalletId: lastWalletId || undefined,\n ...(privateKey ? { privateKey } : {}),\n });\n}\n\nexport const getWalletAdapterState = (): WalletAdapterState => {\n return {\n publicKey: _state.publicKey,\n accountId: _state.accountId,\n lastWalletId: _state.lastWalletId,\n networkId:
|
|
1
|
+
{"version":3,"sources":["../../src/state.ts"],"sourcesContent":["import {\n lsSet,\n lsGet,\n publicKeyFromPrivate,\n} from \"@fastnear/utils\";\nimport {WalletAdapter} from \"@fastnear/wallet-adapter\";\n\nexport const WIDGET_URL = \"https://js.cdn.fastnear.com\";\n\nexport const DEFAULT_NETWORK_ID = \"mainnet\";\nexport const NETWORKS = {\n testnet: {\n networkId: \"testnet\",\n nodeUrl: \"https://rpc.testnet.fastnear.com/\",\n },\n mainnet: {\n networkId: \"mainnet\",\n nodeUrl: \"https://rpc.mainnet.fastnear.com/\",\n },\n};\n\nexport interface NetworkConfig {\n networkId: string;\n nodeUrl?: string;\n walletUrl?: string;\n helperUrl?: string;\n explorerUrl?: string;\n\n [key: string]: any;\n}\n\nexport interface AppState {\n accountId?: string | null;\n privateKey?: string | null;\n lastWalletId?: string | null;\n publicKey?: string | null;\n accessKeyContractId?: string | null;\n\n [key: string]: any;\n}\n\nexport interface TxStatus {\n txId: string;\n updateTimestamp?: number;\n\n [key: string]: any;\n}\n\nexport type TxHistory = Record<string, TxStatus>;\n\nexport interface EventListeners {\n account: Set<(accountId: string) => void>;\n tx: Set<(tx: TxStatus) => void>;\n}\n\nexport interface UnbroadcastedEvents {\n account: string[];\n tx: TxStatus[];\n}\n\nexport interface WalletAdapterState {\n publicKey?: string | null;\n privateKey?: string | null;\n accountId?: string | null;\n lastWalletId?: string | null;\n networkId: string;\n}\n\n\n// Load config from localStorage or default to the network's config\nexport let _config: NetworkConfig = lsGet(\"config\") || {\n ...NETWORKS[DEFAULT_NETWORK_ID]\n};\n\n// Load application state from localStorage\nexport let _state: AppState = lsGet(\"state\") || {};\n\n// Triggered by the wallet adapter\nexport const onAdapterStateUpdate = (state: WalletAdapterState) => {\n console.log(\"Adapter state update:\", state);\n const { accountId, lastWalletId, privateKey } = state;\n update({\n accountId: accountId || undefined,\n lastWalletId: lastWalletId || undefined,\n ...(privateKey ? { privateKey } : {}),\n });\n}\n\nexport const getWalletAdapterState = (): WalletAdapterState => {\n return {\n publicKey: _state.publicKey,\n accountId: _state.accountId,\n lastWalletId: _state.lastWalletId,\n networkId: _config.networkId,\n };\n}\n\n// We can create an adapter instance here\nexport let _adapter = new WalletAdapter({\n onStateUpdate: onAdapterStateUpdate,\n lastState: getWalletAdapterState(),\n widgetUrl: WIDGET_URL,\n});\n\n// Attempt to set publicKey if we have a privateKey\ntry {\n _state.publicKey = _state.privateKey\n ? publicKeyFromPrivate(_state.privateKey)\n : null;\n} catch (e) {\n console.error(\"Error parsing private key:\", e);\n _state.privateKey = null;\n lsSet(\"nonce\", null);\n}\n\n// Transaction history\nexport let _txHistory: TxHistory = lsGet(\"txHistory\") || {};\n\n\nexport const _unbroadcastedEvents: UnbroadcastedEvents = {\n account: [],\n tx: [],\n};\n\n// events / listeners\nexport const events = {\n _eventListeners: {\n account: new Set(),\n tx: new Set(),\n },\n\n notifyAccountListeners: (accountId: string) => {\n if (events._eventListeners.account.size === 0) {\n _unbroadcastedEvents.account.push(accountId);\n return;\n }\n events._eventListeners.account.forEach((callback: any) => {\n try {\n callback(accountId);\n } catch (e) {\n console.error(e);\n }\n });\n },\n\n notifyTxListeners: (tx: TxStatus) => {\n if (events._eventListeners.tx.size === 0) {\n _unbroadcastedEvents.tx.push(tx);\n return;\n }\n events._eventListeners.tx.forEach((callback: any) => {\n try {\n callback(tx);\n } catch (e) {\n console.error(e);\n }\n });\n },\n\n onAccount: (callback: (accountId: string) => void) => {\n events._eventListeners.account.add(callback);\n if (_unbroadcastedEvents.account.length > 0) {\n const accountEvent = _unbroadcastedEvents.account;\n _unbroadcastedEvents.account = [];\n accountEvent.forEach(events.notifyAccountListeners);\n }\n },\n\n onTx: (callback: (tx: TxStatus) => void): void => {\n events._eventListeners.tx.add(callback);\n if (_unbroadcastedEvents.tx.length > 0) {\n const txEvent = _unbroadcastedEvents.tx;\n _unbroadcastedEvents.tx = [];\n txEvent.forEach(events.notifyTxListeners);\n }\n }\n}\n\n// Mutators\n// @todo: in favor of limiting when out of alpha\n// but haven't given it enough thought ~ mike\nexport const update = (newState: Partial<AppState>) => {\n const oldState = _state;\n _state = {..._state, ...newState};\n\n lsSet(\"state\", {\n accountId: _state.accountId,\n privateKey: _state.privateKey,\n lastWalletId: _state.lastWalletId,\n accessKeyContractId: _state.accessKeyContractId,\n });\n\n if (\n newState.hasOwnProperty(\"privateKey\") &&\n newState.privateKey !== oldState.privateKey\n ) {\n _state.publicKey = newState.privateKey\n ? publicKeyFromPrivate(newState.privateKey as string)\n : null;\n lsSet(\"nonce\", null);\n }\n\n if (newState.accountId !== oldState.accountId) {\n events.notifyAccountListeners(newState.accountId as string);\n }\n\n if (\n (newState.hasOwnProperty(\"lastWalletId\") &&\n newState.lastWalletId !== oldState.lastWalletId) ||\n (newState.hasOwnProperty(\"accountId\") &&\n newState.accountId !== oldState.accountId) ||\n (newState.hasOwnProperty(\"privateKey\") &&\n newState.privateKey !== oldState.privateKey)\n ) {\n _adapter.setState(getWalletAdapterState());\n }\n}\n\nexport const updateTxHistory = (txStatus: TxStatus) => {\n const txId = txStatus.txId;\n _txHistory[txId] = {\n ...(_txHistory[txId] || {}),\n ...txStatus,\n updateTimestamp: Date.now(),\n };\n lsSet(\"txHistory\", _txHistory);\n events.notifyTxListeners(_txHistory[txId]);\n}\n\nexport const getConfig = (): NetworkConfig => {\n return _config;\n}\n\nexport const getTxHistory = (): TxHistory => {\n return _txHistory;\n}\n\n// Exposed \"write\" functions\nexport const setConfig = (newConf: NetworkConfig): void => {\n _config = { ...NETWORKS[newConf.networkId], ...newConf };\n lsSet(\"config\", _config);\n}\n\nexport const resetTxHistory = (): void => {\n _txHistory = {};\n lsSet(\"txHistory\", _txHistory);\n}\n"],"mappings":";;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAQ,qBAAoB;AAErB,MAAM,aAAa;AAEnB,MAAM,qBAAqB;AAC3B,MAAM,WAAW;AAAA,EACtB,SAAS;AAAA,IACP,WAAW;AAAA,IACX,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,WAAW;AAAA,IACX,SAAS;AAAA,EACX;AACF;AAmDO,IAAI,UAAyB,MAAM,QAAQ,KAAK;AAAA,EACrD,GAAG,SAAS,kBAAkB;AAChC;AAGO,IAAI,SAAmB,MAAM,OAAO,KAAK,CAAC;AAG1C,MAAM,uBAAuB,wBAAC,UAA8B;AACjE,UAAQ,IAAI,yBAAyB,KAAK;AAC1C,QAAM,EAAE,WAAW,cAAc,WAAW,IAAI;AAChD,SAAO;AAAA,IACL,WAAW,aAAa;AAAA,IACxB,cAAc,gBAAgB;AAAA,IAC9B,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;AAAA,EACrC,CAAC;AACH,GARoC;AAU7B,MAAM,wBAAwB,6BAA0B;AAC7D,SAAO;AAAA,IACL,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,cAAc,OAAO;AAAA,IACrB,WAAW,QAAQ;AAAA,EACrB;AACF,GAPqC;AAU9B,IAAI,WAAW,IAAI,cAAc;AAAA,EACtC,eAAe;AAAA,EACf,WAAW,sBAAsB;AAAA,EACjC,WAAW;AACb,CAAC;AAGD,IAAI;AACF,SAAO,YAAY,OAAO,aACtB,qBAAqB,OAAO,UAAU,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;AAKrB,MAAM,YAAY,wBAAC,YAAiC;AACzD,YAAU,EAAE,GAAG,SAAS,QAAQ,SAAS,GAAG,GAAG,QAAQ;AACvD,QAAM,UAAU,OAAO;AACzB,GAHyB;AAKlB,MAAM,iBAAiB,6BAAY;AACxC,eAAa,CAAC;AACd,QAAM,aAAa,UAAU;AAC/B,GAH8B;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - IIFE/UMD (@fastnear/api version 0.9.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - IIFE/UMD (@fastnear/api version 0.9.6) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.9.6 */
|
|
3
3
|
"use strict";
|
|
4
4
|
var near = (() => {
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -579,7 +579,7 @@ var near = (() => {
|
|
|
579
579
|
txToJsonStringified: () => txToJsonStringified
|
|
580
580
|
});
|
|
581
581
|
|
|
582
|
-
// ../../node_modules/@noble/
|
|
582
|
+
// ../../node_modules/@noble/hashes/esm/_assert.js
|
|
583
583
|
function isBytes(a) {
|
|
584
584
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
585
585
|
}
|
|
@@ -607,11 +607,18 @@ var near = (() => {
|
|
|
607
607
|
}
|
|
608
608
|
__name(aoutput, "aoutput");
|
|
609
609
|
|
|
610
|
-
// ../../node_modules/@noble/
|
|
610
|
+
// ../../node_modules/@noble/hashes/esm/crypto.js
|
|
611
611
|
var crypto2 = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
612
612
|
|
|
613
|
-
// ../../node_modules/@noble/
|
|
614
|
-
|
|
613
|
+
// ../../node_modules/@noble/hashes/esm/utils.js
|
|
614
|
+
function createView(arr) {
|
|
615
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
616
|
+
}
|
|
617
|
+
__name(createView, "createView");
|
|
618
|
+
function rotr(word, shift) {
|
|
619
|
+
return word << 32 - shift | word >>> shift;
|
|
620
|
+
}
|
|
621
|
+
__name(rotr, "rotr");
|
|
615
622
|
function utf8ToBytes(str) {
|
|
616
623
|
if (typeof str !== "string")
|
|
617
624
|
throw new Error("utf8ToBytes expected string, got " + typeof str);
|
|
@@ -654,7 +661,7 @@ var near = (() => {
|
|
|
654
661
|
}
|
|
655
662
|
__name(randomBytes, "randomBytes");
|
|
656
663
|
|
|
657
|
-
// ../../node_modules/@noble/
|
|
664
|
+
// ../../node_modules/@noble/hashes/esm/_md.js
|
|
658
665
|
function setBigUint64(view2, byteOffset, value, isLE) {
|
|
659
666
|
if (typeof view2.setBigUint64 === "function")
|
|
660
667
|
return view2.setBigUint64(byteOffset, value, isLE);
|
|
@@ -668,6 +675,14 @@ var near = (() => {
|
|
|
668
675
|
view2.setUint32(byteOffset + l, wl, isLE);
|
|
669
676
|
}
|
|
670
677
|
__name(setBigUint64, "setBigUint64");
|
|
678
|
+
function Chi(a, b, c) {
|
|
679
|
+
return a & b ^ ~a & c;
|
|
680
|
+
}
|
|
681
|
+
__name(Chi, "Chi");
|
|
682
|
+
function Maj(a, b, c) {
|
|
683
|
+
return a & b ^ a & c ^ b & c;
|
|
684
|
+
}
|
|
685
|
+
__name(Maj, "Maj");
|
|
671
686
|
var HashMD = class extends Hash {
|
|
672
687
|
static {
|
|
673
688
|
__name(this, "HashMD");
|
|
@@ -758,7 +773,7 @@ var near = (() => {
|
|
|
758
773
|
}
|
|
759
774
|
};
|
|
760
775
|
|
|
761
|
-
// ../../node_modules/@noble/
|
|
776
|
+
// ../../node_modules/@noble/hashes/esm/_u64.js
|
|
762
777
|
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
763
778
|
var _32n = /* @__PURE__ */ BigInt(32);
|
|
764
779
|
function fromBig(n, le = false) {
|
|
@@ -827,7 +842,7 @@ var near = (() => {
|
|
|
827
842
|
};
|
|
828
843
|
var u64_default = u64;
|
|
829
844
|
|
|
830
|
-
// ../../node_modules/@noble/
|
|
845
|
+
// ../../node_modules/@noble/hashes/esm/sha512.js
|
|
831
846
|
var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64_default.split([
|
|
832
847
|
"0x428a2f98d728ae22",
|
|
833
848
|
"0x7137449123ef65cd",
|
|
@@ -1427,6 +1442,7 @@ var near = (() => {
|
|
|
1427
1442
|
let sqrtP;
|
|
1428
1443
|
const f = Object.freeze({
|
|
1429
1444
|
ORDER,
|
|
1445
|
+
isLE,
|
|
1430
1446
|
BITS,
|
|
1431
1447
|
BYTES,
|
|
1432
1448
|
MASK: bitMask(BITS),
|
|
@@ -2193,175 +2209,6 @@ var near = (() => {
|
|
|
2193
2209
|
}))();
|
|
2194
2210
|
var ed25519 = /* @__PURE__ */ (() => twistedEdwards(ed25519Defaults))();
|
|
2195
2211
|
|
|
2196
|
-
// ../../node_modules/@noble/hashes/esm/_assert.js
|
|
2197
|
-
function isBytes3(a) {
|
|
2198
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
2199
|
-
}
|
|
2200
|
-
__name(isBytes3, "isBytes");
|
|
2201
|
-
function abytes3(b, ...lengths) {
|
|
2202
|
-
if (!isBytes3(b))
|
|
2203
|
-
throw new Error("Uint8Array expected");
|
|
2204
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
2205
|
-
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
2206
|
-
}
|
|
2207
|
-
__name(abytes3, "abytes");
|
|
2208
|
-
function aexists2(instance, checkFinished = true) {
|
|
2209
|
-
if (instance.destroyed)
|
|
2210
|
-
throw new Error("Hash instance has been destroyed");
|
|
2211
|
-
if (checkFinished && instance.finished)
|
|
2212
|
-
throw new Error("Hash#digest() has already been called");
|
|
2213
|
-
}
|
|
2214
|
-
__name(aexists2, "aexists");
|
|
2215
|
-
function aoutput2(out, instance) {
|
|
2216
|
-
abytes3(out);
|
|
2217
|
-
const min = instance.outputLen;
|
|
2218
|
-
if (out.length < min) {
|
|
2219
|
-
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
__name(aoutput2, "aoutput");
|
|
2223
|
-
|
|
2224
|
-
// ../../node_modules/@noble/hashes/esm/utils.js
|
|
2225
|
-
var createView2 = /* @__PURE__ */ __name((arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength), "createView");
|
|
2226
|
-
var rotr = /* @__PURE__ */ __name((word, shift) => word << 32 - shift | word >>> shift, "rotr");
|
|
2227
|
-
function utf8ToBytes2(str) {
|
|
2228
|
-
if (typeof str !== "string")
|
|
2229
|
-
throw new Error("utf8ToBytes expected string, got " + typeof str);
|
|
2230
|
-
return new Uint8Array(new TextEncoder().encode(str));
|
|
2231
|
-
}
|
|
2232
|
-
__name(utf8ToBytes2, "utf8ToBytes");
|
|
2233
|
-
function toBytes2(data) {
|
|
2234
|
-
if (typeof data === "string")
|
|
2235
|
-
data = utf8ToBytes2(data);
|
|
2236
|
-
abytes3(data);
|
|
2237
|
-
return data;
|
|
2238
|
-
}
|
|
2239
|
-
__name(toBytes2, "toBytes");
|
|
2240
|
-
var Hash2 = class {
|
|
2241
|
-
static {
|
|
2242
|
-
__name(this, "Hash");
|
|
2243
|
-
}
|
|
2244
|
-
// Safe version that clones internal state
|
|
2245
|
-
clone() {
|
|
2246
|
-
return this._cloneInto();
|
|
2247
|
-
}
|
|
2248
|
-
};
|
|
2249
|
-
function wrapConstructor2(hashCons) {
|
|
2250
|
-
const hashC = /* @__PURE__ */ __name((msg) => hashCons().update(toBytes2(msg)).digest(), "hashC");
|
|
2251
|
-
const tmp = hashCons();
|
|
2252
|
-
hashC.outputLen = tmp.outputLen;
|
|
2253
|
-
hashC.blockLen = tmp.blockLen;
|
|
2254
|
-
hashC.create = () => hashCons();
|
|
2255
|
-
return hashC;
|
|
2256
|
-
}
|
|
2257
|
-
__name(wrapConstructor2, "wrapConstructor");
|
|
2258
|
-
|
|
2259
|
-
// ../../node_modules/@noble/hashes/esm/_md.js
|
|
2260
|
-
function setBigUint642(view2, byteOffset, value, isLE) {
|
|
2261
|
-
if (typeof view2.setBigUint64 === "function")
|
|
2262
|
-
return view2.setBigUint64(byteOffset, value, isLE);
|
|
2263
|
-
const _32n2 = BigInt(32);
|
|
2264
|
-
const _u32_max = BigInt(4294967295);
|
|
2265
|
-
const wh = Number(value >> _32n2 & _u32_max);
|
|
2266
|
-
const wl = Number(value & _u32_max);
|
|
2267
|
-
const h = isLE ? 4 : 0;
|
|
2268
|
-
const l = isLE ? 0 : 4;
|
|
2269
|
-
view2.setUint32(byteOffset + h, wh, isLE);
|
|
2270
|
-
view2.setUint32(byteOffset + l, wl, isLE);
|
|
2271
|
-
}
|
|
2272
|
-
__name(setBigUint642, "setBigUint64");
|
|
2273
|
-
var Chi = /* @__PURE__ */ __name((a, b, c) => a & b ^ ~a & c, "Chi");
|
|
2274
|
-
var Maj = /* @__PURE__ */ __name((a, b, c) => a & b ^ a & c ^ b & c, "Maj");
|
|
2275
|
-
var HashMD2 = class extends Hash2 {
|
|
2276
|
-
static {
|
|
2277
|
-
__name(this, "HashMD");
|
|
2278
|
-
}
|
|
2279
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
2280
|
-
super();
|
|
2281
|
-
this.blockLen = blockLen;
|
|
2282
|
-
this.outputLen = outputLen;
|
|
2283
|
-
this.padOffset = padOffset;
|
|
2284
|
-
this.isLE = isLE;
|
|
2285
|
-
this.finished = false;
|
|
2286
|
-
this.length = 0;
|
|
2287
|
-
this.pos = 0;
|
|
2288
|
-
this.destroyed = false;
|
|
2289
|
-
this.buffer = new Uint8Array(blockLen);
|
|
2290
|
-
this.view = createView2(this.buffer);
|
|
2291
|
-
}
|
|
2292
|
-
update(data) {
|
|
2293
|
-
aexists2(this);
|
|
2294
|
-
const { view: view2, buffer, blockLen } = this;
|
|
2295
|
-
data = toBytes2(data);
|
|
2296
|
-
const len = data.length;
|
|
2297
|
-
for (let pos = 0; pos < len; ) {
|
|
2298
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
2299
|
-
if (take === blockLen) {
|
|
2300
|
-
const dataView = createView2(data);
|
|
2301
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
2302
|
-
this.process(dataView, pos);
|
|
2303
|
-
continue;
|
|
2304
|
-
}
|
|
2305
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
2306
|
-
this.pos += take;
|
|
2307
|
-
pos += take;
|
|
2308
|
-
if (this.pos === blockLen) {
|
|
2309
|
-
this.process(view2, 0);
|
|
2310
|
-
this.pos = 0;
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
this.length += data.length;
|
|
2314
|
-
this.roundClean();
|
|
2315
|
-
return this;
|
|
2316
|
-
}
|
|
2317
|
-
digestInto(out) {
|
|
2318
|
-
aexists2(this);
|
|
2319
|
-
aoutput2(out, this);
|
|
2320
|
-
this.finished = true;
|
|
2321
|
-
const { buffer, view: view2, blockLen, isLE } = this;
|
|
2322
|
-
let { pos } = this;
|
|
2323
|
-
buffer[pos++] = 128;
|
|
2324
|
-
this.buffer.subarray(pos).fill(0);
|
|
2325
|
-
if (this.padOffset > blockLen - pos) {
|
|
2326
|
-
this.process(view2, 0);
|
|
2327
|
-
pos = 0;
|
|
2328
|
-
}
|
|
2329
|
-
for (let i = pos; i < blockLen; i++)
|
|
2330
|
-
buffer[i] = 0;
|
|
2331
|
-
setBigUint642(view2, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
2332
|
-
this.process(view2, 0);
|
|
2333
|
-
const oview = createView2(out);
|
|
2334
|
-
const len = this.outputLen;
|
|
2335
|
-
if (len % 4)
|
|
2336
|
-
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
2337
|
-
const outLen = len / 4;
|
|
2338
|
-
const state2 = this.get();
|
|
2339
|
-
if (outLen > state2.length)
|
|
2340
|
-
throw new Error("_sha2: outputLen bigger than state");
|
|
2341
|
-
for (let i = 0; i < outLen; i++)
|
|
2342
|
-
oview.setUint32(4 * i, state2[i], isLE);
|
|
2343
|
-
}
|
|
2344
|
-
digest() {
|
|
2345
|
-
const { buffer, outputLen } = this;
|
|
2346
|
-
this.digestInto(buffer);
|
|
2347
|
-
const res = buffer.slice(0, outputLen);
|
|
2348
|
-
this.destroy();
|
|
2349
|
-
return res;
|
|
2350
|
-
}
|
|
2351
|
-
_cloneInto(to) {
|
|
2352
|
-
to || (to = new this.constructor());
|
|
2353
|
-
to.set(...this.get());
|
|
2354
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
2355
|
-
to.length = length;
|
|
2356
|
-
to.pos = pos;
|
|
2357
|
-
to.finished = finished;
|
|
2358
|
-
to.destroyed = destroyed;
|
|
2359
|
-
if (length % blockLen)
|
|
2360
|
-
to.buffer.set(buffer);
|
|
2361
|
-
return to;
|
|
2362
|
-
}
|
|
2363
|
-
};
|
|
2364
|
-
|
|
2365
2212
|
// ../../node_modules/@noble/hashes/esm/sha256.js
|
|
2366
2213
|
var SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
2367
2214
|
1116352408,
|
|
@@ -2440,7 +2287,7 @@ var near = (() => {
|
|
|
2440
2287
|
1541459225
|
|
2441
2288
|
]);
|
|
2442
2289
|
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
2443
|
-
var SHA256 = class extends
|
|
2290
|
+
var SHA256 = class extends HashMD {
|
|
2444
2291
|
static {
|
|
2445
2292
|
__name(this, "SHA256");
|
|
2446
2293
|
}
|
|
@@ -2513,7 +2360,7 @@ var near = (() => {
|
|
|
2513
2360
|
this.buffer.fill(0);
|
|
2514
2361
|
}
|
|
2515
2362
|
};
|
|
2516
|
-
var sha256 = /* @__PURE__ */
|
|
2363
|
+
var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
2517
2364
|
|
|
2518
2365
|
// ../../node_modules/base58-js/base58_chars.mjs
|
|
2519
2366
|
var base58_chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -3616,16 +3463,12 @@ var near = (() => {
|
|
|
3616
3463
|
};
|
|
3617
3464
|
}
|
|
3618
3465
|
case "FunctionCall": {
|
|
3619
|
-
const argsAsString = JSON.stringify(action.args);
|
|
3620
|
-
const argsEncoded = new TextEncoder().encode(argsAsString);
|
|
3621
|
-
const defaultGas = BigInt("225000000000000");
|
|
3622
|
-
const defaultDeposit = BigInt("0");
|
|
3623
3466
|
return {
|
|
3624
3467
|
functionCall: {
|
|
3625
3468
|
methodName: action.methodName,
|
|
3626
|
-
args:
|
|
3627
|
-
gas: BigInt(action.gas ??
|
|
3628
|
-
deposit: BigInt(action.deposit ??
|
|
3469
|
+
args: action.argsBase64 !== null && action.argsBase64 !== void 0 ? fromBase64(action.argsBase64) : new TextEncoder().encode(JSON.stringify(action.args)),
|
|
3470
|
+
gas: BigInt(action.gas ?? "300000000000000"),
|
|
3471
|
+
deposit: BigInt(action.deposit ?? "0")
|
|
3629
3472
|
}
|
|
3630
3473
|
};
|
|
3631
3474
|
}
|
|
@@ -3928,7 +3771,7 @@ var near = (() => {
|
|
|
3928
3771
|
publicKey: _state.publicKey,
|
|
3929
3772
|
accountId: _state.accountId,
|
|
3930
3773
|
lastWalletId: _state.lastWalletId,
|
|
3931
|
-
networkId:
|
|
3774
|
+
networkId: _config.networkId
|
|
3932
3775
|
};
|
|
3933
3776
|
}, "getWalletAdapterState");
|
|
3934
3777
|
var _adapter = new WalletAdapter({
|
|
@@ -4518,9 +4361,6 @@ message: ${decodedErrMsg}`));
|
|
|
4518
4361
|
|
|
4519
4362
|
@noble/curves/esm/ed25519.js:
|
|
4520
4363
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4521
|
-
|
|
4522
|
-
@noble/hashes/esm/utils.js:
|
|
4523
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4524
4364
|
*/
|
|
4525
4365
|
|
|
4526
4366
|
try {
|