mirror of
https://github.com/fluencelabs/examples
synced 2024-12-04 19:20:17 +00:00
Update getting-started example
This commit is contained in:
parent
0b8637aa4c
commit
33556cabdb
253
quickstart/1-browser-to-browser/package-lock.json
generated
253
quickstart/1-browser-to-browser/package-lock.json
generated
@ -8,7 +8,7 @@
|
||||
"name": "getting-started-browser",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.12.0",
|
||||
"@fluencelabs/fluence": "^0.14.2",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.10",
|
||||
"@testing-library/jest-dom": "^5.14.1",
|
||||
"@testing-library/react": "^11.2.7",
|
||||
@ -24,7 +24,7 @@
|
||||
"web-vitals": "^1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua": "^0.3.0-226",
|
||||
"@fluencelabs/aqua": "^0.4.0-234",
|
||||
"@fluencelabs/aqua-lib": "0.1.14",
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"node-sass": "^6.0.1"
|
||||
@ -1953,14 +1953,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/aqua": {
|
||||
"version": "0.3.0-226",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.3.0-226.tgz",
|
||||
"integrity": "sha512-9o0TdgsVNcBvifqo7VqIkN62P9EReE0LUxgWG1rGHi9yxJiGElvEBvrVUzqShffF66Ene7VGEe85lhFIGCfDgg==",
|
||||
"version": "0.4.0-234",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.4.0-234.tgz",
|
||||
"integrity": "sha512-7ysLPh3R4gAfXgO24OGT7rP5UGKUHs7ipfx4HTJsYZahZ0rMbWA98uC/aM3+q0WH1WEowyV16zvGACONFLZ5RA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.12.1"
|
||||
},
|
||||
"bin": {
|
||||
"aqua": "index.js",
|
||||
"aqua-cli": "error.js",
|
||||
"aqua-j": "index-java.js"
|
||||
"aqua-cli": "error.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/aqua-lib": {
|
||||
@ -1969,37 +1971,11 @@
|
||||
"integrity": "sha512-H2Q4gIvociUxc4J2mwmH0D+mrU2N2Z+enKCHgBCanMVEE2wZDsZ80GTbDKsQjEq+gpqbnJIk8lJBYW6lyvLJTg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@fluencelabs/avm": {
|
||||
"version": "0.14.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.14.4.tgz",
|
||||
"integrity": "sha512-XyR+1H5k0CAc+mDHOkl81viX8XeW1Yqbw793xbsfUfju5bUb/hqk+gHv3q8lAFdbrCG5P45gdOT08a5RNODZaQ==",
|
||||
"dependencies": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm/node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.12.0.tgz",
|
||||
"integrity": "sha512-eYg3CflqeqlWUoaXXXUBxls7Pzjytp1nkHZWoe39bL7poF20T1BuTovNWo/jTWma5HS4L1FaAGGRNaMcN0wFHQ==",
|
||||
"node_modules/@fluencelabs/aqua/node_modules/@fluencelabs/fluence": {
|
||||
"version": "0.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.12.1.tgz",
|
||||
"integrity": "sha512-JrMKMHjYILAHQsLLd5H0fLt/UMZv+/PQYxJYe6h9HFyJlZrN1bUV+EcZnUw1u3DZE5k/RXBx0udfmkahggwrqA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.14.4",
|
||||
@ -2015,34 +1991,56 @@
|
||||
"libp2p-websockets": "0.16.1",
|
||||
"loglevel": "1.7.0",
|
||||
"multiaddr": "10.0.0",
|
||||
"noble-ed25519": "^1.2.5",
|
||||
"peer-id": "0.15.3",
|
||||
"uuid": "8.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm": {
|
||||
"version": "0.14.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.14.4.tgz",
|
||||
"integrity": "sha512-XyR+1H5k0CAc+mDHOkl81viX8XeW1Yqbw793xbsfUfju5bUb/hqk+gHv3q8lAFdbrCG5P45gdOT08a5RNODZaQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence": {
|
||||
"version": "0.14.2",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.14.2.tgz",
|
||||
"integrity": "sha512-Cf5Ii6dpVSSi839jB7H0Y9k07xncYdHiTNKp4LlPg6inXuy2OPb2E7qF5DXlMM9O1dBb/UJTa4jZlQDsgWriiQ==",
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.15.4",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.5.1",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
"it-length-prefixed": "3.0.1",
|
||||
"it-pipe": "1.1.0",
|
||||
"libp2p": "0.32.3",
|
||||
"libp2p-crypto": "0.19.7",
|
||||
"libp2p-mplex": "0.10.4",
|
||||
"libp2p-websockets": "0.16.1",
|
||||
"loglevel": "1.7.0",
|
||||
"multiaddr": "10.0.0",
|
||||
"peer-id": "0.15.3",
|
||||
"rxjs": "^7.3.0",
|
||||
"ts-pattern": "^3.3.3",
|
||||
"uuid": "8.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence-network-environment": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence-network-environment/-/fluence-network-environment-1.0.10.tgz",
|
||||
"integrity": "sha512-aaWZDDFIIasSTgdFdw1KEz+boZMSn7pXffUENZNLX4DrP11rC3AEX4c8GnIJQbWqGsouOFZOPna2DSG6o2rLNQ=="
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence/node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
"node_modules/@fluencelabs/fluence/node_modules/@fluencelabs/avm": {
|
||||
"version": "0.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.15.4.tgz",
|
||||
"integrity": "sha512-NLZDq83ocJ1Helm0D8kPMSSkjxH0y+Tujg0px773zjIShbh3jgiJOjAW1xCYgTt9K0LqepjP0bWX4/8nUZfr7g==",
|
||||
"dependencies": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@gar/promisify": {
|
||||
"version": "1.1.2",
|
||||
@ -5093,9 +5091,23 @@
|
||||
}
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
|
||||
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/batch": {
|
||||
"version": "0.6.1",
|
||||
@ -14864,11 +14876,6 @@
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
},
|
||||
"node_modules/noble-ed25519": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/noble-ed25519/-/noble-ed25519-1.2.5.tgz",
|
||||
"integrity": "sha512-7vst+4UhM5QU3jJ3pUqPMKBCOePrxBojmoQa59qcSnYvjFF/T4jqb4WISlfslcWyBw7G5H9V/acpcAxMd8DzUQ=="
|
||||
},
|
||||
"node_modules/node-addon-api": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
|
||||
@ -19043,6 +19050,19 @@
|
||||
"aproba": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/rxjs": {
|
||||
"version": "7.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz",
|
||||
"integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==",
|
||||
"dependencies": {
|
||||
"tslib": "~2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rxjs/node_modules/tslib": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
|
||||
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A=="
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
@ -21411,6 +21431,11 @@
|
||||
"resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz",
|
||||
"integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA=="
|
||||
},
|
||||
"node_modules/ts-pattern": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-3.3.3.tgz",
|
||||
"integrity": "sha512-Z5EFi6g6wyX3uDFHqxF5W5c5h663oZg9O6aOiAT7fqNu0HPSfCxtHzrQ7SblTy738Mrg2Ezorky8H5aUOm8Pvg=="
|
||||
},
|
||||
"node_modules/ts-pnp": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.2.0.tgz",
|
||||
@ -25314,10 +25339,39 @@
|
||||
}
|
||||
},
|
||||
"@fluencelabs/aqua": {
|
||||
"version": "0.3.0-226",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.3.0-226.tgz",
|
||||
"integrity": "sha512-9o0TdgsVNcBvifqo7VqIkN62P9EReE0LUxgWG1rGHi9yxJiGElvEBvrVUzqShffF66Ene7VGEe85lhFIGCfDgg==",
|
||||
"dev": true
|
||||
"version": "0.4.0-234",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.4.0-234.tgz",
|
||||
"integrity": "sha512-7ysLPh3R4gAfXgO24OGT7rP5UGKUHs7ipfx4HTJsYZahZ0rMbWA98uC/aM3+q0WH1WEowyV16zvGACONFLZ5RA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@fluencelabs/fluence": "0.12.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": {
|
||||
"version": "0.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.12.1.tgz",
|
||||
"integrity": "sha512-JrMKMHjYILAHQsLLd5H0fLt/UMZv+/PQYxJYe6h9HFyJlZrN1bUV+EcZnUw1u3DZE5k/RXBx0udfmkahggwrqA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.14.4",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.5.1",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
"it-length-prefixed": "3.0.1",
|
||||
"it-pipe": "1.1.0",
|
||||
"libp2p": "0.32.3",
|
||||
"libp2p-crypto": "0.19.7",
|
||||
"libp2p-mplex": "0.10.4",
|
||||
"libp2p-websockets": "0.16.1",
|
||||
"loglevel": "1.7.0",
|
||||
"multiaddr": "10.0.0",
|
||||
"peer-id": "0.15.3",
|
||||
"uuid": "8.3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@fluencelabs/aqua-lib": {
|
||||
"version": "0.1.14",
|
||||
@ -25329,24 +25383,18 @@
|
||||
"version": "0.14.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.14.4.tgz",
|
||||
"integrity": "sha512-XyR+1H5k0CAc+mDHOkl81viX8XeW1Yqbw793xbsfUfju5bUb/hqk+gHv3q8lAFdbrCG5P45gdOT08a5RNODZaQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"base64-js": "1.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@fluencelabs/fluence": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.12.0.tgz",
|
||||
"integrity": "sha512-eYg3CflqeqlWUoaXXXUBxls7Pzjytp1nkHZWoe39bL7poF20T1BuTovNWo/jTWma5HS4L1FaAGGRNaMcN0wFHQ==",
|
||||
"version": "0.14.2",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.14.2.tgz",
|
||||
"integrity": "sha512-Cf5Ii6dpVSSi839jB7H0Y9k07xncYdHiTNKp4LlPg6inXuy2OPb2E7qF5DXlMM9O1dBb/UJTa4jZlQDsgWriiQ==",
|
||||
"requires": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.14.4",
|
||||
"@fluencelabs/avm": "0.15.4",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.5.1",
|
||||
"bs58": "4.0.1",
|
||||
@ -25359,15 +25407,19 @@
|
||||
"libp2p-websockets": "0.16.1",
|
||||
"loglevel": "1.7.0",
|
||||
"multiaddr": "10.0.0",
|
||||
"noble-ed25519": "^1.2.5",
|
||||
"peer-id": "0.15.3",
|
||||
"rxjs": "^7.3.0",
|
||||
"ts-pattern": "^3.3.3",
|
||||
"uuid": "8.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
"@fluencelabs/avm": {
|
||||
"version": "0.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.15.4.tgz",
|
||||
"integrity": "sha512-NLZDq83ocJ1Helm0D8kPMSSkjxH0y+Tujg0px773zjIShbh3jgiJOjAW1xCYgTt9K0LqepjP0bWX4/8nUZfr7g==",
|
||||
"requires": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -27801,9 +27853,9 @@
|
||||
}
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
|
||||
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
},
|
||||
"batch": {
|
||||
"version": "0.6.1",
|
||||
@ -35539,11 +35591,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"noble-ed25519": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/noble-ed25519/-/noble-ed25519-1.2.5.tgz",
|
||||
"integrity": "sha512-7vst+4UhM5QU3jJ3pUqPMKBCOePrxBojmoQa59qcSnYvjFF/T4jqb4WISlfslcWyBw7G5H9V/acpcAxMd8DzUQ=="
|
||||
},
|
||||
"node-addon-api": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
|
||||
@ -38855,6 +38902,21 @@
|
||||
"aproba": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"rxjs": {
|
||||
"version": "7.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz",
|
||||
"integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==",
|
||||
"requires": {
|
||||
"tslib": "~2.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
|
||||
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
@ -40791,6 +40853,11 @@
|
||||
"resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz",
|
||||
"integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA=="
|
||||
},
|
||||
"ts-pattern": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-3.3.3.tgz",
|
||||
"integrity": "sha512-Z5EFi6g6wyX3uDFHqxF5W5c5h663oZg9O6aOiAT7fqNu0HPSfCxtHzrQ7SblTy738Mrg2Ezorky8H5aUOm8Pvg=="
|
||||
},
|
||||
"ts-pnp": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.2.0.tgz",
|
||||
|
@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.12.0",
|
||||
"@fluencelabs/fluence": "^0.14.2",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.10",
|
||||
"@testing-library/jest-dom": "^5.14.1",
|
||||
"@testing-library/react": "^11.2.7",
|
||||
@ -45,7 +45,7 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua": "^0.3.0-226",
|
||||
"@fluencelabs/aqua": "^0.4.0-234",
|
||||
"@fluencelabs/aqua-lib": "0.1.14",
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"node-sass": "^6.0.1"
|
||||
|
@ -1,187 +1,138 @@
|
||||
/**
|
||||
*
|
||||
* This file is auto-generated. Do not edit manually: changes may be erased.
|
||||
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
|
||||
* 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.3.0-226
|
||||
* Aqua version: 0.4.0-234
|
||||
*
|
||||
*/
|
||||
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
||||
import {
|
||||
ResultCodes,
|
||||
RequestFlow,
|
||||
RequestFlowBuilder,
|
||||
CallParams,
|
||||
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v1';
|
||||
callFunction,
|
||||
registerService,
|
||||
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v2';
|
||||
|
||||
|
||||
// Services
|
||||
|
||||
export interface HelloPeerDef {
|
||||
hello: (from: string, callParams: CallParams<'from'>) => string;
|
||||
}
|
||||
|
||||
export function registerHelloPeer(service: HelloPeerDef): void;
|
||||
export interface HelloPeerDef {
|
||||
hello: (from: string, callParams: CallParams<'from'>) => string | Promise<string>;
|
||||
}
|
||||
export function registerHelloPeer(service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(serviceId: string, service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(peer: FluencePeer, service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(peer: FluencePeer, serviceId: string, service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let serviceId: any;
|
||||
let service: any;
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
} else {
|
||||
peer = Fluence.getPeer();
|
||||
}
|
||||
|
||||
|
||||
if (typeof args[0] === 'string') {
|
||||
serviceId = args[0];
|
||||
} else if (typeof args[1] === 'string') {
|
||||
serviceId = args[1];
|
||||
}
|
||||
else {
|
||||
serviceId = "HelloPeer"
|
||||
}
|
||||
|
||||
// Figuring out which overload is the service.
|
||||
// If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||
// If the first argument is peer, we are checking further. The second argument might either be
|
||||
// an object, that it must be the service object
|
||||
// or a string, which is the service id. In that case the service is the third argument
|
||||
if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
|
||||
service = args[0];
|
||||
} else if (typeof args[1] === 'object') {
|
||||
service = args[1];
|
||||
} else {
|
||||
service = args[2];
|
||||
}
|
||||
|
||||
peer.internals.callServiceHandler.use((req, resp, next) => {
|
||||
if (req.serviceId !== serviceId) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (req.fnName === 'hello') {
|
||||
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {
|
||||
from: req.tetraplets[0]
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
resp.result = service.hello(req.args[0], callParams)
|
||||
|
||||
}
|
||||
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
export function sayHello(targetPeerId: string, targetRelayPeerId: string, config?: {ttl?: number}) : Promise<string>;
|
||||
export function sayHello(peer: FluencePeer, targetPeerId: string, targetRelayPeerId: string, config?: {ttl?: number}) : Promise<string>;
|
||||
export function sayHello(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let targetPeerId: any;
|
||||
let targetRelayPeerId: any;
|
||||
let config: any;
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
targetPeerId = args[1];
|
||||
targetRelayPeerId = args[2];
|
||||
config = args[3];
|
||||
} else {
|
||||
peer = Fluence.getPeer();
|
||||
targetPeerId = args[0];
|
||||
targetRelayPeerId = args[1];
|
||||
config = args[2];
|
||||
}
|
||||
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<string>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "targetPeerId") [] targetPeerId)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "targetRelayPeerId") [] targetRelayPeerId)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call targetRelayPeerId ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(call targetPeerId ("HelloPeer" "hello") [%init_peer_id%] res)
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call targetRelayPeerId ("op" "noop") [])
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call targetRelayPeerId ("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])
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'targetPeerId', () => {return targetPeerId;});
|
||||
h.on('getDataSrv', 'targetRelayPeerId', () => {return targetRelayPeerId;});
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for sayHello');
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
export function registerHelloPeer(...args: any) {
|
||||
registerService(
|
||||
args,
|
||||
{
|
||||
"defaultServiceId" : "HelloPeer",
|
||||
"functions" : [
|
||||
{
|
||||
"functionName" : "hello",
|
||||
"argDefs" : [
|
||||
{
|
||||
"name" : "from",
|
||||
"argType" : {
|
||||
"tag" : "primitive"
|
||||
}
|
||||
}
|
||||
],
|
||||
"returnType" : {
|
||||
"tag" : "primitive"
|
||||
}
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
peer.internals.initiateFlow(request!);
|
||||
return promise;
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
|
||||
export function sayHello(targetPeerId: string, targetRelayPeerId: string, config?: {ttl?: number}): Promise<string>;
|
||||
export function sayHello(peer: FluencePeer, targetPeerId: string, targetRelayPeerId: string, config?: {ttl?: number}): Promise<string>;
|
||||
export function sayHello(...args: any) {
|
||||
|
||||
let script = `
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "targetPeerId") [] targetPeerId)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "targetRelayPeerId") [] targetRelayPeerId)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call targetRelayPeerId ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(call targetPeerId ("HelloPeer" "hello") [%init_peer_id%] res)
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call targetRelayPeerId ("op" "noop") [])
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call targetRelayPeerId ("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" : "sayHello",
|
||||
"returnType" : {
|
||||
"tag" : "primitive"
|
||||
},
|
||||
"argDefs" : [
|
||||
{
|
||||
"name" : "targetPeerId",
|
||||
"argType" : {
|
||||
"tag" : "primitive"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "targetRelayPeerId",
|
||||
"argType" : {
|
||||
"tag" : "primitive"
|
||||
}
|
||||
}
|
||||
],
|
||||
"names" : {
|
||||
"relay" : "-relay-",
|
||||
"getDataSrv" : "getDataSrv",
|
||||
"callbackSrv" : "callbackSrv",
|
||||
"responseSrv" : "callbackSrv",
|
||||
"responseFnName" : "response",
|
||||
"errorHandlingSrv" : "errorHandlingSrv",
|
||||
"errorFnName" : "error"
|
||||
}
|
||||
},
|
||||
script
|
||||
)
|
||||
}
|
||||
|
251
quickstart/3-browser-to-service/package-lock.json
generated
251
quickstart/3-browser-to-service/package-lock.json
generated
@ -8,7 +8,7 @@
|
||||
"name": "getting-started-browser",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.12.0",
|
||||
"@fluencelabs/fluence": "^0.14.2",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.10",
|
||||
"@testing-library/jest-dom": "^5.14.1",
|
||||
"@testing-library/react": "^11.2.7",
|
||||
@ -24,7 +24,7 @@
|
||||
"web-vitals": "^1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua": "^0.3.0-226",
|
||||
"@fluencelabs/aqua": "^0.4.0-234",
|
||||
"@fluencelabs/aqua-lib": "0.1.14",
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"node-sass": "^6.0.1"
|
||||
@ -1953,14 +1953,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/aqua": {
|
||||
"version": "0.3.0-226",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.3.0-226.tgz",
|
||||
"integrity": "sha512-9o0TdgsVNcBvifqo7VqIkN62P9EReE0LUxgWG1rGHi9yxJiGElvEBvrVUzqShffF66Ene7VGEe85lhFIGCfDgg==",
|
||||
"version": "0.4.0-234",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.4.0-234.tgz",
|
||||
"integrity": "sha512-7ysLPh3R4gAfXgO24OGT7rP5UGKUHs7ipfx4HTJsYZahZ0rMbWA98uC/aM3+q0WH1WEowyV16zvGACONFLZ5RA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.12.1"
|
||||
},
|
||||
"bin": {
|
||||
"aqua": "index.js",
|
||||
"aqua-cli": "error.js",
|
||||
"aqua-j": "index-java.js"
|
||||
"aqua-cli": "error.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/aqua-lib": {
|
||||
@ -1969,37 +1971,20 @@
|
||||
"integrity": "sha512-H2Q4gIvociUxc4J2mwmH0D+mrU2N2Z+enKCHgBCanMVEE2wZDsZ80GTbDKsQjEq+gpqbnJIk8lJBYW6lyvLJTg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@fluencelabs/avm": {
|
||||
"node_modules/@fluencelabs/aqua/node_modules/@fluencelabs/avm": {
|
||||
"version": "0.14.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.14.4.tgz",
|
||||
"integrity": "sha512-XyR+1H5k0CAc+mDHOkl81viX8XeW1Yqbw793xbsfUfju5bUb/hqk+gHv3q8lAFdbrCG5P45gdOT08a5RNODZaQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm/node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.12.0.tgz",
|
||||
"integrity": "sha512-eYg3CflqeqlWUoaXXXUBxls7Pzjytp1nkHZWoe39bL7poF20T1BuTovNWo/jTWma5HS4L1FaAGGRNaMcN0wFHQ==",
|
||||
"node_modules/@fluencelabs/aqua/node_modules/@fluencelabs/fluence": {
|
||||
"version": "0.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.12.1.tgz",
|
||||
"integrity": "sha512-JrMKMHjYILAHQsLLd5H0fLt/UMZv+/PQYxJYe6h9HFyJlZrN1bUV+EcZnUw1u3DZE5k/RXBx0udfmkahggwrqA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.14.4",
|
||||
@ -2015,35 +2000,48 @@
|
||||
"libp2p-websockets": "0.16.1",
|
||||
"loglevel": "1.7.0",
|
||||
"multiaddr": "10.0.0",
|
||||
"noble-ed25519": "^1.2.5",
|
||||
"peer-id": "0.15.3",
|
||||
"uuid": "8.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm": {
|
||||
"version": "0.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.15.4.tgz",
|
||||
"integrity": "sha512-NLZDq83ocJ1Helm0D8kPMSSkjxH0y+Tujg0px773zjIShbh3jgiJOjAW1xCYgTt9K0LqepjP0bWX4/8nUZfr7g==",
|
||||
"dependencies": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence": {
|
||||
"version": "0.14.2",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.14.2.tgz",
|
||||
"integrity": "sha512-Cf5Ii6dpVSSi839jB7H0Y9k07xncYdHiTNKp4LlPg6inXuy2OPb2E7qF5DXlMM9O1dBb/UJTa4jZlQDsgWriiQ==",
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.15.4",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.5.1",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
"it-length-prefixed": "3.0.1",
|
||||
"it-pipe": "1.1.0",
|
||||
"libp2p": "0.32.3",
|
||||
"libp2p-crypto": "0.19.7",
|
||||
"libp2p-mplex": "0.10.4",
|
||||
"libp2p-websockets": "0.16.1",
|
||||
"loglevel": "1.7.0",
|
||||
"multiaddr": "10.0.0",
|
||||
"peer-id": "0.15.3",
|
||||
"rxjs": "^7.3.0",
|
||||
"ts-pattern": "^3.3.3",
|
||||
"uuid": "8.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence-network-environment": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence-network-environment/-/fluence-network-environment-1.0.10.tgz",
|
||||
"integrity": "sha512-aaWZDDFIIasSTgdFdw1KEz+boZMSn7pXffUENZNLX4DrP11rC3AEX4c8GnIJQbWqGsouOFZOPna2DSG6o2rLNQ=="
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence/node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/@gar/promisify": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.2.tgz",
|
||||
@ -5093,9 +5091,23 @@
|
||||
}
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
|
||||
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/batch": {
|
||||
"version": "0.6.1",
|
||||
@ -14864,11 +14876,6 @@
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
},
|
||||
"node_modules/noble-ed25519": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/noble-ed25519/-/noble-ed25519-1.2.5.tgz",
|
||||
"integrity": "sha512-7vst+4UhM5QU3jJ3pUqPMKBCOePrxBojmoQa59qcSnYvjFF/T4jqb4WISlfslcWyBw7G5H9V/acpcAxMd8DzUQ=="
|
||||
},
|
||||
"node_modules/node-addon-api": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
|
||||
@ -19043,6 +19050,19 @@
|
||||
"aproba": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/rxjs": {
|
||||
"version": "7.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz",
|
||||
"integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==",
|
||||
"dependencies": {
|
||||
"tslib": "~2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rxjs/node_modules/tslib": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
|
||||
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A=="
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
@ -21411,6 +21431,11 @@
|
||||
"resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz",
|
||||
"integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA=="
|
||||
},
|
||||
"node_modules/ts-pattern": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-3.3.3.tgz",
|
||||
"integrity": "sha512-Z5EFi6g6wyX3uDFHqxF5W5c5h663oZg9O6aOiAT7fqNu0HPSfCxtHzrQ7SblTy738Mrg2Ezorky8H5aUOm8Pvg=="
|
||||
},
|
||||
"node_modules/ts-pnp": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.2.0.tgz",
|
||||
@ -25314,10 +25339,48 @@
|
||||
}
|
||||
},
|
||||
"@fluencelabs/aqua": {
|
||||
"version": "0.3.0-226",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.3.0-226.tgz",
|
||||
"integrity": "sha512-9o0TdgsVNcBvifqo7VqIkN62P9EReE0LUxgWG1rGHi9yxJiGElvEBvrVUzqShffF66Ene7VGEe85lhFIGCfDgg==",
|
||||
"dev": true
|
||||
"version": "0.4.0-234",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.4.0-234.tgz",
|
||||
"integrity": "sha512-7ysLPh3R4gAfXgO24OGT7rP5UGKUHs7ipfx4HTJsYZahZ0rMbWA98uC/aM3+q0WH1WEowyV16zvGACONFLZ5RA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@fluencelabs/fluence": "0.12.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fluencelabs/avm": {
|
||||
"version": "0.14.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.14.4.tgz",
|
||||
"integrity": "sha512-XyR+1H5k0CAc+mDHOkl81viX8XeW1Yqbw793xbsfUfju5bUb/hqk+gHv3q8lAFdbrCG5P45gdOT08a5RNODZaQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"@fluencelabs/fluence": {
|
||||
"version": "0.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.12.1.tgz",
|
||||
"integrity": "sha512-JrMKMHjYILAHQsLLd5H0fLt/UMZv+/PQYxJYe6h9HFyJlZrN1bUV+EcZnUw1u3DZE5k/RXBx0udfmkahggwrqA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.14.4",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.5.1",
|
||||
"bs58": "4.0.1",
|
||||
"cids": "0.8.1",
|
||||
"it-length-prefixed": "3.0.1",
|
||||
"it-pipe": "1.1.0",
|
||||
"libp2p": "0.32.3",
|
||||
"libp2p-crypto": "0.19.7",
|
||||
"libp2p-mplex": "0.10.4",
|
||||
"libp2p-websockets": "0.16.1",
|
||||
"loglevel": "1.7.0",
|
||||
"multiaddr": "10.0.0",
|
||||
"peer-id": "0.15.3",
|
||||
"uuid": "8.3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@fluencelabs/aqua-lib": {
|
||||
"version": "0.1.14",
|
||||
@ -25326,27 +25389,20 @@
|
||||
"dev": true
|
||||
},
|
||||
"@fluencelabs/avm": {
|
||||
"version": "0.14.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.14.4.tgz",
|
||||
"integrity": "sha512-XyR+1H5k0CAc+mDHOkl81viX8XeW1Yqbw793xbsfUfju5bUb/hqk+gHv3q8lAFdbrCG5P45gdOT08a5RNODZaQ==",
|
||||
"version": "0.15.4",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.15.4.tgz",
|
||||
"integrity": "sha512-NLZDq83ocJ1Helm0D8kPMSSkjxH0y+Tujg0px773zjIShbh3jgiJOjAW1xCYgTt9K0LqepjP0bWX4/8nUZfr7g==",
|
||||
"requires": {
|
||||
"base64-js": "1.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@fluencelabs/fluence": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.12.0.tgz",
|
||||
"integrity": "sha512-eYg3CflqeqlWUoaXXXUBxls7Pzjytp1nkHZWoe39bL7poF20T1BuTovNWo/jTWma5HS4L1FaAGGRNaMcN0wFHQ==",
|
||||
"version": "0.14.2",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence/-/fluence-0.14.2.tgz",
|
||||
"integrity": "sha512-Cf5Ii6dpVSSi839jB7H0Y9k07xncYdHiTNKp4LlPg6inXuy2OPb2E7qF5DXlMM9O1dBb/UJTa4jZlQDsgWriiQ==",
|
||||
"requires": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.14.4",
|
||||
"@fluencelabs/avm": "0.15.4",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.5.1",
|
||||
"bs58": "4.0.1",
|
||||
@ -25359,16 +25415,10 @@
|
||||
"libp2p-websockets": "0.16.1",
|
||||
"loglevel": "1.7.0",
|
||||
"multiaddr": "10.0.0",
|
||||
"noble-ed25519": "^1.2.5",
|
||||
"peer-id": "0.15.3",
|
||||
"rxjs": "^7.3.0",
|
||||
"ts-pattern": "^3.3.3",
|
||||
"uuid": "8.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@fluencelabs/fluence-network-environment": {
|
||||
@ -27801,9 +27851,9 @@
|
||||
}
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
|
||||
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
},
|
||||
"batch": {
|
||||
"version": "0.6.1",
|
||||
@ -35539,11 +35589,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"noble-ed25519": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/noble-ed25519/-/noble-ed25519-1.2.5.tgz",
|
||||
"integrity": "sha512-7vst+4UhM5QU3jJ3pUqPMKBCOePrxBojmoQa59qcSnYvjFF/T4jqb4WISlfslcWyBw7G5H9V/acpcAxMd8DzUQ=="
|
||||
},
|
||||
"node-addon-api": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
|
||||
@ -38855,6 +38900,21 @@
|
||||
"aproba": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"rxjs": {
|
||||
"version": "7.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz",
|
||||
"integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==",
|
||||
"requires": {
|
||||
"tslib": "~2.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
|
||||
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
@ -40791,6 +40851,11 @@
|
||||
"resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz",
|
||||
"integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA=="
|
||||
},
|
||||
"ts-pattern": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-3.3.3.tgz",
|
||||
"integrity": "sha512-Z5EFi6g6wyX3uDFHqxF5W5c5h663oZg9O6aOiAT7fqNu0HPSfCxtHzrQ7SblTy738Mrg2Ezorky8H5aUOm8Pvg=="
|
||||
},
|
||||
"ts-pnp": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.2.0.tgz",
|
||||
|
@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.12.0",
|
||||
"@fluencelabs/fluence": "^0.14.2",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.10",
|
||||
"@testing-library/jest-dom": "^5.14.1",
|
||||
"@testing-library/react": "^11.2.7",
|
||||
@ -45,7 +45,7 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua": "^0.3.0-226",
|
||||
"@fluencelabs/aqua": "^0.4.0-234",
|
||||
"@fluencelabs/aqua-lib": "0.1.14",
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"node-sass": "^6.0.1"
|
||||
|
@ -1,258 +1,200 @@
|
||||
/**
|
||||
*
|
||||
* This file is auto-generated. Do not edit manually: changes may be erased.
|
||||
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
|
||||
* 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.3.0-226
|
||||
* Aqua version: 0.4.0-234
|
||||
*
|
||||
*/
|
||||
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
||||
import { Fluence, FluencePeer } from "@fluencelabs/fluence";
|
||||
import {
|
||||
ResultCodes,
|
||||
RequestFlow,
|
||||
RequestFlowBuilder,
|
||||
CallParams,
|
||||
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v1';
|
||||
|
||||
CallParams,
|
||||
callFunction,
|
||||
registerService,
|
||||
} from "@fluencelabs/fluence/dist/internal/compilerSupport/v2";
|
||||
|
||||
// Services
|
||||
|
||||
export interface HelloWorldDef {
|
||||
hello: (from: string, callParams: CallParams<'from'>) => {msg:string;reply:string};
|
||||
}
|
||||
export interface HelloWorldDef {
|
||||
hello: (
|
||||
from: string,
|
||||
callParams: CallParams<"from">
|
||||
) => { msg: string; reply: string } | Promise<{ msg: string; reply: string }>;
|
||||
}
|
||||
export function registerHelloWorld(
|
||||
serviceId: string,
|
||||
service: HelloWorldDef
|
||||
): void;
|
||||
export function registerHelloWorld(
|
||||
peer: FluencePeer,
|
||||
serviceId: string,
|
||||
service: HelloWorldDef
|
||||
): void;
|
||||
|
||||
export function registerHelloWorld(serviceId: string, service: HelloWorldDef): void;
|
||||
export function registerHelloWorld(peer: FluencePeer, serviceId: string, service: HelloWorldDef): void;
|
||||
export function registerHelloWorld(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let serviceId: any;
|
||||
let service: any;
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
} else {
|
||||
peer = Fluence.getPeer();
|
||||
}
|
||||
|
||||
if (typeof args[0] === 'string') {
|
||||
serviceId = args[0];
|
||||
} else if (typeof args[1] === 'string') {
|
||||
serviceId = args[1];
|
||||
}
|
||||
|
||||
// Figuring out which overload is the service.
|
||||
// If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||
// If the first argument is peer, we are checking further. The second argument might either be
|
||||
// an object, that it must be the service object
|
||||
// or a string, which is the service id. In that case the service is the third argument
|
||||
if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
|
||||
service = args[0];
|
||||
} else if (typeof args[1] === 'object') {
|
||||
service = args[1];
|
||||
} else {
|
||||
service = args[2];
|
||||
}
|
||||
|
||||
peer.internals.callServiceHandler.use((req, resp, next) => {
|
||||
if (req.serviceId !== serviceId) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (req.fnName === 'hello') {
|
||||
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {
|
||||
from: req.tetraplets[0]
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
resp.result = service.hello(req.args[0], callParams)
|
||||
|
||||
}
|
||||
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
export interface HelloPeerDef {
|
||||
hello: (message: string, callParams: CallParams<'message'>) => string;
|
||||
}
|
||||
|
||||
export function registerHelloPeer(service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(serviceId: string, service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(peer: FluencePeer, service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(peer: FluencePeer, serviceId: string, service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let serviceId: any;
|
||||
let service: any;
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
} else {
|
||||
peer = Fluence.getPeer();
|
||||
}
|
||||
|
||||
if (typeof args[0] === 'string') {
|
||||
serviceId = args[0];
|
||||
} else if (typeof args[1] === 'string') {
|
||||
serviceId = args[1];
|
||||
}
|
||||
else {
|
||||
serviceId = "HelloPeer"
|
||||
export function registerHelloWorld(...args: any) {
|
||||
registerService(args, {
|
||||
defaultServiceId: undefined,
|
||||
functions: [
|
||||
{
|
||||
functionName: "hello",
|
||||
argDefs: [
|
||||
{
|
||||
name: "from",
|
||||
argType: {
|
||||
tag: "primitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
returnType: {
|
||||
tag: "primitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
// Figuring out which overload is the service.
|
||||
// If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||
// If the first argument is peer, we are checking further. The second argument might either be
|
||||
// an object, that it must be the service object
|
||||
// or a string, which is the service id. In that case the service is the third argument
|
||||
if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
|
||||
service = args[0];
|
||||
} else if (typeof args[1] === 'object') {
|
||||
service = args[1];
|
||||
} else {
|
||||
service = args[2];
|
||||
}
|
||||
export interface HelloPeerDef {
|
||||
hello: (
|
||||
message: string,
|
||||
callParams: CallParams<"message">
|
||||
) => string | Promise<string>;
|
||||
}
|
||||
export function registerHelloPeer(service: HelloPeerDef): void;
|
||||
export function registerHelloPeer(
|
||||
serviceId: string,
|
||||
service: HelloPeerDef
|
||||
): void;
|
||||
export function registerHelloPeer(
|
||||
peer: FluencePeer,
|
||||
service: HelloPeerDef
|
||||
): void;
|
||||
export function registerHelloPeer(
|
||||
peer: FluencePeer,
|
||||
serviceId: string,
|
||||
service: HelloPeerDef
|
||||
): void;
|
||||
|
||||
peer.internals.callServiceHandler.use((req, resp, next) => {
|
||||
if (req.serviceId !== serviceId) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (req.fnName === 'hello') {
|
||||
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {
|
||||
message: req.tetraplets[0]
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
resp.result = service.hello(req.args[0], callParams)
|
||||
|
||||
}
|
||||
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
export function registerHelloPeer(...args: any) {
|
||||
registerService(args, {
|
||||
defaultServiceId: "HelloPeer",
|
||||
functions: [
|
||||
{
|
||||
functionName: "hello",
|
||||
argDefs: [
|
||||
{
|
||||
name: "message",
|
||||
argType: {
|
||||
tag: "primitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
returnType: {
|
||||
tag: "primitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
export function sayHello(targetPeerId: string, targetRelayPeerId: string, config?: {ttl?: number}) : Promise<string>;
|
||||
export function sayHello(peer: FluencePeer, targetPeerId: string, targetRelayPeerId: string, config?: {ttl?: number}) : Promise<string>;
|
||||
export function sayHello(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let targetPeerId: any;
|
||||
let targetRelayPeerId: any;
|
||||
let config: any;
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
targetPeerId = args[1];
|
||||
targetRelayPeerId = args[2];
|
||||
config = args[3];
|
||||
} else {
|
||||
peer = Fluence.getPeer();
|
||||
targetPeerId = args[0];
|
||||
targetRelayPeerId = args[1];
|
||||
config = args[2];
|
||||
}
|
||||
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<string>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "targetPeerId") [] targetPeerId)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "targetRelayPeerId") [] targetRelayPeerId)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call "12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi" ("1e740ce4-81f6-4dd4-9bed-8d86e9c2fa50" "hello") [%init_peer_id%] comp)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(par
|
||||
(seq
|
||||
(call targetRelayPeerId ("op" "noop") [])
|
||||
(xor
|
||||
(call targetPeerId ("HelloPeer" "hello") [%init_peer_id%] res)
|
||||
(seq
|
||||
(seq
|
||||
(call targetRelayPeerId ("op" "noop") [])
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
)
|
||||
)
|
||||
(null)
|
||||
)
|
||||
)
|
||||
(xor
|
||||
(call %init_peer_id% ("callbackSrv" "response") [comp.$.reply!])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'targetPeerId', () => {return targetPeerId;});
|
||||
h.on('getDataSrv', 'targetRelayPeerId', () => {return targetRelayPeerId;});
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for sayHello');
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
peer.internals.initiateFlow(request!);
|
||||
return promise;
|
||||
export function sayHello(
|
||||
targetPeerId: string,
|
||||
targetRelayPeerId: string,
|
||||
config?: { ttl?: number }
|
||||
): Promise<string>;
|
||||
export function sayHello(
|
||||
peer: FluencePeer,
|
||||
targetPeerId: string,
|
||||
targetRelayPeerId: string,
|
||||
config?: { ttl?: number }
|
||||
): Promise<string>;
|
||||
export function sayHello(...args: any) {
|
||||
let script = `
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "targetPeerId") [] targetPeerId)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "targetRelayPeerId") [] targetRelayPeerId)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call "12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi" ("1e740ce4-81f6-4dd4-9bed-8d86e9c2fa50" "hello") [%init_peer_id%] comp)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(par
|
||||
(seq
|
||||
(call targetRelayPeerId ("op" "noop") [])
|
||||
(xor
|
||||
(call targetPeerId ("HelloPeer" "hello") [%init_peer_id%] res)
|
||||
(seq
|
||||
(seq
|
||||
(call targetRelayPeerId ("op" "noop") [])
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
)
|
||||
)
|
||||
(null)
|
||||
)
|
||||
)
|
||||
(xor
|
||||
(call %init_peer_id% ("callbackSrv" "response") [comp.$.reply!])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
`;
|
||||
return callFunction(
|
||||
args,
|
||||
{
|
||||
functionName: "sayHello",
|
||||
returnType: {
|
||||
tag: "primitive",
|
||||
},
|
||||
argDefs: [
|
||||
{
|
||||
name: "targetPeerId",
|
||||
argType: {
|
||||
tag: "primitive",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "targetRelayPeerId",
|
||||
argType: {
|
||||
tag: "primitive",
|
||||
},
|
||||
},
|
||||
],
|
||||
names: {
|
||||
relay: "-relay-",
|
||||
getDataSrv: "getDataSrv",
|
||||
callbackSrv: "callbackSrv",
|
||||
responseSrv: "callbackSrv",
|
||||
responseFnName: "response",
|
||||
errorHandlingSrv: "errorHandlingSrv",
|
||||
errorFnName: "error",
|
||||
},
|
||||
},
|
||||
script
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user