-
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
cmd
committed
Feb 10, 2024
1 parent
92e2ce3
commit ce34191
Showing
6 changed files
with
67 additions
and
112 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { EscrowSigner, ProposalTemplate, RoleTemplate, create_policy, create_proposal } from "@/index.js" | ||
import { Buff } from "@cmdcode/buff" | ||
import { config } from "../00_demo_config.js" | ||
import { create_draft } from "@/lib/proposal.js" | ||
|
||
const AGENT_ALIAS : string = 'carol' | ||
const SECRET_PASS : string = 'test_draft4' | ||
|
||
const PROP_TEMPLATE : ProposalTemplate = { | ||
title : 'Basic two-party contract with third-party arbitration.', | ||
duration : 14400, | ||
schedule : [[ 7200, 'close|resolve', '*' ]], | ||
value : 15000, | ||
} | ||
|
||
const PROP_ROLES : RoleTemplate[] = [ | ||
{ | ||
title : 'buyer', | ||
paths : [ | ||
[ 'return', 10000 ] | ||
], | ||
programs : [ | ||
[ 'endorse', 'close', '*', 2 ], | ||
[ 'endorse', 'dispute', '*', 1 ] | ||
] | ||
}, | ||
{ | ||
title : 'seller', | ||
paths : [ | ||
[ 'payout', 10000 ] | ||
], | ||
payment : 2000, | ||
programs : [ | ||
[ 'endorse', 'close', '*', 2 ], | ||
[ 'endorse', 'dispute', '*', 1 ] | ||
] | ||
}, | ||
] | ||
|
||
export const alias = AGENT_ALIAS | ||
// Compute draft id for nostr store. | ||
export const secret_id = Buff.str(SECRET_PASS).digest.hex | ||
// Derive signing device from the user alias. | ||
export const signer = EscrowSigner.import(config).from_phrase(AGENT_ALIAS) | ||
// | ||
export const draft = create_draft({ | ||
proposal : create_proposal({ | ||
...PROP_TEMPLATE, | ||
network : config.network, | ||
moderator : signer.pubkey | ||
}), | ||
roles : PROP_ROLES.map(e => create_policy(e)) | ||
}) |
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