Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thegoldenmule committed Mar 22, 2024
0 parents commit 4cfbb11
Show file tree
Hide file tree
Showing 73 changed files with 35,098 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.DS_Store
node_modules

.env*
!.env.project
!.env.vault

config/local.js
.tmp

*~
*#
.vscode
.node_history
dump.rdb

npm-debug.log
lib-cov
*.seed
*.log
*.out
*.pid
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:20

WORKDIR /app

COPY package.json package-lock.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install

COPY . .

EXPOSE 80
ENTRYPOINT [ "node", "app.js" ]
23 changes: 23 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Gruntfile
*
* This Node script is executed when you run `grunt`-- and also when
* you run `sails lift` (provided the grunt hook is installed and
* hasn't been disabled).
*
* WARNING:
* Unless you know what you're doing, you shouldn't change this file.
* Check out the `tasks/` directory instead.
*
* For more information see:
* https://sailsjs.com/anatomy/Gruntfile.js
*/
module.exports = function(grunt) {

var loadGruntTasks = require('sails-hook-grunt/accessible/load-grunt-tasks');

// Load Grunt task configurations (from `tasks/config/`) and Grunt
// task registrations (from `tasks/register/`).
loadGruntTasks(__dirname, grunt);

};
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright 2024 TBD

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Chain-chomp

![Chomp](chomp.png)
Used under [CC License](https://creativecommons.org/licenses/by-nc-nd/3.0/) from [KarlWarrior47](https://www.deviantart.com/karlwarrior47/art/Just-a-chain-chomp-940153554).

Chain-chomp is an HTTP server for interacting Spyre smart contracts.

## Getting Started

Run locally using either `docker-compose`:

```
docker-compose up
```

or `pnpm`:

```
pnpm install
pnpm run dev
```

## Building

Build a docker image with:

`docker build -t chain-chomp .`
Empty file added api/controllers/.gitkeep
Empty file.
26 changes: 26 additions & 0 deletions api/controllers/v1/check-stake.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {

friendlyName: 'Check Stake',
description: '',

inputs: {
stake: {
type: {},
required: true,
},
sig: {
type: {},
required: true,
},
},

exits: {
//
},

fn: async function ({ stake, sig, }) {
const addr = await Web3Service.stakeSignedCheck({ stake, sig, });

return { success: true, addr, };
},
};
31 changes: 31 additions & 0 deletions api/controllers/v1/find-txns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {

friendlyName: 'Find Txn',

description: 'Finds txns.',

inputs: {
//
},

exits: {
//
},

fn: async function () {
let txns;
try {
txns = await Txn.find({}).limit(10);
} catch (error) {
return {
success: false,
error: error.message,
};
}

return {
success: true,
txns,
};
},
};
38 changes: 38 additions & 0 deletions api/controllers/v1/get-balance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {

friendlyName: 'Get USDC balance.',

description: '',

inputs: {
coin: {
type: 'string',
required: true,
},
addr: {
type: 'string',
required: true,
},
},

exits: {
//
},

fn: async function ({ coin, addr, }) {
let balance;
try {
balance = await Web3Service.getBalance({ coin, addr, });
} catch (err) {
return {
success: false,
error: err.message,
};
}

return {
success: true,
balance: balance.toString(),
};
},
};
36 changes: 36 additions & 0 deletions api/controllers/v1/get-nonce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {

friendlyName: 'Get Nonce',

description: 'Gets the hangman nonce for a wallet.',

inputs: {
addr: {
type: 'string',
required: true,
},
},

exits: {
//
},

fn: async function ({ addr, }) {
let nonce;
try {
nonce = await Web3Service.getNonce({ addr, });
} catch (error) {
Logger.warn('Error getting nonce:', error);

return {
success: false,
error: error.message,
};
}

return {
success: true,
nonce: nonce.toString(),
};
},
};
41 changes: 41 additions & 0 deletions api/controllers/v1/get-txn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {

friendlyName: 'Get Txn',

description: 'Retrieves a txn.',

inputs: {
txnId: {
type: 'string',
required: true,
},
},

exits: {
//
},

fn: async function ({ txnId, }) {
let txn;
try {
txn = await Txn.findOne({ id: txnId, });
} catch (error) {
return {
success: false,
error: error.message,
};
}

if (!txn) {
return {
success: false,
error: 'Txn not found.',
};
}

return {
success: true,
txn,
};
},
};
34 changes: 34 additions & 0 deletions api/controllers/v1/get-withdraw-after.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {

friendlyName: 'Get WithdrawAfter',

description: 'Returns the withdrawAfter timestamp for an address.',

inputs: {
addr: {
type: 'string',
required: true,
},
},

exits: {
//
},

fn: async function ({ addr, }) {
let withdrawAfter;
try {
withdrawAfter = await Web3Service.getWithdrawAfter({ addr, });
} catch (err) {
return {
success: false,
error: err.message,
};
}

return {
success: true,
withdrawAfter: withdrawAfter.toString(),
};
},
};
18 changes: 18 additions & 0 deletions api/controllers/v1/healthcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {

friendlyName: 'Healthcheck',

description: 'Checks if the server is up and running.',

inputs: {
//
},

exits: {
//
},

fn: async function () {
return { success: true };
},
};
Loading

0 comments on commit 4cfbb11

Please sign in to comment.