@dynamic-labs/aleo 0.0.0 → 4.67.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/CHANGELOG.md +6993 -0
- package/LICENSE +21 -0
- package/_virtual/_tslib.cjs +36 -0
- package/_virtual/_tslib.js +32 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +32 -1
- package/src/connectors/AleoWalletAdapterConnector/AleoWalletAdapterConnector.cjs +322 -0
- package/src/connectors/AleoWalletAdapterConnector/AleoWalletAdapterConnector.d.ts +59 -0
- package/src/connectors/AleoWalletAdapterConnector/AleoWalletAdapterConnector.js +318 -0
- package/src/connectors/AleoWalletAdapterConnector/index.d.ts +2 -0
- package/src/connectors/AleoWalletConnector/AleoWalletConnector.cjs +219 -0
- package/src/connectors/AleoWalletConnector/AleoWalletConnector.d.ts +111 -0
- package/src/connectors/AleoWalletConnector/AleoWalletConnector.js +215 -0
- package/src/connectors/AleoWalletConnector/index.d.ts +2 -0
- package/src/index.cjs +39 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +16 -0
- package/src/types.d.ts +42 -0
- package/src/utils/fetchAleoWalletAdapterConnectors/fetchAleoWalletAdapterConnectors.cjs +71 -0
- package/src/utils/fetchAleoWalletAdapterConnectors/fetchAleoWalletAdapterConnectors.d.ts +25 -0
- package/src/utils/fetchAleoWalletAdapterConnectors/fetchAleoWalletAdapterConnectors.js +66 -0
- package/src/utils/fetchAleoWalletAdapterConnectors/index.d.ts +1 -0
- package/src/wallet/AleoWallet/AleoWallet.cjs +105 -0
- package/src/wallet/AleoWallet/AleoWallet.d.ts +57 -0
- package/src/wallet/AleoWallet/AleoWallet.js +101 -0
- package/src/wallet/AleoWallet/index.d.ts +1 -0
- package/src/wallet/isAleoWallet/index.d.ts +1 -0
- package/src/wallet/isAleoWallet/isAleoWallet.cjs +8 -0
- package/src/wallet/isAleoWallet/isAleoWallet.d.ts +3 -0
- package/src/wallet/isAleoWallet/isAleoWallet.js +4 -0
|
@@ -0,0 +1,101 @@
|
|
|
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: [toAddress, `${microcredits}u64`],
|
|
23
|
+
program,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
return this._connector.requestTransaction(transaction);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getBalance() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var _a;
|
|
33
|
+
return (_a = (yield this._connector.getBalance(this.address))) !== null && _a !== void 0 ? _a : '0';
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the Aleo public key for this wallet.
|
|
38
|
+
* In Aleo, the public key and address are the same value.
|
|
39
|
+
*/
|
|
40
|
+
getPublicKey() {
|
|
41
|
+
return this.address;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns the current network this wallet is connected to (e.g. 'aleo:mainnet').
|
|
45
|
+
*/
|
|
46
|
+
getNetworkInfo() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return this._connector.getNetwork();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Signs a message with the Aleo wallet.
|
|
53
|
+
* Accepts both plain strings and Uint8Array (decoded to UTF-8).
|
|
54
|
+
*/
|
|
55
|
+
signMessage(message) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const messageString = typeof message === 'string' ? message : new TextDecoder().decode(message);
|
|
58
|
+
const signature = yield this._connector.signMessage(messageString);
|
|
59
|
+
if (!signature) {
|
|
60
|
+
throw new DynamicError('Failed to sign message');
|
|
61
|
+
}
|
|
62
|
+
return signature;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Executes a program transition on the Aleo network.
|
|
67
|
+
* Returns the transaction ID on success.
|
|
68
|
+
*
|
|
69
|
+
* @param transaction - The transaction to execute
|
|
70
|
+
*/
|
|
71
|
+
requestTransaction(transaction) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
return this._connector.requestTransaction(transaction);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Decrypts an Aleo ciphertext using the wallet's view key.
|
|
78
|
+
* Useful for reading private record data.
|
|
79
|
+
*
|
|
80
|
+
* @param ciphertext - The ciphertext string to decrypt
|
|
81
|
+
* @param options - Optional parameters (tpk, programId, functionName, index)
|
|
82
|
+
*/
|
|
83
|
+
decrypt(ciphertext, options) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
return this._connector.decrypt(ciphertext, options);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Requests the records owned by this wallet for a given Aleo program.
|
|
90
|
+
*
|
|
91
|
+
* @param program - The program ID to fetch records for (e.g. 'credits.aleo')
|
|
92
|
+
* @param options - Optional: { plaintext: true } to return decrypted record data
|
|
93
|
+
*/
|
|
94
|
+
requestRecords(program, options) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
return this._connector.requestRecords(program, options);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { AleoWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AleoWallet } from './AleoWallet';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isAleoWallet } from './isAleoWallet';
|