Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create wallet.js #343

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
}
}
22 changes: 22 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request_target]

jobs:
label:

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
73 changes: 73 additions & 0 deletions .github/workflows/wallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const bip39 = require('bip39');
const hdkey = require('ethereumjs-wallet/hdkey');
const { toHex } = require('ethereumjs-util');
const { TonClient } = require('@tonclient/core');

const walletAddress = "0:4818f679ede118884806590b9b705a00fa6aa0cf7009d4b3d128ff263b031c88";
const seedPhrase = "kingdom hungry number apple plug borrow flame dose broken reject roof worry gallery gaze cost mind similar stool retire nephew unable prize involve slim";

// Derive keys from seed phrase
const seed = bip39.mnemonicToSeedSync(seedPhrase);
const hdWallet = hdkey.fromMasterSeed(seed);
const wallet = hdWallet.derivePath(`m/44'/60'/0'/0/0`).getWallet();
const publicKey = "dd659500fa0de6f0f4832f6feeb8a2b0f936b18879090eddb484759cea4b803257a8ed7fc90ddeed12e042387db4ec44ddc3cebdaba4bc93457e56626bd68a09";
const secretKey = toHex(wallet.getPrivateKey());

const callSet = {
function_name: "setWalletType",
input: {
new_wallet_type: "wallet_v3R2"
}
};

const signer = {
type: "Keys",
keys: {
public: publicKey,
secret: secretKey
}
};

const dataCells = "x{000003A829A9A31720CC7B53E49B682279104AE905DA0D456D45ADE97DDB547E22B28069095F09154_}";

async function updateWalletType() {
try {
const client = new TonClient({ network: { server_address: 'https://main.ton.dev' } });
await client.setup();
const { message } = await client.abi.encode_message({
address: walletAddress,
call_set: callSet,
signer: signer,
abi: {
type: "Contract",
value: {
"ABI version": 2,
header: ["time", "expire"],
functions: [
{
name: "setWalletType",
inputs: [
{ name: "new_wallet_type", type: "string" }
],
outputs: []
}
],
data: [],
events: []
}
},
data: dataCells // اضافه کردن سلول‌های داده در اینجا
});

await client.processing.send_message({
message,
send_events: false
});
console.log("Wallet type successfully updated to v3R2");
} catch (error) {
console.error("Error updating wallet type:", error);
}
}

// فراخوانی تابع
updateWalletType();
28 changes: 28 additions & 0 deletions .github/workflows/webpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: NodeJS with Webpack

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Build
run: |
npm install
npx webpack
14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "markdownlint",
"problemMatcher": [
"$markdownlint"
],
"label": "markdownlint: Lint all Markdown files in the workspace with markdownlint"
}
]
}