Skip to content

Commit 80f3635

Browse files
authored
feat: aleo nexus support (#7822)
1 parent a7bc6be commit 80f3635

17 files changed

Lines changed: 880 additions & 280 deletions

File tree

.changeset/ninety-rivers-shave.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@hyperlane-xyz/aleo-sdk': major
3+
'@hyperlane-xyz/widgets': major
4+
'@hyperlane-xyz/sdk': major
5+
---
6+
7+
feat: aleo nexus ui support

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"patchedDependencies": {
6060
"typechain@8.3.2": "patches/typechain@8.3.2.patch",
6161
"node-fetch@2.7.0": "patches/node-fetch@2.7.0.patch",
62-
"@provablehq/sdk@0.9.14": "patches/@provablehq__sdk@0.9.14.patch",
6362
"bigint-buffer@1.1.5": "patches/bigint-buffer@1.1.5.patch",
6463
"node-fetch@3.3.2": "patches/node-fetch@3.3.2.patch"
6564
}

patches/@provablehq__sdk@0.9.14.patch

Lines changed: 0 additions & 246 deletions
This file was deleted.

pnpm-lock.yaml

Lines changed: 68 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/aleo-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"dependencies": {
5959
"@hyperlane-xyz/provider-sdk": "workspace:*",
6060
"@hyperlane-xyz/utils": "workspace:*",
61-
"@provablehq/sdk": "0.9.14",
61+
"@provablehq/sdk": "0.9.15",
6262
"bignumber.js": "catalog:",
6363
"unzipper": "^0.12.3"
6464
},

typescript/aleo-sdk/src/clients/provider.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ import {
5454

5555
import { AleoBase } from './base.js';
5656

57+
interface TransactionFeeCache {
58+
[key: string]: {
59+
fee: bigint;
60+
};
61+
}
62+
5763
export class AleoProvider extends AleoBase implements AltVM.IProvider {
64+
private transactionFeeCache: TransactionFeeCache = {};
65+
5866
static async connect(
5967
rpcUrls: string[],
6068
chainId: string | number,
@@ -139,12 +147,27 @@ export class AleoProvider extends AleoBase implements AltVM.IProvider {
139147
async estimateTransactionFee(
140148
req: AltVM.ReqEstimateTransactionFee<AleoTransaction>,
141149
): Promise<AltVM.ResEstimateTransactionFee> {
150+
const cacheKey = `${req.transaction.programName}:${req.transaction.functionName}`;
151+
152+
const cached = this.transactionFeeCache[cacheKey];
153+
if (cached) {
154+
return {
155+
fee: cached.fee,
156+
gasUnits: 0n,
157+
gasPrice: 0,
158+
};
159+
}
160+
142161
const programManager = this.getProgramManager();
143162
const fee = await programManager.estimateExecutionFee({
144163
programName: req.transaction.programName,
145164
functionName: req.transaction.functionName,
146165
});
147166

167+
this.transactionFeeCache[cacheKey] = {
168+
fee,
169+
};
170+
148171
return {
149172
fee,
150173
gasUnits: 0n,

typescript/sdk/src/core/MultiProtocolCore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { MultiProtocolProvider } from '../providers/MultiProtocolProvider.js';
55
import { TypedTransactionReceipt } from '../providers/ProviderType.js';
66
import { ChainMap, ChainName } from '../types.js';
77

8+
import { AleoCoreAdapter } from './adapters/AleoCoreAdapter.js';
89
import { CosmNativeCoreAdapter } from './adapters/CosmNativeCoreAdapter.js';
910
import { CosmWasmCoreAdapter } from './adapters/CosmWasmCoreAdapter.js';
1011
import { EvmCoreAdapter } from './adapters/EvmCoreAdapter.js';
@@ -45,6 +46,7 @@ export class MultiProtocolCore extends MultiProtocolApp<
4546
if (protocol === ProtocolType.CosmosNative) return CosmNativeCoreAdapter;
4647
if (protocol === ProtocolType.Starknet) return StarknetCoreAdapter;
4748
if (protocol === ProtocolType.Radix) return RadixCoreAdapter;
49+
if (protocol === ProtocolType.Aleo) return AleoCoreAdapter;
4850
throw new Error(`No adapter for protocol ${protocol}`);
4951
}
5052

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { Address, HexString, assert, pollAsync } from '@hyperlane-xyz/utils';
2+
3+
import { BaseAleoAdapter } from '../../app/MultiProtocolApp.js';
4+
import { MultiProtocolProvider } from '../../providers/MultiProtocolProvider.js';
5+
import {
6+
ProviderType,
7+
TypedTransactionReceipt,
8+
} from '../../providers/ProviderType.js';
9+
import { ChainName } from '../../types.js';
10+
11+
import { ICoreAdapter } from './types.js';
12+
13+
export class AleoCoreAdapter extends BaseAleoAdapter implements ICoreAdapter {
14+
constructor(
15+
public readonly chainName: ChainName,
16+
public readonly multiProvider: MultiProtocolProvider<any>,
17+
public readonly addresses: { mailbox: Address },
18+
) {
19+
super(chainName, multiProvider, addresses);
20+
}
21+
22+
extractMessageIds(
23+
sourceTx: TypedTransactionReceipt,
24+
): Array<{ messageId: string; destination: ChainName }> {
25+
assert(
26+
sourceTx.type === ProviderType.Aleo,
27+
`Unsupported provider type for AleoCoreAdapter ${sourceTx.type}`,
28+
);
29+
30+
return [];
31+
}
32+
33+
async waitForMessageProcessed(
34+
messageId: HexString,
35+
destination: ChainName,
36+
delayMs?: number,
37+
maxAttempts?: number,
38+
): Promise<boolean> {
39+
const provider = this.multiProvider.getAleoProvider(destination);
40+
41+
await pollAsync(
42+
async () => {
43+
this.logger.debug(`Checking if message ${messageId} was processed`);
44+
const delivered = await provider.isMessageDelivered({
45+
mailboxAddress: this.addresses.mailbox,
46+
messageId: messageId,
47+
});
48+
49+
assert(delivered, `Message ${messageId} not yet processed`);
50+
51+
this.logger.info(`Message ${messageId} was processed`);
52+
return delivered;
53+
},
54+
delayMs,
55+
maxAttempts,
56+
);
57+
58+
return true;
59+
}
60+
}

typescript/sdk/src/metadata/blockExplorer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export function getExplorerTxUrl(
9797
'proteustestnet',
9898
'radix',
9999
'radixtestnet',
100+
'aleo',
101+
'aleotestnet',
100102
].includes(chainName)
101103
? 'transaction'
102104
: 'tx';

typescript/sdk/src/token/Token.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ import {
2828
TokenStandard,
2929
XERC20_STANDARDS,
3030
} from './TokenStandard.js';
31+
import {
32+
AleoHypCollateralAdapter,
33+
AleoHypNativeAdapter,
34+
AleoHypSyntheticAdapter,
35+
AleoNativeTokenAdapter,
36+
} from './adapters/AleoTokenAdapter.js';
3137
import {
3238
CwHypCollateralAdapter,
3339
CwHypNativeAdapter,
@@ -173,6 +179,10 @@ export class Token implements IToken {
173179
return new RadixNativeTokenAdapter(chainName, multiProvider, {
174180
token: addressOrDenom,
175181
});
182+
} else if (standard === TokenStandard.AleoNative) {
183+
return new AleoNativeTokenAdapter(chainName, multiProvider, {
184+
token: addressOrDenom,
185+
});
176186
} else if (this.isHypToken()) {
177187
return this.getHypAdapter(multiProvider);
178188
} else if (this.isIbcToken()) {
@@ -344,6 +354,18 @@ export class Token implements IToken {
344354
return new RadixHypSyntheticAdapter(chainName, multiProvider, {
345355
token: addressOrDenom,
346356
});
357+
} else if (standard === TokenStandard.AleoHypNative) {
358+
return new AleoHypNativeAdapter(chainName, multiProvider, {
359+
token: addressOrDenom,
360+
});
361+
} else if (standard === TokenStandard.AleoHypCollateral) {
362+
return new AleoHypCollateralAdapter(chainName, multiProvider, {
363+
token: addressOrDenom,
364+
});
365+
} else if (standard === TokenStandard.AleoHypSynthetic) {
366+
return new AleoHypSyntheticAdapter(chainName, multiProvider, {
367+
token: addressOrDenom,
368+
});
347369
} else if (standard === TokenStandard.EvmM0PortalLite) {
348370
assert(
349371
collateralAddressOrDenom,

0 commit comments

Comments
 (0)