neo-n3-walletkit 0.1.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +353 -0
  3. package/dist/address.d.ts +5 -0
  4. package/dist/address.d.ts.map +1 -0
  5. package/dist/address.js +16 -0
  6. package/dist/address.js.map +1 -0
  7. package/dist/contract.d.ts +21 -0
  8. package/dist/contract.d.ts.map +1 -0
  9. package/dist/contract.js +62 -0
  10. package/dist/contract.js.map +1 -0
  11. package/dist/errors.d.ts +11 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +21 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/index.d.ts +13 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +8 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/neoline/adapter.d.ts +35 -0
  20. package/dist/neoline/adapter.d.ts.map +1 -0
  21. package/dist/neoline/adapter.js +289 -0
  22. package/dist/neoline/adapter.js.map +1 -0
  23. package/dist/neoline/index.d.ts +3 -0
  24. package/dist/neoline/index.d.ts.map +1 -0
  25. package/dist/neoline/index.js +2 -0
  26. package/dist/neoline/index.js.map +1 -0
  27. package/dist/neoline/types.d.ts +86 -0
  28. package/dist/neoline/types.d.ts.map +1 -0
  29. package/dist/neoline/types.js +2 -0
  30. package/dist/neoline/types.js.map +1 -0
  31. package/dist/onegate/adapter.d.ts +35 -0
  32. package/dist/onegate/adapter.d.ts.map +1 -0
  33. package/dist/onegate/adapter.js +351 -0
  34. package/dist/onegate/adapter.js.map +1 -0
  35. package/dist/onegate/index.d.ts +3 -0
  36. package/dist/onegate/index.d.ts.map +1 -0
  37. package/dist/onegate/index.js +2 -0
  38. package/dist/onegate/index.js.map +1 -0
  39. package/dist/onegate/types.d.ts +80 -0
  40. package/dist/onegate/types.d.ts.map +1 -0
  41. package/dist/onegate/types.js +2 -0
  42. package/dist/onegate/types.js.map +1 -0
  43. package/dist/types.d.ts +69 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +2 -0
  46. package/dist/types.js.map +1 -0
  47. package/dist/wallet-connect/adapter.d.ts +33 -0
  48. package/dist/wallet-connect/adapter.d.ts.map +1 -0
  49. package/dist/wallet-connect/adapter.js +198 -0
  50. package/dist/wallet-connect/adapter.js.map +1 -0
  51. package/dist/wallet-connect/index.d.ts +3 -0
  52. package/dist/wallet-connect/index.d.ts.map +1 -0
  53. package/dist/wallet-connect/index.js +2 -0
  54. package/dist/wallet-connect/index.js.map +1 -0
  55. package/dist/wallet-connect/types.d.ts +16 -0
  56. package/dist/wallet-connect/types.d.ts.map +1 -0
  57. package/dist/wallet-connect/types.js +2 -0
  58. package/dist/wallet-connect/types.js.map +1 -0
  59. package/dist/wallet-kit.d.ts +40 -0
  60. package/dist/wallet-kit.d.ts.map +1 -0
  61. package/dist/wallet-kit.js +137 -0
  62. package/dist/wallet-kit.js.map +1 -0
  63. package/package.json +75 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WalletKit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,353 @@
