-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lilyanB
committed
Jul 7, 2023
1 parent
8863b9e
commit 674f8d3
Showing
25 changed files
with
18,413 additions
and
149 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Async-calls CI | ||
|
||
on: [push] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./async-calls/contracts | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install | ||
run: npm ci | ||
|
||
- name: Code quality | ||
run: npm run fmt:check | ||
|
||
- name: Test | ||
run: npm run test |
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,43 @@ | ||
name: Async-calls Daily Deploy | ||
|
||
on: | ||
push: | ||
paths: | ||
- async-calls/** | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 7 * * *" | ||
|
||
jobs: | ||
deploy-age: | ||
defaults: | ||
run: | ||
working-directory: ./async-calls/contracts/ | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
cache: "npm" | ||
cache-dependency-path: ./async-calls/contracts/package-lock.json | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Deploy | ||
run: | | ||
if npm run deploy | grep -q "Contract deployed"; then | ||
echo "Contract successfully deployed!" | ||
else | ||
echo "Failed to deploy contract ..." | ||
exit 1 | ||
fi | ||
env: | ||
JSON_RPC_URL_PUBLIC: ${{ secrets.JSON_RPC_URL_PUBLIC }} | ||
WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
WALLET_PRIVATE_KEY="" | ||
|
||
JSON_RPC_URL_PUBLIC=https://buildnet.massa.net/api/v2:33035 |
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,5 @@ | ||
module.exports = { | ||
extends: [ | ||
'@massalabs', | ||
], | ||
}; |
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,3 @@ | ||
node_modules | ||
build | ||
.env |
File renamed without changes.
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,24 @@ | ||
{ | ||
"targets": { | ||
"coverage": { | ||
"lib": ["./node_modules/@as-covers/assembly/index.ts"], | ||
"transform": ["@as-covers/transform", "@as-pect/transform"] | ||
}, | ||
"noCoverage": { | ||
"transform": ["@as-pect/transform"] | ||
} | ||
}, | ||
"options": { | ||
"exportMemory": true, | ||
"outFile": "output.wasm", | ||
"textFile": "output.wat", | ||
"bindings": "raw", | ||
"exportStart": "_start", | ||
"exportRuntime": true, | ||
"use": ["RTRACE=1"], | ||
"debug": true, | ||
"exportTable": true | ||
}, | ||
"extends": "./asconfig.json", | ||
"entries": ["./node_modules/@as-pect/assembly/assembly/index.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,28 @@ | ||
import createMockedABI from '@massalabs/massa-as-sdk/vm-mock'; | ||
|
||
export default { | ||
/** | ||
* A set of globs passed to the glob package that qualify typescript files for testing. | ||
*/ | ||
entries: ['assembly/__tests__/**/*.spec.ts'], | ||
/** | ||
* A set of globs passed to the glob package that quality files to be added to each test. | ||
*/ | ||
include: ['assembly/__tests__/**/*.include.ts'], | ||
/** | ||
* A set of regexp that will disclude source files from testing. | ||
*/ | ||
disclude: [/node_modules/], | ||
/** | ||
* Add your required AssemblyScript imports here. | ||
*/ | ||
async instantiate(memory, createImports, instantiate, binary) { | ||
return createMockedABI(memory, createImports, instantiate, binary); | ||
}, | ||
/** Enable code coverage. */ | ||
// coverage: ["assembly/**/*.ts"], | ||
/** | ||
* Specify if the binary wasm file should be written to the file system. | ||
*/ | ||
outputBinary: false, | ||
}; |
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,21 @@ | ||
{ | ||
"targets": { | ||
"debug": { | ||
"outFile": "build/main.wasm", | ||
"sourceMap": true, | ||
"debug": true | ||
}, | ||
"release": { | ||
"outFile": "build/main.wasm", | ||
"sourceMap": true, | ||
"optimizeLevel": 3, | ||
"shrinkLevel": 0, | ||
"converge": false, | ||
"noAssert": false | ||
} | ||
}, | ||
"options": { | ||
"exportRuntime": true, | ||
"bindings": "esm" | ||
} | ||
} |
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 @@ | ||
/// <reference types="@as-pect/assembly/types/as-pect" /> |
File renamed without changes.
72 changes: 72 additions & 0 deletions
72
async-calls/contracts/assembly/contracts/sendHelloAsyncMessage.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,72 @@ | ||
import { Args } from '@massalabs/as-types'; | ||
/** *********************** | ||
* | ||
* SendHelloAsyncMessage sends an asynchronous message to a previous deployed contract containing a message handler function | ||
**/ | ||
|
||
import { | ||
sendMessage, | ||
callerHasWriteAccess, | ||
Address, | ||
} from '@massalabs/massa-as-sdk'; | ||
import { currentPeriod } from '@massalabs/massa-as-sdk/assembly/std/context'; | ||
|
||
/** | ||
* This function is meant to be called only one time: when the contract is deployed. | ||
*/ | ||
export function constructor(binaryArgs: StaticArray<u8>): StaticArray<u8> { | ||
// This line is important. It ensure that this function can't be called in the future. | ||
// If you remove this check someone could call your constructor function and reset your SC. | ||
if (!callerHasWriteAccess()) { | ||
return []; | ||
} | ||
sendHelloAsyncMessage(binaryArgs); | ||
return []; | ||
} | ||
|
||
/** | ||
* @param binaryArgs - The address of the receive message contract encoded with `Args` | ||
* @returns empty array | ||
*/ | ||
export function sendHelloAsyncMessage( | ||
binaryArgs: StaticArray<u8>, | ||
): StaticArray<u8> { | ||
// Setup the 'message' we will send to our deployed SC | ||
const functionName = 'receive'; | ||
const current_period = currentPeriod(); | ||
const validityStartPeriod = current_period + 1; | ||
const validityStartThread = 13 as u8; | ||
const validityEndPeriod = current_period + 20; | ||
const validityEndThread = 13 as u8; | ||
const maxGas = 1_000_000_000; // gas for smart contract execution. | ||
const rawFee = 0; | ||
const coins = 100; // coins that can be used inside SC. | ||
const msg = new Args().add('hello my good friend!').serialize(); | ||
|
||
const args = new Args(binaryArgs); | ||
|
||
const address = new Address( | ||
args.nextString().expect('Address argument is missing or invalid'), | ||
); | ||
|
||
// Send the message | ||
sendMessage( | ||
address, | ||
functionName, | ||
validityStartPeriod, | ||
validityStartThread, | ||
validityEndPeriod, | ||
validityEndThread, | ||
maxGas, | ||
rawFee, | ||
coins, | ||
msg, | ||
); | ||
|
||
return []; | ||
} |
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,14 @@ | ||
{ | ||
"extends": "assemblyscript/std/assembly.json", | ||
"include": [ | ||
"**/*.ts" | ||
], | ||
"typedocOptions": { | ||
"exclude": "assembly/**/__tests__", | ||
"excludePrivate": true, | ||
"excludeProtected": true, | ||
"excludeExternals": true, | ||
"includeVersion": true, | ||
"skipErrorChecking": true | ||
} | ||
} |
Oops, something went wrong.