This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from nearprotocol/revert-yifang-merge
Revert yifang merge
- Loading branch information
Showing
22 changed files
with
520 additions
and
178 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
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
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 @@ | ||
package-lock.json linguist-generated=true -diff | ||
yarn.lock linguist-generated=true -diff |
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,6 @@ | ||
# Greeter example in AssemblyScript | ||
|
||
## Description | ||
|
||
The contract implements a single function to return a greeting. | ||
For instructions on how to run this project, please follow our online tutorial https://docs.nearprotocol.com/quick-start/local-development |
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,32 @@ | ||
//@nearfile | ||
import { near, context, storage, logging } from "near-runtime-ts"; | ||
import { Greeter } from "./model"; | ||
|
||
// --- contract code goes below | ||
|
||
// It's good to use common constant, but not required. | ||
const LAST_SENDER_KEY = "last_sender"; | ||
|
||
// This is our change method. It modifies the state of the contract by | ||
// storing the account_id of the sender under the key "last_sender" on the blockchain | ||
export function sayHi(): void { | ||
// context.sender is the account_id of the user who sent this call to the contract | ||
// It's provided by the Blockchain runtime. For now we just store it in a local variable. | ||
let sender = context.sender; | ||
// `near` class contains some helper functions, e.g. logging. | ||
// Logs are not persistently stored on the blockchain, but produced by the blockchain runtime. | ||
// It's helpful to use logs for debugging your functions or when you need to get some info | ||
// from the change methods (since change methods don't return values to the front-end). | ||
logging.log(sender + " says \"Hello mate!\""); | ||
// storage is a helper class that allows contracts to modify the persistent state | ||
// and read from it. setString allows you to persitently store a string value for a given string key. | ||
// We'll store the last sender of this contract who called this method. | ||
storage.setString(LAST_SENDER_KEY, sender); | ||
} | ||
|
||
// This is our view method. It returns the last account_id of a sender who called `sayHi`. | ||
// It reads value from the persistent store under the key "last_sender" and returns it. | ||
export function whoSaidHi(): string | null { | ||
// getString returns a string value for a given string key. | ||
return storage.getString(LAST_SENDER_KEY); | ||
} |
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,13 @@ | ||
//@nearfile | ||
// Basic data model | ||
export class Greeter { | ||
text: string; | ||
|
||
constructor(text: string) { | ||
this.text = text; | ||
} | ||
|
||
greet(userId: string): string { | ||
return "Hello, " + userId; | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"extends": "../node_modules/assemblyscript/std/assembly.json", | ||
"include": [ | ||
"./**/*.ts" | ||
] | ||
} |
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,11 @@ | ||
const gulp = require('gulp'); | ||
const nearUtils = require('near-shell/gulp-utils'); | ||
|
||
function build_wasm(done){ | ||
nearUtils.compile('./assembly/main.ts', './out/main.wasm', done); | ||
} | ||
|
||
const build = gulp.series(build_wasm); | ||
|
||
|
||
exports.default = build; |
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 @@ | ||
{"account_id":"test.near","private_key":"ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw"} |
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 @@ | ||
{"account_id":"test.near","private_key":"ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw"} |
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,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
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,30 @@ | ||
{ | ||
"name": "hello_world_ts", | ||
"description": "", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"build": "mkdir -p out/ && gulp", | ||
"deploy:contract": "near deploy", | ||
"deploy:pages": "gh-pages -d src", | ||
"deploy": "npm run build && npm run deploy:contract && npm run deploy:pages", | ||
"prestart": "npm run build && npm run deploy:contract", | ||
"start": "serve src", | ||
"test": "npm run build && jest test --env=near-shell/test_environment" | ||
}, | ||
"devDependencies": { | ||
"gh-pages": "^2.1.1", | ||
"gulp": "^4.0.2", | ||
"jest": "^24.8.0", | ||
"jest-environment-node": "^24.8.0", | ||
"near-runtime-ts": "^0.5.1", | ||
"near-shell": "github:nearprotocol/near-shell" | ||
}, | ||
"wasmStudio": { | ||
"name": "Hello World Example", | ||
"description": "The contract implements a single function to return \"Hello, World!\" using AssemblyScript", | ||
"icon": "typescript-lang-file-icon" | ||
}, | ||
"dependencies": { | ||
"serve": "^11.0.1" | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.