# knos-pay-interface
Fund, top up, refund and read a Knos work order from another Solana program.
`knos_pay` holds a work order's money in escrow and pays it when GitHub signs that the order's terms were met; the
signature is checked on chain by `knos-oidc`. This crate is what a program needs to be the FUNDER of an order by
CPI: a DAO treasury that pays for a merged change, a grants program, a vault. It holds the program ids, the
addresses, the three instructions a funder sends and a reader of the Order account. Its only dependency is
`solana-program`; it carries none of `knos_pay`'s code.
```toml
knos-pay-interface = { git = "https://github.com/drexthealpha/Knos", tag = "v0.3.20" }
```
```rust
use knos_pay_interface as knos;
use solana_program::program::invoke_signed;
// accounts, in this order: treasury (a PDA of this program, a plain system account that holds SOL), the order, its
// token account, the treasury's token account, the mint, knos_pay's ["auth"], the token program, the system
// program, knos_pay's ["pause"]; and the knos_pay program itself somewhere in the transaction.
let f = knos::FundOrder {
repo_id, issue, amount, // which issue of which repository, and what its payees receive
wf_repo: knos::wf_repo_hash("drexthealpha/Knos"), wf_sha, // the workflows whose signed run can pay it, pinned by commit
..Default::default() // merge mode, 14 days of work, no options
};
let ix = knos::fund_order_wallet(&knos::ID, treasury.key, treasury_token.key, mint.key, token_program.key, &f, terms_json);
invoke_signed(&ix, &[treasury.clone(), order.clone(), ov.clone(), treasury_token.clone(), mint.clone(), auth.clone(),
token_program.clone(), system.clone(), pause.clone()], &[&[b"treasury", &[bump]]])?;
let o = knos::Order::read(order.key, order.owner, &order.try_borrow_data()?, &knos::ID).ok_or(ProgramError::InvalidAccountData)?;