-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit de5ce0d
Showing
11 changed files
with
3,598 additions
and
0 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 @@ | ||
MNEMONIC="lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua ut enim ad minim veniam" |
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,7 @@ | ||
// @ts-check | ||
|
||
const { extendEslint } = require("@graz-sh/style-guide-core"); | ||
|
||
module.exports = extendEslint(["node", "typescript"], { | ||
root: true, | ||
}); |
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,16 @@ | ||
# default ignored directores/files | ||
**/node_modules/ | ||
*.log | ||
.DS_Store | ||
.env* | ||
.eslintcache | ||
.turbo | ||
.vercel | ||
dist/** | ||
package-lock.json | ||
tsconfig.tsbuildinfo | ||
vendor/** | ||
|
||
# allowed directories/files | ||
!.gitkeep | ||
!.env.example |
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,2 @@ | ||
public-hoist-pattern[]=* | ||
# enable-pre-post-scripts=true |
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 @@ | ||
18 |
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 @@ | ||
{ | ||
"[stubs/*.ts]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
}, | ||
"[javascriptreact]": { | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
}, | ||
"[typescriptreact]": { | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
}, | ||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"], | ||
"npm.packageManager": "pnpm" | ||
} |
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,5 @@ | ||
declare namespace NodeJS { | ||
interface ProcessEnv { | ||
readonly MNEMONIC?: string; | ||
} | ||
} |
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,52 @@ | ||
import type { EncodeObject } from "@cosmjs/proto-signing"; | ||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; | ||
import { GasPrice, SigningStargateClient } from "@cosmjs/stargate"; | ||
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx"; | ||
|
||
const addresses = { | ||
griko_nibras: `cosmos1kpzxx2lxg05xxn8mfygrerhmkj0ypn8edmu2pu`, | ||
kikiding: `cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430`, | ||
asaadam: `cosmos1q7u2wv5rmzphm53cww42ydcrsgjp7he8u3f85f`, | ||
}; | ||
|
||
const run = async () => { | ||
// https://github.com/cosmos/chain-registry/blob/master/cosmoshub/chain.json | ||
const chainId = "cosmoshub-4"; | ||
const rpcEndpoint = "https://rpc.cosmos.directory/cosmoshub"; | ||
const bech32Prefix = "cosmos"; | ||
|
||
const mnemonic = process.env.MNEMONIC || raise("configure mnemonic in .env file"); | ||
const offlineSigner = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: bech32Prefix }); | ||
|
||
const accounts = await offlineSigner.getAccounts(); | ||
const account = accounts[0] || raise("no account found"); | ||
|
||
const signingClient = await SigningStargateClient.connectWithSigner(rpcEndpoint, offlineSigner, { | ||
gasPrice: GasPrice.fromString("0.025uatom"), | ||
}); | ||
|
||
const sendTokenPayload = MsgSend.fromPartial({ | ||
fromAddress: account.address, | ||
toAddress: addresses.griko_nibras, | ||
amount: [{ amount: "10000", denom: "uatom" }], | ||
}); | ||
|
||
const encodedSendTokenPayload = MsgSend.encode(sendTokenPayload).finish(); | ||
|
||
const messagesToSend: EncodeObject[] = [ | ||
{ | ||
typeUrl: "/cosmos.bank.v1beta1.MsgSend", | ||
value: encodedSendTokenPayload, | ||
}, | ||
]; | ||
|
||
const response = await signingClient.signAndBroadcast(account.address, messagesToSend, "auto"); | ||
|
||
console.log(response); | ||
}; | ||
|
||
const raise = (message?: string): never => { | ||
throw new Error(message); | ||
}; | ||
|
||
void run(); |
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,17 @@ | ||
{ | ||
"scripts": { | ||
"start": "tsx -r dotenv/config index.ts" | ||
}, | ||
"dependencies": { | ||
"@cosmjs/proto-signing": "^0.31.1", | ||
"@cosmjs/stargate": "^0.31.1", | ||
"@graz-sh/style-guide-core": "^4.0.1", | ||
"@types/node": "^18.17.12", | ||
"cosmjs-types": "^0.8.0", | ||
"eslint": "^8.48.0", | ||
"prettier": "^3.0.3", | ||
"tsx": "^3.12.8" | ||
}, | ||
"prettier": "@graz-sh/style-guide-core/prettier", | ||
"private": true | ||
} |
Oops, something went wrong.