How to Import an existing smart contract into new collection on opensea? it seems the function is close - collections

How to Import an existing smart contract into new collection on opensea?
It seems the function is close.
Thx
I try to find some API, but failes

Related

Add replicationRegions to an imported DynamoDB table via CDK?

I have a dynamodb table that was created via console and I want to enable multi-region support by adding to the list of replicationRegions using CDK.
After importing the original table using:
const table = Table.fromTableArn(this, "ImportedTable", "arn:aws:dynamodb...");
I realized I did not have access to the tables replicationRegions field as I would when creating new one.
Is there a way add to the list of replicationRegions on an imported dynamodb table using CDK?
Yes, but use cdk import instead of Table.fromTableArn.
The fromSomethingArn-type methods create *read-only* references to an external resource.* You can't use these to modify a resource. The ISomething interface constructs these methods return are useful for things like creating new permissions and targets.
The cdk import command is preview functionality to properly import existing resources into a CDK stack. A DynamoDB Table is a resource type that supports import operations. Once this one-time import completes, the "adopting" CDK stack can modify the "imported" table like any other, say, by adding replication regions.
In other words, The CDK can only modify resources it owns. To make ad-hoc modifications to an existing resource without permanently "adopting" it, use the SDKs instead.
* Earlier versions of the CDK docs did call these from... methods "importing" operations, but have been updated to use the less ambiguous term "referencing".

What's the reason of using useStore in vuex4

Hey would like to know the reason :)
Why import the useStore function instead of importing directly the /store/index.js file
https://next.vuex.vuejs.org/guide/composition-api.html
Seems like it does the same
useStore uses inject (provide/inject api) to access the store. This means that passing the store from another file/dependency is not needed. It is preferred only because it is consistent thematically with the composition API (hooks).

How to use FieldValue ServerTimestamp in TypeScript data model?

I'm using TypeScript to define the data models for my documents in Firebase. When the document is being created the createdOn field will be the server timestamp sentinal, but otherwise it is a date. For example...
export interface Post<MODE extends 'create' | 'read'> {
comment: string;
createdOn: MODE extends 'create' ? FieldValue : Date;
}
I don't know how to properly define and assign to the createdOn property. First, I'm not really sure which firebase module to load the FieldValue type from. The best I could do was this and this seems a bit hokey...
import * as firebase from 'firebase';
type FieldValue = firebase.default.firestore.FieldValue;
export const SERVER_TIMESTAMP = firebase.default.firestore.FieldValue.serverTimestamp();
And then when I use it, this is what happens...
// Fails when used within cloud function
// Detected an object of type "FieldValue" that doesn't match the
// expected instance (found in field "createdOn"). Please ensure
/// that the Firestore types you are using are from the same NPM package.
post.createdOn = SERVER_TIMESTAMP;
// But this works within cloud function
post.createdOn = admin.firestore.FieldValue.serverTimestamp();
Are the types of FieldValue different when called from within a cloud function and on the client? Can I simply import this type from some module that works from both cloud functions and client?
I think this is a known limitation confusing issue with the javascript SDKs.
https://github.com/firebase/firebase-js-sdk/issues/4246
If you are creating an item in Firestore from an admin app you need to use a different "serverTimestamp" object than when creating one from a client app.
Firebase has quite a few products in their lineup so it's not too intuitive and this can cause confusion. Here you can view all of the products and you can view how to properly implement each library.
In your case it seems you're missing firestore which you can import using:
import * as firebase from 'firebase/app';
import 'firebase/firestore';
Then you are able to use the Field value like so:
const timestamp = firebase.firestore.FieldValue.serverTimestamp();
Here is more information on Field values.

Using custom key in firestore Vue

I am new at using cloud firestore and Vue.
I am trying to use custom key, instead of it's generated Id.
I tried using set()
But, received error:
set() is not a function
Can someone help out, how to use it in Vue?
Thank you in advance
Assuming you have a ready project and imported the JS SDK and the firestore package:
import firebase from 'firebase/app';
import 'firebase/firestore';
First, declare a reference to a collection
const ref = firebase.firestore().collection('cars')
Then, you can set a new document passing an object to the set() function
ref.doc('my_custom_key').set({color: 'red'})

Passing value between two components in angular2-meteor project

I am using angular2-meteor.
When I try to pass a value between two components (when the value change in the first component, create an event in second component and use this new value), I have two ways right now:
One way is meteor way: using this.autorun and Session.get.
Another way is angular2 way: using Injectable service with EventEmitter.
Which way should be prior? Or is there any other better way? Thanks
Now I used angular2-meteor a while.
Although the angular2-meteor tutorial has no example so far about using or choosing Angular 2 service or Meteor Session.
But I feel angular 2 takes the lead in the front end, while meteor makes reactivity easier and also handle all back end things.
So I went with angular2 way using service to share between components. And service is very powerful like #todd-w-crone said.
If anyone has better answer, I will switch to accept that one.
I find it practical to create a new service called App.states.ts which is accessed globally and mimics Session (get / set).
I commonly import this service to all necessary components to get or set new value such as User.status, company.profile, lastProduct, etc.
Since this service is #injectable it can also make use of other services, in case a value hasn't been set already.
This allows me to ask for a variable in a component appState.getLastModifiedItem(), then in app.states.ts I'll write this function to pass this.modifiedItem or either:
Request another service item.service.ts to fetch data
Call another function with itemCollection.findOne({...}) and return such value.
You can configure Mongo queries as you want and either store static data in appState or keep subscription items in appState.
Do take into consideration that all subscriptions handled by an #injectable within a component are imported by such component. Be wary of conflicting subscriptions between components/services.

Resources