-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
201 changed files
with
3,774 additions
and
4,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import { EscrowClient } from '@scrow/sdk' | ||
import { print_banner } from '@scrow/test' | ||
|
||
import { config } from './00_demo_config.js' | ||
|
||
const DEMO_MODE = process.env.VERBOSE === 'true' | ||
|
||
/** | ||
* Define our API client. | ||
* Create a new API client using a ClientConfig object. | ||
*/ | ||
|
||
export const client = new EscrowClient(config.client) | ||
|
||
if (DEMO_MODE) { | ||
print_banner('client config') | ||
console.dir(config.client) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { EscrowSigner } from '@scrow/sdk/client' | ||
import { config } from './00_demo_config.js' | ||
import { print_banner } from '@scrow/test' | ||
|
||
import { config } from './00_demo_config.js' | ||
|
||
const DEMO_MODE = process.env.VERBOSE === 'true' | ||
|
||
/** | ||
* Utility method for creating a list of | ||
* signers from a list of strings. | ||
* Create a list of signing devices to use. | ||
*/ | ||
function create_signer (alias : string) { | ||
// Return an escrow signer. | ||
export const signers = config.members.map(alias => { | ||
return EscrowSigner.import(config.client).from_phrase(alias) | ||
} | ||
}) | ||
|
||
/** | ||
* Define our list of signers. | ||
*/ | ||
export const signers = config.members.map(e => create_signer(e)) | ||
if (DEMO_MODE) { | ||
print_banner('signing members') | ||
console.log(config.members) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
import CVM from '@scrow/sdk/cvm' | ||
import { print_banner } from '@scrow/test' | ||
import { config } from './00_demo_config.js' | ||
|
||
import { client } from './01_create_client.js' | ||
import { publish_req } from './04_finish_proposal.js' | ||
|
||
const DEMO_MODE = process.env.VERBOSE === 'true' | ||
|
||
// Unpack the default script engine and server policy. | ||
const { engine, policy } = config | ||
// Deliver proposal and endorsements to server. | ||
const res = await client.contract.create(engine, policy, publish_req) | ||
// Check if response is valid. | ||
/** | ||
* We will need to pass in a reference to the scripting engine | ||
* defined in the proposal, so that it can verify the terms set | ||
* for each program. | ||
*/ | ||
const engine = CVM | ||
|
||
/** | ||
* Request to create a new contract on the escrow server. | ||
*/ | ||
const res = await client.contract.create(publish_req, engine) | ||
// Check the server response is valid. | ||
if (!res.ok) throw new Error(res.error) | ||
|
||
/** | ||
* Define our published contract. | ||
* The server will respond with a new contract. This contract | ||
* will be published under a contract id (cid), which can be | ||
* referenced for reading and funding. | ||
*/ | ||
export const new_contract = res.data.contract | ||
const new_contract = res.data.contract | ||
|
||
if (DEMO_MODE) { | ||
print_banner('new contract') | ||
console.dir(new_contract, { depth : null }) | ||
} | ||
|
||
export { new_contract } |
Oops, something went wrong.