@fastnear/api 0.7.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +38 -59
- package/dist/cjs/near.cjs +81 -37
- package/dist/cjs/near.cjs.map +1 -1
- package/dist/cjs/state.cjs +60 -66
- package/dist/cjs/state.cjs.map +1 -1
- package/dist/esm/index.d.ts +38 -59
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/near.js +77 -37
- package/dist/esm/near.js.map +1 -1
- package/dist/esm/state.js +58 -60
- package/dist/esm/state.js.map +1 -1
- package/dist/umd/browser.global.js +2551 -2507
- package/dist/umd/browser.global.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/state.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.8.0) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.8.0 */
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -26,27 +26,23 @@ __export(state_exports, {
|
|
|
26
26
|
WIDGET_URL: () => WIDGET_URL,
|
|
27
27
|
_adapter: () => _adapter,
|
|
28
28
|
_config: () => _config,
|
|
29
|
-
_eventListeners: () => _eventListeners,
|
|
30
29
|
_state: () => _state,
|
|
31
30
|
_txHistory: () => _txHistory,
|
|
32
31
|
_unbroadcastedEvents: () => _unbroadcastedEvents,
|
|
32
|
+
events: () => events,
|
|
33
33
|
getConfig: () => getConfig,
|
|
34
34
|
getTxHistory: () => getTxHistory,
|
|
35
35
|
getWalletAdapterState: () => getWalletAdapterState,
|
|
36
|
-
notifyAccountListeners: () => notifyAccountListeners,
|
|
37
|
-
notifyTxListeners: () => notifyTxListeners,
|
|
38
|
-
onAccount: () => onAccount,
|
|
39
36
|
onAdapterStateUpdate: () => onAdapterStateUpdate,
|
|
40
|
-
onTx: () => onTx,
|
|
41
37
|
resetTxHistory: () => resetTxHistory,
|
|
42
38
|
setConfig: () => setConfig,
|
|
43
|
-
|
|
39
|
+
update: () => update,
|
|
44
40
|
updateTxHistory: () => updateTxHistory
|
|
45
41
|
});
|
|
46
42
|
module.exports = __toCommonJS(state_exports);
|
|
47
43
|
var import_utils = require("@fastnear/utils");
|
|
48
44
|
var import_wallet_adapter = require("@fastnear/wallet-adapter");
|
|
49
|
-
const WIDGET_URL = "https://
|
|
45
|
+
const WIDGET_URL = "https://js.cdn.fastnear.com";
|
|
50
46
|
const DEFAULT_NETWORK_ID = "mainnet";
|
|
51
47
|
const NETWORKS = {
|
|
52
48
|
testnet: {
|
|
@@ -65,7 +61,7 @@ let _state = (0, import_utils.lsGet)("state") || {};
|
|
|
65
61
|
const onAdapterStateUpdate = /* @__PURE__ */ __name((state) => {
|
|
66
62
|
console.log("Adapter state update:", state);
|
|
67
63
|
const { accountId, lastWalletId, privateKey } = state;
|
|
68
|
-
|
|
64
|
+
update({
|
|
69
65
|
accountId: accountId || void 0,
|
|
70
66
|
lastWalletId: lastWalletId || void 0,
|
|
71
67
|
...privateKey ? { privateKey } : {}
|
|
@@ -92,15 +88,59 @@ try {
|
|
|
92
88
|
(0, import_utils.lsSet)("nonce", null);
|
|
93
89
|
}
|
|
94
90
|
let _txHistory = (0, import_utils.lsGet)("txHistory") || {};
|
|
95
|
-
const _eventListeners = {
|
|
96
|
-
account: /* @__PURE__ */ new Set(),
|
|
97
|
-
tx: /* @__PURE__ */ new Set()
|
|
98
|
-
};
|
|
99
91
|
const _unbroadcastedEvents = {
|
|
100
92
|
account: [],
|
|
101
93
|
tx: []
|
|
102
94
|
};
|
|
103
|
-
const
|
|
95
|
+
const events = {
|
|
96
|
+
_eventListeners: {
|
|
97
|
+
account: /* @__PURE__ */ new Set(),
|
|
98
|
+
tx: /* @__PURE__ */ new Set()
|
|
99
|
+
},
|
|
100
|
+
notifyAccountListeners: /* @__PURE__ */ __name((accountId) => {
|
|
101
|
+
if (events._eventListeners.account.size === 0) {
|
|
102
|
+
_unbroadcastedEvents.account.push(accountId);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
events._eventListeners.account.forEach((callback) => {
|
|
106
|
+
try {
|
|
107
|
+
callback(accountId);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.error(e);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}, "notifyAccountListeners"),
|
|
113
|
+
notifyTxListeners: /* @__PURE__ */ __name((tx) => {
|
|
114
|
+
if (events._eventListeners.tx.size === 0) {
|
|
115
|
+
_unbroadcastedEvents.tx.push(tx);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
events._eventListeners.tx.forEach((callback) => {
|
|
119
|
+
try {
|
|
120
|
+
callback(tx);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.error(e);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}, "notifyTxListeners"),
|
|
126
|
+
onAccount: /* @__PURE__ */ __name((callback) => {
|
|
127
|
+
events._eventListeners.account.add(callback);
|
|
128
|
+
if (_unbroadcastedEvents.account.length > 0) {
|
|
129
|
+
const accountEvent = _unbroadcastedEvents.account;
|
|
130
|
+
_unbroadcastedEvents.account = [];
|
|
131
|
+
accountEvent.forEach(events.notifyAccountListeners);
|
|
132
|
+
}
|
|
133
|
+
}, "onAccount"),
|
|
134
|
+
onTx: /* @__PURE__ */ __name((callback) => {
|
|
135
|
+
events._eventListeners.tx.add(callback);
|
|
136
|
+
if (_unbroadcastedEvents.tx.length > 0) {
|
|
137
|
+
const txEvent = _unbroadcastedEvents.tx;
|
|
138
|
+
_unbroadcastedEvents.tx = [];
|
|
139
|
+
txEvent.forEach(events.notifyTxListeners);
|
|
140
|
+
}
|
|
141
|
+
}, "onTx")
|
|
142
|
+
};
|
|
143
|
+
const update = /* @__PURE__ */ __name((newState) => {
|
|
104
144
|
const oldState = _state;
|
|
105
145
|
_state = { ..._state, ...newState };
|
|
106
146
|
(0, import_utils.lsSet)("state", {
|
|
@@ -114,12 +154,12 @@ const updateState = /* @__PURE__ */ __name((newState) => {
|
|
|
114
154
|
(0, import_utils.lsSet)("nonce", null);
|
|
115
155
|
}
|
|
116
156
|
if (newState.accountId !== oldState.accountId) {
|
|
117
|
-
notifyAccountListeners(newState.accountId);
|
|
157
|
+
events.notifyAccountListeners(newState.accountId);
|
|
118
158
|
}
|
|
119
159
|
if (newState.hasOwnProperty("lastWalletId") && newState.lastWalletId !== oldState.lastWalletId || newState.hasOwnProperty("accountId") && newState.accountId !== oldState.accountId || newState.hasOwnProperty("privateKey") && newState.privateKey !== oldState.privateKey) {
|
|
120
160
|
_adapter.setState(getWalletAdapterState());
|
|
121
161
|
}
|
|
122
|
-
}, "
|
|
162
|
+
}, "update");
|
|
123
163
|
const updateTxHistory = /* @__PURE__ */ __name((txStatus) => {
|
|
124
164
|
const txId = txStatus.txId;
|
|
125
165
|
_txHistory[txId] = {
|
|
@@ -128,50 +168,8 @@ const updateTxHistory = /* @__PURE__ */ __name((txStatus) => {
|
|
|
128
168
|
updateTimestamp: Date.now()
|
|
129
169
|
};
|
|
130
170
|
(0, import_utils.lsSet)("txHistory", _txHistory);
|
|
131
|
-
notifyTxListeners(_txHistory[txId]);
|
|
171
|
+
events.notifyTxListeners(_txHistory[txId]);
|
|
132
172
|
}, "updateTxHistory");
|
|
133
|
-
const notifyAccountListeners = /* @__PURE__ */ __name((accountId) => {
|
|
134
|
-
if (_eventListeners.account.size === 0) {
|
|
135
|
-
_unbroadcastedEvents.account.push(accountId);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
_eventListeners.account.forEach((callback) => {
|
|
139
|
-
try {
|
|
140
|
-
callback(accountId);
|
|
141
|
-
} catch (e) {
|
|
142
|
-
console.error(e);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}, "notifyAccountListeners");
|
|
146
|
-
const notifyTxListeners = /* @__PURE__ */ __name((tx) => {
|
|
147
|
-
if (_eventListeners.tx.size === 0) {
|
|
148
|
-
_unbroadcastedEvents.tx.push(tx);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
_eventListeners.tx.forEach((callback) => {
|
|
152
|
-
try {
|
|
153
|
-
callback(tx);
|
|
154
|
-
} catch (e) {
|
|
155
|
-
console.error(e);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}, "notifyTxListeners");
|
|
159
|
-
const onAccount = /* @__PURE__ */ __name((callback) => {
|
|
160
|
-
_eventListeners.account.add(callback);
|
|
161
|
-
if (_unbroadcastedEvents.account.length > 0) {
|
|
162
|
-
const events = _unbroadcastedEvents.account;
|
|
163
|
-
_unbroadcastedEvents.account = [];
|
|
164
|
-
events.forEach(notifyAccountListeners);
|
|
165
|
-
}
|
|
166
|
-
}, "onAccount");
|
|
167
|
-
const onTx = /* @__PURE__ */ __name((callback) => {
|
|
168
|
-
_eventListeners.tx.add(callback);
|
|
169
|
-
if (_unbroadcastedEvents.tx.length > 0) {
|
|
170
|
-
const events = _unbroadcastedEvents.tx;
|
|
171
|
-
_unbroadcastedEvents.tx = [];
|
|
172
|
-
events.forEach(notifyTxListeners);
|
|
173
|
-
}
|
|
174
|
-
}, "onTx");
|
|
175
173
|
const getConfig = /* @__PURE__ */ __name(() => {
|
|
176
174
|
return _config;
|
|
177
175
|
}, "getConfig");
|
|
@@ -193,21 +191,17 @@ const resetTxHistory = /* @__PURE__ */ __name(() => {
|
|
|
193
191
|
WIDGET_URL,
|
|
194
192
|
_adapter,
|
|
195
193
|
_config,
|
|
196
|
-
_eventListeners,
|
|
197
194
|
_state,
|
|
198
195
|
_txHistory,
|
|
199
196
|
_unbroadcastedEvents,
|
|
197
|
+
events,
|
|
200
198
|
getConfig,
|
|
201
199
|
getTxHistory,
|
|
202
200
|
getWalletAdapterState,
|
|
203
|
-
notifyAccountListeners,
|
|
204
|
-
notifyTxListeners,
|
|
205
|
-
onAccount,
|
|
206
201
|
onAdapterStateUpdate,
|
|
207
|
-
onTx,
|
|
208
202
|
resetTxHistory,
|
|
209
203
|
setConfig,
|
|
210
|
-
|
|
204
|
+
update,
|
|
211
205
|
updateTxHistory
|
|
212
206
|
});
|
|
213
207
|
//# sourceMappingURL=state.cjs.map
|
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://
|
|
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: DEFAULT_NETWORK_ID,\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,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,KAAK,CAAC;AAAA,IACzB,GAAG;AAAA,IACH,iBAAiB,KAAK,IAAI;AAAA,EAC5B;AACA,0BAAM,aAAa,UAAU;AAC7B,SAAO,kBAAkB,WAAW,IAAI,CAAC;AAC3C,GAT+B;AAWxB,MAAM,YAAY,6BAAqB;AAC5C,SAAO;AACT,GAFyB;AAIlB,MAAM,eAAe,6BAAiB;AAC3C,SAAO;AACT,GAF4B;AAKrB,MAAM,YAAY,wBAAC,YAAiC;AACzD,YAAU,EAAE,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.d.ts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import { WalletAdapter } from '@fastnear/wallet-adapter';
|
|
2
1
|
import * as borsh from 'borsh';
|
|
3
2
|
|
|
4
|
-
declare const WIDGET_URL = "https://wallet-adapter.fastnear.com";
|
|
5
|
-
declare const DEFAULT_NETWORK_ID = "mainnet";
|
|
6
|
-
declare const NETWORKS: {
|
|
7
|
-
testnet: {
|
|
8
|
-
networkId: string;
|
|
9
|
-
nodeUrl: string;
|
|
10
|
-
};
|
|
11
|
-
mainnet: {
|
|
12
|
-
networkId: string;
|
|
13
|
-
nodeUrl: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
3
|
interface NetworkConfig {
|
|
17
4
|
networkId: string;
|
|
18
5
|
nodeUrl?: string;
|
|
@@ -21,63 +8,42 @@ interface NetworkConfig {
|
|
|
21
8
|
explorerUrl?: string;
|
|
22
9
|
[key: string]: any;
|
|
23
10
|
}
|
|
24
|
-
interface AppState {
|
|
25
|
-
accountId?: string | null;
|
|
26
|
-
privateKey?: string | null;
|
|
27
|
-
lastWalletId?: string | null;
|
|
28
|
-
publicKey?: string | null;
|
|
29
|
-
accessKeyContractId?: string | null;
|
|
30
|
-
[key: string]: any;
|
|
31
|
-
}
|
|
32
11
|
interface TxStatus {
|
|
33
12
|
txId: string;
|
|
34
13
|
updateTimestamp?: number;
|
|
35
14
|
[key: string]: any;
|
|
36
15
|
}
|
|
37
16
|
type TxHistory = Record<string, TxStatus>;
|
|
38
|
-
interface EventListeners {
|
|
39
|
-
account: Set<(accountId: string) => void>;
|
|
40
|
-
tx: Set<(tx: TxStatus) => void>;
|
|
41
|
-
}
|
|
42
|
-
interface UnbroadcastedEvents {
|
|
43
|
-
account: string[];
|
|
44
|
-
tx: TxStatus[];
|
|
45
|
-
}
|
|
46
|
-
interface WalletAdapterState {
|
|
47
|
-
publicKey?: string | null;
|
|
48
|
-
privateKey?: string | null;
|
|
49
|
-
accountId?: string | null;
|
|
50
|
-
lastWalletId?: string | null;
|
|
51
|
-
networkId: string;
|
|
52
|
-
}
|
|
53
|
-
declare let _config: NetworkConfig;
|
|
54
|
-
declare let _state: AppState;
|
|
55
|
-
declare const onAdapterStateUpdate: (state: WalletAdapterState) => void;
|
|
56
|
-
declare const getWalletAdapterState: () => WalletAdapterState;
|
|
57
|
-
declare let _adapter: WalletAdapter;
|
|
58
|
-
declare let _txHistory: TxHistory;
|
|
59
|
-
declare const _eventListeners: EventListeners;
|
|
60
|
-
declare const _unbroadcastedEvents: UnbroadcastedEvents;
|
|
61
|
-
declare const updateState: (newState: Partial<AppState>) => void;
|
|
62
|
-
declare const updateTxHistory: (txStatus: TxStatus) => void;
|
|
63
|
-
declare const notifyAccountListeners: (accountId: string) => void;
|
|
64
|
-
declare const notifyTxListeners: (tx: TxStatus) => void;
|
|
65
|
-
declare const onAccount: (callback: (accountId: string) => void) => void;
|
|
66
|
-
declare const onTx: (callback: (tx: TxStatus) => void) => void;
|
|
67
|
-
declare const getConfig: () => NetworkConfig;
|
|
68
|
-
declare const getTxHistory: () => TxHistory;
|
|
69
|
-
declare const setConfig: (newConf: NetworkConfig) => void;
|
|
70
|
-
declare const resetTxHistory: () => void;
|
|
71
17
|
|
|
72
18
|
declare const MaxBlockDelayMs: number;
|
|
73
19
|
interface AccessKeyWithError {
|
|
74
|
-
|
|
75
|
-
|
|
20
|
+
result: {
|
|
21
|
+
nonce: number;
|
|
22
|
+
permission?: any;
|
|
23
|
+
error?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
interface WalletTxResult {
|
|
27
|
+
url?: string;
|
|
28
|
+
outcomes?: Array<{
|
|
29
|
+
transaction: {
|
|
30
|
+
hash: string;
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
rejected?: boolean;
|
|
76
34
|
error?: string;
|
|
77
35
|
}
|
|
78
36
|
interface BlockView {
|
|
37
|
+
result: {
|
|
38
|
+
header: {
|
|
39
|
+
hash: string;
|
|
40
|
+
timestamp_nanosec: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface LastKnownBlock {
|
|
79
45
|
header: {
|
|
80
|
-
|
|
46
|
+
hash: string;
|
|
81
47
|
timestamp_nanosec: string;
|
|
82
48
|
};
|
|
83
49
|
}
|
|
@@ -86,7 +52,7 @@ declare function withBlockId(params: Record<string, any>, blockId?: string): {
|
|
|
86
52
|
} | {
|
|
87
53
|
block_id: string;
|
|
88
54
|
};
|
|
89
|
-
declare function
|
|
55
|
+
declare function sendRpc(method: string, params: Record<string, any> | any[]): Promise<any>;
|
|
90
56
|
declare function afterTxSent(txId: string): void;
|
|
91
57
|
declare function sendTxToRpc(signedTxBase64: string, waitUntil: string | undefined, txId: string): Promise<any>;
|
|
92
58
|
interface AccessKeyView {
|
|
@@ -110,6 +76,17 @@ declare const accountId: () => string | null | undefined;
|
|
|
110
76
|
declare const publicKey: () => string | null | undefined;
|
|
111
77
|
declare const config: (newConfig?: Record<string, any>) => NetworkConfig;
|
|
112
78
|
declare const authStatus: () => string | Record<string, any>;
|
|
79
|
+
declare const getPublicKeyForContract: (opts?: any) => string | null | undefined;
|
|
80
|
+
declare const selected: () => {
|
|
81
|
+
network: string;
|
|
82
|
+
nodeUrl: string | undefined;
|
|
83
|
+
walletUrl: string | undefined;
|
|
84
|
+
helperUrl: string | undefined;
|
|
85
|
+
explorerUrl: string | undefined;
|
|
86
|
+
account: string | null | undefined;
|
|
87
|
+
contract: string | null | undefined;
|
|
88
|
+
publicKey: string | null | undefined;
|
|
89
|
+
};
|
|
113
90
|
declare const requestSignIn: ({ contractId }: {
|
|
114
91
|
contractId: string;
|
|
115
92
|
}) => Promise<void>;
|
|
@@ -177,6 +154,8 @@ declare const exp: {
|
|
|
177
154
|
};
|
|
178
155
|
};
|
|
179
156
|
declare const utils: {};
|
|
157
|
+
declare const state: {};
|
|
158
|
+
declare const event: any;
|
|
180
159
|
declare const actions: {
|
|
181
160
|
functionCall: ({ methodName, gas, deposit, args, argsBase64, }: {
|
|
182
161
|
methodName: string;
|
|
@@ -251,4 +230,4 @@ declare const actions: {
|
|
|
251
230
|
};
|
|
252
231
|
};
|
|
253
232
|
|
|
254
|
-
export { type AccessKeyView, type
|
|
233
|
+
export { type AccessKeyView, type AccessKeyWithError, type BlockView, type LastKnownBlock, MaxBlockDelayMs, type WalletTxResult, accountId, actions, afterTxSent, authStatus, config, event, exp, generateTxId, getPublicKeyForContract, localTxHistory, publicKey, queryAccessKey, queryAccount, queryBlock, queryTx, requestSignIn, selected, sendRpc, sendTx, sendTxToRpc, signOut, state, utils, view, withBlockId };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.
|
|
3
|
-
export * from "./state.js";
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - ESM (@fastnear/api version 0.8.0) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.8.0 */
|
|
4
3
|
export * from "./near.js";
|
|
5
4
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// See tsup.config.ts for additional banner/footer js\nexport * from \"./
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// See tsup.config.ts for additional banner/footer js\nexport * from \"./near.js\";\n"],"mappings":";;AACA,cAAc;","names":[]}
|