@dynamic-labs/aleo 0.0.0 → 4.67.1

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 (31) hide show
  1. package/CHANGELOG.md +7007 -0
  2. package/LICENSE +21 -0
  3. package/_virtual/_tslib.cjs +36 -0
  4. package/_virtual/_tslib.js +32 -0
  5. package/package.cjs +8 -0
  6. package/package.js +4 -0
  7. package/package.json +32 -1
  8. package/src/connectors/AleoWalletAdapterConnector/AleoWalletAdapterConnector.cjs +322 -0
  9. package/src/connectors/AleoWalletAdapterConnector/AleoWalletAdapterConnector.d.ts +59 -0
  10. package/src/connectors/AleoWalletAdapterConnector/AleoWalletAdapterConnector.js +318 -0
  11. package/src/connectors/AleoWalletAdapterConnector/index.d.ts +2 -0
  12. package/src/connectors/AleoWalletConnector/AleoWalletConnector.cjs +219 -0
  13. package/src/connectors/AleoWalletConnector/AleoWalletConnector.d.ts +111 -0
  14. package/src/connectors/AleoWalletConnector/AleoWalletConnector.js +215 -0
  15. package/src/connectors/AleoWalletConnector/index.d.ts +2 -0
  16. package/src/index.cjs +39 -0
  17. package/src/index.d.ts +14 -0
  18. package/src/index.js +16 -0
  19. package/src/types.d.ts +42 -0
  20. package/src/utils/fetchAleoWalletAdapterConnectors/fetchAleoWalletAdapterConnectors.cjs +71 -0
  21. package/src/utils/fetchAleoWalletAdapterConnectors/fetchAleoWalletAdapterConnectors.d.ts +25 -0
  22. package/src/utils/fetchAleoWalletAdapterConnectors/fetchAleoWalletAdapterConnectors.js +66 -0
  23. package/src/utils/fetchAleoWalletAdapterConnectors/index.d.ts +1 -0
  24. package/src/wallet/AleoWallet/AleoWallet.cjs +108 -0
  25. package/src/wallet/AleoWallet/AleoWallet.d.ts +57 -0
  26. package/src/wallet/AleoWallet/AleoWallet.js +104 -0
  27. package/src/wallet/AleoWallet/index.d.ts +1 -0
  28. package/src/wallet/isAleoWallet/index.d.ts +1 -0
  29. package/src/wallet/isAleoWallet/isAleoWallet.cjs +8 -0
  30. package/src/wallet/isAleoWallet/isAleoWallet.d.ts +3 -0
  31. package/src/wallet/isAleoWallet/isAleoWallet.js +4 -0
@@ -0,0 +1,104 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { DynamicError } from '@dynamic-labs/utils';
4
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
5
+
6
+ class AleoWallet extends Wallet {
7
+ sendBalance(_a) {
8
+ return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, token, }) {
9
+ var _b, _c, _d;
10
+ const chainId = (_b = (yield this._connector.getNetwork())) !== null && _b !== void 0 ? _b : '0';
11
+ const decimals = (_c = token === null || token === void 0 ? void 0 : token.decimals) !== null && _c !== void 0 ? _c : 6;
12
+ const microcredits = BigInt(Math.round(parseFloat(amount) * Math.pow(10, decimals)));
13
+ const program = (_d = token === null || token === void 0 ? void 0 : token.address) !== null && _d !== void 0 ? _d : 'credits.aleo';
14
+ const transaction = {
15
+ address: this.address,
16
+ chainId,
17
+ fee: 50000,
18
+ feePrivate: false,
19
+ transitions: [
20
+ {
21
+ functionName: 'transfer_public',
22
+ inputs: [
23
+ toAddress,
24
+ `${microcredits}${(token === null || token === void 0 ? void 0 : token.address) ? 'u128' : 'u64'}`,
25
+ ],
26
+ program,
27
+ },
28
+ ],
29
+ };
30
+ return this._connector.requestTransaction(transaction);
31
+ });
32
+ }
33
+ getBalance() {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ var _a;
36
+ return (_a = (yield this._connector.getBalance(this.address))) !== null && _a !== void 0 ? _a : '0';
37
+ });
38
+ }
39
+ /**
40
+ * Returns the Aleo public key for this wallet.
41
+ * In Aleo, the public key and address are the same value.
42
+ */
43
+ getPublicKey() {
44
+ return this.address;
45
+ }
46
+ /**
47
+ * Returns the current network this wallet is connected to (e.g. 'aleo:mainnet').
48
+ */
49
+ getNetworkInfo() {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ return this._connector.getNetwork();
52
+ });
53
+ }
54
+ /**
55
+ * Signs a message with the Aleo wallet.
56
+ * Accepts both plain strings and Uint8Array (decoded to UTF-8).
57
+ */
58
+ signMessage(message) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const messageString = typeof message === 'string' ? message : new TextDecoder().decode(message);
61
+ const signature = yield this._connector.signMessage(messageString);
62
+ if (!signature) {
63
+ throw new DynamicError('Failed to sign message');
64
+ }
65
+ return signature;
66
+ });
67
+ }
68
+ /**
69
+ * Executes a program transition on the Aleo network.
70
+ * Returns the transaction ID on success.
71
+ *
72
+ * @param transaction - The transaction to execute
73
+ */
74
+ requestTransaction(transaction) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ return this._connector.requestTransaction(transaction);
77
+ });
78
+ }
79
+ /**
80
+ * Decrypts an Aleo ciphertext using the wallet's view key.
81
+ * Useful for reading private record data.
82
+ *
83
+ * @param ciphertext - The ciphertext string to decrypt
84
+ * @param options - Optional parameters (tpk, programId, functionName, index)
85
+ */
86
+ decrypt(ciphertext, options) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ return this._connector.decrypt(ciphertext, options);
89
+ });
90
+ }
91
+ /**
92
+ * Requests the records owned by this wallet for a given Aleo program.
93
+ *
94
+ * @param program - The program ID to fetch records for (e.g. 'credits.aleo')
95
+ * @param options - Optional: { plaintext: true } to return decrypted record data
96
+ */
97
+ requestRecords(program, options) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ return this._connector.requestRecords(program, options);
100
+ });
101
+ }
102
+ }
103
+
104
+ export { AleoWallet };
@@ -0,0 +1 @@
1
+ export { AleoWallet } from './AleoWallet';
@@ -0,0 +1 @@
1
+ export { isAleoWallet } from './isAleoWallet';
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isAleoWallet = (wallet) => wallet.chain === 'ALEO';
7
+
8
+ exports.isAleoWallet = isAleoWallet;
@@ -0,0 +1,3 @@
1
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import { AleoWallet } from '../AleoWallet';
3
+ export declare const isAleoWallet: (wallet: Wallet) => wallet is AleoWallet;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isAleoWallet = (wallet) => wallet.chain === 'ALEO';
3
+
4
+ export { isAleoWallet };