Channel Factory not registered when trying to store a SharedString within root SharedDirectory - fluid-framework

I tried to create and store a new SharedString DDS on my root SharedDirectory with following code:
protected async initializingFirstTime() {
const text = SharedString.create(this.runtime);
this.root.set("text", text.handle)
}
When I run the app, I get following error in JavaScript console:
app.ts:49 Error: Channel Factory https://graph.microsoft.com/types/mergeTree not registered
at new LocalChannelContext (localChannelContext.js:19)
at FluidDataStoreRuntime.createChannel (dataStoreRuntime.js:169)
at Function.create (sharedString.js:33)
at DiceRoller.<anonymous> (dataObject.ts:43)
at Generator.next (<anonymous>)
at dataObject.ts:4
at new Promise (<anonymous>)
at ./src/dataObject.ts.__awaiter (dataObject.ts:4)
at DiceRoller.initializingFirstTime (dataObject.ts:42)
at DiceRoller.initializeInternal (pureDataObject.js:87)

You need to ensure you are registering all DDS types with your Data Object Factory.
public static readonly factory = new DataObjectFactory(
SomeFluidObject.Name,
SomeFluidObject,
[
SharedString.getFactory(),
],
{},
);

Related

Why is AxelSpringer Google PubSub library causing the error "Unable to detect a Project Id in the current environment"?

