mirror of
https://github.com/danog/toncontest.git
synced 2024-11-26 20:15:01 +01:00
add
This commit is contained in:
parent
014b675a9f
commit
2bc55abb62
2
lib
2
lib
@ -1 +1 @@
|
|||||||
Subproject commit 38c3e39066a9c3b8a62b2f4cad54df4dc6307360
|
Subproject commit 6ecce5a9dfa307a3d3df3706f0d3f8a4c70ea0d5
|
@ -1,180 +0,0 @@
|
|||||||
// This is just an approximated TL scheme, explaining the message formats used by the multisig wallet.
|
|
||||||
// Multisig wallet constructors
|
|
||||||
|
|
||||||
// 256 bits
|
|
||||||
pubKey$_ k:bits256 = PubKey;
|
|
||||||
|
|
||||||
// 512 bits
|
|
||||||
signature$_ R:bits256 s:bits256 = Signature;
|
|
||||||
|
|
||||||
twoSignatures$_ a:^Signature b:^Signature = TwoSignatures;
|
|
||||||
|
|
||||||
// key ID => signature
|
|
||||||
incomingState$00 signatures:(Either ^Signature TwoSignatures) seqno:uint32 delta:Grams {turn:(seqno % 2)} = Incoming;
|
|
||||||
incomingGrams$01 signature:Signature reallyTransfer:Bit = Incoming;
|
|
||||||
incomingInit$10 = Incoming;
|
|
||||||
//incomingFuture$11 = Incoming;
|
|
||||||
|
|
||||||
// For internal storage
|
|
||||||
state$_ signatures:TwoSignatures seqno:uint32 delta:Grams {turn:(seqno % 2)} = State;
|
|
||||||
|
|
||||||
// Storage
|
|
||||||
storage$_ keyA:PubKey keyB:PubKey amountA:Grams amountB:Grams state:State = Storage X;
|
|
||||||
|
|
||||||
// TON stuff
|
|
||||||
|
|
||||||
unit$_ = Unit;
|
|
||||||
true$_ = True;
|
|
||||||
// EMPTY False;
|
|
||||||
bool_false$0 = Bool;
|
|
||||||
bool_true$1 = Bool;
|
|
||||||
bool_false$0 = BoolFalse;
|
|
||||||
bool_true$1 = BoolTrue;
|
|
||||||
nothing$0 {X:Type} = Maybe X;
|
|
||||||
just$1 {X:Type} value:X = Maybe X;
|
|
||||||
left$0 {X:Type} {Y:Type} value:X = Either X Y;
|
|
||||||
right$1 {X:Type} {Y:Type} value:Y = Either X Y;
|
|
||||||
pair$_ {X:Type} {Y:Type} first:X second:Y = Both X Y;
|
|
||||||
|
|
||||||
bit$_ (## 1) = Bit;
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* FROM hashmap.tlb
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// ordinary Hashmap / HashmapE, with fixed length keys
|
|
||||||
//
|
|
||||||
hm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n)
|
|
||||||
{n = (~m) + l} node:(HashmapNode m X) = Hashmap n X;
|
|
||||||
|
|
||||||
hmn_leaf#_ {X:Type} value:X = HashmapNode 0 X;
|
|
||||||
hmn_fork#_ {n:#} {X:Type} left:^(Hashmap n X)
|
|
||||||
right:^(Hashmap n X) = HashmapNode (n + 1) X;
|
|
||||||
|
|
||||||
hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m;
|
|
||||||
hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m;
|
|
||||||
hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m;
|
|
||||||
|
|
||||||
unary_zero$0 = Unary ~0;
|
|
||||||
unary_succ$1 {n:#} x:(Unary ~n) = Unary ~(n + 1);
|
|
||||||
|
|
||||||
hme_empty$0 {n:#} {X:Type} = HashmapE n X;
|
|
||||||
hme_root$1 {n:#} {X:Type} root:^(Hashmap n X) = HashmapE n X;
|
|
||||||
|
|
||||||
extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32))
|
|
||||||
= ExtraCurrencyCollection;
|
|
||||||
// true#_ = True;
|
|
||||||
_ {n:#} _:(Hashmap n True) = BitstringSet n;
|
|
||||||
|
|
||||||
// HashmapAug, hashmap with an extra value
|
|
||||||
// (augmentation) of type Y at every node
|
|
||||||
//
|
|
||||||
ahm_edge#_ {n:#} {X:Type} {Y:Type} {l:#} {m:#}
|
|
||||||
label:(HmLabel ~l n) {n = (~m) + l}
|
|
||||||
node:(HashmapAugNode m X Y) = HashmapAug n X Y;
|
|
||||||
ahmn_leaf#_ {X:Type} {Y:Type} extra:Y value:X = HashmapAugNode 0 X Y;
|
|
||||||
ahmn_fork#_ {n:#} {X:Type} {Y:Type} left:^(HashmapAug n X Y)
|
|
||||||
right:^(HashmapAug n X Y) extra:Y = HashmapAugNode (n + 1) X Y;
|
|
||||||
|
|
||||||
ahme_empty$0 {n:#} {X:Type} {Y:Type} extra:Y
|
|
||||||
= HashmapAugE n X Y;
|
|
||||||
ahme_root$1 {n:#} {X:Type} {Y:Type} root:^(HashmapAug n X Y)
|
|
||||||
extra:Y = HashmapAugE n X Y;
|
|
||||||
|
|
||||||
// VarHashmap / VarHashmapE, with variable-length keys
|
|
||||||
//
|
|
||||||
vhm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n)
|
|
||||||
{n = (~m) + l} node:(VarHashmapNode m X)
|
|
||||||
= VarHashmap n X;
|
|
||||||
vhmn_leaf$00 {n:#} {X:Type} value:X = VarHashmapNode n X;
|
|
||||||
vhmn_fork$01 {n:#} {X:Type} left:^(VarHashmap n X)
|
|
||||||
right:^(VarHashmap n X) value:(Maybe X)
|
|
||||||
= VarHashmapNode (n + 1) X;
|
|
||||||
vhmn_cont$1 {n:#} {X:Type} branch:Bit child:^(VarHashmap n X)
|
|
||||||
value:X = VarHashmapNode (n + 1) X;
|
|
||||||
|
|
||||||
// nothing$0 {X:Type} = Maybe X;
|
|
||||||
// just$1 {X:Type} value:X = Maybe X;
|
|
||||||
|
|
||||||
vhme_empty$0 {n:#} {X:Type} = VarHashmapE n X;
|
|
||||||
vhme_root$1 {n:#} {X:Type} root:^(VarHashmap n X)
|
|
||||||
= VarHashmapE n X;
|
|
||||||
|
|
||||||
//
|
|
||||||
// PfxHashmap / PfxHashmapE, with variable-length keys
|
|
||||||
// constituting a prefix code
|
|
||||||
//
|
|
||||||
|
|
||||||
phm_edge#_ {n:#} {X:Type} {l:#} {m:#} label:(HmLabel ~l n)
|
|
||||||
{n = (~m) + l} node:(PfxHashmapNode m X)
|
|
||||||
= PfxHashmap n X;
|
|
||||||
|
|
||||||
phmn_leaf$0 {n:#} {X:Type} value:X = PfxHashmapNode n X;
|
|
||||||
phmn_fork$1 {n:#} {X:Type} left:^(PfxHashmap n X)
|
|
||||||
right:^(PfxHashmap n X) = PfxHashmapNode (n + 1) X;
|
|
||||||
|
|
||||||
phme_empty$0 {n:#} {X:Type} = PfxHashmapE n X;
|
|
||||||
phme_root$1 {n:#} {X:Type} root:^(PfxHashmap n X)
|
|
||||||
= PfxHashmapE n X;
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* END hashmap.tlb
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TON messages
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
_ _:MsgAddressInt = MsgAddress;
|
|
||||||
_ _:MsgAddressExt = MsgAddress;
|
|
||||||
//
|
|
||||||
var_uint$_ {n:#} len:(#< n) value:(uint (len * 8))
|
|
||||||
= VarUInteger n;
|
|
||||||
var_int$_ {n:#} len:(#< n) value:(int (len * 8))
|
|
||||||
= VarInteger n;
|
|
||||||
nanograms$_ amount:(VarUInteger 16) = Grams;
|
|
||||||
//
|
|
||||||
extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32))
|
|
||||||
= ExtraCurrencyCollection;
|
|
||||||
currencies$_ grams:Grams other:ExtraCurrencyCollection
|
|
||||||
= CurrencyCollection;
|
|
||||||
//
|
|
||||||
int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
|
||||||
src:MsgAddressInt dest:MsgAddressInt
|
|
||||||
value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
|
||||||
created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
|
||||||
ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
|
|
||||||
import_fee:Grams = CommonMsgInfo;
|
|
||||||
ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt
|
|
||||||
created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
|
||||||
|
|
||||||
|
|
||||||
int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
|
||||||
src:MsgAddress dest:MsgAddressInt
|
|
||||||
value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
|
||||||
created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed;
|
|
||||||
ext_out_msg_info$11 src:MsgAddress dest:MsgAddressExt
|
|
||||||
created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed;
|
|
||||||
|
|
||||||
tick_tock$_ tick:Bool tock:Bool = TickTock;
|
|
||||||
|
|
||||||
_ split_depth:(Maybe (## 5)) special:(Maybe TickTock)
|
|
||||||
code:(Maybe ^Cell) data:(Maybe ^Cell)
|
|
||||||
library:(HashmapE 256 SimpleLib) = StateInit;
|
|
||||||
|
|
||||||
simple_lib$_ public:Bool root:^Cell = SimpleLib;
|
|
||||||
|
|
||||||
// create a message
|
|
||||||
message$_ {X:Type} info:CommonMsgInfo
|
|
||||||
init:(Maybe (Either StateInit ^StateInit))
|
|
||||||
body:(Either X ^X) = Message X;
|
|
||||||
|
|
@ -53,7 +53,9 @@ int udict_has?(cell dict, int key_len, int index) asm(index dict key_len) "DICTU
|
|||||||
;; Throw if multiSigFuture$11
|
;; Throw if multiSigFuture$11
|
||||||
throw_if(32, message~load_uint(1));
|
throw_if(32, message~load_uint(1));
|
||||||
|
|
||||||
;; Return if multiSigInit$10
|
;; Accept and return if multiSigInit$10
|
||||||
|
accept_message();
|
||||||
|
|
||||||
return ();
|
return ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,14 @@ int udict_has?(cell dict, int key_len, int index) asm(index dict key_len) "DICTU
|
|||||||
;; Throw if multiSigFuture$11
|
;; Throw if multiSigFuture$11
|
||||||
throw_if(32, message~load_uint(1));
|
throw_if(32, message~load_uint(1));
|
||||||
|
|
||||||
;; Return if multiSigInit$10
|
;; Accept if multiSigInit$10
|
||||||
|
accept_message();
|
||||||
|
|
||||||
|
slice stored_data = get_data().begin_parse();
|
||||||
|
(int stored_seqno, int min_sigs, var keys, var messages) = (stored_data~load_uint(32), stored_data~load_uint(4), stored_data~load_dict(), stored_data~load_dict());
|
||||||
|
stored_data.end_parse();
|
||||||
|
|
||||||
|
set_data(begin_cell().store_uint(stored_seqno, 32).store_uint(min_sigs, 4).store_dict(keys).store_dict(messages).end_cell());
|
||||||
return ();
|
return ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,4 +233,4 @@ int seqno() method_id {
|
|||||||
|
|
||||||
(int, int) getMagic() method_id {
|
(int, int) getMagic() method_id {
|
||||||
return (420, 69);
|
return (420, 69);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"Asm.fif" include
|
"Asm.fif" include
|
||||||
// automatically generated from `/home/daniil/repos/contest/lib/crypto/smartcont/stdlib.fc` `./wallet-code-update.fc`
|
// automatically generated from `/home/daniil/repos/contest/lib/crypto/smartcont/stdlib.fc` `wallet-code-update.fc`
|
||||||
PROGRAM{
|
PROGRAM{
|
||||||
DECLPROC ~collect_garbage
|
DECLPROC ~collect_garbage
|
||||||
DECLPROC store_db
|
DECLPROC store_db
|
||||||
@ -67,6 +67,23 @@ PROGRAM{
|
|||||||
1 LDU
|
1 LDU
|
||||||
DROP
|
DROP
|
||||||
32 THROWIF
|
32 THROWIF
|
||||||
|
ACCEPT
|
||||||
|
c4 PUSH
|
||||||
|
CTOS
|
||||||
|
32 LDU
|
||||||
|
4 LDU
|
||||||
|
LDDICT
|
||||||
|
LDDICT
|
||||||
|
ENDS
|
||||||
|
NEWC
|
||||||
|
s1 s4 XCHG
|
||||||
|
32 STU
|
||||||
|
s1 s2 XCHG
|
||||||
|
4 STU
|
||||||
|
STDICT
|
||||||
|
STDICT
|
||||||
|
ENDC
|
||||||
|
c4 POP
|
||||||
}>
|
}>
|
||||||
DUP
|
DUP
|
||||||
1 PLDU
|
1 PLDU
|
||||||
|
@ -53,7 +53,14 @@ int udict_has?(cell dict, int key_len, int index) asm(index dict key_len) "DICTU
|
|||||||
;; Throw if multiSigFuture$11
|
;; Throw if multiSigFuture$11
|
||||||
throw_if(32, message~load_uint(1));
|
throw_if(32, message~load_uint(1));
|
||||||
|
|
||||||
;; Return if multiSigInit$10
|
;; Accept if multiSigInit$10
|
||||||
|
accept_message();
|
||||||
|
|
||||||
|
slice stored_data = get_data().begin_parse();
|
||||||
|
(int stored_seqno, int min_sigs, var keys, var messages) = (stored_data~load_uint(32), stored_data~load_uint(4), stored_data~load_dict(), stored_data~load_dict());
|
||||||
|
stored_data.end_parse();
|
||||||
|
|
||||||
|
set_data(begin_cell().store_uint(stored_seqno, 32).store_uint(min_sigs, 4).store_dict(keys).store_dict(messages).end_cell());
|
||||||
return ();
|
return ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"Asm.fif" include
|
"Asm.fif" include
|
||||||
// automatically generated from `/home/daniil/repos/contest/lib/crypto/smartcont/stdlib.fc` `./wallet-code.fc`
|
// automatically generated from `/home/daniil/repos/contest/lib/crypto/smartcont/stdlib.fc` `wallet-code.fc`
|
||||||
PROGRAM{
|
PROGRAM{
|
||||||
DECLPROC ~collect_garbage
|
DECLPROC ~collect_garbage
|
||||||
DECLPROC store_db
|
DECLPROC store_db
|
||||||
@ -66,6 +66,23 @@ PROGRAM{
|
|||||||
1 LDU
|
1 LDU
|
||||||
DROP
|
DROP
|
||||||
32 THROWIF
|
32 THROWIF
|
||||||
|
ACCEPT
|
||||||
|
c4 PUSH
|
||||||
|
CTOS
|
||||||
|
32 LDU
|
||||||
|
4 LDU
|
||||||
|
LDDICT
|
||||||
|
LDDICT
|
||||||
|
ENDS
|
||||||
|
NEWC
|
||||||
|
s1 s4 XCHG
|
||||||
|
32 STU
|
||||||
|
s1 s2 XCHG
|
||||||
|
4 STU
|
||||||
|
STDICT
|
||||||
|
STDICT
|
||||||
|
ENDC
|
||||||
|
c4 POP
|
||||||
}>
|
}>
|
||||||
DUP
|
DUP
|
||||||
1 PLDU
|
1 PLDU
|
||||||
|
Loading…
Reference in New Issue
Block a user