-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): deploy api handler to cosmic-swingset
- Loading branch information
1 parent
b2f7d99
commit a778018
Showing
7 changed files
with
34 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
## Getting Started | ||
|
||
```sh | ||
npm install -g agoric | ||
agoric init dapp | ||
cd dapp | ||
agoric install | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,7 +1,12 @@ | ||
// Agoric Dapp api deployment script | ||
export default async function deployApi(homeP, { bundleSource }) { | ||
import fs from 'fs'; | ||
import harden from '@agoric/harden'; | ||
|
||
export default async function deployApi(homeP, { bundleSource, pathResolve }) { | ||
const { source, moduleFormat } = await bundleSource('./handler.js'); | ||
const handlerInstall = homeP~.spawner~.install(source, moduleFormat); | ||
handlerInstall~.spawn(homeP); | ||
homeP~.registerCommandHandler(handler); | ||
const cjson = await fs.promises.readFile(pathResolve('./contracts.json')); | ||
const contracts = JSON.parse(cjson); | ||
const handler = handlerInstall~.spawn(harden({ contracts })); | ||
await homeP~.http~.registerCommandHandler(handler); | ||
} |
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,19 @@ | ||
import harden from '@agoric/harden'; | ||
|
||
export default harden((terms, _inviteMaker) => { | ||
const {contracts} = terms; | ||
return harden({ | ||
getCommandHandler() { | ||
return harden({ | ||
processInbound(obj, home) { | ||
switch (obj.type) { | ||
case '@DIR@Message': { | ||
return harden({type: '@DIR@Response', orig: obj, contracts}); | ||
} | ||
} | ||
return undefined; | ||
}, | ||
}); | ||
} | ||
}); | ||
}); |
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