#!/usr/bin/env -S fift -s "TonUtil.fif" include { ."usage: " @' $0 type ." [-B ] []" cr ."Creates a request to shared wallet created by wallet-create.fif, with private key loaded from file .pk " ."and address from .addr, and saves it into .boc ('wallet-query.boc' by default)" cr 1 halt } : usage def? $8 { @' $7 "-B" $= { @' $8 =: body-boc-file [forget] $8 def? $9 { @' $9 =: $7 [forget] $9 } { [forget] $7 } cond @' $# 2- =: $# } if } if $# 6 < $# 9 > or ' usage if true constant bounce $1 =: file-base $2 =: key $3 parse-int =: key-id $4 bounce parse-load-address =: bounce 2=: dest_addr $5 parse-int =: seqno $6 $>GR =: amount def? $7 { @' $7 } { "wallet-query" } cond constant savefile 3 constant send-mode // mode for SENDRAWMSG: +1 - sender pays fees, +2 - ignore errors 3 86400 * constant timeout // external message expires in 3 days file-base +".addr" load-address 2dup 2constant wallet-addr ."Source wallet address = " 2dup .addr cr 6 .Addr cr key +".pk" load-keypair nip constant wallet_pk def? body-boc-file { @' body-boc-file file>B B>boc } { } cond constant body-cell ."Transferring " amount .GR ."to account " dest_addr 2dup bounce 7 + .Addr ." = " .addr ."seqno=0x" seqno x. ."bounce=" bounce . cr ."Body of transfer message is " body-cell // create wrapper message // modeMessage$0 mode:uint8 body:^(Message X) = ModeMessage X; // wrappedMessage$_ expires_at:uint32 seqno:uint32 body:(ModeMessage X) = WrappedMessage X; dup ."signing message: " u@+ swap 256 B>u@ swap // key ID => signature // multiSigWrapper$0 signatures:(HashmapE 4 Signature) message:(WrappedMessage X) = MultiSigWrapper X; // // addr_none$00 = MsgAddressExt; // addr_extern$01 len:(## 9) external_address:(bits len) // = MsgAddressExt; // anycast_info$_ depth:(#<= 30) { depth >= 1 } // rewrite_pfx:(bits depth) = Anycast; // addr_std$10 anycast:(Maybe Anycast) // workchain_id:int8 address:bits256 = MsgAddressInt; // addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9) // workchain_id:int32 address:(bits addr_len) = MsgAddressInt; // // ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt // import_fee:Grams = CommonMsgInfo; // // // message$_ {X:Type} info:CommonMsgInfo // init:(Maybe (Either StateInit ^StateInit)) // body:(Either X ^X) = Message X; // dup ."resulting external message: " B dup Bx. cr savefile +".boc" tuck B>file ."Query expires in " timeout . ."seconds" cr ."(Saved to file " type .")" cr