@fastnear/api 0.6.2 → 0.7.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 +5 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +132 -26
- package/dist/cjs/near.cjs +504 -0
- package/dist/cjs/near.cjs.map +1 -0
- package/dist/cjs/state.cjs +213 -0
- package/dist/cjs/state.cjs.map +1 -0
- package/dist/esm/index.d.ts +132 -26
- package/dist/esm/index.js +3 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/near.js +477 -0
- package/dist/esm/near.js.map +1 -0
- package/dist/esm/state.js +174 -0
- package/dist/esm/state.js.map +1 -0
- package/dist/umd/browser.global.js +584 -528
- package/dist/umd/browser.global.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.6.
|
|
2
|
-
/* https://www.npmjs.com/package/@fastnear/api/v/0.6.
|
|
1
|
+
/* ⋈ 🏃🏻💨 FastNEAR API - CJS (@fastnear/api version 0.6.3) */
|
|
2
|
+
/* https://www.npmjs.com/package/@fastnear/api/v/0.6.3 */
|
|
3
|
+
"use strict";
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -16,13 +17,11 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
16
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
17
18
|
var src_exports = {};
|
|
18
19
|
module.exports = __toCommonJS(src_exports);
|
|
19
|
-
|
|
20
|
+
__reExport(src_exports, require("./state.js"), module.exports);
|
|
20
21
|
__reExport(src_exports, require("./near.js"), module.exports);
|
|
21
|
-
if (typeof window !== "undefined") {
|
|
22
|
-
window.$$ = import_utils.convertUnit;
|
|
23
|
-
}
|
|
24
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
23
|
0 && (module.exports = {
|
|
24
|
+
...require("./state.js"),
|
|
26
25
|
...require("./near.js")
|
|
27
26
|
});
|
|
28
27
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// See tsup.config.ts for additional banner/footer js\nexport * from \"./state.js\"\nexport * from \"./near.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AACA,wBAAc,uBADd;AAEA,wBAAc,sBAFd;","names":[]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { WalletAdapter } from '@fastnear/wallet-adapter';
|
|
2
|
+
import * as borsh from 'borsh';
|
|
3
3
|
|
|
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
|
+
};
|
|
4
16
|
interface NetworkConfig {
|
|
5
17
|
networkId: string;
|
|
6
18
|
nodeUrl?: string;
|
|
@@ -9,14 +21,66 @@ interface NetworkConfig {
|
|
|
9
21
|
explorerUrl?: string;
|
|
10
22
|
[key: string]: any;
|
|
11
23
|
}
|
|
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
|
+
}
|
|
12
32
|
interface TxStatus {
|
|
13
33
|
txId: string;
|
|
14
34
|
updateTimestamp?: number;
|
|
15
35
|
[key: string]: any;
|
|
16
36
|
}
|
|
17
37
|
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;
|
|
18
71
|
|
|
19
72
|
declare const MaxBlockDelayMs: number;
|
|
73
|
+
interface AccessKeyWithError {
|
|
74
|
+
nonce: number;
|
|
75
|
+
permission?: any;
|
|
76
|
+
error?: string;
|
|
77
|
+
}
|
|
78
|
+
interface BlockView {
|
|
79
|
+
header: {
|
|
80
|
+
prev_hash: string;
|
|
81
|
+
timestamp_nanosec: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
20
84
|
declare function withBlockId(params: Record<string, any>, blockId?: string): {
|
|
21
85
|
finality: string;
|
|
22
86
|
} | {
|
|
@@ -24,15 +88,31 @@ declare function withBlockId(params: Record<string, any>, blockId?: string): {
|
|
|
24
88
|
};
|
|
25
89
|
declare function queryRpc(method: string, params: Record<string, any> | any[]): Promise<any>;
|
|
26
90
|
declare function afterTxSent(txId: string): void;
|
|
27
|
-
declare function sendTxToRpc(signedTxBase64: string, waitUntil: string | undefined, txId: string):
|
|
91
|
+
declare function sendTxToRpc(signedTxBase64: string, waitUntil: string | undefined, txId: string): Promise<any>;
|
|
28
92
|
interface AccessKeyView {
|
|
29
93
|
nonce: number;
|
|
30
94
|
permission: any;
|
|
31
95
|
}
|
|
32
|
-
|
|
33
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Generates a mock transaction ID.
|
|
98
|
+
*
|
|
99
|
+
* This function creates a pseudo-unique transaction ID for testing or
|
|
100
|
+
* non-production use. It combines the current timestamp with a
|
|
101
|
+
* random component for uniqueness.
|
|
102
|
+
*
|
|
103
|
+
* **Note:** This is not cryptographically secure and should not be used
|
|
104
|
+
* for actual transaction processing.
|
|
105
|
+
*
|
|
106
|
+
* @returns {string} A mock transaction ID in the format `tx-{timestamp}-{random}`
|
|
107
|
+
*/
|
|
108
|
+
declare function generateTxId(): string;
|
|
109
|
+
declare const accountId: () => string | null | undefined;
|
|
110
|
+
declare const publicKey: () => string | null | undefined;
|
|
34
111
|
declare const config: (newConfig?: Record<string, any>) => NetworkConfig;
|
|
35
112
|
declare const authStatus: () => string | Record<string, any>;
|
|
113
|
+
declare const requestSignIn: ({ contractId }: {
|
|
114
|
+
contractId: string;
|
|
115
|
+
}) => Promise<void>;
|
|
36
116
|
declare const view: ({ contractId, methodName, args, argsBase64, blockId, }: {
|
|
37
117
|
contractId: string;
|
|
38
118
|
methodName: string;
|
|
@@ -40,32 +120,63 @@ declare const view: ({ contractId, methodName, args, argsBase64, blockId, }: {
|
|
|
40
120
|
argsBase64?: string;
|
|
41
121
|
blockId?: string;
|
|
42
122
|
}) => Promise<any>;
|
|
43
|
-
declare const
|
|
123
|
+
declare const queryAccount: ({ accountId, blockId, }: {
|
|
44
124
|
accountId: string;
|
|
45
125
|
blockId?: string;
|
|
46
126
|
}) => Promise<any>;
|
|
47
|
-
declare const
|
|
127
|
+
declare const queryBlock: ({ blockId }: {
|
|
48
128
|
blockId?: string;
|
|
49
|
-
}) => Promise<
|
|
50
|
-
declare const
|
|
129
|
+
}) => Promise<BlockView>;
|
|
130
|
+
declare const queryAccessKey: ({ accountId, publicKey, blockId, }: {
|
|
51
131
|
accountId: string;
|
|
52
132
|
publicKey: string;
|
|
53
133
|
blockId?: string;
|
|
54
|
-
}) => Promise<
|
|
55
|
-
declare const
|
|
134
|
+
}) => Promise<AccessKeyWithError>;
|
|
135
|
+
declare const queryTx: ({ txHash, accountId }: {
|
|
56
136
|
txHash: string;
|
|
57
137
|
accountId: string;
|
|
58
138
|
}) => Promise<any>;
|
|
59
139
|
declare const localTxHistory: () => TxHistory;
|
|
140
|
+
declare const signOut: () => void;
|
|
60
141
|
declare const sendTx: ({ receiverId, actions, waitUntil, }: {
|
|
61
142
|
receiverId: string;
|
|
62
143
|
actions: any[];
|
|
63
144
|
waitUntil?: string;
|
|
64
|
-
}) => Promise<
|
|
65
|
-
declare const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
145
|
+
}) => Promise<any>;
|
|
146
|
+
declare const exp: {
|
|
147
|
+
utils: {};
|
|
148
|
+
borsh: {
|
|
149
|
+
serialize: typeof borsh.serialize;
|
|
150
|
+
deserialize: typeof borsh.deserialize;
|
|
151
|
+
};
|
|
152
|
+
borshSchema: {
|
|
153
|
+
Ed25519Signature: borsh.Schema;
|
|
154
|
+
Secp256k1Signature: borsh.Schema;
|
|
155
|
+
Signature: borsh.Schema;
|
|
156
|
+
Ed25519Data: borsh.Schema;
|
|
157
|
+
Secp256k1Data: borsh.Schema;
|
|
158
|
+
PublicKey: borsh.Schema;
|
|
159
|
+
FunctionCallPermission: borsh.Schema;
|
|
160
|
+
FullAccessPermission: borsh.Schema;
|
|
161
|
+
AccessKeyPermission: borsh.Schema;
|
|
162
|
+
AccessKey: borsh.Schema;
|
|
163
|
+
CreateAccount: borsh.Schema;
|
|
164
|
+
DeployContract: borsh.Schema;
|
|
165
|
+
FunctionCall: borsh.Schema;
|
|
166
|
+
Transfer: borsh.Schema;
|
|
167
|
+
Stake: borsh.Schema;
|
|
168
|
+
AddKey: borsh.Schema;
|
|
169
|
+
DeleteKey: borsh.Schema;
|
|
170
|
+
DeleteAccount: borsh.Schema;
|
|
171
|
+
ClassicAction: borsh.Schema;
|
|
172
|
+
DelegateAction: borsh.Schema;
|
|
173
|
+
SignedDelegate: borsh.Schema;
|
|
174
|
+
Action: borsh.Schema;
|
|
175
|
+
Transaction: borsh.Schema;
|
|
176
|
+
SignedTransaction: borsh.Schema;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
declare const utils: {};
|
|
69
180
|
declare const actions: {
|
|
70
181
|
functionCall: ({ methodName, gas, deposit, args, argsBase64, }: {
|
|
71
182
|
methodName: string;
|
|
@@ -76,10 +187,10 @@ declare const actions: {
|
|
|
76
187
|
}) => {
|
|
77
188
|
type: string;
|
|
78
189
|
methodName: string;
|
|
79
|
-
args: Record<string, any
|
|
80
|
-
argsBase64: string;
|
|
81
|
-
gas: string;
|
|
82
|
-
deposit: string;
|
|
190
|
+
args: Record<string, any> | undefined;
|
|
191
|
+
argsBase64: string | undefined;
|
|
192
|
+
gas: string | undefined;
|
|
193
|
+
deposit: string | undefined;
|
|
83
194
|
};
|
|
84
195
|
transfer: (yoctoAmount: string) => {
|
|
85
196
|
type: string;
|
|
@@ -139,10 +250,5 @@ declare const actions: {
|
|
|
139
250
|
codeBase64: string;
|
|
140
251
|
};
|
|
141
252
|
};
|
|
142
|
-
declare const reExports: {
|
|
143
|
-
utils: typeof reExportUtils;
|
|
144
|
-
borshSchema: typeof reExportBorshSchema;
|
|
145
|
-
};
|
|
146
|
-
declare const utils: typeof reExportUtils;
|
|
147
253
|
|
|
148
|
-
export { type AccessKeyView, MaxBlockDelayMs,
|
|
254
|
+
export { type AccessKeyView, type AppState, DEFAULT_NETWORK_ID, type EventListeners, MaxBlockDelayMs, NETWORKS, type NetworkConfig, type TxHistory, type TxStatus, type UnbroadcastedEvents, WIDGET_URL, type WalletAdapterState, _adapter, _config, _eventListeners, _state, _txHistory, _unbroadcastedEvents, accountId, actions, afterTxSent, authStatus, config, exp, generateTxId, getConfig, getTxHistory, getWalletAdapterState, localTxHistory, notifyAccountListeners, notifyTxListeners, onAccount, onAdapterStateUpdate, onTx, publicKey, queryAccessKey, queryAccount, queryBlock, queryRpc, queryTx, requestSignIn, resetTxHistory, sendTx, sendTxToRpc, setConfig, signOut, updateState, updateTxHistory, utils, view, withBlockId };
|