Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.4;
- // Base class for contracts that are used in a doug system.
- contract DougEnabled {
- address DOUG;
- function setDougAddress(address dougAddr) public returns (bool result){
- // Once the doug address is set, don't allow it to be set again, except by the
- // doug contract itself.
- if(DOUG != 0x0 && msg.sender != DOUG){
- return false;
- }
- DOUG = dougAddr;
- return true;
- }
- // Makes it so that Doug is the only contract that may kill it.
- function remove() public {
- if(msg.sender == DOUG){
- selfdestruct(DOUG);
- }
- }
- }
- // The Doug contract.
- contract Doug {
- address owner;
- // This is where we keep all the contracts.
- mapping (bytes32 => address) public contracts;
- modifier onlyOwner { //a modifier to reduce code replication
- if (msg.sender == owner) // this ensures that only the owner can access the function
- _;
- }
- // Constructor
- function Doug() public {
- owner = msg.sender;
- }
- // Add a new contract to Doug. This will overwrite an existing contract.
- function addContract(bytes32 name, address addr) onlyOwner public returns (bool result) {
- DougEnabled de = DougEnabled(addr);
- // Don't add the contract if this does not work.
- if(!de.setDougAddress(address(this))) {
- return false;
- }
- contracts[name] = addr;
- return true;
- }
- // Remove a contract from Doug. We could also selfdestruct if we want to.
- function removeContract(bytes32 name) onlyOwner public returns (bool result) {
- if (contracts[name] == 0x0){
- return false;
- }
- contracts[name] = 0x0;
- return true;
- }
- // Get the address of a contract by the name of the contract
- function getContract(bytes32 name) onlyOwner constant public returns (address addr) {
- return contracts[name];
- }
- function remove() onlyOwner public {
- address lca = contracts["lcapplication"];
- address perms = contracts["perms"];
- address permsdb = contracts["permsdb"];
- address lc = contracts["letterofcredit"];
- address lcdb = contracts["letterofcreditdb"];
- // Remove everything.
- if(lca != 0x0){ DougEnabled(lca).remove(); }
- if(perms != 0x0){ DougEnabled(perms).remove(); }
- if(permsdb != 0x0){ DougEnabled(permsdb).remove(); }
- if(lc != 0x0){ DougEnabled(lc).remove(); }
- if(lcdb != 0x0){ DougEnabled(lcdb).remove(); }
- // Finally, remove doug. Doug will now have all the funds of the other contracts,
- // and when suiciding it will all go to the owner.
- selfdestruct(owner);
- }
- }
- // The LC manager
- contract LCApplication is DougEnabled {
- address owner;
- // Constructor
- function LCApplication() public {
- owner = msg.sender;
- }
- function getContractLetterOfCredit() private returns (address res) {
- return ContractProvider(DOUG).contracts("letterofcredit");
- }
- // Attempt to create a letter of credit.
- function create(bytes32 purchaseOrder, uint price, address accountSeller) payable public returns (bool res) {
- if (msg.value == 0 || purchaseOrder == 0x0 || price == 0 || accountSeller == 0x0 ){
- return false;
- }
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( letterofcredit == 0x0 || perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 1) {
- // If the user sent money, we should return it if we can't deposit.
- if (!msg.sender.send(msg.value)){ throw; }
- return false;
- }
- // Use the interface to call on the bank contract. We pass msg.value along as well.
- bool success = LetterOfCredit(letterofcredit).create.value(msg.value)(purchaseOrder, price, msg.sender, accountSeller);
- // If the transaction failed, return the Ether to the caller.
- if (!success) {
- if (!msg.sender.send(msg.value)){ throw; }
- }
- return success;
- }
- // Attempt to confirm the letter of credit
- function confirm() public returns (bool res) {
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( letterofcredit == 0x0 || perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 3) {
- return false;
- }
- // Use the interface to call on the bank contract.
- bool success = LetterOfCredit(letterofcredit).confirm();
- return success;
- }
- // Attempt to approve the letter of credit
- function approve() public returns (bool res) {
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( letterofcredit == 0x0 || perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 4) {
- return false;
- }
- // Use the interface to call on the bank contract.
- bool success = LetterOfCredit(letterofcredit).approve();
- return success;
- }
- // Attempt to ship the goods
- function ship(bytes32 packingSlip) public returns (bool res) {
- if (packingSlip == 0x0 ){
- return false;
- }
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( letterofcredit == 0x0 || perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 2) {
- return false;
- }
- // Use the interface to call on the bank contract.
- bool success = LetterOfCredit(letterofcredit).ship(packingSlip);
- return success;
- }
- // Attempt to invoice the buyer
- function invoice(bytes32 inv) public returns (bool res) {
- if (inv == 0x0 ){
- return false;
- }
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( letterofcredit == 0x0 || perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 2) {
- return false;
- }
- // Use the interface to call on the bank contract.
- bool success = LetterOfCredit(letterofcredit).invoice(inv);
- return success;
- }
- // Attempt to approve the release
- function approveRelease() public returns (bool res) {
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( letterofcredit == 0x0 || perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 4) {
- return false;
- }
- // Use the interface to call on the bank contract.
- bool success = LetterOfCredit(letterofcredit).approveRelease();
- return success;
- }
- // Attempt to release the funds of the letter of credit to the seller
- function releaseFunds() public returns (bool res) {
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( letterofcredit == 0x0 || perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 3) {
- return false;
- }
- // Use the interface to call on the bank contract.
- bool success = LetterOfCredit(letterofcredit).releaseFunds();
- return success;
- }
- function getPurchaseOrder() public returns (bytes32 po){
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- uint8 permsSender = Permissions(perms).getPermission(msg.sender);
- if ( letterofcredit == 0x0 || perms == 0x0 || permsSender < 1) {
- return 0x0;
- }
- // Use the interface to call on the LetterOfCredit contract.
- bytes32 purchord = LetterOfCredit(letterofcredit).getPurchaseOrder(permsSender);
- return purchord;
- }
- function getPrice() public returns (uint price){
- address letterofcredit = getContractLetterOfCredit();
- address perms = ContractProvider(DOUG).contracts("perms");
- uint8 permsSender = Permissions(perms).getPermission(msg.sender);
- if ( letterofcredit == 0x0 || perms == 0x0 || permsSender < 1) {
- return 0;
- }
- // Use the interface to call on the LetterOfCredit contract.
- uint prc = LetterOfCredit(letterofcredit).getPrice(permsSender);
- return prc;
- }
- // Set the permissions for a given address.
- function setPermission(address addr, uint8 perm) public returns (bool res) {
- if (msg.sender != owner){
- return false;
- }
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 5 ) {
- return false;
- }
- return Permissions(perms).setPermission(addr,perm);
- }
- // Get the permissions for a given address.
- function getPermission(address addr) public returns (uint8 perm) {
- if (msg.sender != owner){
- throw;
- }
- address perms = ContractProvider(DOUG).contracts("perms");
- if ( perms == 0x0 || Permissions(perms).getPermission(msg.sender) != 5 ) {
- throw;
- }
- return Permissions(perms).getPermission(addr);
- }
- }
- // Interface for getting contracts from Doug
- contract ContractProvider {
- function contracts(bytes32 name) public returns (address addr){}
- }
- // Base class for contracts that only allow the fundmanager to call them.
- // Note that it inherits from DougEnabled
- contract LCApplicationEnabled is DougEnabled {
- // Makes it easier to check that fundmanager is the caller.
- function isLCApplication() public returns (bool res) {
- if(DOUG != 0x0){
- address lca = ContractProvider(DOUG).contracts("lcapplication");
- return msg.sender == lca;
- }
- return false;
- }
- }
- contract LCStateEnabled {
- enum States {
- New,
- Created,
- Confirmed,
- Approved,
- Shipped,
- Invoiced,
- ReleaseApproved,
- Released,
- Completed
- }
- States public state;
- modifier atState(States _state){
- if (state != _state){
- return;
- }
- _;
- }
- // This modifier goes to the next state
- // after the function is done.
- modifier transitionNext(){
- _;
- nextState();
- }
- function nextState() internal {
- state = States(uint(state) + 1);
- }
- event Created();
- event Confirmed();
- event Approved();
- event Shipped();
- event Invoiced();
- event ReleaseApproved();
- event Released();
- }
- contract LCAuthorizationEnabled {
- // Check that the function is called from
- // a certain address
- modifier onlyBy(address _account)
- {
- if(msg.sender != _account){
- return;
- }
- _;
- }
- }
- contract LetterOfCredit is LCApplicationEnabled, LCAuthorizationEnabled {
- function getContractLetterOfCreditDb() private returns (address res) {
- return ContractProvider(DOUG).contracts("letterofcreditdb");
- }
- function create (bytes32 purchaseOrder, uint price, address accountBuyer, address accountSeller) payable public returns (bool res) {
- if (!isLCApplication()){
- return false;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- // If the user sent money, we should return it if we can't deposit.
- if (!msg.sender.send(msg.value)){ throw; }
- return false;
- }
- // Use the interface to call on the letter of credit contract. We pass msg.value along as well.
- bool success = LetterOfCreditDb(letterofcreditdb).create.value(msg.value)(purchaseOrder, price, accountBuyer, accountSeller);
- // If the transaction failed, return the Ether to the caller.
- if (!success) {
- if (!msg.sender.send(msg.value)){ throw; }
- }
- return success;
- }
- function confirm() public returns (bool res) {
- if (!isLCApplication()){
- return false;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- return false;
- }
- // Use the interface to call on the letter of credit contract. We pass msg.value along as well.
- return LetterOfCreditDb(letterofcreditdb).confirm();
- }
- function approve() public returns (bool res) {
- if (!isLCApplication()){
- return false;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- return false;
- }
- // Use the interface to call on the letter of credit contract. We pass msg.value along as well.
- return LetterOfCreditDb(letterofcreditdb).approve();
- }
- function ship(bytes32 packingSlip) public returns (bool res) {
- if (!isLCApplication()){
- return false;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- return false;
- }
- // Use the interface to call on the letter of credit contract. We pass msg.value along as well.
- return LetterOfCreditDb(letterofcreditdb).ship(packingSlip);
- }
- function invoice(bytes32 inv) public returns (bool res) {
- if (!isLCApplication()){
- return false;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- return false;
- }
- // Use the interface to call on the letter of credit contract. We pass msg.value along as well.
- return LetterOfCreditDb(letterofcreditdb).invoice(inv);
- }
- function approveRelease() public returns (bool res) {
- if (!isLCApplication()){
- return false;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- return false;
- }
- // Use the interface to call on the letter of credit contract. We pass msg.value along as well.
- return LetterOfCreditDb(letterofcreditdb).approveRelease();
- }
- function releaseFunds() public returns (bool res) {
- if (!isLCApplication()){
- return false;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- return false;
- }
- // Use the interface to call on the letter of credit contract.
- return LetterOfCreditDb(letterofcreditdb).releaseFunds();
- }
- function getPurchaseOrder(uint8 perms) public returns (bytes32 po) {
- if (!isLCApplication()){
- throw;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- return 0x0;
- }
- return LetterOfCreditDb(letterofcreditdb).getPurchaseOrder(perms);
- }
- function getPrice(uint8 perms) public returns (uint price) {
- if (!isLCApplication()){
- throw;
- }
- address letterofcreditdb = getContractLetterOfCreditDb();
- if ( letterofcreditdb == 0x0 ) {
- return 0x0;
- }
- return LetterOfCreditDb(letterofcreditdb).getPrice(perms);
- }
- function getPackingSlip() public returns (bytes32 po) {
- if (!isLCApplication()){
- throw;
- }
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if ( letterofcredit == 0x0 ) {
- return "";
- }
- return LetterOfCreditDb(letterofcredit).getPackingSlip();
- }
- function getInvoice() public returns (bytes32 po) {
- if (!isLCApplication()){
- throw;
- }
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if ( letterofcredit == 0x0 ) {
- return "";
- }
- return LetterOfCreditDb(letterofcredit).getInvoice();
- }
- }
- contract LetterOfCreditDb is DougEnabled {
- enum States {
- New,
- Created,
- Confirmed,
- Approved,
- Shipped,
- Invoiced,
- ReleaseApproved,
- Released,
- Completed
- }
- States public state;
- modifier atState(States _state){
- if (state != _state){
- return;
- }
- _;
- }
- // This modifier goes to the next state
- // after the function is done.
- modifier transitionNext(){
- _;
- nextState();
- }
- modifier allowReadRequirements(uint perms){
- // advising bank can only view requiremnts after confirmation of issuing bank, so state Confirmed or later
- if (perms == 4 && ( state == States.New || state == States.Created) ){
- return;
- }
- // seller (exporter) can only view requiremnts after approval of advising bank, so state Approved or later
- if (perms == 2 && ( state == States.New || state != States.Created || state != States.Confirmed) ) {
- return;
- }
- _;
- }
- function nextState() internal {
- state = States(uint(state) + 1);
- }
- event Created();
- event Confirmed();
- event Approved();
- event Shipped();
- event Invoiced();
- event ReleaseApproved();
- event Released();
- address public owner;
- address public buyer;
- address public seller;
- uint public balance;
- bytes32 refPurchaseOrder;
- bytes32 refPackingSlip;
- bytes32 refInvoice;
- uint purchasePrice;
- function LetterOfCreditDb () public {
- owner = msg.sender;
- state = States.New;
- }
- function create(bytes32 purchaseOrder, uint price, address accountBuyer, address accountSeller) atState(States.New) payable public returns (bool res ){
- if(DOUG != 0x0){
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if (msg.sender == letterofcredit ){
- buyer = accountBuyer;
- seller = accountSeller;
- balance = msg.value;
- purchasePrice = price;
- refPurchaseOrder = purchaseOrder;
- state = States.Created;
- Created();
- return true;
- }
- }
- // Return if deposit cannot be made.
- if (!msg.sender.send(msg.value)){ throw; }
- return false;
- }
- function confirm() atState(States.Created) public returns (bool res ){
- if(DOUG != 0x0){
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if (msg.sender == letterofcredit ){
- state = States.Confirmed;
- Confirmed();
- return true;
- }
- }
- return false;
- }
- function approve() atState(States.Confirmed) public returns (bool res ){
- if(DOUG != 0x0){
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if (msg.sender == letterofcredit ){
- state = States.Approved;
- Approved();
- return true;
- }
- }
- return false;
- }
- function ship(bytes32 packingSlip) atState(States.Approved) public returns (bool res ){
- if(DOUG != 0x0){
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if (msg.sender == letterofcredit ){
- refPackingSlip = packingSlip;
- state = States.Shipped;
- Shipped();
- return true;
- }
- }
- return false;
- }
- function invoice(bytes32 inv) atState(States.Shipped) public returns (bool res ){
- if(DOUG != 0x0){
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if (msg.sender == letterofcredit ){
- refInvoice = inv;
- state = States.Invoiced;
- Invoiced();
- return true;
- }
- }
- return false;
- }
- function approveRelease() atState(States.Invoiced) public returns (bool res ){
- if(DOUG != 0x0){
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if (msg.sender == letterofcredit ){
- state = States.ReleaseApproved;
- ReleaseApproved();
- return true;
- }
- }
- return false;
- }
- function releaseFunds() atState(States.ReleaseApproved) public payable returns (bool res) {
- // CONDITIONS
- if(DOUG != 0x0){
- address letterofcredit = ContractProvider(DOUG).contracts("letterofcredit");
- if (msg.sender == letterofcredit ){
- uint oldBalance = balance;
- if(oldBalance >= purchasePrice){
- // EFFECTS
- balance = oldBalance - purchasePrice;
- state = States.Released;
- // INTERACTION
- if (!seller.send(purchasePrice)){ throw; }
- if (!buyer.send(balance)){ throw; } // Transfer the possible remaining balance to the buyer
- Released(); // event
- return true;
- }
- }
- }
- return false;
- }
- function getState() constant public returns (States stat) {
- return state;
- }
- function getPurchaseOrder(uint8 perms) allowReadRequirements(perms) constant public returns (bytes32 po) {
- return refPurchaseOrder;
- }
- function getPrice(uint8 perms) allowReadRequirements(perms) constant public returns (uint price) {
- return purchasePrice;
- }
- function getPackingSlip() constant public returns (bytes32 pks) {
- return refPackingSlip;
- }
- function getInvoice() constant public returns (bytes32 inv) {
- return refInvoice;
- }
- }
- // Permissions database
- contract PermissionsDb is DougEnabled {
- mapping (address => uint8) public perms;
- function PermissionsDb() public {
- perms[msg.sender] = 5; // owner gets super permissions
- }
- // Set the permissions of an account.
- function setPermission(address addr, uint8 perm) public returns (bool res) {
- if(DOUG != 0x0){
- address permC = ContractProvider(DOUG).contracts("perms");
- if (msg.sender == permC ){
- perms[addr] = perm;
- return true;
- }
- return false;
- } else {
- return false;
- }
- }
- // Get the permissions of an account.
- function getPermission(address addr) public returns (uint8 res) {
- if(DOUG != 0x0){
- address permC = ContractProvider(DOUG).contracts("perms");
- if (msg.sender == permC ){
- return perms[addr];
- }
- throw;
- } else {
- throw;
- }
- }
- }
- // Permissions
- contract Permissions is LCApplicationEnabled {
- // Set the permissions of an account.
- function setPermission(address addr, uint8 perm) public returns (bool res) {
- if (!isLCApplication()){
- return false;
- }
- address permdb = ContractProvider(DOUG).contracts("permsdb");
- if ( permdb == 0x0 ) {
- return false;
- }
- return PermissionsDb(permdb).setPermission(addr, perm);
- }
- // Set the permissions of an account.
- function getPermission(address addr) public returns (uint8 res) {
- if (!isLCApplication()){
- throw;
- }
- address permdb = ContractProvider(DOUG).contracts("permsdb");
- if ( permdb == 0x0 ) {
- throw;
- }
- return PermissionsDb(permdb).getPermission(addr);
- }
- }
- jobs:
- - name: addrSuperAccount
- job:
- set:
- val: F1925F5F1FAECA776B1340015F38C88008DE3089
- - name: addrBuyer
- job:
- set:
- val: 0ABD37F8D497A2264AAB0DC4A1A58DBA7115F916
- - name: addrSeller
- job:
- set:
- val: DA3C76F15BD6902072FA92B869F45F38AF5F92F1
- - name: addrIssuingBank
- job:
- set:
- val: 096957107AD460D9703FDA86CD14B4C1FB22A10E
- - name: addrAdvisingBank
- job:
- set:
- val: D6EEBF4818185C65544EB0FE2839607400589D06
- - name: deployDoug
- job:
- deploy:
- contract: letterofcredit.sol
- instance: Doug
- - name: deployLetterOfCredit
- job:
- deploy:
- contract: letterofcredit.sol
- instance: LetterOfCredit
- - name: deployLetterOfCreditDb
- job:
- deploy:
- contract: letterofcredit.sol
- instance: LetterOfCreditDb
- - name: deployLCApplication
- job:
- deploy:
- contract: letterofcredit.sol
- instance: LCApplication
- - name: deployPermissions
- job:
- deploy:
- contract: letterofcredit.sol
- instance: Permissions
- - name: deployPermissionsDb
- job:
- deploy:
- contract: letterofcredit.sol
- instance: PermissionsDb
- - name: callSetDougLetterOfCredit
- job:
- call:
- destination: $deployLetterOfCredit
- function: setDougAddress
- data:
- - $deployDoug
- - name: callSetDougLetterOfCreditDb
- job:
- call:
- destination: $deployLetterOfCreditDb
- function: setDougAddress
- data:
- - $deployDoug
- - name: callSetDougLCApplication
- job:
- call:
- destination: $deployLCApplication
- function: setDougAddress
- data:
- - $deployDoug
- - name: callAddContractLetterOfCredit
- job:
- call:
- destination: $deployDoug
- function: addContract
- data:
- - "letterofcredit"
- - $deployLetterOfCredit
- - name: callAddContractLetterOfCreditDb
- job:
- call:
- destination: $deployDoug
- function: addContract
- data:
- - "letterofcreditdb"
- - $deployLetterOfCreditDb
- - name: callAddContractLCApplication
- job:
- call:
- destination: $deployDoug
- function: addContract
- data:
- - "lcapplication"
- - $deployLCApplication
- - name: callAddContractPermissions
- job:
- call:
- destination: $deployDoug
- function: addContract
- data:
- - "perms"
- - $deployPermissions
- - name: callAddContractPermissionsDb
- job:
- call:
- destination: $deployDoug
- function: addContract
- data:
- - "permsdb"
- - $deployPermissionsDb
- - name: callGetContractLetterOfCredit
- job:
- call:
- destination: $deployDoug
- function: getContract
- data:
- - "letterofcredit"
- - name: callGetContractLetterOfCreditDb
- job:
- call:
- destination: $deployDoug
- function: getContract
- data:
- - "letterofcreditdb"
- - name: callGetContractLCApplication
- job:
- call:
- destination: $deployDoug
- function: getContract
- data:
- - "lcapplication"
- - name: callGetContractPermissions
- job:
- call:
- destination: $deployDoug
- function: getContract
- data:
- - "perms"
- - name: callGetContractPermissionsDb
- job:
- call:
- destination: $deployDoug
- function: getContract
- data:
- - "permsdb"
- - name: assertContractLetterOfCredit
- job:
- assert:
- key: $callGetContractLetterOfCredit
- relation: eq
- val: $deployLetterOfCredit
- - name: assertContractLetterOfCreditDb
- job:
- assert:
- key: $callGetContractLetterOfCreditDb
- relation: eq
- val: $deployLetterOfCreditDb
- - name: assertContractLCApplication
- job:
- assert:
- key: $callGetContractLCApplication
- relation: eq
- val: $deployLCApplication
- - name: assertContractPermissions
- job:
- assert:
- key: $callGetContractPermissions
- relation: eq
- val: $deployPermissions
- - name: assertContractPermissionsDb
- job:
- assert:
- key: $callGetContractPermissionsDb
- relation: eq
- val: $deployPermissionsDb
- - name: callGetPermissionSelf
- job:
- call:
- destination: $deployLCApplication
- function: getPermission
- data:
- - $addrSuperAccount
- - name: assertPermissionSelf
- job:
- assert:
- key: $callGetPermissionSelf
- relation: eq
- val: 5
- - name: callSetPermissionBuyer
- job:
- call:
- destination: $deployLCApplication
- function: setPermission
- data:
- - $addrBuyer
- - 1
- - name: callSetPermissionSeller
- job:
- call:
- destination: $deployLCApplication
- function: setPermission
- data:
- - $addrSeller
- - 2
- - name: callSetPermissionIssuingBank
- job:
- call:
- destination: $deployLCApplication
- function: setPermission
- data:
- - $addrIssuingBank
- - 3
- - name: callSetPermissionAdvisingBank
- job:
- call:
- destination: $deployLCApplication
- function: setPermission
- data:
- - $addrAdvisingBank
- - 4
- - name: callGetPermissionBuyer
- job:
- call:
- destination: $deployLCApplication
- function: getPermission
- data:
- - $addrBuyer
- - name: callGetPermissionSeller
- job:
- call:
- destination: $deployLCApplication
- function: getPermission
- data:
- - $addrSeller
- - name: callGetPermissionIssuingBank
- job:
- call:
- destination: $deployLCApplication
- function: getPermission
- data:
- - $addrIssuingBank
- - name: callGetPermissionAdvisingBank
- job:
- call:
- destination: $deployLCApplication
- function: getPermission
- data:
- - $addrAdvisingBank
- - name: assertPermissionBuyer
- job:
- assert:
- key: $callGetPermissionBuyer
- relation: eq
- val: 1
- - name: assertPermissionSeller
- job:
- assert:
- key: $callGetPermissionSeller
- relation: eq
- val: 2
- - name: assertPermissionIssuingBank
- job:
- assert:
- key: $callGetPermissionIssuingBank
- relation: eq
- val: 3
- - name: assertPermissionAdvisingBank
- job:
- assert:
- key: $callGetPermissionAdvisingBank
- relation: eq
- val: 4
- - name: accSuperAccount
- job:
- account:
- address: $addrSuperAccount
- - name: callGetBalance
- job:
- query-account:
- account: $addrSuperAccount
- field: balance
- - name: callCreateLC
- job:
- call:
- destination: $deployLCApplication
- function: create
- address: $addrBuyer
- data:
- - "purchaseorder"
- - 100
- - $addrSeller
- amount: 10000
- - name: callGetBalance
- job:
- query-account:
- account: $addrSuperAccount
- field: balance
- - name: accBuyer
- job:
- account:
- address: $addrBuyer
- - name: callGetBalance
- job:
- query-account:
- account: $addrBuyer
- field: balance
- - name: callCreateLC
- job:
- call:
- destination: $deployLCApplication
- function: create
- address: $addrBuyer
- data:
- - "purchaseorder"
- - 100
- - $addrSeller
- amount: 10000
- - name: callGetBalance
- job:
- query-account:
- account: $addrBuyer
- field: balance
- - name: accAdvisingBank
- job:
- account:
- address: $addrAdvisingBank
- - name: callGetPurchaseOrder
- job:
- call:
- destination: $deployLCApplication
- function: getPurchaseOrder
- - name: accSeller
- job:
- account:
- address: $addrSeller
- - name: callGetPurchaseOrder
- job:
- call:
- destination: $deployLCApplication
- function: getPurchaseOrder
- - name: callConfirm
- job:
- call:
- destination: $deployLCApplication
- function: confirm
- - name: accIssuingBank
- job:
- account:
- address: $addrIssuingBank
- - name: callGetPurchaseOrder
- job:
- call:
- destination: $deployLCApplication
- function: getPurchaseOrder
- - name: callGetPrice
- job:
- call:
- destination: $deployLCApplication
- function: getPrice
- - name: callConfirm
- job:
- call:
- destination: $deployLCApplication
- function: confirm
- - name: callApprove
- job:
- call:
- destination: $deployLCApplication
- function: approve
- - name: accAdvisingBank
- job:
- account:
- address: $addrAdvisingBank
- - name: callGetPurchaseOrder
- job:
- call:
- destination: $deployLCApplication
- function: getPurchaseOrder
- - name: callGetPrice
- job:
- call:
- destination: $deployLCApplication
- function: getPrice
- - name: callApprove
- job:
- call:
- destination: $deployLCApplication
- function: approve
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement