From b5d4c5667790cbd673b11861ebb39bfe8627c878 Mon Sep 17 00:00:00 2001 From: whitefeather2796 <123049042+whitefeather2796@users.noreply.github.com> Date: Sun, 5 Feb 2023 20:06:23 +0000 Subject: [PATCH 1/6] d --- Wampum.creator | 13 ++++++---- contracts/NewContract.sol | 36 +++++++++++++-------------- node_modules/@types/node/console.d.ts | 26 +++++++++---------- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/Wampum.creator b/Wampum.creator index acf6259..07196d6 100644 --- a/Wampum.creator +++ b/Wampum.creator @@ -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() { @@ -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) } @@ -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()) } \ No newline at end of file diff --git a/contracts/NewContract.sol b/contracts/NewContract.sol index 17f75bc..1d86741 100644 --- a/contracts/NewContract.sol +++ b/contracts/NewContract.sol @@ -1,34 +1,32 @@ -pragma solidity >=0.4.22 <0.7.0; +// SPDX-License-Identifier: MIT; +pragma solidity >=0.4.22 <0.7.0> -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! +{[ + git config --global user.email "chiefwhitefeather@proton.me" + git config --global user.name "Chief White Feather" +]}; contract Wampum { - mapping (address => uint) Wampum.balances; + mapping (address => uint) Wampumbalances; event Transfer(address indexed _from, address indexed _to, uint256 _value); constructor() public { - Wampum.balances[tx.origin] = 1000000000000; + 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); + function sendCoin(address receiver, uint $1000000000000) public returns(bool sufficient){ + if (Wampum.balances[msg.sender] ($100,000,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 getBalanceInEth(address addr) public view returns(uint){ + function getBalanceInWAM(address addr) public view returns(uint){ return ConvertLib.convert(getBalance(addr),2); } - function getBalance(address addr) public view returns(uint) { + function getBalance(address addr) public view returns(uint) return Wampum.balances[addr]; - } -} +]}; + diff --git a/node_modules/@types/node/console.d.ts b/node_modules/@types/node/console.d.ts index 16c9137..3dabb18 100755 --- a/node_modules/@types/node/console.d.ts +++ b/node_modules/@types/node/console.d.ts @@ -15,10 +15,10 @@ * Example using the global `console`: * * ```js - * console.log('hello world'); - * // Prints: hello world, to stdout - * console.log('hello %s', 'world'); - * // Prints: hello world, to stdout + * console.log('Wampum Universal Mint'); + * // Prints: Wampum Universal Mint, to stdout + * console.log('Mint %s', 'Universal'); + * // Prints: Universal Mint, to stdout * console.error(new Error('Whoops, something bad happened')); * // Prints error message and stack trace to stderr: * // Error: Whoops, something bad happened @@ -30,9 +30,9 @@ * // at evalScript (node:internal/process/execution:76:60) * // at node:internal/main/eval_string:23:3 * - * const name = 'Will Robinson'; - * console.warn(`Danger ${name}! Danger!`); - * // Prints: Danger Will Robinson! Danger!, to stderr + * const name = 'Chief White Feather'; + * console.warn(`Danger ${Native American Church}! Danger!`); + * // Prints: Danger Chief White Feather! Danger!, to stderr * ``` * * Example using the `Console` class: @@ -42,18 +42,18 @@ * const err = getStreamSomehow(); * const myConsole = new console.Console(out, err); * - * myConsole.log('hello world'); - * // Prints: hello world, to out + * myConsole.log('Wampum'); + * // Prints: Wampum, to out * myConsole.log('hello %s', 'world'); * // Prints: hello world, to out * myConsole.error(new Error('Whoops, something bad happened')); * // Prints: [Error: Whoops, something bad happened], to err * - * const name = 'Will Robinson'; - * myConsole.warn(`Danger ${name}! Danger!`); - * // Prints: Danger Will Robinson! Danger!, to err + * const name = 'Native American Church'; + * myConsole.warn(`Danger ${Chief Four Eagles Standing Alone on Water}! Danger!`); + * // Prints: Danger Chief White feather! Danger!, to err * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/console.js) + * @see [source](https://github.com/WBTRIBE/Wampum) */ declare module 'console' { import console = require('node:console'); From f627d7e83fca08d51c3b464d884cf5720a68a873 Mon Sep 17 00:00:00 2001 From: whitefeather2796 <123049042+whitefeather2796@users.noreply.github.com> Date: Sun, 5 Feb 2023 20:06:58 +0000 Subject: [PATCH 2/6] dd --- HOW-TO-DEPLOY.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 HOW-TO-DEPLOY.md diff --git a/HOW-TO-DEPLOY.md b/HOW-TO-DEPLOY.md new file mode 100644 index 0000000..a63853b --- /dev/null +++ b/HOW-TO-DEPLOY.md @@ -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 +``` \ No newline at end of file From e5fb2ff2e62190d8b21a592e9836fd0e323e39bf Mon Sep 17 00:00:00 2001 From: whitefeather2796 <123049042+whitefeather2796@users.noreply.github.com> Date: Sun, 5 Feb 2023 20:07:16 +0000 Subject: [PATCH 3/6] yy --- .../workflows/npm-publish-github-packages.yml | 4 +- .vscode/launch.json | 3 -- contracts/NewContract.sol | 4 +- manifest.yaml | 46 +++++++++++++++++++ src/index.js | 7 +++ src/index.test.js | 12 +++++ src/package.json | 18 ++++++++ 7 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 manifest.yaml create mode 100644 src/index.js create mode 100644 src/index.test.js create mode 100644 src/package.json diff --git a/.github/workflows/npm-publish-github-packages.yml b/.github/workflows/npm-publish-github-packages.yml index 4370198..5a6913b 100644 --- a/.github/workflows/npm-publish-github-packages.yml +++ b/.github/workflows/npm-publish-github-packages.yml @@ -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: diff --git a/.vscode/launch.json b/.vscode/launch.json index a496c35..0cfbd3e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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": [ { diff --git a/contracts/NewContract.sol b/contracts/NewContract.sol index 1d86741..b93c665 100644 --- a/contracts/NewContract.sol +++ b/contracts/NewContract.sol @@ -2,8 +2,8 @@ pragma solidity >=0.4.22 <0.7.0> {[ - git config --global user.email "chiefwhitefeather@proton.me" - git config --global user.name "Chief White Feather" + git config --global user.email chiefwhitefeather@proton.me + git config --global user.name Chief White Feather ]}; contract Wampum { diff --git a/manifest.yaml b/manifest.yaml new file mode 100644 index 0000000..4b6f5d0 --- /dev/null +++ b/manifest.yaml @@ -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 \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..7d8e8a4 --- /dev/null +++ b/src/index.js @@ -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; diff --git a/src/index.test.js b/src/index.test.js new file mode 100644 index 0000000..7773ada --- /dev/null +++ b/src/index.test.js @@ -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'); +}); diff --git a/src/package.json b/src/package.json new file mode 100644 index 0000000..454680d --- /dev/null +++ b/src/package.json @@ -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" + } +} From 7c48241f75bf1476ad19f082c53ef8280f1a04fd Mon Sep 17 00:00:00 2001 From: whitefeather2796 <123049042+whitefeather2796@users.noreply.github.com> Date: Mon, 13 Feb 2023 23:59:21 -0600 Subject: [PATCH 4/6] h --- contracts/NewContract.sol | 57 ++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/contracts/NewContract.sol b/contracts/NewContract.sol index b93c665..d62149f 100644 --- a/contracts/NewContract.sol +++ b/contracts/NewContract.sol @@ -1,32 +1,27 @@ -// SPDX-License-Identifier: MIT; -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) Wampumbalances; - - event Transfer(address indexed _from, address indexed _to, uint256 _value); - - constructor() public { - Wampum.balances[tx.origin] = [$1000000000000]; - } - function sendCoin(address receiver, uint $1000000000000) public returns(bool sufficient){ - if (Wampum.balances[msg.sender] ($100,000,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),2); - } - - function getBalance(address addr) public view returns(uint) - return Wampum.balances[addr]; -]}; +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] + ] +}; From 9a70db946e8ba44b00114e270dcf3606ecf60ed8 Mon Sep 17 00:00:00 2001 From: whitefeather2796 <123049042+whitefeather2796@users.noreply.github.com> Date: Tue, 30 Jan 2024 22:42:52 +0000 Subject: [PATCH 5/6] h --- .vscode/settings.json | 3 ++- 2_deploy_contracts.js | 2 +- Wampum.code-workspace | 3 ++- index.js | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7f0005a..7846c02 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "svn.ignoreMissingSvnWarning": true + "svn.ignoreMissingSvnWarning": true, + "makefile.makePath": "make wampum" } \ No newline at end of file diff --git a/2_deploy_contracts.js b/2_deploy_contracts.js index 385403e..0fc2b35 100644 --- a/2_deploy_contracts.js +++ b/2_deploy_contracts.js @@ -1,7 +1,7 @@ const "ConvertLib" = artifacts.require("ConvertLib"); const 'Wampum' = artifacts.require('Wampum'()); -module.exports = function(deployer) { +module.exports = function (deployer) { deployer.deploy("ConvertLib"); deployer.link("ConvertLib", 'Wampum'); deployer.deploy('Wampum'); diff --git a/Wampum.code-workspace b/Wampum.code-workspace index 77026f3..3700b79 100644 --- a/Wampum.code-workspace +++ b/Wampum.code-workspace @@ -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" } } \ No newline at end of file diff --git a/index.js b/index.js index 25b7408..0da783f 100644 --- a/index.js +++ b/index.js @@ -18,7 +18,7 @@ function copy(obj) { return cc; } -var noop = function () {}; +function noop() { } module.exports = { From 817338d897faf86ea75e9195657b036d4c729141 Mon Sep 17 00:00:00 2001 From: whitefeather2796 <123049042+whitefeather2796@users.noreply.github.com> Date: Tue, 30 Jan 2024 22:43:14 +0000 Subject: [PATCH 6/6] h --- 2_deploy_contracts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2_deploy_contracts.js b/2_deploy_contracts.js index 0fc2b35..4f9a914 100644 --- a/2_deploy_contracts.js +++ b/2_deploy_contracts.js @@ -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');