You can do following to allow passing blob into contract without a lot of overhead:
export function setContractToDeploy(): void {
env.input(0);
util.read_register(0);
// ...
}
You can do following to allow passing blob into contract without a lot of overhead:
export function setContractToDeploy(): void {
env.input(0);
util.read_register(0);
// ...
}
async function deploy(options) { | |
const configPath = process.cwd() + '/src/config'; | |
const config = require(configPath)(process.env.NODE_ENV || 'development'); | |
const near = await nearlib.connect({...config, deps: { keyStore: new UnencryptedFileSystemKeyStore('./neardev') } }); | |
const contractData = [...fs.readFileSync(options.wasmFile)]; | |
const account = await near.account(options.accountId); | |
await account.signAndSendTransaction(options.accountId, [ | |
deployContract(contractData), | |
// TODO: Use whatever actual params need to be for functionCall or include any other actions as well |
[I] ➜ yarn start | |
yarn run v1.21.1 | |
warning package.json: No license field | |
$ npm run build && near deploy --wasmFile ./contract/res/status_message.wasm | |
npm WARN lifecycle The node binary used for scripts is /var/folders/3c/zjk2krns25s75x_z2_wdvgg80000gn/T/yarn--1580160108615-0.8711654915114355/node but npm is using /Users/vg/n/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. | |
> blank-rust-proj-vg@0.0.1 build /Users/vg/Documents/create-near-app/blank-rust-proj-vg | |
> cd contract && ./build.sh | |
Updating crates.io index |
sqlite3 = require('sqlite3') | |
db = new sqlite3.Database('db/testnet-database.sqlite') | |
db.all(`select name from sqlite_master where type='table'`, console.log) | |
db.all(`select * from transactions where actions like '%deploy%' limit 10`, console.log) | |
db.all(`select count(*) from transactions where actions like '%deploy%' limit 10`, console.log) |
const nearlib = require('nearlib'); | |
const { signTransaction, transfer } = nearlib.transactions; | |
const { base_decode } = nearlib.utils.serialize; | |
const sleep = (ms) => new Promise((resolved) => setTimeout(resolved, ms)); | |
(async () => { | |
const [,, accountId, txCount] = process.argv; | |
const near = await nearlib.connect({...require('near-shell/get-config')(), deps: { keyStore: new nearlib.keyStores.UnencryptedFileSystemKeyStore('./neardev') } }); |
const http = require('http'); | |
const url = require('url'); | |
const hostname = '127.0.0.1'; | |
const port = 3000; | |
const server = http.createServer((req, res) => { | |
res.statusCode = 200; | |
res.setHeader('Content-Type', 'text/html'); | |
try { |
import "allocator/arena"; | |
// TODO: Why cannot import from index? | |
// import { BSONEncoder, BSONDecoder } from "../../../assemblyscript-bson/assembly"; | |
import { BSONEncoder } from "../../../assemblyscript-bson/assembly/encoder"; | |
import { BSONDecoder } from "../../../assemblyscript-bson/assembly/decoder"; | |
declare function sayHello(): void; | |
export class FooBar { | |
foo: i32 = 0; |
book_train_and_hotel() : void { // Needs 6 MANA. | |
// 3 for train and callback and 3 for hotel and callback. | |
// E.g. book_train and book_hotel doesn't need additional mana, so only 1 MANA for a call. | |
// Callback may need 1 additional to cancel train or hotel booking if one of them failed. | |
assert_has_mana(6); | |
let hotelBooking = bookHotel.withMana(3).withCoins(1000).book(sender()); | |
let trainBooking = bookTrain.withMana(3).withCoins(1000).book(sender()); | |
data Rope = Empty | Concat Int Rope Rope | Leaf String deriving (Show, Eq) | |
rope :: String -> Rope | |
rope "" = Empty | |
rope s = Leaf s | |
len :: Rope -> Int | |
len Empty = 0 | |
len (Leaf s) = length s | |
len (Concat length _ _) = length |
/** | |
* CSV Parser. Takes a string as input and returns | |
* an array of arrays (for each row). | |
* | |
* @param input String, CSV input | |
* @param separator String, single character used to separate fields. | |
* Defaults to "," | |
* @param quote String, single character used to quote non-simple fields. | |
* Defaults to "\"". | |
*/ |