#!/usr/bin/fift -s "TonUtil.fif" include "Asm.fif" include "GetOpt.fif" include { show-options-help 1 halt } : usage Basechain =: wc // create smart contract in basechain "new-dns-query.boc" =: savefile 0 =: contract-id variable dns-dict dictnew dns-dict ! begin-options "
[-w] [-r] [-o]" +cr +tab +"Creates a new automatic dns smart contract with 32-bit identifier controlled from wallet with address
" +"and saves it into ('" savefile $+ +"' by default)" disable-digit-options generic-help-setopt "w" "--workchain" { parse-workchain-id =: wc } short-long-option-arg "Selects workchain to create smart contract (" wc (.) $+ +" by default)" option-help "r" "--random-id" { parse-int =: contract-id } short-long-option-arg "Sets 'random' smart contract identifier (" contract-id (.) $+ +" by default)" option-help "o" "--output" { =: savefile } short-long-option-arg "Sets output file for generated initialization message ('" savefile $+ +"' by default)" option-help "h" "--help" { usage } short-long-option "Shows a help message" option-help parse-options $# 6 <> ' usage if 6 :$1..n $1 =: file-base $2 false parse-load-address drop 2=: ctl-addr $3 parse-int dup 0 10000000 in-range? ' usage ifnot =: reg-period $4 $>GR =: reg-price $5 parse-int dup 0< ' usage if =: ng-pb $6 parse-int dup 0< ' usage if =: ng-pc contract-id 32 fits ' usage ifnot { contract-id ?dup { (.) $+ } if } : +contractid ."Creating new automatic DNS smart contract in workchain " wc . ."with random id " contract-id . cr ."Controlling wallet (smart contract) is " ctl-addr 6 .Addr cr ."Subdomain registration period is " reg-period . ."seconds" cr ."Subdomain registration price is " reg-price .GR ."+ " ng-pc . ."per cell + " ng-pb . ."per bit" cr // Create new automatic DNS; source code included from `auto/dns-auto-code.fif` "auto/dns-auto-code.fif" include // code ref, // ctl dns-dict @ dict, dictnew dict, // dom_dict gc reg-period 30 u, reg-price Gram, ng-pc Gram, ng-pb Gram, // stdper ppc ppb 0 64 u, // nhk lhk b> // data null // no libraries // create StateInit dup ."StateInit: " dup ."External message for initialization is " B dup Bx. cr savefile tuck B>file ."(Saved dns smart-contract creating query to file " type .")" cr