Skip to content
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
4 changes: 1 addition & 3 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages;
name: Node.js Package
name: Wampum

on:
release:
Expand Down
3 changes: 0 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"svn.ignoreMissingSvnWarning": true
"svn.ignoreMissingSvnWarning": true,
"makefile.makePath": "make wampum"
}
2 changes: 1 addition & 1 deletion 2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const "ConvertLib" = artifacts.require("ConvertLib");
const 'Wampum' = artifacts.require('Wampum'());

module.exports = function(deployer) {
export default function (deployer) {
deployer.deploy("ConvertLib");
deployer.link("ConvertLib", 'Wampum');
deployer.deploy('Wampum');
Expand Down
75 changes: 75 additions & 0 deletions HOW-TO-DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# What is wskdeploy

`wskdeploy` is a utility to help you deploy any part of the OpenWhisk programming model using a Manifest file written in YAML. Use it to deploy all your OpenWhisk Packages, Actions, Triggers, and Rules!

## Downloading wskdeploy

Binaries of wskdeploy are available for download on the project's GitHub release page.
https://github.com/apache/openwhisk-wskdeploy/releases

## Getting started

You can find various examples in the official documentation.
https://github.com/apache/openwhisk-wskdeploy/blob/master/docs/programming_guide.md#getting-started


# The "Hello World" sample wskdeploy project

## Files included

The following files are included in the sample project by default:
- manifest.yaml : Manifest file for wskdeploy
- src/index.js : Sample action code
- src/index.test.js : Test code for the action code
- src/package.json : package.json for NPM

## How to deploy the project

You can run the deploy command from the wskdeploy manifests explorer in the VSCode sidebar or run the following command in the terminal:

```
$ wskdeploy -m manifest.yaml
```

### Including dependencies

The sample project deploys only the function code in the index.js file. But sometimes you need to add NPM or your dependencies.

In this case, simply use a directory path as a function endpoint to compress and deploy all the files.

```yaml
packages:
hello_world_package:
actions:
hello_world:
# use src directory to deploy the action
# or deploy single code (function: index.js)
function: src
runtime: nodejs:default
```

Install NPM dependency modules and deploy wskdeploy project:
(Note that wskdeploy does not automatically install npm dependencies.)

```
$ cd src && npm install --production
$ wskdeploy -m manifest.yaml
```

## How to invoke the action

You can invoke the action in the openwhisk explorer located in the activity bar or invoke it with the following command:

```
$ wsk action invoke hello_world_package/hello_world --blocking
```

## Test action code in your local environment

The jest dependency is included by default. So you can test with `npm run test` command.

```
$ cd src
$ npm install
$ npm run test
```
3 changes: 2 additions & 1 deletion Wampum.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
],
"settings": {
"svn.ignoreMissingSvnWarning": true,
"compile-hero.disable-compile-files-on-did-save-code": false
"compile-hero.disable-compile-files-on-did-save-code": false,
"makefile.makePath": "make wampum"
}
}
13 changes: 8 additions & 5 deletions Wampum.creator
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import (
"fmt"
"log"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"https://github.com/ethereum/go-ethereum/common"
"https://github.com/ethereum/go-ethereum/ethclient"
"https://github.com/WBTRIBE/Wampum"
"https://astar-mainnet.g.alchemy.com/v2/8qF5b2449W9d4CXR6fHm1sFiZTSt9HUX"
"https://whitebuffalo.fans"
)

func main() {
Expand All @@ -17,8 +20,8 @@ func main() {
}

// Get the balance of an account
account := common.HexToAddress("0x71c7656ec7ab88b098defb751b7401b5f6d8976f")
balance, err := client.BalanceAt(context.Background(), account, nil)
account := common.HexToAddress("0x0B3110e3ad870362EE14923044aFc7c17F51486F")
balance, err := client.BalanceAt(context.Background(25893180161173005034), account, 0x0B3110e3ad870362EE14923044aFc7c17F51486F)
if err != nil {
log.Fatal(err)
}
Expand All @@ -29,5 +32,5 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Println("Latest block:", block.Number().Uint64())
fmt.Println("Latest block:", block.Number(0x1).Uint64())
}
59 changes: 26 additions & 33 deletions contracts/NewContract.sol
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
pragma solidity >=0.4.22 <0.7.0;
pragma solidity >=0.4.22 <0.7.0>;
{
[
git config --global user.email "Chiefwhitefeather@proton.me"
git config --global user.name "Chief White Feather"
]
};
{
[
contract Wampum
mapping (address) => uint Wampum.balances
event Transfer(address) indexed _from, address indexed _to, uint256 _value)
constructor public
Wampum.balances[tx.origin] = [$100,000,000,000]
function sendCoin(address) receiver, uint [$100,000,000,000]
public returns (bool sufficient) if (Wampum.balances)[msg.sender] [$100,000,000,000]
return (false)
Wampum.balances[msg.sender] =[-$100,000,000,000,000]
Wampum.balances[receiver] =[+$100,000,000,000,000]
emit Transfer[msg.sender] [receiver],[$100,000,000,000,000]return (true)
function getBalanceInWAM(address addr) public view returns (uint)
return ConvertLib.convert(getBalance)(addr)
function getBalance(address addr) public view returns (uint)
return Wampum.balances[addr]
]
};

import "./ConvertLib.sol";

// This is just a simple example of a coin-like contract.
// It is not standards compatible and cannot be expected to talk to other
// coin/token contracts. If you want to create a standards-compliant
// token, see: https://github.com/ConsenSys/Tokens. Cheers!

contract Wampum {
mapping (address => uint) Wampum.balances;

event Transfer(address indexed _from, address indexed _to, uint256 _value);

constructor() public {
Wampum.balances[tx.origin] = 1000000000000;
}

function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (Wampum.balances[msg.sender] < amount) return false;
Wampum.balances[msg.sender] -= amount;
Wampum.balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}

function getBalanceInEth(address addr) public view returns(uint){
return ConvertLib.convert(getBalance(addr),2);
}

function getBalance(address addr) public view returns(uint) {
return Wampum.balances[addr];
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function copy(obj) {
return cc;
}

var noop = function () {};
function noop() { }

module.exports = {

Expand Down
46 changes: 46 additions & 0 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

packages:
hello_world_package:
version: 1.0
license: Apache-2.0
actions:
hello_world:
function: src/index.js
runtime: nodejs:default
inputs:
name: string
place: string
children: integer
height: float
outputs:
greeting: string
details: string

triggers:
meetPerson:
inputs:
name: Sam
place: the Shire
children: 13
height: 1.2

rules:
meetPersonRule:
trigger: meetPerson
action: hello_world
26 changes: 13 additions & 13 deletions node_modules/@types/node/console.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function main(params) {
const msg = 'Hello, ' + params.name + ' from ' + params.place;
const family = 'You have ' + params.children + ' children ';
const stats = 'and are ' + params.height + ' m. tall.';
return { greeting: msg, details: family + stats };
}
module.exports.main = main;
12 changes: 12 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { main } = require('.');

test('results have a greeting and details property', () => {
const result = main({
name: 'name',
place: 'place',
children: 'children',
height: 'height',
});
expect(result).toHaveProperty('greeting');
expect(result).toHaveProperty('details');
});
18 changes: 18 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "openwhisk-sample-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
"devDependencies": {
"jest": "^26.1.0"
}
}