near-kit 0.0.0 → 0.2.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 (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +473 -2
  3. package/dist/contracts/contract.d.ts +63 -0
  4. package/dist/contracts/contract.d.ts.map +1 -0
  5. package/dist/contracts/contract.js +42 -0
  6. package/dist/contracts/contract.js.map +1 -0
  7. package/dist/contracts/index.d.ts +5 -0
  8. package/dist/contracts/index.d.ts.map +1 -0
  9. package/dist/contracts/index.js +5 -0
  10. package/dist/contracts/index.js.map +1 -0
  11. package/dist/core/actions.d.ts +193 -0
  12. package/dist/core/actions.d.ts.map +1 -0
  13. package/dist/core/actions.js +195 -0
  14. package/dist/core/actions.js.map +1 -0
  15. package/dist/core/config-schemas.d.ts +179 -0
  16. package/dist/core/config-schemas.d.ts.map +1 -0
  17. package/dist/core/config-schemas.js +169 -0
  18. package/dist/core/config-schemas.js.map +1 -0
  19. package/dist/core/constants.d.ts +43 -0
  20. package/dist/core/constants.d.ts.map +1 -0
  21. package/dist/core/constants.js +49 -0
  22. package/dist/core/constants.js.map +1 -0
  23. package/dist/core/near.d.ts +301 -0
  24. package/dist/core/near.d.ts.map +1 -0
  25. package/dist/core/near.js +504 -0
  26. package/dist/core/near.js.map +1 -0
  27. package/dist/core/nonce-manager.d.ts +39 -0
  28. package/dist/core/nonce-manager.d.ts.map +1 -0
  29. package/dist/core/nonce-manager.js +73 -0
  30. package/dist/core/nonce-manager.js.map +1 -0
  31. package/dist/core/rpc/rpc-error-handler.d.ts +60 -0
  32. package/dist/core/rpc/rpc-error-handler.d.ts.map +1 -0
  33. package/dist/core/rpc/rpc-error-handler.js +324 -0
  34. package/dist/core/rpc/rpc-error-handler.js.map +1 -0
  35. package/dist/core/rpc/rpc-schemas.d.ts +1812 -0
  36. package/dist/core/rpc/rpc-schemas.d.ts.map +1 -0
  37. package/dist/core/rpc/rpc-schemas.js +424 -0
  38. package/dist/core/rpc/rpc-schemas.js.map +1 -0
  39. package/dist/core/rpc/rpc.d.ts +117 -0
  40. package/dist/core/rpc/rpc.d.ts.map +1 -0
  41. package/dist/core/rpc/rpc.js +325 -0
  42. package/dist/core/rpc/rpc.js.map +1 -0
  43. package/dist/core/schema.d.ts +1188 -0
  44. package/dist/core/schema.d.ts.map +1 -0
  45. package/dist/core/schema.js +396 -0
  46. package/dist/core/schema.js.map +1 -0
  47. package/dist/core/transaction.d.ts +390 -0
  48. package/dist/core/transaction.d.ts.map +1 -0
  49. package/dist/core/transaction.js +653 -0
  50. package/dist/core/transaction.js.map +1 -0
  51. package/dist/core/types.d.ts +271 -0
  52. package/dist/core/types.d.ts.map +1 -0
  53. package/dist/core/types.js +9 -0
  54. package/dist/core/types.js.map +1 -0
  55. package/dist/errors/index.d.ts +226 -0
  56. package/dist/errors/index.d.ts.map +1 -0
  57. package/dist/errors/index.js +366 -0
  58. package/dist/errors/index.js.map +1 -0
  59. package/dist/index.d.ts +16 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +23 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/keys/credential-schemas.d.ts +98 -0
  64. package/dist/keys/credential-schemas.d.ts.map +1 -0
  65. package/dist/keys/credential-schemas.js +128 -0
  66. package/dist/keys/credential-schemas.js.map +1 -0
  67. package/dist/keys/file-keystore.d.ts +130 -0
  68. package/dist/keys/file-keystore.d.ts.map +1 -0
  69. package/dist/keys/file-keystore.js +266 -0
  70. package/dist/keys/file-keystore.js.map +1 -0
  71. package/dist/keys/in-memory-keystore.d.ts +71 -0
  72. package/dist/keys/in-memory-keystore.d.ts.map +1 -0
  73. package/dist/keys/in-memory-keystore.js +85 -0
  74. package/dist/keys/in-memory-keystore.js.map +1 -0
  75. package/dist/keys/index.d.ts +14 -0
  76. package/dist/keys/index.d.ts.map +1 -0
  77. package/dist/keys/index.js +20 -0
  78. package/dist/keys/index.js.map +1 -0
  79. package/dist/keys/native-keystore.d.ts +111 -0
  80. package/dist/keys/native-keystore.d.ts.map +1 -0
  81. package/dist/keys/native-keystore.js +167 -0
  82. package/dist/keys/native-keystore.js.map +1 -0
  83. package/dist/keys/rotating-keystore.d.ts +207 -0
  84. package/dist/keys/rotating-keystore.d.ts.map +1 -0
  85. package/dist/keys/rotating-keystore.js +240 -0
  86. package/dist/keys/rotating-keystore.js.map +1 -0
  87. package/dist/sandbox/index.d.ts +6 -0
  88. package/dist/sandbox/index.d.ts.map +1 -0
  89. package/dist/sandbox/index.js +5 -0
  90. package/dist/sandbox/index.js.map +1 -0
  91. package/dist/sandbox/sandbox.d.ts +55 -0
  92. package/dist/sandbox/sandbox.d.ts.map +1 -0
  93. package/dist/sandbox/sandbox.js +341 -0
  94. package/dist/sandbox/sandbox.js.map +1 -0
  95. package/dist/utils/amount.d.ts +76 -0
  96. package/dist/utils/amount.d.ts.map +1 -0
  97. package/dist/utils/amount.js +137 -0
  98. package/dist/utils/amount.js.map +1 -0
  99. package/dist/utils/gas.d.ts +69 -0
  100. package/dist/utils/gas.d.ts.map +1 -0
  101. package/dist/utils/gas.js +92 -0
  102. package/dist/utils/gas.js.map +1 -0
  103. package/dist/utils/index.d.ts +14 -0
  104. package/dist/utils/index.d.ts.map +1 -0
  105. package/dist/utils/index.js +14 -0
  106. package/dist/utils/index.js.map +1 -0
  107. package/dist/utils/key.d.ts +117 -0
  108. package/dist/utils/key.d.ts.map +1 -0
  109. package/dist/utils/key.js +270 -0
  110. package/dist/utils/key.js.map +1 -0
  111. package/dist/utils/nep413.d.ts +97 -0
  112. package/dist/utils/nep413.d.ts.map +1 -0
  113. package/dist/utils/nep413.js +154 -0
  114. package/dist/utils/nep413.js.map +1 -0
  115. package/dist/utils/validation.d.ts +114 -0
  116. package/dist/utils/validation.d.ts.map +1 -0
  117. package/dist/utils/validation.js +150 -0
  118. package/dist/utils/validation.js.map +1 -0
  119. package/dist/wallets/adapters.d.ts +119 -0
  120. package/dist/wallets/adapters.d.ts.map +1 -0
  121. package/dist/wallets/adapters.js +267 -0
  122. package/dist/wallets/adapters.js.map +1 -0
  123. package/dist/wallets/index.d.ts +11 -0
  124. package/dist/wallets/index.d.ts.map +1 -0
  125. package/dist/wallets/index.js +2 -0
  126. package/dist/wallets/index.js.map +1 -0
  127. package/dist/wallets/types.d.ts +99 -0
  128. package/dist/wallets/types.d.ts.map +1 -0
  129. package/dist/wallets/types.js +10 -0
  130. package/dist/wallets/types.js.map +1 -0
  131. package/package.json +78 -7
  132. package/index.js +0 -1
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Zod validation schemas and helpers for NEAR types.
3
+ *
4
+ * @remarks
5
+ * These schemas power runtime validation for account IDs, public/private keys,
6
+ * amounts, and gas while keeping the developer-facing API ergonomic via
7
+ * helpers like {@link validateAccountId} and {@link normalizeAmount}.
8
+ */
9
+ import { z } from "zod";
10
+ import { ACCOUNT_ID_REGEX, ED25519_KEY_PREFIX, MAX_ACCOUNT_ID_LENGTH, MIN_ACCOUNT_ID_LENGTH, SECP256K1_KEY_PREFIX, } from "../core/constants.js";
11
+ import { parseAmount } from "./amount.js";
12
+ import { parseGas } from "./gas.js";
13
+ // ==================== Base58 Validation ====================
14
+ /**
15
+ * Check if a string is valid base58 encoding.
16
+ * @internal
17
+ */
18
+ function isValidBase58(str) {
19
+ const base58Regex = /^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;
20
+ return base58Regex.test(str);
21
+ }
22
+ // ==================== Account ID Schema ====================
23
+ /**
24
+ * Schema for validating NEAR account IDs.
25
+ *
26
+ * Rules:
27
+ * - Length: 2-64 characters
28
+ * - Characters: lowercase alphanumeric, hyphens, underscores, and dots
29
+ * - Pattern: subdomain-like structure (e.g., alice.near, contract.mainnet)
30
+ */
31
+ export const AccountIdSchema = z
32
+ .string()
33
+ .min(MIN_ACCOUNT_ID_LENGTH, `Account ID must be at least ${MIN_ACCOUNT_ID_LENGTH} characters`)
34
+ .max(MAX_ACCOUNT_ID_LENGTH, `Account ID must be at most ${MAX_ACCOUNT_ID_LENGTH} characters`)
35
+ .regex(ACCOUNT_ID_REGEX, "Account ID must contain only lowercase alphanumeric characters, hyphens, underscores, and dots");
36
+ // ==================== Public Key Schema ====================
37
+ /**
38
+ * Schema for validating NEAR public keys.
39
+ *
40
+ * Supports:
41
+ * - Ed25519: "ed25519:..." (base58 encoded)
42
+ * - Secp256k1: "secp256k1:..." (base58 encoded)
43
+ */
44
+ export const PublicKeySchema = z
45
+ .string()
46
+ .refine((key) => key.startsWith(ED25519_KEY_PREFIX) ||
47
+ key.startsWith(SECP256K1_KEY_PREFIX), "Public key must start with 'ed25519:' or 'secp256k1:'")
48
+ .refine((key) => {
49
+ const keyData = key.startsWith(ED25519_KEY_PREFIX)
50
+ ? key.slice(ED25519_KEY_PREFIX.length)
51
+ : key.slice(SECP256K1_KEY_PREFIX.length);
52
+ return isValidBase58(keyData);
53
+ }, "Public key must be valid base58 encoding");
54
+ /**
55
+ * Schema for validating NEAR private keys.
56
+ *
57
+ * Supports:
58
+ * - Ed25519: "ed25519:..." (base58 encoded, 64 bytes)
59
+ * - Secp256k1: "secp256k1:..." (base58 encoded, 96 bytes)
60
+ */
61
+ export const PrivateKeySchema = z
62
+ .string()
63
+ .refine((key) => key.startsWith(ED25519_KEY_PREFIX) ||
64
+ key.startsWith(SECP256K1_KEY_PREFIX), "Private key must start with 'ed25519:' or 'secp256k1:'")
65
+ .refine((key) => {
66
+ const keyData = key.startsWith(ED25519_KEY_PREFIX)
67
+ ? key.slice(ED25519_KEY_PREFIX.length)
68
+ : key.slice(SECP256K1_KEY_PREFIX.length);
69
+ return keyData.length > 0 && isValidBase58(keyData);
70
+ }, "Private key must be valid base58 encoding");
71
+ // ==================== Amount Schema ====================
72
+ /**
73
+ * Schema for NEAR amounts with explicit units.
74
+ *
75
+ * Accepts:
76
+ * - String with unit: "10 NEAR", "1000000 yocto"
77
+ * - Created via Amount.NEAR(10) or Amount.yocto(1000000n)
78
+ * - Raw bigint: 1000000n (treated as yoctoNEAR)
79
+ *
80
+ * Rejects bare numbers to prevent unit confusion.
81
+ * Normalizes to yoctoNEAR string.
82
+ */
83
+ export const AmountSchema = z
84
+ .union([z.string(), z.bigint()])
85
+ .transform((amount) => {
86
+ return parseAmount(amount);
87
+ });
88
+ // ==================== Gas Schema ====================
89
+ /**
90
+ * Schema for gas amounts.
91
+ *
92
+ * Accepts:
93
+ * - String with unit: "30 Tgas", Gas.Tgas(30)
94
+ * - Raw gas number strings for advanced use
95
+ *
96
+ * Normalizes to raw gas string.
97
+ */
98
+ export const GasSchema = z.string().transform((gas) => {
99
+ return parseGas(gas);
100
+ });
101
+ // ==================== Helper Functions ====================
102
+ /**
103
+ * Validate account ID (throws on invalid).
104
+ */
105
+ export function validateAccountId(accountId) {
106
+ return AccountIdSchema.parse(accountId);
107
+ }
108
+ /**
109
+ * Check if account ID is valid (boolean).
110
+ */
111
+ export function isValidAccountId(accountId) {
112
+ return AccountIdSchema.safeParse(accountId).success;
113
+ }
114
+ /**
115
+ * Validate public key (throws on invalid).
116
+ */
117
+ export function validatePublicKey(key) {
118
+ return PublicKeySchema.parse(key);
119
+ }
120
+ /**
121
+ * Check if public key is valid (boolean).
122
+ */
123
+ export function isValidPublicKey(key) {
124
+ return PublicKeySchema.safeParse(key).success;
125
+ }
126
+ /**
127
+ * Validate private key (throws on invalid).
128
+ */
129
+ export function validatePrivateKey(key) {
130
+ return PrivateKeySchema.parse(key);
131
+ }
132
+ /**
133
+ * Check if private key is valid (boolean).
134
+ */
135
+ export function isPrivateKey(key) {
136
+ return PrivateKeySchema.safeParse(key).success;
137
+ }
138
+ /**
139
+ * Normalize amount to yoctoNEAR string.
140
+ */
141
+ export function normalizeAmount(amount) {
142
+ return AmountSchema.parse(amount);
143
+ }
144
+ /**
145
+ * Normalize gas to gas string.
146
+ */
147
+ export function normalizeGas(gas) {
148
+ return GasSchema.parse(gas);
149
+ }
150
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+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AAU,iBAAiB,CAAC,SAAiB;IACjD,OAAO,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,eAAe,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAA;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,OAAO,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,OAAO,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,CAAA;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,OAAO,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,CAAA;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAQ;IACnC,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAC7B,CAAC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Wallet adapters for NEAR wallet integrations.
3
+ *
4
+ * Provides adapter functions to integrate with popular NEAR wallets:
5
+ * - `@near-wallet-selector/core`
6
+ * - `@hot-labs/near-connect`
7
+ *
8
+ * These adapters use duck typing / structural compatibility to work with
9
+ * wallet interfaces. While the actual wallet packages use `@near-js` types
10
+ * (which are classes), our types (plain objects) are structurally compatible
11
+ * and work correctly at runtime. See `tests/wallets/type-compatibility.test.ts`
12
+ * for verification.
13
+ */
14
+ import type { WalletConnection } from "../core/types.js";
15
+ import type { HotConnectConnector } from "./types.js";
16
+ type WalletSelectorWallet = {
17
+ getAccounts(): Promise<Array<{
18
+ accountId: string;
19
+ publicKey?: string;
20
+ }>>;
21
+ signAndSendTransaction(params: {
22
+ signerId?: string;
23
+ receiverId?: string;
24
+ actions: unknown[];
25
+ }): Promise<unknown>;
26
+ signMessage?(params: {
27
+ message: string;
28
+ recipient: string;
29
+ nonce: Buffer;
30
+ callbackUrl?: string;
31
+ state?: string;
32
+ }): Promise<unknown>;
33
+ };
34
+ /**
35
+ * Adapter for @near-wallet-selector/core
36
+ *
37
+ * Converts a wallet-selector Wallet instance to the WalletConnection interface.
38
+ *
39
+ * @param wallet - Wallet instance from wallet-selector
40
+ * @returns WalletConnection interface compatible with near-ts
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * import { Near } from 'near-ts'
45
+ * import { setupWalletSelector } from '@near-wallet-selector/core'
46
+ * import { fromWalletSelector } from 'near-ts/wallets'
47
+ *
48
+ * const selector = await setupWalletSelector({
49
+ * network: 'mainnet',
50
+ * modules: [...]
51
+ * })
52
+ * const wallet = await selector.wallet()
53
+ *
54
+ * const near = new Near({
55
+ * network: 'mainnet',
56
+ * wallet: fromWalletSelector(wallet)
57
+ * })
58
+ * ```
59
+ */
60
+ export declare function fromWalletSelector(wallet: WalletSelectorWallet): WalletConnection;
61
+ /**
62
+ * Adapter for @hot-labs/near-connect (HOT Connect)
63
+ *
64
+ * Converts a HOT Connect NearConnector instance to the WalletConnection interface.
65
+ *
66
+ * @param connector - NearConnector instance from HOT Connect
67
+ * @returns WalletConnection interface compatible with near-ts
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * import { Near } from 'near-ts'
72
+ * import { NearConnector } from '@hot-labs/near-connect'
73
+ * import { fromHotConnect } from 'near-ts/wallets'
74
+ *
75
+ * const connector = new NearConnector({ network: 'mainnet' })
76
+ *
77
+ * // Wait for user to connect their wallet
78
+ * connector.on('wallet:signIn', async () => {
79
+ * const near = new Near({
80
+ * network: 'mainnet',
81
+ * wallet: fromHotConnect(connector)
82
+ * })
83
+ *
84
+ * // Use near-ts with the connected wallet
85
+ * await near.call('contract.near', 'method', { arg: 'value' })
86
+ * })
87
+ * ```
88
+ */
89
+ /**
90
+ * Adapter for @hot-labs/near-connect (HOT Connect)
91
+ *
92
+ * Converts a HOT Connect NearConnector instance to the WalletConnection interface.
93
+ *
94
+ * @param connector - NearConnector instance from HOT Connect
95
+ * @returns WalletConnection interface compatible with near-kit
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * import { Near } from 'near-kit'
100
+ * import { NearConnector } from '@hot-labs/near-connect'
101
+ * import { fromHotConnect } from 'near-kit/wallets'
102
+ *
103
+ * const connector = new NearConnector({ network: 'mainnet' })
104
+ *
105
+ * // Wait for user to connect their wallet
106
+ * connector.on('wallet:signIn', async () => {
107
+ * const near = new Near({
108
+ * network: 'mainnet',
109
+ * wallet: fromHotConnect(connector)
110
+ * })
111
+ *
112
+ * // Use near-kit with the connected wallet
113
+ * await near.call('contract.near', 'method', { arg: 'value' })
114
+ * })
115
+ * ```
116
+ */
117
+ export declare function fromHotConnect(connector: HotConnectConnector): WalletConnection;
118
+ export {};
119
+ //# sourceMappingURL=adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../src/wallets/adapters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAIV,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAQnB,KAAK,oBAAoB,GAAG;IAC1B,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAA;IACxE,sBAAsB,CAAC,MAAM,EAAE;QAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,OAAO,EAAE,OAAO,EAAE,CAAA;KACnB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACpB,WAAW,CAAC,CAAC,MAAM,EAAE;QACnB,OAAO,EAAE,MAAM,CAAA;QACf,SAAS,EAAE,MAAM,CAAA;QACjB,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,oBAAoB,GAC3B,gBAAgB,CA8ClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,mBAAmB,GAC7B,gBAAgB,CAqKlB"}
@@ -0,0 +1,267 @@
1
+ /**
2
+ * Wallet adapters for NEAR wallet integrations.
3
+ *
4
+ * Provides adapter functions to integrate with popular NEAR wallets:
5
+ * - `@near-wallet-selector/core`
6
+ * - `@hot-labs/near-connect`
7
+ *
8
+ * These adapters use duck typing / structural compatibility to work with
9
+ * wallet interfaces. While the actual wallet packages use `@near-js` types
10
+ * (which are classes), our types (plain objects) are structurally compatible
11
+ * and work correctly at runtime. See `tests/wallets/type-compatibility.test.ts`
12
+ * for verification.
13
+ */
14
+ /**
15
+ * Adapter for @near-wallet-selector/core
16
+ *
17
+ * Converts a wallet-selector Wallet instance to the WalletConnection interface.
18
+ *
19
+ * @param wallet - Wallet instance from wallet-selector
20
+ * @returns WalletConnection interface compatible with near-ts
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { Near } from 'near-ts'
25
+ * import { setupWalletSelector } from '@near-wallet-selector/core'
26
+ * import { fromWalletSelector } from 'near-ts/wallets'
27
+ *
28
+ * const selector = await setupWalletSelector({
29
+ * network: 'mainnet',
30
+ * modules: [...]
31
+ * })
32
+ * const wallet = await selector.wallet()
33
+ *
34
+ * const near = new Near({
35
+ * network: 'mainnet',
36
+ * wallet: fromWalletSelector(wallet)
37
+ * })
38
+ * ```
39
+ */
40
+ export function fromWalletSelector(wallet) {
41
+ return {
42
+ async getAccounts() {
43
+ const accounts = await wallet.getAccounts();
44
+ return accounts.map((acc) => ({
45
+ accountId: acc.accountId,
46
+ ...(acc.publicKey !== undefined && { publicKey: acc.publicKey }),
47
+ }));
48
+ },
49
+ async signAndSendTransaction(params) {
50
+ // Our Action[] type is structurally compatible with @near-js Action[]
51
+ // Duck typing works at runtime - see type-compatibility.test.ts
52
+ const result = await wallet.signAndSendTransaction({
53
+ ...(params.signerId !== undefined && { signerId: params.signerId }),
54
+ receiverId: params.receiverId,
55
+ actions: params.actions,
56
+ });
57
+ if (!result) {
58
+ throw new Error("Wallet did not return transaction outcome");
59
+ }
60
+ return result;
61
+ },
62
+ async signMessage(params) {
63
+ if (!wallet.signMessage) {
64
+ throw new Error("Wallet does not support message signing");
65
+ }
66
+ // wallet-selector expects Buffer, convert from Uint8Array
67
+ const nonce = Buffer.from(params.nonce);
68
+ const result = await wallet.signMessage({
69
+ message: params.message,
70
+ recipient: params.recipient,
71
+ nonce,
72
+ });
73
+ // Browser wallets may return void
74
+ if (!result) {
75
+ throw new Error("Wallet did not return signed message");
76
+ }
77
+ return result;
78
+ },
79
+ };
80
+ }
81
+ /**
82
+ * Adapter for @hot-labs/near-connect (HOT Connect)
83
+ *
84
+ * Converts a HOT Connect NearConnector instance to the WalletConnection interface.
85
+ *
86
+ * @param connector - NearConnector instance from HOT Connect
87
+ * @returns WalletConnection interface compatible with near-ts
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { Near } from 'near-ts'
92
+ * import { NearConnector } from '@hot-labs/near-connect'
93
+ * import { fromHotConnect } from 'near-ts/wallets'
94
+ *
95
+ * const connector = new NearConnector({ network: 'mainnet' })
96
+ *
97
+ * // Wait for user to connect their wallet
98
+ * connector.on('wallet:signIn', async () => {
99
+ * const near = new Near({
100
+ * network: 'mainnet',
101
+ * wallet: fromHotConnect(connector)
102
+ * })
103
+ *
104
+ * // Use near-ts with the connected wallet
105
+ * await near.call('contract.near', 'method', { arg: 'value' })
106
+ * })
107
+ * ```
108
+ */
109
+ /**
110
+ * Adapter for @hot-labs/near-connect (HOT Connect)
111
+ *
112
+ * Converts a HOT Connect NearConnector instance to the WalletConnection interface.
113
+ *
114
+ * @param connector - NearConnector instance from HOT Connect
115
+ * @returns WalletConnection interface compatible with near-kit
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * import { Near } from 'near-kit'
120
+ * import { NearConnector } from '@hot-labs/near-connect'
121
+ * import { fromHotConnect } from 'near-kit/wallets'
122
+ *
123
+ * const connector = new NearConnector({ network: 'mainnet' })
124
+ *
125
+ * // Wait for user to connect their wallet
126
+ * connector.on('wallet:signIn', async () => {
127
+ * const near = new Near({
128
+ * network: 'mainnet',
129
+ * wallet: fromHotConnect(connector)
130
+ * })
131
+ *
132
+ * // Use near-kit with the connected wallet
133
+ * await near.call('contract.near', 'method', { arg: 'value' })
134
+ * })
135
+ * ```
136
+ */
137
+ export function fromHotConnect(connector) {
138
+ // Validate that we have a proper connector
139
+ if (!connector || typeof connector.wallet !== "function") {
140
+ throw new Error("Invalid HOT Connect instance. Make sure @hot-labs/near-connect is installed and you're passing a NearConnector instance.");
141
+ }
142
+ return {
143
+ async getAccounts() {
144
+ const wallet = await connector.wallet();
145
+ const accounts = await wallet.getAccounts();
146
+ return accounts.map((acc) => ({
147
+ accountId: acc.accountId,
148
+ publicKey: acc.publicKey,
149
+ }));
150
+ },
151
+ async signAndSendTransaction(params) {
152
+ const wallet = await connector.wallet();
153
+ const convertAction = (action) => {
154
+ const a = action;
155
+ if ("functionCall" in a && a["functionCall"]) {
156
+ const fc = a["functionCall"];
157
+ let args = fc.args;
158
+ if (Array.isArray(args) &&
159
+ args.every((x) => typeof x === "number")) {
160
+ try {
161
+ const argsString = new TextDecoder().decode(new Uint8Array(args));
162
+ args = JSON.parse(argsString);
163
+ }
164
+ catch {
165
+ // If parsing fails, keep args as raw bytes (may be binary data)
166
+ }
167
+ }
168
+ const argsObject = args && typeof args === "object" && !Array.isArray(args)
169
+ ? args
170
+ : {};
171
+ return {
172
+ type: "FunctionCall",
173
+ params: {
174
+ methodName: fc.methodName,
175
+ args: argsObject,
176
+ gas: fc.gas.toString(),
177
+ deposit: fc.deposit.toString(),
178
+ },
179
+ };
180
+ }
181
+ if ("transfer" in a && a["transfer"]) {
182
+ const t = a["transfer"];
183
+ return {
184
+ type: "Transfer",
185
+ params: { deposit: t.deposit.toString() },
186
+ };
187
+ }
188
+ if ("stake" in a && a["stake"]) {
189
+ const s = a["stake"];
190
+ return {
191
+ type: "Stake",
192
+ params: {
193
+ stake: s.stake.toString(),
194
+ // HOT Connect expects a base58 string; we forward whatever representation
195
+ // we have and rely on upstream tooling when stake is used with wallets.
196
+ publicKey: String(s.publicKey),
197
+ },
198
+ };
199
+ }
200
+ if ("addKey" in a && a["addKey"]) {
201
+ const ak = a["addKey"];
202
+ return {
203
+ type: "AddKey",
204
+ params: {
205
+ publicKey: String(ak.publicKey),
206
+ accessKey: {
207
+ nonce: Number(ak.accessKey.nonce),
208
+ permission: ak.accessKey
209
+ .permission,
210
+ },
211
+ },
212
+ };
213
+ }
214
+ if ("deleteKey" in a && a["deleteKey"]) {
215
+ const dk = a["deleteKey"];
216
+ return {
217
+ type: "DeleteKey",
218
+ params: {
219
+ publicKey: String(dk.publicKey),
220
+ },
221
+ };
222
+ }
223
+ if ("deleteAccount" in a && a["deleteAccount"]) {
224
+ const da = a["deleteAccount"];
225
+ return {
226
+ type: "DeleteAccount",
227
+ params: {
228
+ beneficiaryId: da.beneficiaryId,
229
+ },
230
+ };
231
+ }
232
+ if ("createAccount" in a && a["createAccount"] !== undefined) {
233
+ return {
234
+ type: "CreateAccount",
235
+ };
236
+ }
237
+ if ("deployContract" in a && a["deployContract"]) {
238
+ const dc = a["deployContract"];
239
+ return {
240
+ type: "DeployContract",
241
+ params: {
242
+ code: dc.code,
243
+ },
244
+ };
245
+ }
246
+ throw new Error(`Unsupported action type: ${Object.keys(a).join(", ") || "unknown"}`);
247
+ };
248
+ const hotConnectorActions = params.actions.map(convertAction);
249
+ const result = await wallet.signAndSendTransaction({
250
+ ...(params.signerId !== undefined && { signerId: params.signerId }),
251
+ receiverId: params.receiverId,
252
+ actions: hotConnectorActions,
253
+ });
254
+ return result;
255
+ },
256
+ async signMessage(params) {
257
+ const wallet = await connector.wallet();
258
+ const result = await wallet.signMessage({
259
+ message: params.message,
260
+ recipient: params.recipient,
261
+ nonce: params.nonce,
262
+ });
263
+ return result;
264
+ },
265
+ };
266
+ }
267
+ //# sourceMappingURL=adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.js","sourceRoot":"","sources":["../../src/wallets/adapters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoCH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA4B;IAE5B,OAAO;QACL,KAAK,CAAC,WAAW;YACf,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAA;YAC3C,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBAC5B,SAAS,EAAE,GAAG,CAAC,SAAS;gBACxB,GAAG,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;aACjE,CAAC,CAAC,CAAA;QACL,CAAC;QAED,KAAK,CAAC,sBAAsB,CAAC,MAAM;YACjC,sEAAsE;YACtE,gEAAgE;YAChE,MAAM,MAAM,GAAG,MAAM,MAAM,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CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;YAE7D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC;gBACjD,GAAG,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACnE,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,OAAO,EAAE,mBAAmB;aAC7B,CAAC,CAAA;YAEF,OAAO,MAA+B,CAAA;QACxC,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,MAAM;YACtB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,CAAA;YACvC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;gBACtC,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC,CAAA;YACF,OAAO,MAAuB,CAAA;QAChC,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Wallet integration adapters for NEAR.
3
+ *
4
+ * @remarks
5
+ * Re-exports the {@link WalletConnection} interface and concrete adapters
6
+ * {@link fromWalletSelector} and {@link fromHotConnect} for integrating with
7
+ * common NEAR wallet libraries.
8
+ */
9
+ export type { WalletConnection } from "../core/types.js";
10
+ export { fromHotConnect, fromWalletSelector } from "./adapters.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { fromHotConnect, fromWalletSelector } from "./adapters.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wallets/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Internal wallet type helpers for near-kit.
3
+ *
4
+ * Defines lightweight structural types for external wallet libraries
5
+ * (e.g. HOT Connect) without taking a hard dependency on their packages.
6
+ *
7
+ * @internal
8
+ */
9
+ import type { FinalExecutionOutcome, SignedMessage } from "../core/types.js";
10
+ /**
11
+ * HOT Connect action types, mirroring `@hot-labs/near-connect`'s
12
+ * `types/transactions.ts` definitions.
13
+ */
14
+ export type HotConnectCreateAccountAction = {
15
+ type: "CreateAccount";
16
+ };
17
+ export type HotConnectDeployContractAction = {
18
+ type: "DeployContract";
19
+ params: {
20
+ code: Uint8Array;
21
+ };
22
+ };
23
+ export type HotConnectFunctionCallAction = {
24
+ type: "FunctionCall";
25
+ params: {
26
+ methodName: string;
27
+ args: Record<string, unknown>;
28
+ gas: string;
29
+ deposit: string;
30
+ };
31
+ };
32
+ export type HotConnectTransferAction = {
33
+ type: "Transfer";
34
+ params: {
35
+ deposit: string;
36
+ };
37
+ };
38
+ export type HotConnectStakeAction = {
39
+ type: "Stake";
40
+ params: {
41
+ stake: string;
42
+ publicKey: string;
43
+ };
44
+ };
45
+ export type HotConnectAddKeyPermission = "FullAccess" | {
46
+ receiverId: string;
47
+ allowance?: string;
48
+ methodNames?: string[];
49
+ };
50
+ export type HotConnectAddKeyAction = {
51
+ type: "AddKey";
52
+ params: {
53
+ publicKey: string;
54
+ accessKey: {
55
+ nonce?: number;
56
+ permission: HotConnectAddKeyPermission;
57
+ };
58
+ };
59
+ };
60
+ export type HotConnectDeleteKeyAction = {
61
+ type: "DeleteKey";
62
+ params: {
63
+ publicKey: string;
64
+ };
65
+ };
66
+ export type HotConnectDeleteAccountAction = {
67
+ type: "DeleteAccount";
68
+ params: {
69
+ beneficiaryId: string;
70
+ };
71
+ };
72
+ export type HotConnectAction = HotConnectCreateAccountAction | HotConnectDeployContractAction | HotConnectFunctionCallAction | HotConnectTransferAction | HotConnectStakeAction | HotConnectAddKeyAction | HotConnectDeleteKeyAction | HotConnectDeleteAccountAction;
73
+ /**
74
+ * HOT Connect wallet + connector interfaces (structural).
75
+ */
76
+ export type HotConnectWallet = {
77
+ getAccounts(data?: {
78
+ network?: string;
79
+ }): Promise<Array<{
80
+ accountId: string;
81
+ publicKey: string;
82
+ }>>;
83
+ signAndSendTransaction(params: {
84
+ signerId?: string;
85
+ receiverId: string;
86
+ actions: HotConnectAction[];
87
+ network?: string;
88
+ }): Promise<FinalExecutionOutcome>;
89
+ signMessage(params: {
90
+ message: string;
91
+ recipient: string;
92
+ nonce: Uint8Array;
93
+ network?: string;
94
+ }): Promise<SignedMessage>;
95
+ };
96
+ export type HotConnectConnector = {
97
+ wallet(): Promise<HotConnectWallet>;
98
+ };
99
+ //# sourceMappingURL=types.d.ts.map