Skip to content

Commit

Permalink
first functional commit v0.1
Browse files Browse the repository at this point in the history
an early functional commit with a few loose ends

run with, make run-datastore
  • Loading branch information
soetop committed Oct 28, 2021
1 parent a0f8f70 commit 1893d63
Show file tree
Hide file tree
Showing 12 changed files with 1,687 additions and 91 deletions.
3 changes: 2 additions & 1 deletion controller/embeds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ func TestEmbedsHandler_ServeHTTP(t *testing.T) {
}

accounts := make([]*model.InternalAccount, 0)
cons := make([]*model.Contract, 0)
deltas := make([]delta.Delta, 0)
ttpls := make([]*model.TransactionTemplate, 0)
stpls := make([]*model.ScriptTemplate, 0)

internalProj.UserID = user.ID

projErr := store.CreateProject(internalProj, deltas, accounts, ttpls, stpls)
projErr := store.CreateProject(internalProj, deltas, accounts, cons, ttpls, stpls)
require.NoError(t, projErr)

script := `
Expand Down
21 changes: 20 additions & 1 deletion controller/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ func (p *Projects) Create(user *model.User, input model.NewProject) (*model.Inte
return nil, err
}

cons := make([]*model.Contract, len(input.Contracts))

for i, con := range input.Contracts {

con := &model.Contract{
ProjectChildID: model.ProjectChildID{
ID: uuid.New(),
ProjectID: proj.ID,
},
// local account index is swapped with actual account id
AccountID: accounts[con.Index].ID,
Title: con.Title,
Script: con.Script,
Index: con.Index,
}

cons[i] = con
}

ttpls := make([]*model.TransactionTemplate, len(input.TransactionTemplates))

for i, tpl := range input.TransactionTemplates {
Expand Down Expand Up @@ -104,7 +123,7 @@ func (p *Projects) Create(user *model.User, input model.NewProject) (*model.Inte

proj.UserID = user.ID

err = p.store.CreateProject(proj, deltas, accounts, ttpls, stpls)
err = p.store.CreateProject(proj, deltas, accounts, cons, ttpls, stpls)
if err != nil {
return nil, errors.Wrap(err, "failed to create project")
}
Expand Down
Loading

0 comments on commit 1893d63

Please sign in to comment.