I am implementing GraphQL subscription based on this document using the PubSub Class. However,
the document also says:- The PubSub class is not recommended for
production environments, because it's an in-memory event system that
only supports a single server instance. After you get subscriptions
working in development, we strongly recommend switching it out for a
different subclass of the abstract PubSubEngine class. Recommended
subclasses are listed in Production PubSub libraries.
So, I chose the Google PubSub Library, the second option from the list.
In a file subscription.js, I wrote the following code:-
const { GooglePubSub } = require('#axelspringer/graphql-google-pubsub');
const pubsub = new GooglePubSub();
const UPDATE_PARKING = "UPDATE_PARKING";
module.exports = {pubsub, UPDATE_PARKING};
In the file named parking.queries.js, the Graphql is like this:-
type Subscription {
updateParking: Parking
}
In the file named parking.resolver.js, the Resolver is like this
const {pubsub, UPDATE_PARKING} = require("../utils/subscription");
Subscription: {
updateParking: {
subscribe: () => pubsub.asyncIterator(UPDATE_PARKING)
}
}
Now to publish the data in the service file named parking.service.js, I did this:-
const {pubsub, UPDATE_PARKING} = require("../utils/subscription");
.........................
.........................
.........................
pubsub.publish(UPDATE_PARKING, {updateParking: parkingDetail});
.........................
The above code runs fine. However, when I an trying to publish a new subscription, I am facing a strange problem. Let, me explain.
In the file subscription.js, I made the following changes:-
const { GooglePubSub } = require('#axelspringer/graphql-google-pubsub');
const pubsub = new GooglePubSub();
const UPDATE_PARKING = "UPDATE_PARKING";
const UPDATE_USER = "UPDATE_USER";
module.exports = {pubsub, UPDATE_PARKING, UPDATE_USER};
In the file named user.queries.js, the Graphql is like this:-
type Subscription {
updateUser: User
}
In the file named user.resolver.js, the Resolver is like this,
const {pubsub, UPDATE_USER} = require("../utils/subscription");
Subscription: {
updateUser: {
subscribe: () => pubsub.asyncIterator(UPDATE_USER)
}
}
In the service file user_subscription.service.js, I have the code like this:-
const {pubsub, UPDATE_USER} = require("../utils/subscription");
............................
............................
pubsub.publish(UPDATE_USER, {updateUser: newUserData});
............................
Whenever the code pubsub.publish(UPDATE_USER, {updateUser: newUserData}); is getting executed, I am getting this strange error:-
/var/www/example/html/node_modules/google-auth-library/build/src/auth/googleauth.js:89
throw new Error('Unable to detect a Project Id in the current environment. \n' +
^
Error: Unable to detect a Project Id in the current environment.
To learn more about authentication and Google APIs, visit:
https://cloud.google.com/docs/authentication/getting-started
at /var/www/example/html/node_modules/google-auth-library/build/src/auth/googleauth.js:89:31
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[nodemon] app crashed - waiting for file changes before starting...
However, whenever this code is executed pubsub.publish(UPDATE_PARKING, {updateParking: parkingDetail}); the above error doesn't happen.
What am I doing wrong?

Exception in fetchPairData() : call revert exception in method getReserves()

I am trying to call the "fetchPairData" function (https://uniswap.org/docs/v2/SDK/fetcher/) but I am getting the following error.
Error: call revert exception (method="getReserves()", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.1.2)
at Logger.makeError (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\#ethersproject\logger\lib\index.js:180:21)
at Logger.throwError (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\#ethersproject\logger\lib\index.js:189:20)
at Interface.decodeFunctionResult (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\#ethersproject\abi\lib\interface.js:289:23)
at Contract.<anonymous> (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\#ethersproject\contracts\lib\index.js:329:56)
at step (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\#ethersproject\contracts\lib\index.js:48:23)
at Object.next (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\#ethersproject\contracts\lib\index.js:29:53)
at fulfilled (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\#ethersproject\contracts\lib\index.js:20:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
reason: null,
code: 'CALL_EXCEPTION',
method: 'getReserves()',
errorSignature: null,
errorArgs: [ null ],
address: '0x80f836E71a6C92acebf6A49ad39038609c780070',
args: [],
transaction: {
data: '0x0902f1ac',
to: '0x80f836E71a6C92acebf6A49ad39038609c780070'
}
}
Relevant code:
const {ChainId, Token, TokenAmount, Fetcher, Pair, Route, Trade, TradeType, Percent} = require('#pancakeswap-libs/sdk');
const INPUT_TOKEN = new Token(ChainId.MAINNET,InputTokenAddr, 18);
const OUTPUT_TOKEN = new Token(ChainId.MAINNET, OutputTokenAddr, 18);
try {
pair = await Fetcher.fetchPairData(INPUT_TOKEN, OUTPUT_TOKEN, provider);
} catch (ex)
{
console.log("Debug.INPUT_TOKEN: " + JSON.stringify(INPUT_TOKEN));
console.log("Debug.OUTPUT_TOKEN: " + JSON.stringify(OUTPUT_TOKEN));
console.log("Debug.provider: " + JSON.stringify(provider));
console.log(ex)
pair = null;
}
Debug:
Debug.INPUT_TOKEN: {"decimals":18,"chainId":56,"address":"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"}
Debug.OUTPUT_TOKEN: {"decimals":18,"chainId":56,"address":"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56"}
Debug.provider: {"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_networkPromise":{},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"url":"https://bsc-dataseed.binance.org/"},"_nextId":45,"_eventLoopCache":{"detectNetwork":null,"eth_chainId":null},"_network":{"chainId":56,"name":"unknown"}}
I have verified that the swap works correctly in the pancakeswap web interface. It does not indicate route on the web, so it seems that it is a direct swap.
With other tokens the call returns what is expected. For example with the pair WBNB, BUSD.
I found for this error on another site with this comment
I faced the same issue and the problem was that I was trying to fetch
price for a pool that did not exist.
The pool exists. It has liquidity and it is also direct, it does not require a route.
The call revert exception happens when
the client doesn't receive a response
(no contract deployed on the address)
or when the contract code performs a revert.
pragma solidity ^0.8;
contract MyContract {
function foo() external view {
revert();
}
}
(Can also be when you're calling an undefined function and there's no fallback() in the contract)
Your question doesn't specify on which network you tried to perform the call, but there's no contract on the failing address on both mainnet and testnet.
So either your client app is trying to call this non-existing contract directly, or some contract in the chain of calls is trying to call it.
transaction: {
data: '0x0902f1ac',
to: '0x80f836E71a6C92acebf6A49ad39038609c780070'
}
me also facing the same issue for some tokens but i'm sure there is some issue in our end because some tokens have different routes for swapping. If token have different routes not direct swap that tokens will get same error.enter image description here

always failed to create a document when it has a Firestore Geopoint field when using Firebase rules unit testing library

I am tryin to perform testing to my security rules using #firebase/rules-unit-testing library using emulators
I have an Event class like this
class Event {
title: string
coordinate: FirebaseFirestore.GeoPoint
}
create an instance
const event = new Event("event title", new admin.firestore.GeoPoint(-6.931980, 107.559540))
and then I write testing for my security rules like this using Mocha
import * as firebase from "#firebase/rules-unit-testing";
function getFirestore(auth?: TokenOptions) {
return firebase.initializeTestApp({projectId: projectID, auth: auth}).firestore();
}
it("should create an event document", async () => {
const db = getFirestore(myAuth);
const ref = db.collection("events").doc("myEvent");
const event = new Event("event title", new admin.firestore.GeoPoint(-6.931980, 107.559540))
const eventData = { ...event};
const promise = ref.set(eventData);
await firebase.assertSucceeds(promise);
});
but I have error
FirebaseError: Function DocumentReference.set() called with invalid
data. Unsupported field value: a custom object (found in field
coordinate in document events/myEvent)
the error said that the coordinate property using custom object (i.e FirebaseFirestore.GeoPoint)
but I need to test my security rules. I have rules like this
request.resource.data.coordinate is latlng
so how do I test if a field is latlng or not but, I can't create a document which is a Firestore Geopoint?
is it a bug?
I have found the answer from thebrianchen in here
The issue here is that the web and admin SDKs have separate GeoPoint
classes that are not interoperable with each other. If you're using
the web SDK with initializeTestApp(), you'll have to the GeoPoint
class from the web SDK. In your case, you'll need to use the web SDK's
GeoPoint class:
so I have to change the way I create GeoPoint data. From
new admin.firestore.GeoPoint(-6.931980, 107.559540)
to be
import * as firebase from "#firebase/rules-unit-testing";
new firebase.firestore.GeoPoint(-6.931980, 107.559540)

DocuSign' requestJWTUserToken method errors out with 'Not Initialized"

I'm trying to implement the DocuSign JWT Auth following this code example: https://github.com/docusign/eg-01-node-jwt/blob/master/lib/dsJwtAuth.js
But I get this error when calling requestJWTUserToken():
Error: Not initialised
at Sign.update (crypto.js:99:16)
at Object.sign (/code/node_modules/jwa/index.js:159:23)
at Object.jwsSign [as sign] (/code/node_modules/jws/lib/sign-stream.js:32:24)
at Object.module.exports [as sign (/code/node_modules/jsonwebtoken/sign.js:190:16)
at generateAndSignJWTAssertion (/code/node_modules/docusign-esign/src/ApiClient.js:63:16)
at exports.requestJWTUserToken (/code/node_modules/docusign-esign/src/ApiClient.js:892:19)
at ConsentGateway.<anonymous> (/code/app/gateways/ConsentGateway.ts:73:53)
at Generator.next (<anonymous>)
at /code/app/gateways/ConsentGateway.ts:19:71
at new Promise (<anonymous>)
at __awaiter (/code/app/gateways/ConsentGateway.ts:15:12)
at ConsentGateway.getToken (/code/app/gateways/ConsentGateway.ts:64:16)
at ConsentGateway.<anonymous> (/code/app/gateways/ConsentGateway.ts:54:41)
at Generator.next (<anonymous>)
at /code/app/gateways/ConsentGateway.ts:19:71
at new Promise (<anonymous>)
at __awaiter (/code/app/gateways/ConsentGateway.ts:15:12)
at ConsentGateway.checkToken (/code/app/gateways/ConsentGateway.ts:46:16)
at ConsentGateway.<anonymous> (/code/app/gateways/ConsentGateway.ts:139:24)
at Generator.next (<anonymous>)
at /code/app/gateways/ConsentGateway.ts:19:71
at new Promise (<anonymous>)
at __awaiter (/code/app/gateways/ConsentGateway.ts:15:12)
at ConsentGateway.getTemplateList (/code/app/gateways/ConsentGateway.ts:132:16)
at ConsentService.<anonymous> (/code/app/services/ConsentService.ts:58:50)
at Generator.next (<anonymous>)
at /code/app/services/ConsentService.ts:19:71
at new Promise (<anonymous>)
the code calling the method looks like this:
private async getToken(reqId: string): Promise<any> {
try {
const pathToPrivateKey = fs.readFileSync(path.resolve('/code/app/gateways/', 'test.pem'));
this.dsApiClient.setOAuthBasePath(this.authServer);
const jwtToken = await this.dsApiClient.requestJWTUserToken(
this.integrationKey, // clientId
this.guidAccountId, // userId
'signature',
pathToPrivateKey,
10 * 60
);
const expiresAt = moment().add(jwtToken.body.expires_in, 's');
return { accessToken: jwtToken.body.access_token, tokenExpirationTimestamp: expiresAt };
} catch (e) {
this.logger.error(
'Consent Error', reqId, ['accessToken'], { status: e.response.body.errorCode, message: e.response.body.message }
);
}
}
I cannot find any documentation for the requestJWTUserToken method which makes this error hard to debug.
Is there anyone familiar with the JWT Auth flow in node that could help out with this?
Here are the things that you must ensure:
You have an Integration key (clientID) that is configured correctly.
You have an RSA Private key. that key was copied/pasted exactly as given to your configuration file. New lines must be preserved
Your URLs are matching the environment. Meaning you use account-d and demo.docusign.net for the sandbox env endpoints.
You need the userId which is a GUid for the user that would be impersonated. That user must consent to the application. You have to ensure you pass userId and not accountId and that it is for the same account that you would be using.
If you confirm all of this and still get an error - I would consider to use our code example to start. I don't see code in your question, but our code example should be a good way to start.

Error Message : InvalidKey: A key should contain at least a kind

I am getting following error while trying to update the entity in google cloud datastore:
InvalidKey: A key should contain at least a kind.
at keyToKeyProto (/Volumes/Drive B/dev/zapi/node_modules/#google-cloud/datastore/src/entity.js:696:11)
at Array.map (<anonymous>)
at DatastoreRequest.createReadStream (/Volumes/Drive B/dev/zapi/node_modules/#google-cloud/datastore/src/request.js:226:23)
at DatastoreRequest.get (/Volumes/Drive B/dev/zapi/node_modules/#google-cloud/datastore/src/request.js:461:8)
at /Volumes/Drive B/dev/zapi/node_modules/#google-cloud/common/build/src/util.js:681:32
at new Promise (<anonymous>)
at Datastore.wrapper [as get] (/Volumes/Drive B/dev/zapi/node_modules/#google-cloud/common/build/src/util.js:662:20)
at fetchEntity (/Volumes/Drive B/dev/zapi/node_modules/gstore-node/lib/model.js:204:36)
at Function.get (/Volumes/Drive B/dev/zapi/node_modules/gstore-node/lib/model.js:174:16)
at Promise (/Volumes/Drive B/dev/zapi/node_modules/gstore-node/lib/utils.js:39:35)
at new Promise (<anonymous>)
at Function.wrapper (/Volumes/Drive B/dev/zapi/node_modules/gstore-node/lib/utils.js:27:16)
at resolve (/Volumes/Drive B/dev/zapi/graphql/mutations/user/linkConsult.js:101:44)
I don't know why is this coming for.
Thanks in advance.
When you trying to access key and key is not available when no data available, it gives the error
"Error Message : InvalidKey: A key should contain at least a kind"
To avoid this error first make sure that [datastrore.KEY] is available.
Thanks
I want to add to this answer with a little more detail. Here are some other helpful points to investigate if you run into this error when using the datastore.save method. The entity needs the correct key property like the example below.
// remember to use the key method on the google data store instance
const entity = {
key: dataStore.key('Name of your Kind') // this is Kind property you see on the GCP dashboard,
data: {
example: 'this is an example',
...
}
};
// then save the entity
const dbResult = await dataStore.save(entity)

Resources