UNPKG

1.27 kBJavaScriptView Raw
1mnemonic = 'match diamond magnet sing bullet enemy two twin gather shuffle prize jeans'
2
3Card = {
4 permissions: "public",
5 meta: {
6 name: "name"
7 },
8 form: ['*'],
9 schema: {
10 title: "Card",
11 type: "object",
12 properties: {
13 name: {
14 title: "Name",
15 type: "string"
16 },
17 category: {
18 title: "Category",
19 type: "string"
20 }
21 },
22 required: [ "name" ]
23 },
24 children: {}
25};
26
27Identity = {
28 permissions: "public",
29 meta: {
30 name: "name",
31 age: "age"
32 },
33 form: ["*"],
34 schema: {
35 title: "Identity Profile",
36 type: "object",
37 properties: {
38 name: {
39 title: "Name",
40 type: "string"
41 },
42 age: {
43 title: "Age",
44 type: "string"
45 }
46 },
47 required: [ "name" ]
48 },
49 children: {
50 card: Card
51 }
52};
53
54youbase = YouBase(window.location.href);
55wallet = youbase.wallet(mnemonic);
56wallet.profiles.definition('identity', Identity).then(function () {
57 console.log('Defined identity', Identity);
58 return wallet.profiles.insert('identity', {name: 'Josh'});
59}).then(function (profile) {
60 window.profile = profile;
61 return profile.children.insert('card', {name: 'Qdoba', category: 'loyalty'});
62}).then(function (card) {
63 window.card = card;
64});
65
66