From 60ee6a3af28489077c4becbb29c7d18e56cf93b8 Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Tue, 28 Dec 2021 23:10:02 +0300 Subject: [PATCH] near signing node --- .../near-signing-node/.gitignore | 6 +- .../near-signing-node/package.json | 5 +- .../src/_aqua/near_signing_node.ts | 542 ------------------ .../price-oracle/client-peer/.gitignore | 5 +- 4 files changed, 12 insertions(+), 546 deletions(-) delete mode 100644 aqua-examples/near-integration/near-signing-node/src/_aqua/near_signing_node.ts diff --git a/aqua-examples/near-integration/near-signing-node/.gitignore b/aqua-examples/near-integration/near-signing-node/.gitignore index 0a9f66f..893da1f 100644 --- a/aqua-examples/near-integration/near-signing-node/.gitignore +++ b/aqua-examples/near-integration/near-signing-node/.gitignore @@ -43,4 +43,8 @@ yarn.lock package-lock.json .bak -.bk \ No newline at end of file +.bk + +# fluence + +src/_aqua/* \ No newline at end of file diff --git a/aqua-examples/near-integration/near-signing-node/package.json b/aqua-examples/near-integration/near-signing-node/package.json index 6c098fe..a52561d 100644 --- a/aqua-examples/near-integration/near-signing-node/package.json +++ b/aqua-examples/near-integration/near-signing-node/package.json @@ -11,13 +11,14 @@ "author": "", "license": "ISC", "devDependencies": { - "@fluencelabs/aqua": "^0.5.0-249", + "@fluencelabs/aqua": "^0.5.2-256", + "@fluencelabs/aqua-lib": "^0.3.2", "chokidar-cli": "^1.2.0", "ts-node": "^10.4.0", "typescript": "^4.5.2" }, "dependencies": { - "@fluencelabs/fluence": "^0.15.3", + "@fluencelabs/fluence": "0.17.0", "@fluencelabs/fluence-network-environment": "1.0.10", "@types/sqlite3": "^3.1.7", "near-api-js": "^0.43.1" diff --git a/aqua-examples/near-integration/near-signing-node/src/_aqua/near_signing_node.ts b/aqua-examples/near-integration/near-signing-node/src/_aqua/near_signing_node.ts deleted file mode 100644 index 2163cb4..0000000 --- a/aqua-examples/near-integration/near-signing-node/src/_aqua/near_signing_node.ts +++ /dev/null @@ -1,542 +0,0 @@ -/** - * - * This file is auto-generated. Do not edit manually: changes may be erased. - * Generated by Aqua compiler: https://github.com/fluencelabs/aqua/. - * If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues - * Aqua version: 0.5.0-SNAPSHOT - * - */ -import { Fluence, FluencePeer } from '@fluencelabs/fluence'; -import { - CallParams, - callFunction, - registerService, -} from '@fluencelabs/fluence/dist/internal/compilerSupport/v2'; - - -// Services - -export interface NearSignerApiDef { - account_state: (network_id: string, account_id: string, password: string, callParams: CallParams<'network_id' | 'account_id' | 'password'>) => string | Promise; - get_balance: (network_id: string, account_id: string, password: string, callParams: CallParams<'network_id' | 'account_id' | 'password'>) => string | Promise; - send_money: (network_id: string, account_id: string, receiver_id: string, amount: string, password: string, callParams: CallParams<'network_id' | 'account_id' | 'receiver_id' | 'amount' | 'password'>) => string | Promise; -} -export function registerNearSignerApi(service: NearSignerApiDef): void; -export function registerNearSignerApi(serviceId: string, service: NearSignerApiDef): void; -export function registerNearSignerApi(peer: FluencePeer, service: NearSignerApiDef): void; -export function registerNearSignerApi(peer: FluencePeer, serviceId: string, service: NearSignerApiDef): void; - - -export function registerNearSignerApi(...args: any) { - registerService( - args, - { - "defaultServiceId" : "near", - "functions" : [ - { - "functionName" : "account_state", - "argDefs" : [ - { - "name" : "network_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "account_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "password", - "argType" : { - "tag" : "primitive" - } - } - ], - "returnType" : { - "tag" : "primitive" - } - }, - { - "functionName" : "get_balance", - "argDefs" : [ - { - "name" : "network_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "account_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "password", - "argType" : { - "tag" : "primitive" - } - } - ], - "returnType" : { - "tag" : "primitive" - } - }, - { - "functionName" : "send_money", - "argDefs" : [ - { - "name" : "network_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "account_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "receiver_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "amount", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "password", - "argType" : { - "tag" : "primitive" - } - } - ], - "returnType" : { - "tag" : "primitive" - } - } - ] -} - ); -} - -// Functions - - -export function account_state( - network_id: string, - account_id: string, - password: string, - node: string, - relay: string, - config?: {ttl?: number} -): Promise; - -export function account_state( - peer: FluencePeer, - network_id: string, - account_id: string, - password: string, - node: string, - relay: string, - config?: {ttl?: number} -): Promise; - -export function account_state(...args: any) { - - let script = ` - (xor - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) - (call %init_peer_id% ("getDataSrv" "network_id") [] network_id) - ) - (call %init_peer_id% ("getDataSrv" "account_id") [] account_id) - ) - (call %init_peer_id% ("getDataSrv" "password") [] password) - ) - (call %init_peer_id% ("getDataSrv" "node") [] node) - ) - (call %init_peer_id% ("getDataSrv" "relay") [] relay) - ) - (call -relay- ("op" "noop") []) - ) - (call relay ("op" "noop") []) - ) - (xor - (call node ("near" "account_state") [network_id account_id password] res) - (seq - (seq - (seq - (call relay ("op" "noop") []) - (call -relay- ("op" "noop") []) - ) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) - ) - (call -relay- ("op" "noop") []) - ) - ) - ) - (call relay ("op" "noop") []) - ) - (call -relay- ("op" "noop") []) - ) - (xor - (call %init_peer_id% ("callbackSrv" "response") [res]) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) - ) - ) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3]) - ) - ` - return callFunction( - args, - { - "functionName" : "account_state", - "returnType" : { - "tag" : "primitive" - }, - "argDefs" : [ - { - "name" : "network_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "account_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "password", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "node", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "relay", - "argType" : { - "tag" : "primitive" - } - } - ], - "names" : { - "relay" : "-relay-", - "getDataSrv" : "getDataSrv", - "callbackSrv" : "callbackSrv", - "responseSrv" : "callbackSrv", - "responseFnName" : "response", - "errorHandlingSrv" : "errorHandlingSrv", - "errorFnName" : "error" - } -}, - script - ) -} - - - -export function send_money( - network_id: string, - account_id: string, - receiver_id: string, - amount: string, - password: string, - node: string, - relay: string, - config?: {ttl?: number} -): Promise; - -export function send_money( - peer: FluencePeer, - network_id: string, - account_id: string, - receiver_id: string, - amount: string, - password: string, - node: string, - relay: string, - config?: {ttl?: number} -): Promise; - -export function send_money(...args: any) { - - let script = ` - (xor - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) - (call %init_peer_id% ("getDataSrv" "network_id") [] network_id) - ) - (call %init_peer_id% ("getDataSrv" "account_id") [] account_id) - ) - (call %init_peer_id% ("getDataSrv" "receiver_id") [] receiver_id) - ) - (call %init_peer_id% ("getDataSrv" "amount") [] amount) - ) - (call %init_peer_id% ("getDataSrv" "password") [] password) - ) - (call %init_peer_id% ("getDataSrv" "node") [] node) - ) - (call %init_peer_id% ("getDataSrv" "relay") [] relay) - ) - (call -relay- ("op" "noop") []) - ) - (call relay ("op" "noop") []) - ) - (xor - (call node ("near" "send_money") [network_id account_id receiver_id amount password] res) - (seq - (seq - (seq - (call relay ("op" "noop") []) - (call -relay- ("op" "noop") []) - ) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) - ) - (call -relay- ("op" "noop") []) - ) - ) - ) - (call relay ("op" "noop") []) - ) - (call -relay- ("op" "noop") []) - ) - (xor - (call %init_peer_id% ("callbackSrv" "response") [res]) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) - ) - ) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3]) - ) - ` - return callFunction( - args, - { - "functionName" : "send_money", - "returnType" : { - "tag" : "primitive" - }, - "argDefs" : [ - { - "name" : "network_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "account_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "receiver_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "amount", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "password", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "node", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "relay", - "argType" : { - "tag" : "primitive" - } - } - ], - "names" : { - "relay" : "-relay-", - "getDataSrv" : "getDataSrv", - "callbackSrv" : "callbackSrv", - "responseSrv" : "callbackSrv", - "responseFnName" : "response", - "errorHandlingSrv" : "errorHandlingSrv", - "errorFnName" : "error" - } -}, - script - ) -} - - - -export function get_balance( - network_id: string, - account_id: string, - password: string, - node: string, - relay: string, - config?: {ttl?: number} -): Promise; - -export function get_balance( - peer: FluencePeer, - network_id: string, - account_id: string, - password: string, - node: string, - relay: string, - config?: {ttl?: number} -): Promise; - -export function get_balance(...args: any) { - - let script = ` - (xor - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (seq - (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) - (call %init_peer_id% ("getDataSrv" "network_id") [] network_id) - ) - (call %init_peer_id% ("getDataSrv" "account_id") [] account_id) - ) - (call %init_peer_id% ("getDataSrv" "password") [] password) - ) - (call %init_peer_id% ("getDataSrv" "node") [] node) - ) - (call %init_peer_id% ("getDataSrv" "relay") [] relay) - ) - (call -relay- ("op" "noop") []) - ) - (call relay ("op" "noop") []) - ) - (xor - (call node ("near" "get_balance") [network_id account_id password] res) - (seq - (seq - (seq - (call relay ("op" "noop") []) - (call -relay- ("op" "noop") []) - ) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) - ) - (call -relay- ("op" "noop") []) - ) - ) - ) - (call relay ("op" "noop") []) - ) - (call -relay- ("op" "noop") []) - ) - (xor - (call %init_peer_id% ("callbackSrv" "response") [res]) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) - ) - ) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3]) - ) - ` - return callFunction( - args, - { - "functionName" : "get_balance", - "returnType" : { - "tag" : "primitive" - }, - "argDefs" : [ - { - "name" : "network_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "account_id", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "password", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "node", - "argType" : { - "tag" : "primitive" - } - }, - { - "name" : "relay", - "argType" : { - "tag" : "primitive" - } - } - ], - "names" : { - "relay" : "-relay-", - "getDataSrv" : "getDataSrv", - "callbackSrv" : "callbackSrv", - "responseSrv" : "callbackSrv", - "responseFnName" : "response", - "errorHandlingSrv" : "errorHandlingSrv", - "errorFnName" : "error" - } -}, - script - ) -} diff --git a/aqua-examples/price-oracle/client-peer/.gitignore b/aqua-examples/price-oracle/client-peer/.gitignore index 11985a1..4a6a0d1 100644 --- a/aqua-examples/price-oracle/client-peer/.gitignore +++ b/aqua-examples/price-oracle/client-peer/.gitignore @@ -1,2 +1,5 @@ dist/ -src/_aqua/ \ No newline at end of file + +# fluence + +src/_aqua/* \ No newline at end of file