@@ -2,7 +2,12 @@ import { BigNumber } from 'bignumber.js';
22
33import { AltVM , assert , ensure0x , strip0x } from '@hyperlane-xyz/utils' ;
44
5- import { ALEO_NULL_ADDRESS , formatAddress } from '../utils/helper.js' ;
5+ import {
6+ ALEO_NULL_ADDRESS ,
7+ arrayToPlaintext ,
8+ fillArray ,
9+ formatAddress ,
10+ } from '../utils/helper.js' ;
611import { AleoTransaction } from '../utils/types.js' ;
712
813import { AleoBase } from './base.js' ;
@@ -750,23 +755,21 @@ export class AleoProvider extends AleoBase implements AltVM.IProvider {
750755 throw new Error ( `maximum ${ MAXIMUM_VALIDATORS } validators allowed` ) ;
751756 }
752757
753- const validators = Array ( MAXIMUM_VALIDATORS ) . fill ( {
754- bytes : Array ( 20 ) . fill ( `0u8` ) ,
755- } ) ;
756-
757- req . validators
758- . map ( ( v ) => ( {
758+ const validators = fillArray (
759+ req . validators . map ( ( v ) => ( {
759760 bytes : [ ...Buffer . from ( strip0x ( v ) , 'hex' ) ] . map ( ( b ) => `${ b } u8` ) ,
760- } ) )
761- . forEach ( ( v , i ) => ( validators [ i ] = v ) ) ;
761+ } ) ) ,
762+ MAXIMUM_VALIDATORS ,
763+ Array ( 20 ) . fill ( `0u8` ) ,
764+ ) ;
762765
763766 return {
764767 programName : 'ism_manager.aleo' ,
765768 functionName : 'init_message_id_multisig' ,
766769 priorityFee : 0 ,
767770 privateFee : false ,
768771 inputs : [
769- JSON . stringify ( validators ) . replaceAll ( '"' , '' ) ,
772+ arrayToPlaintext ( validators ) ,
770773 `${ req . validators . length } u8` ,
771774 `${ req . threshold } u8` ,
772775 ] ,
@@ -1026,16 +1029,14 @@ export class AleoProvider extends AleoBase implements AltVM.IProvider {
10261029 ...Buffer . from ( strip0x ( req . remoteRouter . receiverAddress ) , 'hex' ) ,
10271030 ] . map ( ( b ) => `${ b } u8` ) ;
10281031
1029- console . log ( JSON . stringify ( bytes ) . replaceAll ( '"' , '' ) ) ;
1030-
10311032 return {
10321033 programName : req . tokenAddress ,
10331034 functionName : 'enroll_remote_router' ,
10341035 priorityFee : 0 ,
10351036 privateFee : false ,
10361037 inputs : [
10371038 `${ req . remoteRouter . receiverDomainId } u32` ,
1038- JSON . stringify ( bytes ) . replaceAll ( '"' , '' ) ,
1039+ arrayToPlaintext ( bytes ) ,
10391040 `${ req . remoteRouter . gas } u128` ,
10401041 ] ,
10411042 // skipProof: this.skipProof,
@@ -1153,7 +1154,7 @@ export class AleoProvider extends AleoBase implements AltVM.IProvider {
11531154 const hookMetadata = Array ( 256 ) . fill ( `0u8` ) ;
11541155
11551156 if ( req . customHookMetadata ) {
1156- Buffer . from ( req . customHookMetadata , 'hex' ) . forEach ( ( b , i ) => {
1157+ Buffer . from ( strip0x ( req . customHookMetadata ) , 'hex' ) . forEach ( ( b , i ) => {
11571158 hookMetadata [ i ] = `${ b } u8` ;
11581159 } ) ;
11591160 }
@@ -1170,9 +1171,9 @@ export class AleoProvider extends AleoBase implements AltVM.IProvider {
11701171 `${ req . destinationDomainId } u8` ,
11711172 recipient ,
11721173 `${ req . amount } u128` ,
1173- JSON . stringify ( creditAllowance ) . replaceAll ( '"' , '' ) ,
1174+ arrayToPlaintext ( creditAllowance ) ,
11741175 req . customHookAddress ,
1175- JSON . stringify ( hookMetadata ) . replaceAll ( '"' , '' ) ,
1176+ arrayToPlaintext ( hookMetadata ) ,
11761177 ] ,
11771178 // skipProof: this.skipProof,
11781179 } ;
@@ -1190,7 +1191,7 @@ export class AleoProvider extends AleoBase implements AltVM.IProvider {
11901191 `${ req . destinationDomainId } u8` ,
11911192 recipient ,
11921193 `${ req . amount } u128` ,
1193- JSON . stringify ( creditAllowance ) . replaceAll ( '"' , '' ) ,
1194+ arrayToPlaintext ( creditAllowance ) ,
11941195 ] ,
11951196 // skipProof: this.skipProof,
11961197 } ;
0 commit comments