1
+ # Neo N3 WalletKit
2
+
3
+ A framework-independent TypeScript package for connecting frontend
4
+ applications to Neo N3 wallets and calling smart contracts.
5
+
6
+ Supported wallets:
7
+
8
+ - WalletConnect
9
+ - NeoLine
10
+ - OneGate
11
+
12
+ The same contract API works with every supported wallet.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install neo-n3-walletkit
18
+ ```
19
+
20
+ ## Choose A Wallet
21
+
22
+ | Wallet | Requirements | Initialize with |
23
+ | --- | --- | --- |
24
+ | WalletConnect | WalletConnect project ID and application metadata | `WalletKit.init()` |
25
+ | NeoLine | NeoLine N3 browser extension installed and unlocked | `WalletKit.initNeoLine()` |
26
+ | OneGate | Open the dApp inside a OneGate browser that supports NEP-21 | `WalletKit.initOneGate()` |
27
+
28
+ All wallets default to `neo3:testnet`. The network selected in the wallet must
29
+ match the network configured in WalletKit.
30
+
31
+ ## WalletConnect Setup
32
+
33
+ WalletConnect requires:
34
+
35
+ - A project ID from WalletConnect Cloud
36
+ - Application metadata
37
+ - A wallet that supports the requested Neo N3 methods
38
+
39
+ Create a shared wallet module:
40
+
41
+ ```ts
42
+ // wallet.ts
43
+ import { WalletKit } from "neo-n3-walletkit";
44
+
45
+ export const walletKit = await WalletKit.init({
46
+ projectId: "your-walletconnect-project-id",
47
+ relayUrl: "wss://relay.walletconnect.com",
48
+ metadata: {
49
+ name: "My Neo App",
50
+ description: "My Neo N3 application",
51
+ url: window.location.origin,
52
+ icons: ["/icon.png"]
53
+ },
54
+ network: "neo3:testnet"
55
+ });
56
+ ```
57
+
58
+ Connect the wallet:
59
+
60
+ ```ts
61
+ import { walletKit } from "./wallet";
62
+
63
+ await walletKit.connect();
64
+ ```
65
+
66
+ For a custom QR code or deep-link flow:
67
+
68
+ ```ts
69
+ const { uri, approval } = await walletKit.createConnection();
70
+
71
+ if (uri) {
72
+ showQrCode(uri);
73
+ }
74
+
75
+ await approval();
76
+ ```
77
+
78
+ ## NeoLine Setup
79
+
80
+ NeoLine requires:
81
+
82
+ - The NeoLine N3 browser extension
83
+ - The extension to be unlocked
84
+ - NeoLine to use the same network as WalletKit
85
+
86
+ Create a shared wallet module:
87
+
88
+ ```ts
89
+ // wallet.ts
90
+ import { WalletKit } from "neo-n3-walletkit";
91
+
92
+ export const walletKit = await WalletKit.initNeoLine({
93
+ network: "neo3:testnet"
94
+ });
95
+ ```
96
+
97
+ Connect the wallet:
98
+
99
+ ```ts
100
+ import { walletKit } from "./wallet";
101
+
102
+ await walletKit.connect();
103
+ ```
104
+
105
+ ## OneGate Setup
106
+
107
+ OneGate requires:
108
+
109
+ - The dApp to run inside a OneGate browser with NEP-21 support
110
+ - OneGate to use the same network as WalletKit
111
+
112
+ Create a shared wallet module:
113
+
114
+ ```ts
115
+ // wallet.ts
116
+ import { WalletKit } from "neo-n3-walletkit";
117
+
118
+ export const walletKit = await WalletKit.initOneGate({
119
+ network: "neo3:testnet"
120
+ });
121
+ ```
122
+
123
+ Connect the wallet:
124
+
125
+ ```ts
126
+ import { walletKit } from "./wallet";
127
+
128
+ await walletKit.connect();
129
+ ```
130
+
131
+ WalletKit discovers OneGate through the NEP-21 provider events.
132
+
133
+ ## Call A Smart Contract
134
+
135
+ After initializing and connecting any supported wallet, create a contract
136
+ helper:
137
+
138
+ ```ts
139
+ import { walletKit } from "./wallet";
140
+
141
+ const contract = walletKit.contract(
142
+ "0x010101c0775af568185025b0ce43cfaa9b990a2a"
143
+ );
144
+ ```
145
+
146
+ Call a read-only method:
147
+
148
+ ```ts
149
+ const result = await contract.testInvokeFirst<string>("getTry", [
150
+ { type: "String", value: "my-answer" }
151
+ ]);
152
+ ```
153
+
154
+ Call a method that creates a transaction:
155
+
156
+ ```ts
157
+ const account = walletKit.account;
158
+
159
+ if (!account) {
160
+ throw new Error("Connect a wallet first");
161
+ }
162
+
163
+ const txid = await contract.invoke("submitAnswer", [
164
+ { type: "Address", value: account.address },
165
+ { type: "String", value: "puzzle-1" },
166
+ { type: "String", value: "my-answer" }
167
+ ]);
168
+ ```
169
+
170
+ `invoke()` requests a signed transaction and returns its transaction ID.
171
+ `testInvoke()` and `testInvokeFirst()` do not persist blockchain changes.
172
+
173
+ WalletKit automatically adds the connected account as a `CalledByEntry` signer
174
+ unless the call provides its own signers.
175
+
176
+ ## Connection State
177
+
178
+ ```ts
179
+ console.log(walletKit.isConnected);
180
+ console.log(walletKit.account?.address);
181
+ console.log(walletKit.account?.scriptHash);
182
+
183
+ const unsubscribe = walletKit.onSessionChange(session => {
184
+ console.log("Wallet session changed", session);
185
+ });
186
+
187
+ await walletKit.disconnect();
188
+ unsubscribe();
189
+ ```
190
+
191
+ For NeoLine and OneGate, `disconnect()` clears WalletKit's local session.
192
+ Disconnect the dApp inside the wallet to fully revoke its connection.
193
+
194
+ ## Provider-Specific Methods
195
+
196
+ The active wallet adapter is available through `walletKit.wallet`.
197
+
198
+ ```ts
199
+ import { NeoLineAdapter } from "neo-n3-walletkit";
200
+
201
+ const neoLine = walletKit.wallet as NeoLineAdapter;
202
+ const balances = await neoLine.provider.getBalance({
203
+ address: walletKit.account!.address
204
+ });
205
+ ```
206
+
207
+ ```ts
208
+ import { OneGateAdapter } from "neo-n3-walletkit";
209
+
210
+ const oneGate = walletKit.wallet as OneGateAdapter;
211
+ const balance = await oneGate.provider.getBalance(
212
+ "0xd2a4cff31913016155e38e474a2c06d08be276cf",
213
+ `0x${walletKit.account!.scriptHash}`
214
+ );
215
+ ```
216
+
217
+ Provider-specific adapters and types can also be imported from
218
+ `neo-n3-walletkit/neoline`, `neo-n3-walletkit/onegate`, and
219
+ `neo-n3-walletkit/wallet-connect`.
220
+
221
+ ## Framework Usage
222
+
223
+ WalletKit has no Angular, React, Vue, Svelte, or RxJS dependency. Export one
224
+ initialized instance from `wallet.ts`, then import or wrap it using your
225
+ framework's normal state-management tools.
226
+
227
+ ## Current Limitations
228
+
229
+ - NeoLine and OneGate support WalletKit's `invokeFunction` and `testInvoke`
230
+ methods.
231
+ - OneGate does not currently support read-call signers or multi-call test
232
+ invocations.
233
+ - NeoLine does not currently support `abortOnFail` or multi-call test
234
+ invocations.
235
+ - NeoLine and OneGate do not support WalletKit network-fee overrides.
236
+
237
+ ## Run This Project
238
+
239
+ Install dependencies:
240
+
241
+ ```bash
242
+ npm install
243
+ ```
244
+
245
+ Run tests:
246
+
247
+ ```bash
248
+ npm test
249
+ ```
250
+
251
+ Check TypeScript:
252
+
253
+ ```bash
254
+ npm run typecheck
255
+ ```
256
+
257
+ Build the package:
258
+
259
+ ```bash
260
+ npm run build
261
+ ```
262
+
263
+ Run every check used before publishing:
264
+
265
+ ```bash
266
+ npm run prepublishOnly
267
+ ```
268
+
269
+ The compiled package is written to `dist`.
270
+
271
+ ## Publish To npm
272
+
273
+ Create an account at [npmjs.com](https://www.npmjs.com), then log in from the
274
+ terminal:
275
+
276
+ ```bash
277
+ npm login
278
+ npm whoami
279
+ ```
280
+
281
+ Before the first publish, confirm that the package name in `package.json` is
282
+ the name you want to own:
283
+
284
+ ```json
285
+ {
286
+ "name": "neo-n3-walletkit",
287
+ "version": "0.1.0"
288
+ }
289
+ ```
290
+
291
+ Run the checks and inspect the package contents:
292
+
293
+ ```bash
294
+ npm run prepublishOnly
295
+ npm pack --dry-run
296
+ ```
297
+
298
+ Publish the package publicly:
299
+
300
+ ```bash
301
+ npm publish --access public
302
+ ```
303
+
304
+ If npm returns `E403` and says two-factor authentication is required, publish
305
+ with a one-time password from your authenticator app:
306
+
307
+ ```bash
308
+ npm publish --access public --otp 123456
309
+ ```
310
+
311
+ Replace `123456` with the current code from your authenticator. If npm opens a
312
+ browser-based security-key flow, complete that prompt and run the publish
313
+ command again if needed.
314
+
315
+ For CI/CD, create a granular npm access token on npmjs.com with write access
316
+ and "Bypass two-factor authentication" enabled, then publish using that token
317
+ instead of an interactive login. Do not commit npm tokens to the repository.
318
+
319
+ Consumers can then install it:
320
+
321
+ ```bash
322
+ npm install neo-n3-walletkit
323
+ ```
324
+
325
+ For later releases, increase the version before publishing:
326
+
327
+ ```bash
328
+ npm version patch
329
+ npm publish --access public
330
+ ```
331
+
332
+ Use `npm version minor` for new backward-compatible features and
333
+ `npm version major` for breaking changes. npm does not allow publishing the
334
+ same package version more than once.
335
+
336
+ ## Project Structure
337
+
338
+ ```text
339
+ src/
340
+ neoline/ NeoLine adapter, types, and exports
341
+ onegate/ OneGate adapter, types, and exports
342
+ wallet-connect/ WalletConnect adapter, types, and exports
343
+ contract.ts Shared smart-contract helper
344
+ types.ts Shared provider-neutral types
345
+ wallet-kit.ts Main WalletKit API
346
+ ```
347
+
348
+ ## Security
349
+
350
+ - WalletKit never needs the user's private key.
351
+ - Validate contract hashes, arguments, networks, and transaction results.
352
+ - Use explicit signer scopes when `CalledByEntry` is not sufficient.
353
+ - Treat wallet and RPC responses as untrusted data.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Converts a validated Neo N3 Base58Check address to its script hash.
3
+ */
4
+ export declare function addressToScriptHash(address: string): string;
5
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAY3D"}
@@ -0,0 +1,16 @@
1
+ import { createBase58check } from "@scure/base";
2
+ import { sha256 } from "@noble/hashes/sha2.js";
3
+ const neoBase58Check = createBase58check(sha256);
4
+ const NEO_N3_ADDRESS_VERSION = 0x35;
5
+ /**
6
+ * Converts a validated Neo N3 Base58Check address to its script hash.
7
+ */
8
+ export function addressToScriptHash(address) {
9
+ const payload = neoBase58Check.decode(address);
10
+ if (payload.length !== 21 ||
11
+ payload[0] !== NEO_N3_ADDRESS_VERSION) {
12
+ throw new TypeError("Expected a valid Neo N3 address.");
13
+ }
14
+ return Array.from(payload.slice(1).reverse(), byte => byte.toString(16).padStart(2, "0")).join("");
15
+ }
16
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,MAAM,cAAc,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACjD,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/C,IACE,OAAO,CAAC,MAAM,KAAK,EAAE;QACrB,OAAO,CAAC,CAAC,CAAC,KAAK,sBAAsB,EACrC,CAAC;QACD,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,EAAE,CACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CACnC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACb,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ContractInvocationMulti, InvokeResult, RpcResponseStackItem, Signer } from "@cityofzion/neon-dappkit-types";
2
+ import type { ContractArgs, ContractCallOptions, ContractOptions } from "./types.js";
3
+ export interface ContractWallet {
4
+ connectedSigner(scopes?: string | number): Signer;
5
+ invokeFunction(params: ContractInvocationMulti, context?: string): Promise<string>;
6
+ testInvoke(params: ContractInvocationMulti, context?: string): Promise<InvokeResult>;
7
+ }
8
+ /**
9
+ * Reusable helper bound to one Neo N3 smart contract.
10
+ */
11
+ export declare class NeoContract {
12
+ private readonly wallet;
13
+ readonly scriptHash: string;
14
+ private readonly defaults;
15
+ constructor(wallet: ContractWallet, scriptHash: string, defaults?: ContractOptions);
16
+ invoke(operation: string, args?: ContractArgs, options?: ContractCallOptions): Promise<string>;
17
+ testInvoke(operation: string, args?: ContractArgs, options?: ContractCallOptions): Promise<InvokeResult>;
18
+ testInvokeFirst<T = unknown>(operation: string, args?: ContractArgs, options?: ContractCallOptions): Promise<T>;
19
+ }
20
+ export declare function stackItemValue<T = unknown>(stackItem: RpcResponseStackItem | undefined): T;
21
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACP,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAClD,cAAc,CAAC,MAAM,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnF,UAAU,CACR,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1B;AA+CD;;GAEG;AACH,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAFR,MAAM,EAAE,cAAc,EAC9B,UAAU,EAAE,MAAM,EACV,QAAQ,GAAE,eAAoB;IAGjD,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,YAAiB,EACvB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC;IAclB,UAAU,CACR,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,YAAiB,EACvB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,YAAY,CAAC;IAclB,eAAe,CAAC,CAAC,GAAG,OAAO,EAC/B,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,YAAiB,EACvB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,CAAC,CAAC;CAId;AAED,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EACxC,SAAS,EAAE,oBAAoB,GAAG,SAAS,GAC1C,CAAC,CAMH"}
@@ -0,0 +1,62 @@
1
+ function buildInvocation(scriptHash, operation, args, options, defaults, wallet) {
2
+ const includeConnectedSigner = options.includeConnectedSigner ??
3
+ defaults.includeConnectedSigner ??
4
+ (options.signers === undefined && defaults.signers === undefined);
5
+ const signers = options.signers ??
6
+ defaults.signers ??
7
+ (includeConnectedSigner ? [wallet.connectedSigner()] : []);
8
+ const invocation = {
9
+ scriptHash,
10
+ operation,
11
+ args: args,
12
+ ...(options.abortOnFail === undefined
13
+ ? {}
14
+ : { abortOnFail: options.abortOnFail })
15
+ };
16
+ return {
17
+ invocations: [invocation],
18
+ signers,
19
+ ...(options.extraSystemFee === undefined
20
+ ? {}
21
+ : { extraSystemFee: options.extraSystemFee }),
22
+ ...(options.systemFeeOverride === undefined
23
+ ? {}
24
+ : { systemFeeOverride: options.systemFeeOverride }),
25
+ ...(options.extraNetworkFee === undefined
26
+ ? {}
27
+ : { extraNetworkFee: options.extraNetworkFee }),
28
+ ...(options.networkFeeOverride === undefined
29
+ ? {}
30
+ : { networkFeeOverride: options.networkFeeOverride })
31
+ };
32
+ }
33
+ /**
34
+ * Reusable helper bound to one Neo N3 smart contract.
35
+ */
36
+ export class NeoContract {
37
+ wallet;
38
+ scriptHash;
39
+ defaults;
40
+ constructor(wallet, scriptHash, defaults = {}) {
41
+ this.wallet = wallet;
42
+ this.scriptHash = scriptHash;
43
+ this.defaults = defaults;
44
+ }
45
+ invoke(operation, args = [], options = {}) {
46
+ return this.wallet.invokeFunction(buildInvocation(this.scriptHash, operation, args, options, this.defaults, this.wallet), options.context);
47
+ }
48
+ testInvoke(operation, args = [], options = {}) {
49
+ return this.wallet.testInvoke(buildInvocation(this.scriptHash, operation, args, options, this.defaults, this.wallet), options.context);
50
+ }
51
+ async testInvokeFirst(operation, args = [], options = {}) {
52
+ const result = await this.testInvoke(operation, args, options);
53
+ return stackItemValue(result.stack[0]);
54
+ }
55
+ }
56
+ export function stackItemValue(stackItem) {
57
+ if (!stackItem || !("value" in stackItem)) {
58
+ throw new TypeError("Expected a value in the first Neo VM stack item.");
59
+ }
60
+ return stackItem.value;
61
+ }
62
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAuBA,SAAS,eAAe,CACtB,UAAkB,EAClB,SAAiB,EACjB,IAAkB,EAClB,OAA4B,EAC5B,QAAyB,EACzB,MAAsB;IAEtB,MAAM,sBAAsB,GAC1B,OAAO,CAAC,sBAAsB;QAC9B,QAAQ,CAAC,sBAAsB;QAC/B,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC;IAEpE,MAAM,OAAO,GACX,OAAO,CAAC,OAAO;QACf,QAAQ,CAAC,OAAO;QAChB,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE7D,MAAM,UAAU,GAAG;QACjB,UAAU;QACV,SAAS;QACT,IAAI,EAAE,IAAa;QACnB,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS;YACn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;IACJ,CAAC;IAED,UAAU,CACR,SAAiB,EACjB,OAAqB,EAAE,EACvB,UAA+B,EAAE;QAEjC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAC3B,eAAe,CACb,IAAI,CAAC,UAAU,EACf,SAAS,EACT,IAAI,EACJ,OAAO,EACP,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,CACZ,EACD,OAAO,CAAC,OAAO,CAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,SAAiB,EACjB,OAAqB,EAAE,EACvB,UAA+B,EAAE;QAEjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/D,OAAO,cAAc,CAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,MAAM,UAAU,cAAc,CAC5B,SAA2C;IAE3C,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,IAAI,SAAS,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,SAAS,CAAC,KAAU,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare class WalletKitError extends Error {
2
+ constructor(message: string, options?: ErrorOptions);
3
+ }
4
+ export declare class WalletNotConnectedError extends WalletKitError {
5
+ constructor();
6
+ }
7
+ export declare class WalletRequestError extends WalletKitError {
8
+ readonly payload: unknown;
9
+ constructor(message: string, payload: unknown);
10
+ }
11
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAED,qBAAa,uBAAwB,SAAQ,cAAc;;CAK1D;AAED,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;CAK9C"}
package/dist/errors.js ADDED
@@ -0,0 +1,21 @@
1
+ export class WalletKitError extends Error {
2
+ constructor(message, options) {
3
+ super(message, options);
4
+ this.name = "WalletKitError";
5
+ }
6
+ }
7
+ export class WalletNotConnectedError extends WalletKitError {
8
+ constructor() {
9
+ super("No Neo wallet is connected. Call connect() before this operation.");
10
+ this.name = "WalletNotConnectedError";
11
+ }
12
+ }
13
+ export class WalletRequestError extends WalletKitError {
14
+ payload;
15
+ constructor(message, payload) {
16
+ super(message);
17
+ this.name = "WalletRequestError";
18
+ this.payload = payload;
19
+ }
20
+ }
21
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,cAAc;IACzD;QACE,KAAK,CAAC,mEAAmE,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IAC3C,OAAO,CAAU;IAE1B,YAAY,OAAe,EAAE,OAAgB;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ export { addressToScriptHash } from "./address.js";
2
+ export { NeoContract, stackItemValue } from "./contract.js";
3
+ export { WalletKitError, WalletNotConnectedError, WalletRequestError } from "./errors.js";
4
+ export { NeoLineAdapter } from "./neoline/index.js";
5
+ export type { NeoLineAccount, NeoLineArg, NeoLineBalance, NeoLineInvocation, NeoLineInvokeParams, NeoLineInvokeReadParams, NeoLineInvokeResult, NeoLineN3Provider, NeoLineNetworks, NeoLineOptions, NeoLineReadResult, NeoLineSignerOptions, NeoLineWriteOptions } from "./neoline/index.js";
6
+ export { OneGateAdapter } from "./onegate/index.js";
7
+ export type { OneGateAccount, OneGateInvocation, OneGateInvocationResult, OneGateNetwork, OneGateOptions, OneGateProvider, OneGateSigner, OneGateTransactionOptions, OneGateWitnessScope } from "./onegate/index.js";
8
+ export { NeoWalletConnect } from "./wallet-connect/index.js";
9
+ export type { WalletConnectAdapter, WalletConnectOptions, WalletKitOptions, WalletMetadata } from "./wallet-connect/index.js";
10
+ export type { ConnectedAccount, ConnectionProposal, ContractArgs, ContractCallOptions, ContractMethod, ContractOptions, Method, NetworkType, SessionListener, WalletAdapter, WalletArg, WalletKitClientOptions, WalletProvider, WalletSession } from "./types.js";
11
+ export { WalletKit } from "./wallet-kit.js";
12
+ export type { Arg, ContractInvocation, ContractInvocationMulti, InvokeResult, RpcResponseStackItem, Signer } from "@cityofzion/neon-dappkit-types";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,WAAW,EACX,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACb,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACf,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,MAAM,EACN,WAAW,EACX,eAAe,EACf,aAAa,EACb,SAAS,EACT,sBAAsB,EACtB,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EACV,GAAG,EACH,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACP,MAAM,gCAAgC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { addressToScriptHash } from "./address.js";
2
+ export { NeoContract, stackItemValue } from "./contract.js";
3
+ export { WalletKitError, WalletNotConnectedError, WalletRequestError } from "./errors.js";
4
+ export { NeoLineAdapter } from "./neoline/index.js";
5
+ export { OneGateAdapter } from "./onegate/index.js";
6
+ export { NeoWalletConnect } from "./wallet-connect/index.js";
7
+ export { WalletKit } from "./wallet-kit.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,WAAW,EACX,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACf,MAAM,oBAAoB,CAAC;AAgB5B,OAAO,EACL,cAAc,EACf,MAAM,oBAAoB,CAAC;AAY5B,OAAO,EACL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAuBnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { ConnectionProposal, Method, NetworkType, SessionListener, WalletAdapter, WalletSession } from "../types.js";
2
+ import type { NeoLineN3Provider, NeoLineOptions } from "./types.js";
3
+ /**
4
+ * Adapter for the NeoLine N3 browser extension.
5
+ */
6
+ export declare class NeoLineAdapter implements WalletAdapter {
7
+ readonly provider: NeoLineN3Provider;
8
+ private currentSession;
9
+ private readonly listeners;
10
+ private eventsBound;
11
+ private lastMethods;
12
+ private constructor();
13
+ static init(options?: NeoLineOptions): Promise<NeoLineAdapter>;
14
+ static fromProvider(provider: NeoLineN3Provider): NeoLineAdapter;
15
+ get session(): WalletSession | null;
16
+ isConnected(): boolean;
17
+ getChainId(): NetworkType | null;
18
+ getAccountAddress(): string | null;
19
+ manageSession(network?: NetworkType, methods?: Method[]): Promise<WalletSession | null>;
20
+ connect(network: NetworkType, methods: Method[]): Promise<WalletSession>;
21
+ createConnection(network: NetworkType, methods: Method[]): Promise<ConnectionProposal>;
22
+ disconnect(): Promise<void>;
23
+ onSessionChange(listener: SessionListener): () => void;
24
+ request<T>(method: Method, params: unknown, _context?: string): Promise<T>;
25
+ private invoke;
26
+ private testInvoke;
27
+ private assertSupportedMethods;
28
+ private readNetwork;
29
+ private bindEvents;
30
+ private bindEvent;
31
+ private refreshFromEvent;
32
+ private setConnectedSession;
33
+ private setSession;
34
+ }
35
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