update max_heap_size

This commit is contained in:
boneyard93501 2022-05-18 02:01:43 -05:00
parent bb23807f12
commit d23b7c294e
2 changed files with 2 additions and 229 deletions

View File

@ -1,227 +0,0 @@
import { Fluence, KeyPair as FluenceKeyPair } from "@fluencelabs/fluence";
import { krasnodar } from "@fluencelabs/fluence-network-environment";
import { sign_transaction, NearSignerApiDef, registerNearSignerApi } from "./_aqua/near_signer";
import * as nearAPI from "near-api-js";
import { KeyStore } from "near-api-js/lib/key_stores";
import * as fs from 'fs';
import * as path from 'path';
import { Buffer } from 'buffer';
import { Near } from "near-api-js";
const { connect, keyStores, KeyPair, WalletConnection, Account } = nearAPI;
// const homedir = require("os").homedir();
// const CREDENTIALS_DIR = ".near-credentials";
// const credentialsPath = path.join(homedir, CREDENTIALS_DIR);
// const keyStore = new keyStores.UnencryptedFileSystemKeyStore(credentialsPath);
// temp fix replace with your key, e.g., account pk
const SeedArray = new Uint8Array([10, 10, 20, 20, 100, 100]);
class NearSigner implements NearSignerApiDef {
_homedir = require("os").homedir();
_CREDENTIALS_DIR = ".near-credentials";
_credentialsPath = path.join(this._homedir, this._CREDENTIALS_DIR);
_keyStore = new keyStores.UnencryptedFileSystemKeyStore(this._credentialsPath);
async sign_transaction(network_id: string, tx_string: string, password: string): Promise<string> {
const config = get_config(network_id, this._keyStore);
const near = await network_connect(config);
const wallet = await wallet_connect(near, "signer-node");
await wallet_signout(wallet);
return Promise.resolve("boo yah");
}
async account_state(network_id: string, account_id: string): Promise<any> {
const config = get_config(network_id, this._keyStore);
const near = await network_connect(config);
const state = await account_state(near, account_id);
console.log("account state: ", state);
return Promise.resolve(state);
}
async send_tokens(network_id: string, account_id: string, receiver_id: string, amount: string): Promise<any> {
console.log("keyStore: ", keyStore);
console.log("keyStore: ", this._keyStore);
const config = get_config(network_id, keyStore);
// const config = get_config("testnet", this._keyStore);
console.log("config: ", config);
const near = await network_connect(config);
// let account = await near.account(account_id);
let account = await near.account("boneyard93501.testnet");
console.log("account: ", account);
// let tx_receipt = await account.sendMoney(receiver_id, amount);
let tx_receipt = await account.sendMoney("boneyard93502.testnet", "100000");
console.log("receipt: ", tx_receipt);
return Promise.resolve(tx_receipt);
}
}
function get_config(networkId: string, keyStore: any): any {
const config = {
// networkId,
networkId: "testnet",
keyStore,
// nodeUrl: `https://rpc.${networkId}.near.org`,
nodeUrl: `https://rpc.testnet.near.org`,
// walletUrl: `https://wallet.${networkId}.near.org`,
walletUrl: `https://wallet.testnet.near.org`,
// helperUrl: `https://helper.${networkId}.near.org`,
helperUrl: `https://helper.testnet.near.org`,
// explorerUrl: `https://explorer.${networkId}.near.org`,
explorerUrl: `https://explorer.testnet.near.org`,
};
return config;
}
async function network_connect(network_id: string): Promise<nearAPI.Near> {
const config = get_config(network_id, keyStore);
const near = await connect(config);
// console.log("near: ", near);
return Promise.resolve(near);
}
async function wallet_signout(wallet: nearAPI.WalletConnection): Promise<boolean> {
if (wallet.isSignedIn()) {
wallet.signOut();
}
return Promise.resolve(wallet.isSignedIn());
}
async function wallet_connect(near: nearAPI.Near, app_name: string): Promise<nearAPI.WalletConnection> {
// create wallet connection
const wallet = new WalletConnection(near, app_name);
return Promise.resolve(wallet);
}
async function wallet_load(network_id: string, account_id: string) {
const config = get_config(network_id, keyStore);
const near = await connect(config);
const account = await near.account(account_id);
}
async function sign(network_id: string, payload: string, account_id: string): Promise<Uint8Array> {
const keyPair = await keyStore.getKey(network_id, account_id);
const msg = Buffer.from(payload);
const { signature } = keyPair.sign(msg);
return Promise.resolve(signature);
}
async function verify_signature(network_id: string, account_id: string, payload: string, signature: Uint8Array) {
const keyPair = await keyStore.getKey(network_id, account_id);
const msg = Buffer.from(payload);
}
// account
async function get_balance(near: nearAPI.Near, account_id: string): Promise<any> {
const account = await near.account(account_id);
const balance = await account.getAccountBalance();
return Promise.resolve(balance);
}
// deploy
async function deploy_contract_local(near: nearAPI.Near, account_id: string, wasm_path: string): Promise<nearAPI.providers.FinalExecutionOutcome> {
const account = await near.account(account_id);
const deployment = account.deployContract(fs.readFileSync(wasm_path));
return Promise.resolve(deployment);
}
async function deploy_contract(near: nearAPI.Near, account_id: string, wasm_raw: Uint8Array): Promise<nearAPI.providers.FinalExecutionOutcome> {
const account = await near.account(account_id);
const deployment = account.deployContract(wasm_raw);
return Promise.resolve(deployment);
}
async function deploy_contract_from_string(near: nearAPI.Near, account_id: string, wasm_str: string): Promise<nearAPI.providers.FinalExecutionOutcome> {
const account = await near.account(account_id);
const buffer = Buffer.from(wasm_str, 'utf8');
const deployment = account.deployContract(buffer);
return Promise.resolve(deployment);
}
async function send_tokens(near: nearAPI.Near, account_id: string, receiver_id: string, amount: string): Promise<nearAPI.providers.FinalExecutionOutcome> {
const account = await near.account(account_id);
const result = await account.sendMoney(receiver_id, amount);
return Promise.resolve(result);
}
// state
async function account_state(near: nearAPI.Near, account_id: string): Promise<any> {
const account = await near.account(account_id);
const response = await account.state();
return Promise.resolve(response);
}
interface AccountState {
amount: string,
block_hash: string,
block_height: number,
code_hash: string,
locked: string,
storage_paid_at: number,
storage_usage: number
}
async function main() {
/*
const config = get_config("testnet");
const near = await connect(config);
console.log("near: ", near, "\n");
let account = await near.account("boneyard93501.testnet");
let res = await account.sendMoney("boneyard93502.testnet", "100000");
console.log("tx: ", res);
*/
console.log("keyStore: ", keyStore);
await Fluence.start({
connectTo: krasnodar[5],
/*
connectTo: {
multiaddr: "/ip4/127.0.0.1/tcp/9990/ws/p2p/12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK",
peerId: "12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK"
},
*/
KeyPair: await FluenceKeyPair.fromEd25519SK(SeedArray)
});
console.log("PeerId: ", Fluence.getStatus().peerId);
console.log("Relay id: ", Fluence.getStatus().relayPeerId);
registerNearSignerApi("near", new NearSigner());
/*
const config = get_config("testnet");
const near = await connect(config);
console.log("near: ", near, "\n");
let accounts = new Array<nearAPI.Account>();
accounts.push(await near.account("boneyard93501.testnet"));
accounts.push(await near.account("boneyard93502.testnet"));
console.log("Accounts: ", accounts);
*/
console.log("ctrl-c to exit");
}
main();

View File

@ -2,12 +2,12 @@ modules_dir = "artifacts"
[[module]]
name = "curl_adapter"
mem_pages_count = 10
max_heap_size = "100 KiB"
logger_enabled = true
[module.mounted_binaries]
curl = "/usr/bin/curl"
[[module]]
name = "near_rpc_services"
mem_pages_count = 10
max_heap_size = "10 KiB"
logger_enabled = true