其实就是写一篇给自己打打气的,目前对于list当中的一系列迭代的inter contract invocation还是没能解决。记录一下不需要迭代的简单情况,如何实现吧。
//ligolang.org
//重点就是ProxyApproval 另一个action 纯粹占位,可忽略。
type contract_storage is record
creditor : address;
payamount : nat;
end
type action is
| ProxyApproval
| AddCreditor of (address)
const exectAddress : address =
("KT1DdshqQRd8MSK4P57fyMtjQBuL6fVTpmgP" : address);
type parameter is
| Transfer of (address * address * nat)
| Approve of (address * nat)
function addCreditor (const store : contract_storage ; const creditor : address) : contract_storage is
block {
const logging : contract_storage =
record [
creditor = ("tz1g4Kw2qhYELxeeHc2yiuLtPdovVckYNc6G" : address);
payamount = 1000n;
];
} with store
function proxyApproval (const store : contract_storage) : list(operation) * contract_storage is
block {
const execontract : contract (parameter) =
case (Tezos.get_contract_opt (exectAddress) : option (contract (parameter))) of
Some (contract) -> contract
| None -> (failwith ("Contract not found.") : contract (parameter))
end;
const mock_param : parameter = Approve (store.creditor, store.payamount);
const op : operation = Tezos.transaction (mock_param, 0tez, execontract);
const ops : list (operation) = list [op]
} with (ops,store)
function main (const p : action ; const s : contract_storage) :
(list(operation) * contract_storage) is
case p of
| ProxyApproval -> (proxyApproval(s))
| AddCreditor (n) -> ((nil : list(operation)), addCreditor(s,n))
end
喜大普奔,时隔两天之后,contract interaction within map iteration 解决了。中心思想是list(operation) 这玩意儿必须被返回到最上层,底下才会层层跑过去。
再次翻转,解决个毛线,还是没搞定loop中的inter-contract invocation。最后两个contracts 合并到了一个 再用loop。不开心!!!但是为了比赛交差,还是先给对,再来看做精的问题。