How do I get Account Information Through Algorand TypeScript SDK? - smartcontracts

So Basically I'm trying to get Account Information.
Method: Algodv2accountInformation,
returns the AccountInformation type, but after calling .do()
.i.e
Algodv2accountInformation.do()
the return type is a more generic
<Promise<Record<string, any>>
What is the right way to make this api call but have it return right Information.
<AccountInformation>

I just checked their docs,
It is confusing as docs says it returns
<AccountInformation>
Here's Link to docs
<AccountInformation> is encapsulating request, not response.
What you can do it leverage class,
as it extends Base Class which does takes in Record<string,any> as input.
So the JSON you get from running .do() on .
accountInformation(account.addr).do():
{
address: 'LFNDB6ADWN7M3HFA7TSBKW4ZV7Q3TAJ2TWAGHH35WFGQAVGTJGFVJXQASI',
amount: 10000000,
'amount-without-pending-rewards': 10000000,
'apps-local-state': [],
'apps-total-schema': { 'num-byte-slice': 0, 'num-uint': 0 },
assets: [],
'created-apps': [],
'created-assets': [],
'min-balance': 100000,
'pending-rewards': 0,
'reward-base': 0,
rewards: 0,
round: 32,
status: 'Offline',
'total-apps-opted-in': 0,
'total-assets-opted-in': 0,
'total-created-apps': 0,
'total-created-assets': 0
}
Could be passed to Account(Record<String, any>) as follows:
new algosdk.modelsv2.Account(info):
Account {
address: 'LFNDB6ADWN7M3HFA7TSBKW4ZV7Q3TAJ2TWAGHH35WFGQAVGTJGFVJXQASI',
amount: 10000000,
amountWithoutPendingRewards: undefined,
minBalance: undefined,
pendingRewards: undefined,
rewards: 0,
round: 32,
status: 'Offline',
totalAppsOptedIn: undefined,
totalAssetsOptedIn: undefined,
totalCreatedApps: undefined,
totalCreatedAssets: undefined,
appsLocalState: undefined,
appsTotalExtraPages: undefined,
appsTotalSchema: undefined,
assets: [],
authAddr: undefined,
createdApps: undefined,
createdAssets: undefined,
participation: undefined,
rewardBase: undefined,
sigType: undefined,
attribute_map: {
address: 'address',
amount: 'amount',
amountWithoutPendingRewards: 'amount-without-pending-rewards',
minBalance: 'min-balance',
pendingRewards: 'pending-rewards',
rewards: 'rewards',
round: 'round',
status: 'status',
totalAppsOptedIn: 'total-apps-opted-in',
totalAssetsOptedIn: 'total-assets-opted-in',
totalCreatedApps: 'total-created-apps',
totalCreatedAssets: 'total-created-assets',
appsLocalState: 'apps-local-state',
appsTotalExtraPages: 'apps-total-extra-pages',
appsTotalSchema: 'apps-total-schema',
assets: 'assets',
authAddr: 'auth-addr',
createdApps: 'created-apps',
createdAssets: 'created-assets',
participation: 'participation',
rewardBase: 'reward-base',
sigType: 'sig-type'
}
}
And! Voilla! you've got your account model object!
Actually there should be some method .getModel(),
I'll create a PR, as this should be part of SDK.

Related

Add multiple v.slots with a v-for with Bootsrtap-Vue

My table data has nested objects, so I need to use a v-slot to render it correctly on a table. The thing is that the table columns depend on the lenght of another array.
I tried using a v-for outside my v-slot, but then I get an error telling me that the v-slots need to be directly under the root level inside its component.
<div v-for="plant in stockTable.plants" :key="plant.key">
<template v-slot:cell(plant.name)="row">
</template>
</div>
My data looks like this:
{ key: 1, description: 'Stock-1', plants: [{ key: 1, name: 'Plant-1', inventory: [{ type: 'Physical', stock: 875 }, { type: 'Virtual', stock: 1540 }] }, { key: 2, name: 'Plant-2', inventory: [{ type: 'Physical', stock: 458 }, { type: 'Virtual', stock: 525 }] }] }
And the array it depends on it this one:
plants: [{ key: 1, name: 'Plant-1' }, { key: 2, name: 'Plant-2' }]
It has to create columns with the second array, and show the corresponding data of the first one.
Edit: This is a mock up of what I'm trying to do
Found another similar question wich was correctly answered. For what I understand, the issue had to do with some string interpolation.
Here's the answer:
https://stackoverflow.com/a/58143362/11932235

