mirror of
https://github.com/danog/ton.git
synced 2024-11-26 20:14:55 +01:00
49 lines
1.6 KiB
Plaintext
49 lines
1.6 KiB
Plaintext
#!/usr/bin/fift -s
|
|
"TonUtil.fif" include
|
|
|
|
{ ."usage: " @' $0 type ." <filename-base> <seqno> <index> <new-value-boc> [<savefile>]" cr
|
|
."Creates a request to simple configuration smart contract created by mc0.fif requesting to change configuration parameter <index> to <new-value-boc>, "
|
|
."with private key loaded from file <filename-base>.pk, "
|
|
."and saves it into <savefile>.boc ('config-query.boc' by default)" cr 1 halt
|
|
} : usage
|
|
def? $# { @' $# dup 4 < swap 5 > or ' usage if } if
|
|
|
|
"config-master" constant file-base
|
|
0 constant seqno
|
|
-1 constant idx
|
|
true constant bounce
|
|
"new-value.boc" constant boc-filename
|
|
100 constant interval // valid for 100 seconds
|
|
|
|
def? $4 {
|
|
@' $1 =: file-base
|
|
@' $2 parse-int =: seqno
|
|
@' $3 parse-int =: idx
|
|
@' $4 =: boc-filename
|
|
} if
|
|
def? $5 { @' $5 } { "config-query" } cond constant savefile
|
|
|
|
file-base +".addr" load-address
|
|
2dup 2constant config_addr
|
|
."Configuration smart contract address = " 2dup .addr cr 6 .Addr cr
|
|
file-base +".pk" load-keypair nip constant config_pk
|
|
|
|
."Loading new value of configuration parameter " idx . ."from file " boc-filename type cr
|
|
boc-filename file>B B>boc
|
|
dup <s csr. cr
|
|
|
|
{ 2drop true } : is-valid-config?
|
|
|
|
dup idx is-valid-config? not abort"not a valid value for chosen configuration parameter"
|
|
|
|
// create a message
|
|
<b x{43665021} s, seqno 32 u, now interval + 32 u, idx 32 i, swap ref, b>
|
|
dup ."signing message: " <s csr. cr
|
|
dup hash config_pk ed25519_sign_uint
|
|
<b b{1000100} s, config_addr addr, 0 Gram, b{00} s,
|
|
swap B, swap <s s, b>
|
|
dup ."resulting external message: " <s csr. cr
|
|
2 boc+>B dup Bx. cr
|
|
savefile +".boc" tuck B>file
|
|
."(Saved to file " type .")" cr
|