# new Asset(code, issuer)
Parameters:
Name | Type | Description |
---|---|---|
code |
string
|
The asset code. |
issuer |
string
|
The account ID of the issuer. |
Classes
Methods
# _toXDRObject(xdrAsset) → {xdr.Asset|xdr.ChangeTrustAsset|xdr.TrustLineAsset}
Returns the xdr object for this asset.
Parameters:
Name | Type | Description |
---|---|---|
xdrAsset |
xdr.Asset
|
xdr.ChangeTrustAsset
|
The asset xdr object. |
XDR Asset object
xdr.Asset
|
xdr.ChangeTrustAsset
|
xdr.TrustLineAsset
# contractId(networkPassphrase) → {string}
Returns the would-be contract ID (C...
format) for this asset on a given
network.
Parameters:
Name | Type | Description |
---|---|---|
networkPassphrase |
string
|
indicates which network the contract ID should refer to, since every network will have a unique ID for the same contract (see Networks for options) |
the strkey-encoded (C...
) contract ID for this asset
string
# equals(asset) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
asset |
Asset
|
Asset to compare |
true if this asset equals the given asset.
boolean
# getAssetType() → {string}
Asset type. Can be one of following types:
native
,credit_alphanum4
,credit_alphanum12
, orunknown
as the error case (which should never occur)
string
# getRawAssetType() → {xdr.AssetType}
the raw XDR representation of the asset type
xdr.AssetType
# isNative() → {boolean}
true if this asset object is the native asset.
boolean
# toChangeTrustXDRObject() → {xdr.ChangeTrustAsset}
Returns the xdr.ChangeTrustAsset object for this asset.
XDR asset object
xdr.ChangeTrustAsset
# toTrustLineXDRObject() → {xdr.TrustLineAsset}
Returns the xdr.TrustLineAsset object for this asset.
XDR asset object
xdr.TrustLineAsset
# toXDRObject() → {xdr.Asset}
Returns the xdr.Asset object for this asset.
XDR asset object
xdr.Asset
# static compare(assetA, assetB) → {number}
Compares two assets according to the criteria:
- First compare the type (native < alphanum4 < alphanum12).
- If the types are equal, compare the assets codes.
- If the asset codes are equal, compare the issuers.
Parameters:
-1
if assetA < assetB, 0
if assetA == assetB, 1
if assetA > assetB.
number
# static fromOperation(assetXdr) → {Asset}
Returns an asset object from its XDR object representation.
Parameters:
Name | Type | Description |
---|---|---|
assetXdr |
xdr.Asset
|
The asset xdr object. |