-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from hollow-leaf/feat/tezosTaquito
feat: add tezos taquito
- Loading branch information
Showing
5 changed files
with
421 additions
and
109 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "tezos-interact", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "tsup src/index.ts --format cjs --dts", | ||
"build:dev": "npm run build -- --watch", | ||
"dev": "ts-node src/test.ts" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@taquito/signer": "^17.2.0", | ||
"@taquito/taquito": "^17.2.0", | ||
"ts-node": "^10.9.1", | ||
"tsconfig": "workspace:*", | ||
"tsup": "^6.1.3" | ||
}, | ||
"devDependencies": { | ||
"tsconfig": "workspace:*", | ||
"typescript": "^5.1.6" | ||
} | ||
} |
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,59 @@ | ||
import { TezosToolkit } from '@taquito/taquito'; | ||
import { InMemorySigner, importKey } from '@taquito/signer'; | ||
|
||
const Tezos = new TezosToolkit('https://ghostnet.tezos.marigold.dev'); | ||
|
||
Tezos.setProvider({ | ||
signer: new InMemorySigner('edskS1zsQPHwdhuQQ9dcvtmrgSC1f7pqMZMrst4xzB4hMgkmAzgnDHbRhHGckG7RXN6yoed1PE31S63z2Y7Pa13kvZcQgcQ8bU'), | ||
}); | ||
|
||
|
||
export const accessProposal = async () => { | ||
await Tezos.contract | ||
.at('KT1KqDtnTZMYiEpe81f6u24Jnmq5Hg2h9z5v') | ||
.then((contract) => { | ||
console.log('Access proposal...') | ||
return contract.methods.access().send(); | ||
}) | ||
.then((op) => { | ||
const result: any = op.results[0] | ||
console.log(`Waiting for ${op.hash} to be confirmed...`); | ||
return op.confirmation(1).then(() => op.hash); | ||
}) | ||
.then((hash) => { | ||
console.log(`Access operation finished: https://better-call.dev/ghostnet/opg/${hash}`) | ||
}) | ||
.catch((error) => { | ||
console.log(`Access error: ${JSON.stringify(error, null, 2)}`) | ||
}) | ||
} | ||
|
||
export const voteProposal = async (vote: number) => { | ||
await Tezos.contract | ||
.at('KT1KqDtnTZMYiEpe81f6u24Jnmq5Hg2h9z5v') | ||
.then((contract) => { | ||
console.log('Vote proposal...') | ||
return contract.methods.vote(vote).send(); | ||
}) | ||
.then((op) => { | ||
console.log(`Waiting for ${op.hash} to be confirmed...`); | ||
return op.confirmation(1).then(() => op.hash); | ||
}) | ||
.then((hash) => { | ||
console.log(`Vote finished: https://better-call.dev/ghostnet/opg/${hash}`) | ||
}) | ||
.catch((error) => { | ||
console.log(`Vote error: ${JSON.stringify(error, null, 2)}`) | ||
}); | ||
} | ||
|
||
export const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) | ||
|
||
const main = async () => { | ||
// await voteProposal(1) | ||
// sleep(15000) | ||
// await accessProposal() | ||
} | ||
|
||
main() | ||
|
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,8 @@ | ||
import { voteProposal, accessProposal } from './index'; | ||
|
||
const main = async () => { | ||
await voteProposal(1) | ||
await accessProposal() | ||
} | ||
|
||
main() |
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,8 @@ | ||
{ | ||
"extends": "tsconfig/base.json", | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
}, | ||
"include": [ "**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
Oops, something went wrong.