mirror of
https://github.com/fluencelabs/examples
synced 2024-12-04 19:20:17 +00:00
near signing node
This commit is contained in:
parent
36f6479107
commit
60ee6a3af2
@ -43,4 +43,8 @@ yarn.lock
|
||||
package-lock.json
|
||||
|
||||
.bak
|
||||
.bk
|
||||
.bk
|
||||
|
||||
# fluence
|
||||
|
||||
src/_aqua/*
|
@ -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"
|
||||
|
@ -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<string>;
|
||||
get_balance: (network_id: string, account_id: string, password: string, callParams: CallParams<'network_id' | 'account_id' | 'password'>) => string | Promise<string>;
|
||||
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<string>;
|
||||
}
|
||||
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<string>;
|
||||
|
||||
export function account_state(
|
||||
peer: FluencePeer,
|
||||
network_id: string,
|
||||
account_id: string,
|
||||
password: string,
|
||||
node: string,
|
||||
relay: string,
|
||||
config?: {ttl?: number}
|
||||
): Promise<string>;
|
||||
|
||||
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<string>;
|
||||
|
||||
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<string>;
|
||||
|
||||
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<string>;
|
||||
|
||||
export function get_balance(
|
||||
peer: FluencePeer,
|
||||
network_id: string,
|
||||
account_id: string,
|
||||
password: string,
|
||||
node: string,
|
||||
relay: string,
|
||||
config?: {ttl?: number}
|
||||
): Promise<string>;
|
||||
|
||||
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
|
||||
)
|
||||
}
|
@ -1,2 +1,5 @@
|
||||
dist/
|
||||
src/_aqua/
|
||||
|
||||
# fluence
|
||||
|
||||
src/_aqua/*
|
Loading…
Reference in New Issue
Block a user