mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-04 18:00:18 +00:00
Using polyfill for Buffer in browsers (#129)
This commit is contained in:
parent
976cd0435c
commit
d860ea6dec
2
package-lock.json
generated
2
package-lock.json
generated
@ -14,7 +14,9 @@
|
||||
"@fluencelabs/avm-runner-background": "0.1.2",
|
||||
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
||||
"async": "3.2.0",
|
||||
"browser-or-node": "^2.0.0",
|
||||
"bs58": "4.0.1",
|
||||
"buffer": "^6.0.3",
|
||||
"cids": "0.8.1",
|
||||
"it-length-prefixed": "3.0.1",
|
||||
"it-pipe": "1.1.0",
|
||||
|
@ -28,6 +28,7 @@
|
||||
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
||||
"async": "3.2.0",
|
||||
"bs58": "4.0.1",
|
||||
"buffer": "^6.0.3",
|
||||
"cids": "0.8.1",
|
||||
"it-length-prefixed": "3.0.1",
|
||||
"it-pipe": "1.1.0",
|
||||
@ -40,7 +41,8 @@
|
||||
"peer-id": "=0.15.4",
|
||||
"rxjs": "^7.3.0",
|
||||
"ts-pattern": "^3.3.3",
|
||||
"uuid": "8.3.0"
|
||||
"uuid": "8.3.0",
|
||||
"browser-or-node": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua": "^0.5.3-258",
|
||||
|
4
src/internal/Buffer.ts
Normal file
4
src/internal/Buffer.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { isBrowser } from 'browser-or-node';
|
||||
import { Buffer as BufferPolyfill } from 'buffer';
|
||||
|
||||
export default isBrowser ? BufferPolyfill : Buffer;
|
@ -26,6 +26,7 @@ import PeerId from 'peer-id';
|
||||
import { Multiaddr } from 'multiaddr';
|
||||
import { all as allow_all } from 'libp2p-websockets/src/filters';
|
||||
import { Connection } from 'libp2p-interfaces/src/topology';
|
||||
import Buffer from './Buffer';
|
||||
|
||||
export const PROTOCOL_NAME = '/fluence/particle/2.0.0';
|
||||
|
||||
|
@ -30,6 +30,7 @@ import { AvmRunner, InterpreterResult, LogLevel } from '@fluencelabs/avm-runner-
|
||||
import { AvmRunnerBackground } from '@fluencelabs/avm-runner-background';
|
||||
import { defaultSigGuard, Sig } from './builtins/Sig';
|
||||
import { registerSig } from './_aqua/services';
|
||||
import Buffer from './Buffer';
|
||||
|
||||
/**
|
||||
* Node of the Fluence network specified as a pair of node's multiaddr and it's peer id
|
||||
|
@ -20,6 +20,7 @@ import { CallResultsArray, LogLevel } from '@fluencelabs/avm-runner-interface';
|
||||
import log from 'loglevel';
|
||||
import { ParticleContext } from './commonTypes';
|
||||
import { dataToString, jsonify } from './utils';
|
||||
import Buffer from './Buffer';
|
||||
|
||||
export class Particle {
|
||||
id: string;
|
||||
|
@ -18,7 +18,7 @@ import log from 'loglevel';
|
||||
import { CallServiceData, CallServiceResult, CallServiceResultType, ResultCodes } from './commonTypes';
|
||||
import { FluencePeer } from './FluencePeer';
|
||||
import { Particle, ParticleExecutionStage } from './Particle';
|
||||
import { LogLevel as AvmLoglevel } from '@fluencelabs/avm-runner-interface';
|
||||
import Buffer from './Buffer';
|
||||
|
||||
export const MakeServiceCall = (fn: (args: any[]) => CallServiceResultType) => {
|
||||
return (req: CallServiceData): CallServiceResult => {
|
||||
|
Loading…
Reference in New Issue
Block a user