I don't know why it results in `undefined` when I used tweet_mode='extended' in Twitter API get function() on Node.js

I have a few question.
I would like to get twitter full-text, so I used get() function but it truncate when it returned.
like this :
'RT #Journeyto100k_: Google was not the first search engine, but quickly became the standard. Internet explorer even came preloaded on every…',
'RT #ApolloCurrency: Check out our latest blog post! In case you missed it. \n\n"Apollonauts Unveil Wiki…',
I used tweet_mode ='extended' and retweeted_status to get property full_text
but it didn't work.
let keyword1 = T.get('search/tweets', {
q: 'Crypto Currency crypto currency since:2019-04-15', count: 100, request: tweet_mode='extended' },async function (err, data, response) {
let addr;
let text = data.statuses.map(retweeted_status=>retweeted_status.text);
console.log(text);
I expect the output of get() result to be full-text, but the actual output is text truncated.
+ In further more,
data obejct has 'full-text' property, but it returns text truncated.
like this :
{ created_at: 'Fri Apr 19 04:22:40 +0000 2019',
id: 1119093934167212000,
id_str: '1119093934167212032',
full_text:
'RT #Drife_official: DRIFE presented at Trybe’s first annual Endless Dappathon\n #trybe_social \n#cryptocurrency #drife…',
truncated: false,
display_text_range: [Array],
entities: [Object],
metadata: [Object],
source:
'Twitter Web Client',
in_reply_to_status_id: null,
in_reply_to_status_id_str: null,
in_reply_to_user_id: null,
in_reply_to_user_id_str: null,
in_reply_to_screen_name: null,
user: [Object],
geo: null,
coordinates: null,
place: null,
contributors: null,
retweeted_status: [Object],
is_quote_status: false,
retweet_count: 330,
favorite_count: 0,
favorited: false,
retweeted: false,
possibly_sensitive: false,
lang: 'en' },
I found solution.
T.get('search/tweets', {
q, count, tweet_mode: 'extended'},async function (err, data, response) {
let text = data.statuses.map(status=>status.full_text);
I have missed full_text instead of text.
and ONLY RT(retwitt)is truncated. another didn't truncate.

How to define an example request body containing an array of complex objects in Swagger?

I am trying to write the Swagger spec for a service that posts an array of objects as request body. I would like the user to be able to test the service with a specific set of multiple different complex objects in the array as the default sample inputs.
So far I have the following code defining the service and complex object:
paths:
/myService
post:
summary: test 123
description: test 123
parameters:
- name: bodyParamsObject
description: 'Object containing any / all params in the body'
in: body
required: true
schema:
properties:
data:
$ref: '#/definitions/myInputArray'
responses:
200:
description: OK
schema: myOutputArray
definitions:
myInputArray:
type: array
items:
$ref: '#/definitions/myComplexObject'
myOutputArray:
type: array
items:
$ref: '#/definitions/myComplexObject'
myComplexObject:
type: object
properties:
description:
type: string
example: 'Example Item'
size:
example: 552
type: integer
format: int32
hasAdditionalProperties:
type: boolean
example: true
The output array is coming back correctly, but there is only one item in the model schema.
How can I make the sample request body contain multiple different items in the array?
I was able to solve this by using the example property on the object definition and filling it with the array in json.
definitions:
myInputArray:
type: array
items:
$ref: '#/definitions/myComplexObject'
example: [
{
"description": "Example Item 1",
"hasAdditionalProperties": true,
"size": 750,
},
{
"description": "Another example",
"hasAdditionalProperties": false,
"size": -22,
},
{
"description": "Last one",
"hasAdditionalProperties": true,
"size": 0,
}
]
myComplexObject:
type: object
properties:
description:
type: string
example: 'Example Item'
size:
example: 552
type: integer
format: int32
hasAdditionalProperties:
type: boolean
example: true

Is it possible to create dummy bidders to test header bidding?

I am a developer curious about header bidding. I don't have demand partners. But I want to test the solution I build. Is it possible to create dummy bidders? Is there any open source code that can mimic a bidder?
You can use appnexus's dummy bidder used in their examples on prebid.org.
It's also available on jsfiddle
Here's the complete configuration:
var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
sizes: [[300, 250], [300,600]],
bids: [{
bidder: 'appnexus',
params: {
placementId: '10433394'
}
}]
},{
code: 'div-gpt-ad-1460505661639-0',
sizes: [[728, 90], [970, 90]],
bids: [{
bidder: 'appnexus',
params: {
placementId: '10433394'
}
}]
}];
Of course you could also take some else's live configuration, but the owners won't be happy to see your dummy bids

Can't get the elements of the sencha store

So I have a store
Ext.define('APN.store.BackupShow', {
extend: 'Ext.data.Store',
requires: [
'APN.model.ScheduledShow'
],
config: {
model: 'APN.model.ScheduledShow',
proxy: {
type: 'ajax',
url: '',
reader: {
type: 'xml',
record: 'item',
rootProperty: 'xml'
}
}
},
getShow: function () {
if (this.getData().length greater 1) # by some reason stackoverflow didn't allow me to put greater sign in here;
return null;
// Copy field data across as wrong field is popped.
this.getAt(0).set("listimage", this.getAt(0).get("onairimage"));
this.getAt(0).set("isbackup", "true");
return this.getAt(0);
}
});
And when I'm trying to call the first element of the store I get undefined, however the element exists in the store:
(0) console.log(backupShowStore);
(1) console.log(backupShowStore.data);
(2) console.log(backupShowStore.getData().all);
(3) console.log(backupShowStore.getData().all.length);
(4) console.log(backupShowStore.getData().all.getAt(0));
I got back:
(1)
Class
_data: Class
_model: function () {
_modelDefaults: objectClass
_proxy: Class
_remoteFilter: false
_remoteSort: false
_storeId: "backupShow"
_totalCount: null
config: objectClass
data: Class
_autoFilter: true
_autoSort: true
_filterRoot: "data"
_sortRoot: "data"
all: Array[1]
0: Class
_data: Object
data: Object
bufferingProgress: null
contentlink: null
description: null
facebooklink: "http://www.facebook.com/mixmelbourne"
id: "ext-record-45"
isbackup: null
listimage: null
onairimage: "http://arntrnassets.mediaspanonline.com/radio/mxm/53808/on-air-default_v3.png"
showbody: "Melbourne's widest variety from 2K to today, Mix101.1 with Chrissie & Jane waking up Melbourne weekdays from 6am."
showbyline: "The widest variety from 2K to today"
showcontentxml: null
showemail: null
showname: "Mix 101.1"
showschedule: null
smallimage: null
title: null
twittername: "mixmelbourne"
__proto__: Object
id: "ext-record-45"
internalId: "ext-record-45"
modified: Object
phantom: true
raw: item
stores: Array[1]
__proto__: TemplateClass
length: 1
__proto__: Array[0]
(2)
_autoFilter: true
_autoSort: true
_filterRoot: "data"
_sortRoot: "data"
all: Array[1]
config: objectClass
dirtyIndices: true
getKey: function (record) {
indices: Object
initConfig: function (){}
initialConfig: Object
items: Array[1]
keys: Array[1]
length: 1
map: Object
__proto__: TemplateClass
(3)
Array[1]
0: Class
length: 1
__proto__: Array[0]
(4)
0
(5)
Uncaught TypeError: Object [object Array] has no method 'getAt'
Which is understandable for (5) as array doesn't have method getAt, however the store doesn't have any items and that is indicated by (4) where the array of getData elements equals to 0...
Am very confused at this point of time with Sencha Touch Framework and how to get the first element of an array of elements
Why not just use the Ext.data.Store.first() method.
I have found I am typically a happier developer when I use the methods provided by the api. On the rare occasion that I need something not provided I will navigate the Sencha Objects myself but I really try not to.
Let me know if and why that solution might not work and I'll try to find something else for you.