Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More β†’
Socket
Book a DemoInstallSign in
Socket

@automatedtf/slate

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automatedtf/slate

### πŸ“– Table of Contents - [πŸ‘‹ Introduction](#-introduction) - [πŸ”Œ Getting Started](#-getting-started) - [Parsing to an OfferArtifact](#parsing-to-an-offerartifact) - [The OfferArtifact Type](#the-offerartifact-type) - [ItemInstance](#iteminst

latest
Source
npmnpm
Version
0.0.25
Version published
Maintainers
1
Created
Source

Slate

πŸ“– Table of Contents

  • πŸ‘‹ Introduction
  • πŸ”Œ Getting Started
  • πŸ“š Helpful Resources

Introduction

Slate is a simple modular library to represent Steam trade offers using @automatedtf/sherpa in a standardised compact data object called an OfferArtifact; this format is optimised for archiving trade offers within a database.

πŸ”Œ Getting Started

You can install this module with npm within your project by running the command:

npm install @automatedtf/slate

Parsing to an OfferArtifact

This module exposes one function: parseToOfferArtifact.

const steamid: string = "76561198081082634"; // account of perspective offer object is seen from
const offer: TradeOffer = { ... }; // get from steam-tradeoffer-manager

const artifact: OfferArtifact = await parseToOfferArtifact(steamid, offer);

The OfferArtifact Type

The OfferArtifact type is the primary datatype you will be working with when interacting with this module.

type OfferArtifact = {

    // Carried over from TradeOffer type
    id?: string; // trade offer id
    message?: string; // trade message
    state: OfferState; // see OfferState enum in lib/types.ts

    // Own introduced fields
    created: number; // created at (unix timestamp)
    updated: number;  // last-updated (unix timestamp)
    expires: number; // expires at (unix timestamp)
    escrowEnds?: number; // time escrow complete (unix timestamp)
    sender: string; // steamid of sender
    recipient: string; // steamid of recipient
    itemsSending: ItemInstance[]; // Items being sent away from sender
    itemsReceiving: ItemInstance[]; // Items being received to the sender
} 

ItemInstance

The itemsSending and itemsReceiving field of OfferArtifact are both arrays of objects of the interface ItemInstance. This is an interface that is derived from @automatedtf/sherpa.

interface ItemInstance {
    appid: number;
    assetid: string;
    instanceid: string;
    classid: string;
    icon_url: string;
    sku: string;
    full_sku: string;
}

πŸ”— See @automatedtf/sherpa ItemInstance

Information Population with Sherpa

To provide sufficient item details, @automatedtf/sherpa is used to populate every item under itemsSending and itemsReceiving. Originally, the input TradeOffer object from steam-tradeoffer-manager will represent each item within itemsToGive and itemsToReceive as a TradeItem.

interface TradeItem {
    appid: number;
    contextid: string;
    assetid: string;
    classid: string;
    instanceid: string;
    ...
    descriptions: any[],
    ...
    tags: any[],
    tradable: boolean,
    ...
}

This may be insufficient to developers who may like e.g the icon_url of an item to quickly display the item visually on their website without making further API calls on-the-fly.

This is resolved by taking the TradeOffer object from and extracting the least but necessary fields of a TradeItem into an ItemInstance by using Catalog to represent item types and customisations as a single-string SKU and Sherpa to provide item instance information. This is all done as a TradeOffer is parsed to an OfferArtifact.

πŸ“š Helpful Resources

FAQs

Package last updated on 12 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts