Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Johnny
docker-momiji-node
Commits
5ce6ae55
Commit
5ce6ae55
authored
1 year ago
by
Johnny
Browse files
Options
Download
Email Patches
Plain Diff
initial commit
parents
Pipeline
#43
canceled with stages
Changes
22
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
tsconfig.json
tsconfig.json
+15
-0
watchers/momiji.js
watchers/momiji.js
+34
-0
No files found.
tsconfig.json
0 → 100755
View file @
5ce6ae55
{
"files"
:
[
"./src/index.ts"
],
"compilerOptions"
:
{
"lib"
:
[
"es2021"
],
"target"
:
"es2021"
,
"module"
:
"commonjs"
,
"outDir"
:
"./dist"
,
"skipLibCheck"
:
true
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
watchers/momiji.js
0 → 100755
View file @
5ce6ae55
"
use strict
"
;
var
__importDefault
=
(
this
&&
this
.
__importDefault
)
||
function
(
mod
)
{
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
const
ethers_1
=
require
(
"
ethers
"
);
const
fs_1
=
__importDefault
(
require
(
"
fs
"
));
const
dotenv_1
=
require
(
"
dotenv
"
);
from
;
"
./helpers
"
;
(
0
,
dotenv_1
.
config
)({
path
:
"
.env
"
});
class
Momiji
{
constructor
(
provider
)
{
this
.
queue
=
{
transactions
:
[]
};
const
abi
=
JSON
.
parse
(
fs_1
.
default
.
readFileSync
(
"
./abis/state.json
"
,
"
utf8
"
));
const
address
=
process
.
env
[
"
STATE_CONTRACT_ADDRESS
"
];
if
(
!
address
)
throw
new
Error
(
"
momiji.constructor: STATE_CONTRACT_ADDRESS is not set, but is required
"
);
this
.
contract
=
new
ethers_1
.
Contract
(
address
,
abi
,
provider
);
// Fetch existing queue from chain
}
watchEvents
()
{
this
.
contract
.
on
(
"
TransactionSent
"
,
(
event
)
=>
{
console
.
log
(
`Event received:
${
event
}
`
);
// Add it to the queue and start proving in the background
});
this
.
contract
.
on
(
"
BatchPublish
"
,
(
event
)
=>
{
console
.
log
(
`Event received:
${
event
}
`
);
// Clear the queue and flush the batch object
this
.
queue
=
{
transactions
:
[]
};
// reset the queue
});
}
}
exports
.
default
=
Momiji
;
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help