@provablehq/aleo-wallet-adaptor-core 0.1.1-alpha.0 → 0.3.0-alpha.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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -87,6 +87,7 @@ declare abstract class BaseAleoWalletAdapter extends EventEmitter<WalletEvents>
|
|
|
87
87
|
transactionId: string;
|
|
88
88
|
}>;
|
|
89
89
|
}
|
|
90
|
+
declare function scopePollingDetectionStrategy(detect: () => boolean): void;
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* Get the short address representation (for display)
|
|
@@ -184,4 +185,4 @@ declare class MethodNotImplementedError extends WalletError {
|
|
|
184
185
|
constructor(method: string);
|
|
185
186
|
}
|
|
186
187
|
|
|
187
|
-
export { BaseAleoWalletAdapter, MethodNotImplementedError, WalletConnectionError, WalletDecryptionError, WalletDecryptionNotAllowedError, WalletDisconnectionError, WalletError, WalletFeatureNotAvailableError, WalletNotConnectedError, WalletNotReadyError, WalletNotSelectedError, WalletSignMessageError, WalletSwitchNetworkError, WalletTransactionError, WalletTransactionRejectedError, WalletTransactionTimeoutError, createAccount, getShortAddress };
|
|
188
|
+
export { BaseAleoWalletAdapter, MethodNotImplementedError, WalletConnectionError, WalletDecryptionError, WalletDecryptionNotAllowedError, WalletDisconnectionError, WalletError, WalletFeatureNotAvailableError, WalletNotConnectedError, WalletNotReadyError, WalletNotSelectedError, WalletSignMessageError, WalletSwitchNetworkError, WalletTransactionError, WalletTransactionRejectedError, WalletTransactionTimeoutError, createAccount, getShortAddress, scopePollingDetectionStrategy };
|
package/dist/index.d.ts
CHANGED
|
@@ -87,6 +87,7 @@ declare abstract class BaseAleoWalletAdapter extends EventEmitter<WalletEvents>
|
|
|
87
87
|
transactionId: string;
|
|
88
88
|
}>;
|
|
89
89
|
}
|
|
90
|
+
declare function scopePollingDetectionStrategy(detect: () => boolean): void;
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* Get the short address representation (for display)
|
|
@@ -184,4 +185,4 @@ declare class MethodNotImplementedError extends WalletError {
|
|
|
184
185
|
constructor(method: string);
|
|
185
186
|
}
|
|
186
187
|
|
|
187
|
-
export { BaseAleoWalletAdapter, MethodNotImplementedError, WalletConnectionError, WalletDecryptionError, WalletDecryptionNotAllowedError, WalletDisconnectionError, WalletError, WalletFeatureNotAvailableError, WalletNotConnectedError, WalletNotReadyError, WalletNotSelectedError, WalletSignMessageError, WalletSwitchNetworkError, WalletTransactionError, WalletTransactionRejectedError, WalletTransactionTimeoutError, createAccount, getShortAddress };
|
|
188
|
+
export { BaseAleoWalletAdapter, MethodNotImplementedError, WalletConnectionError, WalletDecryptionError, WalletDecryptionNotAllowedError, WalletDisconnectionError, WalletError, WalletFeatureNotAvailableError, WalletNotConnectedError, WalletNotReadyError, WalletNotSelectedError, WalletSignMessageError, WalletSwitchNetworkError, WalletTransactionError, WalletTransactionRejectedError, WalletTransactionTimeoutError, createAccount, getShortAddress, scopePollingDetectionStrategy };
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,8 @@ __export(index_exports, {
|
|
|
38
38
|
WalletTransactionRejectedError: () => WalletTransactionRejectedError,
|
|
39
39
|
WalletTransactionTimeoutError: () => WalletTransactionTimeoutError,
|
|
40
40
|
createAccount: () => createAccount,
|
|
41
|
-
getShortAddress: () => getShortAddress
|
|
41
|
+
getShortAddress: () => getShortAddress,
|
|
42
|
+
scopePollingDetectionStrategy: () => scopePollingDetectionStrategy
|
|
42
43
|
});
|
|
43
44
|
module.exports = __toCommonJS(index_exports);
|
|
44
45
|
|
|
@@ -288,6 +289,38 @@ var BaseAleoWalletAdapter = class extends import_aleo_wallet_standard.EventEmitt
|
|
|
288
289
|
return feature.executeDeployment(deployment);
|
|
289
290
|
}
|
|
290
291
|
};
|
|
292
|
+
function scopePollingDetectionStrategy(detect) {
|
|
293
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
294
|
+
const disposers = [];
|
|
295
|
+
function detectAndDispose() {
|
|
296
|
+
const detected = detect();
|
|
297
|
+
if (detected) {
|
|
298
|
+
for (const dispose of disposers) {
|
|
299
|
+
dispose();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const interval = (
|
|
304
|
+
// TODO: #334 Replace with idle callback strategy.
|
|
305
|
+
setInterval(detectAndDispose, 1e3)
|
|
306
|
+
);
|
|
307
|
+
disposers.push(() => clearInterval(interval));
|
|
308
|
+
if (
|
|
309
|
+
// Implies that `DOMContentLoaded` has not yet fired.
|
|
310
|
+
document.readyState === "loading"
|
|
311
|
+
) {
|
|
312
|
+
document.addEventListener("DOMContentLoaded", detectAndDispose, { once: true });
|
|
313
|
+
disposers.push(() => document.removeEventListener("DOMContentLoaded", detectAndDispose));
|
|
314
|
+
}
|
|
315
|
+
if (
|
|
316
|
+
// If the `complete` state has been reached, we're too late.
|
|
317
|
+
document.readyState !== "complete"
|
|
318
|
+
) {
|
|
319
|
+
window.addEventListener("load", detectAndDispose, { once: true });
|
|
320
|
+
disposers.push(() => window.removeEventListener("load", detectAndDispose));
|
|
321
|
+
}
|
|
322
|
+
detectAndDispose();
|
|
323
|
+
}
|
|
291
324
|
|
|
292
325
|
// src/account.ts
|
|
293
326
|
function getShortAddress(address, prefixLength = 4, suffixLength = 4) {
|
|
@@ -331,6 +364,7 @@ var import_aleo_wallet_standard2 = require("@provablehq/aleo-wallet-standard");
|
|
|
331
364
|
WalletTransactionRejectedError,
|
|
332
365
|
WalletTransactionTimeoutError,
|
|
333
366
|
createAccount,
|
|
334
|
-
getShortAddress
|
|
367
|
+
getShortAddress,
|
|
368
|
+
scopePollingDetectionStrategy
|
|
335
369
|
});
|
|
336
370
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/adapter.ts","../src/errors.ts","../src/account.ts","../src/types.ts"],"sourcesContent":["export { BaseAleoWalletAdapter } from './adapter';\nexport * from './account';\nexport * from './errors';\nexport * from './types';\n","import {\n Account,\n Network,\n TransactionOptions,\n TransactionStatusResponse,\n} from '@provablehq/aleo-types';\nimport {\n AleoChain,\n StandardWallet,\n WalletAdapter,\n WalletFeatureName,\n WalletReadyState,\n EventEmitter,\n WalletEvents,\n WalletName,\n WalletDecryptPermission,\n AleoDeployment,\n} from '@provablehq/aleo-wallet-standard';\nimport { WalletFeatureNotAvailableError, WalletNotConnectedError } from './errors';\nimport { WalletConnectionError } from './errors';\n\n/**\n * Base class for Aleo wallet adapters\n */\nexport abstract class BaseAleoWalletAdapter\n extends EventEmitter<WalletEvents>\n implements WalletAdapter\n{\n /**\n * The wallet name\n */\n abstract name: WalletName<string>;\n\n /**\n * The wallet URL\n */\n abstract url?: string;\n\n /**\n * The wallet icon\n */\n abstract icon?: string;\n\n /**\n * The wallet's ready state\n */\n abstract _readyState: WalletReadyState;\n get readyState(): WalletReadyState {\n return this._readyState;\n }\n protected set readyState(state: WalletReadyState) {\n if (state !== this._readyState) {\n this._readyState = state;\n this.emit('readyStateChange', state);\n }\n }\n\n /**\n * The connected account, if any\n */\n account?: Account;\n\n /**\n * The wallet's network\n */\n abstract network: Network;\n\n /**\n * The wallet's decrypt permission\n */\n abstract decryptPermission: WalletDecryptPermission;\n\n /**\n * The wallet's standard interface, if available\n */\n protected _wallet?: StandardWallet;\n\n /**\n * The supported chains\n */\n get chains(): AleoChain[] {\n return this._wallet?.features[WalletFeatureName.CHAINS]?.chains || [];\n }\n\n /**\n * The wallet's connected state\n */\n get connected(): boolean {\n return !!this.account;\n }\n\n /**\n * Connect to the wallet\n * @param network The network to connect to\n * @param decryptPermission The decrypt permission\n * @param programs The programs to connect to\n * @returns The connected account\n */\n async connect(\n network: Network,\n decryptPermission: WalletDecryptPermission,\n programs?: string[],\n ): Promise<Account> {\n if (!this._wallet) {\n throw new WalletConnectionError('No wallet provider found');\n }\n const feature = this._wallet.features[WalletFeatureName.CONNECT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.CONNECT);\n }\n try {\n const account = await feature.connect(network, decryptPermission, programs);\n this.account = account;\n this.emit('connect', account);\n return account;\n } catch (err) {\n this.emit('error', err as Error);\n throw err;\n }\n }\n\n /**\n * Disconnect from the wallet\n */\n async disconnect(): Promise<void> {\n if (!this._wallet) return;\n const feature = this._wallet.features[WalletFeatureName.CONNECT];\n if (feature && feature.available) {\n try {\n await feature.disconnect();\n } catch (err) {\n this.emit('error', err as Error);\n }\n }\n this.account = undefined;\n this.emit('disconnect');\n }\n\n /**\n * Sign a message\n * @param options Transaction options\n * @returns The signed transaction\n */\n async signMessage(message: Uint8Array): Promise<Uint8Array> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.SIGN];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.SIGN);\n }\n return feature.signMessage(message);\n }\n\n /**\n * Execute a transaction\n * @param options Transaction options\n * @returns The executed temporary transaction ID\n */\n async executeTransaction(options: TransactionOptions): Promise<{ transactionId: string }> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.EXECUTE];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.EXECUTE);\n }\n return feature.executeTransaction(options);\n }\n\n /**\n * Get transaction status\n * @param transactionId The transaction ID\n * @returns The transaction status\n */\n async transactionStatus(transactionId: string): Promise<TransactionStatusResponse> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.TRANSACTION_STATUS];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.TRANSACTION_STATUS);\n }\n return feature.transactionStatus(transactionId);\n }\n\n async switchNetwork(network: Network): Promise<void> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.SWITCH_NETWORK];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.SWITCH_NETWORK);\n }\n await feature.switchNetwork(network);\n this.emit('networkChange', network);\n }\n\n async decrypt(\n cipherText: string,\n tpk?: string,\n programId?: string,\n functionName?: string,\n index?: number,\n ): Promise<string> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.DECRYPT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.DECRYPT);\n }\n return feature.decrypt(cipherText, tpk, programId, functionName, index);\n }\n\n async requestRecords(program: string, includePlaintext: boolean): Promise<unknown[]> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.REQUEST_RECORDS];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.REQUEST_RECORDS);\n }\n\n return feature.requestRecords(program, includePlaintext);\n }\n\n async executeDeployment(deployment: AleoDeployment): Promise<{ transactionId: string }> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.EXECUTE_DEPLOYMENT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.EXECUTE_DEPLOYMENT);\n }\n return feature.executeDeployment(deployment);\n }\n}\n","/**\n * Base wallet error\n */\nexport class WalletError extends Error {\n name = 'WalletError';\n}\n\n/**\n * Error thrown when a wallet is not connected\n */\nexport class WalletNotConnectedError extends WalletError {\n name = 'WalletNotConnectedError';\n\n constructor() {\n super('Wallet not connected');\n }\n}\n\n/**\n * Error thrown when the wallet connection is rejected\n */\nexport class WalletConnectionError extends WalletError {\n name = 'WalletConnectionError';\n\n constructor(message = 'Connection to wallet failed') {\n super(message);\n }\n}\n\n/**\n * Error thrown when a required wallet feature is not available\n */\nexport class WalletFeatureNotAvailableError extends WalletError {\n name = 'WalletFeatureNotAvailableError';\n\n constructor(feature: string) {\n super(`Wallet feature not available: ${feature}`);\n }\n}\n\n/**\n * Error thrown when a wallet transaction fails\n */\nexport class WalletTransactionError extends WalletError {\n name = 'WalletTransactionError';\n\n constructor(message = 'Transaction failed') {\n super(message);\n }\n}\n\n/**\n * Error thrown when a user rejects a transaction\n */\nexport class WalletTransactionRejectedError extends WalletTransactionError {\n name = 'WalletTransactionRejectedError';\n\n constructor() {\n super('Transaction rejected by user');\n }\n}\n\n/**\n * Error thrown when a transaction times out\n */\nexport class WalletTransactionTimeoutError extends WalletTransactionError {\n name = 'WalletTransactionTimeoutError';\n\n constructor() {\n super('Transaction timed out');\n }\n}\n\nexport class WalletNotSelectedError extends WalletError {\n name = 'WalletNotSelectedError';\n\n constructor() {\n super('Wallet not selected');\n }\n}\n\nexport class WalletDisconnectionError extends WalletError {\n name = 'WalletDisconnectionError';\n\n constructor(message = 'Disconnection failed') {\n super(message);\n }\n}\n\nexport class WalletSignMessageError extends WalletError {\n name = 'WalletSignMessageError';\n\n constructor(message = 'Failed to sign message') {\n super(message);\n }\n}\n\nexport class WalletSwitchNetworkError extends WalletError {\n name = 'WalletSwitchNetworkError';\n\n constructor(message = 'Failed to switch network') {\n super(message);\n }\n}\n\nexport class WalletNotReadyError extends WalletError {\n name = 'WalletNotReadyError';\n\n constructor() {\n super('Wallet not ready');\n }\n}\n\nexport class WalletDecryptionNotAllowedError extends WalletError {\n name = 'WalletDecryptionNotAllowedError';\n\n constructor() {\n super('Decryption not allowed');\n }\n}\nexport class WalletDecryptionError extends WalletError {\n name = 'WalletDecryptionError';\n\n constructor(message = 'Failed to decrypt') {\n super(message);\n }\n}\n\nexport class MethodNotImplementedError extends WalletError {\n name = 'MethodNotImplementedError';\n\n constructor(method: string) {\n super(`Method not implemented: ${method}`);\n }\n}\n","import { Account, AccountOptions } from '@provablehq/aleo-types';\n\n/**\n * Get the short address representation (for display)\n * @param address The full address\n * @param prefixLength The number of characters to keep at the beginning\n * @param suffixLength The number of characters to keep at the end\n * @returns The short address representation\n */\nexport function getShortAddress(address: string, prefixLength = 4, suffixLength = 4): string {\n if (!address) {\n return '';\n }\n\n if (address.length <= prefixLength + suffixLength) {\n return address;\n }\n\n return `${address.slice(0, prefixLength)}...${address.slice(-suffixLength)}`;\n}\n\n/**\n * Create a new account with the given options\n * @param options Account options\n * @returns The created account\n */\nexport function createAccount(options?: AccountOptions): Account {\n // This is a mock implementation. In a real implementation, you would\n // use the Aleo SDK to create an account.\n const address = `aleo1${Math.random().toString(36).substring(2, 15)}`;\n const viewKey = options?.privateKey\n ? `AViewKey${Math.random().toString(36).substring(2, 15)}`\n : undefined;\n\n return {\n address,\n viewKey,\n privateKey: options?.privateKey,\n };\n}\n","import { WalletDecryptPermission } from '@provablehq/aleo-wallet-standard';\n\nexport { WalletDecryptPermission as DecryptPermission };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,kCAWO;;;ACdA,IAAM,cAAN,cAA0B,MAAM;AAAA,EAAhC;AAAA;AACL,gBAAO;AAAA;AACT;AAKO,IAAM,0BAAN,cAAsC,YAAY;AAAA,EAGvD,cAAc;AACZ,UAAM,sBAAsB;AAH9B,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,wBAAN,cAAoC,YAAY;AAAA,EAGrD,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AAHf,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,iCAAN,cAA6C,YAAY;AAAA,EAG9D,YAAY,SAAiB;AAC3B,UAAM,iCAAiC,OAAO,EAAE;AAHlD,g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,eAAe,GAAG,eAAe,GAAW;AAC3F,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,UAAU,eAAe,cAAc;AACjD,WAAO;AAAA,EACT;AAEA,SAAO,GAAG,QAAQ,MAAM,GAAG,YAAY,CAAC,MAAM,QAAQ,MAAM,CAAC,YAAY,CAAC;AAC5E;AAOO,SAAS,cAAc,SAAmC;AAG/D,QAAM,UAAU,QAAQ,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,EAAE,CAAC;AACnE,QAAM,UAAU,SAAS,aACrB,WAAW,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,EAAE,CAAC,KACtD;AAEJ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,YAAY,SAAS;AAAA,EACvB;AACF;;;ACvCA,IAAAA,+BAAwC;","names":["import_aleo_wallet_standard"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/adapter.ts","../src/errors.ts","../src/account.ts","../src/types.ts"],"sourcesContent":["export { BaseAleoWalletAdapter, scopePollingDetectionStrategy } from './adapter';\nexport * from './account';\nexport * from './errors';\nexport * from './types';\n","import {\n Account,\n Network,\n TransactionOptions,\n TransactionStatusResponse,\n} from '@provablehq/aleo-types';\nimport {\n AleoChain,\n StandardWallet,\n WalletAdapter,\n WalletFeatureName,\n WalletReadyState,\n EventEmitter,\n WalletEvents,\n WalletName,\n WalletDecryptPermission,\n AleoDeployment,\n} from '@provablehq/aleo-wallet-standard';\nimport { WalletFeatureNotAvailableError, WalletNotConnectedError } from './errors';\nimport { WalletConnectionError } from './errors';\n\n/**\n * Base class for Aleo wallet adapters\n */\nexport abstract class BaseAleoWalletAdapter\n extends EventEmitter<WalletEvents>\n implements WalletAdapter\n{\n /**\n * The wallet name\n */\n abstract name: WalletName<string>;\n\n /**\n * The wallet URL\n */\n abstract url?: string;\n\n /**\n * The wallet icon\n */\n abstract icon?: string;\n\n /**\n * The wallet's ready state\n */\n abstract _readyState: WalletReadyState;\n get readyState(): WalletReadyState {\n return this._readyState;\n }\n protected set readyState(state: WalletReadyState) {\n if (state !== this._readyState) {\n this._readyState = state;\n this.emit('readyStateChange', state);\n }\n }\n\n /**\n * The connected account, if any\n */\n account?: Account;\n\n /**\n * The wallet's network\n */\n abstract network: Network;\n\n /**\n * The wallet's decrypt permission\n */\n abstract decryptPermission: WalletDecryptPermission;\n\n /**\n * The wallet's standard interface, if available\n */\n protected _wallet?: StandardWallet;\n\n /**\n * The supported chains\n */\n get chains(): AleoChain[] {\n return this._wallet?.features[WalletFeatureName.CHAINS]?.chains || [];\n }\n\n /**\n * The wallet's connected state\n */\n get connected(): boolean {\n return !!this.account;\n }\n\n /**\n * Connect to the wallet\n * @param network The network to connect to\n * @param decryptPermission The decrypt permission\n * @param programs The programs to connect to\n * @returns The connected account\n */\n async connect(\n network: Network,\n decryptPermission: WalletDecryptPermission,\n programs?: string[],\n ): Promise<Account> {\n if (!this._wallet) {\n throw new WalletConnectionError('No wallet provider found');\n }\n const feature = this._wallet.features[WalletFeatureName.CONNECT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.CONNECT);\n }\n try {\n const account = await feature.connect(network, decryptPermission, programs);\n this.account = account;\n this.emit('connect', account);\n return account;\n } catch (err) {\n this.emit('error', err as Error);\n throw err;\n }\n }\n\n /**\n * Disconnect from the wallet\n */\n async disconnect(): Promise<void> {\n if (!this._wallet) return;\n const feature = this._wallet.features[WalletFeatureName.CONNECT];\n if (feature && feature.available) {\n try {\n await feature.disconnect();\n } catch (err) {\n this.emit('error', err as Error);\n }\n }\n this.account = undefined;\n this.emit('disconnect');\n }\n\n /**\n * Sign a message\n * @param options Transaction options\n * @returns The signed transaction\n */\n async signMessage(message: Uint8Array): Promise<Uint8Array> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.SIGN];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.SIGN);\n }\n return feature.signMessage(message);\n }\n\n /**\n * Execute a transaction\n * @param options Transaction options\n * @returns The executed temporary transaction ID\n */\n async executeTransaction(options: TransactionOptions): Promise<{ transactionId: string }> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.EXECUTE];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.EXECUTE);\n }\n return feature.executeTransaction(options);\n }\n\n /**\n * Get transaction status\n * @param transactionId The transaction ID\n * @returns The transaction status\n */\n async transactionStatus(transactionId: string): Promise<TransactionStatusResponse> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.TRANSACTION_STATUS];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.TRANSACTION_STATUS);\n }\n return feature.transactionStatus(transactionId);\n }\n\n async switchNetwork(network: Network): Promise<void> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.SWITCH_NETWORK];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.SWITCH_NETWORK);\n }\n await feature.switchNetwork(network);\n this.emit('networkChange', network);\n }\n\n async decrypt(\n cipherText: string,\n tpk?: string,\n programId?: string,\n functionName?: string,\n index?: number,\n ): Promise<string> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.DECRYPT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.DECRYPT);\n }\n return feature.decrypt(cipherText, tpk, programId, functionName, index);\n }\n\n async requestRecords(program: string, includePlaintext: boolean): Promise<unknown[]> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.REQUEST_RECORDS];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.REQUEST_RECORDS);\n }\n\n return feature.requestRecords(program, includePlaintext);\n }\n\n async executeDeployment(deployment: AleoDeployment): Promise<{ transactionId: string }> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.EXECUTE_DEPLOYMENT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.EXECUTE_DEPLOYMENT);\n }\n return feature.executeDeployment(deployment);\n }\n}\n\nexport function scopePollingDetectionStrategy(detect: () => boolean): void {\n // Early return when server-side rendering\n if (typeof window === 'undefined' || typeof document === 'undefined') return;\n\n const disposers: (() => void)[] = [];\n\n function detectAndDispose() {\n const detected = detect();\n if (detected) {\n for (const dispose of disposers) {\n dispose();\n }\n }\n }\n\n // Strategy #1: Try detecting every second.\n const interval =\n // TODO: #334 Replace with idle callback strategy.\n setInterval(detectAndDispose, 1000);\n disposers.push(() => clearInterval(interval));\n\n // Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.\n if (\n // Implies that `DOMContentLoaded` has not yet fired.\n document.readyState === 'loading'\n ) {\n document.addEventListener('DOMContentLoaded', detectAndDispose, { once: true });\n disposers.push(() => document.removeEventListener('DOMContentLoaded', detectAndDispose));\n }\n\n // Strategy #3: Detect after the `window` has fully loaded.\n if (\n // If the `complete` state has been reached, we're too late.\n document.readyState !== 'complete'\n ) {\n window.addEventListener('load', detectAndDispose, { once: true });\n disposers.push(() => window.removeEventListener('load', detectAndDispose));\n }\n\n // Strategy #4: Detect synchronously, now.\n detectAndDispose();\n}\n","/**\n * Base wallet error\n */\nexport class WalletError extends Error {\n name = 'WalletError';\n}\n\n/**\n * Error thrown when a wallet is not connected\n */\nexport class WalletNotConnectedError extends WalletError {\n name = 'WalletNotConnectedError';\n\n constructor() {\n super('Wallet not connected');\n }\n}\n\n/**\n * Error thrown when the wallet connection is rejected\n */\nexport class WalletConnectionError extends WalletError {\n name = 'WalletConnectionError';\n\n constructor(message = 'Connection to wallet failed') {\n super(message);\n }\n}\n\n/**\n * Error thrown when a required wallet feature is not available\n */\nexport class WalletFeatureNotAvailableError extends WalletError {\n name = 'WalletFeatureNotAvailableError';\n\n constructor(feature: string) {\n super(`Wallet feature not available: ${feature}`);\n }\n}\n\n/**\n * Error thrown when a wallet transaction fails\n */\nexport class WalletTransactionError extends WalletError {\n name = 'WalletTransactionError';\n\n constructor(message = 'Transaction failed') {\n super(message);\n }\n}\n\n/**\n * Error thrown when a user rejects a transaction\n */\nexport class WalletTransactionRejectedError extends WalletTransactionError {\n name = 'WalletTransactionRejectedError';\n\n constructor() {\n super('Transaction rejected by user');\n }\n}\n\n/**\n * Error thrown when a transaction times out\n */\nexport class WalletTransactionTimeoutError extends WalletTransactionError {\n name = 'WalletTransactionTimeoutError';\n\n constructor() {\n super('Transaction timed out');\n }\n}\n\nexport class WalletNotSelectedError extends WalletError {\n name = 'WalletNotSelectedError';\n\n constructor() {\n super('Wallet not selected');\n }\n}\n\nexport class WalletDisconnectionError extends WalletError {\n name = 'WalletDisconnectionError';\n\n constructor(message = 'Disconnection failed') {\n super(message);\n }\n}\n\nexport class WalletSignMessageError extends WalletError {\n name = 'WalletSignMessageError';\n\n constructor(message = 'Failed to sign message') {\n super(message);\n }\n}\n\nexport class WalletSwitchNetworkError extends WalletError {\n name = 'WalletSwitchNetworkError';\n\n constructor(message = 'Failed to switch network') {\n super(message);\n }\n}\n\nexport class WalletNotReadyError extends WalletError {\n name = 'WalletNotReadyError';\n\n constructor() {\n super('Wallet not ready');\n }\n}\n\nexport class WalletDecryptionNotAllowedError extends WalletError {\n name = 'WalletDecryptionNotAllowedError';\n\n constructor() {\n super('Decryption not allowed');\n }\n}\nexport class WalletDecryptionError extends WalletError {\n name = 'WalletDecryptionError';\n\n constructor(message = 'Failed to decrypt') {\n super(message);\n }\n}\n\nexport class MethodNotImplementedError extends WalletError {\n name = 'MethodNotImplementedError';\n\n constructor(method: string) {\n super(`Method not implemented: ${method}`);\n }\n}\n","import { Account, AccountOptions } from '@provablehq/aleo-types';\n\n/**\n * Get the short address representation (for display)\n * @param address The full address\n * @param prefixLength The number of characters to keep at the beginning\n * @param suffixLength The number of characters to keep at the end\n * @returns The short address representation\n */\nexport function getShortAddress(address: string, prefixLength = 4, suffixLength = 4): string {\n if (!address) {\n return '';\n }\n\n if (address.length <= prefixLength + suffixLength) {\n return address;\n }\n\n return `${address.slice(0, prefixLength)}...${address.slice(-suffixLength)}`;\n}\n\n/**\n * Create a new account with the given options\n * @param options Account options\n * @returns The created account\n */\nexport function createAccount(options?: AccountOptions): Account {\n // This is a mock implementation. In a real implementation, you would\n // use the Aleo SDK to create an account.\n const address = `aleo1${Math.random().toString(36).substring(2, 15)}`;\n const viewKey = options?.privateKey\n ? `AViewKey${Math.random().toString(36).substring(2, 15)}`\n : undefined;\n\n return {\n address,\n viewKey,\n privateKey: options?.privateKey,\n };\n}\n","import { WalletDecryptPermission } from '@provablehq/aleo-wallet-standard';\n\nexport { WalletDecryptPermission as DecryptPermission };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,kCAWO;;;ACdA,IAAM,cAAN,cAA0B,MAAM;AAAA,EAAhC;AAAA;AACL,gBAAO;AAAA;AACT;AAKO,IAAM,0BAAN,cAAsC,YAAY;AAAA,EAGvD,cAAc;AACZ,UAAM,sBAAsB;AAH9B,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,wBAAN,cAAoC,YAAY;AAAA,EAGrD,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AAHf,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,iCAAN,cAA6C,YAAY;AAAA,EAG9D,YAAY,SAAiB;AAC3B,UAAM,iCAAiC,OAAO,EAAE;AAHlD,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A,EACvB;AACF;;;ACvCA,IAAAA,+BAAwC;","names":["import_aleo_wallet_standard"]}
|
package/dist/index.mjs
CHANGED
|
@@ -247,6 +247,38 @@ var BaseAleoWalletAdapter = class extends EventEmitter {
|
|
|
247
247
|
return feature.executeDeployment(deployment);
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
|
+
function scopePollingDetectionStrategy(detect) {
|
|
251
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
252
|
+
const disposers = [];
|
|
253
|
+
function detectAndDispose() {
|
|
254
|
+
const detected = detect();
|
|
255
|
+
if (detected) {
|
|
256
|
+
for (const dispose of disposers) {
|
|
257
|
+
dispose();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const interval = (
|
|
262
|
+
// TODO: #334 Replace with idle callback strategy.
|
|
263
|
+
setInterval(detectAndDispose, 1e3)
|
|
264
|
+
);
|
|
265
|
+
disposers.push(() => clearInterval(interval));
|
|
266
|
+
if (
|
|
267
|
+
// Implies that `DOMContentLoaded` has not yet fired.
|
|
268
|
+
document.readyState === "loading"
|
|
269
|
+
) {
|
|
270
|
+
document.addEventListener("DOMContentLoaded", detectAndDispose, { once: true });
|
|
271
|
+
disposers.push(() => document.removeEventListener("DOMContentLoaded", detectAndDispose));
|
|
272
|
+
}
|
|
273
|
+
if (
|
|
274
|
+
// If the `complete` state has been reached, we're too late.
|
|
275
|
+
document.readyState !== "complete"
|
|
276
|
+
) {
|
|
277
|
+
window.addEventListener("load", detectAndDispose, { once: true });
|
|
278
|
+
disposers.push(() => window.removeEventListener("load", detectAndDispose));
|
|
279
|
+
}
|
|
280
|
+
detectAndDispose();
|
|
281
|
+
}
|
|
250
282
|
|
|
251
283
|
// src/account.ts
|
|
252
284
|
function getShortAddress(address, prefixLength = 4, suffixLength = 4) {
|
|
@@ -289,6 +321,7 @@ export {
|
|
|
289
321
|
WalletTransactionRejectedError,
|
|
290
322
|
WalletTransactionTimeoutError,
|
|
291
323
|
createAccount,
|
|
292
|
-
getShortAddress
|
|
324
|
+
getShortAddress,
|
|
325
|
+
scopePollingDetectionStrategy
|
|
293
326
|
};
|
|
294
327
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter.ts","../src/errors.ts","../src/account.ts","../src/types.ts"],"sourcesContent":["import {\n Account,\n Network,\n TransactionOptions,\n TransactionStatusResponse,\n} from '@provablehq/aleo-types';\nimport {\n AleoChain,\n StandardWallet,\n WalletAdapter,\n WalletFeatureName,\n WalletReadyState,\n EventEmitter,\n WalletEvents,\n WalletName,\n WalletDecryptPermission,\n AleoDeployment,\n} from '@provablehq/aleo-wallet-standard';\nimport { WalletFeatureNotAvailableError, WalletNotConnectedError } from './errors';\nimport { WalletConnectionError } from './errors';\n\n/**\n * Base class for Aleo wallet adapters\n */\nexport abstract class BaseAleoWalletAdapter\n extends EventEmitter<WalletEvents>\n implements WalletAdapter\n{\n /**\n * The wallet name\n */\n abstract name: WalletName<string>;\n\n /**\n * The wallet URL\n */\n abstract url?: string;\n\n /**\n * The wallet icon\n */\n abstract icon?: string;\n\n /**\n * The wallet's ready state\n */\n abstract _readyState: WalletReadyState;\n get readyState(): WalletReadyState {\n return this._readyState;\n }\n protected set readyState(state: WalletReadyState) {\n if (state !== this._readyState) {\n this._readyState = state;\n this.emit('readyStateChange', state);\n }\n }\n\n /**\n * The connected account, if any\n */\n account?: Account;\n\n /**\n * The wallet's network\n */\n abstract network: Network;\n\n /**\n * The wallet's decrypt permission\n */\n abstract decryptPermission: WalletDecryptPermission;\n\n /**\n * The wallet's standard interface, if available\n */\n protected _wallet?: StandardWallet;\n\n /**\n * The supported chains\n */\n get chains(): AleoChain[] {\n return this._wallet?.features[WalletFeatureName.CHAINS]?.chains || [];\n }\n\n /**\n * The wallet's connected state\n */\n get connected(): boolean {\n return !!this.account;\n }\n\n /**\n * Connect to the wallet\n * @param network The network to connect to\n * @param decryptPermission The decrypt permission\n * @param programs The programs to connect to\n * @returns The connected account\n */\n async connect(\n network: Network,\n decryptPermission: WalletDecryptPermission,\n programs?: string[],\n ): Promise<Account> {\n if (!this._wallet) {\n throw new WalletConnectionError('No wallet provider found');\n }\n const feature = this._wallet.features[WalletFeatureName.CONNECT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.CONNECT);\n }\n try {\n const account = await feature.connect(network, decryptPermission, programs);\n this.account = account;\n this.emit('connect', account);\n return account;\n } catch (err) {\n this.emit('error', err as Error);\n throw err;\n }\n }\n\n /**\n * Disconnect from the wallet\n */\n async disconnect(): Promise<void> {\n if (!this._wallet) return;\n const feature = this._wallet.features[WalletFeatureName.CONNECT];\n if (feature && feature.available) {\n try {\n await feature.disconnect();\n } catch (err) {\n this.emit('error', err as Error);\n }\n }\n this.account = undefined;\n this.emit('disconnect');\n }\n\n /**\n * Sign a message\n * @param options Transaction options\n * @returns The signed transaction\n */\n async signMessage(message: Uint8Array): Promise<Uint8Array> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.SIGN];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.SIGN);\n }\n return feature.signMessage(message);\n }\n\n /**\n * Execute a transaction\n * @param options Transaction options\n * @returns The executed temporary transaction ID\n */\n async executeTransaction(options: TransactionOptions): Promise<{ transactionId: string }> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.EXECUTE];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.EXECUTE);\n }\n return feature.executeTransaction(options);\n }\n\n /**\n * Get transaction status\n * @param transactionId The transaction ID\n * @returns The transaction status\n */\n async transactionStatus(transactionId: string): Promise<TransactionStatusResponse> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.TRANSACTION_STATUS];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.TRANSACTION_STATUS);\n }\n return feature.transactionStatus(transactionId);\n }\n\n async switchNetwork(network: Network): Promise<void> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.SWITCH_NETWORK];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.SWITCH_NETWORK);\n }\n await feature.switchNetwork(network);\n this.emit('networkChange', network);\n }\n\n async decrypt(\n cipherText: string,\n tpk?: string,\n programId?: string,\n functionName?: string,\n index?: number,\n ): Promise<string> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.DECRYPT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.DECRYPT);\n }\n return feature.decrypt(cipherText, tpk, programId, functionName, index);\n }\n\n async requestRecords(program: string, includePlaintext: boolean): Promise<unknown[]> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.REQUEST_RECORDS];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.REQUEST_RECORDS);\n }\n\n return feature.requestRecords(program, includePlaintext);\n }\n\n async executeDeployment(deployment: AleoDeployment): Promise<{ transactionId: string }> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.EXECUTE_DEPLOYMENT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.EXECUTE_DEPLOYMENT);\n }\n return feature.executeDeployment(deployment);\n }\n}\n","/**\n * Base wallet error\n */\nexport class WalletError extends Error {\n name = 'WalletError';\n}\n\n/**\n * Error thrown when a wallet is not connected\n */\nexport class WalletNotConnectedError extends WalletError {\n name = 'WalletNotConnectedError';\n\n constructor() {\n super('Wallet not connected');\n }\n}\n\n/**\n * Error thrown when the wallet connection is rejected\n */\nexport class WalletConnectionError extends WalletError {\n name = 'WalletConnectionError';\n\n constructor(message = 'Connection to wallet failed') {\n super(message);\n }\n}\n\n/**\n * Error thrown when a required wallet feature is not available\n */\nexport class WalletFeatureNotAvailableError extends WalletError {\n name = 'WalletFeatureNotAvailableError';\n\n constructor(feature: string) {\n super(`Wallet feature not available: ${feature}`);\n }\n}\n\n/**\n * Error thrown when a wallet transaction fails\n */\nexport class WalletTransactionError extends WalletError {\n name = 'WalletTransactionError';\n\n constructor(message = 'Transaction failed') {\n super(message);\n }\n}\n\n/**\n * Error thrown when a user rejects a transaction\n */\nexport class WalletTransactionRejectedError extends WalletTransactionError {\n name = 'WalletTransactionRejectedError';\n\n constructor() {\n super('Transaction rejected by user');\n }\n}\n\n/**\n * Error thrown when a transaction times out\n */\nexport class WalletTransactionTimeoutError extends WalletTransactionError {\n name = 'WalletTransactionTimeoutError';\n\n constructor() {\n super('Transaction timed out');\n }\n}\n\nexport class WalletNotSelectedError extends WalletError {\n name = 'WalletNotSelectedError';\n\n constructor() {\n super('Wallet not selected');\n }\n}\n\nexport class WalletDisconnectionError extends WalletError {\n name = 'WalletDisconnectionError';\n\n constructor(message = 'Disconnection failed') {\n super(message);\n }\n}\n\nexport class WalletSignMessageError extends WalletError {\n name = 'WalletSignMessageError';\n\n constructor(message = 'Failed to sign message') {\n super(message);\n }\n}\n\nexport class WalletSwitchNetworkError extends WalletError {\n name = 'WalletSwitchNetworkError';\n\n constructor(message = 'Failed to switch network') {\n super(message);\n }\n}\n\nexport class WalletNotReadyError extends WalletError {\n name = 'WalletNotReadyError';\n\n constructor() {\n super('Wallet not ready');\n }\n}\n\nexport class WalletDecryptionNotAllowedError extends WalletError {\n name = 'WalletDecryptionNotAllowedError';\n\n constructor() {\n super('Decryption not allowed');\n }\n}\nexport class WalletDecryptionError extends WalletError {\n name = 'WalletDecryptionError';\n\n constructor(message = 'Failed to decrypt') {\n super(message);\n }\n}\n\nexport class MethodNotImplementedError extends WalletError {\n name = 'MethodNotImplementedError';\n\n constructor(method: string) {\n super(`Method not implemented: ${method}`);\n }\n}\n","import { Account, AccountOptions } from '@provablehq/aleo-types';\n\n/**\n * Get the short address representation (for display)\n * @param address The full address\n * @param prefixLength The number of characters to keep at the beginning\n * @param suffixLength The number of characters to keep at the end\n * @returns The short address representation\n */\nexport function getShortAddress(address: string, prefixLength = 4, suffixLength = 4): string {\n if (!address) {\n return '';\n }\n\n if (address.length <= prefixLength + suffixLength) {\n return address;\n }\n\n return `${address.slice(0, prefixLength)}...${address.slice(-suffixLength)}`;\n}\n\n/**\n * Create a new account with the given options\n * @param options Account options\n * @returns The created account\n */\nexport function createAccount(options?: AccountOptions): Account {\n // This is a mock implementation. In a real implementation, you would\n // use the Aleo SDK to create an account.\n const address = `aleo1${Math.random().toString(36).substring(2, 15)}`;\n const viewKey = options?.privateKey\n ? `AViewKey${Math.random().toString(36).substring(2, 15)}`\n : undefined;\n\n return {\n address,\n viewKey,\n privateKey: options?.privateKey,\n };\n}\n","import { WalletDecryptPermission } from '@provablehq/aleo-wallet-standard';\n\nexport { WalletDecryptPermission as DecryptPermission };\n"],"mappings":";AAMA;AAAA,EAIE;AAAA,EAEA;AAAA,OAKK;;;ACdA,IAAM,cAAN,cAA0B,MAAM;AAAA,EAAhC;AAAA;AACL,gBAAO;AAAA;AACT;AAKO,IAAM,0BAAN,cAAsC,YAAY;AAAA,EAGvD,cAAc;AACZ,UAAM,sBAAsB;AAH9B,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,wBAAN,cAAoC,YAAY;AAAA,EAGrD,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AAHf,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,iCAAN,cAA6C,YAAY;AAAA,EAG9D,YAAY,SAAiB;AAC3B,UAAM,iCAAiC,OAAO,EAAE;AAHlD,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,yBAAN,cAAqC,YAAY;AAAA,EAGt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,EACT;AAEA,MAAI,QAAQ,UAAU,eAAe,cAAc;AACjD,WAAO;AAAA,EACT;AAEA,SAAO,GAAG,QAAQ,MAAM,GAAG,YAAY,CAAC,MAAM,QAAQ,MAAM,CAAC,YAAY,CAAC;AAC5E;AAOO,SAAS,cAAc,SAAmC;AAG/D,QAAM,UAAU,QAAQ,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,EAAE,CAAC;AACnE,QAAM,UAAU,SAAS,aACrB,WAAW,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,EAAE,CAAC,KACtD;AAEJ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,YAAY,SAAS;AAAA,EACvB;AACF;;;ACvCA,SAAS,2BAAAA,gCAA+B;","names":["WalletDecryptPermission"]}
|
|
1
|
+
{"version":3,"sources":["../src/adapter.ts","../src/errors.ts","../src/account.ts","../src/types.ts"],"sourcesContent":["import {\n Account,\n Network,\n TransactionOptions,\n TransactionStatusResponse,\n} from '@provablehq/aleo-types';\nimport {\n AleoChain,\n StandardWallet,\n WalletAdapter,\n WalletFeatureName,\n WalletReadyState,\n EventEmitter,\n WalletEvents,\n WalletName,\n WalletDecryptPermission,\n AleoDeployment,\n} from '@provablehq/aleo-wallet-standard';\nimport { WalletFeatureNotAvailableError, WalletNotConnectedError } from './errors';\nimport { WalletConnectionError } from './errors';\n\n/**\n * Base class for Aleo wallet adapters\n */\nexport abstract class BaseAleoWalletAdapter\n extends EventEmitter<WalletEvents>\n implements WalletAdapter\n{\n /**\n * The wallet name\n */\n abstract name: WalletName<string>;\n\n /**\n * The wallet URL\n */\n abstract url?: string;\n\n /**\n * The wallet icon\n */\n abstract icon?: string;\n\n /**\n * The wallet's ready state\n */\n abstract _readyState: WalletReadyState;\n get readyState(): WalletReadyState {\n return this._readyState;\n }\n protected set readyState(state: WalletReadyState) {\n if (state !== this._readyState) {\n this._readyState = state;\n this.emit('readyStateChange', state);\n }\n }\n\n /**\n * The connected account, if any\n */\n account?: Account;\n\n /**\n * The wallet's network\n */\n abstract network: Network;\n\n /**\n * The wallet's decrypt permission\n */\n abstract decryptPermission: WalletDecryptPermission;\n\n /**\n * The wallet's standard interface, if available\n */\n protected _wallet?: StandardWallet;\n\n /**\n * The supported chains\n */\n get chains(): AleoChain[] {\n return this._wallet?.features[WalletFeatureName.CHAINS]?.chains || [];\n }\n\n /**\n * The wallet's connected state\n */\n get connected(): boolean {\n return !!this.account;\n }\n\n /**\n * Connect to the wallet\n * @param network The network to connect to\n * @param decryptPermission The decrypt permission\n * @param programs The programs to connect to\n * @returns The connected account\n */\n async connect(\n network: Network,\n decryptPermission: WalletDecryptPermission,\n programs?: string[],\n ): Promise<Account> {\n if (!this._wallet) {\n throw new WalletConnectionError('No wallet provider found');\n }\n const feature = this._wallet.features[WalletFeatureName.CONNECT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.CONNECT);\n }\n try {\n const account = await feature.connect(network, decryptPermission, programs);\n this.account = account;\n this.emit('connect', account);\n return account;\n } catch (err) {\n this.emit('error', err as Error);\n throw err;\n }\n }\n\n /**\n * Disconnect from the wallet\n */\n async disconnect(): Promise<void> {\n if (!this._wallet) return;\n const feature = this._wallet.features[WalletFeatureName.CONNECT];\n if (feature && feature.available) {\n try {\n await feature.disconnect();\n } catch (err) {\n this.emit('error', err as Error);\n }\n }\n this.account = undefined;\n this.emit('disconnect');\n }\n\n /**\n * Sign a message\n * @param options Transaction options\n * @returns The signed transaction\n */\n async signMessage(message: Uint8Array): Promise<Uint8Array> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.SIGN];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.SIGN);\n }\n return feature.signMessage(message);\n }\n\n /**\n * Execute a transaction\n * @param options Transaction options\n * @returns The executed temporary transaction ID\n */\n async executeTransaction(options: TransactionOptions): Promise<{ transactionId: string }> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.EXECUTE];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.EXECUTE);\n }\n return feature.executeTransaction(options);\n }\n\n /**\n * Get transaction status\n * @param transactionId The transaction ID\n * @returns The transaction status\n */\n async transactionStatus(transactionId: string): Promise<TransactionStatusResponse> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.TRANSACTION_STATUS];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.TRANSACTION_STATUS);\n }\n return feature.transactionStatus(transactionId);\n }\n\n async switchNetwork(network: Network): Promise<void> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.SWITCH_NETWORK];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.SWITCH_NETWORK);\n }\n await feature.switchNetwork(network);\n this.emit('networkChange', network);\n }\n\n async decrypt(\n cipherText: string,\n tpk?: string,\n programId?: string,\n functionName?: string,\n index?: number,\n ): Promise<string> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.DECRYPT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.DECRYPT);\n }\n return feature.decrypt(cipherText, tpk, programId, functionName, index);\n }\n\n async requestRecords(program: string, includePlaintext: boolean): Promise<unknown[]> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.REQUEST_RECORDS];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.REQUEST_RECORDS);\n }\n\n return feature.requestRecords(program, includePlaintext);\n }\n\n async executeDeployment(deployment: AleoDeployment): Promise<{ transactionId: string }> {\n if (!this._wallet || !this.account) {\n throw new WalletNotConnectedError();\n }\n const feature = this._wallet.features[WalletFeatureName.EXECUTE_DEPLOYMENT];\n if (!feature || !feature.available) {\n throw new WalletFeatureNotAvailableError(WalletFeatureName.EXECUTE_DEPLOYMENT);\n }\n return feature.executeDeployment(deployment);\n }\n}\n\nexport function scopePollingDetectionStrategy(detect: () => boolean): void {\n // Early return when server-side rendering\n if (typeof window === 'undefined' || typeof document === 'undefined') return;\n\n const disposers: (() => void)[] = [];\n\n function detectAndDispose() {\n const detected = detect();\n if (detected) {\n for (const dispose of disposers) {\n dispose();\n }\n }\n }\n\n // Strategy #1: Try detecting every second.\n const interval =\n // TODO: #334 Replace with idle callback strategy.\n setInterval(detectAndDispose, 1000);\n disposers.push(() => clearInterval(interval));\n\n // Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.\n if (\n // Implies that `DOMContentLoaded` has not yet fired.\n document.readyState === 'loading'\n ) {\n document.addEventListener('DOMContentLoaded', detectAndDispose, { once: true });\n disposers.push(() => document.removeEventListener('DOMContentLoaded', detectAndDispose));\n }\n\n // Strategy #3: Detect after the `window` has fully loaded.\n if (\n // If the `complete` state has been reached, we're too late.\n document.readyState !== 'complete'\n ) {\n window.addEventListener('load', detectAndDispose, { once: true });\n disposers.push(() => window.removeEventListener('load', detectAndDispose));\n }\n\n // Strategy #4: Detect synchronously, now.\n detectAndDispose();\n}\n","/**\n * Base wallet error\n */\nexport class WalletError extends Error {\n name = 'WalletError';\n}\n\n/**\n * Error thrown when a wallet is not connected\n */\nexport class WalletNotConnectedError extends WalletError {\n name = 'WalletNotConnectedError';\n\n constructor() {\n super('Wallet not connected');\n }\n}\n\n/**\n * Error thrown when the wallet connection is rejected\n */\nexport class WalletConnectionError extends WalletError {\n name = 'WalletConnectionError';\n\n constructor(message = 'Connection to wallet failed') {\n super(message);\n }\n}\n\n/**\n * Error thrown when a required wallet feature is not available\n */\nexport class WalletFeatureNotAvailableError extends WalletError {\n name = 'WalletFeatureNotAvailableError';\n\n constructor(feature: string) {\n super(`Wallet feature not available: ${feature}`);\n }\n}\n\n/**\n * Error thrown when a wallet transaction fails\n */\nexport class WalletTransactionError extends WalletError {\n name = 'WalletTransactionError';\n\n constructor(message = 'Transaction failed') {\n super(message);\n }\n}\n\n/**\n * Error thrown when a user rejects a transaction\n */\nexport class WalletTransactionRejectedError extends WalletTransactionError {\n name = 'WalletTransactionRejectedError';\n\n constructor() {\n super('Transaction rejected by user');\n }\n}\n\n/**\n * Error thrown when a transaction times out\n */\nexport class WalletTransactionTimeoutError extends WalletTransactionError {\n name = 'WalletTransactionTimeoutError';\n\n constructor() {\n super('Transaction timed out');\n }\n}\n\nexport class WalletNotSelectedError extends WalletError {\n name = 'WalletNotSelectedError';\n\n constructor() {\n super('Wallet not selected');\n }\n}\n\nexport class WalletDisconnectionError extends WalletError {\n name = 'WalletDisconnectionError';\n\n constructor(message = 'Disconnection failed') {\n super(message);\n }\n}\n\nexport class WalletSignMessageError extends WalletError {\n name = 'WalletSignMessageError';\n\n constructor(message = 'Failed to sign message') {\n super(message);\n }\n}\n\nexport class WalletSwitchNetworkError extends WalletError {\n name = 'WalletSwitchNetworkError';\n\n constructor(message = 'Failed to switch network') {\n super(message);\n }\n}\n\nexport class WalletNotReadyError extends WalletError {\n name = 'WalletNotReadyError';\n\n constructor() {\n super('Wallet not ready');\n }\n}\n\nexport class WalletDecryptionNotAllowedError extends WalletError {\n name = 'WalletDecryptionNotAllowedError';\n\n constructor() {\n super('Decryption not allowed');\n }\n}\nexport class WalletDecryptionError extends WalletError {\n name = 'WalletDecryptionError';\n\n constructor(message = 'Failed to decrypt') {\n super(message);\n }\n}\n\nexport class MethodNotImplementedError extends WalletError {\n name = 'MethodNotImplementedError';\n\n constructor(method: string) {\n super(`Method not implemented: ${method}`);\n }\n}\n","import { Account, AccountOptions } from '@provablehq/aleo-types';\n\n/**\n * Get the short address representation (for display)\n * @param address The full address\n * @param prefixLength The number of characters to keep at the beginning\n * @param suffixLength The number of characters to keep at the end\n * @returns The short address representation\n */\nexport function getShortAddress(address: string, prefixLength = 4, suffixLength = 4): string {\n if (!address) {\n return '';\n }\n\n if (address.length <= prefixLength + suffixLength) {\n return address;\n }\n\n return `${address.slice(0, prefixLength)}...${address.slice(-suffixLength)}`;\n}\n\n/**\n * Create a new account with the given options\n * @param options Account options\n * @returns The created account\n */\nexport function createAccount(options?: AccountOptions): Account {\n // This is a mock implementation. In a real implementation, you would\n // use the Aleo SDK to create an account.\n const address = `aleo1${Math.random().toString(36).substring(2, 15)}`;\n const viewKey = options?.privateKey\n ? `AViewKey${Math.random().toString(36).substring(2, 15)}`\n : undefined;\n\n return {\n address,\n viewKey,\n privateKey: options?.privateKey,\n };\n}\n","import { WalletDecryptPermission } from '@provablehq/aleo-wallet-standard';\n\nexport { WalletDecryptPermission as DecryptPermission };\n"],"mappings":";AAMA;AAAA,EAIE;AAAA,EAEA;AAAA,OAKK;;;ACdA,IAAM,cAAN,cAA0B,MAAM;AAAA,EAAhC;AAAA;AACL,gBAAO;AAAA;AACT;AAKO,IAAM,0BAAN,cAAsC,YAAY;AAAA,EAGvD,cAAc;AACZ,UAAM,sBAAsB;AAH9B,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,wBAAN,cAAoC,YAAY;AAAA,EAGrD,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AAHf,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,iCAAN,cAA6C,YAAY;AAAA,EAG9D,YAAY,SAAiB;AAC3B,UAAM,iCAAiC,OAAO,EAAE;AAHlD,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,yBAAN,cAAqC,YAAY;AAAA,EAGtD,YAAY,UAAU,sBAAsB;AAC1C,UAAM,OAAO;AAHf,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,iCAAN,cAA6C,uBAAuB;AAAA,EAGzE,cAAc;AACZ,UAAM,8BAA8B;AAHtC,gBAAO;AAAA,EAIP;AACF;AAKO,IAAM,gCAAN,cAA4C,uBAAuB;AAAA,EAGxE,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cAAc,QAAQ,CAAC;AAG5C;AAAA;AAAA,IAEE,SAAS,eAAe;AAAA,IACxB;AACA,aAAS,iBAAiB,oBAAoB,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAC9E,cAAU,KAAK,MAAM,SAAS,oBAAoB,oBAAoB,gBAAgB,CAAC;AAAA,EACzF;AAGA;AAAA;AAAA,IAEE,SAAS,eAAe;AAAA,IACxB;AACA,WAAO,iBAAiB,QAAQ,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAChE,cAAU,KAAK,MAAM,OAAO,oBAAoB,QAAQ,gBAAgB,CAAC;AAAA,EAC3E;AAGA,mBAAiB;AACnB;;;AE/QO,SAAS,gBAAgB,SAAiB,eAAe,GAAG,eAAe,GAAW;AAC3F,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,UAAU,eAAe,cAAc;AACjD,WAAO;AAAA,EACT;AAEA,SAAO,GAAG,QAAQ,MAAM,GAAG,YAAY,CAAC,MAAM,QAAQ,MAAM,CAAC,YAAY,CAAC;AAC5E;AAOO,SAAS,cAAc,SAAmC;AAG/D,QAAM,UAAU,QAAQ,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,EAAE,CAAC;AACnE,QAAM,UAAU,SAAS,aACrB,WAAW,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,EAAE,CAAC,KACtD;AAEJ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,YAAY,SAAS;AAAA,EACvB;AACF;;;ACvCA,SAAS,2BAAAA,gCAA+B;","names":["WalletDecryptPermission"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@provablehq/aleo-wallet-adaptor-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.0",
|
|
4
4
|
"description": "Core wallet adapter logic and utilities",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
],
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@provablehq/aleo-types": "0.
|
|
15
|
-
"@provablehq/aleo-wallet-standard": "0.
|
|
14
|
+
"@provablehq/aleo-types": "0.3.0-alpha.0",
|
|
15
|
+
"@provablehq/aleo-wallet-standard": "0.3.0-alpha.0"
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"clean": "rimraf dist",
|
|
40
40
|
"dev": "tsup --watch",
|
|
41
41
|
"lint": "eslint src/**/*.ts*",
|
|
42
|
-
"test": "jest"
|
|
42
|
+
"test": "jest --passWithNoTests"
|
|
43
43
|
}
|
|
44
44
|
}
|