@@ -20,8 +20,8 @@ use super::errors::RuntimeErrorType;
20
20
use super :: events:: * ;
21
21
use super :: functions:: crypto:: { pubkey_to_address_v1, pubkey_to_address_v2} ;
22
22
use super :: types:: {
23
- ASCIIData , AssetIdentifier , BlockInfoProperty , BuffData , BurnBlockInfoProperty , CharType ,
24
- FixedFunction , FunctionType , ListData , ListTypeData , OptionalData , PrincipalData ,
23
+ ASCIIData , AssetIdentifier , BlockInfoProperty , BuffData , BurnBlockInfoProperty , CallableData ,
24
+ CharType , FixedFunction , FunctionType , ListData , ListTypeData , OptionalData , PrincipalData ,
25
25
QualifiedContractIdentifier , ResponseData , SequenceData , StacksAddressExtensions ,
26
26
StandardPrincipalData , TraitIdentifier , TupleData , TupleTypeSignature , UTF8Data , BUFF_1 ,
27
27
BUFF_32 , BUFF_33 ,
@@ -1568,29 +1568,39 @@ fn pass_argument_to_wasm(
1568
1568
buffer. push ( Val :: I32 ( written) ) ;
1569
1569
Ok ( ( buffer, offset + written, in_mem_offset + in_mem_written) )
1570
1570
}
1571
- Value :: Principal ( p) => {
1572
- let bytes: Vec < u8 > = match p {
1573
- PrincipalData :: Standard ( StandardPrincipalData ( v, h) ) => {
1574
- std:: iter:: once ( v) . chain ( h. iter ( ) ) . copied ( ) . collect ( )
1575
- }
1576
- PrincipalData :: Contract ( QualifiedContractIdentifier {
1577
- issuer : StandardPrincipalData ( v, h) ,
1578
- name,
1579
- } ) => std:: iter:: once ( v)
1580
- . chain ( h. iter ( ) )
1581
- . chain ( std:: iter:: once ( & name. len ( ) ) )
1582
- . chain ( name. as_bytes ( ) )
1583
- . copied ( )
1584
- . collect ( ) ,
1585
- } ;
1571
+ Value :: Principal ( PrincipalData :: Standard ( StandardPrincipalData ( v, h) ) ) => {
1572
+ let bytes: Vec < u8 > = std:: iter:: once ( v) . chain ( h. iter ( ) ) . copied ( ) . collect ( ) ;
1573
+ let buffer = vec ! [ Val :: I32 ( in_mem_offset) , Val :: I32 ( bytes. len( ) as i32 ) ] ;
1574
+ memory
1575
+ . write ( & mut store, in_mem_offset as usize , & bytes)
1576
+ . map_err ( |e| Error :: Wasm ( WasmError :: UnableToWriteMemory ( e. into ( ) ) ) ) ?;
1577
+ let adjusted_in_mem_offset = in_mem_offset + bytes. len ( ) as i32 ;
1578
+ Ok ( ( buffer, offset, adjusted_in_mem_offset) )
1579
+ }
1580
+ Value :: Principal ( PrincipalData :: Contract ( p) )
1581
+ | Value :: CallableContract ( CallableData {
1582
+ contract_identifier : p,
1583
+ ..
1584
+ } ) => {
1585
+ // Callable types can just ignore the optional trait identifier, and
1586
+ // is handled like a qualified contract
1587
+ let QualifiedContractIdentifier {
1588
+ issuer : StandardPrincipalData ( v, h) ,
1589
+ name,
1590
+ } = p;
1591
+ let bytes: Vec < u8 > = std:: iter:: once ( v)
1592
+ . chain ( h. iter ( ) )
1593
+ . chain ( std:: iter:: once ( & name. len ( ) ) )
1594
+ . chain ( name. as_bytes ( ) )
1595
+ . copied ( )
1596
+ . collect ( ) ;
1586
1597
let buffer = vec ! [ Val :: I32 ( in_mem_offset) , Val :: I32 ( bytes. len( ) as i32 ) ] ;
1587
1598
memory
1588
1599
. write ( & mut store, in_mem_offset as usize , & bytes)
1589
1600
. map_err ( |e| Error :: Wasm ( WasmError :: UnableToWriteMemory ( e. into ( ) ) ) ) ?;
1590
1601
let adjusted_in_mem_offset = in_mem_offset + bytes. len ( ) as i32 ;
1591
1602
Ok ( ( buffer, offset, adjusted_in_mem_offset) )
1592
1603
}
1593
- Value :: CallableContract ( _c) => todo ! ( "Value type not yet implemented: {:?}" , value) ,
1594
1604
Value :: Tuple ( _t) => todo ! ( "Value type not yet implemented: {:?}" , value) ,
1595
1605
}
1596
1606
}
0 commit comments