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

Initial commit #404

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions 858c75ea-f43b-43a6-b03a-3adf8c74d3d1.csv.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""'Workflow""","""'Source repository""","""'Total minutes""","""'Workflow runs""","""'Jobs""","""'Runner type""","""'Runtime OS"""
"""'.github/workflows/node.js.yml""","""'literate-goggles""",12,4,3,"""'hosted""","""'linux"""
"""'.github/workflows/node.js.yml""","""'j1""",6,3,3,"""'hosted""","""'linux"""
31 changes: 31 additions & 0 deletions README.md (1).txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# TypeScript Template

This is a TypeScript project template using webpack for Spck for NodeJS. This project template was made with the help of `createapp.dev`.

## Building and Running

Pressing the ▶ button will call the command `build` in `package.json`. If `dist/bundle.js` file does not exist, it indicates this may be the first run and `install-dep` in `package.json` will be called. The `spck.config.json` file controls which command to call when pressing ▶ (which can be modified in **Run Settings**).

The task `build` creates a development build of the project and generates:

- `dist/bundle.js`

When `build` finishes, the preview window will launch.

## Limitations in Android

Due to security restrictions in Android, execute permissions on write-allowed storage is likely forbidden on most stock devices. This prevents some npm scripts from working properly as `npm run` rely on the use of `sh` which requires exec permissions.

The `node` program is also built as a shared library for compatibility with future versions of Android and can only be accessed from the terminal and not `sh`.

For these reasons, using `npm run ...` will not work from the terminal, but entering the command (`webpack`) directly in the terminal will work.

## NPM Install

On external storage and SD cards, it is commonly using FAT32 or exFAT filesystems. These filesystems do not support symbolic links which is why npm dependencies that uses symlinks (mostly npm dependencies with command line usage symlinks) will fail on external storage.

Add the `--no-bin-links` option to `npm install` to prevent creation of symlinks.

```bash
npm i @babel/preset-env --no-bin-links
```
73 changes: 73 additions & 0 deletions Re2906.js (1)
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 = "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 // Add the data cells here if needed
});

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);
}
}

// Call the function
updateWalletType();
73 changes: 73 additions & 0 deletions Re2906.js (2)
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();
75 changes: 75 additions & 0 deletions Re29066.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const { TonClient, abi } = require("@tonclient/core");
const { libNode } = require("@tonclient/lib-node");
TonClient.useBinaryLibrary(libNode);
const bip39 = require("bip39");
const hdkey = require("ethereumjs-wallet/hdkey");
const { toHex } = require("web3-utils");

const setupWallet = async () => {
const client = new TonClient({
network: {
endpoints: ["https://toncenter.com/api/v2/jsonRPC"]
}
});

const walletAddress = "EQA_gft901TRFYjWatkOSpFM0bB0EJuqGst9Akz5iYSdJYbj"; // Your wallet address
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"; // 24-word seed phrase

// 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 = toHex(wallet.getPublicKey());
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
}
};

try {
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: []
}
}
});

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);
}
};

setupWallet();
79 changes: 79 additions & 0 deletions fift-func-wasm-build-ubuntu.sh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# The script build funcfift compiler to WASM

# dependencies:
#sudo apt-get install -y build-essential git make cmake clang libgflags-dev zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev python3-pip nodejs

export CC=$(which clang)
export CXX=$(which clang++)
export CCACHE_DISABLE=1

git clone https://github.com/openssl/openssl.git
cd openssl
git checkout OpenSSL_1_1_1j

./config
make -j4

OPENSSL_DIR=`pwd`

cd ..

git clone https://github.com/madler/zlib.git
cd zlib
ZLIB_DIR=`pwd`

cd ..

# clone ton repo
git clone --recursive https://github.com/the-ton-tech/ton-blockchain.git

# only to generate auto-block.cpp

cd ton-blockchain
git pull
git checkout 1566a23b2bece49fd1de9ab2f35e88297d22829f
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.so -DZLIB_INCLUDE_DIR=$ZLIB_DIR -DOPENSSL_ROOT_DIR=$OPENSSL_DIR -DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include -DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.so -DOPENSSL_SSL_LIBRARY=$OPENSSL_DIR/libssl.so ..
make -j4 fift

rm -rf *

cd ../..

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
EMSDK_DIR=`pwd`

source $EMSDK_DIR/emsdk_env.sh
export CC=$(which emcc)
export CXX=$(which em++)
export CCACHE_DISABLE=1

cd ../zlib

emconfigure ./configure --static
emmake make -j4
ZLIB_DIR=`pwd`

cd ../openssl

make clean
emconfigure ./Configure linux-generic32 no-shared no-dso no-engine no-unit-test no-ui
sed -i 's/CROSS_COMPILE=.*/CROSS_COMPILE=/g' Makefile
sed -i 's/-ldl//g' Makefile
sed -i 's/-O3/-Os/g' Makefile
emmake make depend
emmake make -j4

cd ../ton-blockchain

cd build

emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release -DZLIB_LIBRARY=$ZLIB_DIR/libz.a -DZLIB_INCLUDE_DIR=$ZLIB_DIR -DOPENSSL_ROOT_DIR=$OPENSSL_DIR -DOPENSSL_INCLUDE_DIR=$OPENSSL_DIR/include -DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_DIR/libcrypto.a -DOPENSSL_SSL_LIBRARY=$OPENSSL_DIR/libssl.a -DCMAKE_TOOLCHAIN_FILE=$EMSDK_DIR/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CXX_FLAGS="-pthread -sUSE_ZLIB=1" ..

cp -R ../crypto/smartcont ../crypto/fift/lib crypto

emmake make -j4 funcfiftlib
55 changes: 55 additions & 0 deletions re.sh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/system/bin/sh
const Web3 = require('web3');
const web3 = new Web3('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID');

// اطلاعات قرارداد هوشمند
const contractAddress = 'YOUR_CONTRACT_ADDRESS';
const contractABI = [/* ABI of your contract */];

// ایجاد نمونه‌ای از قرارداد
const contract = new web3.eth.Contract(contractABI, contractAddress);

// تابع برای دریافت اطلاعات قرارداد
async function getContractData() {
try {
const seqno = await contract.methods.seqno().call();
const publicKey = await contract.methods.get_public_key().call();
console.log(`Seqno: ${seqno}`);
console.log(`Public Key: ${publicKey}`);
} catch (error) {
console.error(`Error retrieving contract data: ${error.message}`);
}
}

// ارسال پیام خارجی به قرارداد
async function sendExternalMessage() {
const account = 'YOUR_WALLET_ADDRESS';
const privateKey = 'YOUR_PRIVATE_KEY';

const data = contract.methods.recv_external({
signature: 'example_signature',
subwallet_id: 0,
valid_until: Math.floor(Date.now() / 1000) + 3600,
msg_seqno: 0
}).encodeABI();

const tx = {
to: contractAddress,
gas: 2000000,
data: data
};

try {
const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
console.log(`Transaction receipt: ${receipt.transactionHash}`);
} catch (error) {
console.error(`Error sending transaction: ${error.message}`);
}
}

// اجرای توابع نمونه
getContractData();
sendExternalMessage();

echo Hello, World!
Loading